DeFi API
Query estimated calculation information for subscription

Query estimated calculation information for subscription#

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

  • Super node name and estimated gas fees.
  • List of received tokens, details of voucher tokens, details of earnings tokens, and token authorization status (including whether authorization is required).
  • Subscribable amount, minimum subscription amount, maximum subscription amount, currency exchange rates, etc.

Request URl#

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

Request parameter#

Parameter nameDescriptionData typeRequiredData type
addressUser wallet addressRequest bodyNoString
inputAmountSubscription token quantityRequest bodyYesString
investmentCategorySubscription category: 0: Default category; 1: BRC-20Request bodyNoString
investmentIdInvestment ID (refer to here)Request bodyYesString
inputTokenAddressSmart contract address of the subscription token (refer to here)Request bodyYesString
isSingleDetermine if it’s a single token investment: Yes: Single token; No: MultipleRequest bodyNoBoolean
slippageSlippage: default is 1%Request bodyNoString

Response parameters#

Parameter nameDescriptionData type
validatorNameSuper node nameString
isAllowSubscribeWhether subscription is allowedBoolean
estimateGasFeeType of earnings calculation: 0: APY; 1: APRString
isSwapInvestWhether it is a swap investmentBoolean
exchangeRateCurrency exchange rateString
investWithTokenListPledged tokensArray[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: Interest earnings; 1: Mining earnings; 2: Transaction fees; 3: BonusString
gainsTokenListList of earning tokens: same structure as investWithTokenListArray[Struct]
receiveTokenInfoVoucher tokens received from the investment: same structure as investWithTokenListArray[Struct]
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/subscribe-info' \
--header 'OK-ACCESS-KEY: 9c****77' \
--header 'OK-ACCESS-PASSPHRASE: p****d' \
--header 'Content-Type: application/json' \
--data '{
  "inputAmount": "1",
  "inputTokenAddress": "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
  "isSingle": false,
  "tokenDecimal": "18",
  "investmentId": "21915",
  "address": "0x7f****da",
  "investmentType": 0
}'

Response example#

200
{
    "code": 0,
    "msg": "",
    "data": {
        "investWithTokenList": [
            {
                "tokenSymbol": "CORE",
                "tokenName": "Core",
                "tokenAddress": "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
                "network": "CORE",
                "chainId": "1116",
                "tokenPrecision": "18",
                "isBaseToken": true,
                "coinAmount": "1",
                "currencyAmount": "0.5035"
            }
        ],
        "gainsTokenList": [
            {
                "tokenSymbol": "CORE",
                "tokenName": "Core",
                "tokenAddress": "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
                "network": "CORE",
                "tokenPrecision": "18",
                "coinAmount": "0.000742226856350101",
                "dataType": "0"
            }
        ],
        "approveStatusList": [
            {
                "tokenSymbol": "CORE",
                "tokenAddress": "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
                "network": "CORE",
                "chainId": "1116",
                "tokenPrecision": "18",
                "isNeedApprove": false,
                "approveAddress": "0x0000000000000000000000000000000000001007",
                "orderType": "3"
            }
        ],
        "isSwapInvest": false,
        "estimateGasFee": "99343",
        "isAllowSubscribe": true,
        "validatorName": "OKXEarn"
    }
}