Skip to content

Commit

Permalink
Merge pull request #121 from valory-xyz/tanya/celo-bonding-fix
Browse files Browse the repository at this point in the history
(bond) fix: celo bonding products
  • Loading branch information
DavidMinarsch authored Oct 23, 2024
2 parents 8abf6b3 + 8ab13cc commit f9f0a3e
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,13 @@ const getCurrentPriceUniswapFn = memoize(async (tokenAddress) => {
throw new Error(`Chain id not found for provided token address: ${tokenAddress}`);
}

const contract = getUniswapV2PairContractByChain(tokenAddress, chainId);
const tokenOriginAddress = LP_PAIRS[tokenAddress].originAddress;

if (!tokenOriginAddress) {
throw new Error(`Origin address not found for provided token address: ${tokenAddress}`);
}

const contract = getUniswapV2PairContractByChain(tokenOriginAddress, chainId);

const [totalSupply, reserves, token0] = await Promise.all([
contract.read.totalSupply(),
Expand All @@ -220,7 +226,7 @@ const getCurrentPriceUniswapFn = memoize(async (tokenAddress) => {

const olasTokenAddress = ADDRESSES[chainId].olasAddress;
const reservesOlas = areAddressesEqual(token0, olasTokenAddress) ? reserve0 : reserve1;
const priceLp = ethers.parseUnits(`${reservesOlas / totalSupply}`, 'ether');
const priceLp = (reservesOlas * BigInt(10 ** 18)) / totalSupply;
return priceLp;
});

Expand Down

0 comments on commit f9f0a3e

Please sign in to comment.