-
Notifications
You must be signed in to change notification settings - Fork 6.3k
feat(solid): Terra2 TVL adapter #16057
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
feat(solid): Terra2 TVL adapter #16057
Conversation
solid: fix lint (no-empty) by skipping failed pair in catch, row 126
projects/solid/index.js
Outdated
async function getLunaUsd() { | ||
try { | ||
const { data } = await axios.get("https://coins.llama.fi/prices/current/coingecko:terra-luna-2"); | ||
return data?.coins?.["coingecko:terra-luna-2"]?.price ?? 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why are we fetching price here instead of just returning a token balance?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the feedback. For standard tokens I agree we should only return balances.
However, ampLUNA and bLUNA are LSTs (liquid staking derivatives) of LUNA, so their value is not 1:1 with LUNA but determined by an exchange rate.
Without applying the exchange rate, the TVL would be under/over-reported.
That’s why we fetch both balance and price (exchange rate) here directly.
If you prefer, we can instead return balances only and set up separate price feeds for ampLUNA and bLUNA, but this seemed the simpler integration.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm getting 501s from the Terra LCD when I try to test this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We will move ampLUNA and bLUNA pricing into our coin prices server. Is there a better way to get the bLUNA rate than reading pool weights?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated the adapter to return balances only and removed all pricing/exchange-rate logic.
- ampLUNA/bLUNA (and other assets) are now reported as raw balances.
- Pricing, including LST exchange rates, should be handled by DefiLlama coin-prices infra.
- Added TERRA_LCD env var (default: https://terra-api.cosmosrescue.dev:8443).
- CW20 balances via wasm smart queries; IBC/native via bank balances.
- Keys use "terra2:<cw20_contract>" and "terra2:<ibc_denom>".
Some Terra LCDs return 501/5xx. For local testing, please use:
https://terra-api.cosmosrescue.dev:8443
Examples:
- CW20 smart query:
GET /cosmwasm/wasm/v1/contract//smart/<base64({"balance":{"address":""}})> - Bank balances:
GET /cosmos/bank/v1beta1/balances/
You can also override via: export TERRA_LCD=https://terra-api.cosmosrescue.dev:8443
For LSTs please prefer on-chain exchange rate over pool weights.
bLUNA:
price(bLUNA) = exchange_rate * price(LUNA)
exchange_rate can be obtained from the hub/minter contract state
(either a direct "exchange_rate" field, or computed as total_bonded / total_shares).
ampLUNA:
price(ampLUNA) = exchange_rate * price(LUNA)
exchange_rate available via Eris public API (and on-chain as well).
Happy to provide exact hub/minter contract addresses & query schema if helpful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hey could you give me more details on how to fetch the exchange_rate
for bLUNA please? Thanks for your help
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bLUNA doesn’t expose a direct exchange_rate endpoint like ampLUNA (Eris API).
Instead, we calculate its effective rate via liquidity-weighted pool prices:
• Astroport bLUNA–LUNA pool (contract: terra1h32epkd72x7st0wk49z35qlpsxf26pw4ydacs8acq6uka7hgshmq7z7vl9)
• White Whale bLUNA–LUNA pool (contract: terra1j5znhs9jeyty9u9jcagl3vefkvzwqp6u9tq9a3e5qrz4gmj2udyqp0z0xc)
For each pool:
1. Query pool reserves (via LCD wasm/contract/{pair}/smart with { pool: {} }).
2. Extract LUNA reserve (uluna) and bLUNA reserve (CW20 address terra17aj4ty4sz4yhgm08na8drc0v03v2jwr3waxcqrwhajj729zhl7zqnpc0ml).
3. Compute the price as LUNA_reserve / bLUNA_reserve.
4. Weight the rate by the LUNA-side liquidity, to avoid small pools skewing results.
5. Skip pools if their LUNA-side liquidity < $3k (to filter out dust).
6. Final bLUNA exchange_rate = weighted average across valid pools.
This way, the exchange_rate dynamically reflects the actual market ratio of bLUNA to LUNA.
projects/solid/index.js
Outdated
|
||
for (const pair of ADDR.bLUNA.pairs) { | ||
try { | ||
const pool = await smartQuery(pair, { pool: {} }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is giving me for both pools listed
{
code: 12,
message: "Not Implemented",
details: [
],
}
Is this expected? Using https://terra-api.cosmosrescue.dev:8443
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Im aware this is an old commit, trying to derive bLuna price
NOTE
Please enable "Allow edits by maintainers" while putting up the PR.
package-lock.json
file as part of your changes, we use lockfileVersion 2, and most use v1 and using that messes up our CIName (to be shown on DefiLlama):
SOLID
Twitter Link:
https://x.com/solid_capa
List of audit links if any:
• https://github.com/SCV-Security/PublicReports/blob/main/CW/Capapult/Capapult%20-%20Money%20Market%20Contracts%20-%20Audit%20Report%20v1.0%20.pdf
• https://github.com/SCV-Security/PublicReports/blob/fa51bf944593bf18d128b4f812b3150b218f0d25/Capapult%2FCapapult%20Finance%20-%20Oracle%20Contract%20-%20Audit%20Report%20v1.0.pdf
Website Link:
https://solid.online
Logo (High resolution, will be shown with rounded borders):
https://raw.githubusercontent.com/cosmos/chain-registry/master/terra2/images/solid.png
Current TVL:
95.8k USD (August 24, 2025) and dynamic — calculated via custody contracts (collaterals).
Treasury Addresses (if the protocol has treasury):
None
Chain:
Terra2 (Phoenix)
Coingecko ID:
solid-2 (https://api.coingecko.com/api/v3/coins/list)
Coinmarketcap ID:
N/A
Short Description (to be shown on DefiLlama):
SOLID is an over-collateralized stablecoin protocol on Terra2 (Phoenix). Users can deposit LSTs and IBC assets to mint the stablecoin SOLID. Its governance token is CAPA.
Token address and ticker if any:
• SOLID (stablecoin) → Contract: terra10aa3zdkrc7jwuf8ekl3zq7e7m42vmzqehcmu74e4egc7xkm5kr2s0muyst
• CAPA (governance token) → Contract: terra1t4p3u8khpd7f8qzurwyafxt648dya6mp6vur3vaapswt6m24gkuqrfdhar
Blockchain Explorers:
• https://www.mintscan.io/terra
• https://terrasco.pe
Category:
protocol
Oracle Provider(s):
• ampLUNA: Eris Protocol API
• bLUNA: Weighted pool price from Astroport & White Whale
• IBC assets: on-chain custody balances
Implementation Details:
• ampLUNA price pulled from Eris Protocol API.
• bLUNA price calculated via weighted average of Astroport & White Whale pools.
• USDC (Noble), axl.WBTC, axl.WETH, wSOL, wBNB read directly from custody contracts.
Documentation/Proof:
• https://www.erisprotocol.com/terra/amplifier/LUNA
• https://app.backbonelabs.io/liquid-staking/gravedigger/phoenix-1
• https://github.com/SCV-Security/PublicReports
• https://terra-api.cosmosrescue.dev:8443
forkedFrom:
None
methodology (what is being counted as TVL, how is TVL being calculated):
TVL = sum of all collateral vault balances:
• ampLUNA (Eris LST of LUNA): exchange rate from Eris API, with $3k min-effective filter.
• bLUNA (Backbone LST of LUNA): liquidity-weighted average rate from Astroport & White Whale bLUNA–LUNA pools.
• USDC (Noble IBC), wETH.axl, wBTC.axl, wSOL.wormhole, wBNB.wormhole: balances directly from custody contracts on Terra.
Github org/user (Optional):
https://github.com/solid-online
Notes:
• Uses LCD: https://terra-api.cosmosrescue.dev:8443
• Only counts collateral (no governance tokens, no protocol-owned assets).
• Custody contracts verified via on-chain registry and solid-online GitHub.