Skip to content

Commit

Permalink
fix: compute only the stakes liqLIT
Browse files Browse the repository at this point in the history
  • Loading branch information
0xtekgrinder committed Sep 15, 2023
1 parent ca5c514 commit 3f2bf1e
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions src/adaptors/liquis/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ const zeroAddress = '0x0000000000000000000000000000000000000000';
const weth = '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2';
const bal = '0xba100000625a3754423978a60c9317c58a424e3D';

const rewardPool = {
ethereum: '0x7Ea6930a9487ce8d039f7cC89432435E6D5AcB23',
};

const lit80weth20 = {
ethereum: '0x9232a548DD9E81BaC65500b5e0d918F8Ba93675C',
};
Expand Down Expand Up @@ -135,14 +139,9 @@ const liqLitPool = async (chain, olitprice, liqprice) => {

// Compute tvl
let tvlUsd = 0;
const { output: veLitTotalSupply } = await sdk.api.erc20.totalSupply({
target: veLit[chain],
});
const { output: veBalance } = await sdk.api.erc20.balanceOf({
target: veLit[chain],
owner: voterProxy[chain],
const { output: veBalance } = await sdk.api.erc20.totalSupply({
target: rewardPool[chain],
});
const liqRatio = veBalance / veLitTotalSupply;
const balancerToken = lit80weth20[chain];
const owner = veLit[chain];
const lpSupply = (
Expand All @@ -155,7 +154,6 @@ const liqLitPool = async (chain, olitprice, liqprice) => {
params: owner,
})
)?.output;
const ratio = lpTokens / lpSupply;
const poolId = (
await sdk.api.abi.call({
abi: balancerTokenABI.find((n) => n.name == 'getPoolId'),
Expand All @@ -177,10 +175,9 @@ const liqLitPool = async (chain, olitprice, liqprice) => {
)?.output;
pools.tokens.forEach((v, i) => {
tvlUsd +=
(pools.balances[i] / 1e18) *
prices[`${chain}:${v}`].price *
ratio *
liqRatio;
(pools.balances[i] / lpSupply) *
(veBalance / 1e18) *
prices[`${chain}:${v}`].price;
});

const balRate = (
Expand Down Expand Up @@ -223,7 +220,7 @@ const liqLitPool = async (chain, olitprice, liqprice) => {
const olitUsd = olitAmount * olitprice;
const liqUsd = liqAmount * liqprice;

const apyBase = (balUsd / tvlUsd + wethUsd / tvlUsd) * 100;
const apyBase = (balUsd / tvlUsd + wethUsd / tvlUsd) * 100;
const apyReward = (liqUsd / tvlUsd + olitUsd / tvlUsd) * 100;

return {
Expand Down

0 comments on commit 3f2bf1e

Please sign in to comment.