Data Type

The structures and enumerations used in Protocolink contracts.

enum WrapMode {
    NONE,
    WRAP_BEFORE,
    UNWRAP_AFTER
}
  • NONE: Do not wrap the native token when Protocolink executes the protocol operation.

  • WRAP_BEFORE: Wrap the native token before Protocolink executes the protocol operation.

  • UNWRAP_AFTER: Unwrap the token after Protocolink executes the protocol operation.

struct Input {
    address token;
    uint256 balanceBps;
    uint256 amountOrOffset;
}
  • token: The address of the input token.

  • balanceBps: The value represents how much percentage of the token balance will be used. The base is 10_000 which means 7_000 represents 70% of the token balance. If you want to use a fixed amount instead, set this value to 0.

  • amountOrOffset: The value represents the fixed token amount in use when balanceBps is set to 0. Otherwise, it represents the byte offset for replacing the amount value in the Logic.data. If the amount value does not need to be replaced, set amountOrOffset to 1<<255.

struct Logic {
    address to;
    bytes data;
    Input[] inputs;
    WrapMode wrapMode;
    address approveTo;
    address callback;
}
  • to: The contract address that Protocolink interacts with.

  • data: The transaction data to execute.

  • inputs: The token addresses and amounts expected to be used in the transaction.

  • wrapMode: Specifies whether the native tokens need to be wrapped (e.g., ETH to WETH). If the native tokens need to be wrapped, set it to WRAP_BEFORE. If the tokens need to be unwrapped after the transaction data is executed, set it to UNWRAP_AFTER. Otherwise, set it to NONE.

  • approveTo: Authorize a contract address, such as Paraswap TokenTransferProxy, that does not equal the to address. If the approveTo address equals the to address, fill in the approveTo address with address(0).

  • callback: The callback address is provided to a flash loan contract to execute subsequent operations.

struct ExecutionDetails {
    bytes[] permit2Datas;
    Logic[] logics;
    address[] tokensReturn;
    uint256 nonce;
    uint256 deadline;
}
  • permit2Datas: The Permit2 data for pulling tokens from the user address.

  • logics: The operations for Protocolink to interact with other protocols.

  • tokensReturn: The specified tokens should be sent back to the user address at the end of the transaction.

  • nonce: A one-time used value to prevent signature replay attack.

  • deadline: The signature expiration time.

struct Fee {
    address token;
    uint256 amount;
    bytes32 metadata;
}
  • token: The fee token address.

  • amount: The fee amount.

  • metadata: The fee source that is used only for events.

struct LogicBatch {
    Logic[] logics;
    Fee[] fees;
    bytes32[] referrals;
    uint256 deadline;
}
  • logics: The operations for Protocolink to interact with other protocols.

  • fees: The fees that are charged by Protocolink.

  • referrals: The receivers of the fees and the fee rates.

  • deadline: The signature expiration time.

struct ExecutionBatchDetails {
    bytes[] permit2Datas;
    LogicBatch logicBatch;
    address[] tokensReturn;
    uint256 nonce;
    uint256 deadline;
}
  • permit2Datas: The Permit2 data for pulling tokens from the user address.

  • logicBatch: The operations for Protocolink to interact with other protocols.

  • tokensReturn: The specified tokens should be sent back to the user address at the end of the transaction.

  • nonce: A one-time used value to prevent signature replay attack.

  • deadline: The signature expiration time.

struct DelegationDetails {
    address delegatee;
    uint128 expiry;
    uint128 nonce;
    uint256 deadline;
}
  • delegatee: The delegatee address.

  • expiry: The delegation expiration time.

  • nonce: A one-time used value to prevent signature replay attack.

  • deadline: The signature expiration time.

struct PackedDelegation {
    uint128 expiry;
    uint128 nonce;
}
  • expiry: The delegation expiration time.

  • nonce: A one-time used value to prevent signature replay attack.

Last updated