Router
Generated transactions are executed using the Router smart contract.
Introduction
Requests made to the Jam API will be tailed to be executed on the Router
contract. It is what enables execution of complex, multi-step DeFi transactions in a single call.
This documentation focuses on the runSteps
function and its data structures.
Functions
Executes a sequence of steps, each comprising a call to another contract and potentially modifying an array of "stores."
Parameters
steps
: An array ofStep
structs that represent the steps in the multi-step transaction.stores
: An array of uint256 numbers that serve as a store for values that can be used in the transaction steps.
Conditions
Must be invoked using
DELEGATECALL
.The
steps
array must not be empty.
Behavior
Executes the steps in sequence, modifying the calldata and using the
stores
as needed.Reverts the transaction if any of the steps fail.
Data structures
Step
Struct for representing a transaction step.
Fields
stepAddress
: The target contract address for this step.stepEncodedCall
: ABI-encoded calldata to be passed to the target contract.storeOperations
: An array ofStoreOperation
structs detailing any store-related modifications required for this step.
StoreOperation
Struct that describes how to operate on stores or results of steps.
storeOpType
: A numerical code representing the type of store operation, determined by the followingenum
:
Type
RetrieveStoreAssignValue
:Retrieve store value at
storeNumber
, multiply byfraction
and setvalue
Type
RetrieveStoreAssignCall
:Retrieve store value at
storeNumber
, multiply byfraction
and setoffset
atstepEncodedCall
Type
RetrieveResultAssignStore
:Retrieve result value at
offset
of function's result and add it to store atstoreNumber
Type
RetrieveResultSubtractStore
:Retrieve result value at
offset
of function's result and subtracts it from store atstoreNumber
Type
RetrieveStoreAssignValueSubtract
:Retrieve store value at
storeNumber
, multiply byfraction
and setvalue.
Subtracts calculated value from store.
Type
RetrieveStoreAssignCallSubtract
:Retrieve store value at
storeNumber
, multiply byfraction
and setoffset
atstepEncodedCall
. Subtracts calculated value from store.
Type
SubtractStoreFromStore
:Subtracts store value at store
storeNumber
from store atoffset
Examples
Examples will be added here.
Source code
Last updated