DeFi API
Generate call data for claiming bonus rewards

Generate call data for claiming bonus rewards#

Description: This API provides the call data for claiming bonus rewards.

Request URL#

POST https://www.okx.com/api/v5/defi/transaction/bonus

Request parameter#

Parameter nameDescriptionParameter typeRequiredData type
addressUser wallet addressRequest bodyYesString
investmentIdInvestment product IDRequest bodyYesString
userInputListUser input token informationRequest bodyYesArray[Struct]
>chainIdBlockchain ID (default: investment product network)Request bodyNoString
>coinAmountSubscription quantityRequest bodyYesString
>tokenAddressSmart contract address of the subscription token (default: investment product token address)Request bodyNoString
expectOutputLIstUser expected profit informationRequest bodyYesArray[Struct]
>chainIdBlockchain IDRequest bodyNoString
>coinAmountSubscription quantityRequest bodyYesString
>tokenAddressSmart contract address of the subscription tokenRequest bodyNoString
extraSee remarks for specific meaningRequest bodyNoString

Remarks:#

Usage of extra claiming bonus rewards

  • a. key: claimIndex (number), meaning: ID of the reward to be claimed. Click here to obtain supporting protocols, such as: Ankr, Benqi, Stader, Lido. The interface can retrieve the user’s positions if the returned result field is present. rewardDefiTokenInfo.claimMode is 1. It means there is a secondary page. You can click here to get the reward list. To claim a specific reward, you need to pay attention to several fields:
  • canClaimAll:Indicates whether all rewards can be claimed.
  • rewardTokenInfos.claimIndex:Identifies the ID of a specific reward.
  • callDataRewardType: 1-claimable reward, 2-expired reward, 3-unclaimable reward. Call data Extra field parameters:
  1. If canClaimAll = true (currently only for Benqi/Tranchess)
  • If the length of claimIndex is 1, it will claim 1 reward.
{"extra" : "{\"claimIndex\":[\"2\"]}" }
  • If the length of claimIndex is greater than 1, it will claim all claimable rewards.
{"extra" : "{\"claimIndex\":[\"2\",\"3\"]}" }
  1. If canClaimAll = false, not all rewards can be claimed, and the length of claimIndex can only be 1.
{"extra" : "{\"claimIndex\":[\"2\"]}" }
  1. If callDataRewardType = 2 and a reward needs to be claimed (only for Benqi), claimOverdue = true. This means that it can be claimed even if it has expired, but it will claim a different currency. The default value is false, which means it will not claim the expired reward and will claim the specified currency reward in the next claiming cycle.
{"extra": "{\"claimOverdue\":1,\"claimIndex\":[\"2\"]}"}
  • b. key: analysisPlatformId (Number), meaning: Claim rewards for the entire platform. Click here to obtain supporting platforms, such as: Compound, Aave V2, WePiggy, Venus, Aave V3, Benqi, Radiant, Geist finance, Tender, Compound V3, SonneFinance, Clearpool.

Response parameters#

Parameter nameDescriptionData type
dataListCall data informationArray[Struct]
>fromFrom (user address)String
>toTo (target contract address)String
>valueTransfer amount (native token quantity, default is an empty string)String
>serializedDataCall data dataString
>originalDataOriginal data (JSON)JSON String
>callDataTypeOperation type (authorization, subscription, redemption, claiming)String
>signatureDataSigned Call data information, can be used to verify data generated by OKXString

Remarks:#

Signature verification method:

  1. Calculate the values of r, s, and v using the signatureData.
  2. Concatenate the string formed by to + serializedData + originalData and calculate the verification hash.
  3. Perform public key recovery verification. The decision to perform signature verification can be made by the integrating client. If the verification is successful, it indicates that the data was generated by OKX.

Example of claiming protocol rewards#

Request example#

shell
curl --location 'https://www.okx.com/api/v5/defi/transaction/bonus' \
--header 'OK-ACCESS-KEY: 9c****77' \
--header 'OK-ACCESS-PASSPHRASE: p****d' \
--header 'Content-Type: application/json' \
--data '{
  "address": "0x7f****da",
  "expectOutputList": [
    {
      "chainId": 1,
      "coinAmount": "1065142752604499571",
      "tokenAddress": "0x7d1afa7b718fb893db30a3abc0cfc608aacfebb0"
    }
  ],
  "investmentId": "10003",
  "extra": "{\"claimOverdue\":0,\"claimIndex\":[\"1286\"],\"callDataExtJson\":\"\",\"redeemCalldataExtInfo\":[],\"rewardAddress\":\"\"}"
}'

Response example#

200
{
    "code": 0,
    "msg": "",
    "data": {
        "dataList": [
            {
                "callDataType": "CLAIM",
                "from": "0x7f****da",
                "to": "0x9e****99",
                "value": "0x0",
                "serializedData": "0x46e04a2f000000000000000000000000000000000000000000000000000000000000042a",
                "originalData": "{\"callDataType\":\"CLAIM\",\"methodDefine\":\"claimTokens(uint256)\",\"methodId\":\"0x46e04a2f\",\"methodType\":\"METHOD_ID\",\"params\":{\"params\":[\"1066\"]},\"useAdapter\":false}",
                "signatureData": "e35e234d1568e13f5b7a9bd175ae947268dc3e817973120381fc8eecda78f71633ff67564c6460e388a2ca60daab62ce68f8952387e48ce63c19cad38f332c941b"
            }
        ]
    }
}