diff --git a/README.md b/README.md index fcd690a..421c047 100644 --- a/README.md +++ b/README.md @@ -164,7 +164,11 @@ import crvusd from "@curvefi/stablecoin-api"; // 1257.43 await crvusd.totalSupply(); // sum(llammasSupply) + sum(pegKeepersDebt) - // 1415.12 + // { + // total: '1415.12', + // minted: '1415.12', + // pegKeepersDebt: '0' + // } })() ``` diff --git a/package.json b/package.json index e96aa03..9e2d449 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@curvefi/stablecoin-api", - "version": "1.5.2", + "version": "1.5.3", "description": "JavaScript library for Curve Stablecoin", "main": "lib/index.js", "author": "Macket", diff --git a/src/utils.ts b/src/utils.ts index a873884..f86f8fa 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -265,7 +265,7 @@ export const getUsdRate = async (coin: string): Promise => { return _usdRatesCache[coinAddress]['rate'] } -export const totalSupply = async (): Promise => { +export const totalSupply = async (): Promise<{ total: string, minted: string, pegKeepersDebt: string }> => { const calls = []; for (const llammaId of crvusd.getLlammaList()) { const controllerAddress = crvusd.constants.LLAMMAS[llammaId].controller_address; @@ -277,14 +277,15 @@ export const totalSupply = async (): Promise => { } const res: ethers.BigNumber[] = await crvusd.multicallProvider.all(calls); - let totalSupplyBN = BN(0); + let mintedBN = BN(0); for (let i = 0; i < crvusd.getLlammaList().length; i++) { const [_minted, _redeemed] = res.splice(0, 2); - totalSupplyBN = toBN(_minted).minus(toBN(_redeemed)).plus(totalSupplyBN); + mintedBN = toBN(_minted).minus(toBN(_redeemed)).plus(mintedBN); } + let pegKeepersBN = BN(0); for (const _pegKeeperDebt of res) { - totalSupplyBN = totalSupplyBN.plus(toBN(_pegKeeperDebt)); + pegKeepersBN = pegKeepersBN.plus(toBN(_pegKeeperDebt)); } - return totalSupplyBN.toString(); + return { total: mintedBN.plus(pegKeepersBN).toString(), minted: mintedBN.toString(), pegKeepersDebt: pegKeepersBN.toString() }; } \ No newline at end of file