-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
145 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,39 @@ | ||
import { curve } from "../../curve.js"; | ||
import { PoolTemplate } from "../PoolTemplate.js"; | ||
import { _calcExpectedAmounts, _calcExpectedUnderlyingAmountsMeta } from "./common.js"; | ||
import {IStatsPool} from "../subClasses/statsPool"; | ||
|
||
|
||
// @ts-ignore | ||
export const poolBalancesMetaMixin: PoolTemplate = { | ||
async statsUnderlyingBalances(): Promise<string[]> { | ||
const swapContract = curve.contracts[this.address].multicallContract; | ||
const contractCalls = this.wrappedCoins.map((_, i) => swapContract.balances(i)); | ||
export const poolBalancesMetaMixin: IStatsPool = { | ||
async underlyingBalances(): Promise<string[]> { | ||
const swapContract = curve.contracts[this.pool.address].multicallContract; | ||
const contractCalls = this.pool.wrappedCoins.map((_, i) => swapContract.balances(i)); | ||
const _poolWrappedBalances: bigint[] = await curve.multicallProvider.all(contractCalls); | ||
const [_poolMetaCoinBalance] = _poolWrappedBalances.splice(this.metaCoinIdx, 1); | ||
const [_poolMetaCoinBalance] = _poolWrappedBalances.splice(this.pool.metaCoinIdx, 1); | ||
const _poolUnderlyingBalances = _poolWrappedBalances; | ||
const basePool = new PoolTemplate(this.basePool); | ||
const basePool = new PoolTemplate(this.pool.basePool); | ||
const _basePoolExpectedAmounts = basePool.isMeta ? | ||
await _calcExpectedUnderlyingAmountsMeta.call(basePool, _poolMetaCoinBalance) : | ||
await _calcExpectedAmounts.call(basePool, _poolMetaCoinBalance); | ||
_poolUnderlyingBalances.splice(this.metaCoinIdx, 0, ..._basePoolExpectedAmounts); | ||
_poolUnderlyingBalances.splice(this.pool.metaCoinIdx, 0, ..._basePoolExpectedAmounts); | ||
|
||
return _poolUnderlyingBalances.map((_b: bigint, i: number) => curve.formatUnits(_b, this.underlyingDecimals[i])) | ||
return _poolUnderlyingBalances.map((_b: bigint, i: number) => curve.formatUnits(_b, this.pool.underlyingDecimals[i])) | ||
}, | ||
} | ||
|
||
// @ts-ignore | ||
export const poolBalancesLendingMixin: PoolTemplate = { | ||
async statsUnderlyingBalances(): Promise<string[]> { | ||
const swapContract = curve.contracts[this.address].multicallContract; | ||
const contractCalls = this.wrappedCoins.map((_, i) => swapContract.balances(i)); | ||
export const poolBalancesLendingMixin: IStatsPool = { | ||
async underlyingBalances(): Promise<string[]> { | ||
const swapContract = curve.contracts[this.pool.address].multicallContract; | ||
const contractCalls = this.pool.wrappedCoins.map((_, i) => swapContract.balances(i)); | ||
const _poolWrappedBalances: bigint[] = await curve.multicallProvider.all(contractCalls); | ||
|
||
// @ts-ignore | ||
const _rates: bigint[] = await this._getRates(); | ||
const _poolUnderlyingBalances = _poolWrappedBalances.map( | ||
(_b: bigint, i: number) => _b * _rates[i] / curve.parseUnits(String(10**18), 0)); | ||
|
||
return _poolUnderlyingBalances.map((_b: bigint, i: number) => curve.formatUnits(_b, this.underlyingDecimals[i])) | ||
return _poolUnderlyingBalances.map((_b: bigint, i: number) => curve.formatUnits(_b, this.pool.underlyingDecimals[i])) | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters