1delta contract entrypoiny

Our smart contract has a single call entrypoint for external calls.

deltaCompose(bytes) is the trigger to call a batch operation in our composer contracts.

Aside of approval & entry flags, the contract is stateless.

The deltaCompose function consumes byte-encoded operations that are sequentially executed.

The operations themselves are categorized via human-readable enum values as follows

enum ComposerCommands {
    SWAPS; // swap paths
    EXT_CALL; // external calls (`deltaForwardCompose`)
    EXT_TRY_CALL; // external call with fallback (callForwarder only)
    LENDING; // any lending operation (deposit, borrow, withdraw, repay)
    TRANSFERS; // pulling, sending and approving
    PERMIT; // execute token or lender permit
    FLASH_LOAN; // execute flash loans on common targets
    ERC4626; // vault operations
    GEN_2025_SINGELTONS; // balancer V3 and Uniswap V4 operations
    BRIDGING; // bridge execution (callForwarder only)
}

To create an operation OPERATION with that has e.g. the following parameters

Offset Length (bytes) Description
0 20 underlying address
20 16 amount uint128
36 20 receiver address
56 20 comet address

the caller has to encode it as follows:


bytes memory operation = abi.encodePacked(
    uint8(ComposerCommands.[OPERATION]),
    address(underlying),
    uint128(amount),
    address(receiver),
    address(comet)
)

composer.deltaCompose(operation);

It is designed so that the caller can always append any sort of operations.


bytes memory operation = abi.encodePacked(
    operation0, // (as bytes memory) add another operation to the start
    uint8(ComposerCommands.[OPERATION]), // then just continue the next one
    address(underlying),
    uint128(amount),
    address(receiver),
    address(comet)
)

composer.deltaCompose(operation);

Typically the calldata will be built in TypeScript or Rust, we write the descriptions in Solidity to have it consistent across all frameworks, e.g. for using viem, it would look like this:


const operations = solidityPack(
    ["bytes", "uint8", "address", "uint128", "address", "address"],
    [operation0, ComposerCommands.[OPERATION], underlying amount, receiver, comet]
)

const contractCall = encodeFunctionData({
  abi: composerAbi,
  functionName: "deltaCompose",
  args: [operations]
})
© 1delta https://1delta.io/

Found an error in the docs? The source code can be found here. Please feel free to edit and contribute a merge request
Modified at: 2025-08-16 19:10:42

results matching ""

    No results matching ""