YieldCreateExitAction generates unsigned withdrawal transaction calldata for a yield position.
curl --request POST \
--url https://trails-api.sequence.app/rpc/Trails/YieldCreateExitAction \
--header 'Content-Type: application/json' \
--data '
{
"earnMarketId": "<string>",
"userWalletAddress": "<string>",
"args": {}
}
'import requests
url = "https://trails-api.sequence.app/rpc/Trails/YieldCreateExitAction"
payload = {
"earnMarketId": "<string>",
"userWalletAddress": "<string>",
"args": {}
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({earnMarketId: '<string>', userWalletAddress: '<string>', args: {}})
};
fetch('https://trails-api.sequence.app/rpc/Trails/YieldCreateExitAction', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://trails-api.sequence.app/rpc/Trails/YieldCreateExitAction",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'earnMarketId' => '<string>',
'userWalletAddress' => '<string>',
'args' => [
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://trails-api.sequence.app/rpc/Trails/YieldCreateExitAction"
payload := strings.NewReader("{\n \"earnMarketId\": \"<string>\",\n \"userWalletAddress\": \"<string>\",\n \"args\": {}\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://trails-api.sequence.app/rpc/Trails/YieldCreateExitAction")
.header("Content-Type", "application/json")
.body("{\n \"earnMarketId\": \"<string>\",\n \"userWalletAddress\": \"<string>\",\n \"args\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://trails-api.sequence.app/rpc/Trails/YieldCreateExitAction")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"earnMarketId\": \"<string>\",\n \"userWalletAddress\": \"<string>\",\n \"args\": {}\n}"
response = http.request(request)
puts response.read_body{
"payload": {}
}{
"error": "WebrpcEndpoint",
"code": 0,
"msg": "endpoint error",
"status": 400,
"cause": "<string>"
}{
"error": "WebrpcBadResponse",
"code": -5,
"msg": "bad response",
"status": 500,
"cause": "<string>"
}Earn
YieldCreateExitAction
Generate unsigned withdrawal transaction calldata for a DeFi yield position
POST
/
rpc
/
Trails
/
YieldCreateExitAction
YieldCreateExitAction generates unsigned withdrawal transaction calldata for a yield position.
curl --request POST \
--url https://trails-api.sequence.app/rpc/Trails/YieldCreateExitAction \
--header 'Content-Type: application/json' \
--data '
{
"earnMarketId": "<string>",
"userWalletAddress": "<string>",
"args": {}
}
'import requests
url = "https://trails-api.sequence.app/rpc/Trails/YieldCreateExitAction"
payload = {
"earnMarketId": "<string>",
"userWalletAddress": "<string>",
"args": {}
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({earnMarketId: '<string>', userWalletAddress: '<string>', args: {}})
};
fetch('https://trails-api.sequence.app/rpc/Trails/YieldCreateExitAction', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://trails-api.sequence.app/rpc/Trails/YieldCreateExitAction",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'earnMarketId' => '<string>',
'userWalletAddress' => '<string>',
'args' => [
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://trails-api.sequence.app/rpc/Trails/YieldCreateExitAction"
payload := strings.NewReader("{\n \"earnMarketId\": \"<string>\",\n \"userWalletAddress\": \"<string>\",\n \"args\": {}\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://trails-api.sequence.app/rpc/Trails/YieldCreateExitAction")
.header("Content-Type", "application/json")
.body("{\n \"earnMarketId\": \"<string>\",\n \"userWalletAddress\": \"<string>\",\n \"args\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://trails-api.sequence.app/rpc/Trails/YieldCreateExitAction")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"earnMarketId\": \"<string>\",\n \"userWalletAddress\": \"<string>\",\n \"args\": {}\n}"
response = http.request(request)
puts response.read_body{
"payload": {}
}{
"error": "WebrpcEndpoint",
"code": 0,
"msg": "endpoint error",
"status": 400,
"cause": "<string>"
}{
"error": "WebrpcBadResponse",
"code": -5,
"msg": "bad response",
"status": 500,
"cause": "<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
| Field | Type | Required | Description |
|---|---|---|---|
earnMarketId | string | Yes | Market ID from YieldGetMarkets |
userWalletAddress | string | Yes | Address of the withdrawing wallet |
args | object | No | Market-specific arguments (e.g. amount, shares) |
Response
Returnspayload containing unsigned transaction data:
| Field | Description |
|---|---|
transactions | Array of transaction objects to execute |
transactions[].to | Contract address |
transactions[].data | ABI-encoded calldata |
transactions[].value | ETH 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
Useargs 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
- YieldCreateEnterAction — Deposit into a position
- YieldGetAggregateBalances — Check existing positions before exiting
- YieldGetMarkets — Discover market IDs
Body
application/json
Response
OK
JSON object containing unsigned transaction payloads
Was this page helpful?