DeFi API

Generate redemption transaction call data#

Description: This API provides the call data for a redemption transaction.

Request URL#

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

Request parameters#

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 detailsRequest bodyNoString

Remarks:#

Usage of extra redeemCalldataExtInfo

Here provides the investOrderList field, which represents each user’s subscription. The investOrderList.redeemExtra field represents the data required for the call data Extra.

{"extra": "{\"redeemCalldataExtInfo\":[{\"unstakeIndex\":\"0xbc5118e65240dd5702218b37fd8d965d6eb4400474f34b6fe4a8f7805fc09405\"}]}"}

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 dataString
>originalDataOriginal data (JSON)JSON String
>callDataTypeOperation type (authorization, subscription, redemption, claim)String
>signatureDataSigned call data information, can be used to verify data generated by OKXString

Remarks:#

Signature verification method:

  1. Calculate r, s, v using the signatureData signature information.
  2. Calculate the verification hash by concatenating the string formed by to + serializedData + originalData.
  3. Perform public key recovery verification. The client can choose whether to perform signature verification. If the verification is successful, it indicates that the data was signed by OKX.

Redemption example#

Request example#

shell
curl --location 'https://www.okx.com/api/v5/defi/transaction/redemption' \
--header 'OK-ACCESS-KEY: 9c****77' \
--header 'OK-ACCESS-PASSPHRASE: p****d' \
--header 'Content-Type: application/json' \
--data '{
  "address": "0x7f****da",
  "investmentId": "21033",
  "userInputList": [
    {
      "chainId": 1,
      "coinAmount": "1",
      "tokenAddress": "0x6b175474e89094c44da98b954eedeac495271d0f"
    }
  ],
  "extra": "{\"redeemAll\":1}"
}'

Response example#

200
{
    "code": 0,
    "msg": "",
    "data": {
        "dataList": [
            {
                "callDataType": "WITHDRAW",
                "from": "0x7f****da",
                "to": "0x83****ea",
                "value": "0x0",
                "serializedData": "0xba0876520000000000000000000000000000000000000000000000000cbb507c8eb3879f0000000000000000000000007f429edeff8afc7bb3a2cf7db832fc86f6fa99da0000000000000000000000007f429edeff8afc7bb3a2cf7db832fc86f6fa99da",
                "originalData": "{\"callDataType\":\"WITHDRAW\",\"methodDefine\":\"redeem(uint256,address,address)\",\"methodId\":\"0xba087652\",\"methodType\":\"METHOD_ID\",\"params\":{\"params\":[\"917415445000325023\",\"0x7f429edeff8afc7bb3a2cf7db832fc86f6fa99da\",\"0x7f429edeff8afc7bb3a2cf7db832fc86f6fa99da\"]},\"useAdapter\":false}",
                "signatureData": "e6beeb6f9df6ecb7eb7791e57226f9eca1d7c3efa869172bb5021b9c827ad21b46e3dc4566608af727555e0a47aa90cf261331f4e1691b0201aa0b8a00ea685b1b"
            }
        ]
    }
}