Jam

What is Jam?

Jam is an open-source API that generates DeFi operations. Today, it's primarily aimed at ERC-4337 applications. Its goal is to enable developers to easily offer a wide variety of DeFi products through a simple API while making DeFi more accessible to end users. With Jam, developers can request execution of a specific DeFi operation. In return, they receive the calldata that consolidates all the necessary steps into a single transaction.

Example: Going from token A to a staked liquidity pool of tokens B and C

We at Picnic have been working with various DeFi integrations and felt the hurdles of maintaining this kind of infrastructure. We believe the best way to move forward is to turn this into a public good.

The project has been granted an Ethereum Foundation grant during the ERC-4337 Account Abstraction grant round. [article]

API Structure

Basic strategies

This is the simplest way to interact with the API. In it, you specify from which assets you’d like to start and which assets you’d like to end up with.

These strategies require that assets (for instance tokens, pools, vaults, or any other type of on-chain asset) be previously registered and be an assigned an ID (not to be confused with its address).

Example: one-to-one swap

Let’s go through a few examples, starting with the simplest one:

Here our intention is to convert 1000000 units of USDC (1.0 USDC) into WETH. The fraction parameter indicates, relative to all assets on outputAllocation, how much of its value should correspond to that asset. In this case, a fraction of 1 indicates that the totality of the output should be converted into WETH.

We can expect an output such as the following:

In order to execute the above transaction, one requires just the address and transactionData. The transaction data is customized to the requested walletAddress, as several operations require the wallet address to be specified.

Example: 1-to-1 stake into pool

A slightly more intricate use-case is to specify assets with more complex behaviours.

As can be seen the second strategy is more complex and, without transaction batching, would have required several separate transactions.

Some notes about executing calldata

It’s important to note that transaction batching requires being executed in a smart wallet with delegatecall support.

Stores

stores, which start numbering from 0, act as placeholders for intermediate transaction amounts. They are always used in conjunction with storeOperations. These operations (explained in detail here (TO BE LINKED) can, for instance, take a value from a store and replace on a specified position on the respective stepEncodedCall, or take the result a function and add that value to a store.

This mechanism exists due to the unknown nature of each step prior to its actual execution, and our desire to always ensure that a chain of transactions allow for a precise assignment of the end result. In addition to this, oftentimes the input amount of one transaction depends on the exact output amount of the previous transaction as well as on-chain calculations.

Observations

  1. Picnic has been adopting a similar architecture for its current users. The current structure closely reflects the “basic strategies”. The “advanced strategies” are an ongoing process and will require some iteration before the exact data is matured.

  2. In the same spirit as the previous point, in the existing smart contracts used by Picnic (https://github.com/usePicnic/picnic-contracts), the exact amounts are replaced using special-purpose bridges. For Jam, we will experiment with stores that replace pre-specified slots on calldata for each step to replace with exact asset amounts.

  3. The advanced strategies will require extensive work on specification and testing, in order to allow operations such as borrow and flashloans which so far are not present on Picnic. We will share more of these details as we mature the architecture.

FAQ

What wallet implementations will be supported?

For Jam’s transaction batching to work, the wallet needs to support DELEGATECALL. In principle, Jam's generated transactions will work out of the box with:

Can I contribute to Jam?

Absolutely! We're in the early stages of Jam's development, and while we're still structuring our contribution guidelines, please reach out, we’d be pleased to work together!

How is the plan moving forward for Jam?

Please check the roadmap to see future plans.

Twitter: https://twitter.com/usePicnic

Github: https://github.com/usePicnic/jam

Discord: https://discord.gg/MNV7RXm6DD

Email: [email protected]

Last updated