YieldGetAggregateBalances returns a wallet's earn positions across chains.
curl --request POST \
--url https://trails-api.sequence.app/rpc/Trails/YieldGetAggregateBalances \
--header 'Content-Type: application/json' \
--data '
{
"queries": [
{
"address": "<string>",
"network": "<string>"
}
]
}
'import requests
url = "https://trails-api.sequence.app/rpc/Trails/YieldGetAggregateBalances"
payload = { "queries": [
{
"address": "<string>",
"network": "<string>"
}
] }
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({queries: [{address: '<string>', network: '<string>'}]})
};
fetch('https://trails-api.sequence.app/rpc/Trails/YieldGetAggregateBalances', 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/YieldGetAggregateBalances",
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([
'queries' => [
[
'address' => '<string>',
'network' => '<string>'
]
]
]),
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/YieldGetAggregateBalances"
payload := strings.NewReader("{\n \"queries\": [\n {\n \"address\": \"<string>\",\n \"network\": \"<string>\"\n }\n ]\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/YieldGetAggregateBalances")
.header("Content-Type", "application/json")
.body("{\n \"queries\": [\n {\n \"address\": \"<string>\",\n \"network\": \"<string>\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://trails-api.sequence.app/rpc/Trails/YieldGetAggregateBalances")
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 \"queries\": [\n {\n \"address\": \"<string>\",\n \"network\": \"<string>\"\n }\n ]\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
YieldGetAggregateBalances
Fetch a wallet’s earn balances across chains and yield positions
POST
/
rpc
/
Trails
/
YieldGetAggregateBalances
YieldGetAggregateBalances returns a wallet's earn positions across chains.
curl --request POST \
--url https://trails-api.sequence.app/rpc/Trails/YieldGetAggregateBalances \
--header 'Content-Type: application/json' \
--data '
{
"queries": [
{
"address": "<string>",
"network": "<string>"
}
]
}
'import requests
url = "https://trails-api.sequence.app/rpc/Trails/YieldGetAggregateBalances"
payload = { "queries": [
{
"address": "<string>",
"network": "<string>"
}
] }
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({queries: [{address: '<string>', network: '<string>'}]})
};
fetch('https://trails-api.sequence.app/rpc/Trails/YieldGetAggregateBalances', 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/YieldGetAggregateBalances",
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([
'queries' => [
[
'address' => '<string>',
'network' => '<string>'
]
]
]),
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/YieldGetAggregateBalances"
payload := strings.NewReader("{\n \"queries\": [\n {\n \"address\": \"<string>\",\n \"network\": \"<string>\"\n }\n ]\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/YieldGetAggregateBalances")
.header("Content-Type", "application/json")
.body("{\n \"queries\": [\n {\n \"address\": \"<string>\",\n \"network\": \"<string>\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://trails-api.sequence.app/rpc/Trails/YieldGetAggregateBalances")
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 \"queries\": [\n {\n \"address\": \"<string>\",\n \"network\": \"<string>\"\n }\n ]\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
YieldGetAggregateBalances returns a wallet’s active yield positions across one or more chains. Use this to show users their current DeFi holdings — principal, earned yield, and which markets they are in.
The SDK’s useEarnBalances hook wraps this endpoint — prefer it in React apps.
Request Parameters
| Field | Type | Required | Description |
|---|---|---|---|
queries | object[] | Yes | Array of 1–25 balance queries |
| Field | Type | Required | Description |
|---|---|---|---|
address | string | Yes | Wallet address to look up |
network | string | Yes | Network identifier (e.g. "ethereum", "base", "polygon") |
You can pass up to 25 queries per request, enabling multi-chain balance lookups in a single call.
Response
Returnspayload containing balance records. Each balance entry includes:
| Field | Description |
|---|---|
yieldId | Market ID — matches the id field from YieldGetMarkets |
address | Wallet address |
network | Network the position is on |
amount | Balance amount in the market’s token |
amountUsd | USD value of the position |
Examples
Fetch balances on a single chain
const response = 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: '0xYourWalletAddress',
network: 'base',
},
],
}),
})
const { payload } = await response.json()
const balances = JSON.parse(payload)
balances.forEach(position => {
console.log(`${position.yieldId}: ${position.amountUsd} USD`)
})
Multi-chain balance lookup
const response = 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: '0xYourWalletAddress', network: 'base' },
{ address: '0xYourWalletAddress', network: 'ethereum' },
{ address: '0xYourWalletAddress', network: 'polygon' },
],
}),
})
const { payload } = await response.json()
const balances = JSON.parse(payload)
SDK alternative
In React, use theuseEarnBalances hook:
import { useEarnBalances } from '0xtrails'
// Single chain
const { data: balances } = useEarnBalances({
walletAddress: '0xYourWalletAddress',
chain: 'base',
})
// Multiple chains
const { data: balances } = useEarnBalances({
walletAddress: '0xYourWalletAddress',
chains: ['base', 'ethereum', 'polygon'],
})
See also
- YieldGetMarkets — Match
yieldIdagainst market IDs - YieldCreateExitAction — Build withdrawal transactions for active positions
- Markets & Providers — SDK hooks reference
Was this page helpful?