Skip to content
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

stratum-exchange #1233

Merged
merged 8 commits into from
Mar 18, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix wrong rewardRate
  • Loading branch information
od-git committed Mar 17, 2024
commit e04f3b048479e1671e98831b7e00a4d1eddcc213
24 changes: 13 additions & 11 deletions src/adaptors/stratum-exchange/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,8 @@ const getApy = async () => {
permitFailure: true,
})
).output.map((o) => o.output);
const pool2rewardRate = {};
allPools.forEach((pool, i) => pool2rewardRate[pool] = rewardRate[i]);

const tokens = [
...new Set(
Expand Down Expand Up @@ -226,7 +228,7 @@ const getApy = async () => {
// Generate resulting SDK Pool objects
//

const poolDescriptorsOfPairs = allPairs.map((p, i) => {
const poolDescriptorsOfPairs = allPairs.map((pair, i) => {
const pairMeta = metaDataOfPairs[i];
const r0 = pairMeta.r0 / pairMeta.dec0;
const r1 = pairMeta.r1 / pairMeta.dec1;
Expand All @@ -237,11 +239,11 @@ const getApy = async () => {
const tvlUsd = r0 * p0 + r1 * p1;

const apyReward =
(((rewardRate[i] / 1e18) * 86400 * 365 * prices[`mantle:${STRAT}`]?.price) /
(((pool2rewardRate[pair] / 1e18) * 86400 * 365 * prices[`mantle:${STRAT}`]?.price) /
tvlUsd) * 100;

return {
pool: p,
pool: pair,
chain: utils.formatChain(chain),
project: 'stratum-exchange',
symbol: utils.formatSymbol(symbolsOfPairs[i].split('-')[1]),
Expand All @@ -250,34 +252,34 @@ const getApy = async () => {
rewardTokens: apyReward ? [STRAT] : [],
underlyingTokens: [pairMeta.t0, pairMeta.t1],
poolMeta: pairMeta.st
? `sAMM: stable V2 pair ${pool2fee[p] / 100}%`
: `vAMM: volatile V2 pair ${pool2fee[p] / 100}%`,
url: `https://app.stratumexchange.com/liquidity/${p.split('-')[0]}`,
? `sAMM: stable V2 pair ${pool2fee[pair] / 100}%`
: `vAMM: volatile V2 pair ${pool2fee[pair] / 100}%`,
url: `https://app.stratumexchange.com/liquidity/${pair}`,
};
});

const poolDescriptorsOfMultipools = allMultipools.map((p, i) => {
const poolDescriptorsOfMultipools = allMultipools.map((multipool, i) => {
let tvlUsd = 0;
pooledTokensOfMultipools[i].forEach((tokenAddr, j) =>
tvlUsd += (multipoolBalances[i][j] / (10 ** token2decimals[tokenAddr]))
* prices[`mantle:${tokenAddr}`]?.price
);

const apyReward =
(((rewardRate[i] / 1e18) * 86400 * 365 * prices[`mantle:${STRAT}`]?.price) /
(((pool2rewardRate[multipool] / 1e18) * 86400 * 365 * prices[`mantle:${STRAT}`]?.price) /
tvlUsd) * 100;

return {
pool: p,
pool: multipool,
chain: utils.formatChain(chain),
project: 'stratum-exchange',
symbol: utils.formatSymbol(symbolsOfMultipools[i]),
tvlUsd,
apyReward,
rewardTokens: apyReward ? [STRAT] : [],
underlyingTokens: pooledTokensOfMultipools[i],
poolMeta: `multipool (curve style) ${pool2fee[p] / 100}%`,
url: `https://app.stratumexchange.com/liquidity/${p.split('-')[0]}`,
poolMeta: `multipool (curve style) ${pool2fee[multipool] / 100}%`,
url: `https://app.stratumexchange.com/liquidity/${multipool}`,
};
});

Expand Down