Skip to main content
POST
/
rpc
/
Trails
/
YieldCreateExitAction
YieldCreateExitAction returns unsigned exit-action transaction payloads.
curl --request POST \
  --url https://api.example.com/rpc/Trails/YieldCreateExitAction \
  --header 'Content-Type: application/json' \
  --data '
{
  "earnMarketId": "<string>",
  "userWalletAddress": "<string>",
  "args": {
    "amount": "<string>",
    "amounts": [
      "<string>"
    ],
    "validatorAddress": "<string>",
    "validatorAddresses": [
      "<string>"
    ],
    "providerId": "<string>",
    "duration": 123,
    "inputToken": "<string>",
    "inputTokenNetwork": "<string>",
    "outputToken": "<string>",
    "outputTokenNetwork": "<string>",
    "subnetId": 123,
    "tronResource": "<string>",
    "feeConfigurationId": "<string>",
    "cosmosPubKey": "<string>",
    "tezosPubKey": "<string>",
    "cAddressBech": "<string>",
    "pAddressBech": "<string>",
    "executionMode": "<string>",
    "ledgerWalletApiCompatible": true,
    "useMaxAmount": true,
    "useInstantExecution": true,
    "skipPrechecks": true,
    "useMaxAllowance": true,
    "feePayerAddress": "<string>",
    "receiverAddress": "<string>",
    "rangeMin": "<string>",
    "rangeMax": "<string>",
    "percentage": 123,
    "tokenId": "<string>"
  }
}
'
{
  "action": {
    "id": "<string>",
    "intent": "<string>",
    "type": "<string>",
    "yieldId": "<string>",
    "address": "<string>",
    "transactions": [
      {
        "id": "<string>",
        "title": "<string>",
        "network": "<string>",
        "status": "<string>",
        "type": "<string>",
        "createdAt": "<string>",
        "hash": "<string>",
        "broadcastedAt": "<string>",
        "signedTransaction": "<string>",
        "unsignedTransaction": {},
        "annotatedTransaction": {},
        "structuredTransaction": {},
        "stepIndex": 123,
        "description": "<string>",
        "error": "<string>",
        "gasEstimate": "<string>",
        "explorerUrl": "<string>",
        "isMessage": true
      }
    ],
    "executionPattern": "<string>",
    "createdAt": "<string>",
    "status": "<string>",
    "amount": "<string>",
    "amountRaw": "<string>",
    "amountUsd": "<string>",
    "rawArguments": {
      "amount": "<string>",
      "amounts": [
        "<string>"
      ],
      "validatorAddress": "<string>",
      "validatorAddresses": [
        "<string>"
      ],
      "providerId": "<string>",
      "duration": 123,
      "inputToken": "<string>",
      "inputTokenNetwork": "<string>",
      "outputToken": "<string>",
      "outputTokenNetwork": "<string>",
      "subnetId": 123,
      "tronResource": "<string>",
      "feeConfigurationId": "<string>",
      "cosmosPubKey": "<string>",
      "tezosPubKey": "<string>",
      "cAddressBech": "<string>",
      "pAddressBech": "<string>",
      "executionMode": "<string>",
      "ledgerWalletApiCompatible": true,
      "useMaxAmount": true,
      "useInstantExecution": true,
      "skipPrechecks": true,
      "useMaxAllowance": true,
      "feePayerAddress": "<string>",
      "receiverAddress": "<string>",
      "rangeMin": "<string>",
      "rangeMax": "<string>",
      "percentage": 123,
      "tokenId": "<string>"
    },
    "completedAt": "<string>"
  }
}

Overview

YieldCreateExitAction returns the unsigned transaction payload needed to withdraw from a DeFi yield position. It is the counterpart to YieldCreateEnterAction. Use this endpoint to build withdrawal UIs or construct exit calldata for Trails routes. For React apps, the composable action builders handle this automatically.

Request Parameters

FieldTypeRequiredDescription
earnMarketIdstringYesMarket ID from YieldGetMarkets
userWalletAddressstringYesAddress of the withdrawing wallet
argsobjectNoMarket-specific arguments (e.g. amount, shares)

Response

Returns payload containing unsigned transaction data:
FieldDescription
transactionsArray of transaction objects to execute
transactions[].toContract address
transactions[].dataABI-encoded calldata
transactions[].valueETH value (for native token withdrawals)

Examples

Withdraw from an Aave lending position

const response = await fetch('https://trails-api.sequence.app/rpc/Trails/YieldCreateExitAction', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'X-Access-Key': 'YOUR_ACCESS_KEY',
  },
  body: JSON.stringify({
    earnMarketId: 'base-usdc-aave-v3-lending',
    userWalletAddress: '0xYourWalletAddress',
  }),
})

const { payload } = await response.json()
const action = JSON.parse(payload)

Withdraw a specific amount

Use args to pass withdrawal parameters for markets that require them (e.g. partial withdrawals):
const response = await fetch('https://trails-api.sequence.app/rpc/Trails/YieldCreateExitAction', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'X-Access-Key': 'YOUR_ACCESS_KEY',
  },
  body: JSON.stringify({
    earnMarketId: 'ethereum-usdc-morpho-0x...',
    userWalletAddress: '0xYourWalletAddress',
    args: {
      amount: '1000000', // 1 USDC in wei
    },
  }),
})

Common pattern: check balance then exit

// 1. Check what positions the wallet holds
const balancesRes = await fetch('https://trails-api.sequence.app/rpc/Trails/YieldGetAggregateBalances', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json', 'X-Access-Key': 'YOUR_ACCESS_KEY' },
  body: JSON.stringify({ queries: [{ address: '0xYourWallet', network: 'base' }] }),
})
const { payload: balPayload } = await balancesRes.json()
const balances = JSON.parse(balPayload)

// 2. Build exit calldata for each position
for (const position of balances) {
  const exitRes = await fetch('https://trails-api.sequence.app/rpc/Trails/YieldCreateExitAction', {
    method: 'POST',
    headers: { 'Content-Type': 'application/json', 'X-Access-Key': 'YOUR_ACCESS_KEY' },
    body: JSON.stringify({
      earnMarketId: position.yieldId,
      userWalletAddress: '0xYourWallet',
    }),
  })
  const { payload: exitPayload } = await exitRes.json()
  const exitAction = JSON.parse(exitPayload)
  // Use exitAction.transactions to build and submit the withdrawal
}

See also

Body

application/json
earnMarketId
string
required
userWalletAddress
string
required
args
object

Response

OK

action
object
required