Architectural overview
Overview
Jam's off-chain TypeScript backend assists in generating blockchain transactions tailored for multi-step DeFi operations. The backend performs computations to output a series of actions (transaction steps) to be executed in a batch, which will then be invoked via an ERC-4337-compatible wallet using DELEGATECALL
. This documentation covers the key classes and functions exposed by the backend for transaction generation.
AssetStore
The AssetStore
class is responsible for managing and accessing information about different assets (tokens).
Constructor
Parameters
assets
: An array ofAsset
objects containing information like asset id, chain id, symbol, etc.
Asset
A type directly derived from asset' JSON objects, with the following parameters:
generateTransaction
The function takes in details about input and output assets and generates a series of steps for a multi-step transaction.
Syntax
Parameters
chainId
: Chain ID to specify on which blockchain network the transaction should occur.walletAddress
:assetStore
: An instance of theAssetStore
class to fetch details about assets.inputAllocation
: An array describing which assets and how much of them should be used as input.outputAllocation
: An array describing how the output should be allocated among different assets.
Types
AbsoluteAllocationItem
Type used to define an item in the input allocation array.
assetId
: Unique identifier for the asset.amountStr
: The amount of the asset in string format, compatible with BigNumber libraries.
FractionAllocationItem
Type used to define an item in the output allocation array.
assetId
: Unique identifier for the asset.fraction
: A float (0-1) representing the fraction of the output asset.rewards
: Optional, additional nested FractionAllocationItems for cases like staking rewards.
Utility Types
AbsoluteAllocation
: Array ofAbsoluteAllocationItem
.FractionAllocation
: Array ofFractionAllocationItem
.
Last updated