Binance Web3 Connector JS
    Preparing search index...

    DefiTransactionApi - interface DefiTransactionApi

    interface DefiTransactionApiInterface {
        buildDeFiClaimTransaction(
            requestParameters: BuildDeFiClaimTransactionRequest,
        ): Promise<RestApiResponse<BuildDeFiClaimTransactionResponse>>;
        buildDeFiDepositTransaction(
            requestParameters: BuildDeFiDepositTransactionRequest,
        ): Promise<RestApiResponse<BuildDeFiDepositTransactionResponse>>;
        buildDeFiRedeemTransaction(
            requestParameters: BuildDeFiRedeemTransactionRequest,
        ): Promise<RestApiResponse<BuildDeFiRedeemTransactionResponse>>;
        buildLpAddTransaction(
            requestParameters: BuildLpAddTransactionRequest,
        ): Promise<RestApiResponse<BuildLpAddTransactionResponse>>;
        buildLpRemoveTransaction(
            requestParameters: BuildLpRemoveTransactionRequest,
        ): Promise<RestApiResponse<BuildLpRemoveTransactionResponse>>;
        calculateLpAddPairedAmounts(
            requestParameters: CalculateLpAddPairedAmountsRequest,
        ): Promise<RestApiResponse<CalculateLpAddPairedAmountsResponse>>;
    }

    Implemented by

    Index
    • Build the unsigned claim calldata for one of four claim types — see DefiClaimType for which companion fields each type requires and which protocol constraints apply (e.g. REWARD_PROTOCOL is not supported for LP protocols; PancakeSwap V3 farming uses LP_FEE, not REWARD_INVESTMENT). Returns an ordered dataList (typically [CLAIM]). binanceChainId resolution rules*:

      • Normally resolved from investmentId; the call always executes on that chain.

      • For claim types other than REWARD_PROTOCOL, any client-supplied binanceChainId is silently ignored* — passing a different chainId will not redirect the claim.

      • Exception: REWARD_PROTOCOL with no investmentId — the client MUST pass binanceChainId (it is the only chain signal).

      tokenAddressList optionally narrows the claim scope. Set simulate=true to also receive preview.

      Parameters

      Returns Promise<RestApiResponse<BuildDeFiClaimTransactionResponse>>

      DefiTransactionApiInterface

    • Build the unsigned transaction calldata for a DeFi redeem / withdraw. Returns an ordered dataList (typically [REDEEM] or [APPROVE, REDEEM]). Redeem amount is decided by exactly one of ratio or token* (mutually exclusive): - ratio omitted / blank → exact-amount redeem: the amount comes from token (tokenAddress + amount); the position is not queried. token is required in this mode (omitting token, or leaving amount blank, is rejected with 40001, Parameter error; both ratio and token absent is also rejected with 40001).

      • ratio present → proportional redeem: must parse as a decimal in (0, 1]. The service queries the user's on-chain position under investmentId and scales each token's amount by ratio (floored to the token's decimals). ratio="1" is a full (max) redeem. In this mode token is ignored — the output tokens and amounts are derived from the position.

      slippageBps is the slippage tolerance in basis points (e.g. 300 = 3%). The caller does NOT pass binanceChainId — resolved from investmentId. Set simulate=true to also receive preview. The response also carries redeemDelayDays — the redeem waiting period as a [min, max] day pair (e.g. ["7","10"] = 7–10 days, [] = instant). The wait starts after the redeem tx is confirmed on-chain. See the redeemDelayDays field on DefiTxResponse.

      Parameters

      Returns Promise<RestApiResponse<BuildDeFiRedeemTransactionResponse>>

      DefiTransactionApiInterface

    • Build the unsigned transaction calldata for adding liquidity. tokenList supports multiple tokens. Returns an ordered dataList (typically [APPROVE, LP_ADD]). *Tick range source (provide exactly one group)**:

      1. nftId — append to an existing LP position (reuses its range).
      2. priceRange — percentage band (e.g. "5" = ±5%) for a new position.
      3. tickLower + tickUpper — explicit raw int24 pair for a new position. Rules*:
      • If more than one group is supplied, only the highest-priority one above is used and the others are silently ignored (priority: nftId > priceRange > explicit tick pair).

      • If none is supplied, the request is rejected (40453).

      • tickLower / tickUpper are raw int24 values and MUST be aligned to the pool's tickSpacing, otherwise the request is rejected (40453).

      • The caller does NOT pass binanceChainId — resolved from investmentId.

      Parameters

      Returns Promise<RestApiResponse<BuildLpAddTransactionResponse>>

      DefiTransactionApiInterface

    • Given a single input token, calculate the paired token amount needed for an LP add. This is a pure computation endpoint — it does not touch the chain and does not deduct any fee. Use it before /transaction/lp-add to size the paired token when only one side is supplied. Tick range source rules are the same as /lp-add — provide exactly one group: nftId (existing position), priceRange, or tickLower+tickUpper.

      • If more than one group is supplied, only the highest-priority one is used and the others are silently ignored (priority: nftId > priceRange > explicit tick pair).

      • If none is supplied, the request is rejected.

      • The caller does NOT pass binanceChainId — resolved from investmentId.

      Parameters

      Returns Promise<RestApiResponse<CalculateLpAddPairedAmountsResponse>>

      DefiTransactionApiInterface