from compass_api_sdk import CompassAPI, models
with CompassAPI(
api_key_auth="<YOUR_API_KEY_HERE>",
) as compass_api:
res = compass_api.risk_yield.risk_yield_positions(chain=models.V2RiskYieldPositionsChain.ROBINHOOD, owner="0x06A9aF046187895AcFc7258450B15397CAc67400", include_closed=False)
# Handle response
print(res)import { CompassApiSDK } from "@compass-labs/api-sdk";
const compassApiSDK = new CompassApiSDK({
apiKeyAuth: "<YOUR_API_KEY_HERE>",
});
async function run() {
const result = await compassApiSDK.riskYield.riskYieldPositions({
chain: "robinhood",
owner: "0x06A9aF046187895AcFc7258450B15397CAc67400",
includeClosed: false,
});
console.log(result);
}
run();curl --request GET \
--url https://api.compasslabs.ai/v2/risk_yield/positions \
--header 'x-api-key: <api-key>'const options = {method: 'GET', headers: {'x-api-key': '<api-key>'}};
fetch('https://api.compasslabs.ai/v2/risk_yield/positions', 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://api.compasslabs.ai/v2/risk_yield/positions",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"x-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.compasslabs.ai/v2/risk_yield/positions"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("x-api-key", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.compasslabs.ai/v2/risk_yield/positions")
.header("x-api-key", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.compasslabs.ai/v2/risk_yield/positions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["x-api-key"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"account": "<string>",
"positions": [
{
"token_id": 123,
"dex_version": "V3",
"token0": {
"address": "<string>",
"symbol": "<string>",
"name": "<string>",
"decimals": 123,
"kind": "OTHER",
"price_usd": "<string>",
"price_source": "CHAINLINK",
"price_confidence": "<string>",
"stock_ticker": "<string>"
},
"token1": {
"address": "<string>",
"symbol": "<string>",
"name": "<string>",
"decimals": 123,
"kind": "OTHER",
"price_usd": "<string>",
"price_source": "CHAINLINK",
"price_confidence": "<string>",
"stock_ticker": "<string>"
},
"fee_ppm": 123,
"range": {
"tick_lower": 123,
"tick_upper": 123,
"price_lower": "<string>",
"price_upper": "<string>",
"width_lower_pct": "<string>",
"width_upper_pct": "<string>",
"is_full_range": true
},
"liquidity": "<string>",
"in_range": true,
"amount0": "<string>",
"amount1": "<string>",
"unclaimed_fees0": "<string>",
"unclaimed_fees1": "<string>",
"cost_basis": {
"source": "indexed",
"amount0": "<string>",
"amount1": "<string>",
"value_usd": "<string>",
"opened_at": "2023-11-07T05:31:56Z"
},
"status": "ACTIVE",
"pool_id": 123,
"pool_address": "<string>",
"current_tick": 123,
"current_price": "<string>",
"out_of_range_side": "<string>",
"value_usd": "<string>",
"unclaimed_fees_usd": "<string>",
"fees_collected0": "<string>",
"fees_collected1": "<string>",
"hold_value_usd": "<string>",
"il_usd": "<string>",
"il_pct": "<string>",
"fees_earned_usd": "<string>",
"pnl_usd": "<string>",
"fee_apr_since_open_pct": "<string>",
"age_days": "<string>",
"needs_rebalance": false,
"rebalance_reasons": [
"OUT_OF_RANGE"
],
"needs_collect": false,
"lp_earns_fees": true
}
],
"total_value_usd": "<string>",
"total_unclaimed_fees_usd": "<string>",
"total_pnl_usd": "<string>",
"prices_updated_at": "2023-11-07T05:31:56Z"
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}List LP positions
Your liquidity positions: what they hold, what they cost, what they paid.
Only the first of those is on chain. A position reports its liquidity and
its range; it does not report the amounts that opened it or what has already
been collected. Those come from recorded events, and where there are none
cost_basis.source is unavailable and the PnL fields are null rather than
guessed — an invented cost basis would make every number derived from it
wrong in the same direction.
hold_value_usd is what the deposited amounts would be worth if they had
simply been held. The gap between that and value_usd is impermanent loss,
and it is the number that decides whether the fees were worth it.
needs_rebalance and rebalance_reasons say what the API would look at, not
what it will do: rebalancing realizes the loss, pays gas twice and a swap,
and puts the position back at risk from a new price.
from compass_api_sdk import CompassAPI, models
with CompassAPI(
api_key_auth="<YOUR_API_KEY_HERE>",
) as compass_api:
res = compass_api.risk_yield.risk_yield_positions(chain=models.V2RiskYieldPositionsChain.ROBINHOOD, owner="0x06A9aF046187895AcFc7258450B15397CAc67400", include_closed=False)
# Handle response
print(res)import { CompassApiSDK } from "@compass-labs/api-sdk";
const compassApiSDK = new CompassApiSDK({
apiKeyAuth: "<YOUR_API_KEY_HERE>",
});
async function run() {
const result = await compassApiSDK.riskYield.riskYieldPositions({
chain: "robinhood",
owner: "0x06A9aF046187895AcFc7258450B15397CAc67400",
includeClosed: false,
});
console.log(result);
}
run();curl --request GET \
--url https://api.compasslabs.ai/v2/risk_yield/positions \
--header 'x-api-key: <api-key>'const options = {method: 'GET', headers: {'x-api-key': '<api-key>'}};
fetch('https://api.compasslabs.ai/v2/risk_yield/positions', 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://api.compasslabs.ai/v2/risk_yield/positions",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"x-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.compasslabs.ai/v2/risk_yield/positions"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("x-api-key", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.compasslabs.ai/v2/risk_yield/positions")
.header("x-api-key", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.compasslabs.ai/v2/risk_yield/positions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["x-api-key"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"account": "<string>",
"positions": [
{
"token_id": 123,
"dex_version": "V3",
"token0": {
"address": "<string>",
"symbol": "<string>",
"name": "<string>",
"decimals": 123,
"kind": "OTHER",
"price_usd": "<string>",
"price_source": "CHAINLINK",
"price_confidence": "<string>",
"stock_ticker": "<string>"
},
"token1": {
"address": "<string>",
"symbol": "<string>",
"name": "<string>",
"decimals": 123,
"kind": "OTHER",
"price_usd": "<string>",
"price_source": "CHAINLINK",
"price_confidence": "<string>",
"stock_ticker": "<string>"
},
"fee_ppm": 123,
"range": {
"tick_lower": 123,
"tick_upper": 123,
"price_lower": "<string>",
"price_upper": "<string>",
"width_lower_pct": "<string>",
"width_upper_pct": "<string>",
"is_full_range": true
},
"liquidity": "<string>",
"in_range": true,
"amount0": "<string>",
"amount1": "<string>",
"unclaimed_fees0": "<string>",
"unclaimed_fees1": "<string>",
"cost_basis": {
"source": "indexed",
"amount0": "<string>",
"amount1": "<string>",
"value_usd": "<string>",
"opened_at": "2023-11-07T05:31:56Z"
},
"status": "ACTIVE",
"pool_id": 123,
"pool_address": "<string>",
"current_tick": 123,
"current_price": "<string>",
"out_of_range_side": "<string>",
"value_usd": "<string>",
"unclaimed_fees_usd": "<string>",
"fees_collected0": "<string>",
"fees_collected1": "<string>",
"hold_value_usd": "<string>",
"il_usd": "<string>",
"il_pct": "<string>",
"fees_earned_usd": "<string>",
"pnl_usd": "<string>",
"fee_apr_since_open_pct": "<string>",
"age_days": "<string>",
"needs_rebalance": false,
"rebalance_reasons": [
"OUT_OF_RANGE"
],
"needs_collect": false,
"lp_earns_fees": true
}
],
"total_value_usd": "<string>",
"total_unclaimed_fees_usd": "<string>",
"total_pnl_usd": "<string>",
"prices_updated_at": "2023-11-07T05:31:56Z"
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}Query Parameters
robinhood The wallet that owns the Risk Yield Account.
Which Uniswap deployment a pool belongs to.
v3 pools hold their own tokens and pay LPs the fee tier. v4 pools live in a shared PoolManager and may route the fee through a hook, which is where the launchpad pools' zero LP yield comes from.
V3, V4 Include positions with no liquidity and nothing owed. Off by default: a closed position is history, not a holding.
Was this page helpful?