DeFi API

Query estimated calculation information for redemption#

Description: This API provides you with estimated redemption details for a specific investment. The content includes:

  • Super node name and estimated gas fees.
  • List of received tokens, details of token exchange, and token authorization status (including whether authorization is required).
  • Redeemable amount, minimum redemption amount, maximum redemption amount, etc.

Request URL#

POST https://www.okx.com/api/v5/defi/calculator/redeem-info

Request parameter#

Parameter nameDescriptionParameter typeRequiredData type
addressUser wallet addressRequest bodyNoString
inputTokenAmountSubscription token quantityRequest bodyYesString
investmentCategorySubscription category: (e.g., 0: Default category; 1: BRC-20)Request bodyNoString
investmentIdInvestment ID (refer to here)Request bodyYesString
isSingleDetermine if it's a single token investment: Yes: Single; No: MultipleRequest bodyNoBoolean
outputTokenAddressToken smart contract address (refer to here)Request bodyYesString
slippageSlippageRequest bodyNoString

Response parameters#

Parameter nameDescriptionData type
isAllowRedeemWhether redemption is allowedBoolean
estimateGasFeeEstimated gas limitString
isSwapInvestWhether it is a swap investmentBoolean
inputCurrencyAmountInput currency value in USDString
receiveTokenListList of received token informationArray[Struct]
> coinAmountToken quantityString
> currencyAmountToken value in USDString
> tokenSymbolToken symbolString
> tokenNameToken nameString
> tokenAddressToken smart contract addressString
> tokenPrecisionToken decimal precisionString
> isBaseTokenWhether the pledging token is the mainnet base tokenBoolean
> networkToken networkString
> chainIdToken chain IDString
> dataType0: principle 1: rewards 2: tradingFee 3: BonusString
swapFromTokenListToken list during redemption: same structure as investWithTokenListArray[Struct]
mySupplyRedeemable amount: same structure as investWithTokenListStruct
approveStatusListList of token authorization statusArray[Struct]
> tokenSymbolToken symbolString
> tokenAddressToken smart contract addressString
> tokenPrecisionToken decimal precisionString
> isNeedApproveWhether authorization is requiredBoolean
> approveAddressContract address requiring authorizationString
> networkToken networkString
> chainIdToken chain IDString
> orderTypeParameter passed to call data (3: buy authorization, 4: redemption authorization, 8: enter farm, 9: leave farm)String

Request example#

shell
curl --location 'https://www.okx.com/api/v5/defi/calculator/redeem-info' \
--header 'OK-ACCESS-KEY: 9c****77' \
--header 'OK-ACCESS-PASSPHRASE: p****d' \
--header 'Content-Type: application/json' \
--data '{
  "address": "0x7f****da",
  "inputTokenAmount": "1.000000146425127036",
  "investmentCategory": "0",
  "investmentId": "21033",
  "isSingle": false,
  "outputTokenAddress": "0x6b175474e89094c44da98b954eedeac495271d0f",
  "outputTokenDecimal": "18",
  "redeemId": "",
  "slippage": ""
}'

Response example#

200
{
    "code": 0,
    "msg": "",
    "data": {
        "receiveTokenList": [
            {
                "tokenSymbol": "DAI",
                "tokenName": "Dai Stablecoin",
                "tokenAddress": "0x6b****0f",
                "network": "ETH",
                "chainId": "1",
                "tokenPrecision": "18",
                "isBaseToken": false,
                "coinAmount": "1.000000146425127036",
                "currencyAmount": "0.9993097704396316094231068522159962",
                "dataType": "0"
            }
        ],
        "swapFromTokenList": [
            {
                "tokenSymbol": "DAI",
                "tokenName": "Dai Stablecoin",
                "tokenAddress": "0x6b****0f",
                "network": "ETH",
                "chainId": "1",
                "tokenPrecision": "18",
                "isBaseToken": false,
                "coinAmount": "1.000000146425127036",
                "currencyAmount": "0.9993097704396316094231068522159962"
            }
        ],
        "isSwapInvest": false,
        "estimateGasFee": "276614",
        "isAllowRedeem": true,
        "mySupply": {
            "tokenSymbol": "DAI",
            "tokenName": "Dai Stablecoin",
            "tokenAddress": "0x6b****0f",
            "network": "ETH",
            "chainId": "1",
            "tokenPrecision": "18",
            "isBaseToken": false,
            "coinAmount": "0",
            "currencyAmount": "0"
        },
        "inputCurrencyAmount": "0.9993097704396316094231068522159962"
    }
}