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 name | Description | Parameter type | Required | Data type |
---|---|---|---|---|
address | User wallet address | Request body | Yes | String |
investmentId | Investment product ID | Request body | Yes | String |
userInputList | User input token information | Request body | Yes | Array[Struct] |
>chainId | Blockchain ID (default: investment product network) | Request body | No | String |
>coinAmount | Subscription quantity | Request body | Yes | String |
>tokenAddress | Smart contract address of the subscription token (default: investment product token address) | Request body | No | String |
expectOutputLIst | User expected profit information | Request body | Yes | Array[Struct] |
>chainId | Blockchain ID | Request body | No | String |
>coinAmount | Subscription quantity | Request body | Yes | String |
>tokenAddress | Smart contract address of the subscription token | Request body | No | String |
extra | See remarks for specific meaning | Request body | No | String |
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:
- 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\"]}" }
- If canClaimAll = false, not all rewards can be claimed, and the length of claimIndex can only be 1.
{"extra" : "{\"claimIndex\":[\"2\"]}" }
- 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 name | Description | Data type |
---|---|---|
dataList | Call data information | Array[Struct] |
>from | From (user address) | String |
>to | To (target contract address) | String |
>value | Transfer amount (native token quantity, default is an empty string) | String |
>serializedData | Call data data | String |
>originalData | Original data (JSON) | JSON String |
>callDataType | Operation type (authorization, subscription, redemption, claiming) | String |
>signatureData | Signed Call data information, can be used to verify data generated by OKX | String |
Remarks:#
Signature verification method:
- Calculate the values of r, s, and v using the signatureData.
- Concatenate the string formed by to + serializedData + originalData and calculate the verification hash.
- 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"
}
]
}
}