Skip to content

Commit 5fb66bf

Browse files
authored
feat: add marginfi-lst adapter (#2390)
1 parent 3a939e6 commit 5fb66bf

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

src/adaptors/marginfi-lst/index.js

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
const axios = require('axios');
2+
const { getTotalSupply } = require('../utils');
3+
4+
const LST_MINT = 'LSTxxxnJzKDFSLr4dUkPcmCf5VyryEqzPLz5j4bpxFp';
5+
const priceKey = `solana:${LST_MINT}`;
6+
const SOL = 'So11111111111111111111111111111111111111112';
7+
8+
const apy = async () => {
9+
const [totalSupply, priceRes, apyRes] = await Promise.all([
10+
getTotalSupply(LST_MINT),
11+
axios.get(`https://coins.llama.fi/prices/current/${priceKey}`),
12+
axios.get(
13+
`https://extra-api.sanctum.so/v1/apy/latest?lst=${LST_MINT}`
14+
),
15+
]);
16+
17+
const currentPrice = priceRes.data.coins[priceKey]?.price;
18+
if (!currentPrice) throw new Error('Unable to fetch LST price');
19+
20+
const apyRaw = apyRes?.data?.apys?.[LST_MINT];
21+
if (!Number.isFinite(apyRaw))
22+
throw new Error(`Unable to fetch APY for ${LST_MINT}`);
23+
const apyBase = apyRaw * 100;
24+
25+
return [
26+
{
27+
pool: LST_MINT,
28+
chain: 'Solana',
29+
project: 'marginfi-lst',
30+
symbol: 'LST',
31+
tvlUsd: totalSupply * currentPrice,
32+
apyBase,
33+
underlyingTokens: [SOL],
34+
token: LST_MINT,
35+
poolMeta: '0% rewards fee',
36+
},
37+
];
38+
};
39+
40+
module.exports = {
41+
timetravel: false,
42+
apy,
43+
url: 'https://app.marginfi.com/stake',
44+
};

0 commit comments

Comments
 (0)