DeFi API

查询认购的预估计算信息#

描述: 该 API 将给你指定投资品的预估认购收益详情。内容包括:

  • 超级节点名、预估网络费相关;
  • 接收代币列表、凭证代币详情列表、收益代币详情列表、代币授权状态列表(包括是否需要授权);
  • 可申购金额、最小申购数额、最大申购数额、币种交换汇率等。

请求地址#

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

请求参数#

参数名称相关描述数据类型必传数据类型
address用户钱包地址请求体String
inputAmount认购代币数量请求体String
investmentCategory认购类型:(0:默认类型;1:BRC-20)请求体String
investmentId投资品 ID (这里获取)请求体String
inputTokenAddress认购代币的智能合约地址 (这里获取)请求体String
isSingle判断是否为单币投资品:是:单币;否:多币请求体Boolean
slippage滑点:默认为 1%请求体String

响应参数#

参数名称相关描述数据类型
validatorName超级节点名称String
isAllowSubscribe是否允许申购Boolean
estimateGasFee收益率计算类型:0:APY;1:APRString
isSwapInvest是否是兑换投资Boolean
exchangeRate币种汇率String
investWithTokenList质押代币Array[Struct]
>coinAmount币种数量String
>currencyAmount币种美元价值String
>tokenSymbol币种标识String
>tokenName币种名称String
>tokenAddress币种的智能合约地址String
>tokenPrecision币种精确小数位String
>isBaseToken质押代币是否为主网基准代币Boolean
>network币种网络String
>chainId币种的链 IDString
>dataType0:利息收益;1:矿币收益;2:手续费;3:奖励金String
gainsTokenList收益代币列表:结构同 investWithTokenListArray[Struct]
receiveTokenInfo投资收到的凭证代币:结构同 investWithTokenListArray[Struct]
approveStatusList币种授权状态列表Array[Struct]
>tokenSymbol币种标识String
>tokenAddress币种的智能合约地址String
>tokenPrecision币种精确小数位String
>isNeedApprove是否需要授权Boolean
>approveAddress需要授权的合约地址String
>network币种网络String
>chainId币种的链 IDString
>orderType类型透传给 Call data 的参数 (3:买入授权;4:赎回授权;8:进入 Farm;9:离开 Farm)String

请求示例#

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
}'

响应示例#

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"
    }
}