diff --git a/.changeset/fluffy-suits-complain.md b/.changeset/fluffy-suits-complain.md new file mode 100644 index 0000000000..5acddbc377 --- /dev/null +++ b/.changeset/fluffy-suits-complain.md @@ -0,0 +1,5 @@ +--- +"@venusprotocol/evm": patch +--- + +reinstate useGetPools hook refactor diff --git a/apps/evm/__mocks__/@venusprotocol/chains.ts b/apps/evm/__mocks__/@venusprotocol/chains.ts new file mode 100644 index 0000000000..b2eaf8c3ae --- /dev/null +++ b/apps/evm/__mocks__/@venusprotocol/chains.ts @@ -0,0 +1,39 @@ +import { ChainId } from '__mocks__/models/chains'; +import { isolatedPool, legacyCorePool } from '__mocks__/models/pools'; +import { bnb, eth } from '__mocks__/models/tokens'; +export { ChainId } from '__mocks__/models/chains'; + +export const chainMetadata = { + [ChainId.BSC_MAINNET]: { + name: 'BNB Chain', + logoSrc: 'fake-logo-src-bsc-mainnet', + explorerUrl: 'https://bscscan.com', + layerZeroScanUrl: 'https://layerzeroscan.com', + blockTimeMs: 3000, + blocksPerDay: 28800, + corePoolComptrollerContractAddress: legacyCorePool.comptrollerAddress, + nativeToken: bnb, + }, + [ChainId.BSC_TESTNET]: { + name: 'BNB testnet', + logoSrc: 'fake-logo-src-bsc-testnet', + explorerUrl: 'https://testnet.bscscan.com', + layerZeroScanUrl: 'https://testnet.layerzeroscan.com', + blockTimeMs: 3000, + blocksPerDay: 28800, + corePoolComptrollerContractAddress: legacyCorePool.comptrollerAddress, + nativeToken: bnb, + }, + [ChainId.ETHEREUM]: { + name: 'Ethereum', + logoSrc: 'fake-logo-src-bsc-ethereum', + explorerUrl: 'https://etherscan.io', + layerZeroScanUrl: 'https://layerzeroscan.com', + blockTimeMs: 12000, + blocksPerDay: 7200, + corePoolComptrollerContractAddress: isolatedPool.comptrollerAddress, + lstPoolComptrollerContractAddress: '0xF522cd0360EF8c2FF48B648d53EA1717Ec0F3Ac3', + lstPoolVWstEthContractAddress: '0x4a240F0ee138697726C8a3E43eFE6Ac3593432CB', + nativeToken: eth, + }, +}; diff --git a/apps/evm/package.json b/apps/evm/package.json index e4dab1a24f..7b13538183 100644 --- a/apps/evm/package.json +++ b/apps/evm/package.json @@ -47,6 +47,7 @@ "@sentry/react": "^8.11.0", "@sentry/vite-plugin": "^2.20.0", "@tanstack/react-query": "^5.48.0", + "@venusprotocol/chains": "*", "@wagmi/core": "^2.11.6", "@yornaath/batshit": "^0.10.1", "bignumber.js": "^9.1.1", diff --git a/apps/evm/src/__mocks__/api/markets.json b/apps/evm/src/__mocks__/api/markets.json deleted file mode 100644 index 7a3e1821b0..0000000000 --- a/apps/evm/src/__mocks__/api/markets.json +++ /dev/null @@ -1,1283 +0,0 @@ -{ - "limit": 100, - "page": 0, - "total": 22, - "result": [ - { - "address": "0x714db6c38A17883964B68a07d56cE331501d9eb6", - "chainId": "97", - "symbol": "vAAVE", - "name": "Venus AAVE", - "underlyingAddress": "0x4B7268FC7C727B88c5Fc127D41b491BfAe63e144", - "underlyingName": "Aave Token", - "underlyingSymbol": "AAVE", - "underlyingDecimal": 18, - "borrowerDailyXvsMantissa": "12500000000000006400", - "supplierDailyXvsMantissa": "12500000000000006400", - "xvsBorrowIndex": "85118563287737462261471437372685634421", - "xvsSupplyIndex": "6601715752309389703740065071275333955", - "borrowRatePerBlock": "794031465", - "supplyRatePerBlock": "33138342", - "exchangeRateMantissa": "2155014452534515249", - "underlyingPriceMantissa": "124208800000000000000", - "totalBorrowsMantissa": "932010469362685774563", - "totalSupplyMantissa": "10362809970497229629502", - "cashMantissa": "21399994785927617654795", - "totalReservesMantissa": "0", - "reserveFactorMantissa": "0", - "collateralFactorMantissa": "550000000000000000", - "borrowApy": "0.835863542000393987", - "supplyApy": "0.034745604995460892", - "borrowXvsApy": "28.638082890878194012", - "supplyXvsApy": "1.056900678515979334", - "borrowXvsApr": "0.2526119390", - "supplyXvsApr": "0.0105425809", - "liquidityCents": "265806767.2366326275760901", - "tokenPriceCents": "12420.88", - "totalDistributedMantissa": "465622489062457507", - "lastCalculatedXvsAccruedBlockNumber": "40813640", - "supplyCapsMantissa": "115792089237316195423570985008687907853269984665640564039457584007913129639935", - "borrowCapsMantissa": "0", - "borrowerCount": 8, - "supplierCount": 9, - "estimatedPrimeBorrowApyBoost": null, - "estimatedPrimeSupplyApyBoost": null, - "pausedActionsBitmap": 0, - "isListed": true, - "poolComptrollerAddress": "0x94d1820b2D1c7c7452A163983Dc888CEC546b77D", - "rewardsDistributors": [ - { - "marketAddress": "0x714db6c38A17883964B68a07d56cE331501d9eb6", - "rewardTokenAddress": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", - "chainId": "97", - "lastRewardingSupplyBlockOrTimestamp": "0", - "lastRewardingBorrowBlockOrTimestamp": "0", - "supplySpeed": "434027777777778", - "borrowSpeed": "434027777777778", - "priceMantissa": "6409500000000000000", - "rewardsDistributorContractAddress": null, - "createdAt": "2024-06-18T14:48:54.000Z", - "updatedAt": "2024-09-03T14:58:33.000Z" - } - ] - }, - { - "address": "0x37C28DE42bA3d22217995D146FC684B2326Ede64", - "chainId": "97", - "symbol": "vADA", - "name": "Venus ADA", - "underlyingAddress": "0xcD34BC54106bd45A04Ed99EBcC2A6a3e70d7210F", - "underlyingName": "Binance-Peg Cardano Token", - "underlyingSymbol": "ADA", - "underlyingDecimal": 18, - "borrowerDailyXvsMantissa": "87499999999999872000", - "supplierDailyXvsMantissa": "87499999999999872000", - "xvsBorrowIndex": "1017736040995462295185676239178815537", - "xvsSupplyIndex": "1136999179013848911275960797314132729007991", - "borrowRatePerBlock": "5878105048", - "supplyRatePerBlock": "2456497735", - "exchangeRateMantissa": "216243797287914552404234393", - "underlyingPriceMantissa": "320610000000000000", - "totalBorrowsMantissa": "9089570141028019779483855", - "totalSupplyMantissa": "100582091306961905", - "cashMantissa": "12660683222349162890595202", - "totalReservesMantissa": "0", - "reserveFactorMantissa": "0", - "collateralFactorMantissa": "600000000000000000", - "borrowApy": "6.355400573963748019", - "supplyApy": "2.608546875574209802", - "borrowXvsApy": "7.255545114199961792", - "supplyXvsApy": "2.970618685146700051", - "borrowXvsApr": "0.0702432601", - "supplyXvsApr": "0.0293551082", - "liquidityCents": "405914164.7917365114353727", - "tokenPriceCents": "32.061", - "totalDistributedMantissa": "8041772673564487536114", - "lastCalculatedXvsAccruedBlockNumber": "40813640", - "supplyCapsMantissa": "115792089237316195423570985008687907853269984665640564039457584007913129639935", - "borrowCapsMantissa": "0", - "borrowerCount": 10, - "supplierCount": 6, - "estimatedPrimeBorrowApyBoost": null, - "estimatedPrimeSupplyApyBoost": null, - "pausedActionsBitmap": 0, - "isListed": true, - "poolComptrollerAddress": "0x94d1820b2D1c7c7452A163983Dc888CEC546b77D", - "rewardsDistributors": [ - { - "marketAddress": "0x37C28DE42bA3d22217995D146FC684B2326Ede64", - "rewardTokenAddress": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", - "chainId": "97", - "lastRewardingSupplyBlockOrTimestamp": "0", - "lastRewardingBorrowBlockOrTimestamp": "0", - "supplySpeed": "3038194444444440", - "borrowSpeed": "3038194444444440", - "priceMantissa": "6409500000000000000", - "rewardsDistributorContractAddress": null, - "createdAt": "2024-06-18T14:48:54.000Z", - "updatedAt": "2024-09-03T14:58:33.000Z" - } - ] - }, - { - "address": "0x2E7222e51c0f6e98610A1543Aa3836E092CDe62c", - "chainId": "97", - "symbol": "vBNB", - "name": "Venus BNB", - "underlyingAddress": null, - "underlyingName": "BNB", - "underlyingSymbol": "BNB", - "underlyingDecimal": 18, - "borrowerDailyXvsMantissa": "1499999990400000000000", - "supplierDailyXvsMantissa": "1499999990400000000000", - "xvsBorrowIndex": "105691042801504980925475682131713519630", - "xvsSupplyIndex": "8141544355417915063944376628824300520342639914", - "borrowRatePerBlock": "98326552387", - "supplyRatePerBlock": "90101857759", - "exchangeRateMantissa": "1773447735505080749666848858", - "underlyingPriceMantissa": "522556865270000000000", - "totalBorrowsMantissa": "1031519833913146342793186", - "totalSupplyMantissa": "476055424862453", - "cashMantissa": "5556233762724731858", - "totalReservesMantissa": "187265974949682677258591", - "reserveFactorMantissa": "250000000000000000", - "collateralFactorMantissa": "800000000000000000", - "borrowApy": "179.916227241628238879", - "supplyApy": "156.852648288428633396", - "borrowXvsApy": "0.651346878430104129", - "supplyXvsApy": "0.796390771213776658", - "borrowXvsApr": "0.0065102420", - "supplyXvsApr": "0.0079542420", - "liquidityCents": "290344.8097756772853617", - "tokenPriceCents": "52255.686527", - "totalDistributedMantissa": "259157084689196533384895", - "lastCalculatedXvsAccruedBlockNumber": "43377938", - "supplyCapsMantissa": "115792089237316195423570985008687907853269984665640564039457584007913129639935", - "borrowCapsMantissa": "0", - "borrowerCount": 263, - "supplierCount": 923, - "estimatedPrimeBorrowApyBoost": null, - "estimatedPrimeSupplyApyBoost": null, - "pausedActionsBitmap": 0, - "isListed": true, - "poolComptrollerAddress": "0x94d1820b2D1c7c7452A163983Dc888CEC546b77D", - "rewardsDistributors": [ - { - "marketAddress": "0x2E7222e51c0f6e98610A1543Aa3836E092CDe62c", - "rewardTokenAddress": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", - "chainId": "97", - "lastRewardingSupplyBlockOrTimestamp": "0", - "lastRewardingBorrowBlockOrTimestamp": "0", - "supplySpeed": "52083333000000000", - "borrowSpeed": "52083333000000000", - "priceMantissa": "6409500000000000000", - "rewardsDistributorContractAddress": null, - "createdAt": "2024-06-18T14:48:54.000Z", - "updatedAt": "2024-09-03T14:58:32.000Z" - } - ] - }, - { - "address": "0xb6e9322C49FD75a367Fcb17B0Fcd62C5070EbCBe", - "chainId": "97", - "symbol": "vBTC", - "name": "Venus BTC", - "underlyingAddress": "0xA808e341e8e723DC6BA0Bb5204Bafc2330d7B8e4", - "underlyingName": "BTCB Token", - "underlyingSymbol": "BTCB", - "underlyingDecimal": 18, - "borrowerDailyXvsMantissa": "1499999990400000000000", - "supplierDailyXvsMantissa": "1499999990400000000000", - "xvsBorrowIndex": "9405325536598357827724273005107028015331", - "xvsSupplyIndex": "1108558237039195785170238927132072069589267959679", - "borrowRatePerBlock": "11477039266", - "supplyRatePerBlock": "10396128619", - "exchangeRateMantissa": "267618928698396193302449922", - "underlyingPriceMantissa": "57726369000000000000000", - "totalBorrowsMantissa": "1954267680841100177596", - "totalSupplyMantissa": "7255510166453", - "cashMantissa": "0", - "totalReservesMantissa": "12555822934626074494", - "reserveFactorMantissa": "100000000000000000", - "collateralFactorMantissa": "800000000000000000", - "borrowApy": "12.783088574229786432", - "supplyApy": "11.512709317018632846", - "borrowXvsApy": "3.150600133555122671", - "supplyXvsApy": "3.171291877006591725", - "borrowXvsApr": "0.0311064164", - "supplyXvsApr": "0.0313075620", - "liquidityCents": "0", - "tokenPriceCents": "5772636.9", - "totalDistributedMantissa": "15618541847887808851523", - "lastCalculatedXvsAccruedBlockNumber": "41769612", - "supplyCapsMantissa": "115792089237316195423570985008687907853269984665640564039457584007913129639935", - "borrowCapsMantissa": "0", - "borrowerCount": 49, - "supplierCount": 30, - "estimatedPrimeBorrowApyBoost": "0", - "estimatedPrimeSupplyApyBoost": "0", - "pausedActionsBitmap": 0, - "isListed": true, - "poolComptrollerAddress": "0x94d1820b2D1c7c7452A163983Dc888CEC546b77D", - "rewardsDistributors": [ - { - "marketAddress": "0xb6e9322C49FD75a367Fcb17B0Fcd62C5070EbCBe", - "rewardTokenAddress": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", - "chainId": "97", - "lastRewardingSupplyBlockOrTimestamp": "0", - "lastRewardingBorrowBlockOrTimestamp": "0", - "supplySpeed": "52083333000000000", - "borrowSpeed": "52083333000000000", - "priceMantissa": "6409500000000000000", - "rewardsDistributorContractAddress": null, - "createdAt": "2024-06-18T14:48:54.000Z", - "updatedAt": "2024-09-03T14:58:33.000Z" - } - ] - }, - { - "address": "0x08e0A5575De71037aE36AbfAfb516595fE68e5e4", - "chainId": "97", - "symbol": "vBUSD", - "name": "Venus BUSD", - "underlyingAddress": "0x8301F2213c0eeD49a7E28Ae4c3e91722919B8B47", - "underlyingName": "BUSD", - "underlyingSymbol": "BUSD", - "underlyingDecimal": 18, - "borrowerDailyXvsMantissa": "0", - "supplierDailyXvsMantissa": "0", - "xvsBorrowIndex": "1977151763630172707382704323704603564", - "xvsSupplyIndex": "38295216010831373328189928188548146574423007", - "borrowRatePerBlock": "1902587521", - "supplyRatePerBlock": "0", - "exchangeRateMantissa": "203276602375088268292741033", - "underlyingPriceMantissa": "1000006200000000000", - "totalBorrowsMantissa": "246624445312815898417382769450", - "totalSupplyMantissa": "4919405329327832875221358523019", - "cashMantissa": "1000000000805039591593730097030595646249", - "totalReservesMantissa": "0", - "reserveFactorMantissa": "1000000000000000000", - "collateralFactorMantissa": "0", - "borrowApy": "2.014488270427066776", - "supplyApy": "0", - "borrowXvsApy": "0", - "supplyXvsApy": "0", - "borrowXvsApr": "0.0000000000", - "supplyXvsApr": "0.0000000000", - "liquidityCents": "100000620080504458283919.7978157197235942", - "tokenPriceCents": "100.00062", - "totalDistributedMantissa": "9656421926", - "lastCalculatedXvsAccruedBlockNumber": "40610282", - "supplyCapsMantissa": "0", - "borrowCapsMantissa": "1", - "borrowerCount": 438, - "supplierCount": 933, - "estimatedPrimeBorrowApyBoost": null, - "estimatedPrimeSupplyApyBoost": null, - "pausedActionsBitmap": 133, - "isListed": true, - "poolComptrollerAddress": "0x94d1820b2D1c7c7452A163983Dc888CEC546b77D", - "rewardsDistributors": [ - { - "marketAddress": "0x08e0A5575De71037aE36AbfAfb516595fE68e5e4", - "rewardTokenAddress": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", - "chainId": "97", - "lastRewardingSupplyBlockOrTimestamp": "0", - "lastRewardingBorrowBlockOrTimestamp": "0", - "supplySpeed": "0", - "borrowSpeed": "0", - "priceMantissa": "6409500000000000000", - "rewardsDistributorContractAddress": null, - "createdAt": "2024-06-18T14:48:54.000Z", - "updatedAt": "2024-09-03T14:58:33.000Z" - } - ] - }, - { - "address": "0xeDaC03D29ff74b5fDc0CC936F6288312e1459BC6", - "chainId": "97", - "symbol": "vCAKE", - "name": "Venus CAKE", - "underlyingAddress": "0xe8bd7cCC165FAEb9b81569B05424771B9A20cbEF", - "underlyingName": "CAKE", - "underlyingSymbol": "CAKE", - "underlyingDecimal": 18, - "borrowerDailyXvsMantissa": "87499999999999872000", - "supplierDailyXvsMantissa": "87499999999999872000", - "xvsBorrowIndex": "350539516507092513631266656739249188367", - "xvsSupplyIndex": "16966874130639415131680527385403644991373451866", - "borrowRatePerBlock": "2106158768", - "supplyRatePerBlock": "22535277", - "exchangeRateMantissa": "232365889426639360267554271", - "underlyingPriceMantissa": "1686000000000000000", - "totalBorrowsMantissa": "51355434309380964571964", - "totalSupplyMantissa": "15491857541329692", - "cashMantissa": "3548423822152483349893210", - "totalReservesMantissa": "0", - "reserveFactorMantissa": "250000000000000000", - "collateralFactorMantissa": "600000000000000000", - "borrowApy": "2.23241502900537543", - "supplyApy": "0.023626964646132097", - "borrowXvsApy": "948.664906542644205177", - "supplyXvsApy": "3.420614327600371608", - "borrowXvsApr": "2.3641830138", - "supplyXvsApr": "0.0337280808", - "liquidityCents": "598264256.4149086927919952", - "tokenPriceCents": "168.6", - "totalDistributedMantissa": "8501886931768998951051", - "lastCalculatedXvsAccruedBlockNumber": "42653243", - "supplyCapsMantissa": "115792089237316195423570985008687907853269984665640564039457584007913129639935", - "borrowCapsMantissa": "50000000000000000000000", - "borrowerCount": 8, - "supplierCount": 13, - "estimatedPrimeBorrowApyBoost": null, - "estimatedPrimeSupplyApyBoost": null, - "pausedActionsBitmap": 0, - "isListed": true, - "poolComptrollerAddress": "0x94d1820b2D1c7c7452A163983Dc888CEC546b77D", - "rewardsDistributors": [ - { - "marketAddress": "0xeDaC03D29ff74b5fDc0CC936F6288312e1459BC6", - "rewardTokenAddress": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", - "chainId": "97", - "lastRewardingSupplyBlockOrTimestamp": "0", - "lastRewardingBorrowBlockOrTimestamp": "0", - "supplySpeed": "3038194444444440", - "borrowSpeed": "3038194444444440", - "priceMantissa": "6409500000000000000", - "rewardsDistributorContractAddress": null, - "createdAt": "2024-06-18T14:48:54.000Z", - "updatedAt": "2024-09-03T14:58:33.000Z" - } - ] - }, - { - "address": "0xF912d3001CAf6DC4ADD366A62Cc9115B4303c9A9", - "chainId": "97", - "symbol": "vDOGE", - "name": "Venus DOGE", - "underlyingAddress": "0x67D262CE2b8b846d9B94060BC04DC40a83F0e25B", - "underlyingName": "DOGE", - "underlyingSymbol": "DOGE", - "underlyingDecimal": 8, - "borrowerDailyXvsMantissa": "45805000000000032000", - "supplierDailyXvsMantissa": "45805000000000032000", - "xvsBorrowIndex": "29477570890004228395941234702634547672863854277799208", - "xvsSupplyIndex": "27936096259934623016561227838755567528706818", - "borrowRatePerBlock": "2002755593", - "supplyRatePerBlock": "21088351", - "exchangeRateMantissa": "22127481133731064", - "underlyingPriceMantissa": "977800000000000000000000000", - "totalBorrowsMantissa": "1076723700152567", - "totalSupplyMantissa": "4621230319469918525", - "cashMantissa": "101179463008544036", - "totalReservesMantissa": "0", - "reserveFactorMantissa": "0", - "collateralFactorMantissa": "800000000000000000", - "borrowApy": "2.12166207506541981", - "supplyApy": "0.022109777257975513", - "borrowXvsApy": "10.681893261541533268", - "supplyXvsApy": "0.106937559332461288", - "borrowXvsApr": "0.1017830823", - "supplyXvsApr": "0.0010717421", - "liquidityCents": "9893327892.97543584008", - "tokenPriceCents": "9.778", - "totalDistributedMantissa": "81799852571307832068", - "lastCalculatedXvsAccruedBlockNumber": "40813640", - "supplyCapsMantissa": "115792089237316195423570985008687907853269984665640564039457584007913129639935", - "borrowCapsMantissa": "0", - "borrowerCount": 12, - "supplierCount": 4, - "estimatedPrimeBorrowApyBoost": null, - "estimatedPrimeSupplyApyBoost": null, - "pausedActionsBitmap": 0, - "isListed": true, - "poolComptrollerAddress": "0x94d1820b2D1c7c7452A163983Dc888CEC546b77D", - "rewardsDistributors": [ - { - "marketAddress": "0xF912d3001CAf6DC4ADD366A62Cc9115B4303c9A9", - "rewardTokenAddress": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", - "chainId": "97", - "lastRewardingSupplyBlockOrTimestamp": "0", - "lastRewardingBorrowBlockOrTimestamp": "0", - "supplySpeed": "1590451388888890", - "borrowSpeed": "1590451388888890", - "priceMantissa": "6409500000000000000", - "rewardsDistributorContractAddress": null, - "createdAt": "2024-06-18T14:48:54.000Z", - "updatedAt": "2024-09-03T14:58:33.000Z" - } - ] - }, - { - "address": "0x162D005F0Fff510E54958Cfc5CF32A3180A84aab", - "chainId": "97", - "symbol": "vETH", - "name": "Venus ETH", - "underlyingAddress": "0x98f7A83361F7Ac8765CcEBAB1425da6b341958a7", - "underlyingName": "Ethereum Token", - "underlyingSymbol": "ETH", - "underlyingDecimal": 18, - "borrowerDailyXvsMantissa": "250000012800000000000", - "supplierDailyXvsMantissa": "250000012800000000000", - "xvsBorrowIndex": "268589938372675892994578512370576569759", - "xvsSupplyIndex": "13805526024990152334999386496181183990421862352", - "borrowRatePerBlock": "11428816224", - "supplyRatePerBlock": "10300305713", - "exchangeRateMantissa": "265653038049231291803344237", - "underlyingPriceMantissa": "2446538900000000000000", - "totalBorrowsMantissa": "15135219324740320369457", - "totalSupplyMantissa": "56894145058707", - "cashMantissa": "0", - "totalReservesMantissa": "21116842681145210304", - "reserveFactorMantissa": "100000000000000000", - "collateralFactorMantissa": "800000000000000000", - "borrowApy": "12.726106336788702714", - "supplyApy": "11.400780963386549066", - "borrowXvsApy": "1.587596592520731068", - "supplyXvsApy": "1.589832212603489454", - "borrowXvsApr": "0.0157948754", - "supplyXvsApr": "0.0158169433", - "liquidityCents": "0", - "tokenPriceCents": "244653.89", - "totalDistributedMantissa": "770610123023466747020", - "lastCalculatedXvsAccruedBlockNumber": "40813640", - "supplyCapsMantissa": "115792089237316195423570985008687907853269984665640564039457584007913129639935", - "borrowCapsMantissa": "0", - "borrowerCount": 35, - "supplierCount": 25, - "estimatedPrimeBorrowApyBoost": "0", - "estimatedPrimeSupplyApyBoost": "0", - "pausedActionsBitmap": 0, - "isListed": true, - "poolComptrollerAddress": "0x94d1820b2D1c7c7452A163983Dc888CEC546b77D", - "rewardsDistributors": [ - { - "marketAddress": "0x162D005F0Fff510E54958Cfc5CF32A3180A84aab", - "rewardTokenAddress": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", - "chainId": "97", - "lastRewardingSupplyBlockOrTimestamp": "0", - "lastRewardingBorrowBlockOrTimestamp": "0", - "supplySpeed": "8680556000000000", - "borrowSpeed": "8680556000000000", - "priceMantissa": "6409500000000000000", - "rewardsDistributorContractAddress": null, - "createdAt": "2024-06-18T14:48:54.000Z", - "updatedAt": "2024-09-03T14:58:33.000Z" - } - ] - }, - { - "address": "0xF06e662a00796c122AaAE935EC4F0Be3F74f5636", - "chainId": "97", - "symbol": "vFDUSD", - "name": "Venus FDUSD", - "underlyingAddress": "0xcF27439fA231af9931ee40c4f27Bb77B83826F3C", - "underlyingName": "First Digital USD", - "underlyingSymbol": "FDUSD", - "underlyingDecimal": 18, - "borrowerDailyXvsMantissa": "4999999999999996800", - "supplierDailyXvsMantissa": "4999999999999996800", - "xvsBorrowIndex": "72309412846065359669169680816853700396255739746", - "xvsSupplyIndex": "431910243846800487986776637097922605992467636", - "borrowRatePerBlock": "654015", - "supplyRatePerBlock": "58", - "exchangeRateMantissa": "10000000001895916581414104083", - "underlyingPriceMantissa": "1000000000000000000", - "totalBorrowsMantissa": "1000002116574035040", - "totalSupplyMantissa": "1000000000001", - "cashMantissa": "9998999999789342546376", - "totalReservesMantissa": "0", - "reserveFactorMantissa": "100000000000000000", - "collateralFactorMantissa": "750000000000000000", - "borrowApy": "0.000685619348701698", - "supplyApy": "0.000000060802560018", - "borrowXvsApy": "1000000", - "supplyXvsApy": "220.484512694700409915", - "borrowXvsApr": "11697.3127417716", - "supplyXvsApr": "1.1697337498", - "liquidityCents": "999899.9999789342546376", - "tokenPriceCents": "100", - "totalDistributedMantissa": "725658854166666202244", - "lastCalculatedXvsAccruedBlockNumber": "40330700", - "supplyCapsMantissa": "5500000000000000000000000", - "borrowCapsMantissa": "4400000000000000000000000", - "borrowerCount": 1, - "supplierCount": 2, - "estimatedPrimeBorrowApyBoost": null, - "estimatedPrimeSupplyApyBoost": null, - "pausedActionsBitmap": 0, - "isListed": true, - "poolComptrollerAddress": "0x94d1820b2D1c7c7452A163983Dc888CEC546b77D", - "rewardsDistributors": [ - { - "marketAddress": "0xF06e662a00796c122AaAE935EC4F0Be3F74f5636", - "rewardTokenAddress": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", - "chainId": "97", - "lastRewardingSupplyBlockOrTimestamp": "0", - "lastRewardingBorrowBlockOrTimestamp": "0", - "supplySpeed": "173611111111111", - "borrowSpeed": "173611111111111", - "priceMantissa": "6409500000000000000", - "rewardsDistributorContractAddress": null, - "createdAt": "2024-06-18T14:48:54.000Z", - "updatedAt": "2024-09-03T14:58:33.000Z" - } - ] - }, - { - "address": "0xAfc13BC065ABeE838540823431055D2ea52eBA52", - "chainId": "97", - "symbol": "vLTC", - "name": "Venus LTC", - "underlyingAddress": "0x969F147B6b8D81f86175de33206A4FD43dF17913", - "underlyingName": "Litecoin Token", - "underlyingSymbol": "LTC", - "underlyingDecimal": 18, - "borrowerDailyXvsMantissa": "250000012800000000000", - "supplierDailyXvsMantissa": "250000012800000000000", - "xvsBorrowIndex": "321358523398000000010831693964764549022765455853397163883", - "xvsSupplyIndex": "438901240485943276689544632773456407273653745", - "borrowRatePerBlock": "11402809068", - "supplyRatePerBlock": "10248810129", - "exchangeRateMantissa": "251415701150693845575391004", - "underlyingPriceMantissa": "64781729000000000000", - "totalBorrowsMantissa": "345330590935747400499587", - "totalSupplyMantissa": "1375382739904149", - "cashMantissa": "462224967816607358036", - "totalReservesMantissa": "0", - "reserveFactorMantissa": "100000000000000000", - "collateralFactorMantissa": "600000000000000000", - "borrowApy": "12.695387179561544987", - "supplyApy": "11.340676542337701886", - "borrowXvsApy": "2.641411313772282414", - "supplyXvsApy": "2.637834474900266459", - "borrowXvsApr": "0.0261438450", - "supplyXvsApr": "0.0261088983", - "liquidityCents": "2994373.2602129179567694", - "tokenPriceCents": "6478.1729", - "totalDistributedMantissa": "14424596326849945425398", - "lastCalculatedXvsAccruedBlockNumber": "42399093", - "supplyCapsMantissa": "115792089237316195423570985008687907853269984665640564039457584007913129639935", - "borrowCapsMantissa": "0", - "borrowerCount": 27, - "supplierCount": 18, - "estimatedPrimeBorrowApyBoost": null, - "estimatedPrimeSupplyApyBoost": null, - "pausedActionsBitmap": 0, - "isListed": true, - "poolComptrollerAddress": "0x94d1820b2D1c7c7452A163983Dc888CEC546b77D", - "rewardsDistributors": [ - { - "marketAddress": "0xAfc13BC065ABeE838540823431055D2ea52eBA52", - "rewardTokenAddress": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", - "chainId": "97", - "lastRewardingSupplyBlockOrTimestamp": "0", - "lastRewardingBorrowBlockOrTimestamp": "0", - "supplySpeed": "8680556000000000", - "borrowSpeed": "8680556000000000", - "priceMantissa": "6409500000000000000", - "rewardsDistributorContractAddress": null, - "createdAt": "2024-06-18T14:48:54.000Z", - "updatedAt": "2024-09-03T14:58:33.000Z" - } - ] - }, - { - "address": "0x3619bdDc61189F33365CC572DF3a68FB3b316516", - "chainId": "97", - "symbol": "vMATIC", - "name": "Venus MATIC", - "underlyingAddress": "0xcfeb0103d4BEfa041EA4c2dACce7B3E83E1aE7E3", - "underlyingName": "Polygon", - "underlyingSymbol": "MATIC", - "underlyingDecimal": 18, - "borrowerDailyXvsMantissa": "0", - "supplierDailyXvsMantissa": "0", - "xvsBorrowIndex": "1000000000000000000000000000000000000", - "xvsSupplyIndex": "1000000000000000000000000000000000000", - "borrowRatePerBlock": "6267125814", - "supplyRatePerBlock": "1725215392", - "exchangeRateMantissa": "959012059148581915724511904", - "underlyingPriceMantissa": "406592670000000000", - "totalBorrowsMantissa": "4306173407219413942425029", - "totalSupplyMantissa": "14680303852746521", - "cashMantissa": "9772415019529887636730721", - "totalReservesMantissa": "0", - "reserveFactorMantissa": "100000000000000000", - "collateralFactorMantissa": "600000000000000000", - "borrowApy": "6.789946785599375754", - "supplyApy": "1.824985862525394149", - "borrowXvsApy": "0", - "supplyXvsApy": "0", - "borrowXvsApr": "0.0000000000", - "supplyXvsApr": "0.0000000000", - "liquidityCents": "397339231.5138759159018333", - "tokenPriceCents": "40.659267", - "totalDistributedMantissa": "0", - "lastCalculatedXvsAccruedBlockNumber": "42776399", - "supplyCapsMantissa": "115792089237316195423570985008687907853269984665640564039457584007913129639935", - "borrowCapsMantissa": "0", - "borrowerCount": 8, - "supplierCount": 6, - "estimatedPrimeBorrowApyBoost": null, - "estimatedPrimeSupplyApyBoost": null, - "pausedActionsBitmap": 0, - "isListed": true, - "poolComptrollerAddress": "0x94d1820b2D1c7c7452A163983Dc888CEC546b77D", - "rewardsDistributors": [ - { - "marketAddress": "0x3619bdDc61189F33365CC572DF3a68FB3b316516", - "rewardTokenAddress": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", - "chainId": "97", - "lastRewardingSupplyBlockOrTimestamp": "0", - "lastRewardingBorrowBlockOrTimestamp": "0", - "supplySpeed": "0", - "borrowSpeed": "0", - "priceMantissa": "6409500000000000000", - "rewardsDistributorContractAddress": null, - "createdAt": "2024-06-18T14:48:54.000Z", - "updatedAt": "2024-09-03T14:58:33.000Z" - } - ] - }, - { - "address": "0x74469281310195A04840Daf6EdF576F559a3dE80", - "chainId": "97", - "symbol": "vSXP", - "name": "Venus SXP", - "underlyingAddress": "0x75107940Cf1121232C0559c747A986DEfbc69DA9", - "underlyingName": "SXP", - "underlyingSymbol": "SXP", - "underlyingDecimal": 18, - "borrowerDailyXvsMantissa": "24999999999999984000", - "supplierDailyXvsMantissa": "24999999999999984000", - "xvsBorrowIndex": "2214118777264877536505516095372072208", - "xvsSupplyIndex": "92030607810320351810386787595126360793714730", - "borrowRatePerBlock": "11612791560", - "supplyRatePerBlock": "10668241746", - "exchangeRateMantissa": "252388541107195703411128782", - "underlyingPriceMantissa": "196071650000000000", - "totalBorrowsMantissa": "1254947258163647298227534213569428", - "totalSupplyMantissa": "4871269223886847400340315", - "cashMantissa": "0", - "totalReservesMantissa": "25494725406464402806465223027321", - "reserveFactorMantissa": "100000000000000000", - "collateralFactorMantissa": "500000000000000000", - "borrowApy": "12.943653105664683333", - "supplyApy": "11.831169702098985539", - "borrowXvsApy": "0.000000023704197974", - "supplyXvsApy": "0.000000024195743574", - "borrowXvsApr": "0.0000000002", - "supplyXvsApr": "0.0000000002", - "liquidityCents": "0", - "tokenPriceCents": "19.607165", - "totalDistributedMantissa": "50444713385654794", - "lastCalculatedXvsAccruedBlockNumber": "40813640", - "supplyCapsMantissa": "1007000000000000000000000000000000", - "borrowCapsMantissa": "0", - "borrowerCount": 277, - "supplierCount": 661, - "estimatedPrimeBorrowApyBoost": null, - "estimatedPrimeSupplyApyBoost": null, - "pausedActionsBitmap": 0, - "isListed": true, - "poolComptrollerAddress": "0x94d1820b2D1c7c7452A163983Dc888CEC546b77D", - "rewardsDistributors": [ - { - "marketAddress": "0x74469281310195A04840Daf6EdF576F559a3dE80", - "rewardTokenAddress": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", - "chainId": "97", - "lastRewardingSupplyBlockOrTimestamp": "0", - "lastRewardingBorrowBlockOrTimestamp": "0", - "supplySpeed": "868055555555555", - "borrowSpeed": "868055555555555", - "priceMantissa": "6409500000000000000", - "rewardsDistributorContractAddress": null, - "createdAt": "2024-06-18T14:48:54.000Z", - "updatedAt": "2024-09-03T14:58:33.000Z" - } - ] - }, - { - "address": "0x6AF3Fdb3282c5bb6926269Db10837fa8Aec67C04", - "chainId": "97", - "symbol": "vTRX", - "name": "Venus TRX", - "underlyingAddress": "0x7D21841DC10BA1C5797951EFc62fADBBDD06704B", - "underlyingName": "TRON", - "underlyingSymbol": "TRX", - "underlyingDecimal": 6, - "borrowerDailyXvsMantissa": "24999999999999984000", - "supplierDailyXvsMantissa": "24999999999999984000", - "xvsBorrowIndex": "3206120070683388844186748616448660508496352622374", - "xvsSupplyIndex": "117133827040061860395551187737238783537930745", - "borrowRatePerBlock": "181750044826", - "supplyRatePerBlock": "174507013343", - "exchangeRateMantissa": "50437671786208427", - "underlyingPriceMantissa": "151239800000000000000000000000", - "totalBorrowsMantissa": "6057002965093", - "totalSupplyMantissa": "100058590996759", - "cashMantissa": "0", - "totalReservesMantissa": "1010280593008", - "reserveFactorMantissa": "200000000000000000", - "collateralFactorMantissa": "600000000000000000", - "borrowApy": "568.825359528345682152", - "supplyApy": "520.161775569854727359", - "borrowXvsApy": "6.573577685405158249", - "supplyXvsApy": "7.94039480487733241", - "borrowXvsApr": "0.0638459193", - "supplyXvsApr": "0.0766269459", - "liquidityCents": "0", - "tokenPriceCents": "15.12398", - "totalDistributedMantissa": "4124113459493255217238", - "lastCalculatedXvsAccruedBlockNumber": "40813640", - "supplyCapsMantissa": "115792089237316195423570985008687907853269984665640564039457584007913129639935", - "borrowCapsMantissa": "0", - "borrowerCount": 1, - "supplierCount": 3, - "estimatedPrimeBorrowApyBoost": null, - "estimatedPrimeSupplyApyBoost": null, - "pausedActionsBitmap": 0, - "isListed": true, - "poolComptrollerAddress": "0x94d1820b2D1c7c7452A163983Dc888CEC546b77D", - "rewardsDistributors": [ - { - "marketAddress": "0x6AF3Fdb3282c5bb6926269Db10837fa8Aec67C04", - "rewardTokenAddress": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", - "chainId": "97", - "lastRewardingSupplyBlockOrTimestamp": "0", - "lastRewardingBorrowBlockOrTimestamp": "0", - "supplySpeed": "868055555555555", - "borrowSpeed": "868055555555555", - "priceMantissa": "6409500000000000000", - "rewardsDistributorContractAddress": null, - "createdAt": "2024-06-18T14:48:54.000Z", - "updatedAt": "2024-09-03T14:58:33.000Z" - } - ] - }, - { - "address": "0x369Fea97f6fB7510755DCA389088d9E2e2819278", - "chainId": "97", - "symbol": "vTRXOLD", - "name": "Venus TRXOLD", - "underlyingAddress": "0x19E7215abF8B2716EE807c9f4b83Af0e7f92653F", - "underlyingName": "TRON", - "underlyingSymbol": "TRX", - "underlyingDecimal": 18, - "borrowerDailyXvsMantissa": "25000000000000012800", - "supplierDailyXvsMantissa": "25000000000000012800", - "xvsBorrowIndex": "1116319444444458592972336404424292900444743561428437019", - "xvsSupplyIndex": "894606301239538712616137272975672334071540266", - "borrowRatePerBlock": "187623505280", - "supplyRatePerBlock": "183235531222", - "exchangeRateMantissa": "5154651109509209711223889381", - "underlyingPriceMantissa": "151239800000000000", - "totalBorrowsMantissa": "10612941138090987816358017134188878", - "totalSupplyMantissa": "1686568639918209626233292", - "cashMantissa": "0", - "totalReservesMantissa": "1919268227073149767108083637197926", - "reserveFactorMantissa": "200000000000000000", - "collateralFactorMantissa": "600000000000000000", - "borrowApy": "611.069282541134837625", - "supplyApy": "579.266956322473345728", - "borrowXvsApy": "0.000000003633822192", - "supplyXvsApy": "0.000000004436047252", - "borrowXvsApr": "0.0000000000", - "supplyXvsApr": "0.0000000000", - "liquidityCents": "0", - "tokenPriceCents": "15.12398", - "totalDistributedMantissa": "0", - "lastCalculatedXvsAccruedBlockNumber": "42769433", - "supplyCapsMantissa": "115792089237316195423570985008687907853269984665640564039457584007913129639935", - "borrowCapsMantissa": "0", - "borrowerCount": 4, - "supplierCount": 4, - "estimatedPrimeBorrowApyBoost": null, - "estimatedPrimeSupplyApyBoost": null, - "pausedActionsBitmap": 0, - "isListed": true, - "poolComptrollerAddress": "0x94d1820b2D1c7c7452A163983Dc888CEC546b77D", - "rewardsDistributors": [ - { - "marketAddress": "0x369Fea97f6fB7510755DCA389088d9E2e2819278", - "rewardTokenAddress": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", - "chainId": "97", - "lastRewardingSupplyBlockOrTimestamp": "0", - "lastRewardingBorrowBlockOrTimestamp": "0", - "supplySpeed": "868055555555556", - "borrowSpeed": "868055555555556", - "priceMantissa": "6409500000000000000", - "rewardsDistributorContractAddress": null, - "createdAt": "2024-06-18T14:48:54.000Z", - "updatedAt": "2024-09-03T14:58:33.000Z" - } - ] - }, - { - "address": "0x3A00d9B02781f47d033BAd62edc55fBF8D083Fb0", - "chainId": "97", - "symbol": "vTUSDOLD", - "name": "Venus TUSDOLD", - "underlyingAddress": "0xFeC3A63401Eb9C1476200d7C32c4009Be0154169", - "underlyingName": "TrueUSD", - "underlyingSymbol": "TUSD", - "underlyingDecimal": 18, - "borrowerDailyXvsMantissa": "0", - "supplierDailyXvsMantissa": "0", - "xvsBorrowIndex": "12589249437975844774090757370352084339106920314", - "xvsSupplyIndex": "2828780501409777475336780747363835676", - "borrowRatePerBlock": "2947815", - "supplyRatePerBlock": "0", - "exchangeRateMantissa": "22000002162622067652", - "underlyingPriceMantissa": "1000000000000000000", - "totalBorrowsMantissa": "62784550287202573863525", - "totalSupplyMantissa": "4604838929893023262857822", - "cashMantissa": "101243681865885596980072254", - "totalReservesMantissa": "0", - "reserveFactorMantissa": "1000000000000000000", - "collateralFactorMantissa": "550000000000000000", - "borrowApy": "0.003090301038442095", - "supplyApy": "0", - "borrowXvsApy": "0", - "supplyXvsApy": "0", - "borrowXvsApr": "0.0000000000", - "supplyXvsApr": "0.0000000000", - "liquidityCents": "10124368186.5885596980072254", - "tokenPriceCents": "100", - "totalDistributedMantissa": "0", - "lastCalculatedXvsAccruedBlockNumber": "38638517", - "supplyCapsMantissa": "115792089237316195423570985008687907853269984665640564039457584007913129639935", - "borrowCapsMantissa": "0", - "borrowerCount": 1, - "supplierCount": 1, - "estimatedPrimeBorrowApyBoost": null, - "estimatedPrimeSupplyApyBoost": null, - "pausedActionsBitmap": 133, - "isListed": true, - "poolComptrollerAddress": "0x94d1820b2D1c7c7452A163983Dc888CEC546b77D", - "rewardsDistributors": [ - { - "marketAddress": "0x3A00d9B02781f47d033BAd62edc55fBF8D083Fb0", - "rewardTokenAddress": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", - "chainId": "97", - "lastRewardingSupplyBlockOrTimestamp": "0", - "lastRewardingBorrowBlockOrTimestamp": "0", - "supplySpeed": "0", - "borrowSpeed": "0", - "priceMantissa": "6409500000000000000", - "rewardsDistributorContractAddress": null, - "createdAt": "2024-06-18T14:48:54.000Z", - "updatedAt": "2024-09-03T14:58:33.000Z" - } - ] - }, - { - "address": "0xEFAACF73CE2D38ED40991f29E72B12C74bd4cf23", - "chainId": "97", - "symbol": "vTUSD", - "name": "Venus TUSD", - "underlyingAddress": "0xB32171ecD878607FFc4F8FC0bCcE6852BB3149E0", - "underlyingName": "TrueUSD", - "underlyingSymbol": "TUSD", - "underlyingDecimal": 18, - "borrowerDailyXvsMantissa": "6250000000000003200", - "supplierDailyXvsMantissa": "6250000000000003200", - "xvsBorrowIndex": "1172232299342796453991734978184325204", - "xvsSupplyIndex": "1703785116404226307319288163144672676222846157", - "borrowRatePerBlock": "26854931049", - "supplyRatePerBlock": "24708239800", - "exchangeRateMantissa": "13058860455495617397721393034", - "underlyingPriceMantissa": "1000000000000000000", - "totalBorrowsMantissa": "13416727508636764715024", - "totalSupplyMantissa": "1005000000000", - "cashMantissa": "0", - "totalReservesMantissa": "292572750863669230314", - "reserveFactorMantissa": "100000000000000000", - "collateralFactorMantissa": "0", - "borrowApy": "32.500575155026984524", - "supplyApy": "29.55422115445964043", - "borrowXvsApy": "196.004374796796467855", - "supplyXvsApy": "203.24150262708903721", - "borrowXvsApr": "1.0898091107", - "supplyXvsApr": "1.1141038905", - "liquidityCents": "0", - "tokenPriceCents": "100", - "totalDistributedMantissa": "0", - "lastCalculatedXvsAccruedBlockNumber": "38638517", - "supplyCapsMantissa": "1000000000000000000000000", - "borrowCapsMantissa": "600000000000000000000000", - "borrowerCount": 0, - "supplierCount": 0, - "estimatedPrimeBorrowApyBoost": null, - "estimatedPrimeSupplyApyBoost": null, - "pausedActionsBitmap": 0, - "isListed": true, - "poolComptrollerAddress": "0x94d1820b2D1c7c7452A163983Dc888CEC546b77D", - "rewardsDistributors": [ - { - "marketAddress": "0xEFAACF73CE2D38ED40991f29E72B12C74bd4cf23", - "rewardTokenAddress": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", - "chainId": "97", - "lastRewardingSupplyBlockOrTimestamp": "0", - "lastRewardingBorrowBlockOrTimestamp": "0", - "supplySpeed": "217013888888889", - "borrowSpeed": "217013888888889", - "priceMantissa": "6409500000000000000", - "rewardsDistributorContractAddress": null, - "createdAt": "2024-06-18T14:48:54.000Z", - "updatedAt": "2024-09-03T14:58:33.000Z" - } - ] - }, - { - "address": "0x171B468b52d7027F12cEF90cd065d6776a25E24e", - "chainId": "97", - "symbol": "vUNI", - "name": "Venus UNI", - "underlyingAddress": "0x8D2f061C75780d8D91c10A7230B907411aCBC8fC", - "underlyingName": "Uniswap", - "underlyingSymbol": "UNI", - "underlyingDecimal": 18, - "borrowerDailyXvsMantissa": "2340000000000000000", - "supplierDailyXvsMantissa": "2340000000000000000", - "xvsBorrowIndex": "324243050000000000000000000000000000000", - "xvsSupplyIndex": "1316423590403528166734410983148239848843830093", - "borrowRatePerBlock": "7747576", - "supplyRatePerBlock": "2366", - "exchangeRateMantissa": "10000000210411150435540151977", - "underlyingPriceMantissa": "4100000000000000000", - "totalBorrowsMantissa": "1000068884847210887", - "totalSupplyMantissa": "245588863999", - "cashMantissa": "2454888622779788197300", - "totalReservesMantissa": "0", - "reserveFactorMantissa": "250000000000000000", - "collateralFactorMantissa": "550000000000000000", - "borrowApy": "0.008122267804506585", - "supplyApy": "0.000002480325150675", - "borrowXvsApy": "1000000", - "supplyXvsApy": "71.906974153217368033", - "borrowXvsApr": "1335.1163112047", - "supplyXvsApr": "0.5436762199", - "liquidityCents": "1006504.335339713160893", - "tokenPriceCents": "410", - "totalDistributedMantissa": "0", - "lastCalculatedXvsAccruedBlockNumber": "38638517", - "supplyCapsMantissa": "100000000000000000000000", - "borrowCapsMantissa": "50000000000000000000000", - "borrowerCount": 1, - "supplierCount": 2, - "estimatedPrimeBorrowApyBoost": null, - "estimatedPrimeSupplyApyBoost": null, - "pausedActionsBitmap": 0, - "isListed": true, - "poolComptrollerAddress": "0x94d1820b2D1c7c7452A163983Dc888CEC546b77D", - "rewardsDistributors": [ - { - "marketAddress": "0x171B468b52d7027F12cEF90cd065d6776a25E24e", - "rewardTokenAddress": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", - "chainId": "97", - "lastRewardingSupplyBlockOrTimestamp": "0", - "lastRewardingBorrowBlockOrTimestamp": "0", - "supplySpeed": "81250000000000", - "borrowSpeed": "81250000000000", - "priceMantissa": "6409500000000000000", - "rewardsDistributorContractAddress": null, - "createdAt": "2024-06-18T14:48:54.000Z", - "updatedAt": "2024-09-03T14:58:33.000Z" - } - ] - }, - { - "address": "0xD5C4C2e2facBEB59D0216D0595d63FcDc6F9A1a7", - "chainId": "97", - "symbol": "vUSDC", - "name": "Venus USDC", - "underlyingAddress": "0x16227D60f7a0e586C66B005219dfc887D13C9531", - "underlyingName": "USDC", - "underlyingSymbol": "USDC", - "underlyingDecimal": 6, - "borrowerDailyXvsMantissa": "499999996800000000000", - "supplierDailyXvsMantissa": "499999996800000000000", - "xvsBorrowIndex": "2513615443067425983890015492722034985810503560752", - "xvsSupplyIndex": "18116117080577329072147625407407020698819079", - "borrowRatePerBlock": "1902587666", - "supplyRatePerBlock": "26", - "exchangeRateMantissa": "212182314281319", - "underlyingPriceMantissa": "1000087800000000000000000000000", - "totalBorrowsMantissa": "15624105827811046883", - "totalSupplyMantissa": "4760890765432828888806260211280", - "cashMantissa": "1010176805025995623519739993", - "totalReservesMantissa": "0", - "reserveFactorMantissa": "100000000000000000", - "collateralFactorMantissa": "810000000000000000", - "borrowApy": "2.01448842548712155", - "supplyApy": "0.000000027256320003", - "borrowXvsApy": "0.000007465557623335", - "supplyXvsApy": "0.000000000000115388", - "borrowXvsApr": "0.0000000749", - "supplyXvsApr": "0.0000000000", - "liquidityCents": "101026549854947690593548.50261713854", - "tokenPriceCents": "100.00878", - "totalDistributedMantissa": "5441010114342408", - "lastCalculatedXvsAccruedBlockNumber": "43154959", - "supplyCapsMantissa": "115792089237316195423570985008687907853269984665640564039457584007913129639935", - "borrowCapsMantissa": "0", - "borrowerCount": 229, - "supplierCount": 534, - "estimatedPrimeBorrowApyBoost": "0", - "estimatedPrimeSupplyApyBoost": "0", - "pausedActionsBitmap": 0, - "isListed": true, - "poolComptrollerAddress": "0x94d1820b2D1c7c7452A163983Dc888CEC546b77D", - "rewardsDistributors": [ - { - "marketAddress": "0xD5C4C2e2facBEB59D0216D0595d63FcDc6F9A1a7", - "rewardTokenAddress": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", - "chainId": "97", - "lastRewardingSupplyBlockOrTimestamp": "0", - "lastRewardingBorrowBlockOrTimestamp": "0", - "supplySpeed": "17361111000000000", - "borrowSpeed": "17361111000000000", - "priceMantissa": "6409500000000000000", - "rewardsDistributorContractAddress": null, - "createdAt": "2024-06-18T14:48:54.000Z", - "updatedAt": "2024-09-03T14:58:32.000Z" - } - ] - }, - { - "address": "0xb7526572FFE56AB9D7489838Bf2E18e3323b441A", - "chainId": "97", - "symbol": "vUSDT", - "name": "Venus USDT", - "underlyingAddress": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", - "underlyingName": "USDT", - "underlyingSymbol": "USDT", - "underlyingDecimal": 6, - "borrowerDailyXvsMantissa": "499999996800000000000", - "supplierDailyXvsMantissa": "499999996800000000000", - "xvsBorrowIndex": "3159570043183500785798225680693711670622959548527", - "xvsSupplyIndex": "50767324415277671732355063874605899243901012", - "borrowRatePerBlock": "1902587519", - "supplyRatePerBlock": "0", - "exchangeRateMantissa": "200776461931237", - "underlyingPriceMantissa": "999962830000000000000000000000", - "totalBorrowsMantissa": "7437398122554", - "totalSupplyMantissa": "49810304144596634830089279266960347223689796", - "cashMantissa": "10000736633870942814396398228131487657572", - "totalReservesMantissa": "0", - "reserveFactorMantissa": "100000000000000000", - "collateralFactorMantissa": "800000000000000000", - "borrowApy": "2.014488268288307401", - "supplyApy": "0", - "borrowXvsApy": "16.978319455633402879", - "supplyXvsApy": "0", - "borrowXvsApr": "0.1572831256", - "supplyXvsApr": "0.0000000000", - "liquidityCents": "1000036490649026183145198711400934801.017576804876", - "tokenPriceCents": "99.996283", - "totalDistributedMantissa": "10280094790496879416570", - "lastCalculatedXvsAccruedBlockNumber": "42329402", - "supplyCapsMantissa": "115792089237316195423570985008687907853269984665640564039457584007913129639935", - "borrowCapsMantissa": "0", - "borrowerCount": 249, - "supplierCount": 670, - "estimatedPrimeBorrowApyBoost": "301.053134481467201813", - "estimatedPrimeSupplyApyBoost": "301.053134481467201813", - "pausedActionsBitmap": 0, - "isListed": true, - "poolComptrollerAddress": "0x94d1820b2D1c7c7452A163983Dc888CEC546b77D", - "rewardsDistributors": [ - { - "marketAddress": "0xb7526572FFE56AB9D7489838Bf2E18e3323b441A", - "rewardTokenAddress": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", - "chainId": "97", - "lastRewardingSupplyBlockOrTimestamp": "0", - "lastRewardingBorrowBlockOrTimestamp": "0", - "supplySpeed": "17361111000000000", - "borrowSpeed": "17361111000000000", - "priceMantissa": "6409500000000000000", - "rewardsDistributorContractAddress": null, - "createdAt": "2024-06-18T14:48:54.000Z", - "updatedAt": "2024-09-03T14:58:33.000Z" - } - ] - }, - { - "address": "0x6d6F697e34145Bb95c54E77482d97cc261Dc237E", - "chainId": "97", - "symbol": "Venus XVS", - "name": "vXVS", - "underlyingAddress": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", - "underlyingName": "Venus", - "underlyingSymbol": "XVS", - "underlyingDecimal": 18, - "borrowerDailyXvsMantissa": "0", - "supplierDailyXvsMantissa": "0", - "xvsBorrowIndex": "1306014178018669882667220692703167088", - "xvsSupplyIndex": "12001246649616749573360284547054922972341230", - "borrowRatePerBlock": "14815172690", - "supplyRatePerBlock": "1730453971", - "exchangeRateMantissa": "211104888219909524206925479", - "underlyingPriceMantissa": "6409500000000000000", - "totalBorrowsMantissa": "416830497450657884046579", - "totalSupplyMantissa": "12678536539791436", - "cashMantissa": "2259670541574051694198243", - "totalReservesMantissa": "0", - "reserveFactorMantissa": "250000000000000000", - "collateralFactorMantissa": "600000000000000000", - "borrowApy": "16.798179063657014898", - "supplyApy": "1.830577667825525182", - "borrowXvsApy": "0", - "supplyXvsApy": "0", - "borrowXvsApr": "0.0000000000", - "supplyXvsApr": "0.0000000000", - "liquidityCents": "1448335833.6218884333963638", - "tokenPriceCents": "640.95", - "totalDistributedMantissa": "22572109963147294", - "lastCalculatedXvsAccruedBlockNumber": "40753215", - "supplyCapsMantissa": "3750000000000000000000000", - "borrowCapsMantissa": "270000000000000000000000", - "borrowerCount": 68, - "supplierCount": 274, - "estimatedPrimeBorrowApyBoost": null, - "estimatedPrimeSupplyApyBoost": null, - "pausedActionsBitmap": 0, - "isListed": true, - "poolComptrollerAddress": "0x94d1820b2D1c7c7452A163983Dc888CEC546b77D", - "rewardsDistributors": [ - { - "marketAddress": "0x6d6F697e34145Bb95c54E77482d97cc261Dc237E", - "rewardTokenAddress": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", - "chainId": "97", - "lastRewardingSupplyBlockOrTimestamp": "0", - "lastRewardingBorrowBlockOrTimestamp": "0", - "supplySpeed": "0", - "borrowSpeed": "0", - "priceMantissa": "6409500000000000000", - "rewardsDistributorContractAddress": null, - "createdAt": "2024-06-18T14:48:54.000Z", - "updatedAt": "2024-09-03T14:58:33.000Z" - } - ] - }, - { - "address": "0x35566ED3AF9E537Be487C98b1811cDf95ad0C32b", - "chainId": "97", - "symbol": "vWBETH", - "name": "Venus WBETH", - "underlyingAddress": "0x9c37E59Ba22c4320547F00D4f1857AF1abd1Dd6f", - "underlyingName": "Wrapped Binance Beacon ETH", - "underlyingSymbol": "wBETH", - "underlyingDecimal": 18, - "borrowerDailyXvsMantissa": "17177499999999936000", - "supplierDailyXvsMantissa": "17177499999999936000", - "xvsBorrowIndex": "942098443819440938096000000000000000000", - "xvsSupplyIndex": "8566375013252936080909648901753967063960042151767", - "borrowRatePerBlock": "58243460642", - "supplyRatePerBlock": "47462718580", - "exchangeRateMantissa": "14733815782885745170356888932", - "underlyingPriceMantissa": "2569153851730000000000", - "totalBorrowsMantissa": "8254461067763439120", - "totalSupplyMantissa": "549994107", - "cashMantissa": "0", - "totalReservesMantissa": "150949213552687822", - "reserveFactorMantissa": "200000000000000000", - "collateralFactorMantissa": "500000000000000000", - "borrowApy": "84.055346639454554175", - "supplyApy": "64.414651921332198395", - "borrowXvsApy": "558.550780652684606388", - "supplyXvsApy": "582.020616575499545188", - "borrowXvsApr": "1.8949516685", - "supplyXvsApr": "1.9302501255", - "liquidityCents": "0", - "tokenPriceCents": "256915.385173", - "totalDistributedMantissa": "0", - "lastCalculatedXvsAccruedBlockNumber": "38638517", - "supplyCapsMantissa": "300000000000000000000", - "borrowCapsMantissa": "4000000000000000000000", - "borrowerCount": 0, - "supplierCount": 0, - "estimatedPrimeBorrowApyBoost": null, - "estimatedPrimeSupplyApyBoost": null, - "pausedActionsBitmap": 0, - "isListed": true, - "poolComptrollerAddress": "0x94d1820b2D1c7c7452A163983Dc888CEC546b77D", - "rewardsDistributors": [ - { - "marketAddress": "0x35566ED3AF9E537Be487C98b1811cDf95ad0C32b", - "rewardTokenAddress": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", - "chainId": "97", - "lastRewardingSupplyBlockOrTimestamp": "0", - "lastRewardingBorrowBlockOrTimestamp": "0", - "supplySpeed": "596440972222220", - "borrowSpeed": "596440972222220", - "priceMantissa": "6409500000000000000", - "rewardsDistributorContractAddress": null, - "createdAt": "2024-06-18T14:48:54.000Z", - "updatedAt": "2024-09-03T14:58:33.000Z" - } - ] - }, - { - "address": "0x488aB2826a154da01CC4CC16A8C83d4720D3cA2C", - "chainId": "97", - "symbol": "vXRP", - "name": "Venus XRP", - "underlyingAddress": "0x3022A32fdAdB4f02281E8Fab33e0A6811237aab0", - "underlyingName": "XRP Token", - "underlyingSymbol": "XRP", - "underlyingDecimal": 18, - "borrowerDailyXvsMantissa": "250000012800000000000", - "supplierDailyXvsMantissa": "250000012800000000000", - "xvsBorrowIndex": "622462880290916457206416721332153725549", - "xvsSupplyIndex": "253238101787594131150524504427280384406491334", - "borrowRatePerBlock": "11630231610", - "supplyRatePerBlock": "10703452788", - "exchangeRateMantissa": "262377228244564270155318552", - "underlyingPriceMantissa": "558999990000000000", - "totalBorrowsMantissa": "25660392114161284185987093", - "totalSupplyMantissa": "95641003416966799", - "cashMantissa": "0", - "totalReservesMantissa": "566370731088635098741108", - "reserveFactorMantissa": "100000000000000000", - "collateralFactorMantissa": "600000000000000000", - "borrowApy": "12.964297292540792608", - "supplyApy": "11.872444229926720427", - "borrowXvsApy": "4.149782364239513093", - "supplyXvsApy": "4.245398150637804954", - "borrowXvsApr": "0.0407738723", - "supplyXvsApr": "0.0416941365", - "liquidityCents": "0", - "tokenPriceCents": "55.899999", - "totalDistributedMantissa": "31967022465174246959103", - "lastCalculatedXvsAccruedBlockNumber": "40813640", - "supplyCapsMantissa": "115792089237316195423570985008687907853269984665640564039457584007913129639935", - "borrowCapsMantissa": "0", - "borrowerCount": 35, - "supplierCount": 53, - "estimatedPrimeBorrowApyBoost": null, - "estimatedPrimeSupplyApyBoost": null, - "pausedActionsBitmap": 0, - "isListed": true, - "poolComptrollerAddress": "0x94d1820b2D1c7c7452A163983Dc888CEC546b77D", - "rewardsDistributors": [ - { - "marketAddress": "0x488aB2826a154da01CC4CC16A8C83d4720D3cA2C", - "rewardTokenAddress": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", - "chainId": "97", - "lastRewardingSupplyBlockOrTimestamp": "0", - "lastRewardingBorrowBlockOrTimestamp": "0", - "supplySpeed": "8680556000000000", - "borrowSpeed": "8680556000000000", - "priceMantissa": "6409500000000000000", - "rewardsDistributorContractAddress": null, - "createdAt": "2024-06-18T14:48:54.000Z", - "updatedAt": "2024-09-03T14:58:33.000Z" - } - ] - } - ] -} diff --git a/apps/evm/src/__mocks__/models/chains.ts b/apps/evm/src/__mocks__/models/chains.ts new file mode 100644 index 0000000000..076853aad6 --- /dev/null +++ b/apps/evm/src/__mocks__/models/chains.ts @@ -0,0 +1,5 @@ +export enum ChainId { + BSC_MAINNET = 56, + BSC_TESTNET = 97, + ETHEREUM = 1, +} diff --git a/apps/evm/src/__mocks__/models/markets.ts b/apps/evm/src/__mocks__/models/markets.ts deleted file mode 100644 index cf87662323..0000000000 --- a/apps/evm/src/__mocks__/models/markets.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { formatToMarket } from 'utilities'; -import apiMarketsResponse from '../api/markets.json'; - -import type { Market } from 'types'; - -export const markets: Market[] = apiMarketsResponse.result.map(apiMarket => - formatToMarket({ apiMarket }), -); diff --git a/apps/evm/src/__mocks__/models/pools.ts b/apps/evm/src/__mocks__/models/pools.ts index 0582978f71..aa0d3df9a0 100644 --- a/apps/evm/src/__mocks__/models/pools.ts +++ b/apps/evm/src/__mocks__/models/pools.ts @@ -1,41 +1,27 @@ -import { chainMetadata } from '@venusprotocol/chains'; import BigNumber from 'bignumber.js'; -import apiPoolsResponse from '__mocks__/api/pools.json'; import { assetData } from '__mocks__/models/asset'; -import formatToPool from 'clients/api/queries/getApiPools/formatToPool'; -import { ChainId, type Pool } from 'types'; +import type { Pool } from 'types'; -const { corePoolComptrollerContractAddress } = chainMetadata[ChainId.BSC_TESTNET]; +export const legacyCorePool = { + comptrollerAddress: '0x94d1820b2d1c7c7452a163983dc888cec546b77d', + assets: assetData, + name: 'Venus', + isIsolated: false, + userSupplyBalanceCents: new BigNumber(123879865), + userBorrowBalanceCents: new BigNumber(12333), + userBorrowLimitCents: new BigNumber(192673), +}; -export const apiPoolsData = apiPoolsResponse.result.map(apiPoolData => - formatToPool({ - apiPoolData, - corePoolComptrollerContractAddress, - chainId: ChainId.BSC_TESTNET, - }), -); +export const isolatedPool = { + comptrollerAddress: '0x10b57706ad2345e590c2ea4dc02faef0d9f5b08b', + assets: assetData, + name: 'Metaverse', + isIsolated: true, + userSupplyBalanceCents: new BigNumber(0), + userBorrowBalanceCents: new BigNumber(0), + userBorrowLimitCents: new BigNumber(0), +}; -export const poolData: Pool[] = [ - { - comptrollerAddress: '0x94d1820b2d1c7c7452a163983dc888cec546b77d', - assets: assetData, - name: 'Venus', - description: 'Fake description 1', - isIsolated: false, - userSupplyBalanceCents: new BigNumber(123879865), - userBorrowBalanceCents: new BigNumber(12333), - userBorrowLimitCents: new BigNumber(192673), - }, - { - comptrollerAddress: '0x10b57706ad2345e590c2ea4dc02faef0d9f5b08b', - assets: assetData, - name: 'Metaverse', - description: 'Fake description 2', - isIsolated: true, - userSupplyBalanceCents: new BigNumber(0), - userBorrowBalanceCents: new BigNumber(0), - userBorrowLimitCents: new BigNumber(0), - }, -]; +export const poolData: Pool[] = [legacyCorePool, isolatedPool]; diff --git a/apps/evm/src/__mocks__/models/tokens.ts b/apps/evm/src/__mocks__/models/tokens.ts index 1504f85a5f..5ebd2c0839 100644 --- a/apps/evm/src/__mocks__/models/tokens.ts +++ b/apps/evm/src/__mocks__/models/tokens.ts @@ -108,4 +108,4 @@ export const lisUsd: Token = { asset: lisUsdLogo, }; -export default [xvs, bnb, usdc, usdt, busd, ust, luna, vai, wbnb, eth, vrt, lisUsd]; +export default [xvs, bnb, usdc, usdt, busd, ust, luna, vai, wbnb, weth, eth, vrt, lisUsd]; diff --git a/apps/evm/src/clients/api/__mocks__/index.ts b/apps/evm/src/clients/api/__mocks__/index.ts index 79198a4b95..c2fab65e84 100644 --- a/apps/evm/src/clients/api/__mocks__/index.ts +++ b/apps/evm/src/clients/api/__mocks__/index.ts @@ -1,10 +1,14 @@ -import { type MutationObserverOptions, useMutation, useQuery } from '@tanstack/react-query'; +import { + type MutationObserverOptions, + type QueryObserverOptions, + useMutation, + useQuery, +} from '@tanstack/react-query'; import BigNumber from 'bignumber.js'; import fakeAddress from '__mocks__/models/address'; import { assetData } from '__mocks__/models/asset'; import fakeContractTransaction from '__mocks__/models/contractTransaction'; -import { markets } from '__mocks__/models/markets'; import { poolData } from '__mocks__/models/pools'; import { primeEstimationData } from '__mocks__/models/primeEstimation'; import vTokens from '__mocks__/models/vTokens'; @@ -61,14 +65,6 @@ export const useGetVaiTreasuryPercentage = vi.fn(() => export const getHypotheticalAccountLiquidity = vi.fn(); -export const getLegacyPoolMarkets = vi.fn(async () => ({ markets })); -export const useGetLegacyPoolMarkets = vi.fn(() => - useQuery({ - queryKey: [FunctionKey.GET_LEGACY_CORE_POOL_MARKETS], - queryFn: getLegacyPoolMarkets, - }), -); - export const getMarketHistory = vi.fn(); export const useGetMarketHistory = vi.fn(() => useQuery({ @@ -138,11 +134,13 @@ export const getTokenBalances = vi.fn(async ({ tokens }: { tokens: Token[] }) => })), })); -export const useGetTokenBalances = vi.fn((input: GetTokenBalancesInput) => - useQuery({ - queryKey: [FunctionKey.GET_TOKEN_BALANCES], - queryFn: () => getTokenBalances(input), - }), +export const useGetTokenBalances = vi.fn( + (input: GetTokenBalancesInput, options?: Partial) => + useQuery({ + queryKey: [FunctionKey.GET_TOKEN_BALANCES], + queryFn: () => getTokenBalances(input), + ...options, + }), ); export const getProposalMinQuorumVotes = vi.fn(); @@ -219,23 +217,6 @@ export const useGetXvsVaultUserPendingWithdrawalsFromBeforeUpgrade = vi.fn(() => }), ); -export const useGetIsolatedPools = vi.fn(() => ({ - isLoading: false, - data: { - pools: poolData.slice(1), - }, -})); - -export const getLegacyPool = vi.fn(async () => ({ - pool: poolData[0], -})); -export const useGetLegacyPool = vi.fn(() => - useQuery({ - queryKey: [FunctionKey.GET_LEGACY_POOL], - queryFn: getLegacyPool, - }), -); - export const useGetPool = vi.fn(() => ({ isLoading: false, data: { diff --git a/apps/evm/src/clients/api/index.ts b/apps/evm/src/clients/api/index.ts index eb0ea5008d..b3f6b278fe 100644 --- a/apps/evm/src/clients/api/index.ts +++ b/apps/evm/src/clients/api/index.ts @@ -140,14 +140,6 @@ export { default as useGetVaiTreasuryPercentage } from './queries/getVaiTreasury export { default as getHypotheticalAccountLiquidity } from './queries/getHypotheticalAccountLiquidity'; export * from './queries/getHypotheticalAccountLiquidity'; -export { default as getApiMarkets } from './queries/getApiMarkets'; -export * from './queries/getApiMarkets'; -export { default as useGetApiMarkets } from './queries/getApiMarkets/useGetApiMarkets'; - -export { default as getPools } from './queries/getApiPools'; -export * from './queries/getApiPools'; -export { default as useGetApiPools } from './queries/getApiPools/useGetApiPools'; - export { default as getVTokenBalancesAll } from './queries/getVTokenBalancesAll'; export * from './queries/getVTokenBalancesAll'; export { default as useGetVTokenBalancesAll } from './queries/getVTokenBalancesAll/useGetVTokenBalancesAll'; @@ -199,19 +191,10 @@ export { default as useGetXvsWithdrawableAmount } from './queries/getXvsWithdraw export { default as useGetAsset } from './queries/useGetAsset'; -export * from './queries/getLegacyPool'; -export { default as useGetLegacyPool } from './queries/getLegacyPool/useGetLegacyPool'; - -export { default as useGetPools } from './queries/useGetPools'; - -export { default as useGetLegacyPoolMarkets } from './queries/useGetLegacyPoolMarkets'; +export * from './queries/useGetPools'; export { default as useGetPool } from './queries/useGetPool'; -export { default as getIsolatedPools } from './queries/getIsolatedPools'; -export * from './queries/getIsolatedPools'; -export { default as useGetIsolatedPools } from './queries/getIsolatedPools/useGetIsolatedPools'; - export { default as getMarketHistory } from './queries/getMarketHistory'; export * from './queries/getMarketHistory'; export { default as useGetMarketHistory } from './queries/getMarketHistory/useGetMarketHistory'; diff --git a/apps/evm/src/clients/api/queries/getApiMarkets/useGetApiMarkets.ts b/apps/evm/src/clients/api/queries/getApiMarkets/useGetApiMarkets.ts deleted file mode 100644 index ef26b98b32..0000000000 --- a/apps/evm/src/clients/api/queries/getApiMarkets/useGetApiMarkets.ts +++ /dev/null @@ -1,37 +0,0 @@ -import { type QueryObserverOptions, useQuery } from '@tanstack/react-query'; - -import getApiMarkets, { - type GetApiMarketsInput, - type GetApiMarketsOutput, -} from 'clients/api/queries/getApiMarkets'; -import FunctionKey from 'constants/functionKey'; -import { useGetToken } from 'libs/tokens'; -import { useChainId } from 'libs/wallet'; -import { callOrThrow } from 'utilities'; - -type TrimmedGetMarketsInput = Omit; - -export type UseGetMarketsQueryKey = [FunctionKey.GET_MARKETS, TrimmedGetMarketsInput]; - -type Options = QueryObserverOptions< - GetApiMarketsOutput, - Error, - GetApiMarketsOutput, - GetApiMarketsOutput, - UseGetMarketsQueryKey ->; - -const useGetApiMarkets = (options?: Options) => { - const { chainId } = useChainId(); - const xvs = useGetToken({ - symbol: 'XVS', - }); - - return useQuery({ - queryKey: [FunctionKey.GET_MARKETS, { chainId }], - queryFn: () => callOrThrow({ xvs }, params => getApiMarkets({ ...params, chainId })), - ...options, - }); -}; - -export default useGetApiMarkets; diff --git a/apps/evm/src/clients/api/queries/getApiPools/formatToPool.ts b/apps/evm/src/clients/api/queries/getApiPools/formatToPool.ts deleted file mode 100644 index 6ba5cbf709..0000000000 --- a/apps/evm/src/clients/api/queries/getApiPools/formatToPool.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { ChainId } from 'types'; -import { areAddressesEqual, formatToMarket } from 'utilities'; -import type { ApiPoolData } from '.'; - -interface FormatToPoolInput { - apiPoolData: ApiPoolData; - corePoolComptrollerContractAddress: string; - chainId: ChainId; -} - -const formatToPool = ({ - apiPoolData, - corePoolComptrollerContractAddress, - chainId, -}: FormatToPoolInput) => ({ - address: apiPoolData.address, - name: apiPoolData.name, - description: apiPoolData.description ?? '', - isIsolated: - chainId === ChainId.BSC_MAINNET || chainId === ChainId.BSC_TESTNET - ? !areAddressesEqual(corePoolComptrollerContractAddress, apiPoolData.address) - : true, - markets: apiPoolData.markets.map(apiMarket => formatToMarket({ apiMarket })), -}); - -export default formatToPool; diff --git a/apps/evm/src/clients/api/queries/getApiPools/index.ts b/apps/evm/src/clients/api/queries/getApiPools/index.ts deleted file mode 100644 index abab9e8edb..0000000000 --- a/apps/evm/src/clients/api/queries/getApiPools/index.ts +++ /dev/null @@ -1,58 +0,0 @@ -import type { ChainId, Market } from 'types'; -import { restService } from 'utilities'; -import type { ApiMarketData } from '../getApiMarkets'; -import formatToPool from './formatToPool'; - -export interface ApiPoolData { - address: string; - name: string; - description: string | null; - markets: ApiMarketData[]; -} - -export interface GetApiPoolsResponse { - result: ApiPoolData[]; - request: { addresses: string[] }; -} - -export interface GetApiPoolsInput { - chainId: ChainId; - corePoolComptrollerContractAddress: string; -} - -export interface GetApiPoolsOutput { - pools: { - address: string; - name: string; - description: string; - isIsolated: boolean; - markets: Market[]; - }[]; -} - -const getPools = async ({ - chainId, - corePoolComptrollerContractAddress, -}: GetApiPoolsInput): Promise => { - const response = await restService({ - endpoint: '/pools', - method: 'GET', - params: { - chainId, - }, - }); - - const payload = response.data; - - if (payload && 'error' in payload) { - throw new Error(payload.error); - } - - return { - pools: (payload?.result || []).map(apiPoolData => - formatToPool({ apiPoolData, corePoolComptrollerContractAddress, chainId }), - ), - }; -}; - -export default getPools; diff --git a/apps/evm/src/clients/api/queries/getApiPools/useGetApiPools.ts b/apps/evm/src/clients/api/queries/getApiPools/useGetApiPools.ts deleted file mode 100644 index 7d808206e6..0000000000 --- a/apps/evm/src/clients/api/queries/getApiPools/useGetApiPools.ts +++ /dev/null @@ -1,39 +0,0 @@ -import { type QueryObserverOptions, useQuery } from '@tanstack/react-query'; - -import getApiPools, { - type GetApiPoolsInput, - type GetApiPoolsOutput, -} from 'clients/api/queries/getApiPools'; -import FunctionKey from 'constants/functionKey'; -import { useGetChainMetadata } from 'hooks/useGetChainMetadata'; -import { useGetToken } from 'libs/tokens'; -import { useChainId } from 'libs/wallet'; -import { callOrThrow } from 'utilities'; - -type TrimmedGetApiPoolsInput = Omit; - -export type UseGetApiPoolsQueryKey = [FunctionKey.GET_POOLS, TrimmedGetApiPoolsInput]; - -type Options = QueryObserverOptions< - GetApiPoolsOutput, - Error, - GetApiPoolsOutput, - GetApiPoolsOutput, - UseGetApiPoolsQueryKey ->; - -const useGetApiPools = (options?: Options) => { - const xvs = useGetToken({ - symbol: 'XVS', - }); - const { chainId } = useChainId(); - const { corePoolComptrollerContractAddress } = useGetChainMetadata(); - - return useQuery({ - queryKey: [FunctionKey.GET_POOLS, { chainId, corePoolComptrollerContractAddress }], - queryFn: () => callOrThrow({ chainId, corePoolComptrollerContractAddress, xvs }, getApiPools), - ...options, - }); -}; - -export default useGetApiPools; diff --git a/apps/evm/src/clients/api/queries/getIsolatedPools/__testUtils__/fakeData.ts b/apps/evm/src/clients/api/queries/getIsolatedPools/__testUtils__/fakeData.ts deleted file mode 100644 index 0e7c80ea30..0000000000 --- a/apps/evm/src/clients/api/queries/getIsolatedPools/__testUtils__/fakeData.ts +++ /dev/null @@ -1,75 +0,0 @@ -import { BigNumber as BN } from 'ethers'; - -import fakePoolLensContractResponses from '__mocks__/contracts/poolLens'; -import { xvs } from '__mocks__/models/tokens'; - -import type { getIsolatedPoolParticipantsCount } from 'clients/subgraph'; -import MAX_UINT256 from 'constants/maxUint256'; -import type { - IsolatedPoolComptroller, - PoolLens, - ResilientOracle, - RewardsDistributor, -} from 'libs/contracts'; - -export const fakeIsolatedPoolParticipantsCount: Awaited< - ReturnType -> = { - pools: fakePoolLensContractResponses.getAllPools.map(pool => ({ - __typename: 'Pool', - id: pool.comptroller, - markets: pool.vTokens.map(({ vToken }) => ({ - id: vToken, - supplierCount: 10, - borrowerCount: 20, - })), - })), -}; - -export const fakeGetPriceOutput = BN.from('0x30f7dc8a6370b000'); - -export const fakeGetAssetsInOutput = [ - '0x501a91b995Bd41177503A1A4144F3D25BFF869e1', - '0x2517A3bEe42EA8f628926849B04870260164b555', -]; - -export const fakeGetRewardDistributorsOutput = [ - '0x170d3b2da05cc2124334240fB34ad1359e34C562', - '0x3338988d0beb4419Acb8fE624218754053362D06', -]; - -export const fakePoolRegistryContractAddress = '0x4301F2213c0eeD49a7E28Ae4c3e91722919B8B45'; - -export const fakePoolLensContract = { - getAllPools: async () => fakePoolLensContractResponses.getAllPools, - callStatic: { - vTokenBalancesAll: async (vTokenAddresses: string[]) => - vTokenAddresses.map(vTokenAddress => ({ - vToken: vTokenAddress, - balanceOf: BN.from('1000000000000000000'), - balanceOfUnderlying: BN.from('2000000000000000000'), - borrowBalanceCurrent: BN.from('300000000000000000'), - tokenBalance: BN.from('40000000000000000000'), - tokenAllowance: BN.from(MAX_UINT256), - })), - }, -} as unknown as PoolLens; - -export const fakeResilientOracleContract = { - getPrice: async () => fakeGetPriceOutput, -} as unknown as ResilientOracle; - -export const fakeIsolatedPoolComptrollerContract = { - getRewardDistributors: async () => fakeGetRewardDistributorsOutput, - getAssetsIn: async () => fakeGetAssetsInOutput, -} as unknown as IsolatedPoolComptroller; - -export const fakeRewardsDistributorContract = { - rewardToken: async () => xvs.address, - rewardTokenSupplySpeeds: async () => BN.from('868055555555556'), - rewardTokenBorrowSpeeds: async () => BN.from('868055555555556'), - rewardTokenSupplyState: async () => ({ lastRewardingBlock: 0 }), - rewardTokenBorrowState: async () => ({ lastRewardingBlock: 0 }), - rewardTokenSupplyStateTimeBased: async () => ({ lastRewardingTimestamp: BN.from(0) }), - rewardTokenBorrowStateTimeBased: async () => ({ lastRewardingTimestamp: BN.from(0) }), -} as unknown as RewardsDistributor; diff --git a/apps/evm/src/clients/api/queries/getIsolatedPools/__tests__/__snapshots__/index.spec.ts.snap b/apps/evm/src/clients/api/queries/getIsolatedPools/__tests__/__snapshots__/index.spec.ts.snap deleted file mode 100644 index 5eefcf79cf..0000000000 --- a/apps/evm/src/clients/api/queries/getIsolatedPools/__tests__/__snapshots__/index.spec.ts.snap +++ /dev/null @@ -1,995 +0,0 @@ -// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html - -exports[`getIsolatedPools > returns isolated pools with block based reward rates in the correct format 1`] = ` -{ - "pools": [ - { - "assets": [ - { - "borrowApyPercentage": "3.0457256612776096", - "borrowBalanceCents": "10266.891765447722", - "borrowBalanceTokens": "102.672734", - "borrowCapTokens": "14880000", - "borrowDistributions": [ - { - "apyPercentage": "0", - "dailyDistributedTokens": "0", - "token": { - "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", - "asset": "/src/libs/tokens/img/usdt.svg", - "decimals": 6, - "symbol": "USDT", - }, - "type": "rewardDistributor", - }, - ], - "borrowerCount": 20, - "cashTokens": "2649291.731707", - "collateralFactor": 0.8, - "disabledTokenActions": [], - "exchangeRateVTokens": "0.99999847176819609601", - "isCollateralOfUser": false, - "liquidityCents": "264919325.753333245081", - "reserveFactor": 0.1, - "reserveTokens": "0", - "supplierCount": 10, - "supplyApyPercentage": "0.000104647012366676", - "supplyBalanceCents": "264929592.64509868800383953542527752", - "supplyBalanceTokens": "2649394.40444099995200661144", - "supplyCapTokens": "18600000", - "supplyDistributions": [ - { - "apyPercentage": "0", - "dailyDistributedTokens": "0", - "token": { - "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", - "asset": "/src/libs/tokens/img/usdt.svg", - "decimals": 6, - "symbol": "USDT", - }, - "type": "rewardDistributor", - }, - ], - "tokenPriceCents": "99.996283", - "userBorrowBalanceCents": "0", - "userBorrowBalanceTokens": "0", - "userPercentOfLimit": 0, - "userSupplyBalanceCents": "0", - "userSupplyBalanceTokens": "0", - "userWalletBalanceCents": "0", - "userWalletBalanceTokens": "0", - "vToken": { - "address": "0x80CC30811e362aC9aB857C3d7875CbcCc0b65750", - "decimals": 8, - "symbol": "vUSDT", - "underlyingToken": { - "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", - "asset": "/src/libs/tokens/img/usdt.svg", - "decimals": 6, - "symbol": "USDT", - }, - }, - }, - ], - "comptrollerAddress": "0x23a73971A6B9f6580c048B9CB188869B2A2aA2aD", - "description": "", - "isIsolated": true, - "name": "DeFi", - "userBorrowBalanceCents": "0", - "userBorrowLimitCents": "0", - "userSupplyBalanceCents": "0", - }, - { - "assets": [ - { - "borrowApyPercentage": "4.003672121275481", - "borrowBalanceCents": "1032129.557718287222", - "borrowBalanceTokens": "10321.679234", - "borrowCapTokens": "14880000", - "borrowDistributions": [], - "borrowerCount": 20, - "cashTokens": "101166.023761", - "collateralFactor": 0.8, - "disabledTokenActions": [], - "exchangeRateVTokens": "0.997398625122774492", - "isCollateralOfUser": false, - "liquidityCents": "10116226.341989680363", - "reserveFactor": 0.1, - "reserveTokens": "0.000131", - "supplierCount": 10, - "supplyApyPercentage": "0.32764541346423925", - "supplyBalanceCents": "11148355.88660845370158439626770976", - "supplyBalanceTokens": "111487.70286399999189554272", - "supplyCapTokens": "18600000", - "supplyDistributions": [], - "tokenPriceCents": "99.996283", - "userBorrowBalanceCents": "0", - "userBorrowBalanceTokens": "0", - "userPercentOfLimit": 0, - "userSupplyBalanceCents": "0", - "userSupplyBalanceTokens": "0", - "userWalletBalanceCents": "0", - "userWalletBalanceTokens": "0", - "vToken": { - "address": "0x0bFE4e0B8A2a096A27e5B18b078d25be57C08634", - "decimals": 8, - "symbol": "vUSDT", - "underlyingToken": { - "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", - "asset": "/src/libs/tokens/img/usdt.svg", - "decimals": 6, - "symbol": "USDT", - }, - }, - }, - ], - "comptrollerAddress": "0x1F4f0989C51f12DAcacD4025018176711f3Bf289", - "description": "", - "isIsolated": true, - "name": "GameFi", - "userBorrowBalanceCents": "0", - "userBorrowLimitCents": "0", - "userSupplyBalanceCents": "0", - }, - { - "assets": [ - { - "borrowApyPercentage": "3.045326359470546", - "borrowBalanceCents": "0.000399985132", - "borrowBalanceTokens": "0.000004", - "borrowCapTokens": "14880000", - "borrowDistributions": [ - { - "apyPercentage": "0", - "dailyDistributedTokens": "0", - "token": { - "address": "0xe73774DfCD551BF75650772dC2cC56a2B6323453", - "asset": "/src/libs/tokens/img/lisUSD.png", - "decimals": 18, - "symbol": "lisUSD", - }, - "type": "rewardDistributor", - }, - ], - "borrowerCount": 20, - "cashTokens": "11031000", - "collateralFactor": 0.8, - "disabledTokenActions": [], - "exchangeRateVTokens": "0.999999999999545", - "isCollateralOfUser": false, - "liquidityCents": "1103058997.773", - "reserveFactor": 0.1, - "reserveTokens": "0", - "supplierCount": 10, - "supplyApyPercentage": "0", - "supplyBalanceCents": "1103058997.77339989563532689599327223", - "supplyBalanceTokens": "11031000.00000399910500000181", - "supplyCapTokens": "18600000", - "supplyDistributions": [ - { - "apyPercentage": "0", - "dailyDistributedTokens": "0", - "token": { - "address": "0xe73774DfCD551BF75650772dC2cC56a2B6323453", - "asset": "/src/libs/tokens/img/lisUSD.png", - "decimals": 18, - "symbol": "lisUSD", - }, - "type": "rewardDistributor", - }, - ], - "tokenPriceCents": "99.996283", - "userBorrowBalanceCents": "0", - "userBorrowBalanceTokens": "0", - "userPercentOfLimit": 0, - "userSupplyBalanceCents": "0", - "userSupplyBalanceTokens": "0", - "userWalletBalanceCents": "0", - "userWalletBalanceTokens": "0", - "vToken": { - "address": "0x2197d02cC9cd1ad51317A0a85A656a0c82383A7c", - "decimals": 8, - "symbol": "vUSDT", - "underlyingToken": { - "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", - "asset": "/src/libs/tokens/img/usdt.svg", - "decimals": 6, - "symbol": "USDT", - }, - }, - }, - { - "borrowApyPercentage": "399.5548791715505", - "borrowBalanceCents": "14020.2378315565440147153504", - "borrowBalanceTokens": "0.267025220823379366", - "borrowCapTokens": "56000", - "borrowDistributions": [ - { - "apyPercentage": "0", - "dailyDistributedTokens": "0", - "token": { - "address": "0xe73774DfCD551BF75650772dC2cC56a2B6323453", - "asset": "/src/libs/tokens/img/lisUSD.png", - "decimals": 18, - "symbol": "lisUSD", - }, - "type": "rewardDistributor", - }, - ], - "borrowerCount": 20, - "cashTokens": "0.000705300034659891", - "collateralFactor": 0.45, - "disabledTokenActions": [], - "exchangeRateVTokens": "0.856077892298015039", - "isCollateralOfUser": false, - "liquidityCents": "37.0319859601477808269104", - "reserveFactor": 0.25, - "reserveTokens": "0", - "supplierCount": 10, - "supplyApyPercentage": "233.30903562118922", - "supplyBalanceCents": "14057.269817516691795017207856", - "supplyBalanceTokens": "0.26773052085803925699", - "supplyCapTokens": "80000", - "supplyDistributions": [ - { - "apyPercentage": "0", - "dailyDistributedTokens": "0", - "token": { - "address": "0xe73774DfCD551BF75650772dC2cC56a2B6323453", - "asset": "/src/libs/tokens/img/lisUSD.png", - "decimals": 18, - "symbol": "lisUSD", - }, - "type": "rewardDistributor", - }, - ], - "tokenPriceCents": "52505.2944", - "userBorrowBalanceCents": "0", - "userBorrowBalanceTokens": "0", - "userPercentOfLimit": 0, - "userSupplyBalanceCents": "0", - "userSupplyBalanceTokens": "0", - "userWalletBalanceCents": "0", - "userWalletBalanceTokens": "0", - "vToken": { - "address": "0x231dED0Dfc99634e52EE1a1329586bc970d773b3", - "decimals": 8, - "symbol": "vWBNB", - "underlyingToken": { - "address": "0xae13d989daC2f0dEbFf460aC112a837C89BAa7cd", - "asset": "/src/libs/tokens/img/wbnb.svg", - "decimals": 18, - "symbol": "WBNB", - }, - }, - }, - ], - "comptrollerAddress": "0x596B11acAACF03217287939f88d63b51d3771704", - "description": "", - "isIsolated": true, - "name": "Liquid Staked BNB", - "userBorrowBalanceCents": "0", - "userBorrowLimitCents": "0", - "userSupplyBalanceCents": "0", - }, - { - "assets": [ - { - "borrowApyPercentage": "0.011647930409597329", - "borrowBalanceCents": "399.985132", - "borrowBalanceTokens": "4", - "borrowCapTokens": "900000", - "borrowDistributions": [], - "borrowerCount": 0, - "cashTokens": "6006", - "collateralFactor": 0.75, - "disabledTokenActions": [], - "exchangeRateVTokens": "1", - "isCollateralOfUser": false, - "liquidityCents": "600577.675698", - "reserveFactor": 0.1, - "reserveTokens": "0", - "supplierCount": 0, - "supplyApyPercentage": "0.000006975767097294", - "supplyBalanceCents": "600977.66083", - "supplyBalanceTokens": "6010", - "supplyCapTokens": "1000000", - "supplyDistributions": [], - "tokenPriceCents": "99.996283", - "userBorrowBalanceCents": "0", - "userBorrowBalanceTokens": "0", - "userPercentOfLimit": 0, - "userSupplyBalanceCents": "0", - "userSupplyBalanceTokens": "0", - "userWalletBalanceCents": "0", - "userWalletBalanceTokens": "0", - "vToken": { - "address": "0x3AF2bE7AbEF0f840b196D99d79F4B803a5dB14a1", - "decimals": 8, - "symbol": "vUSDT", - "underlyingToken": { - "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", - "asset": "/src/libs/tokens/img/usdt.svg", - "decimals": 6, - "symbol": "USDT", - }, - }, - }, - ], - "comptrollerAddress": "0x92e8E3C202093A495e98C10f9fcaa5Abe288F74A", - "description": "", - "isIsolated": true, - "name": "Meme", - "userBorrowBalanceCents": "0", - "userBorrowLimitCents": "0", - "userSupplyBalanceCents": "0", - }, - { - "assets": [ - { - "borrowApyPercentage": "5.130421804803698", - "borrowBalanceCents": "1030091.4588649133175062", - "borrowBalanceTokens": "10300.914588649133175062", - "borrowCapTokens": "200000", - "borrowDistributions": [], - "borrowerCount": 20, - "cashTokens": "32569.640339677929523638", - "collateralFactor": 0.65, - "disabledTokenActions": [], - "exchangeRateVTokens": "0.9930076443898276885", - "isCollateralOfUser": false, - "liquidityCents": "3256964.0339677929523638", - "reserveFactor": 0.2, - "reserveTokens": "0.000166728600388574", - "supplierCount": 10, - "supplyApyPercentage": "0.966416714921392", - "supplyBalanceCents": "4287055.476159846231009819", - "supplyBalanceTokens": "42870.55476159846231009819", - "supplyCapTokens": "500000", - "supplyDistributions": [], - "tokenPriceCents": "100", - "userBorrowBalanceCents": "0", - "userBorrowBalanceTokens": "0", - "userPercentOfLimit": 0, - "userSupplyBalanceCents": "0", - "userSupplyBalanceTokens": "0", - "userWalletBalanceCents": "0", - "userWalletBalanceTokens": "0", - "vToken": { - "address": "0x170d3b2da05cc2124334240fB34ad1359e34C562", - "decimals": 8, - "symbol": "vlisUSD", - "underlyingToken": { - "address": "0xe73774DfCD551BF75650772dC2cC56a2B6323453", - "asset": "/src/libs/tokens/img/lisUSD.png", - "decimals": 18, - "symbol": "lisUSD", - }, - }, - }, - { - "borrowApyPercentage": "2.028626199218375", - "borrowBalanceCents": "100461.088822525373", - "borrowBalanceTokens": "1004.648231", - "borrowCapTokens": "400000", - "borrowDistributions": [ - { - "apyPercentage": "0", - "dailyDistributedTokens": "0", - "token": { - "address": "0xe73774DfCD551BF75650772dC2cC56a2B6323453", - "asset": "/src/libs/tokens/img/lisUSD.png", - "decimals": 18, - "symbol": "lisUSD", - }, - "type": "rewardDistributor", - }, - ], - "borrowerCount": 20, - "cashTokens": "998174.53518", - "collateralFactor": 0.8, - "disabledTokenActions": [], - "exchangeRateVTokens": "0.99998934225265418908", - "isCollateralOfUser": false, - "liquidityCents": "99813743.30325273594", - "reserveFactor": 0.1, - "reserveTokens": "0.000002", - "supplierCount": 10, - "supplyApyPercentage": "0.001817450869823211", - "supplyBalanceCents": "99914204.39187526542630629377313097", - "supplyBalanceTokens": "999179.18340899996679182859", - "supplyCapTokens": "1000000", - "supplyDistributions": [ - { - "apyPercentage": "0", - "dailyDistributedTokens": "0", - "token": { - "address": "0xe73774DfCD551BF75650772dC2cC56a2B6323453", - "asset": "/src/libs/tokens/img/lisUSD.png", - "decimals": 18, - "symbol": "lisUSD", - }, - "type": "rewardDistributor", - }, - ], - "tokenPriceCents": "99.996283", - "userBorrowBalanceCents": "0", - "userBorrowBalanceTokens": "0", - "userPercentOfLimit": 0, - "userSupplyBalanceCents": "0", - "userSupplyBalanceTokens": "0", - "userWalletBalanceCents": "0", - "userWalletBalanceTokens": "0", - "vToken": { - "address": "0x3338988d0beb4419Acb8fE624218754053362D06", - "decimals": 8, - "symbol": "vUSDT", - "underlyingToken": { - "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", - "asset": "/src/libs/tokens/img/usdt.svg", - "decimals": 6, - "symbol": "USDT", - }, - }, - }, - ], - "comptrollerAddress": "0x10b57706AD2345e590c2eA4DC02faef0d9f5b08B", - "description": "", - "isIsolated": true, - "name": "Stablecoins", - "userBorrowBalanceCents": "0", - "userBorrowLimitCents": "0", - "userSupplyBalanceCents": "0", - }, - { - "assets": [ - { - "borrowApyPercentage": "3.045326359470546", - "borrowBalanceCents": "0", - "borrowBalanceTokens": "0", - "borrowCapTokens": "14880000", - "borrowDistributions": [], - "borrowerCount": 20, - "cashTokens": "10000", - "collateralFactor": 0.8, - "disabledTokenActions": [], - "exchangeRateVTokens": "1", - "isCollateralOfUser": false, - "liquidityCents": "999962.83", - "reserveFactor": 0.1, - "reserveTokens": "0", - "supplierCount": 10, - "supplyApyPercentage": "0", - "supplyBalanceCents": "999962.83", - "supplyBalanceTokens": "10000", - "supplyCapTokens": "18600000", - "supplyDistributions": [], - "tokenPriceCents": "99.996283", - "userBorrowBalanceCents": "0", - "userBorrowBalanceTokens": "0", - "userPercentOfLimit": 0, - "userSupplyBalanceCents": "0", - "userSupplyBalanceTokens": "0", - "userWalletBalanceCents": "0", - "userWalletBalanceTokens": "0", - "vToken": { - "address": "0x712774CBFFCBD60e9825871CcEFF2F917442b2c3", - "decimals": 8, - "symbol": "vUSDT", - "underlyingToken": { - "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", - "asset": "/src/libs/tokens/img/usdt.svg", - "decimals": 6, - "symbol": "USDT", - }, - }, - }, - ], - "comptrollerAddress": "0x11537D023f489E4EF0C7157cc729C7B69CbE0c97", - "description": "", - "isIsolated": true, - "name": "Tron", - "userBorrowBalanceCents": "0", - "userBorrowLimitCents": "0", - "userSupplyBalanceCents": "0", - }, - ], -} -`; - -exports[`getIsolatedPools > returns isolated pools with time based reward rates in the correct format 1`] = ` -{ - "pools": [ - { - "assets": [ - { - "borrowApyPercentage": "9.417486254245567", - "borrowBalanceCents": "10266.891765447722", - "borrowBalanceTokens": "102.672734", - "borrowCapTokens": "14880000", - "borrowDistributions": [ - { - "apyPercentage": "0", - "dailyDistributedTokens": "0", - "token": { - "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", - "asset": "/src/libs/tokens/img/usdt.svg", - "decimals": 6, - "symbol": "USDT", - }, - "type": "rewardDistributor", - }, - ], - "borrowerCount": 20, - "cashTokens": "2649291.731707", - "collateralFactor": 0.8, - "disabledTokenActions": [], - "exchangeRateVTokens": "0.99999847176819609601", - "isCollateralOfUser": false, - "liquidityCents": "264919325.753333245081", - "reserveFactor": 0.1, - "reserveTokens": "0", - "supplierCount": 10, - "supplyApyPercentage": "0.000313941372853676", - "supplyBalanceCents": "264929592.64509868800383953542527752", - "supplyBalanceTokens": "2649394.40444099995200661144", - "supplyCapTokens": "18600000", - "supplyDistributions": [ - { - "apyPercentage": "0", - "dailyDistributedTokens": "0", - "token": { - "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", - "asset": "/src/libs/tokens/img/usdt.svg", - "decimals": 6, - "symbol": "USDT", - }, - "type": "rewardDistributor", - }, - ], - "tokenPriceCents": "99.996283", - "userBorrowBalanceCents": "0", - "userBorrowBalanceTokens": "0", - "userPercentOfLimit": 0, - "userSupplyBalanceCents": "0", - "userSupplyBalanceTokens": "0", - "userWalletBalanceCents": "0", - "userWalletBalanceTokens": "0", - "vToken": { - "address": "0x80CC30811e362aC9aB857C3d7875CbcCc0b65750", - "decimals": 8, - "symbol": "vUSDT", - "underlyingToken": { - "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", - "asset": "/src/libs/tokens/img/usdt.svg", - "decimals": 6, - "symbol": "USDT", - }, - }, - }, - ], - "comptrollerAddress": "0x23a73971A6B9f6580c048B9CB188869B2A2aA2aD", - "description": "", - "isIsolated": true, - "name": "DeFi", - "userBorrowBalanceCents": "0", - "userBorrowLimitCents": "0", - "userSupplyBalanceCents": "0", - }, - { - "assets": [ - { - "borrowApyPercentage": "12.496891075741745", - "borrowBalanceCents": "1032129.557718287222", - "borrowBalanceTokens": "10321.679234", - "borrowCapTokens": "14880000", - "borrowDistributions": [], - "borrowerCount": 20, - "cashTokens": "101166.023761", - "collateralFactor": 0.8, - "disabledTokenActions": [], - "exchangeRateVTokens": "0.997398625122774492", - "isCollateralOfUser": false, - "liquidityCents": "10116226.341989680363", - "reserveFactor": 0.1, - "reserveTokens": "0.000131", - "supplierCount": 10, - "supplyApyPercentage": "0.986151422039705", - "supplyBalanceCents": "11148355.88660845370158439626770976", - "supplyBalanceTokens": "111487.70286399999189554272", - "supplyCapTokens": "18600000", - "supplyDistributions": [], - "tokenPriceCents": "99.996283", - "userBorrowBalanceCents": "0", - "userBorrowBalanceTokens": "0", - "userPercentOfLimit": 0, - "userSupplyBalanceCents": "0", - "userSupplyBalanceTokens": "0", - "userWalletBalanceCents": "0", - "userWalletBalanceTokens": "0", - "vToken": { - "address": "0x0bFE4e0B8A2a096A27e5B18b078d25be57C08634", - "decimals": 8, - "symbol": "vUSDT", - "underlyingToken": { - "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", - "asset": "/src/libs/tokens/img/usdt.svg", - "decimals": 6, - "symbol": "USDT", - }, - }, - }, - ], - "comptrollerAddress": "0x1F4f0989C51f12DAcacD4025018176711f3Bf289", - "description": "", - "isIsolated": true, - "name": "GameFi", - "userBorrowBalanceCents": "0", - "userBorrowLimitCents": "0", - "userSupplyBalanceCents": "0", - }, - { - "assets": [ - { - "borrowApyPercentage": "9.416214491141229", - "borrowBalanceCents": "0.000399985132", - "borrowBalanceTokens": "0.000004", - "borrowCapTokens": "14880000", - "borrowDistributions": [ - { - "apyPercentage": "0", - "dailyDistributedTokens": "0", - "token": { - "address": "0xe73774DfCD551BF75650772dC2cC56a2B6323453", - "asset": "/src/libs/tokens/img/lisUSD.png", - "decimals": 18, - "symbol": "lisUSD", - }, - "type": "rewardDistributor", - }, - ], - "borrowerCount": 20, - "cashTokens": "11031000", - "collateralFactor": 0.8, - "disabledTokenActions": [], - "exchangeRateVTokens": "0.999999999999545", - "isCollateralOfUser": false, - "liquidityCents": "1103058997.773", - "reserveFactor": 0.1, - "reserveTokens": "0", - "supplierCount": 10, - "supplyApyPercentage": "0", - "supplyBalanceCents": "1103058997.77339989563532689599327223", - "supplyBalanceTokens": "11031000.00000399910500000181", - "supplyCapTokens": "18600000", - "supplyDistributions": [ - { - "apyPercentage": "0", - "dailyDistributedTokens": "0", - "token": { - "address": "0xe73774DfCD551BF75650772dC2cC56a2B6323453", - "asset": "/src/libs/tokens/img/lisUSD.png", - "decimals": 18, - "symbol": "lisUSD", - }, - "type": "rewardDistributor", - }, - ], - "tokenPriceCents": "99.996283", - "userBorrowBalanceCents": "0", - "userBorrowBalanceTokens": "0", - "userPercentOfLimit": 0, - "userSupplyBalanceCents": "0", - "userSupplyBalanceTokens": "0", - "userWalletBalanceCents": "0", - "userWalletBalanceTokens": "0", - "vToken": { - "address": "0x2197d02cC9cd1ad51317A0a85A656a0c82383A7c", - "decimals": 8, - "symbol": "vUSDT", - "underlyingToken": { - "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", - "asset": "/src/libs/tokens/img/usdt.svg", - "decimals": 6, - "symbol": "USDT", - }, - }, - }, - { - "borrowApyPercentage": "12106.214016012123", - "borrowBalanceCents": "14020.2378315565440147153504", - "borrowBalanceTokens": "0.267025220823379366", - "borrowCapTokens": "56000", - "borrowDistributions": [ - { - "apyPercentage": "0", - "dailyDistributedTokens": "0", - "token": { - "address": "0xe73774DfCD551BF75650772dC2cC56a2B6323453", - "asset": "/src/libs/tokens/img/lisUSD.png", - "decimals": 18, - "symbol": "lisUSD", - }, - "type": "rewardDistributor", - }, - ], - "borrowerCount": 20, - "cashTokens": "0.000705300034659891", - "collateralFactor": 0.45, - "disabledTokenActions": [], - "exchangeRateVTokens": "0.856077892298015039", - "isCollateralOfUser": false, - "liquidityCents": "37.0319859601477808269104", - "reserveFactor": 0.25, - "reserveTokens": "0", - "supplierCount": 10, - "supplyApyPercentage": "3559.2823592784207", - "supplyBalanceCents": "14057.269817516691795017207856", - "supplyBalanceTokens": "0.26773052085803925699", - "supplyCapTokens": "80000", - "supplyDistributions": [ - { - "apyPercentage": "0", - "dailyDistributedTokens": "0", - "token": { - "address": "0xe73774DfCD551BF75650772dC2cC56a2B6323453", - "asset": "/src/libs/tokens/img/lisUSD.png", - "decimals": 18, - "symbol": "lisUSD", - }, - "type": "rewardDistributor", - }, - ], - "tokenPriceCents": "52505.2944", - "userBorrowBalanceCents": "0", - "userBorrowBalanceTokens": "0", - "userPercentOfLimit": 0, - "userSupplyBalanceCents": "0", - "userSupplyBalanceTokens": "0", - "userWalletBalanceCents": "0", - "userWalletBalanceTokens": "0", - "vToken": { - "address": "0x231dED0Dfc99634e52EE1a1329586bc970d773b3", - "decimals": 8, - "symbol": "vWBNB", - "underlyingToken": { - "address": "0xae13d989daC2f0dEbFf460aC112a837C89BAa7cd", - "asset": "/src/libs/tokens/img/wbnb.svg", - "decimals": 18, - "symbol": "WBNB", - }, - }, - }, - ], - "comptrollerAddress": "0x596B11acAACF03217287939f88d63b51d3771704", - "description": "", - "isIsolated": true, - "name": "Liquid Staked BNB", - "userBorrowBalanceCents": "0", - "userBorrowLimitCents": "0", - "userSupplyBalanceCents": "0", - }, - { - "assets": [ - { - "borrowApyPercentage": "0.034947850469535524", - "borrowBalanceCents": "399.985132", - "borrowBalanceTokens": "4", - "borrowCapTokens": "900000", - "borrowDistributions": [], - "borrowerCount": 0, - "cashTokens": "6006", - "collateralFactor": 0.75, - "disabledTokenActions": [], - "exchangeRateVTokens": "1", - "isCollateralOfUser": false, - "liquidityCents": "600577.675698", - "reserveFactor": 0.1, - "reserveTokens": "0", - "supplierCount": 0, - "supplyApyPercentage": "0.000020927294630546", - "supplyBalanceCents": "600977.66083", - "supplyBalanceTokens": "6010", - "supplyCapTokens": "1000000", - "supplyDistributions": [], - "tokenPriceCents": "99.996283", - "userBorrowBalanceCents": "0", - "userBorrowBalanceTokens": "0", - "userPercentOfLimit": 0, - "userSupplyBalanceCents": "0", - "userSupplyBalanceTokens": "0", - "userWalletBalanceCents": "0", - "userWalletBalanceTokens": "0", - "vToken": { - "address": "0x3AF2bE7AbEF0f840b196D99d79F4B803a5dB14a1", - "decimals": 8, - "symbol": "vUSDT", - "underlyingToken": { - "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", - "asset": "/src/libs/tokens/img/usdt.svg", - "decimals": 6, - "symbol": "USDT", - }, - }, - }, - ], - "comptrollerAddress": "0x92e8E3C202093A495e98C10f9fcaa5Abe288F74A", - "description": "", - "isIsolated": true, - "name": "Meme", - "userBorrowBalanceCents": "0", - "userBorrowLimitCents": "0", - "userSupplyBalanceCents": "0", - }, - { - "assets": [ - { - "borrowApyPercentage": "16.19201615588166", - "borrowBalanceCents": "1030091.4588649133175062", - "borrowBalanceTokens": "10300.914588649133175062", - "borrowCapTokens": "200000", - "borrowDistributions": [], - "borrowerCount": 20, - "cashTokens": "32569.640339677929523638", - "collateralFactor": 0.65, - "disabledTokenActions": [], - "exchangeRateVTokens": "0.9930076443898276885", - "isCollateralOfUser": false, - "liquidityCents": "3256964.0339677929523638", - "reserveFactor": 0.2, - "reserveTokens": "0.000166728600388574", - "supplierCount": 10, - "supplyApyPercentage": "2.927280991598047", - "supplyBalanceCents": "4287055.476159846231009819", - "supplyBalanceTokens": "42870.55476159846231009819", - "supplyCapTokens": "500000", - "supplyDistributions": [], - "tokenPriceCents": "100", - "userBorrowBalanceCents": "0", - "userBorrowBalanceTokens": "0", - "userPercentOfLimit": 0, - "userSupplyBalanceCents": "0", - "userSupplyBalanceTokens": "0", - "userWalletBalanceCents": "0", - "userWalletBalanceTokens": "0", - "vToken": { - "address": "0x170d3b2da05cc2124334240fB34ad1359e34C562", - "decimals": 8, - "symbol": "vlisUSD", - "underlyingToken": { - "address": "0xe73774DfCD551BF75650772dC2cC56a2B6323453", - "asset": "/src/libs/tokens/img/lisUSD.png", - "decimals": 18, - "symbol": "lisUSD", - }, - }, - }, - { - "borrowApyPercentage": "6.209821106979763", - "borrowBalanceCents": "100461.088822525373", - "borrowBalanceTokens": "1004.648231", - "borrowCapTokens": "400000", - "borrowDistributions": [ - { - "apyPercentage": "0", - "dailyDistributedTokens": "0", - "token": { - "address": "0xe73774DfCD551BF75650772dC2cC56a2B6323453", - "asset": "/src/libs/tokens/img/lisUSD.png", - "decimals": 18, - "symbol": "lisUSD", - }, - "type": "rewardDistributor", - }, - ], - "borrowerCount": 20, - "cashTokens": "998174.53518", - "collateralFactor": 0.8, - "disabledTokenActions": [], - "exchangeRateVTokens": "0.99998934225265418908", - "isCollateralOfUser": false, - "liquidityCents": "99813743.30325273594", - "reserveFactor": 0.1, - "reserveTokens": "0.000002", - "supplierCount": 10, - "supplyApyPercentage": "0.00545245142431483", - "supplyBalanceCents": "99914204.39187526542630629377313097", - "supplyBalanceTokens": "999179.18340899996679182859", - "supplyCapTokens": "1000000", - "supplyDistributions": [ - { - "apyPercentage": "0", - "dailyDistributedTokens": "0", - "token": { - "address": "0xe73774DfCD551BF75650772dC2cC56a2B6323453", - "asset": "/src/libs/tokens/img/lisUSD.png", - "decimals": 18, - "symbol": "lisUSD", - }, - "type": "rewardDistributor", - }, - ], - "tokenPriceCents": "99.996283", - "userBorrowBalanceCents": "0", - "userBorrowBalanceTokens": "0", - "userPercentOfLimit": 0, - "userSupplyBalanceCents": "0", - "userSupplyBalanceTokens": "0", - "userWalletBalanceCents": "0", - "userWalletBalanceTokens": "0", - "vToken": { - "address": "0x3338988d0beb4419Acb8fE624218754053362D06", - "decimals": 8, - "symbol": "vUSDT", - "underlyingToken": { - "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", - "asset": "/src/libs/tokens/img/usdt.svg", - "decimals": 6, - "symbol": "USDT", - }, - }, - }, - ], - "comptrollerAddress": "0x10b57706AD2345e590c2eA4DC02faef0d9f5b08B", - "description": "", - "isIsolated": true, - "name": "Stablecoins", - "userBorrowBalanceCents": "0", - "userBorrowLimitCents": "0", - "userSupplyBalanceCents": "0", - }, - { - "assets": [ - { - "borrowApyPercentage": "9.416214491141229", - "borrowBalanceCents": "0", - "borrowBalanceTokens": "0", - "borrowCapTokens": "14880000", - "borrowDistributions": [], - "borrowerCount": 20, - "cashTokens": "10000", - "collateralFactor": 0.8, - "disabledTokenActions": [], - "exchangeRateVTokens": "1", - "isCollateralOfUser": false, - "liquidityCents": "999962.83", - "reserveFactor": 0.1, - "reserveTokens": "0", - "supplierCount": 10, - "supplyApyPercentage": "0", - "supplyBalanceCents": "999962.83", - "supplyBalanceTokens": "10000", - "supplyCapTokens": "18600000", - "supplyDistributions": [], - "tokenPriceCents": "99.996283", - "userBorrowBalanceCents": "0", - "userBorrowBalanceTokens": "0", - "userPercentOfLimit": 0, - "userSupplyBalanceCents": "0", - "userSupplyBalanceTokens": "0", - "userWalletBalanceCents": "0", - "userWalletBalanceTokens": "0", - "vToken": { - "address": "0x712774CBFFCBD60e9825871CcEFF2F917442b2c3", - "decimals": 8, - "symbol": "vUSDT", - "underlyingToken": { - "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", - "asset": "/src/libs/tokens/img/usdt.svg", - "decimals": 6, - "symbol": "USDT", - }, - }, - }, - ], - "comptrollerAddress": "0x11537D023f489E4EF0C7157cc729C7B69CbE0c97", - "description": "", - "isIsolated": true, - "name": "Tron", - "userBorrowBalanceCents": "0", - "userBorrowLimitCents": "0", - "userSupplyBalanceCents": "0", - }, - ], -} -`; diff --git a/apps/evm/src/clients/api/queries/getIsolatedPools/__tests__/index.spec.ts b/apps/evm/src/clients/api/queries/getIsolatedPools/__tests__/index.spec.ts deleted file mode 100644 index 00b89a070e..0000000000 --- a/apps/evm/src/clients/api/queries/getIsolatedPools/__tests__/index.spec.ts +++ /dev/null @@ -1,63 +0,0 @@ -import type Vi from 'vitest'; - -import fakeProvider from '__mocks__/models/provider'; -import tokens, { xvs } from '__mocks__/models/tokens'; - -import { getIsolatedPoolParticipantsCount } from 'clients/subgraph'; -import { getIsolatedPoolComptrollerContract, getRewardsDistributorContract } from 'libs/contracts'; -import { ChainId } from 'types'; - -import { apiPoolsData } from '__mocks__/models/pools'; -import getIsolatedPools from '..'; -import { - fakeIsolatedPoolComptrollerContract, - fakeIsolatedPoolParticipantsCount, - fakePoolLensContract, - fakeRewardsDistributorContract, -} from '../__testUtils__/fakeData'; - -vi.mock('hooks/useGetChainMetadata'); -vi.mock('libs/contracts'); - -describe('getIsolatedPools', () => { - beforeEach(() => { - (getIsolatedPoolComptrollerContract as Vi.Mock).mockImplementation( - () => fakeIsolatedPoolComptrollerContract, - ); - - (getRewardsDistributorContract as Vi.Mock).mockImplementation( - () => fakeRewardsDistributorContract, - ); - - (getIsolatedPoolParticipantsCount as Vi.Mock).mockImplementation( - () => fakeIsolatedPoolParticipantsCount, - ); - }); - - it('returns isolated pools with block based reward rates in the correct format', async () => { - const response = await getIsolatedPools({ - chainId: ChainId.BSC_TESTNET, - xvs, - blocksPerDay: 28800, - tokens, - provider: fakeProvider, - poolLensContract: fakePoolLensContract, - isolatedPoolsData: { pools: apiPoolsData.filter(p => p.isIsolated) }, - }); - - expect(response).toMatchSnapshot(); - }); - - it('returns isolated pools with time based reward rates in the correct format', async () => { - const response = await getIsolatedPools({ - chainId: ChainId.BSC_TESTNET, - xvs, - tokens, - provider: fakeProvider, - poolLensContract: fakePoolLensContract, - isolatedPoolsData: { pools: apiPoolsData.filter(p => p.isIsolated) }, - }); - - expect(response).toMatchSnapshot(); - }); -}); diff --git a/apps/evm/src/clients/api/queries/getIsolatedPools/__tests__/indexPrime.spec.ts b/apps/evm/src/clients/api/queries/getIsolatedPools/__tests__/indexPrime.spec.ts deleted file mode 100644 index b7fed7acad..0000000000 --- a/apps/evm/src/clients/api/queries/getIsolatedPools/__tests__/indexPrime.spec.ts +++ /dev/null @@ -1,123 +0,0 @@ -import { BigNumber as BN } from 'ethers'; -import type Vi from 'vitest'; - -import fakePrimeContractResponses from '__mocks__/contracts/prime'; -import fakeAccountAddress from '__mocks__/models/address'; -import fakeProvider from '__mocks__/models/provider'; -import tokens, { xvs } from '__mocks__/models/tokens'; - -import { getIsolatedPoolParticipantsCount } from 'clients/subgraph'; -import { type UseIsFeatureEnabled, useIsFeatureEnabled } from 'hooks/useIsFeatureEnabled'; -import { - type Prime, - getIsolatedPoolComptrollerContract, - getRewardsDistributorContract, -} from 'libs/contracts'; -import { ChainId } from 'types'; - -import { apiPoolsData } from '__mocks__/models/pools'; -import getIsolatedPools from '..'; -import { - fakeIsolatedPoolComptrollerContract, - fakeIsolatedPoolParticipantsCount, - fakePoolLensContract, - fakeRewardsDistributorContract, -} from '../__testUtils__/fakeData'; - -vi.mock('libs/contracts'); - -const fakePrimeContract = { - tokens: async () => fakePrimeContractResponses.tokens, - MINIMUM_STAKED_XVS: async () => fakePrimeContractResponses.MINIMUM_STAKED_XVS, - getAllMarkets: async () => fakePrimeContractResponses.getAllMarkets, - estimateAPR: async () => fakePrimeContractResponses.estimateAPR, - calculateAPR: async () => fakePrimeContractResponses.calculateAPR, -} as unknown as Prime; - -describe('getIsolatedPools - Feature enabled: Prime', () => { - beforeEach(() => { - (useIsFeatureEnabled as Vi.Mock).mockImplementation( - ({ name }: UseIsFeatureEnabled) => name === 'prime', - ); - - (getIsolatedPoolComptrollerContract as Vi.Mock).mockImplementation( - () => fakeIsolatedPoolComptrollerContract, - ); - - (getRewardsDistributorContract as Vi.Mock).mockImplementation( - () => fakeRewardsDistributorContract, - ); - - (getIsolatedPoolParticipantsCount as Vi.Mock).mockImplementation( - () => fakeIsolatedPoolParticipantsCount, - ); - }); - - it('fetches and formats Prime distributions and Prime distribution simulations if user is Prime', async () => { - const response = await getIsolatedPools({ - chainId: ChainId.BSC_TESTNET, - xvs, - blocksPerDay: 28800, - tokens, - accountAddress: fakeAccountAddress, - provider: fakeProvider, - poolLensContract: fakePoolLensContract, - primeContract: fakePrimeContract, - isolatedPoolsData: { pools: apiPoolsData.filter(pool => pool.isIsolated) }, - }); - - expect(response).toMatchSnapshot(); - }); - - it('does not fetch Prime distributions if user is not Prime', async () => { - const customFakePrimeContract = { - ...fakePrimeContract, - tokens: async () => ({ - ...fakePrimeContractResponses.tokens, - exists: false, - }), - } as unknown as Prime; - - const response = await getIsolatedPools({ - chainId: ChainId.BSC_TESTNET, - xvs, - blocksPerDay: 28800, - tokens, - accountAddress: fakeAccountAddress, - provider: fakeProvider, - poolLensContract: fakePoolLensContract, - primeContract: customFakePrimeContract, - isolatedPoolsData: { pools: apiPoolsData.filter(pool => pool.isIsolated) }, - }); - - expect(response).toMatchSnapshot(); - }); - - it('filters out Prime distributions and simulations that are 0', async () => { - const customFakePrimeContract = { - ...fakePrimeContract, - estimateAPR: async () => ({ - borrowAPR: BN.from(0), - supplyAPR: BN.from(0), - }), - calculateAPR: async () => ({ - borrowAPR: BN.from(0), - supplyAPR: BN.from(0), - }), - } as unknown as Prime; - - const response = await getIsolatedPools({ - chainId: ChainId.BSC_TESTNET, - xvs, - blocksPerDay: 28800, - tokens, - accountAddress: fakeAccountAddress, - provider: fakeProvider, - poolLensContract: fakePoolLensContract, - primeContract: customFakePrimeContract, - isolatedPoolsData: { pools: apiPoolsData.filter(pool => pool.isIsolated) }, - }); - - expect(response).toMatchSnapshot(); - }); -}); diff --git a/apps/evm/src/clients/api/queries/getIsolatedPools/formatOutput/index.ts b/apps/evm/src/clients/api/queries/getIsolatedPools/formatOutput/index.ts deleted file mode 100644 index 1fb545ba0b..0000000000 --- a/apps/evm/src/clients/api/queries/getIsolatedPools/formatOutput/index.ts +++ /dev/null @@ -1,291 +0,0 @@ -import BigNumber from 'bignumber.js'; - -import type { getIsolatedPoolParticipantsCount } from 'clients/subgraph'; -import { COMPOUND_DECIMALS } from 'constants/compoundMantissa'; -import type { PoolLens } from 'libs/contracts'; -import type { Asset, ChainId, Pool, PrimeApy, Token, VToken } from 'types'; -import addUserPropsToPool from 'utilities/addUserPropsToPool'; -import areAddressesEqual from 'utilities/areAddressesEqual'; -import areTokensEqual from 'utilities/areTokensEqual'; -import { calculateDailyTokenRate } from 'utilities/calculateDailyTokenRate'; -import { calculateYearlyPercentageRate } from 'utilities/calculateYearlyPercentageRate'; -import convertDollarsToCents from 'utilities/convertDollarsToCents'; -import convertFactorFromSmartContract from 'utilities/convertFactorFromSmartContract'; -import convertMantissaToTokens from 'utilities/convertMantissaToTokens'; -import findTokenByAddress from 'utilities/findTokenByAddress'; -import { getDisabledTokenActions } from 'utilities/getDisabledTokenActions'; - -import type { GetApiPoolsOutput } from '../../getApiPools'; -import type { GetTokenBalancesOutput } from '../../getTokenBalances'; -import type { GetRewardsDistributorSettingsMappingOutput } from '../getRewardsDistributorSettingsMapping'; -import type { GetTokenPriceDollarsMappingOutput } from '../getTokenPriceDollarsMapping'; -import formatDistributions from './formatDistributions'; - -export interface FormatToPoolsInput { - chainId: ChainId; - tokens: Token[]; - currentBlockNumber: number; - pools: GetApiPoolsOutput['pools']; - rewardsDistributorSettingsMapping: GetRewardsDistributorSettingsMappingOutput; - tokenPriceDollarsMapping: GetTokenPriceDollarsMappingOutput; - primeApyMap: Map; - userCollateralizedVTokenAddresses: string[]; - blocksPerDay?: number; - poolParticipantsCountResult?: Awaited>; - userVTokenBalancesAll?: Awaited>; - userTokenBalancesAll?: GetTokenBalancesOutput; -} - -const formatToPools = ({ - chainId, - tokens, - blocksPerDay, - currentBlockNumber, - pools, - rewardsDistributorSettingsMapping, - tokenPriceDollarsMapping, - poolParticipantsCountResult, - userCollateralizedVTokenAddresses, - primeApyMap, - userVTokenBalancesAll, - userTokenBalancesAll, -}: FormatToPoolsInput) => { - const formattedPools: Pool[] = pools.map(p => { - const subgraphPool = poolParticipantsCountResult?.pools.find(pool => - areAddressesEqual(pool.id, p.address), - ); - - const assets = p.markets.reduce((acc, market) => { - // Remove unlisted tokens - if (!market.isListed) { - return acc; - } - - const { underlyingTokenAddress } = market; - - // Retrieve underlying token record - const underlyingToken = findTokenByAddress({ - tokens, - address: underlyingTokenAddress, - }); - - if (!underlyingToken) { - return acc; - } - - const tokenPriceDollars = tokenPriceDollarsMapping[underlyingToken.address.toLowerCase()]; - - if (!tokenPriceDollars) { - return acc; - } - - // Shape vToken - const vToken: VToken = { - address: market.vTokenAddress, - decimals: 8, - symbol: `v${underlyingToken.symbol}`, - underlyingToken, - }; - - const userVTokenBalances = userVTokenBalancesAll?.find(userBalances => - areAddressesEqual(userBalances.vToken, vToken.address), - ); - - // Extract supplierCount and borrowerCount from subgraph result - const subgraphPoolMarket = subgraphPool?.markets.find(market => - areAddressesEqual(market.id, vToken.address), - ); - const supplierCount = +(subgraphPoolMarket?.supplierCount || 0); - const borrowerCount = +(subgraphPoolMarket?.borrowerCount || 0); - - const borrowCapTokens = convertMantissaToTokens({ - value: market.borrowCapsMantissa, - token: vToken.underlyingToken, - }); - - const supplyCapTokens = convertMantissaToTokens({ - value: market.supplyCapsMantissa, - token: vToken.underlyingToken, - }); - - const reserveFactor = convertFactorFromSmartContract({ - factor: market.reserveFactorMantissa, - }); - - const collateralFactor = convertFactorFromSmartContract({ - factor: market.collateralFactorMantissa, - }); - - const cashTokens = convertMantissaToTokens({ - value: market.cashMantissa, - token: vToken.underlyingToken, - }); - - const tokenPriceCents = convertDollarsToCents(tokenPriceDollars); - const liquidityCents = cashTokens.multipliedBy(tokenPriceCents); - - const reserveTokens = convertMantissaToTokens({ - value: market.totalReservesMantissa, - token: vToken.underlyingToken, - }); - - const exchangeRateVTokens = new BigNumber(1).div( - market.exchangeRateMantissa.div( - 10 ** (COMPOUND_DECIMALS + vToken.underlyingToken.decimals - vToken.decimals), - ), - ); - - const supplyDailyPercentageRate = calculateDailyTokenRate({ - rateMantissa: market.supplyRatePerBlockOrTimestamp, - blocksPerDay, - }); - - const supplyApyPercentage = calculateYearlyPercentageRate({ - dailyPercentageRate: supplyDailyPercentageRate, - }); - - const borrowDailyPercentageRate = calculateDailyTokenRate({ - rateMantissa: market.borrowRatePerBlockOrTimestamp, - blocksPerDay, - }); - - const borrowApyPercentage = calculateYearlyPercentageRate({ - dailyPercentageRate: borrowDailyPercentageRate, - }); - - const supplyBalanceVTokens = convertMantissaToTokens({ - value: market.totalSupplyMantissa, - token: vToken, - }); - const supplyBalanceTokens = supplyBalanceVTokens.div(exchangeRateVTokens); - const supplyBalanceCents = supplyBalanceTokens.multipliedBy(tokenPriceCents); - - const borrowBalanceTokens = convertMantissaToTokens({ - value: market.totalBorrowsMantissa, - token: vToken.underlyingToken, - }); - - const borrowBalanceCents = borrowBalanceTokens.multipliedBy(tokenPriceCents); - - // User-specific props - const userBorrowBalanceTokens = userVTokenBalances - ? convertMantissaToTokens({ - value: new BigNumber(userVTokenBalances.borrowBalanceCurrent.toString()), - token: vToken.underlyingToken, - }) - : new BigNumber(0); - - const userSupplyBalanceTokens = userVTokenBalances - ? convertMantissaToTokens({ - value: new BigNumber(userVTokenBalances.balanceOfUnderlying.toString()), - token: vToken.underlyingToken, - }) - : new BigNumber(0); - - const tokenBalanceRes = userTokenBalancesAll?.tokenBalances.find(tokenBalance => - areTokensEqual(tokenBalance.token, vToken.underlyingToken), - ); - - const userWalletBalanceTokens = tokenBalanceRes - ? convertMantissaToTokens({ - value: tokenBalanceRes.balanceMantissa, - token: tokenBalanceRes.token, - }) - : new BigNumber(0); - - const userSupplyBalanceCents = userSupplyBalanceTokens.multipliedBy(tokenPriceCents); - const userBorrowBalanceCents = userBorrowBalanceTokens.multipliedBy(tokenPriceCents); - const userWalletBalanceCents = userWalletBalanceTokens.multipliedBy(tokenPriceCents); - - const isCollateralOfUser = !!userCollateralizedVTokenAddresses.some(address => - areAddressesEqual(address, vToken.address), - ); - - const { supplyDistributions, borrowDistributions } = formatDistributions({ - blocksPerDay, - underlyingToken, - underlyingTokenPriceDollars: tokenPriceDollars, - tokens, - tokenPriceDollarsMapping, - supplyBalanceTokens, - borrowBalanceTokens, - currentBlockNumber, - rewardsDistributorSettings: - rewardsDistributorSettingsMapping[vToken.address.toLowerCase()] || [], - primeApy: primeApyMap.get(vToken.address), - }); - - const disabledTokenActions = getDisabledTokenActions({ - bitmask: market.pausedActionsBitmap, - tokenAddresses: [vToken.address, vToken.underlyingToken.address], - chainId, - }); - - const asset: Asset = { - vToken, - disabledTokenActions, - tokenPriceCents, - reserveFactor, - collateralFactor, - cashTokens, - liquidityCents, - reserveTokens, - exchangeRateVTokens, - supplierCount, - borrowerCount, - borrowApyPercentage, - supplyApyPercentage, - supplyBalanceTokens, - supplyBalanceCents, - borrowBalanceTokens, - borrowBalanceCents, - borrowCapTokens, - supplyCapTokens, - supplyDistributions, - borrowDistributions, - userSupplyBalanceTokens, - userSupplyBalanceCents, - userBorrowBalanceTokens, - userBorrowBalanceCents, - userWalletBalanceTokens, - userWalletBalanceCents, - // This will be calculated after all assets have been formatted - userPercentOfLimit: 0, - isCollateralOfUser, - }; - - return [...acc, asset]; - }, []); - - const pool: Pool = addUserPropsToPool({ - name: p.name, - description: p.description, - comptrollerAddress: p.address, - isIsolated: true, - assets, - }); - - // Calculate userPercentOfLimit for each asset - const formattedAssets: Asset[] = assets.map(asset => ({ - ...asset, - userPercentOfLimit: - asset.userBorrowBalanceCents?.isGreaterThan(0) && - pool.userBorrowLimitCents?.isGreaterThan(0) - ? new BigNumber(asset.userBorrowBalanceCents) - .times(100) - .div(pool.userBorrowLimitCents) - .dp(2) - .toNumber() - : 0, - })); - - return { - ...pool, - assets: formattedAssets, - }; - }); - - return formattedPools; -}; - -export default formatToPools; diff --git a/apps/evm/src/clients/api/queries/getIsolatedPools/getRewardsDistributorSettingsMapping.ts b/apps/evm/src/clients/api/queries/getIsolatedPools/getRewardsDistributorSettingsMapping.ts deleted file mode 100644 index 475921ef25..0000000000 --- a/apps/evm/src/clients/api/queries/getIsolatedPools/getRewardsDistributorSettingsMapping.ts +++ /dev/null @@ -1,75 +0,0 @@ -import type BigNumber from 'bignumber.js'; -import type { RewardsDistributor } from 'libs/contracts'; -import type { Market } from 'types'; -import type { GetApiPoolsOutput } from '../getApiPools'; - -type RewardTokenBorrowStatePromise = - | ReturnType - | ReturnType; - -type RewardTokenSupplyStatePromise = - | ReturnType - | ReturnType; - -export interface RewardsDistributorSettingsPromise { - vTokenAddress: string; - rewardsDistributorAddress: string; - promises: [ - ReturnType, - ReturnType, - ReturnType, - RewardTokenSupplyStatePromise, - RewardTokenBorrowStatePromise, - ]; -} - -export type RewardsDistributorSettingsResult = { - rewardsDistributorAddress: string; - rewardTokenAddress: string; - rewardTokenSupplySpeeds: BigNumber; - rewardTokenBorrowSpeeds: BigNumber; - rewardTokenLastRewardingSupplyBlockOrTimestamp: BigNumber; - rewardTokenLastRewardingBorrowBlockOrTimestamp: BigNumber; - rewardTokenPriceMantissa: BigNumber; -}; - -export interface GetRewardsDistributorSettingsMappingInput { - pools: GetApiPoolsOutput['pools']; -} - -export interface GetRewardsDistributorSettingsMappingOutput { - [vTokenAddress: string]: RewardsDistributorSettingsResult[]; -} - -const getRewardsDistributorSettingsMapping = async ({ - pools, -}: GetRewardsDistributorSettingsMappingInput) => { - const allIsolatedMarkets = pools.reduce((acc, pool) => acc.concat(...pool.markets), []); - - return allIsolatedMarkets.reduce((acc, market) => { - const vTokenAddress = market.vTokenAddress.toLowerCase(); - - if (!acc[vTokenAddress]) { - acc[vTokenAddress] = []; - } - - market.rewardsDistributors.forEach(rd => { - const settings: RewardsDistributorSettingsResult = { - rewardsDistributorAddress: rd.rewardsDistributorContractAddress, - rewardTokenAddress: rd.rewardTokenAddress, - rewardTokenSupplySpeeds: rd.supplySpeed, - rewardTokenBorrowSpeeds: rd.borrowSpeed, - rewardTokenLastRewardingSupplyBlockOrTimestamp: rd.lastRewardingSupplyBlockOrTimestamp, - rewardTokenLastRewardingBorrowBlockOrTimestamp: rd.lastRewardingBorrowBlockOrTimestamp, - rewardTokenPriceMantissa: rd.priceMantissa, - }; - acc[vTokenAddress] = acc[vTokenAddress].concat(settings); - }); - - return { - ...acc, - }; - }, {}); -}; - -export default getRewardsDistributorSettingsMapping; diff --git a/apps/evm/src/clients/api/queries/getIsolatedPools/getTokenPriceDollarsMapping.ts b/apps/evm/src/clients/api/queries/getIsolatedPools/getTokenPriceDollarsMapping.ts deleted file mode 100644 index 4d46298a12..0000000000 --- a/apps/evm/src/clients/api/queries/getIsolatedPools/getTokenPriceDollarsMapping.ts +++ /dev/null @@ -1,87 +0,0 @@ -import type BigNumber from 'bignumber.js'; - -import convertPriceMantissaToDollars from 'utilities/convertPriceMantissaToDollars'; -import findTokenByAddress from 'utilities/findTokenByAddress'; - -import type { Market, Token } from 'types'; -import type { GetApiPoolsOutput } from '../getApiPools'; -import type { - GetRewardsDistributorSettingsMappingOutput, - RewardsDistributorSettingsResult, -} from './getRewardsDistributorSettingsMapping'; - -export interface GetTokenPriceDollarsMappingInput { - tokens: Token[]; - pools: GetApiPoolsOutput['pools']; - rewardsDistributorSettingsMapping: GetRewardsDistributorSettingsMappingOutput; -} - -export interface GetTokenPriceDollarsMappingOutput { - [tokenAddress: string]: BigNumber; -} - -const getTokenPriceDollarsMapping = async ({ - tokens, - pools, - rewardsDistributorSettingsMapping, -}: GetTokenPriceDollarsMappingInput) => { - // Get all underlying tokens and their prices - const allMarkets = pools.reduce((acc, pool) => acc.concat(pool.markets), []); - - const underlyingTokenPrices = allMarkets.reduce( - (acc, market) => { - return { - ...acc, - [market.underlyingTokenAddress.toLowerCase()]: market.underlyingTokenPriceMantissa, - }; - }, - {}, - ); - - // Get price data for all reward tokens - const allRewardsDistributorSettings = Object.values(rewardsDistributorSettingsMapping).reduce< - RewardsDistributorSettingsResult[] - >((acc, rewardsDistributorSettings) => acc.concat(rewardsDistributorSettings), []); - const rewardTokensPriceData = - allRewardsDistributorSettings.reduce( - (acc, rewardsDistributorSetting) => { - return { - ...acc, - [rewardsDistributorSetting.rewardTokenAddress.toLowerCase()]: - rewardsDistributorSetting.rewardTokenPriceMantissa, - }; - }, - {}, - ); - - const allTokensPriceData = Object.keys(rewardTokensPriceData).reduce( - (acc, rewardTokenAddress) => ({ - ...acc, - [rewardTokenAddress]: rewardTokensPriceData[rewardTokenAddress], - }), - underlyingTokenPrices, - ); - - return Object.keys(allTokensPriceData).reduce((acc, tokenAddress) => { - const token = findTokenByAddress({ - tokens, - address: tokenAddress, - }); - - if (!token) { - return acc; - } - - const tokenPriceDollars = convertPriceMantissaToDollars({ - priceMantissa: allTokensPriceData[tokenAddress], - decimals: token.decimals, - }); - - return { - ...acc, - [token.address.toLowerCase()]: tokenPriceDollars, - }; - }, {}); -}; - -export default getTokenPriceDollarsMapping; diff --git a/apps/evm/src/clients/api/queries/getIsolatedPools/index.ts b/apps/evm/src/clients/api/queries/getIsolatedPools/index.ts deleted file mode 100644 index b4df5432ca..0000000000 --- a/apps/evm/src/clients/api/queries/getIsolatedPools/index.ts +++ /dev/null @@ -1,249 +0,0 @@ -import BigNumber from 'bignumber.js'; - -import { getBlockNumber, getTokenBalances } from 'clients/api'; -import { - type GetIsolatedPoolParticipantsCountInput, - getIsolatedPoolParticipantsCount, -} from 'clients/subgraph'; -import { type IsolatedPoolComptroller, getIsolatedPoolComptrollerContract } from 'libs/contracts'; -import { logError } from 'libs/errors'; -import type { Asset, PrimeApy, Token } from 'types'; -import { - appendPrimeSimulationDistributions, - areTokensEqual, - convertAprBipsToApy, - findTokenByAddress, -} from 'utilities'; -import extractSettledPromiseValue from 'utilities/extractSettledPromiseValue'; -import removeDuplicates from 'utilities/removeDuplicates'; -import formatOutput from './formatOutput'; -import getRewardsDistributorSettingsMapping from './getRewardsDistributorSettingsMapping'; -import getTokenPriceDollarsMapping from './getTokenPriceDollarsMapping'; -import type { GetIsolatedPoolsInput, GetIsolatedPoolsOutput } from './types'; - -export type { GetIsolatedPoolsInput, GetIsolatedPoolsOutput } from './types'; - -// Since the borrower and supplier counts aren't essential information, we make the logic so the -// dApp can still function if the subgraph is down -const safelyGetIsolatedPoolParticipantsCount = async ({ - chainId, -}: GetIsolatedPoolParticipantsCountInput) => { - try { - const res = await getIsolatedPoolParticipantsCount({ chainId }); - return res; - } catch (error) { - logError(error); - } -}; - -const getIsolatedPools = async ({ - isolatedPoolsData, - chainId, - xvs, - blocksPerDay, - accountAddress, - poolLensContract, - primeContract, - provider, - tokens, -}: GetIsolatedPoolsInput): Promise => { - const [ - poolParticipantsCountResult, - currentBlockNumberResult, - primeVTokenAddressesResult, - primeMinimumXvsToStakeResult, - userPrimeTokenResult, - ] = await Promise.allSettled([ - // Fetch borrower and supplier counts of each isolated token - safelyGetIsolatedPoolParticipantsCount({ chainId }), - // Fetch current block number - getBlockNumber({ provider }), - // Prime related calls - primeContract?.getAllMarkets(), - primeContract?.MINIMUM_STAKED_XVS(), - accountAddress ? primeContract?.tokens(accountAddress) : undefined, - ]); - - if (poolParticipantsCountResult.status === 'rejected') { - throw new Error(poolParticipantsCountResult.reason); - } - - if (currentBlockNumberResult.status === 'rejected') { - throw new Error(currentBlockNumberResult.reason); - } - - const { pools: isolatedPools } = isolatedPoolsData; - - // Extract token records and addresses - const [vTokenAddresses, underlyingTokens] = isolatedPools.reduce<[string[], Token[]]>( - (acc, poolResult) => { - const newVTokenAddresses: string[] = []; - const newUnderlyingTokens: Token[] = []; - const newUnderlyingTokenAddresses: string[] = []; - - poolResult.markets.forEach(market => { - const underlyingToken = findTokenByAddress({ - address: market.underlyingTokenAddress, - tokens, - }); - - if (!underlyingToken) { - return; - } - - if (!newVTokenAddresses.includes(market.vTokenAddress)) { - newVTokenAddresses.push(market.vTokenAddress.toLowerCase()); - } - - if ( - !newUnderlyingTokens.some(listedUnderlyingToken => - areTokensEqual(listedUnderlyingToken, underlyingToken), - ) - ) { - newUnderlyingTokens.push(underlyingToken); - } - - if (!newUnderlyingTokenAddresses.includes(underlyingToken.address.toLowerCase())) { - newUnderlyingTokenAddresses.push(underlyingToken.address.toLowerCase()); - } - }); - - return [acc[0].concat(newVTokenAddresses), acc[1].concat(newUnderlyingTokens)]; - }, - [[], []], - ); - - // Extract Prime data - const primeVTokenAddresses = extractSettledPromiseValue(primeVTokenAddressesResult) || []; - const primeMinimumXvsToStakeMantissa = extractSettledPromiseValue(primeMinimumXvsToStakeResult); - const isUserPrime = extractSettledPromiseValue(userPrimeTokenResult)?.exists || false; - - // Fetch addresses of user collaterals - const getAssetsInPromises: ReturnType[] = []; - - isolatedPools.forEach(p => { - const comptrollerContract = getIsolatedPoolComptrollerContract({ - signerOrProvider: provider, - address: p.address, - }); - - if (accountAddress) { - getAssetsInPromises.push(comptrollerContract.getAssetsIn(accountAddress)); - } - }); - - const settledGetAssetsInPromises = Promise.allSettled(getAssetsInPromises); - const tokenBalancesPromises = Promise.allSettled([ - accountAddress - ? poolLensContract.callStatic.vTokenBalancesAll(vTokenAddresses, accountAddress) - : undefined, - accountAddress - ? getTokenBalances({ - accountAddress, - tokens: underlyingTokens, - provider, - }) - : undefined, - ]); - - // Fetch Prime distributions - const settledPrimeAprPromises = - primeContract && isUserPrime - ? Promise.allSettled( - accountAddress - ? primeVTokenAddresses.map(primeVTokenAddress => - primeContract.calculateAPR(primeVTokenAddress, accountAddress), - ) - : [], - ) - : undefined; - - const [userVTokenBalancesAllResult, userTokenBalancesResult] = await tokenBalancesPromises; - const userAssetsInResults = await settledGetAssetsInPromises; - const primeAprResults = (await settledPrimeAprPromises) || []; - - // Log errors without throwing so that assets can still be displayed - if (userVTokenBalancesAllResult?.status === 'rejected') { - logError(userVTokenBalancesAllResult.reason); - } - - if (userTokenBalancesResult?.status === 'rejected') { - logError(userTokenBalancesResult.reason); - } - - // Get addresses of user collaterals - const userCollateralizedVTokenAddresses = removeDuplicates( - userAssetsInResults.reduce((acc, userAssetsInResult) => { - const result = extractSettledPromiseValue(userAssetsInResult); - - if (!result) { - return acc; - } - - return acc.concat(result); - }, []), - ); - - // Get Prime APYs - const primeApyMap = new Map(); - primeAprResults.forEach((primeAprResult, index) => { - if (primeAprResult.status !== 'fulfilled') { - return; - } - - const primeApr = primeAprResult.value; - - const apys: PrimeApy = { - borrowApy: convertAprBipsToApy({ aprBips: primeApr?.borrowAPR.toString() || '0' }), - supplyApy: convertAprBipsToApy({ aprBips: primeApr?.supplyAPR.toString() || '0' }), - }; - - primeApyMap.set(primeVTokenAddresses[index], apys); - }); - - // Fetch reward settings - const rewardsDistributorSettingsMapping = await getRewardsDistributorSettingsMapping({ - pools: isolatedPools, - }); - - // Fetch token prices - const tokenPriceDollarsMapping = await getTokenPriceDollarsMapping({ - tokens, - pools: isolatedPoolsData.pools, - rewardsDistributorSettingsMapping, - }); - - const pools = formatOutput({ - chainId, - blocksPerDay, - tokens, - currentBlockNumber: currentBlockNumberResult.value.blockNumber, - pools: isolatedPools, - poolParticipantsCountResult: poolParticipantsCountResult.value, - rewardsDistributorSettingsMapping, - tokenPriceDollarsMapping, - userCollateralizedVTokenAddresses, - userVTokenBalancesAll: extractSettledPromiseValue(userVTokenBalancesAllResult), - userTokenBalancesAll: extractSettledPromiseValue(userTokenBalancesResult), - primeApyMap, - }); - - // Fetch Prime simulations and add them to distributions - if (primeContract && primeMinimumXvsToStakeMantissa) { - await appendPrimeSimulationDistributions({ - assets: pools.reduce((acc, pool) => acc.concat(pool.assets), []), - primeContract, - primeVTokenAddresses, - accountAddress, - primeMinimumXvsToStakeMantissa: new BigNumber(primeMinimumXvsToStakeMantissa.toString()), - xvs, - chainId, - }); - } - - return { - pools, - }; -}; - -export default getIsolatedPools; diff --git a/apps/evm/src/clients/api/queries/getIsolatedPools/types.ts b/apps/evm/src/clients/api/queries/getIsolatedPools/types.ts deleted file mode 100644 index d53c70725b..0000000000 --- a/apps/evm/src/clients/api/queries/getIsolatedPools/types.ts +++ /dev/null @@ -1,20 +0,0 @@ -import type { PoolLens, Prime } from 'libs/contracts'; -import type { Provider } from 'libs/wallet'; -import type { ChainId, Pool, Token } from 'types'; -import type { GetApiPoolsOutput } from '../getApiPools'; - -export interface GetIsolatedPoolsInput { - chainId: ChainId; - xvs: Token; - tokens: Token[]; - provider: Provider; - poolLensContract: PoolLens; - blocksPerDay?: number; - primeContract?: Prime; - accountAddress?: string; - isolatedPoolsData: GetApiPoolsOutput; -} - -export interface GetIsolatedPoolsOutput { - pools: Pool[]; -} diff --git a/apps/evm/src/clients/api/queries/getIsolatedPools/useGetIsolatedPools.ts b/apps/evm/src/clients/api/queries/getIsolatedPools/useGetIsolatedPools.ts deleted file mode 100644 index 7d962f7375..0000000000 --- a/apps/evm/src/clients/api/queries/getIsolatedPools/useGetIsolatedPools.ts +++ /dev/null @@ -1,101 +0,0 @@ -import { type QueryObserverOptions, useQuery } from '@tanstack/react-query'; - -import { useGetApiPools } from 'clients/api'; -import getIsolatedPools, { - type GetIsolatedPoolsInput, - type GetIsolatedPoolsOutput, -} from 'clients/api/queries/getIsolatedPools'; -import FunctionKey from 'constants/functionKey'; -import { useGetChainMetadata } from 'hooks/useGetChainMetadata'; -import { useIsFeatureEnabled } from 'hooks/useIsFeatureEnabled'; -import { - useGetPoolLensContract, - useGetPoolRegistryContractAddress, - useGetPrimeContract, -} from 'libs/contracts'; -import { useGetToken, useGetTokens } from 'libs/tokens'; -import { useChainId, useProvider } from 'libs/wallet'; -import type { ChainId } from 'types'; -import { callOrThrow, generatePseudoRandomRefetchInterval } from 'utilities'; - -type TrimmedInput = Omit< - GetIsolatedPoolsInput, - | 'chainId' - | 'xvs' - | 'blocksPerDay' - | 'provider' - | 'primeContract' - | 'poolLensContract' - | 'vTreasuryContractAddress' - | 'poolRegistryContractAddress' - | 'resilientOracleContract' - | 'tokens' - | 'isolatedPoolsData' ->; - -export type UseGetIsolatedPoolsQueryKey = [ - FunctionKey.GET_ISOLATED_POOLS, - TrimmedInput & { - chainId: ChainId; - }, -]; - -type Options = QueryObserverOptions< - GetIsolatedPoolsOutput, - Error, - GetIsolatedPoolsOutput, - GetIsolatedPoolsOutput, - UseGetIsolatedPoolsQueryKey ->; - -const refetchInterval = generatePseudoRandomRefetchInterval(); - -const useGetIsolatedPools = (input?: TrimmedInput, options?: Options) => { - const { data: apiPoolsData } = useGetApiPools(); - const { provider } = useProvider(); - const { chainId } = useChainId(); - const { blocksPerDay } = useGetChainMetadata(); - - const tokens = useGetTokens(); - const xvs = useGetToken({ symbol: 'XVS' }); - const isPrimeEnabled = useIsFeatureEnabled({ - name: 'prime', - }); - - const poolLensContract = useGetPoolLensContract(); - const primeContract = useGetPrimeContract(); - const poolRegistryContractAddress = useGetPoolRegistryContractAddress(); - - const isQueryEnabled = - apiPoolsData !== undefined && (options?.enabled === undefined || options?.enabled); - - return useQuery({ - queryKey: [FunctionKey.GET_ISOLATED_POOLS, { ...input, chainId }], - - queryFn: () => - callOrThrow( - { - chainId, - poolLensContract, - poolRegistryContractAddress, - xvs, - }, - params => - getIsolatedPools({ - isolatedPoolsData: { pools: apiPoolsData!.pools.filter(p => p.isIsolated) }, - provider, - tokens, - blocksPerDay, - primeContract: isPrimeEnabled ? primeContract : undefined, - ...input, - ...params, - }), - ), - - refetchInterval, - ...options, - enabled: isQueryEnabled, - }); -}; - -export default useGetIsolatedPools; diff --git a/apps/evm/src/clients/api/queries/getLegacyPool/__testUtils__/fakeData.ts b/apps/evm/src/clients/api/queries/getLegacyPool/__testUtils__/fakeData.ts deleted file mode 100644 index ba47d6b25f..0000000000 --- a/apps/evm/src/clients/api/queries/getLegacyPool/__testUtils__/fakeData.ts +++ /dev/null @@ -1,397 +0,0 @@ -import { BigNumber as BN } from 'ethers'; - -import fakeLegacyPoolComptrollerContractResponses from '__mocks__/contracts/legacyPoolComptroller'; -import fakeVenusLensContractResponses from '__mocks__/contracts/venusLens'; -import { altAddress } from '__mocks__/models/address'; - -import type { - LegacyPoolComptroller, - ResilientOracle, - VaiController, - VenusLens, -} from 'libs/contracts'; - -export const fakeGetXvsPriceOutput = BN.from('0x30f7dc8a6370b000'); - -export const fakeGetAssetsInOutput = [ - '0x6d6F697e34145Bb95c54E77482d97cc261Dc237E', - '0x3A00d9B02781f47d033BAd62edc55fBF8D083Fb0', - '0xb6e9322C49FD75a367Fcb17B0Fcd62C5070EbCBe', - '0x08e0A5575De71037aE36AbfAfb516595fE68e5e4', - '0x74469281310195A04840Daf6EdF576F559a3dE80', - '0x2E7222e51c0f6e98610A1543Aa3836E092CDe62c', - '0x6AF3Fdb3282c5bb6926269Db10837fa8Aec67C04', - '0xD5C4C2e2facBEB59D0216D0595d63FcDc6F9A1a7', -]; - -export const fakeGetVaiRepayAmountOutput = BN.from('0x00'); - -export const fakeGetUnderlyingPriceOutputs = { - '0xD5C4C2e2facBEB59D0216D0595d63FcDc6F9A1a7': BN.from('0x0c9f252afd4c2fb98f97000000'), - '0xb7526572FFE56AB9D7489838Bf2E18e3323b441A': BN.from('0x0c9f00c3826ac3b6fd38c00000'), - '0x08e0A5575De71037aE36AbfAfb516595fE68e5e4': BN.from('0x0ddfc1bd0c5de800'), - '0x74469281310195A04840Daf6EdF576F559a3dE80': BN.from('0x037474d7e3bfac00'), - '0x2E7222e51c0f6e98610A1543Aa3836E092CDe62c': BN.from('0x0ba44b0d5ad2004800'), - '0x6d6F697e34145Bb95c54E77482d97cc261Dc237E': BN.from('0x30f7dc8a6370b000'), - '0x162D005F0Fff510E54958Cfc5CF32A3180A84aab': BN.from('0x58e0a2138e84ee0000'), - '0xAfc13BC065ABeE838540823431055D2ea52eBA52': BN.from('0x037942fd7102be5c00'), - '0x488aB2826a154da01CC4CC16A8C83d4720D3cA2C': BN.from('0x0702b820fa7ee000'), - '0xb6e9322C49FD75a367Fcb17B0Fcd62C5070EbCBe': BN.from('0x057eeeebda8e17a00800'), - '0x37C28DE42bA3d22217995D146FC684B2326Ede64': BN.from('0x038f17ea90a62000'), - '0xF912d3001CAf6DC4ADD366A62Cc9115B4303c9A9': BN.from('0x020a0ca01fb38684f0500000'), - '0xeDaC03D29ff74b5fDc0CC936F6288312e1459BC6': BN.from('0x111d7aa92d73a800'), - '0x3619bdDc61189F33365CC572DF3a68FB3b316516': BN.from('0x078d630446c48000'), - '0x714db6c38A17883964B68a07d56cE331501d9eb6': BN.from('0x02ffb81ee6ee9c0000'), - '0x3A00d9B02781f47d033BAd62edc55fBF8D083Fb0': BN.from('0x0de0b6b3a7640000'), - '0x369Fea97f6fB7510755DCA389088d9E2e2819278': BN.from('0x0111d2d971bda800'), - '0xF206af85BC2761c4F876d27Bd474681CfB335EfA': BN.from('0x01'), - '0x9C3015191d39cF1930F92EB7e7BCbd020bCA286a': BN.from('0xe8d4a51000'), - '0x6AF3Fdb3282c5bb6926269Db10837fa8Aec67C04': BN.from('0xf90a88392965357922800000'), - '0x35566ED3AF9E537Be487C98b1811cDf95ad0C32b': BN.from('0x5a069df15cba8eec00'), - '0xEFAACF73CE2D38ED40991f29E72B12C74bd4cf23': BN.from('0x0de0b6b3a7640000'), -}; - -export const fakeBorrowCapsOutputs = { - '0xD5C4C2e2facBEB59D0216D0595d63FcDc6F9A1a7': BN.from('0x00'), - '0xb7526572FFE56AB9D7489838Bf2E18e3323b441A': BN.from('0x00'), - '0x08e0A5575De71037aE36AbfAfb516595fE68e5e4': BN.from('0x01'), - '0x74469281310195A04840Daf6EdF576F559a3dE80': BN.from('0x00'), - '0x2E7222e51c0f6e98610A1543Aa3836E092CDe62c': BN.from('0x00'), - '0x6d6F697e34145Bb95c54E77482d97cc261Dc237E': BN.from('0x392cbab546b0ccc00000'), - '0x162D005F0Fff510E54958Cfc5CF32A3180A84aab': BN.from('0x00'), - '0xAfc13BC065ABeE838540823431055D2ea52eBA52': BN.from('0x00'), - '0x488aB2826a154da01CC4CC16A8C83d4720D3cA2C': BN.from('0x00'), - '0xb6e9322C49FD75a367Fcb17B0Fcd62C5070EbCBe': BN.from('0x00'), - '0x37C28DE42bA3d22217995D146FC684B2326Ede64': BN.from('0x00'), - '0xF912d3001CAf6DC4ADD366A62Cc9115B4303c9A9': BN.from('0x00'), - '0xeDaC03D29ff74b5fDc0CC936F6288312e1459BC6': BN.from('0x0a968163f0a57b400000'), - '0x3619bdDc61189F33365CC572DF3a68FB3b316516': BN.from('0x00'), - '0x714db6c38A17883964B68a07d56cE331501d9eb6': BN.from('0x00'), - '0x3A00d9B02781f47d033BAd62edc55fBF8D083Fb0': BN.from('0x00'), - '0x369Fea97f6fB7510755DCA389088d9E2e2819278': BN.from('0x00'), - '0xF206af85BC2761c4F876d27Bd474681CfB335EfA': BN.from('0x00'), - '0x9C3015191d39cF1930F92EB7e7BCbd020bCA286a': BN.from('0x00'), - '0x6AF3Fdb3282c5bb6926269Db10837fa8Aec67C04': BN.from('0x00'), - '0x35566ED3AF9E537Be487C98b1811cDf95ad0C32b': BN.from('0x0ad78ebc5ac6200000'), - '0xEFAACF73CE2D38ED40991f29E72B12C74bd4cf23': BN.from('0x7f0e10af47c1c7000000'), -}; - -export const fakeSupplyCapsOutputs = { - '0xD5C4C2e2facBEB59D0216D0595d63FcDc6F9A1a7': BN.from( - '0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff', - ), - '0xb7526572FFE56AB9D7489838Bf2E18e3323b441A': BN.from( - '0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff', - ), - '0x08e0A5575De71037aE36AbfAfb516595fE68e5e4': BN.from('0x00'), - '0x74469281310195A04840Daf6EdF576F559a3dE80': BN.from('0x31a6207cd74525f3dc71c0000000'), - '0x2E7222e51c0f6e98610A1543Aa3836E092CDe62c': BN.from( - '0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff', - ), - '0x6d6F697e34145Bb95c54E77482d97cc261Dc237E': BN.from( - '0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff', - ), - '0x162D005F0Fff510E54958Cfc5CF32A3180A84aab': BN.from( - '0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff', - ), - '0xAfc13BC065ABeE838540823431055D2ea52eBA52': BN.from( - '0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff', - ), - '0x488aB2826a154da01CC4CC16A8C83d4720D3cA2C': BN.from( - '0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff', - ), - '0xb6e9322C49FD75a367Fcb17B0Fcd62C5070EbCBe': BN.from( - '0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff', - ), - '0x37C28DE42bA3d22217995D146FC684B2326Ede64': BN.from( - '0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff', - ), - '0xF912d3001CAf6DC4ADD366A62Cc9115B4303c9A9': BN.from( - '0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff', - ), - '0xeDaC03D29ff74b5fDc0CC936F6288312e1459BC6': BN.from( - '0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff', - ), - '0x3619bdDc61189F33365CC572DF3a68FB3b316516': BN.from( - '0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff', - ), - '0x714db6c38A17883964B68a07d56cE331501d9eb6': BN.from( - '0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff', - ), - '0x3A00d9B02781f47d033BAd62edc55fBF8D083Fb0': BN.from( - '0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff', - ), - '0x369Fea97f6fB7510755DCA389088d9E2e2819278': BN.from( - '0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff', - ), - '0xF206af85BC2761c4F876d27Bd474681CfB335EfA': BN.from('0x00'), - '0x9C3015191d39cF1930F92EB7e7BCbd020bCA286a': BN.from('0x00'), - '0x6AF3Fdb3282c5bb6926269Db10837fa8Aec67C04': BN.from( - '0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff', - ), - '0x35566ED3AF9E537Be487C98b1811cDf95ad0C32b': BN.from('0x1043561a8829300000'), - '0xEFAACF73CE2D38ED40991f29E72B12C74bd4cf23': BN.from('0xd3c21bcecceda1000000'), -}; - -export const fakeXvsBorrowSpeedOutputs = { - '0xD5C4C2e2facBEB59D0216D0595d63FcDc6F9A1a7': BN.from('0x3dadd6a60fa600'), - '0xb7526572FFE56AB9D7489838Bf2E18e3323b441A': BN.from('0x3dadd6a60fa600'), - '0x08e0A5575De71037aE36AbfAfb516595fE68e5e4': BN.from('0x00'), - '0x74469281310195A04840Daf6EdF576F559a3dE80': BN.from('0x03157def08c0e3'), - '0x2E7222e51c0f6e98610A1543Aa3836E092CDe62c': BN.from('0xb90983f22ef200'), - '0x6d6F697e34145Bb95c54E77482d97cc261Dc237E': BN.from('0x00'), - '0x162D005F0Fff510E54958Cfc5CF32A3180A84aab': BN.from('0x1ed6eb70d53800'), - '0xAfc13BC065ABeE838540823431055D2ea52eBA52': BN.from('0x1ed6eb70d53800'), - '0x488aB2826a154da01CC4CC16A8C83d4720D3cA2C': BN.from('0x1ed6eb70d53800'), - '0xb6e9322C49FD75a367Fcb17B0Fcd62C5070EbCBe': BN.from('0xb90983f22ef200'), - '0x37C28DE42bA3d22217995D146FC684B2326Ede64': BN.from('0x0acb38c49ea318'), - '0xF912d3001CAf6DC4ADD366A62Cc9115B4303c9A9': BN.from('0x05a681d211373a'), - '0xeDaC03D29ff74b5fDc0CC936F6288312e1459BC6': BN.from('0x0acb38c49ea318'), - '0x3619bdDc61189F33365CC572DF3a68FB3b316516': BN.from('0x00'), - '0x714db6c38A17883964B68a07d56cE331501d9eb6': BN.from('0x018abef7846072'), - '0x3A00d9B02781f47d033BAd62edc55fBF8D083Fb0': BN.from('0x00'), - '0x369Fea97f6fB7510755DCA389088d9E2e2819278': BN.from('0x03157def08c0e4'), - '0xF206af85BC2761c4F876d27Bd474681CfB335EfA': BN.from('0x03157def08c0e4'), - '0x9C3015191d39cF1930F92EB7e7BCbd020bCA286a': BN.from('0x04a03ce68d2156'), - '0x6AF3Fdb3282c5bb6926269Db10837fa8Aec67C04': BN.from('0x03157def08c0e3'), - '0x35566ED3AF9E537Be487C98b1811cDf95ad0C32b': BN.from('0x021e75bc475f0c'), - '0xEFAACF73CE2D38ED40991f29E72B12C74bd4cf23': BN.from('0xc55f7bc23039'), -}; - -export const fakeXvsSupplySpeedOutputs = { - '0xD5C4C2e2facBEB59D0216D0595d63FcDc6F9A1a7': BN.from('0x3dadd6a60fa600'), - '0xb7526572FFE56AB9D7489838Bf2E18e3323b441A': BN.from('0x3dadd6a60fa600'), - '0x08e0A5575De71037aE36AbfAfb516595fE68e5e4': BN.from('0x00'), - '0x74469281310195A04840Daf6EdF576F559a3dE80': BN.from('0x03157def08c0e3'), - '0x2E7222e51c0f6e98610A1543Aa3836E092CDe62c': BN.from('0xb90983f22ef200'), - '0x6d6F697e34145Bb95c54E77482d97cc261Dc237E': BN.from('0x00'), - '0x162D005F0Fff510E54958Cfc5CF32A3180A84aab': BN.from('0x1ed6eb70d53800'), - '0xAfc13BC065ABeE838540823431055D2ea52eBA52': BN.from('0x1ed6eb70d53800'), - '0x488aB2826a154da01CC4CC16A8C83d4720D3cA2C': BN.from('0x1ed6eb70d53800'), - '0xb6e9322C49FD75a367Fcb17B0Fcd62C5070EbCBe': BN.from('0xb90983f22ef200'), - '0x37C28DE42bA3d22217995D146FC684B2326Ede64': BN.from('0x0acb38c49ea318'), - '0xF912d3001CAf6DC4ADD366A62Cc9115B4303c9A9': BN.from('0x05a681d211373a'), - '0xeDaC03D29ff74b5fDc0CC936F6288312e1459BC6': BN.from('0x0acb38c49ea318'), - '0x3619bdDc61189F33365CC572DF3a68FB3b316516': BN.from('0x00'), - '0x714db6c38A17883964B68a07d56cE331501d9eb6': BN.from('0x018abef7846072'), - '0x3A00d9B02781f47d033BAd62edc55fBF8D083Fb0': BN.from('0x00'), - '0x369Fea97f6fB7510755DCA389088d9E2e2819278': BN.from('0x03157def08c0e4'), - '0xF206af85BC2761c4F876d27Bd474681CfB335EfA': BN.from('0x03157def08c0e4'), - '0x9C3015191d39cF1930F92EB7e7BCbd020bCA286a': BN.from('0x04a03ce68d2156'), - '0x6AF3Fdb3282c5bb6926269Db10837fa8Aec67C04': BN.from('0x03157def08c0e3'), - '0x35566ED3AF9E537Be487C98b1811cDf95ad0C32b': BN.from('0x021e75bc475f0c'), - '0xEFAACF73CE2D38ED40991f29E72B12C74bd4cf23': BN.from('0xc55f7bc23039'), -}; - -export const fakeVTokenBalancesAllOutput = [ - { - vToken: '0xD5C4C2e2facBEB59D0216D0595d63FcDc6F9A1a7', - balanceOf: BN.from('0x00'), - borrowBalanceCurrent: BN.from('0x9c8c53'), - balanceOfUnderlying: BN.from('0x00'), - tokenBalance: BN.from('0x1365b040b675'), - tokenAllowance: BN.from('0xffffffffffffffffffffffffffffffffffffffffffffffffffffffe033fe072f'), - }, - { - vToken: '0xb7526572FFE56AB9D7489838Bf2E18e3323b441A', - balanceOf: BN.from('0x00'), - borrowBalanceCurrent: BN.from('0x1a78c999e6ab'), - balanceOfUnderlying: BN.from('0x00'), - tokenBalance: BN.from('0x204fb9313b5d351530080df8'), - tokenAllowance: BN.from('0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffce4a2b7f9'), - }, - { - vToken: '0x08e0A5575De71037aE36AbfAfb516595fE68e5e4', - balanceOf: BN.from('0x06d3faf8f065d0dd'), - borrowBalanceCurrent: BN.from('0x0b13dcc0553d80e6fecb33'), - balanceOfUnderlying: BN.from('0x52baee784430933a367879'), - tokenBalance: BN.from('0x2009084ac91b161262655797'), - tokenAllowance: BN.from('0x20090a68e2fbdfcd14a55797'), - }, - { - vToken: '0x74469281310195A04840Daf6EdF576F559a3dE80', - balanceOf: BN.from('0x0208887d15faa8'), - borrowBalanceCurrent: BN.from('0x074daffe6d79bdd536'), - balanceOfUnderlying: BN.from('0x1b7af46077c560c79148'), - tokenBalance: BN.from('0x21412a87a401b9f52b160000'), - tokenAllowance: BN.from('0xffffffffffffffffffffffffffffffffffffffffffffe51847cad389f0bfffff'), - }, - { - vToken: '0x2E7222e51c0f6e98610A1543Aa3836E092CDe62c', - balanceOf: BN.from('0x0175e1ef02453e'), - borrowBalanceCurrent: BN.from('0x0edca19edfa534de621b'), - balanceOfUnderlying: BN.from('0x468a727f89a362ed9fdb'), - tokenBalance: BN.from('0x8502d85123a800'), - tokenAllowance: BN.from('0x8502d85123a800'), - }, - { - vToken: '0x6d6F697e34145Bb95c54E77482d97cc261Dc237E', - balanceOf: BN.from('0x115a3cc5cb72c6'), - borrowBalanceCurrent: BN.from('0x00'), - balanceOfUnderlying: BN.from('0xd6f3109e087d6631fe88'), - tokenBalance: BN.from('0x04a12be2351d65639ba911'), - tokenAllowance: BN.from('0xffffffffffffffffffffffff'), - }, - { - vToken: '0x162D005F0Fff510E54958Cfc5CF32A3180A84aab', - balanceOf: BN.from('0x00'), - borrowBalanceCurrent: BN.from('0x016225b3e2b944410b'), - balanceOfUnderlying: BN.from('0x00'), - tokenBalance: BN.from('0x12362de47784a9c3fad2'), - tokenAllowance: BN.from('0xffffffffffffffffffffffffffffffffffffffffffffffe92d738a8db88bffff'), - }, - { - vToken: '0xAfc13BC065ABeE838540823431055D2ea52eBA52', - balanceOf: BN.from('0x01b2d36ea88e5a'), - borrowBalanceCurrent: BN.from('0x1d47e7c1c3e92ef846'), - balanceOfUnderlying: BN.from('0x16ee00ec27a4d7bb3c05'), - tokenBalance: BN.from('0x01ec2c6f7d657b7c0000'), - tokenAllowance: BN.from('0xffffffffffffffffffffffffffffffffffffffffffffe9a35bbace13b69bffff'), - }, - { - vToken: '0x488aB2826a154da01CC4CC16A8C83d4720D3cA2C', - balanceOf: BN.from('0x0107403d01589d74'), - borrowBalanceCurrent: BN.from('0x00'), - balanceOfUnderlying: BN.from('0x0e6db7ca6dcbcfc66b85c8'), - tokenBalance: BN.from('0x1622290c5ab44cf8a2a81c'), - tokenAllowance: BN.from('0xffffffffffffffffffffffffffffffffffffffffffcf44aba726fcfcc7fe2422'), - }, - { - vToken: '0xb6e9322C49FD75a367Fcb17B0Fcd62C5070EbCBe', - balanceOf: BN.from('0x0af7c2457a'), - borrowBalanceCurrent: BN.from('0x03281b30a1c48fcf08'), - balanceOfUnderlying: BN.from('0x9e339617b3d2a0a3'), - tokenBalance: BN.from('0x152d91cf8f2411e75394'), - tokenAllowance: BN.from('0x32f422ece5359a9190'), - }, - { - vToken: '0x37C28DE42bA3d22217995D146FC684B2326Ede64', - balanceOf: BN.from('0xb175a2881b3823'), - borrowBalanceCurrent: BN.from('0x6d2d5e6e0d3c1b6f408f'), - balanceOfUnderlying: BN.from('0x08b765441d7f55398fdbb9'), - tokenBalance: BN.from('0x7e37b63bd5a17885f75356ccaf'), - tokenAllowance: BN.from('0xfffffffffffffffffffffffffffffffffffffffffff6af54bcbbd193bd7eccae'), - }, - { - vToken: '0xF912d3001CAf6DC4ADD366A62Cc9115B4303c9A9', - balanceOf: BN.from('0xb1a6f24e960cb1'), - borrowBalanceCurrent: BN.from('0x00'), - balanceOfUnderlying: BN.from('0x03ee1d736bbc63'), - tokenBalance: BN.from('0x0b7abc62705050aaad72e1f7547bc4fd5617'), - tokenAllowance: BN.from('0xfffffffffffffffffffffffffffffffffffffffffffffffffffc018ef9332b14'), - }, - { - vToken: '0xeDaC03D29ff74b5fDc0CC936F6288312e1459BC6', - balanceOf: BN.from('0x1e4890d1667e12'), - borrowBalanceCurrent: BN.from('0x00'), - balanceOfUnderlying: BN.from('0x01a354497f6ee36e5db445'), - tokenBalance: BN.from('0x20a0cf2d039b35c0a0c97c9e'), - tokenAllowance: BN.from('0xfffffffffffffffffffffffffffffffffffffffffffb3681f06dacd741d17c9d'), - }, - { - vToken: '0x3619bdDc61189F33365CC572DF3a68FB3b316516', - balanceOf: BN.from('0x11c77582facc34'), - borrowBalanceCurrent: BN.from('0x25e233441ec90ece2b5c'), - balanceOfUnderlying: BN.from('0x03e707348a326b46bd24d6'), - tokenBalance: BN.from('0x02f050fe93a992c1363f963c2831418000'), - tokenAllowance: BN.from('0xffffffffffffffffffffffffffffffffffffffffffff2c011f312a62621bffff'), - }, - { - vToken: '0x714db6c38A17883964B68a07d56cE331501d9eb6', - balanceOf: BN.from('0x00'), - borrowBalanceCurrent: BN.from('0x7ca56f6a76'), - balanceOfUnderlying: BN.from('0x00'), - tokenBalance: BN.from('0x00'), - tokenAllowance: BN.from('0xfffffffffffffffffffffffffffffffffffffffffffffffa9438a1d29cefffff'), - }, - { - vToken: '0x3A00d9B02781f47d033BAd62edc55fBF8D083Fb0', - balanceOf: BN.from('0x00'), - borrowBalanceCurrent: BN.from('0x00'), - balanceOfUnderlying: BN.from('0x00'), - tokenBalance: BN.from('0x22f04dd08dde193719669da5'), - tokenAllowance: BN.from('0xfffffffffffffffffffffffffffffffffffffffffffffe7e8f720f631e70c848'), - }, - { - vToken: '0x369Fea97f6fB7510755DCA389088d9E2e2819278', - balanceOf: BN.from('0x00'), - borrowBalanceCurrent: BN.from('0x00'), - balanceOfUnderlying: BN.from('0x00'), - tokenBalance: BN.from('0x152d2c6a084fb6fc9862'), - tokenAllowance: BN.from('0xfffffffffffffffffffffffffffffffffffffffffffffffff21f494c589bffff'), - }, - { - vToken: '0xF206af85BC2761c4F876d27Bd474681CfB335EfA', - balanceOf: BN.from('0x00'), - borrowBalanceCurrent: BN.from('0x00'), - balanceOfUnderlying: BN.from('0x00'), - tokenBalance: BN.from('0x00'), - tokenAllowance: BN.from('0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff'), - }, - { - vToken: '0x9C3015191d39cF1930F92EB7e7BCbd020bCA286a', - balanceOf: BN.from('0x00'), - borrowBalanceCurrent: BN.from('0x00'), - balanceOfUnderlying: BN.from('0x00'), - tokenBalance: BN.from('0x00'), - tokenAllowance: BN.from('0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff'), - }, - { - vToken: '0x6AF3Fdb3282c5bb6926269Db10837fa8Aec67C04', - balanceOf: BN.from('0x5af4ea1f8aee'), - borrowBalanceCurrent: BN.from('0x00'), - balanceOfUnderlying: BN.from('0x0182c0e5ae58'), - tokenBalance: BN.from('0x0de0b59a796c93c0'), - tokenAllowance: BN.from('0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffa0a1eff'), - }, - { - vToken: '0x35566ED3AF9E537Be487C98b1811cDf95ad0C32b', - balanceOf: BN.from('0x00'), - borrowBalanceCurrent: BN.from('0x00'), - balanceOfUnderlying: BN.from('0x00'), - tokenBalance: BN.from('0x00'), - tokenAllowance: BN.from('0x00'), - }, - { - vToken: '0xEFAACF73CE2D38ED40991f29E72B12C74bd4cf23', - balanceOf: BN.from('0x00'), - borrowBalanceCurrent: BN.from('0x00'), - balanceOfUnderlying: BN.from('0x00'), - tokenBalance: BN.from('0x00'), - tokenAllowance: BN.from('0x00'), - }, -]; - -export const fakeLegacyPoolComptrollerContract = { - address: altAddress, - getAllMarkets: async () => fakeLegacyPoolComptrollerContractResponses.getAllMarkets, - getAssetsIn: async () => fakeGetAssetsInOutput, - borrowCaps: async (vTokenAddress: keyof typeof fakeBorrowCapsOutputs) => - fakeBorrowCapsOutputs[vTokenAddress], - supplyCaps: async (vTokenAddress: keyof typeof fakeSupplyCapsOutputs) => - fakeSupplyCapsOutputs[vTokenAddress], - venusBorrowSpeeds: async (vTokenAddress: keyof typeof fakeXvsBorrowSpeedOutputs) => - fakeXvsBorrowSpeedOutputs[vTokenAddress], - venusSupplySpeeds: async (vTokenAddress: keyof typeof fakeXvsSupplySpeedOutputs) => - fakeXvsSupplySpeedOutputs[vTokenAddress], -} as unknown as LegacyPoolComptroller; - -export const fakeResilientOracleContract = { - getPrice: async () => fakeGetXvsPriceOutput, - getUnderlyingPrice: async (vTokenAddress: keyof typeof fakeGetUnderlyingPriceOutputs) => - fakeGetUnderlyingPriceOutputs[vTokenAddress], -} as unknown as ResilientOracle; - -export const fakeVaiControllerContract = { - callStatic: { - accrueVAIInterest: vi.fn(), - }, - getVAIRepayAmount: async () => fakeGetVaiRepayAmountOutput, -} as unknown as VaiController; - -export const fakeVenusLensContract = { - callStatic: { - vTokenMetadataAll: async () => fakeVenusLensContractResponses.vTokenMetadataAll, - vTokenBalancesAll: async () => fakeVTokenBalancesAllOutput, - }, -} as unknown as VenusLens; diff --git a/apps/evm/src/clients/api/queries/getLegacyPool/__tests__/__snapshots__/index.spec.ts.snap b/apps/evm/src/clients/api/queries/getLegacyPool/__tests__/__snapshots__/index.spec.ts.snap deleted file mode 100644 index 949b43c1c9..0000000000 --- a/apps/evm/src/clients/api/queries/getLegacyPool/__tests__/__snapshots__/index.spec.ts.snap +++ /dev/null @@ -1,412 +0,0 @@ -// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html - -exports[`getLegacyPool > returns core pool in the correct format 1`] = ` -{ - "pool": { - "assets": [ - { - "borrowApyPercentage": "2.0200781054088957", - "borrowBalanceCents": "24663011775918.58670630114424219627258", - "borrowBalanceTokens": "246628588661.936163058800477859", - "borrowCapTokens": "1e-18", - "borrowDistributions": [ - { - "apyPercentage": "0", - "dailyDistributedTokens": "0", - "token": { - "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", - "asset": "/src/libs/tokens/img/xvs.svg", - "decimals": 18, - "symbol": "XVS", - }, - "type": "rewardDistributor", - }, - ], - "borrowerCount": 438, - "cashTokens": "1.00000000080503544824460983238917793784e+21", - "collateralFactor": 0, - "disabledTokenActions": [ - "supply", - "borrow", - ], - "exchangeRateVTokens": "49.19405324154271215086", - "isCollateralOfUser": true, - "liquidityCents": "1.000006200805040439464388948970138750743214608e+23", - "reserveFactor": 1, - "reserveTokens": "0", - "supplierCount": 933, - "supplyApyPercentage": "0", - "supplyBalanceCents": "1.000006201051670556767362816225462034303610544746e+23", - "supplyBalanceTokens": "1.00000000105166403645033682413715238395883e+21", - "supplyCapTokens": "0", - "supplyDistributions": [ - { - "apyPercentage": "0", - "dailyDistributedTokens": "0", - "token": { - "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", - "asset": "/src/libs/tokens/img/xvs.svg", - "decimals": 18, - "symbol": "XVS", - }, - "type": "rewardDistributor", - }, - ], - "tokenPriceCents": "100.00062", - "userBorrowBalanceCents": "1.02596026091418e-9", - "userBorrowBalanceTokens": "1.0259539e-11", - "userPercentOfLimit": 0, - "userSupplyBalanceCents": "0", - "userSupplyBalanceTokens": "0", - "userWalletBalanceCents": "0.00213276018859808651478", - "userWalletBalanceTokens": "0.000021327469655669", - "vToken": { - "address": "0x08e0A5575De71037aE36AbfAfb516595fE68e5e4", - "decimals": 8, - "symbol": "vBUSD", - "underlyingToken": { - "address": "0x8301F2213c0eeD49a7E28Ae4c3e91722919B8B47", - "asset": "/src/libs/tokens/img/busd.svg", - "decimals": 18, - "symbol": "BUSD", - }, - }, - }, - { - "borrowApyPercentage": "12.763322565556457", - "borrowBalanceCents": "3721959398.320962344455482972", - "borrowBalanceTokens": "15136.746248595758022748", - "borrowCapTokens": "0", - "borrowDistributions": [ - { - "apyPercentage": "1.5797413696681861", - "dailyDistributedTokens": "250.0000128", - "token": { - "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", - "asset": "/src/libs/tokens/img/xvs.svg", - "decimals": 18, - "symbol": "XVS", - }, - "type": "rewardDistributor", - }, - ], - "borrowerCount": 35, - "cashTokens": "0", - "collateralFactor": 0.8, - "disabledTokenActions": [], - "exchangeRateVTokens": "37.63966306652044917955", - "isCollateralOfUser": false, - "liquidityCents": "0", - "reserveFactor": 0.1, - "reserveTokens": "21.269535066688975633", - "supplierCount": 25, - "supplyApyPercentage": "11.434048167920574", - "supplyBalanceCents": "3716729453.6129492577232450137", - "supplyBalanceTokens": "15115.4767135290690422233", - "supplyCapTokens": "1.15792089237316195423570985008687907853269984665640564039457584007913129639935e+59", - "supplyDistributions": [ - { - "apyPercentage": "1.5819817239252298", - "dailyDistributedTokens": "250.0000128", - "token": { - "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", - "asset": "/src/libs/tokens/img/xvs.svg", - "decimals": 18, - "symbol": "XVS", - }, - "type": "rewardDistributor", - }, - ], - "tokenPriceCents": "245889", - "userBorrowBalanceCents": "7.156865078267903019", - "userBorrowBalanceTokens": "0.000029106080704171", - "userPercentOfLimit": 0, - "userSupplyBalanceCents": "0", - "userSupplyBalanceTokens": "0", - "userWalletBalanceCents": "2458865411100005.406193157416225272", - "userWalletBalanceTokens": "9999900000.000021986315603448", - "vToken": { - "address": "0x162D005F0Fff510E54958Cfc5CF32A3180A84aab", - "decimals": 8, - "symbol": "vETH", - "underlyingToken": { - "address": "0x98f7A83361F7Ac8765CcEBAB1425da6b341958a7", - "asset": "/src/libs/tokens/img/eth.svg", - "decimals": 18, - "isNative": true, - "symbol": "ETH", - }, - }, - }, - { - "borrowApyPercentage": "180.75799822550164", - "borrowBalanceCents": "54206766464.991794941213834066224", - "borrowBalanceTokens": "1032405.72373577234796371", - "borrowCapTokens": "0", - "borrowDistributions": [ - { - "apyPercentage": "0.6478221277312901", - "dailyDistributedTokens": "1499.9999904", - "token": { - "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", - "asset": "/src/libs/tokens/img/xvs.svg", - "decimals": 18, - "symbol": "XVS", - }, - "type": "rewardDistributor", - }, - ], - "borrowerCount": 263, - "cashTokens": "5.556233762724731858", - "collateralFactor": 0.8, - "disabledTokenActions": [], - "exchangeRateVTokens": "5.63429988023545433776", - "isCollateralOfUser": true, - "liquidityCents": "291731.6894670817923653489952", - "reserveFactor": 0.25, - "reserveTokens": "187487.447405339178551222", - "supplierCount": 923, - "supplyApyPercentage": "157.57792083092227", - "supplyBalanceCents": "44362974574.359412320127072323564288", - "supplyBalanceTokens": "844923.83256419589412162352", - "supplyCapTokens": "1.15792089237316195423570985008687907853269984665640564039457584007913129639935e+59", - "supplyDistributions": [ - { - "apyPercentage": "0.7921351276470645", - "dailyDistributedTokens": "1499.9999904", - "token": { - "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", - "asset": "/src/libs/tokens/img/xvs.svg", - "decimals": 18, - "symbol": "XVS", - }, - "type": "rewardDistributor", - }, - ], - "tokenPriceCents": "52505.2944", - "userBorrowBalanceCents": "7073785.2980067928964376533856", - "userBorrowBalanceTokens": "134.725181123959051574", - "userPercentOfLimit": 0.12, - "userSupplyBalanceCents": "6813717433.5010155085170052265088", - "userSupplyBalanceTokens": "129772.007020705620660552", - "userWalletBalanceCents": "540373271888369.14416", - "userWalletBalanceTokens": "10291786343.9", - "vToken": { - "address": "0x2E7222e51c0f6e98610A1543Aa3836E092CDe62c", - "decimals": 8, - "symbol": "vBNB", - "underlyingToken": { - "address": "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE", - "asset": "/src/libs/tokens/img/bnb.svg", - "decimals": 18, - "isNative": true, - "symbol": "BNB", - }, - }, - }, - { - "borrowApyPercentage": "16.850090258739982", - "borrowBalanceCents": "266527277.02974427316207663041589", - "borrowBalanceTokens": "416884.364702270734855123", - "borrowCapTokens": "270000", - "borrowDistributions": [ - { - "apyPercentage": "0", - "dailyDistributedTokens": "0", - "token": { - "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", - "asset": "/src/libs/tokens/img/xvs.svg", - "decimals": 18, - "symbol": "XVS", - }, - "type": "rewardDistributor", - }, - ], - "borrowerCount": 68, - "cashTokens": "2259657.074761148481496107", - "collateralFactor": 0.6, - "disabledTokenActions": [], - "exchangeRateVTokens": "47.36910235297224095005", - "isCollateralOfUser": true, - "liquidityCents": "1444669788.91666196711723462774301", - "reserveFactor": 0.25, - "reserveTokens": "0", - "supplierCount": 274, - "supplyApyPercentage": "1.8360754649567212", - "supplyBalanceCents": "1711197065.9464062401284554003137589", - "supplyBalanceTokens": "2676541.43946341921611527123", - "supplyCapTokens": "3750000", - "supplyDistributions": [ - { - "apyPercentage": "0", - "dailyDistributedTokens": "0", - "token": { - "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", - "asset": "/src/libs/tokens/img/xvs.svg", - "decimals": 18, - "symbol": "XVS", - }, - "type": "rewardDistributor", - }, - ], - "tokenPriceCents": "639.33143", - "userBorrowBalanceCents": "0", - "userBorrowBalanceTokens": "0", - "userPercentOfLimit": 0, - "userSupplyBalanceCents": "0.70725092468251742803237", - "userSupplyBalanceTokens": "0.001106235188034659", - "userWalletBalanceCents": "6.3933143000000639331429999863775169751254466605905e+26", - "userWalletBalanceTokens": "1.000000000000009999999999997869261171021335e+24", - "vToken": { - "address": "0x6d6F697e34145Bb95c54E77482d97cc261Dc237E", - "decimals": 8, - "symbol": "vXVS", - "underlyingToken": { - "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", - "asset": "/src/libs/tokens/img/xvs.svg", - "decimals": 18, - "symbol": "XVS", - }, - }, - }, - { - "borrowApyPercentage": "2.0200781032592374", - "borrowBalanceCents": "743724749.881571973423", - "borrowBalanceTokens": "7437523.951581", - "borrowCapTokens": "0", - "borrowDistributions": [ - { - "apyPercentage": "16.981964056809385", - "dailyDistributedTokens": "499.9999968", - "token": { - "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", - "asset": "/src/libs/tokens/img/xvs.svg", - "decimals": 18, - "symbol": "XVS", - }, - "type": "rewardDistributor", - }, - ], - "borrowerCount": 249, - "cashTokens": "1.0000736633870942814396398228131475074669e+34", - "collateralFactor": 0.8, - "disabledTokenActions": [], - "exchangeRateVTokens": "49.8066352191466231613", - "isCollateralOfUser": false, - "liquidityCents": "1.000036490649026183145198711400933542774047455327e+36", - "reserveFactor": 0.1, - "reserveTokens": "0", - "supplierCount": 670, - "supplyApyPercentage": "0", - "supplyBalanceCents": "1.00003649064902618314530970887489046343322854178897705712904885e+36", - "supplyBalanceTokens": "1.000073663387094281439750824413033895903139261475326095e+34", - "supplyCapTokens": "1.15792089237316195423570985008687907853269984665640564039457584007913129639935e+71", - "supplyDistributions": [ - { - "apyPercentage": "0", - "dailyDistributedTokens": "499.9999968", - "token": { - "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", - "asset": "/src/libs/tokens/img/xvs.svg", - "decimals": 18, - "symbol": "XVS", - }, - "type": "rewardDistributor", - }, - ], - "tokenPriceCents": "99.996283", - "userBorrowBalanceCents": "0", - "userBorrowBalanceTokens": "0", - "userPercentOfLimit": 0, - "userSupplyBalanceCents": "0", - "userSupplyBalanceTokens": "0", - "userWalletBalanceCents": "9999928289169302585.414550788886", - "userWalletBalanceTokens": "100003000003203144.915042", - "vToken": { - "address": "0xb7526572FFE56AB9D7489838Bf2E18e3323b441A", - "decimals": 8, - "symbol": "vUSDT", - "underlyingToken": { - "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", - "asset": "/src/libs/tokens/img/usdt.svg", - "decimals": 6, - "symbol": "USDT", - }, - }, - }, - { - "borrowApyPercentage": "2.0200782609031798", - "borrowBalanceCents": "1562397934365776.075433634816", - "borrowBalanceTokens": "15624370577897.031296", - "borrowCapTokens": "0", - "borrowDistributions": [ - { - "apyPercentage": "0.000007467880158706", - "dailyDistributedTokens": "499.9999968", - "token": { - "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", - "asset": "/src/libs/tokens/img/xvs.svg", - "decimals": 18, - "symbol": "XVS", - }, - "type": "rewardDistributor", - }, - ], - "borrowerCount": 229, - "cashTokens": "1.010176805025969148511141552e+21", - "collateralFactor": 0.81, - "disabledTokenActions": [], - "exchangeRateVTokens": "47.12928141003911013496", - "isCollateralOfUser": true, - "liquidityCents": "1.01015151019877129824366283301553792e+23", - "reserveFactor": 0.1, - "reserveTokens": "0", - "supplierCount": 534, - "supplyApyPercentage": "2.7328805884e-8", - "supplyBalanceCents": "1.0101515258227468345608256850251328456045167117888e+23", - "supplyBalanceTokens": "1.01017682065033591897223674983334867265528e+21", - "supplyCapTokens": "1.15792089237316195423570985008687907853269984665640564039457584007913129639935e+71", - "supplyDistributions": [ - { - "apyPercentage": "0", - "dailyDistributedTokens": "499.9999968", - "token": { - "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", - "asset": "/src/libs/tokens/img/xvs.svg", - "decimals": 18, - "symbol": "XVS", - }, - "type": "rewardDistributor", - }, - ], - "tokenPriceCents": "99.997496", - "userBorrowBalanceCents": "0", - "userBorrowBalanceTokens": "0", - "userPercentOfLimit": 0, - "userSupplyBalanceCents": "0", - "userSupplyBalanceTokens": "0", - "userWalletBalanceCents": "0", - "userWalletBalanceTokens": "0", - "vToken": { - "address": "0xD5C4C2e2facBEB59D0216D0595d63FcDc6F9A1a7", - "decimals": 8, - "symbol": "vUSDC", - "underlyingToken": { - "address": "0x16227D60f7a0e586C66B005219dfc887D13C9531", - "asset": "/src/libs/tokens/img/usdc.svg", - "decimals": 6, - "symbol": "USDC", - }, - }, - }, - ], - "comptrollerAddress": "0xa258a693A403b7e98fd05EE9e1558C760308cFC7", - "description": "Fake pool description", - "isIsolated": false, - "name": "Fake pool name", - "userBorrowBalanceCents": "7073792.45487187219030093329978", - "userBorrowLimitCents": "5450973947.225162961623114638026462", - "userSupplyBalanceCents": "6813717434.20826643319952265454117", - }, -} -`; diff --git a/apps/evm/src/clients/api/queries/getLegacyPool/__tests__/__snapshots__/indexPrime.spec.ts.snap b/apps/evm/src/clients/api/queries/getLegacyPool/__tests__/__snapshots__/indexPrime.spec.ts.snap deleted file mode 100644 index d6fa0b2c5e..0000000000 --- a/apps/evm/src/clients/api/queries/getLegacyPool/__tests__/__snapshots__/indexPrime.spec.ts.snap +++ /dev/null @@ -1,1534 +0,0 @@ -// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html - -exports[`getLegacyPool - Feature enabled: Prime > does not fetch Prime distributions if user is not Prime 1`] = ` -{ - "pool": { - "assets": [ - { - "borrowApyPercentage": "2.0200781054088957", - "borrowBalanceCents": "24663011775918.58670630114424219627258", - "borrowBalanceTokens": "246628588661.936163058800477859", - "borrowCapTokens": "1e-18", - "borrowDistributions": [ - { - "apyPercentage": "0", - "dailyDistributedTokens": "0", - "token": { - "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", - "asset": "/src/libs/tokens/img/xvs.svg", - "decimals": 18, - "symbol": "XVS", - }, - "type": "rewardDistributor", - }, - { - "apyPercentage": "0.20019958435848473", - "referenceValues": { - "userBorrowBalanceTokens": "563078969.54779945903835725538", - "userSupplyBalanceTokens": "1071811362327614186.97785297335171745333", - "userXvsStakedTokens": "1000", - }, - "token": { - "address": "0x8301F2213c0eeD49a7E28Ae4c3e91722919B8B47", - "asset": "/src/libs/tokens/img/busd.svg", - "decimals": 18, - "symbol": "BUSD", - }, - "type": "primeSimulation", - }, - ], - "borrowerCount": 438, - "cashTokens": "1.00000000080503544824460983238917793784e+21", - "collateralFactor": 0, - "disabledTokenActions": [ - "supply", - "borrow", - ], - "exchangeRateVTokens": "49.19405324154271215086", - "isCollateralOfUser": true, - "liquidityCents": "1.000006200805040439464388948970138750743214608e+23", - "reserveFactor": 1, - "reserveTokens": "0", - "supplierCount": 933, - "supplyApyPercentage": "0", - "supplyBalanceCents": "1.000006201051670556767362816225462034303610544746e+23", - "supplyBalanceTokens": "1.00000000105166403645033682413715238395883e+21", - "supplyCapTokens": "0", - "supplyDistributions": [ - { - "apyPercentage": "0", - "dailyDistributedTokens": "0", - "token": { - "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", - "asset": "/src/libs/tokens/img/xvs.svg", - "decimals": 18, - "symbol": "XVS", - }, - "type": "rewardDistributor", - }, - { - "apyPercentage": "0.23026397657694986", - "referenceValues": { - "userBorrowBalanceTokens": "563078969.54779945903835725538", - "userSupplyBalanceTokens": "1071811362327614186.97785297335171745333", - "userXvsStakedTokens": "1000", - }, - "token": { - "address": "0x8301F2213c0eeD49a7E28Ae4c3e91722919B8B47", - "asset": "/src/libs/tokens/img/busd.svg", - "decimals": 18, - "symbol": "BUSD", - }, - "type": "primeSimulation", - }, - ], - "tokenPriceCents": "100.00062", - "userBorrowBalanceCents": "1.02596026091418e-9", - "userBorrowBalanceTokens": "1.0259539e-11", - "userPercentOfLimit": 0, - "userSupplyBalanceCents": "0", - "userSupplyBalanceTokens": "0", - "userWalletBalanceCents": "0.00213276018859808651478", - "userWalletBalanceTokens": "0.000021327469655669", - "vToken": { - "address": "0x08e0A5575De71037aE36AbfAfb516595fE68e5e4", - "decimals": 8, - "symbol": "vBUSD", - "underlyingToken": { - "address": "0x8301F2213c0eeD49a7E28Ae4c3e91722919B8B47", - "asset": "/src/libs/tokens/img/busd.svg", - "decimals": 18, - "symbol": "BUSD", - }, - }, - }, - { - "borrowApyPercentage": "12.763322565556457", - "borrowBalanceCents": "3721959398.320962344455482972", - "borrowBalanceTokens": "15136.746248595758022748", - "borrowCapTokens": "0", - "borrowDistributions": [ - { - "apyPercentage": "1.5797413696681861", - "dailyDistributedTokens": "250.0000128", - "token": { - "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", - "asset": "/src/libs/tokens/img/xvs.svg", - "decimals": 18, - "symbol": "XVS", - }, - "type": "rewardDistributor", - }, - ], - "borrowerCount": 35, - "cashTokens": "0", - "collateralFactor": 0.8, - "disabledTokenActions": [], - "exchangeRateVTokens": "37.63966306652044917955", - "isCollateralOfUser": false, - "liquidityCents": "0", - "reserveFactor": 0.1, - "reserveTokens": "21.269535066688975633", - "supplierCount": 25, - "supplyApyPercentage": "11.434048167920574", - "supplyBalanceCents": "3716729453.6129492577232450137", - "supplyBalanceTokens": "15115.4767135290690422233", - "supplyCapTokens": "1.15792089237316195423570985008687907853269984665640564039457584007913129639935e+59", - "supplyDistributions": [ - { - "apyPercentage": "1.5819817239252298", - "dailyDistributedTokens": "250.0000128", - "token": { - "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", - "asset": "/src/libs/tokens/img/xvs.svg", - "decimals": 18, - "symbol": "XVS", - }, - "type": "rewardDistributor", - }, - ], - "tokenPriceCents": "245889", - "userBorrowBalanceCents": "7.156865078267903019", - "userBorrowBalanceTokens": "0.000029106080704171", - "userPercentOfLimit": 0, - "userSupplyBalanceCents": "0", - "userSupplyBalanceTokens": "0", - "userWalletBalanceCents": "2458865411100005.406193157416225272", - "userWalletBalanceTokens": "9999900000.000021986315603448", - "vToken": { - "address": "0x162D005F0Fff510E54958Cfc5CF32A3180A84aab", - "decimals": 8, - "symbol": "vETH", - "underlyingToken": { - "address": "0x98f7A83361F7Ac8765CcEBAB1425da6b341958a7", - "asset": "/src/libs/tokens/img/eth.svg", - "decimals": 18, - "isNative": true, - "symbol": "ETH", - }, - }, - }, - { - "borrowApyPercentage": "180.75799822550164", - "borrowBalanceCents": "54206766464.991794941213834066224", - "borrowBalanceTokens": "1032405.72373577234796371", - "borrowCapTokens": "0", - "borrowDistributions": [ - { - "apyPercentage": "0.6478221277312901", - "dailyDistributedTokens": "1499.9999904", - "token": { - "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", - "asset": "/src/libs/tokens/img/xvs.svg", - "decimals": 18, - "symbol": "XVS", - }, - "type": "rewardDistributor", - }, - ], - "borrowerCount": 263, - "cashTokens": "5.556233762724731858", - "collateralFactor": 0.8, - "disabledTokenActions": [], - "exchangeRateVTokens": "5.63429988023545433776", - "isCollateralOfUser": true, - "liquidityCents": "291731.6894670817923653489952", - "reserveFactor": 0.25, - "reserveTokens": "187487.447405339178551222", - "supplierCount": 923, - "supplyApyPercentage": "157.57792083092227", - "supplyBalanceCents": "44362974574.359412320127072323564288", - "supplyBalanceTokens": "844923.83256419589412162352", - "supplyCapTokens": "1.15792089237316195423570985008687907853269984665640564039457584007913129639935e+59", - "supplyDistributions": [ - { - "apyPercentage": "0.7921351276470645", - "dailyDistributedTokens": "1499.9999904", - "token": { - "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", - "asset": "/src/libs/tokens/img/xvs.svg", - "decimals": 18, - "symbol": "XVS", - }, - "type": "rewardDistributor", - }, - ], - "tokenPriceCents": "52505.2944", - "userBorrowBalanceCents": "7073785.2980067928964376533856", - "userBorrowBalanceTokens": "134.725181123959051574", - "userPercentOfLimit": 0.12, - "userSupplyBalanceCents": "6813717433.5010155085170052265088", - "userSupplyBalanceTokens": "129772.007020705620660552", - "userWalletBalanceCents": "540373271888369.14416", - "userWalletBalanceTokens": "10291786343.9", - "vToken": { - "address": "0x2E7222e51c0f6e98610A1543Aa3836E092CDe62c", - "decimals": 8, - "symbol": "vBNB", - "underlyingToken": { - "address": "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE", - "asset": "/src/libs/tokens/img/bnb.svg", - "decimals": 18, - "isNative": true, - "symbol": "BNB", - }, - }, - }, - { - "borrowApyPercentage": "16.850090258739982", - "borrowBalanceCents": "266527277.02974427316207663041589", - "borrowBalanceTokens": "416884.364702270734855123", - "borrowCapTokens": "270000", - "borrowDistributions": [ - { - "apyPercentage": "0", - "dailyDistributedTokens": "0", - "token": { - "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", - "asset": "/src/libs/tokens/img/xvs.svg", - "decimals": 18, - "symbol": "XVS", - }, - "type": "rewardDistributor", - }, - ], - "borrowerCount": 68, - "cashTokens": "2259657.074761148481496107", - "collateralFactor": 0.6, - "disabledTokenActions": [], - "exchangeRateVTokens": "47.36910235297224095005", - "isCollateralOfUser": true, - "liquidityCents": "1444669788.91666196711723462774301", - "reserveFactor": 0.25, - "reserveTokens": "0", - "supplierCount": 274, - "supplyApyPercentage": "1.8360754649567212", - "supplyBalanceCents": "1711197065.9464062401284554003137589", - "supplyBalanceTokens": "2676541.43946341921611527123", - "supplyCapTokens": "3750000", - "supplyDistributions": [ - { - "apyPercentage": "0", - "dailyDistributedTokens": "0", - "token": { - "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", - "asset": "/src/libs/tokens/img/xvs.svg", - "decimals": 18, - "symbol": "XVS", - }, - "type": "rewardDistributor", - }, - ], - "tokenPriceCents": "639.33143", - "userBorrowBalanceCents": "0", - "userBorrowBalanceTokens": "0", - "userPercentOfLimit": 0, - "userSupplyBalanceCents": "0.70725092468251742803237", - "userSupplyBalanceTokens": "0.001106235188034659", - "userWalletBalanceCents": "6.3933143000000639331429999863775169751254466605905e+26", - "userWalletBalanceTokens": "1.000000000000009999999999997869261171021335e+24", - "vToken": { - "address": "0x6d6F697e34145Bb95c54E77482d97cc261Dc237E", - "decimals": 8, - "symbol": "vXVS", - "underlyingToken": { - "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", - "asset": "/src/libs/tokens/img/xvs.svg", - "decimals": 18, - "symbol": "XVS", - }, - }, - }, - { - "borrowApyPercentage": "2.0200781032592374", - "borrowBalanceCents": "743724749.881571973423", - "borrowBalanceTokens": "7437523.951581", - "borrowCapTokens": "0", - "borrowDistributions": [ - { - "apyPercentage": "16.981964056809385", - "dailyDistributedTokens": "499.9999968", - "token": { - "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", - "asset": "/src/libs/tokens/img/xvs.svg", - "decimals": 18, - "symbol": "XVS", - }, - "type": "rewardDistributor", - }, - { - "apyPercentage": "0.20019958435848473", - "referenceValues": { - "userBorrowBalanceTokens": "10009.21", - "userSupplyBalanceTokens": "5003.94", - "userXvsStakedTokens": "3731.33", - }, - "token": { - "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", - "asset": "/src/libs/tokens/img/usdt.svg", - "decimals": 6, - "symbol": "USDT", - }, - "type": "primeSimulation", - }, - ], - "borrowerCount": 249, - "cashTokens": "1.0000736633870942814396398228131475074669e+34", - "collateralFactor": 0.8, - "disabledTokenActions": [], - "exchangeRateVTokens": "49.8066352191466231613", - "isCollateralOfUser": false, - "liquidityCents": "1.000036490649026183145198711400933542774047455327e+36", - "reserveFactor": 0.1, - "reserveTokens": "0", - "supplierCount": 670, - "supplyApyPercentage": "0", - "supplyBalanceCents": "1.00003649064902618314530970887489046343322854178897705712904885e+36", - "supplyBalanceTokens": "1.000073663387094281439750824413033895903139261475326095e+34", - "supplyCapTokens": "1.15792089237316195423570985008687907853269984665640564039457584007913129639935e+71", - "supplyDistributions": [ - { - "apyPercentage": "0", - "dailyDistributedTokens": "499.9999968", - "token": { - "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", - "asset": "/src/libs/tokens/img/xvs.svg", - "decimals": 18, - "symbol": "XVS", - }, - "type": "rewardDistributor", - }, - { - "apyPercentage": "0.23026397657694986", - "referenceValues": { - "userBorrowBalanceTokens": "10009.21", - "userSupplyBalanceTokens": "5003.94", - "userXvsStakedTokens": "3731.33", - }, - "token": { - "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", - "asset": "/src/libs/tokens/img/usdt.svg", - "decimals": 6, - "symbol": "USDT", - }, - "type": "primeSimulation", - }, - ], - "tokenPriceCents": "99.996283", - "userBorrowBalanceCents": "0", - "userBorrowBalanceTokens": "0", - "userPercentOfLimit": 0, - "userSupplyBalanceCents": "0", - "userSupplyBalanceTokens": "0", - "userWalletBalanceCents": "9999928289169302585.414550788886", - "userWalletBalanceTokens": "100003000003203144.915042", - "vToken": { - "address": "0xb7526572FFE56AB9D7489838Bf2E18e3323b441A", - "decimals": 8, - "symbol": "vUSDT", - "underlyingToken": { - "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", - "asset": "/src/libs/tokens/img/usdt.svg", - "decimals": 6, - "symbol": "USDT", - }, - }, - }, - { - "borrowApyPercentage": "2.0200782609031798", - "borrowBalanceCents": "1562397934365776.075433634816", - "borrowBalanceTokens": "15624370577897.031296", - "borrowCapTokens": "0", - "borrowDistributions": [ - { - "apyPercentage": "0.000007467880158706", - "dailyDistributedTokens": "499.9999968", - "token": { - "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", - "asset": "/src/libs/tokens/img/xvs.svg", - "decimals": 18, - "symbol": "XVS", - }, - "type": "rewardDistributor", - }, - { - "apyPercentage": "0.20019958435848473", - "referenceValues": { - "userBorrowBalanceTokens": "2405.43", - "userSupplyBalanceTokens": "13068.75", - "userXvsStakedTokens": "3265.3", - }, - "token": { - "address": "0x16227D60f7a0e586C66B005219dfc887D13C9531", - "asset": "/src/libs/tokens/img/usdc.svg", - "decimals": 6, - "symbol": "USDC", - }, - "type": "primeSimulation", - }, - ], - "borrowerCount": 229, - "cashTokens": "1.010176805025969148511141552e+21", - "collateralFactor": 0.81, - "disabledTokenActions": [], - "exchangeRateVTokens": "47.12928141003911013496", - "isCollateralOfUser": true, - "liquidityCents": "1.01015151019877129824366283301553792e+23", - "reserveFactor": 0.1, - "reserveTokens": "0", - "supplierCount": 534, - "supplyApyPercentage": "2.7328805884e-8", - "supplyBalanceCents": "1.0101515258227468345608256850251328456045167117888e+23", - "supplyBalanceTokens": "1.01017682065033591897223674983334867265528e+21", - "supplyCapTokens": "1.15792089237316195423570985008687907853269984665640564039457584007913129639935e+71", - "supplyDistributions": [ - { - "apyPercentage": "0", - "dailyDistributedTokens": "499.9999968", - "token": { - "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", - "asset": "/src/libs/tokens/img/xvs.svg", - "decimals": 18, - "symbol": "XVS", - }, - "type": "rewardDistributor", - }, - { - "apyPercentage": "0.23026397657694986", - "referenceValues": { - "userBorrowBalanceTokens": "2405.43", - "userSupplyBalanceTokens": "13068.75", - "userXvsStakedTokens": "3265.3", - }, - "token": { - "address": "0x16227D60f7a0e586C66B005219dfc887D13C9531", - "asset": "/src/libs/tokens/img/usdc.svg", - "decimals": 6, - "symbol": "USDC", - }, - "type": "primeSimulation", - }, - ], - "tokenPriceCents": "99.997496", - "userBorrowBalanceCents": "0", - "userBorrowBalanceTokens": "0", - "userPercentOfLimit": 0, - "userSupplyBalanceCents": "0", - "userSupplyBalanceTokens": "0", - "userWalletBalanceCents": "0", - "userWalletBalanceTokens": "0", - "vToken": { - "address": "0xD5C4C2e2facBEB59D0216D0595d63FcDc6F9A1a7", - "decimals": 8, - "symbol": "vUSDC", - "underlyingToken": { - "address": "0x16227D60f7a0e586C66B005219dfc887D13C9531", - "asset": "/src/libs/tokens/img/usdc.svg", - "decimals": 6, - "symbol": "USDC", - }, - }, - }, - ], - "comptrollerAddress": "0xa258a693A403b7e98fd05EE9e1558C760308cFC7", - "description": "Fake pool description", - "isIsolated": false, - "name": "Fake pool name", - "userBorrowBalanceCents": "7073792.45487187219030093329978", - "userBorrowLimitCents": "5450973947.225162961623114638026462", - "userSupplyBalanceCents": "6813717434.20826643319952265454117", - }, -} -`; - -exports[`getLegacyPool - Feature enabled: Prime > fetches and formats Prime distributions and Prime distribution simulations if user is Prime 1`] = ` -{ - "pool": { - "assets": [ - { - "borrowApyPercentage": "2.0200781054088957", - "borrowBalanceCents": "24663011775918.58670630114424219627258", - "borrowBalanceTokens": "246628588661.936163058800477859", - "borrowCapTokens": "1e-18", - "borrowDistributions": [ - { - "apyPercentage": "0", - "dailyDistributedTokens": "0", - "token": { - "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", - "asset": "/src/libs/tokens/img/xvs.svg", - "decimals": 18, - "symbol": "XVS", - }, - "type": "rewardDistributor", - }, - { - "apyPercentage": "0.32051113933926345", - "token": { - "address": "0x8301F2213c0eeD49a7E28Ae4c3e91722919B8B47", - "asset": "/src/libs/tokens/img/busd.svg", - "decimals": 18, - "symbol": "BUSD", - }, - "type": "prime", - }, - { - "apyPercentage": "0.20019958435848473", - "referenceValues": { - "userBorrowBalanceTokens": "563078969.54779945903835725538", - "userSupplyBalanceTokens": "1071811362327614186.97785297335171745333", - "userXvsStakedTokens": "1000", - }, - "token": { - "address": "0x8301F2213c0eeD49a7E28Ae4c3e91722919B8B47", - "asset": "/src/libs/tokens/img/busd.svg", - "decimals": 18, - "symbol": "BUSD", - }, - "type": "primeSimulation", - }, - ], - "borrowerCount": 438, - "cashTokens": "1.00000000080503544824460983238917793784e+21", - "collateralFactor": 0, - "disabledTokenActions": [ - "supply", - "borrow", - ], - "exchangeRateVTokens": "49.19405324154271215086", - "isCollateralOfUser": true, - "liquidityCents": "1.000006200805040439464388948970138750743214608e+23", - "reserveFactor": 1, - "reserveTokens": "0", - "supplierCount": 933, - "supplyApyPercentage": "0", - "supplyBalanceCents": "1.000006201051670556767362816225462034303610544746e+23", - "supplyBalanceTokens": "1.00000000105166403645033682413715238395883e+21", - "supplyCapTokens": "0", - "supplyDistributions": [ - { - "apyPercentage": "0", - "dailyDistributedTokens": "0", - "token": { - "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", - "asset": "/src/libs/tokens/img/xvs.svg", - "decimals": 18, - "symbol": "XVS", - }, - "type": "rewardDistributor", - }, - { - "apyPercentage": "0.2904197513866391", - "token": { - "address": "0x8301F2213c0eeD49a7E28Ae4c3e91722919B8B47", - "asset": "/src/libs/tokens/img/busd.svg", - "decimals": 18, - "symbol": "BUSD", - }, - "type": "prime", - }, - { - "apyPercentage": "0.23026397657694986", - "referenceValues": { - "userBorrowBalanceTokens": "563078969.54779945903835725538", - "userSupplyBalanceTokens": "1071811362327614186.97785297335171745333", - "userXvsStakedTokens": "1000", - }, - "token": { - "address": "0x8301F2213c0eeD49a7E28Ae4c3e91722919B8B47", - "asset": "/src/libs/tokens/img/busd.svg", - "decimals": 18, - "symbol": "BUSD", - }, - "type": "primeSimulation", - }, - ], - "tokenPriceCents": "100.00062", - "userBorrowBalanceCents": "1.02596026091418e-9", - "userBorrowBalanceTokens": "1.0259539e-11", - "userPercentOfLimit": 0, - "userSupplyBalanceCents": "0", - "userSupplyBalanceTokens": "0", - "userWalletBalanceCents": "0.00213276018859808651478", - "userWalletBalanceTokens": "0.000021327469655669", - "vToken": { - "address": "0x08e0A5575De71037aE36AbfAfb516595fE68e5e4", - "decimals": 8, - "symbol": "vBUSD", - "underlyingToken": { - "address": "0x8301F2213c0eeD49a7E28Ae4c3e91722919B8B47", - "asset": "/src/libs/tokens/img/busd.svg", - "decimals": 18, - "symbol": "BUSD", - }, - }, - }, - { - "borrowApyPercentage": "12.763322565556457", - "borrowBalanceCents": "3721959398.320962344455482972", - "borrowBalanceTokens": "15136.746248595758022748", - "borrowCapTokens": "0", - "borrowDistributions": [ - { - "apyPercentage": "1.5797413696681861", - "dailyDistributedTokens": "250.0000128", - "token": { - "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", - "asset": "/src/libs/tokens/img/xvs.svg", - "decimals": 18, - "symbol": "XVS", - }, - "type": "rewardDistributor", - }, - ], - "borrowerCount": 35, - "cashTokens": "0", - "collateralFactor": 0.8, - "disabledTokenActions": [], - "exchangeRateVTokens": "37.63966306652044917955", - "isCollateralOfUser": false, - "liquidityCents": "0", - "reserveFactor": 0.1, - "reserveTokens": "21.269535066688975633", - "supplierCount": 25, - "supplyApyPercentage": "11.434048167920574", - "supplyBalanceCents": "3716729453.6129492577232450137", - "supplyBalanceTokens": "15115.4767135290690422233", - "supplyCapTokens": "1.15792089237316195423570985008687907853269984665640564039457584007913129639935e+59", - "supplyDistributions": [ - { - "apyPercentage": "1.5819817239252298", - "dailyDistributedTokens": "250.0000128", - "token": { - "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", - "asset": "/src/libs/tokens/img/xvs.svg", - "decimals": 18, - "symbol": "XVS", - }, - "type": "rewardDistributor", - }, - ], - "tokenPriceCents": "245889", - "userBorrowBalanceCents": "7.156865078267903019", - "userBorrowBalanceTokens": "0.000029106080704171", - "userPercentOfLimit": 0, - "userSupplyBalanceCents": "0", - "userSupplyBalanceTokens": "0", - "userWalletBalanceCents": "2458865411100005.406193157416225272", - "userWalletBalanceTokens": "9999900000.000021986315603448", - "vToken": { - "address": "0x162D005F0Fff510E54958Cfc5CF32A3180A84aab", - "decimals": 8, - "symbol": "vETH", - "underlyingToken": { - "address": "0x98f7A83361F7Ac8765CcEBAB1425da6b341958a7", - "asset": "/src/libs/tokens/img/eth.svg", - "decimals": 18, - "isNative": true, - "symbol": "ETH", - }, - }, - }, - { - "borrowApyPercentage": "180.75799822550164", - "borrowBalanceCents": "54206766464.991794941213834066224", - "borrowBalanceTokens": "1032405.72373577234796371", - "borrowCapTokens": "0", - "borrowDistributions": [ - { - "apyPercentage": "0.6478221277312901", - "dailyDistributedTokens": "1499.9999904", - "token": { - "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", - "asset": "/src/libs/tokens/img/xvs.svg", - "decimals": 18, - "symbol": "XVS", - }, - "type": "rewardDistributor", - }, - ], - "borrowerCount": 263, - "cashTokens": "5.556233762724731858", - "collateralFactor": 0.8, - "disabledTokenActions": [], - "exchangeRateVTokens": "5.63429988023545433776", - "isCollateralOfUser": true, - "liquidityCents": "291731.6894670817923653489952", - "reserveFactor": 0.25, - "reserveTokens": "187487.447405339178551222", - "supplierCount": 923, - "supplyApyPercentage": "157.57792083092227", - "supplyBalanceCents": "44362974574.359412320127072323564288", - "supplyBalanceTokens": "844923.83256419589412162352", - "supplyCapTokens": "1.15792089237316195423570985008687907853269984665640564039457584007913129639935e+59", - "supplyDistributions": [ - { - "apyPercentage": "0.7921351276470645", - "dailyDistributedTokens": "1499.9999904", - "token": { - "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", - "asset": "/src/libs/tokens/img/xvs.svg", - "decimals": 18, - "symbol": "XVS", - }, - "type": "rewardDistributor", - }, - ], - "tokenPriceCents": "52505.2944", - "userBorrowBalanceCents": "7073785.2980067928964376533856", - "userBorrowBalanceTokens": "134.725181123959051574", - "userPercentOfLimit": 0.12, - "userSupplyBalanceCents": "6813717433.5010155085170052265088", - "userSupplyBalanceTokens": "129772.007020705620660552", - "userWalletBalanceCents": "540373271888369.14416", - "userWalletBalanceTokens": "10291786343.9", - "vToken": { - "address": "0x2E7222e51c0f6e98610A1543Aa3836E092CDe62c", - "decimals": 8, - "symbol": "vBNB", - "underlyingToken": { - "address": "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE", - "asset": "/src/libs/tokens/img/bnb.svg", - "decimals": 18, - "isNative": true, - "symbol": "BNB", - }, - }, - }, - { - "borrowApyPercentage": "16.850090258739982", - "borrowBalanceCents": "266527277.02974427316207663041589", - "borrowBalanceTokens": "416884.364702270734855123", - "borrowCapTokens": "270000", - "borrowDistributions": [ - { - "apyPercentage": "0", - "dailyDistributedTokens": "0", - "token": { - "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", - "asset": "/src/libs/tokens/img/xvs.svg", - "decimals": 18, - "symbol": "XVS", - }, - "type": "rewardDistributor", - }, - ], - "borrowerCount": 68, - "cashTokens": "2259657.074761148481496107", - "collateralFactor": 0.6, - "disabledTokenActions": [], - "exchangeRateVTokens": "47.36910235297224095005", - "isCollateralOfUser": true, - "liquidityCents": "1444669788.91666196711723462774301", - "reserveFactor": 0.25, - "reserveTokens": "0", - "supplierCount": 274, - "supplyApyPercentage": "1.8360754649567212", - "supplyBalanceCents": "1711197065.9464062401284554003137589", - "supplyBalanceTokens": "2676541.43946341921611527123", - "supplyCapTokens": "3750000", - "supplyDistributions": [ - { - "apyPercentage": "0", - "dailyDistributedTokens": "0", - "token": { - "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", - "asset": "/src/libs/tokens/img/xvs.svg", - "decimals": 18, - "symbol": "XVS", - }, - "type": "rewardDistributor", - }, - ], - "tokenPriceCents": "639.33143", - "userBorrowBalanceCents": "0", - "userBorrowBalanceTokens": "0", - "userPercentOfLimit": 0, - "userSupplyBalanceCents": "0.70725092468251742803237", - "userSupplyBalanceTokens": "0.001106235188034659", - "userWalletBalanceCents": "6.3933143000000639331429999863775169751254466605905e+26", - "userWalletBalanceTokens": "1.000000000000009999999999997869261171021335e+24", - "vToken": { - "address": "0x6d6F697e34145Bb95c54E77482d97cc261Dc237E", - "decimals": 8, - "symbol": "vXVS", - "underlyingToken": { - "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", - "asset": "/src/libs/tokens/img/xvs.svg", - "decimals": 18, - "symbol": "XVS", - }, - }, - }, - { - "borrowApyPercentage": "2.0200781032592374", - "borrowBalanceCents": "743724749.881571973423", - "borrowBalanceTokens": "7437523.951581", - "borrowCapTokens": "0", - "borrowDistributions": [ - { - "apyPercentage": "16.981964056809385", - "dailyDistributedTokens": "499.9999968", - "token": { - "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", - "asset": "/src/libs/tokens/img/xvs.svg", - "decimals": 18, - "symbol": "XVS", - }, - "type": "rewardDistributor", - }, - { - "apyPercentage": "0.32051113933926345", - "token": { - "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", - "asset": "/src/libs/tokens/img/usdt.svg", - "decimals": 6, - "symbol": "USDT", - }, - "type": "prime", - }, - { - "apyPercentage": "0.20019958435848473", - "referenceValues": { - "userBorrowBalanceTokens": "10009.21", - "userSupplyBalanceTokens": "5003.94", - "userXvsStakedTokens": "3731.33", - }, - "token": { - "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", - "asset": "/src/libs/tokens/img/usdt.svg", - "decimals": 6, - "symbol": "USDT", - }, - "type": "primeSimulation", - }, - ], - "borrowerCount": 249, - "cashTokens": "1.0000736633870942814396398228131475074669e+34", - "collateralFactor": 0.8, - "disabledTokenActions": [], - "exchangeRateVTokens": "49.8066352191466231613", - "isCollateralOfUser": false, - "liquidityCents": "1.000036490649026183145198711400933542774047455327e+36", - "reserveFactor": 0.1, - "reserveTokens": "0", - "supplierCount": 670, - "supplyApyPercentage": "0", - "supplyBalanceCents": "1.00003649064902618314530970887489046343322854178897705712904885e+36", - "supplyBalanceTokens": "1.000073663387094281439750824413033895903139261475326095e+34", - "supplyCapTokens": "1.15792089237316195423570985008687907853269984665640564039457584007913129639935e+71", - "supplyDistributions": [ - { - "apyPercentage": "0", - "dailyDistributedTokens": "499.9999968", - "token": { - "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", - "asset": "/src/libs/tokens/img/xvs.svg", - "decimals": 18, - "symbol": "XVS", - }, - "type": "rewardDistributor", - }, - { - "apyPercentage": "0.2904197513866391", - "token": { - "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", - "asset": "/src/libs/tokens/img/usdt.svg", - "decimals": 6, - "symbol": "USDT", - }, - "type": "prime", - }, - { - "apyPercentage": "0.23026397657694986", - "referenceValues": { - "userBorrowBalanceTokens": "10009.21", - "userSupplyBalanceTokens": "5003.94", - "userXvsStakedTokens": "3731.33", - }, - "token": { - "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", - "asset": "/src/libs/tokens/img/usdt.svg", - "decimals": 6, - "symbol": "USDT", - }, - "type": "primeSimulation", - }, - ], - "tokenPriceCents": "99.996283", - "userBorrowBalanceCents": "0", - "userBorrowBalanceTokens": "0", - "userPercentOfLimit": 0, - "userSupplyBalanceCents": "0", - "userSupplyBalanceTokens": "0", - "userWalletBalanceCents": "9999928289169302585.414550788886", - "userWalletBalanceTokens": "100003000003203144.915042", - "vToken": { - "address": "0xb7526572FFE56AB9D7489838Bf2E18e3323b441A", - "decimals": 8, - "symbol": "vUSDT", - "underlyingToken": { - "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", - "asset": "/src/libs/tokens/img/usdt.svg", - "decimals": 6, - "symbol": "USDT", - }, - }, - }, - { - "borrowApyPercentage": "2.0200782609031798", - "borrowBalanceCents": "1562397934365776.075433634816", - "borrowBalanceTokens": "15624370577897.031296", - "borrowCapTokens": "0", - "borrowDistributions": [ - { - "apyPercentage": "0.000007467880158706", - "dailyDistributedTokens": "499.9999968", - "token": { - "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", - "asset": "/src/libs/tokens/img/xvs.svg", - "decimals": 18, - "symbol": "XVS", - }, - "type": "rewardDistributor", - }, - { - "apyPercentage": "0.32051113933926345", - "token": { - "address": "0x16227D60f7a0e586C66B005219dfc887D13C9531", - "asset": "/src/libs/tokens/img/usdc.svg", - "decimals": 6, - "symbol": "USDC", - }, - "type": "prime", - }, - { - "apyPercentage": "0.20019958435848473", - "referenceValues": { - "userBorrowBalanceTokens": "2405.43", - "userSupplyBalanceTokens": "13068.75", - "userXvsStakedTokens": "3265.3", - }, - "token": { - "address": "0x16227D60f7a0e586C66B005219dfc887D13C9531", - "asset": "/src/libs/tokens/img/usdc.svg", - "decimals": 6, - "symbol": "USDC", - }, - "type": "primeSimulation", - }, - ], - "borrowerCount": 229, - "cashTokens": "1.010176805025969148511141552e+21", - "collateralFactor": 0.81, - "disabledTokenActions": [], - "exchangeRateVTokens": "47.12928141003911013496", - "isCollateralOfUser": true, - "liquidityCents": "1.01015151019877129824366283301553792e+23", - "reserveFactor": 0.1, - "reserveTokens": "0", - "supplierCount": 534, - "supplyApyPercentage": "2.7328805884e-8", - "supplyBalanceCents": "1.0101515258227468345608256850251328456045167117888e+23", - "supplyBalanceTokens": "1.01017682065033591897223674983334867265528e+21", - "supplyCapTokens": "1.15792089237316195423570985008687907853269984665640564039457584007913129639935e+71", - "supplyDistributions": [ - { - "apyPercentage": "0", - "dailyDistributedTokens": "499.9999968", - "token": { - "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", - "asset": "/src/libs/tokens/img/xvs.svg", - "decimals": 18, - "symbol": "XVS", - }, - "type": "rewardDistributor", - }, - { - "apyPercentage": "0.2904197513866391", - "token": { - "address": "0x16227D60f7a0e586C66B005219dfc887D13C9531", - "asset": "/src/libs/tokens/img/usdc.svg", - "decimals": 6, - "symbol": "USDC", - }, - "type": "prime", - }, - { - "apyPercentage": "0.23026397657694986", - "referenceValues": { - "userBorrowBalanceTokens": "2405.43", - "userSupplyBalanceTokens": "13068.75", - "userXvsStakedTokens": "3265.3", - }, - "token": { - "address": "0x16227D60f7a0e586C66B005219dfc887D13C9531", - "asset": "/src/libs/tokens/img/usdc.svg", - "decimals": 6, - "symbol": "USDC", - }, - "type": "primeSimulation", - }, - ], - "tokenPriceCents": "99.997496", - "userBorrowBalanceCents": "0", - "userBorrowBalanceTokens": "0", - "userPercentOfLimit": 0, - "userSupplyBalanceCents": "0", - "userSupplyBalanceTokens": "0", - "userWalletBalanceCents": "0", - "userWalletBalanceTokens": "0", - "vToken": { - "address": "0xD5C4C2e2facBEB59D0216D0595d63FcDc6F9A1a7", - "decimals": 8, - "symbol": "vUSDC", - "underlyingToken": { - "address": "0x16227D60f7a0e586C66B005219dfc887D13C9531", - "asset": "/src/libs/tokens/img/usdc.svg", - "decimals": 6, - "symbol": "USDC", - }, - }, - }, - ], - "comptrollerAddress": "0xa258a693A403b7e98fd05EE9e1558C760308cFC7", - "description": "Fake pool description", - "isIsolated": false, - "name": "Fake pool name", - "userBorrowBalanceCents": "7073792.45487187219030093329978", - "userBorrowLimitCents": "5450973947.225162961623114638026462", - "userSupplyBalanceCents": "6813717434.20826643319952265454117", - }, -} -`; - -exports[`getLegacyPool - Feature enabled: Prime > filters out Prime distributions and simulations that are 0 1`] = ` -{ - "pool": { - "assets": [ - { - "borrowApyPercentage": "2.0200781054088957", - "borrowBalanceCents": "24663011775918.58670630114424219627258", - "borrowBalanceTokens": "246628588661.936163058800477859", - "borrowCapTokens": "1e-18", - "borrowDistributions": [ - { - "apyPercentage": "0", - "dailyDistributedTokens": "0", - "token": { - "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", - "asset": "/src/libs/tokens/img/xvs.svg", - "decimals": 18, - "symbol": "XVS", - }, - "type": "rewardDistributor", - }, - { - "apyPercentage": "0", - "token": { - "address": "0x8301F2213c0eeD49a7E28Ae4c3e91722919B8B47", - "asset": "/src/libs/tokens/img/busd.svg", - "decimals": 18, - "symbol": "BUSD", - }, - "type": "prime", - }, - ], - "borrowerCount": 438, - "cashTokens": "1.00000000080503544824460983238917793784e+21", - "collateralFactor": 0, - "disabledTokenActions": [ - "supply", - "borrow", - ], - "exchangeRateVTokens": "49.19405324154271215086", - "isCollateralOfUser": true, - "liquidityCents": "1.000006200805040439464388948970138750743214608e+23", - "reserveFactor": 1, - "reserveTokens": "0", - "supplierCount": 933, - "supplyApyPercentage": "0", - "supplyBalanceCents": "1.000006201051670556767362816225462034303610544746e+23", - "supplyBalanceTokens": "1.00000000105166403645033682413715238395883e+21", - "supplyCapTokens": "0", - "supplyDistributions": [ - { - "apyPercentage": "0", - "dailyDistributedTokens": "0", - "token": { - "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", - "asset": "/src/libs/tokens/img/xvs.svg", - "decimals": 18, - "symbol": "XVS", - }, - "type": "rewardDistributor", - }, - { - "apyPercentage": "0", - "token": { - "address": "0x8301F2213c0eeD49a7E28Ae4c3e91722919B8B47", - "asset": "/src/libs/tokens/img/busd.svg", - "decimals": 18, - "symbol": "BUSD", - }, - "type": "prime", - }, - ], - "tokenPriceCents": "100.00062", - "userBorrowBalanceCents": "1.02596026091418e-9", - "userBorrowBalanceTokens": "1.0259539e-11", - "userPercentOfLimit": 0, - "userSupplyBalanceCents": "0", - "userSupplyBalanceTokens": "0", - "userWalletBalanceCents": "0.00213276018859808651478", - "userWalletBalanceTokens": "0.000021327469655669", - "vToken": { - "address": "0x08e0A5575De71037aE36AbfAfb516595fE68e5e4", - "decimals": 8, - "symbol": "vBUSD", - "underlyingToken": { - "address": "0x8301F2213c0eeD49a7E28Ae4c3e91722919B8B47", - "asset": "/src/libs/tokens/img/busd.svg", - "decimals": 18, - "symbol": "BUSD", - }, - }, - }, - { - "borrowApyPercentage": "12.763322565556457", - "borrowBalanceCents": "3721959398.320962344455482972", - "borrowBalanceTokens": "15136.746248595758022748", - "borrowCapTokens": "0", - "borrowDistributions": [ - { - "apyPercentage": "1.5797413696681861", - "dailyDistributedTokens": "250.0000128", - "token": { - "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", - "asset": "/src/libs/tokens/img/xvs.svg", - "decimals": 18, - "symbol": "XVS", - }, - "type": "rewardDistributor", - }, - ], - "borrowerCount": 35, - "cashTokens": "0", - "collateralFactor": 0.8, - "disabledTokenActions": [], - "exchangeRateVTokens": "37.63966306652044917955", - "isCollateralOfUser": false, - "liquidityCents": "0", - "reserveFactor": 0.1, - "reserveTokens": "21.269535066688975633", - "supplierCount": 25, - "supplyApyPercentage": "11.434048167920574", - "supplyBalanceCents": "3716729453.6129492577232450137", - "supplyBalanceTokens": "15115.4767135290690422233", - "supplyCapTokens": "1.15792089237316195423570985008687907853269984665640564039457584007913129639935e+59", - "supplyDistributions": [ - { - "apyPercentage": "1.5819817239252298", - "dailyDistributedTokens": "250.0000128", - "token": { - "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", - "asset": "/src/libs/tokens/img/xvs.svg", - "decimals": 18, - "symbol": "XVS", - }, - "type": "rewardDistributor", - }, - ], - "tokenPriceCents": "245889", - "userBorrowBalanceCents": "7.156865078267903019", - "userBorrowBalanceTokens": "0.000029106080704171", - "userPercentOfLimit": 0, - "userSupplyBalanceCents": "0", - "userSupplyBalanceTokens": "0", - "userWalletBalanceCents": "2458865411100005.406193157416225272", - "userWalletBalanceTokens": "9999900000.000021986315603448", - "vToken": { - "address": "0x162D005F0Fff510E54958Cfc5CF32A3180A84aab", - "decimals": 8, - "symbol": "vETH", - "underlyingToken": { - "address": "0x98f7A83361F7Ac8765CcEBAB1425da6b341958a7", - "asset": "/src/libs/tokens/img/eth.svg", - "decimals": 18, - "isNative": true, - "symbol": "ETH", - }, - }, - }, - { - "borrowApyPercentage": "180.75799822550164", - "borrowBalanceCents": "54206766464.991794941213834066224", - "borrowBalanceTokens": "1032405.72373577234796371", - "borrowCapTokens": "0", - "borrowDistributions": [ - { - "apyPercentage": "0.6478221277312901", - "dailyDistributedTokens": "1499.9999904", - "token": { - "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", - "asset": "/src/libs/tokens/img/xvs.svg", - "decimals": 18, - "symbol": "XVS", - }, - "type": "rewardDistributor", - }, - ], - "borrowerCount": 263, - "cashTokens": "5.556233762724731858", - "collateralFactor": 0.8, - "disabledTokenActions": [], - "exchangeRateVTokens": "5.63429988023545433776", - "isCollateralOfUser": true, - "liquidityCents": "291731.6894670817923653489952", - "reserveFactor": 0.25, - "reserveTokens": "187487.447405339178551222", - "supplierCount": 923, - "supplyApyPercentage": "157.57792083092227", - "supplyBalanceCents": "44362974574.359412320127072323564288", - "supplyBalanceTokens": "844923.83256419589412162352", - "supplyCapTokens": "1.15792089237316195423570985008687907853269984665640564039457584007913129639935e+59", - "supplyDistributions": [ - { - "apyPercentage": "0.7921351276470645", - "dailyDistributedTokens": "1499.9999904", - "token": { - "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", - "asset": "/src/libs/tokens/img/xvs.svg", - "decimals": 18, - "symbol": "XVS", - }, - "type": "rewardDistributor", - }, - ], - "tokenPriceCents": "52505.2944", - "userBorrowBalanceCents": "7073785.2980067928964376533856", - "userBorrowBalanceTokens": "134.725181123959051574", - "userPercentOfLimit": 0.12, - "userSupplyBalanceCents": "6813717433.5010155085170052265088", - "userSupplyBalanceTokens": "129772.007020705620660552", - "userWalletBalanceCents": "540373271888369.14416", - "userWalletBalanceTokens": "10291786343.9", - "vToken": { - "address": "0x2E7222e51c0f6e98610A1543Aa3836E092CDe62c", - "decimals": 8, - "symbol": "vBNB", - "underlyingToken": { - "address": "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE", - "asset": "/src/libs/tokens/img/bnb.svg", - "decimals": 18, - "isNative": true, - "symbol": "BNB", - }, - }, - }, - { - "borrowApyPercentage": "16.850090258739982", - "borrowBalanceCents": "266527277.02974427316207663041589", - "borrowBalanceTokens": "416884.364702270734855123", - "borrowCapTokens": "270000", - "borrowDistributions": [ - { - "apyPercentage": "0", - "dailyDistributedTokens": "0", - "token": { - "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", - "asset": "/src/libs/tokens/img/xvs.svg", - "decimals": 18, - "symbol": "XVS", - }, - "type": "rewardDistributor", - }, - ], - "borrowerCount": 68, - "cashTokens": "2259657.074761148481496107", - "collateralFactor": 0.6, - "disabledTokenActions": [], - "exchangeRateVTokens": "47.36910235297224095005", - "isCollateralOfUser": true, - "liquidityCents": "1444669788.91666196711723462774301", - "reserveFactor": 0.25, - "reserveTokens": "0", - "supplierCount": 274, - "supplyApyPercentage": "1.8360754649567212", - "supplyBalanceCents": "1711197065.9464062401284554003137589", - "supplyBalanceTokens": "2676541.43946341921611527123", - "supplyCapTokens": "3750000", - "supplyDistributions": [ - { - "apyPercentage": "0", - "dailyDistributedTokens": "0", - "token": { - "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", - "asset": "/src/libs/tokens/img/xvs.svg", - "decimals": 18, - "symbol": "XVS", - }, - "type": "rewardDistributor", - }, - ], - "tokenPriceCents": "639.33143", - "userBorrowBalanceCents": "0", - "userBorrowBalanceTokens": "0", - "userPercentOfLimit": 0, - "userSupplyBalanceCents": "0.70725092468251742803237", - "userSupplyBalanceTokens": "0.001106235188034659", - "userWalletBalanceCents": "6.3933143000000639331429999863775169751254466605905e+26", - "userWalletBalanceTokens": "1.000000000000009999999999997869261171021335e+24", - "vToken": { - "address": "0x6d6F697e34145Bb95c54E77482d97cc261Dc237E", - "decimals": 8, - "symbol": "vXVS", - "underlyingToken": { - "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", - "asset": "/src/libs/tokens/img/xvs.svg", - "decimals": 18, - "symbol": "XVS", - }, - }, - }, - { - "borrowApyPercentage": "2.0200781032592374", - "borrowBalanceCents": "743724749.881571973423", - "borrowBalanceTokens": "7437523.951581", - "borrowCapTokens": "0", - "borrowDistributions": [ - { - "apyPercentage": "16.981964056809385", - "dailyDistributedTokens": "499.9999968", - "token": { - "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", - "asset": "/src/libs/tokens/img/xvs.svg", - "decimals": 18, - "symbol": "XVS", - }, - "type": "rewardDistributor", - }, - { - "apyPercentage": "0", - "token": { - "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", - "asset": "/src/libs/tokens/img/usdt.svg", - "decimals": 6, - "symbol": "USDT", - }, - "type": "prime", - }, - ], - "borrowerCount": 249, - "cashTokens": "1.0000736633870942814396398228131475074669e+34", - "collateralFactor": 0.8, - "disabledTokenActions": [], - "exchangeRateVTokens": "49.8066352191466231613", - "isCollateralOfUser": false, - "liquidityCents": "1.000036490649026183145198711400933542774047455327e+36", - "reserveFactor": 0.1, - "reserveTokens": "0", - "supplierCount": 670, - "supplyApyPercentage": "0", - "supplyBalanceCents": "1.00003649064902618314530970887489046343322854178897705712904885e+36", - "supplyBalanceTokens": "1.000073663387094281439750824413033895903139261475326095e+34", - "supplyCapTokens": "1.15792089237316195423570985008687907853269984665640564039457584007913129639935e+71", - "supplyDistributions": [ - { - "apyPercentage": "0", - "dailyDistributedTokens": "499.9999968", - "token": { - "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", - "asset": "/src/libs/tokens/img/xvs.svg", - "decimals": 18, - "symbol": "XVS", - }, - "type": "rewardDistributor", - }, - { - "apyPercentage": "0", - "token": { - "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", - "asset": "/src/libs/tokens/img/usdt.svg", - "decimals": 6, - "symbol": "USDT", - }, - "type": "prime", - }, - ], - "tokenPriceCents": "99.996283", - "userBorrowBalanceCents": "0", - "userBorrowBalanceTokens": "0", - "userPercentOfLimit": 0, - "userSupplyBalanceCents": "0", - "userSupplyBalanceTokens": "0", - "userWalletBalanceCents": "9999928289169302585.414550788886", - "userWalletBalanceTokens": "100003000003203144.915042", - "vToken": { - "address": "0xb7526572FFE56AB9D7489838Bf2E18e3323b441A", - "decimals": 8, - "symbol": "vUSDT", - "underlyingToken": { - "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", - "asset": "/src/libs/tokens/img/usdt.svg", - "decimals": 6, - "symbol": "USDT", - }, - }, - }, - { - "borrowApyPercentage": "2.0200782609031798", - "borrowBalanceCents": "1562397934365776.075433634816", - "borrowBalanceTokens": "15624370577897.031296", - "borrowCapTokens": "0", - "borrowDistributions": [ - { - "apyPercentage": "0.000007467880158706", - "dailyDistributedTokens": "499.9999968", - "token": { - "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", - "asset": "/src/libs/tokens/img/xvs.svg", - "decimals": 18, - "symbol": "XVS", - }, - "type": "rewardDistributor", - }, - { - "apyPercentage": "0", - "token": { - "address": "0x16227D60f7a0e586C66B005219dfc887D13C9531", - "asset": "/src/libs/tokens/img/usdc.svg", - "decimals": 6, - "symbol": "USDC", - }, - "type": "prime", - }, - ], - "borrowerCount": 229, - "cashTokens": "1.010176805025969148511141552e+21", - "collateralFactor": 0.81, - "disabledTokenActions": [], - "exchangeRateVTokens": "47.12928141003911013496", - "isCollateralOfUser": true, - "liquidityCents": "1.01015151019877129824366283301553792e+23", - "reserveFactor": 0.1, - "reserveTokens": "0", - "supplierCount": 534, - "supplyApyPercentage": "2.7328805884e-8", - "supplyBalanceCents": "1.0101515258227468345608256850251328456045167117888e+23", - "supplyBalanceTokens": "1.01017682065033591897223674983334867265528e+21", - "supplyCapTokens": "1.15792089237316195423570985008687907853269984665640564039457584007913129639935e+71", - "supplyDistributions": [ - { - "apyPercentage": "0", - "dailyDistributedTokens": "499.9999968", - "token": { - "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", - "asset": "/src/libs/tokens/img/xvs.svg", - "decimals": 18, - "symbol": "XVS", - }, - "type": "rewardDistributor", - }, - { - "apyPercentage": "0", - "token": { - "address": "0x16227D60f7a0e586C66B005219dfc887D13C9531", - "asset": "/src/libs/tokens/img/usdc.svg", - "decimals": 6, - "symbol": "USDC", - }, - "type": "prime", - }, - ], - "tokenPriceCents": "99.997496", - "userBorrowBalanceCents": "0", - "userBorrowBalanceTokens": "0", - "userPercentOfLimit": 0, - "userSupplyBalanceCents": "0", - "userSupplyBalanceTokens": "0", - "userWalletBalanceCents": "0", - "userWalletBalanceTokens": "0", - "vToken": { - "address": "0xD5C4C2e2facBEB59D0216D0595d63FcDc6F9A1a7", - "decimals": 8, - "symbol": "vUSDC", - "underlyingToken": { - "address": "0x16227D60f7a0e586C66B005219dfc887D13C9531", - "asset": "/src/libs/tokens/img/usdc.svg", - "decimals": 6, - "symbol": "USDC", - }, - }, - }, - ], - "comptrollerAddress": "0xa258a693A403b7e98fd05EE9e1558C760308cFC7", - "description": "Fake pool description", - "isIsolated": false, - "name": "Fake pool name", - "userBorrowBalanceCents": "7073792.45487187219030093329978", - "userBorrowLimitCents": "5450973947.225162961623114638026462", - "userSupplyBalanceCents": "6813717434.20826643319952265454117", - }, -} -`; diff --git a/apps/evm/src/clients/api/queries/getLegacyPool/__tests__/index.spec.ts b/apps/evm/src/clients/api/queries/getLegacyPool/__tests__/index.spec.ts deleted file mode 100644 index e4bdecaec7..0000000000 --- a/apps/evm/src/clients/api/queries/getLegacyPool/__tests__/index.spec.ts +++ /dev/null @@ -1,34 +0,0 @@ -import fakeAccountAddress from '__mocks__/models/address'; -import tokens, { vai, xvs } from '__mocks__/models/tokens'; - -import { apiPoolsData } from '__mocks__/models/pools'; -import { ChainId } from 'types'; -import getLegacyPool from '..'; -import { - fakeLegacyPoolComptrollerContract, - fakeVaiControllerContract, - fakeVenusLensContract, -} from '../__testUtils__/fakeData'; - -describe('getLegacyPool', () => { - it('returns core pool in the correct format', async () => { - const response = await getLegacyPool({ - legacyPoolData: apiPoolsData.find(p => !p.isIsolated)!, - chainId: ChainId.BSC_TESTNET, - blocksPerDay: 28800, - name: 'Fake pool name', - description: 'Fake pool description', - xvs, - vai, - tokens, - accountAddress: fakeAccountAddress, - legacyPoolComptrollerContract: fakeLegacyPoolComptrollerContract, - venusLensContract: fakeVenusLensContract, - vaiControllerContract: fakeVaiControllerContract, - }); - - // Check VAI interests were accrued before being fetched - expect(fakeVaiControllerContract.callStatic.accrueVAIInterest).toHaveBeenCalledTimes(1); - expect(response).toMatchSnapshot(); - }); -}); diff --git a/apps/evm/src/clients/api/queries/getLegacyPool/__tests__/indexPrime.spec.ts b/apps/evm/src/clients/api/queries/getLegacyPool/__tests__/indexPrime.spec.ts deleted file mode 100644 index 49bb757534..0000000000 --- a/apps/evm/src/clients/api/queries/getLegacyPool/__tests__/indexPrime.spec.ts +++ /dev/null @@ -1,119 +0,0 @@ -import { BigNumber as BN } from 'ethers'; -import type Vi from 'vitest'; - -import fakePrimeContractResponses from '__mocks__/contracts/prime'; -import fakeAccountAddress from '__mocks__/models/address'; -import tokens, { vai, xvs } from '__mocks__/models/tokens'; - -import { type UseIsFeatureEnabled, useIsFeatureEnabled } from 'hooks/useIsFeatureEnabled'; -import type { Prime } from 'libs/contracts'; -import { ChainId } from 'types'; - -import { apiPoolsData } from '__mocks__/models/pools'; -import getLegacyPool from '..'; -import { - fakeLegacyPoolComptrollerContract, - fakeVaiControllerContract, - fakeVenusLensContract, -} from '../__testUtils__/fakeData'; - -describe('getLegacyPool - Feature enabled: Prime', () => { - beforeEach(() => { - (useIsFeatureEnabled as Vi.Mock).mockImplementation( - ({ name }: UseIsFeatureEnabled) => name === 'prime', - ); - }); - - it('fetches and formats Prime distributions and Prime distribution simulations if user is Prime', async () => { - const fakePrimeContract = { - tokens: async () => fakePrimeContractResponses.tokens, - MINIMUM_STAKED_XVS: async () => fakePrimeContractResponses.MINIMUM_STAKED_XVS, - getAllMarkets: async () => fakePrimeContractResponses.getAllMarkets, - estimateAPR: async () => fakePrimeContractResponses.estimateAPR, - calculateAPR: async () => fakePrimeContractResponses.calculateAPR, - } as unknown as Prime; - - const response = await getLegacyPool({ - legacyPoolData: apiPoolsData.find(p => !p.isIsolated)!, - chainId: ChainId.BSC_TESTNET, - blocksPerDay: 28800, - name: 'Fake pool name', - description: 'Fake pool description', - xvs, - vai, - tokens, - accountAddress: fakeAccountAddress, - legacyPoolComptrollerContract: fakeLegacyPoolComptrollerContract, - venusLensContract: fakeVenusLensContract, - vaiControllerContract: fakeVaiControllerContract, - primeContract: fakePrimeContract, - }); - - expect(response).toMatchSnapshot(); - }); - - it('does not fetch Prime distributions if user is not Prime', async () => { - const fakePrimeContract = { - tokens: async () => ({ - ...fakePrimeContractResponses.tokens, - exists: false, - }), - MINIMUM_STAKED_XVS: async () => fakePrimeContractResponses.MINIMUM_STAKED_XVS, - getAllMarkets: async () => fakePrimeContractResponses.getAllMarkets, - estimateAPR: async () => fakePrimeContractResponses.estimateAPR, - calculateAPR: async () => fakePrimeContractResponses.calculateAPR, - } as unknown as Prime; - - const response = await getLegacyPool({ - legacyPoolData: apiPoolsData.find(p => !p.isIsolated)!, - chainId: ChainId.BSC_TESTNET, - blocksPerDay: 28800, - name: 'Fake pool name', - description: 'Fake pool description', - xvs, - vai, - tokens, - accountAddress: fakeAccountAddress, - legacyPoolComptrollerContract: fakeLegacyPoolComptrollerContract, - venusLensContract: fakeVenusLensContract, - vaiControllerContract: fakeVaiControllerContract, - primeContract: fakePrimeContract, - }); - - expect(response).toMatchSnapshot(); - }); - - it('filters out Prime distributions and simulations that are 0', async () => { - const fakePrimeContract = { - tokens: async () => fakePrimeContractResponses.tokens, - MINIMUM_STAKED_XVS: async () => fakePrimeContractResponses.MINIMUM_STAKED_XVS, - getAllMarkets: async () => fakePrimeContractResponses.getAllMarkets, - estimateAPR: async () => ({ - borrowAPR: BN.from(0), - supplyAPR: BN.from(0), - }), - calculateAPR: async () => ({ - borrowAPR: BN.from(0), - supplyAPR: BN.from(0), - }), - } as unknown as Prime; - - const response = await getLegacyPool({ - legacyPoolData: apiPoolsData.find(p => !p.isIsolated)!, - chainId: ChainId.BSC_TESTNET, - blocksPerDay: 28800, - name: 'Fake pool name', - description: 'Fake pool description', - xvs, - vai, - tokens, - accountAddress: fakeAccountAddress, - legacyPoolComptrollerContract: fakeLegacyPoolComptrollerContract, - venusLensContract: fakeVenusLensContract, - vaiControllerContract: fakeVaiControllerContract, - primeContract: fakePrimeContract, - }); - - expect(response).toMatchSnapshot(); - }); -}); diff --git a/apps/evm/src/clients/api/queries/getLegacyPool/formatToPool/formatDistributions.ts b/apps/evm/src/clients/api/queries/getLegacyPool/formatToPool/formatDistributions.ts deleted file mode 100644 index 568ee063c4..0000000000 --- a/apps/evm/src/clients/api/queries/getLegacyPool/formatToPool/formatDistributions.ts +++ /dev/null @@ -1,51 +0,0 @@ -import type BigNumber from 'bignumber.js'; - -import type { AssetDistribution, Token, VToken } from 'types'; -import { calculateDailyTokenRate, formatRewardDistribution } from 'utilities'; - -export interface FormatDistributionsInput { - xvsSpeedMantissa: BigNumber; - balanceDollars: BigNumber; - xvsPriceDollars: BigNumber; - xvs: Token; - vToken: VToken; - blocksPerDay?: number; - primeApy?: BigNumber; -} - -export const formatDistributions = ({ - blocksPerDay, - xvsSpeedMantissa, - balanceDollars, - xvsPriceDollars, - xvs, - vToken, - primeApy, -}: FormatDistributionsInput) => { - const dailyDistributedXvs = calculateDailyTokenRate({ - rateMantissa: xvsSpeedMantissa, - decimals: xvs.decimals, - blocksPerDay, - }); - - const xvsDistribution = formatRewardDistribution({ - rewardToken: xvs, - rewardTokenPriceDollars: xvsPriceDollars, - dailyDistributedRewardTokens: dailyDistributedXvs, - balanceDollars, - }); - - const distributions: AssetDistribution[] = [xvsDistribution]; - - if (primeApy) { - const primeDistribution: AssetDistribution = { - type: 'prime', - apyPercentage: primeApy, - token: vToken.underlyingToken, - }; - - distributions.push(primeDistribution); - } - - return distributions; -}; diff --git a/apps/evm/src/clients/api/queries/getLegacyPool/formatToPool/index.ts b/apps/evm/src/clients/api/queries/getLegacyPool/formatToPool/index.ts deleted file mode 100644 index 568c28c286..0000000000 --- a/apps/evm/src/clients/api/queries/getLegacyPool/formatToPool/index.ts +++ /dev/null @@ -1,300 +0,0 @@ -import BigNumber from 'bignumber.js'; - -import { COMPOUND_DECIMALS } from 'constants/compoundMantissa'; -import type { VenusLens } from 'libs/contracts'; -import type { Asset, ChainId, Market, Pool, PrimeApy, Token, VToken } from 'types'; -import { - addUserPropsToPool, - calculateDailyTokenRate, - calculateYearlyPercentageRate, - convertDollarsToCents, - convertFactorFromSmartContract, - convertMantissaToTokens, - convertPriceMantissaToDollars, - getDisabledTokenActions, -} from 'utilities'; -import findTokenByAddress from 'utilities/findTokenByAddress'; -import { formatDistributions } from './formatDistributions'; - -export interface FormatToPoolInput { - chainId: ChainId; - name: string; - xvs: Token; - vai?: Token; - tokens: Token[]; - description: string; - comptrollerContractAddress: string; - legacyPoolMarkets: Market[]; - xvsPriceMantissa: BigNumber; - primeApyMap: Map; - userCollateralizedVTokenAddresses?: string[]; - userVTokenBalances?: Awaited>; - userVaiBorrowBalanceMantissa?: BigNumber; - blocksPerDay?: number; -} - -export const formatToPool = ({ - chainId, - blocksPerDay, - name, - xvs, - vai, - tokens, - description, - comptrollerContractAddress, - legacyPoolMarkets, - xvsPriceMantissa, - userCollateralizedVTokenAddresses, - userVTokenBalances, - userVaiBorrowBalanceMantissa, - primeApyMap, -}: FormatToPoolInput) => { - const assets: Asset[] = []; - - legacyPoolMarkets.forEach((legacyPoolMarket, index) => { - const { underlyingTokenAddress } = legacyPoolMarket; - - const underlyingToken = findTokenByAddress({ - tokens, - address: underlyingTokenAddress, - }); - - if (!underlyingToken) { - return; - } - - const vToken: VToken = { - decimals: 8, - address: legacyPoolMarket.vTokenAddress, - symbol: `v${underlyingToken.symbol}`, - underlyingToken, - }; - - const { - underlyingTokenPriceMantissa, - borrowCapsMantissa, - supplyCapsMantissa, - exchangeRateMantissa, - supplyRatePerBlockOrTimestamp, - borrowRatePerBlockOrTimestamp, - totalSupplyMantissa, - totalBorrowsMantissa, - } = legacyPoolMarket; - - const userVTokenBalancesResult = userVTokenBalances?.[index]; - - const tokenPriceDollars = convertPriceMantissaToDollars({ - priceMantissa: underlyingTokenPriceMantissa, - decimals: underlyingToken.decimals, - }); - - const tokenPriceCents = convertDollarsToCents(tokenPriceDollars); - - const borrowCapTokens = convertMantissaToTokens({ - value: borrowCapsMantissa, - token: vToken.underlyingToken, - }); - - const supplyCapTokens = convertMantissaToTokens({ - value: supplyCapsMantissa, - token: vToken.underlyingToken, - }); - - const reserveFactor = convertFactorFromSmartContract({ - factor: legacyPoolMarket.reserveFactorMantissa, - }); - - const collateralFactor = convertFactorFromSmartContract({ - factor: legacyPoolMarket.collateralFactorMantissa, - }); - - const cashTokens = convertMantissaToTokens({ - value: legacyPoolMarket.cashMantissa, - token: vToken.underlyingToken, - }); - - const liquidityCents = cashTokens.multipliedBy(tokenPriceCents); - - const reserveTokens = convertMantissaToTokens({ - value: legacyPoolMarket.totalReservesMantissa, - token: vToken.underlyingToken, - }); - - const exchangeRateVTokens = exchangeRateMantissa.isEqualTo(0) - ? new BigNumber(0) - : new BigNumber(1).div( - exchangeRateMantissa.div( - 10 ** (COMPOUND_DECIMALS + vToken.underlyingToken.decimals - vToken.decimals), - ), - ); - - const supplyDailyPercentageRate = calculateDailyTokenRate({ - rateMantissa: supplyRatePerBlockOrTimestamp, - blocksPerDay, - }); - - const supplyApyPercentage = calculateYearlyPercentageRate({ - dailyPercentageRate: supplyDailyPercentageRate, - }); - - const borrowDailyPercentageRate = calculateDailyTokenRate({ - rateMantissa: borrowRatePerBlockOrTimestamp, - blocksPerDay, - }); - - const borrowApyPercentage = calculateYearlyPercentageRate({ - dailyPercentageRate: borrowDailyPercentageRate, - }); - - const supplyBalanceVTokens = convertMantissaToTokens({ - value: totalSupplyMantissa, - token: vToken, - }); - const supplyBalanceTokens = supplyBalanceVTokens.div(exchangeRateVTokens); - const supplyBalanceDollars = supplyBalanceTokens.multipliedBy(tokenPriceDollars); - const supplyBalanceCents = convertDollarsToCents(supplyBalanceDollars); - - const borrowBalanceTokens = convertMantissaToTokens({ - value: totalBorrowsMantissa, - token: vToken.underlyingToken, - }); - const borrowBalanceDollars = borrowBalanceTokens.multipliedBy(tokenPriceDollars); - const borrowBalanceCents = convertDollarsToCents(borrowBalanceDollars); - - const xvsPriceDollars = convertPriceMantissaToDollars({ - priceMantissa: xvsPriceMantissa, - decimals: xvs.decimals, - }); - - // the legacy pool markets only have a single reward: XVS - const borrowDistributions = formatDistributions({ - xvsSpeedMantissa: legacyPoolMarket.rewardsDistributors[0].borrowSpeed, - balanceDollars: borrowBalanceDollars, - xvsPriceDollars, - xvs, - vToken, - primeApy: primeApyMap.get(vToken.address)?.borrowApy, - blocksPerDay, - }); - - // the legacy pool markets only have a single reward: XVS - const supplyDistributions = formatDistributions({ - xvsSpeedMantissa: legacyPoolMarket.rewardsDistributors[0].supplySpeed, - balanceDollars: supplyBalanceDollars, - xvsPriceDollars, - xvs, - vToken, - primeApy: primeApyMap.get(vToken.address)?.supplyApy, - blocksPerDay, - }); - - const isCollateralOfUser = (userCollateralizedVTokenAddresses || []).includes( - legacyPoolMarket.vTokenAddress, - ); - const userSupplyBalanceTokens = userVTokenBalancesResult?.balanceOfUnderlying - ? convertMantissaToTokens({ - value: new BigNumber(userVTokenBalancesResult.balanceOfUnderlying.toString()), - token: vToken.underlyingToken, - }) - : new BigNumber(0); - - const userBorrowBalanceTokens = userVTokenBalancesResult?.balanceOfUnderlying - ? convertMantissaToTokens({ - value: new BigNumber(userVTokenBalancesResult.borrowBalanceCurrent.toString()), - token: vToken.underlyingToken, - }) - : new BigNumber(0); - - const userSupplyBalanceCents = userSupplyBalanceTokens.multipliedBy(tokenPriceCents); - const userBorrowBalanceCents = userBorrowBalanceTokens.multipliedBy(tokenPriceCents); - - const userWalletBalanceTokens = userVTokenBalancesResult?.tokenBalance - ? convertMantissaToTokens({ - value: new BigNumber(userVTokenBalancesResult.tokenBalance.toString()), - token: vToken.underlyingToken, - }) - : new BigNumber(0); - const userWalletBalanceCents = userWalletBalanceTokens.multipliedBy(tokenPriceCents); - - const disabledTokenActions = getDisabledTokenActions({ - bitmask: legacyPoolMarket.pausedActionsBitmap, - tokenAddresses: [vToken.address, vToken.underlyingToken.address], - chainId, - }); - - const asset: Asset = { - vToken, - disabledTokenActions, - tokenPriceCents, - reserveFactor, - collateralFactor, - liquidityCents, - reserveTokens, - cashTokens, - borrowCapTokens, - supplyCapTokens, - exchangeRateVTokens, - borrowApyPercentage, - supplyApyPercentage, - supplyBalanceTokens, - supplyBalanceCents, - borrowBalanceTokens, - borrowBalanceCents, - supplyDistributions, - borrowDistributions, - supplierCount: legacyPoolMarket?.supplierCount || 0, - borrowerCount: legacyPoolMarket?.borrowerCount || 0, - // User-specific props - userSupplyBalanceTokens, - userSupplyBalanceCents, - userBorrowBalanceTokens, - userBorrowBalanceCents, - userWalletBalanceTokens, - userWalletBalanceCents, - // This will be calculated after all assets have been formatted - userPercentOfLimit: 0, - isCollateralOfUser, - }; - - assets.push(asset); - }); - - const pool: Pool = addUserPropsToPool({ - name, - description, - comptrollerAddress: comptrollerContractAddress, - isIsolated: false, - assets, - }); - - // Add user VAI loan to user borrow balance - if (pool.userBorrowBalanceCents && userVaiBorrowBalanceMantissa) { - const userVaiBorrowBalanceCents = convertMantissaToTokens({ - value: userVaiBorrowBalanceMantissa, - token: vai, - }) // Convert VAI to dollar cents (we assume 1 VAI = 1 dollar) - .times(100); - - pool.userBorrowBalanceCents = pool.userBorrowBalanceCents.plus(userVaiBorrowBalanceCents); - } - - // Calculate userPercentOfLimit for each asset - const formattedAssets: Asset[] = assets.map(asset => ({ - ...asset, - userPercentOfLimit: - asset.userBorrowBalanceCents?.isGreaterThan(0) && pool.userBorrowLimitCents?.isGreaterThan(0) - ? new BigNumber(asset.userBorrowBalanceCents) - .times(100) - .div(pool.userBorrowLimitCents) - .dp(2) - .toNumber() - : 0, - })); - - return { - ...pool, - assets: formattedAssets, - }; -}; - -export default formatToPool; diff --git a/apps/evm/src/clients/api/queries/getLegacyPool/index.ts b/apps/evm/src/clients/api/queries/getLegacyPool/index.ts deleted file mode 100644 index 6a04ecb153..0000000000 --- a/apps/evm/src/clients/api/queries/getLegacyPool/index.ts +++ /dev/null @@ -1,145 +0,0 @@ -import BigNumber from 'bignumber.js'; - -import type { PrimeApy } from 'types'; -import { - appendPrimeSimulationDistributions, - areAddressesEqual, - convertAprBipsToApy, - extractSettledPromiseValue, -} from 'utilities'; - -import { VError, logError } from 'libs/errors'; -import { formatToPool } from './formatToPool'; -import type { GetLegacyPoolInput, GetLegacyPoolOutput } from './types'; - -export type { GetLegacyPoolInput, GetLegacyPoolOutput } from './types'; - -const getLegacyPool = async ({ - legacyPoolData, - chainId, - blocksPerDay, - name, - description, - xvs, - vai, - tokens, - accountAddress, - legacyPoolComptrollerContract, - venusLensContract, - vaiControllerContract, - primeContract, -}: GetLegacyPoolInput): Promise => { - const [ - primeVTokenAddressesResult, - primeMinimumXvsToStakeResult, - userPrimeTokenResult, - assetsInResult, - _accrueVaiInterestResult, - vaiRepayAmountResult, - ] = await Promise.allSettled([ - // Prime related calls - primeContract?.getAllMarkets(), - primeContract?.MINIMUM_STAKED_XVS(), - // Account related calls - accountAddress ? primeContract?.tokens(accountAddress) : undefined, - accountAddress ? legacyPoolComptrollerContract.getAssetsIn(accountAddress) : undefined, - // Call (statically) accrueVAIInterest to calculate past accrued interests before fetching all - // interests. Since multicall will batch these requests, the call to accrueVAIInterest and - // getVAIRepayAmount will happen in the same request (thus making the accrual possible) - accountAddress ? vaiControllerContract.callStatic.accrueVAIInterest() : undefined, - accountAddress ? vaiControllerContract.getVAIRepayAmount(accountAddress) : undefined, - ]); - - const xvsMarket = legacyPoolData.markets.find(m => - areAddressesEqual(m.underlyingTokenAddress || '', xvs.address), - ); - if (!xvsMarket) { - logError('No XVS market found'); - throw new VError({ - type: 'unexpected', - code: 'somethingWentWrong', - }); - } - - const xvsPriceMantissa = new BigNumber(xvsMarket.underlyingTokenPriceMantissa); - - const vTokenAddresses = legacyPoolData.markets.map(m => m.vTokenAddress); - const primeVTokenAddresses = extractSettledPromiseValue(primeVTokenAddressesResult) || []; - const primeMinimumXvsToStakeMantissa = extractSettledPromiseValue(primeMinimumXvsToStakeResult); - const isUserPrime = extractSettledPromiseValue(userPrimeTokenResult)?.exists || false; - - // Fetch Prime distributions - const primeAprPromises = - primeContract && isUserPrime - ? Promise.allSettled( - accountAddress - ? primeVTokenAddresses.map(primeVTokenAddress => - primeContract.calculateAPR(primeVTokenAddress, accountAddress), - ) - : [], - ) - : undefined; - - const primeAprResults = (await primeAprPromises) || []; - - const primeApyMap = new Map(); - primeAprResults.forEach((primeAprResult, index) => { - if (primeAprResult.status !== 'fulfilled') { - return; - } - - const primeApr = primeAprResult.value; - - const apys: PrimeApy = { - borrowApy: convertAprBipsToApy({ aprBips: primeApr?.borrowAPR.toString() || '0' }), - supplyApy: convertAprBipsToApy({ aprBips: primeApr?.supplyAPR.toString() || '0' }), - }; - - primeApyMap.set(primeVTokenAddresses[index], apys); - }); - - const vaiRepayAmountMantissa = extractSettledPromiseValue(vaiRepayAmountResult); - - // Fetch user vToken balances - const userVTokenBalancesResults = await (accountAddress - ? venusLensContract.callStatic.vTokenBalancesAll(vTokenAddresses, accountAddress) - : undefined); - - const pool = formatToPool({ - chainId, - blocksPerDay, - name, - xvs, - vai, - tokens, - description, - comptrollerContractAddress: legacyPoolComptrollerContract.address, - legacyPoolMarkets: legacyPoolData.markets, - xvsPriceMantissa, - userCollateralizedVTokenAddresses: extractSettledPromiseValue(assetsInResult), - userVTokenBalances: userVTokenBalancesResults, - userVaiBorrowBalanceMantissa: vaiRepayAmountMantissa - ? new BigNumber(vaiRepayAmountMantissa.toString()) - : undefined, - primeApyMap, - }); - - // Fetch Prime simulations and add them to distributions - if (primeContract && primeMinimumXvsToStakeMantissa) { - await appendPrimeSimulationDistributions({ - assets: pool.assets, - primeContract, - primeVTokenAddresses, - accountAddress, - primeMinimumXvsToStakeMantissa: new BigNumber(primeMinimumXvsToStakeMantissa.toString()), - xvs, - chainId, - }); - } - - return { - pool, - }; -}; - -export default getLegacyPool; diff --git a/apps/evm/src/clients/api/queries/getLegacyPool/types.ts b/apps/evm/src/clients/api/queries/getLegacyPool/types.ts deleted file mode 100644 index be0a5ea3eb..0000000000 --- a/apps/evm/src/clients/api/queries/getLegacyPool/types.ts +++ /dev/null @@ -1,23 +0,0 @@ -import type { LegacyPoolComptroller, Prime, VaiController, VenusLens } from 'libs/contracts'; -import type { ChainId, Pool, Token } from 'types'; -import type { GetApiPoolsOutput } from '../getApiPools'; - -export interface GetLegacyPoolInput { - legacyPoolData: GetApiPoolsOutput['pools'][number]; - chainId: ChainId; - blocksPerDay: number; - name: string; - description: string; - xvs: Token; - vai: Token; - tokens: Token[]; - legacyPoolComptrollerContract: LegacyPoolComptroller; - venusLensContract: VenusLens; - vaiControllerContract: VaiController; - primeContract?: Prime; - accountAddress?: string; -} - -export interface GetLegacyPoolOutput { - pool: Pool; -} diff --git a/apps/evm/src/clients/api/queries/getLegacyPool/useGetLegacyPool.ts b/apps/evm/src/clients/api/queries/getLegacyPool/useGetLegacyPool.ts deleted file mode 100644 index fa2a7e735d..0000000000 --- a/apps/evm/src/clients/api/queries/getLegacyPool/useGetLegacyPool.ts +++ /dev/null @@ -1,117 +0,0 @@ -import { type QueryObserverOptions, useQuery } from '@tanstack/react-query'; - -import getLegacyPool, { - type GetLegacyPoolInput, - type GetLegacyPoolOutput, -} from 'clients/api/queries/getLegacyPool'; -import FunctionKey from 'constants/functionKey'; -import { useGetChainMetadata } from 'hooks/useGetChainMetadata'; -import { useIsFeatureEnabled } from 'hooks/useIsFeatureEnabled'; -import { - useGetLegacyPoolComptrollerContract, - useGetPrimeContract, - useGetResilientOracleContract, - useGetVaiControllerContract, - useGetVenusLensContract, -} from 'libs/contracts'; -import { useGetToken, useGetTokens } from 'libs/tokens'; -import { useTranslation } from 'libs/translations'; -import { useChainId } from 'libs/wallet'; -import type { ChainId } from 'types'; -import { callOrThrow, generatePseudoRandomRefetchInterval } from 'utilities'; -import useGetApiPools from '../getApiPools/useGetApiPools'; - -type TrimmedInput = Omit< - GetLegacyPoolInput, - | 'chainId' - | 'blocksPerDay' - | 'provider' - | 'name' - | 'description' - | 'venusLensContract' - | 'legacyPoolComptrollerContract' - | 'resilientOracleContract' - | 'vaiControllerContract' - | 'vTreasuryContractAddress' - | 'vai' - | 'xvs' - | 'tokens' - | 'legacyPoolData' ->; - -export type UseGetLegacyPoolQueryKey = [ - FunctionKey.GET_LEGACY_POOL, - TrimmedInput & { chainId: ChainId }, - additionalQueryKey?: 'PrimeCalculator', -]; - -type Options = QueryObserverOptions< - GetLegacyPoolOutput, - Error, - GetLegacyPoolOutput, - GetLegacyPoolOutput, - UseGetLegacyPoolQueryKey ->; - -const refetchInterval = generatePseudoRandomRefetchInterval(); - -const useGetLegacyPool = (input?: TrimmedInput, options?: Partial) => { - const { data: apiPoolsData } = useGetApiPools(); - const { chainId } = useChainId(); - const { blocksPerDay } = useGetChainMetadata(); - - const { t } = useTranslation(); - - const xvs = useGetToken({ symbol: 'XVS' }); - const vai = useGetToken({ symbol: 'VAI' }); - const tokens = useGetTokens(); - const isPrimeEnabled = useIsFeatureEnabled({ - name: 'prime', - }); - - const legacyPoolComptrollerContract = useGetLegacyPoolComptrollerContract(); - const venusLensContract = useGetVenusLensContract(); - const resilientOracleContract = useGetResilientOracleContract(); - const vaiControllerContract = useGetVaiControllerContract(); - const primeContract = useGetPrimeContract(); - - const isQueryEnabled = - !!legacyPoolComptrollerContract && - !!venusLensContract && - !!vai && - !!vaiControllerContract && - apiPoolsData !== undefined && - (options?.enabled === undefined || options?.enabled); - - return useQuery({ - queryKey: [FunctionKey.GET_LEGACY_POOL, { ...input, chainId }], - queryFn: () => - callOrThrow( - { - xvs, - legacyPoolComptrollerContract, - venusLensContract, - resilientOracleContract, - vai, - vaiControllerContract, - blocksPerDay, - legacyPoolData: (apiPoolsData?.pools || []).find(p => !p.isIsolated), - }, - params => - getLegacyPool({ - chainId, - name: t('legacyPool.name'), - description: t('legacyPool.description'), - tokens, - primeContract: isPrimeEnabled ? primeContract : undefined, - ...input, - ...params, - }), - ), - refetchInterval, - ...options, - enabled: isQueryEnabled, - }); -}; - -export default useGetLegacyPool; diff --git a/apps/evm/src/clients/api/queries/getPendingRewards/useGetPendingRewards.ts b/apps/evm/src/clients/api/queries/getPendingRewards/useGetPendingRewards.ts index 657efd01b7..0304049f46 100644 --- a/apps/evm/src/clients/api/queries/getPendingRewards/useGetPendingRewards.ts +++ b/apps/evm/src/clients/api/queries/getPendingRewards/useGetPendingRewards.ts @@ -19,7 +19,7 @@ import { callOrThrow, generatePseudoRandomRefetchInterval } from 'utilities'; import getPendingRewards from '.'; import useGetXvsVaultPoolCount from '../getXvsVaultPoolCount/useGetXvsVaultPoolCount'; -import useGetPools from '../useGetPools'; +import { useGetPools } from '../useGetPools'; import type { GetPendingRewardsInput, GetPendingRewardsOutput } from './types'; type TrimmedGetPendingRewardsInput = Omit< diff --git a/apps/evm/src/clients/api/queries/getPoolLiquidationIncentive/useGetPoolLiquidationIncentive.ts b/apps/evm/src/clients/api/queries/getPoolLiquidationIncentive/useGetPoolLiquidationIncentive.ts index 302d30b172..2f06e62c35 100644 --- a/apps/evm/src/clients/api/queries/getPoolLiquidationIncentive/useGetPoolLiquidationIncentive.ts +++ b/apps/evm/src/clients/api/queries/getPoolLiquidationIncentive/useGetPoolLiquidationIncentive.ts @@ -6,14 +6,13 @@ import { getPoolLiquidationIncentive, } from 'clients/api/queries/getPoolLiquidationIncentive'; import FunctionKey from 'constants/functionKey'; -import { useGetChainMetadata } from 'hooks/useGetChainMetadata'; import { useGetIsolatedPoolComptrollerContract, useGetLegacyPoolComptrollerContract, } from 'libs/contracts'; import { useChainId } from 'libs/wallet'; -import { ChainId } from 'types'; -import { areAddressesEqual, callOrThrow } from 'utilities'; +import type { ChainId } from 'types'; +import { callOrThrow, isPoolIsolated } from 'utilities'; interface TrimmedGetPoolLiquidationIncentiveInput extends Omit { @@ -40,7 +39,6 @@ export const useGetPoolLiquidationIncentive = ( options?: Partial, ) => { const { chainId } = useChainId(); - const { corePoolComptrollerContractAddress } = useGetChainMetadata(); const legacyPoolComptrollerContract = useGetLegacyPoolComptrollerContract(); const isolatedPoolComptrollerContract = useGetIsolatedPoolComptrollerContract({ @@ -48,11 +46,14 @@ export const useGetPoolLiquidationIncentive = ( passSigner: false, }); - const poolComptrollerContract = - areAddressesEqual(corePoolComptrollerContractAddress, poolComptrollerContractAddress) && - (chainId === ChainId.BSC_MAINNET || chainId === ChainId.BSC_TESTNET) - ? legacyPoolComptrollerContract - : isolatedPoolComptrollerContract; + const isIsolated = isPoolIsolated({ + chainId, + comptrollerAddress: poolComptrollerContractAddress, + }); + + const poolComptrollerContract = isIsolated + ? isolatedPoolComptrollerContract + : legacyPoolComptrollerContract; return useQuery({ queryKey: [ diff --git a/apps/evm/src/clients/api/queries/useGetLegacyPoolMarkets/__tests__/__snapshots__/index.spec.ts.snap b/apps/evm/src/clients/api/queries/useGetLegacyPoolMarkets/__tests__/__snapshots__/index.spec.ts.snap deleted file mode 100644 index 8300be0de4..0000000000 --- a/apps/evm/src/clients/api/queries/useGetLegacyPoolMarkets/__tests__/__snapshots__/index.spec.ts.snap +++ /dev/null @@ -1,12 +0,0 @@ -// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html - -exports[`getLegacyPoolMarkets > returns formatted markets on success 1`] = ` -[ - { - "address": "0x3d759121234cd36F8124C21aFe1c6852d2bEd848", - "borrowerCount": 1, - "supplierCount": 2, - "totalXvsDistributedTokens": "959736.453684596858981282", - }, -] -`; diff --git a/apps/evm/src/clients/api/queries/useGetLegacyPoolMarkets/index.ts b/apps/evm/src/clients/api/queries/useGetLegacyPoolMarkets/index.ts deleted file mode 100644 index f12cbb031d..0000000000 --- a/apps/evm/src/clients/api/queries/useGetLegacyPoolMarkets/index.ts +++ /dev/null @@ -1,41 +0,0 @@ -import { type QueryObserverOptions, useQuery } from '@tanstack/react-query'; - -import { type GetApiMarketsOutput, getApiMarkets } from 'clients/api'; -import FunctionKey from 'constants/functionKey'; -import { useGetChainMetadata } from 'hooks/useGetChainMetadata'; -import { useGetToken } from 'libs/tokens'; -import { useChainId } from 'libs/wallet'; -import { ChainId } from 'types'; -import { callOrThrow } from 'utilities'; - -type Options = QueryObserverOptions< - GetApiMarketsOutput, - Error, - GetApiMarketsOutput, - GetApiMarketsOutput, - [FunctionKey.GET_LEGACY_CORE_POOL_MARKETS] ->; - -const useGetLegacyPoolMarkets = (options?: Partial) => { - const { chainId } = useChainId(); - const { corePoolComptrollerContractAddress } = useGetChainMetadata(); - const xvs = useGetToken({ - symbol: 'XVS', - }); - - const isQueryEnabled = - (chainId === ChainId.BSC_MAINNET || chainId === ChainId.BSC_TESTNET) && !!options?.enabled; - - return useQuery({ - queryKey: [FunctionKey.GET_LEGACY_CORE_POOL_MARKETS], - queryFn: () => - callOrThrow( - { xvs, chainId, poolComptrollerAddress: corePoolComptrollerContractAddress }, - getApiMarkets, - ), - ...options, - enabled: isQueryEnabled, - }); -}; - -export default useGetLegacyPoolMarkets; diff --git a/apps/evm/src/clients/api/queries/useGetPool/__snapshots__/index.spec.tsx.snap b/apps/evm/src/clients/api/queries/useGetPool/__snapshots__/index.spec.tsx.snap index 482e66e429..e856071cc8 100644 --- a/apps/evm/src/clients/api/queries/useGetPool/__snapshots__/index.spec.tsx.snap +++ b/apps/evm/src/clients/api/queries/useGetPool/__snapshots__/index.spec.tsx.snap @@ -403,7 +403,6 @@ exports[`api/queries/useGetPool > returns the correct asset 1`] = ` }, ], "comptrollerAddress": "0x94d1820b2d1c7c7452a163983dc888cec546b77d", - "description": "Fake description 1", "isIsolated": false, "name": "Venus", "userBorrowBalanceCents": "12333", diff --git a/apps/evm/src/clients/api/queries/useGetPools/__snapshots__/index.spec.tsx.snap b/apps/evm/src/clients/api/queries/useGetPools/__snapshots__/index.spec.tsx.snap deleted file mode 100644 index 06a9750c94..0000000000 --- a/apps/evm/src/clients/api/queries/useGetPools/__snapshots__/index.spec.tsx.snap +++ /dev/null @@ -1,824 +0,0 @@ -// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html - -exports[`api/queries/useGetPools > returns data in the correct format 1`] = ` -{ - "pools": [ - { - "assets": [ - { - "borrowApyPercentage": "-2.3062487835658776", - "borrowBalanceCents": "70925716", - "borrowBalanceTokens": "1852935.597521220541385584", - "borrowCapTokens": "1.15792089237316195423570985008687907853269984665640564039457584007913129639935e+77", - "borrowDistributions": [ - { - "apyPercentage": "4.17469243006608279", - "dailyDistributedTokens": "9999999.5", - "token": { - "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", - "asset": "/src/libs/tokens/img/xvs.svg", - "decimals": 18, - "symbol": "XVS", - }, - "type": "rewardDistributor", - }, - ], - "borrowerCount": 10, - "cashTokens": "10", - "collateralFactor": 0.5, - "disabledTokenActions": [], - "exchangeRateVTokens": "49.589181233", - "isCollateralOfUser": true, - "liquidityCents": "8036465875", - "reserveFactor": 0.25, - "reserveTokens": "1000", - "supplierCount": 100, - "supplyApyPercentage": "0.05225450324405023", - "supplyBalanceCents": "278311516", - "supplyBalanceTokens": "19339683254955736", - "supplyCapTokens": "1.15792089237316195423570985008687907853269984665640564039457584007913129639935e+77", - "supplyDistributions": [ - { - "apyPercentage": "0.11720675342484096", - "dailyDistributedTokens": "9999999.5", - "token": { - "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", - "asset": "/src/libs/tokens/img/xvs.svg", - "decimals": 18, - "symbol": "XVS", - }, - "type": "rewardDistributor", - }, - ], - "tokenPriceCents": "127.86734", - "userBorrowBalanceCents": "0", - "userBorrowBalanceTokens": "0", - "userPercentOfLimit": 0, - "userSupplyBalanceCents": "11508", - "userSupplyBalanceTokens": "90", - "userWalletBalanceCents": "12786", - "userWalletBalanceTokens": "100", - "vToken": { - "address": "0x6d6F697e34145Bb95c54E77482d97cc261Dc237E", - "decimals": 8, - "symbol": "vXVS", - "underlyingToken": { - "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", - "asset": "/src/libs/tokens/img/xvs.svg", - "decimals": 18, - "symbol": "XVS", - }, - }, - }, - { - "borrowApyPercentage": "-5.361233028654066", - "borrowBalanceCents": "858721657509436", - "borrowBalanceTokens": "73128318.509651061457900627", - "borrowCapTokens": "1.15792089237316195423570985008687907853269984665640564039457584007913129639935e+77", - "borrowDistributions": [ - { - "apyPercentage": "1.670327607690572731", - "dailyDistributedTokens": "9999999.5", - "token": { - "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", - "asset": "/src/libs/tokens/img/xvs.svg", - "decimals": 18, - "symbol": "XVS", - }, - "type": "rewardDistributor", - }, - { - "apyPercentage": "1.233105649796123742", - "referenceValues": { - "userBorrowBalanceTokens": "1000", - "userSupplyBalanceTokens": "1000", - "userXvsStakedTokens": "1000", - }, - "token": { - "address": "0x16227D60f7a0e586C66B005219dfc887D13C9531", - "asset": "/src/libs/tokens/img/usdc.svg", - "decimals": 6, - "symbol": "USDC", - }, - "type": "primeSimulation", - }, - { - "apyPercentage": "0.913105649796123742", - "token": { - "address": "0x16227D60f7a0e586C66B005219dfc887D13C9531", - "asset": "/src/libs/tokens/img/usdc.svg", - "decimals": 6, - "symbol": "USDC", - }, - "type": "prime", - }, - ], - "borrowerCount": 10, - "cashTokens": "10", - "collateralFactor": 0.8, - "disabledTokenActions": [ - "borrow", - "supply", - ], - "exchangeRateVTokens": "1", - "isCollateralOfUser": false, - "liquidityCents": "1702951959", - "reserveFactor": 0.2, - "reserveTokens": "1000", - "supplierCount": 100, - "supplyApyPercentage": "3.887242555711379188", - "supplyBalanceCents": "1000183891879506", - "supplyBalanceTokens": "4.717199913187927152720001083e+28", - "supplyCapTokens": "1.15792089237316195423570985008687907853269984665640564039457584007913129639935e+77", - "supplyDistributions": [ - { - "apyPercentage": "1.353105649796123742", - "dailyDistributedTokens": "9999999.5", - "token": { - "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", - "asset": "/src/libs/tokens/img/xvs.svg", - "decimals": 18, - "symbol": "XVS", - }, - "type": "rewardDistributor", - }, - { - "apyPercentage": "0.953105649796123742", - "referenceValues": { - "userBorrowBalanceTokens": "1000", - "userSupplyBalanceTokens": "1000", - "userXvsStakedTokens": "1000", - }, - "token": { - "address": "0x16227D60f7a0e586C66B005219dfc887D13C9531", - "asset": "/src/libs/tokens/img/usdc.svg", - "decimals": 6, - "symbol": "USDC", - }, - "type": "primeSimulation", - }, - { - "apyPercentage": "0.753105649796123742", - "token": { - "address": "0x16227D60f7a0e586C66B005219dfc887D13C9531", - "asset": "/src/libs/tokens/img/usdc.svg", - "decimals": 6, - "symbol": "USDC", - }, - "type": "prime", - }, - ], - "tokenPriceCents": "99.99364", - "userBorrowBalanceCents": "0", - "userBorrowBalanceTokens": "0", - "userPercentOfLimit": 0, - "userSupplyBalanceCents": "9999", - "userSupplyBalanceTokens": "100", - "userWalletBalanceCents": "0", - "userWalletBalanceTokens": "0", - "vToken": { - "address": "0xD5C4C2e2facBEB59D0216D0595d63FcDc6F9A1a7", - "decimals": 8, - "symbol": "vUSDC", - "underlyingToken": { - "address": "0x16227D60f7a0e586C66B005219dfc887D13C9531", - "asset": "/src/libs/tokens/img/usdc.svg", - "decimals": 6, - "symbol": "USDC", - }, - }, - }, - { - "borrowApyPercentage": "-4.9748661428011145", - "borrowBalanceCents": "3158444721", - "borrowBalanceTokens": "232511166.920938849475104194", - "borrowCapTokens": "1.15792089237316195423570985008687907853269984665640564039457584007913129639935e+77", - "borrowDistributions": [ - { - "apyPercentage": "0.522209972682294832", - "dailyDistributedTokens": "9999999.5", - "token": { - "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", - "asset": "/src/libs/tokens/img/xvs.svg", - "decimals": 18, - "symbol": "XVS", - }, - "type": "rewardDistributor", - }, - { - "apyPercentage": "1.015310564979612374", - "referenceValues": { - "userBorrowBalanceTokens": "1000", - "userSupplyBalanceTokens": "1000", - "userXvsStakedTokens": "1000", - }, - "token": { - "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", - "asset": "/src/libs/tokens/img/usdt.svg", - "decimals": 6, - "symbol": "USDT", - }, - "type": "primeSimulation", - }, - ], - "borrowerCount": 10, - "cashTokens": "10", - "collateralFactor": 0.8, - "disabledTokenActions": [ - "swapAndSupply", - ], - "exchangeRateVTokens": "0.981982", - "isCollateralOfUser": false, - "liquidityCents": "5534102886", - "reserveFactor": 0.2, - "reserveTokens": "1000", - "supplierCount": 100, - "supplyApyPercentage": "3.593608909332766999", - "supplyBalanceCents": "1098041201011568", - "supplyBalanceTokens": "5.029972090817266864401527367893625e+33", - "supplyCapTokens": "1.15792089237316195423570985008687907853269984665640564039457584007913129639935e+77", - "supplyDistributions": [ - { - "apyPercentage": "0.421719501189155143", - "dailyDistributedTokens": "9999999.5", - "token": { - "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", - "asset": "/src/libs/tokens/img/xvs.svg", - "decimals": 18, - "symbol": "XVS", - }, - "type": "rewardDistributor", - }, - { - "apyPercentage": "1.753105649796123742", - "referenceValues": { - "userBorrowBalanceTokens": "1000", - "userSupplyBalanceTokens": "1000", - "userXvsStakedTokens": "1000", - }, - "token": { - "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", - "asset": "/src/libs/tokens/img/usdt.svg", - "decimals": 6, - "symbol": "USDT", - }, - "type": "primeSimulation", - }, - ], - "tokenPriceCents": "100.024602", - "userBorrowBalanceCents": "4000", - "userBorrowBalanceTokens": "40", - "userPercentOfLimit": 0, - "userSupplyBalanceCents": "0", - "userSupplyBalanceTokens": "0", - "userWalletBalanceCents": "90000", - "userWalletBalanceTokens": "900", - "vToken": { - "address": "0xb7526572FFE56AB9D7489838Bf2E18e3323b441A", - "decimals": 8, - "symbol": "vUSDT", - "underlyingToken": { - "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", - "asset": "/src/libs/tokens/img/usdt.svg", - "decimals": 6, - "symbol": "USDT", - }, - }, - }, - { - "borrowApyPercentage": "-4.050271277344538", - "borrowBalanceCents": "83910350502", - "borrowBalanceTokens": "142662020.229587308931217432", - "borrowCapTokens": "1.15792089237316195423570985008687907853269984665640564039457584007913129639935e+77", - "borrowDistributions": [ - { - "apyPercentage": "0.852697602175970714", - "dailyDistributedTokens": "9999999.5", - "token": { - "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", - "asset": "/src/libs/tokens/img/xvs.svg", - "decimals": 18, - "symbol": "XVS", - }, - "type": "rewardDistributor", - }, - { - "apyPercentage": "1.753105649796123742", - "referenceValues": { - "userBorrowBalanceTokens": "1000", - "userSupplyBalanceTokens": "1000", - "userXvsStakedTokens": "1000", - }, - "token": { - "address": "0x8301F2213c0eeD49a7E28Ae4c3e91722919B8B47", - "asset": "/src/libs/tokens/img/busd.svg", - "decimals": 18, - "symbol": "BUSD", - }, - "type": "primeSimulation", - }, - { - "apyPercentage": "0.913105649796123742", - "token": { - "address": "0x8301F2213c0eeD49a7E28Ae4c3e91722919B8B47", - "asset": "/src/libs/tokens/img/busd.svg", - "decimals": 18, - "symbol": "BUSD", - }, - "type": "prime", - }, - ], - "borrowerCount": 10, - "cashTokens": "10", - "collateralFactor": 0.8, - "disabledTokenActions": [ - "supply", - ], - "exchangeRateVTokens": "1.000003", - "isCollateralOfUser": false, - "liquidityCents": "3654492935", - "reserveFactor": 0.2, - "reserveTokens": "1000", - "supplierCount": 100, - "supplyApyPercentage": "2.886396363044176106", - "supplyBalanceCents": "1054707853878", - "supplyBalanceTokens": "51881081291203672464", - "supplyCapTokens": "1.15792089237316195423570985008687907853269984665640564039457584007913129639935e+77", - "supplyDistributions": [ - { - "apyPercentage": "0.678420831753642169", - "dailyDistributedTokens": "9999999.5", - "token": { - "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", - "asset": "/src/libs/tokens/img/xvs.svg", - "decimals": 18, - "symbol": "XVS", - }, - "type": "rewardDistributor", - }, - { - "apyPercentage": "1.753105649796123742", - "referenceValues": { - "userBorrowBalanceTokens": "1000", - "userSupplyBalanceTokens": "1000", - "userXvsStakedTokens": "1000", - }, - "token": { - "address": "0x8301F2213c0eeD49a7E28Ae4c3e91722919B8B47", - "asset": "/src/libs/tokens/img/busd.svg", - "decimals": 18, - "symbol": "BUSD", - }, - "type": "primeSimulation", - }, - { - "apyPercentage": "0", - "token": { - "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", - "asset": "/src/libs/tokens/img/xvs.svg", - "decimals": 18, - "symbol": "XVS", - }, - "type": "prime", - }, - ], - "tokenPriceCents": "100.000922", - "userBorrowBalanceCents": "5000", - "userBorrowBalanceTokens": "50", - "userPercentOfLimit": 0, - "userSupplyBalanceCents": "0", - "userSupplyBalanceTokens": "0", - "userWalletBalanceCents": "11000", - "userWalletBalanceTokens": "110", - "vToken": { - "address": "0x08e0A5575De71037aE36AbfAfb516595fE68e5e4", - "decimals": 8, - "symbol": "vBUSD", - "underlyingToken": { - "address": "0x8301F2213c0eeD49a7E28Ae4c3e91722919B8B47", - "asset": "/src/libs/tokens/img/busd.svg", - "decimals": 18, - "symbol": "BUSD", - }, - }, - }, - ], - "comptrollerAddress": "0x94d1820b2d1c7c7452a163983dc888cec546b77d", - "description": "Fake description 1", - "isIsolated": false, - "name": "Venus", - "userBorrowBalanceCents": "12333", - "userBorrowLimitCents": "192673", - "userSupplyBalanceCents": "123879865", - }, - { - "assets": [ - { - "borrowApyPercentage": "-2.3062487835658776", - "borrowBalanceCents": "70925716", - "borrowBalanceTokens": "1852935.597521220541385584", - "borrowCapTokens": "1.15792089237316195423570985008687907853269984665640564039457584007913129639935e+77", - "borrowDistributions": [ - { - "apyPercentage": "4.17469243006608279", - "dailyDistributedTokens": "9999999.5", - "token": { - "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", - "asset": "/src/libs/tokens/img/xvs.svg", - "decimals": 18, - "symbol": "XVS", - }, - "type": "rewardDistributor", - }, - ], - "borrowerCount": 10, - "cashTokens": "10", - "collateralFactor": 0.5, - "disabledTokenActions": [], - "exchangeRateVTokens": "49.589181233", - "isCollateralOfUser": true, - "liquidityCents": "8036465875", - "reserveFactor": 0.25, - "reserveTokens": "1000", - "supplierCount": 100, - "supplyApyPercentage": "0.05225450324405023", - "supplyBalanceCents": "278311516", - "supplyBalanceTokens": "19339683254955736", - "supplyCapTokens": "1.15792089237316195423570985008687907853269984665640564039457584007913129639935e+77", - "supplyDistributions": [ - { - "apyPercentage": "0.11720675342484096", - "dailyDistributedTokens": "9999999.5", - "token": { - "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", - "asset": "/src/libs/tokens/img/xvs.svg", - "decimals": 18, - "symbol": "XVS", - }, - "type": "rewardDistributor", - }, - ], - "tokenPriceCents": "127.86734", - "userBorrowBalanceCents": "0", - "userBorrowBalanceTokens": "0", - "userPercentOfLimit": 0, - "userSupplyBalanceCents": "11508", - "userSupplyBalanceTokens": "90", - "userWalletBalanceCents": "12786", - "userWalletBalanceTokens": "100", - "vToken": { - "address": "0x6d6F697e34145Bb95c54E77482d97cc261Dc237E", - "decimals": 8, - "symbol": "vXVS", - "underlyingToken": { - "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", - "asset": "/src/libs/tokens/img/xvs.svg", - "decimals": 18, - "symbol": "XVS", - }, - }, - }, - { - "borrowApyPercentage": "-5.361233028654066", - "borrowBalanceCents": "858721657509436", - "borrowBalanceTokens": "73128318.509651061457900627", - "borrowCapTokens": "1.15792089237316195423570985008687907853269984665640564039457584007913129639935e+77", - "borrowDistributions": [ - { - "apyPercentage": "1.670327607690572731", - "dailyDistributedTokens": "9999999.5", - "token": { - "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", - "asset": "/src/libs/tokens/img/xvs.svg", - "decimals": 18, - "symbol": "XVS", - }, - "type": "rewardDistributor", - }, - { - "apyPercentage": "1.233105649796123742", - "referenceValues": { - "userBorrowBalanceTokens": "1000", - "userSupplyBalanceTokens": "1000", - "userXvsStakedTokens": "1000", - }, - "token": { - "address": "0x16227D60f7a0e586C66B005219dfc887D13C9531", - "asset": "/src/libs/tokens/img/usdc.svg", - "decimals": 6, - "symbol": "USDC", - }, - "type": "primeSimulation", - }, - { - "apyPercentage": "0.913105649796123742", - "token": { - "address": "0x16227D60f7a0e586C66B005219dfc887D13C9531", - "asset": "/src/libs/tokens/img/usdc.svg", - "decimals": 6, - "symbol": "USDC", - }, - "type": "prime", - }, - ], - "borrowerCount": 10, - "cashTokens": "10", - "collateralFactor": 0.8, - "disabledTokenActions": [ - "borrow", - "supply", - ], - "exchangeRateVTokens": "1", - "isCollateralOfUser": false, - "liquidityCents": "1702951959", - "reserveFactor": 0.2, - "reserveTokens": "1000", - "supplierCount": 100, - "supplyApyPercentage": "3.887242555711379188", - "supplyBalanceCents": "1000183891879506", - "supplyBalanceTokens": "4.717199913187927152720001083e+28", - "supplyCapTokens": "1.15792089237316195423570985008687907853269984665640564039457584007913129639935e+77", - "supplyDistributions": [ - { - "apyPercentage": "1.353105649796123742", - "dailyDistributedTokens": "9999999.5", - "token": { - "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", - "asset": "/src/libs/tokens/img/xvs.svg", - "decimals": 18, - "symbol": "XVS", - }, - "type": "rewardDistributor", - }, - { - "apyPercentage": "0.953105649796123742", - "referenceValues": { - "userBorrowBalanceTokens": "1000", - "userSupplyBalanceTokens": "1000", - "userXvsStakedTokens": "1000", - }, - "token": { - "address": "0x16227D60f7a0e586C66B005219dfc887D13C9531", - "asset": "/src/libs/tokens/img/usdc.svg", - "decimals": 6, - "symbol": "USDC", - }, - "type": "primeSimulation", - }, - { - "apyPercentage": "0.753105649796123742", - "token": { - "address": "0x16227D60f7a0e586C66B005219dfc887D13C9531", - "asset": "/src/libs/tokens/img/usdc.svg", - "decimals": 6, - "symbol": "USDC", - }, - "type": "prime", - }, - ], - "tokenPriceCents": "99.99364", - "userBorrowBalanceCents": "0", - "userBorrowBalanceTokens": "0", - "userPercentOfLimit": 0, - "userSupplyBalanceCents": "9999", - "userSupplyBalanceTokens": "100", - "userWalletBalanceCents": "0", - "userWalletBalanceTokens": "0", - "vToken": { - "address": "0xD5C4C2e2facBEB59D0216D0595d63FcDc6F9A1a7", - "decimals": 8, - "symbol": "vUSDC", - "underlyingToken": { - "address": "0x16227D60f7a0e586C66B005219dfc887D13C9531", - "asset": "/src/libs/tokens/img/usdc.svg", - "decimals": 6, - "symbol": "USDC", - }, - }, - }, - { - "borrowApyPercentage": "-4.9748661428011145", - "borrowBalanceCents": "3158444721", - "borrowBalanceTokens": "232511166.920938849475104194", - "borrowCapTokens": "1.15792089237316195423570985008687907853269984665640564039457584007913129639935e+77", - "borrowDistributions": [ - { - "apyPercentage": "0.522209972682294832", - "dailyDistributedTokens": "9999999.5", - "token": { - "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", - "asset": "/src/libs/tokens/img/xvs.svg", - "decimals": 18, - "symbol": "XVS", - }, - "type": "rewardDistributor", - }, - { - "apyPercentage": "1.015310564979612374", - "referenceValues": { - "userBorrowBalanceTokens": "1000", - "userSupplyBalanceTokens": "1000", - "userXvsStakedTokens": "1000", - }, - "token": { - "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", - "asset": "/src/libs/tokens/img/usdt.svg", - "decimals": 6, - "symbol": "USDT", - }, - "type": "primeSimulation", - }, - ], - "borrowerCount": 10, - "cashTokens": "10", - "collateralFactor": 0.8, - "disabledTokenActions": [ - "swapAndSupply", - ], - "exchangeRateVTokens": "0.981982", - "isCollateralOfUser": false, - "liquidityCents": "5534102886", - "reserveFactor": 0.2, - "reserveTokens": "1000", - "supplierCount": 100, - "supplyApyPercentage": "3.593608909332766999", - "supplyBalanceCents": "1098041201011568", - "supplyBalanceTokens": "5.029972090817266864401527367893625e+33", - "supplyCapTokens": "1.15792089237316195423570985008687907853269984665640564039457584007913129639935e+77", - "supplyDistributions": [ - { - "apyPercentage": "0.421719501189155143", - "dailyDistributedTokens": "9999999.5", - "token": { - "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", - "asset": "/src/libs/tokens/img/xvs.svg", - "decimals": 18, - "symbol": "XVS", - }, - "type": "rewardDistributor", - }, - { - "apyPercentage": "1.753105649796123742", - "referenceValues": { - "userBorrowBalanceTokens": "1000", - "userSupplyBalanceTokens": "1000", - "userXvsStakedTokens": "1000", - }, - "token": { - "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", - "asset": "/src/libs/tokens/img/usdt.svg", - "decimals": 6, - "symbol": "USDT", - }, - "type": "primeSimulation", - }, - ], - "tokenPriceCents": "100.024602", - "userBorrowBalanceCents": "4000", - "userBorrowBalanceTokens": "40", - "userPercentOfLimit": 0, - "userSupplyBalanceCents": "0", - "userSupplyBalanceTokens": "0", - "userWalletBalanceCents": "90000", - "userWalletBalanceTokens": "900", - "vToken": { - "address": "0xb7526572FFE56AB9D7489838Bf2E18e3323b441A", - "decimals": 8, - "symbol": "vUSDT", - "underlyingToken": { - "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", - "asset": "/src/libs/tokens/img/usdt.svg", - "decimals": 6, - "symbol": "USDT", - }, - }, - }, - { - "borrowApyPercentage": "-4.050271277344538", - "borrowBalanceCents": "83910350502", - "borrowBalanceTokens": "142662020.229587308931217432", - "borrowCapTokens": "1.15792089237316195423570985008687907853269984665640564039457584007913129639935e+77", - "borrowDistributions": [ - { - "apyPercentage": "0.852697602175970714", - "dailyDistributedTokens": "9999999.5", - "token": { - "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", - "asset": "/src/libs/tokens/img/xvs.svg", - "decimals": 18, - "symbol": "XVS", - }, - "type": "rewardDistributor", - }, - { - "apyPercentage": "1.753105649796123742", - "referenceValues": { - "userBorrowBalanceTokens": "1000", - "userSupplyBalanceTokens": "1000", - "userXvsStakedTokens": "1000", - }, - "token": { - "address": "0x8301F2213c0eeD49a7E28Ae4c3e91722919B8B47", - "asset": "/src/libs/tokens/img/busd.svg", - "decimals": 18, - "symbol": "BUSD", - }, - "type": "primeSimulation", - }, - { - "apyPercentage": "0.913105649796123742", - "token": { - "address": "0x8301F2213c0eeD49a7E28Ae4c3e91722919B8B47", - "asset": "/src/libs/tokens/img/busd.svg", - "decimals": 18, - "symbol": "BUSD", - }, - "type": "prime", - }, - ], - "borrowerCount": 10, - "cashTokens": "10", - "collateralFactor": 0.8, - "disabledTokenActions": [ - "supply", - ], - "exchangeRateVTokens": "1.000003", - "isCollateralOfUser": false, - "liquidityCents": "3654492935", - "reserveFactor": 0.2, - "reserveTokens": "1000", - "supplierCount": 100, - "supplyApyPercentage": "2.886396363044176106", - "supplyBalanceCents": "1054707853878", - "supplyBalanceTokens": "51881081291203672464", - "supplyCapTokens": "1.15792089237316195423570985008687907853269984665640564039457584007913129639935e+77", - "supplyDistributions": [ - { - "apyPercentage": "0.678420831753642169", - "dailyDistributedTokens": "9999999.5", - "token": { - "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", - "asset": "/src/libs/tokens/img/xvs.svg", - "decimals": 18, - "symbol": "XVS", - }, - "type": "rewardDistributor", - }, - { - "apyPercentage": "1.753105649796123742", - "referenceValues": { - "userBorrowBalanceTokens": "1000", - "userSupplyBalanceTokens": "1000", - "userXvsStakedTokens": "1000", - }, - "token": { - "address": "0x8301F2213c0eeD49a7E28Ae4c3e91722919B8B47", - "asset": "/src/libs/tokens/img/busd.svg", - "decimals": 18, - "symbol": "BUSD", - }, - "type": "primeSimulation", - }, - { - "apyPercentage": "0", - "token": { - "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", - "asset": "/src/libs/tokens/img/xvs.svg", - "decimals": 18, - "symbol": "XVS", - }, - "type": "prime", - }, - ], - "tokenPriceCents": "100.000922", - "userBorrowBalanceCents": "5000", - "userBorrowBalanceTokens": "50", - "userPercentOfLimit": 0, - "userSupplyBalanceCents": "0", - "userSupplyBalanceTokens": "0", - "userWalletBalanceCents": "11000", - "userWalletBalanceTokens": "110", - "vToken": { - "address": "0x08e0A5575De71037aE36AbfAfb516595fE68e5e4", - "decimals": 8, - "symbol": "vBUSD", - "underlyingToken": { - "address": "0x8301F2213c0eeD49a7E28Ae4c3e91722919B8B47", - "asset": "/src/libs/tokens/img/busd.svg", - "decimals": 18, - "symbol": "BUSD", - }, - }, - }, - ], - "comptrollerAddress": "0x10b57706ad2345e590c2ea4dc02faef0d9f5b08b", - "description": "Fake description 2", - "isIsolated": true, - "name": "Metaverse", - "userBorrowBalanceCents": "0", - "userBorrowLimitCents": "0", - "userSupplyBalanceCents": "0", - }, - ], -} -`; diff --git a/apps/evm/src/clients/api/queries/useGetPools/__testUtils__/fakeData.ts b/apps/evm/src/clients/api/queries/useGetPools/__testUtils__/fakeData.ts new file mode 100644 index 0000000000..9e276be01f --- /dev/null +++ b/apps/evm/src/clients/api/queries/useGetPools/__testUtils__/fakeData.ts @@ -0,0 +1,145 @@ +import { BigNumber as BN } from 'ethers'; + +import apiPoolsResponse from '__mocks__/api/pools.json'; +import type { + IsolatedPoolComptroller, + LegacyPoolComptroller, + PoolLens, + Prime, + VaiController, + VenusLens, +} from 'libs/contracts'; + +const userLegacyCollateralizedVTokenAddresses = [ + '0x08e0A5575De71037aE36AbfAfb516595fE68e5e4', + '0x162D005F0Fff510E54958Cfc5CF32A3180A84aab', + '0x171B468b52d7027F12cEF90cd065d6776a25E24e', + '0x2E7222e51c0f6e98610A1543Aa3836E092CDe62c', + '0x35566ED3AF9E537Be487C98b1811cDf95ad0C32b', + '0x3619bdDc61189F33365CC572DF3a68FB3b316516', + '0x3A00d9B02781f47d033BAd62edc55fBF8D083Fb0', + '0x6AF3Fdb3282c5bb6926269Db10837fa8Aec67C04', + '0x6d6F697e34145Bb95c54E77482d97cc261Dc237E', + '0x74469281310195A04840Daf6EdF576F559a3dE80', + '0xb6e9322C49FD75a367Fcb17B0Fcd62C5070EbCBe', + '0xb7526572FFE56AB9D7489838Bf2E18e3323b441A', + '0xD5C4C2e2facBEB59D0216D0595d63FcDc6F9A1a7', + '0xF06e662a00796c122AaAE935EC4F0Be3F74f5636', + '0x4C94e67d239aD585275Fdd3246Ab82c8a2668564', + '0x5e68913fbbfb91af30366ab1B21324410b49a308', + '0x80CC30811e362aC9aB857C3d7875CbcCc0b65750', + '0xa109DE0abaeefC521Ec29D89eA42E64F37A6882E', + '0xe237aA131E7B004aC88CB808Fa56AF3dc4C408f1', + '0xe507B30C41E9e375BCe05197c1e09fc9ee40c0f6', + '0x0bFE4e0B8A2a096A27e5B18b078d25be57C08634', + '0x1958035231E125830bA5d17D168cEa07Bb42184a', +]; + +const userIsolatedCollateralizedVTokenAddresses = [ + '0x4c94e67d239ad585275fdd3246ab82c8a2668564', + '0x5e68913fbbfb91af30366ab1b21324410b49a308', + '0x80cc30811e362ac9ab857c3d7875cbccc0b65750', + '0xa109de0abaeefc521ec29d89ea42e64f37a6882e', + '0xb677e080148368eeee70fa3865d07e92c6500174', + '0xb7cac5ef82cb7f9197ee184779bdc52c5490c02a', + '0x1958035231e125830ba5d17d168cea07bb42184a', + '0xdedf3b2bcf25d0023115fd71a0f8221c91c92b1a', + '0x231ded0dfc99634e52ee1a1329586bc970d773b3', + '0x57a664dd7f1de19545fee9c86c949e3bf43d6d47', + '0x644a149853e5507adf3e682218b8ac86cdd62951', + '0x75aa42c832a8911b77219dbebabbb40040d16987', + '0xd5b20708d8f0fca52cb609938d0594c4e32e5dad', + '0xeffe7874c345ae877c1d893cd5160ddd359b24da', + '0x3af2be7abef0f840b196d99d79f4b803a5db14a1', + '0x170d3b2da05cc2124334240fb34ad1359e34c562', + '0x3338988d0beb4419acb8fe624218754053362d06', + '0x899ddf81dfbbf5889a16d075c352f2b959dd24a4', + '0x410286c43a525e1dcc7468a9b091c111c8324cd1', + '0xd804f74fe21290d213c46610ab171f7c2eeebde7', + '0xee543d5de2dbb5b07675fc72831a2f1812428393', +]; + +const userCollateralVTokenAddresses = [ + ...userLegacyCollateralizedVTokenAddresses, + ...userIsolatedCollateralizedVTokenAddresses, +]; + +const vTokenBalancesAllMock = async (vTokenAddresses: string[]) => + vTokenAddresses.map(vTokenAddress => { + const isUserCollateral = userCollateralVTokenAddresses.some( + a => a.toLowerCase() === vTokenAddress.toLowerCase(), + ); + + return { + vToken: vTokenAddress, + balanceOf: BN.from(isUserCollateral ? '4000000000000000000' : 0), + balanceOfUnderlying: BN.from('2000000000000000000'), + borrowBalanceCurrent: BN.from(isUserCollateral ? '100000000000000000' : 0), + tokenBalance: BN.from('40000000000000000000'), + tokenAllowance: BN.from('50000000000000000000'), + }; + }); + +export const fakeVenusLensContract = { + callStatic: { + vTokenBalancesAll: vTokenBalancesAllMock, + }, +} as unknown as VenusLens; + +export const fakePoolLensContract = { + callStatic: { + vTokenBalancesAll: vTokenBalancesAllMock, + }, +} as unknown as PoolLens; + +export const fakeVaiControllerContract = { + getVAIRepayAmount: async () => BN.from('1000000000000000000'), + callStatic: { + accrueVAIInterest: vi.fn(), + }, +} as unknown as VaiController; + +export const fakeIsolatedPoolComptrollerContract = { + getAssetsIn: async () => userIsolatedCollateralizedVTokenAddresses, +} as unknown as IsolatedPoolComptroller; + +export const fakeLegacyPoolComptrollerContract = { + getAssetsIn: async () => userLegacyCollateralizedVTokenAddresses, +} as unknown as LegacyPoolComptroller; + +export const fakePrimeContract = { + tokens: async () => ({ + exists: true, + isIrrevocable: false, + }), + MINIMUM_STAKED_XVS: async () => BN.from('1000000000000000000000'), + getAllMarkets: async () => [ + '0xD5C4C2e2facBEB59D0216D0595d63FcDc6F9A1a7', + '0xb7526572FFE56AB9D7489838Bf2E18e3323b441A', + '0x08e0A5575De71037aE36AbfAfb516595fE68e5e4', + '0x74469281310195A04840Daf6EdF576F559a3dE80', + '0x3338988d0beb4419Acb8fE624218754053362D06', + '0x2197d02cC9cd1ad51317A0a85A656a0c82383A7c', + '0x712774CBFFCBD60e9825871CcEFF2F917442b2c3', + ], + estimateAPR: async () => ({ + borrowAPR: BN.from('20'), + supplyAPR: BN.from('23'), + }), + calculateAPR: async () => ({ + borrowAPR: BN.from('32'), + supplyAPR: BN.from('29'), + }), +} as unknown as Prime; + +export const fakeIsolatedPoolParticipantsCount = { + pools: apiPoolsResponse.result.map(pool => ({ + __typename: 'Pool', + id: pool.address, + markets: pool.markets.map(market => ({ + id: market.address, + supplierCount: 10, + borrowerCount: 20, + })), + })), +}; diff --git a/apps/evm/src/clients/api/queries/useGetPools/__tests__/__snapshots__/index.prime.spec.ts.snap b/apps/evm/src/clients/api/queries/useGetPools/__tests__/__snapshots__/index.prime.spec.ts.snap new file mode 100644 index 0000000000..0e838709ba --- /dev/null +++ b/apps/evm/src/clients/api/queries/useGetPools/__tests__/__snapshots__/index.prime.spec.ts.snap @@ -0,0 +1,3295 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`useGetPools > does not fetch Prime distributions if user is not Prime 1`] = ` +{ + "pools": [ + { + "assets": [ + { + "borrowApyPercentage": "2.014488270427066776", + "borrowBalanceCents": "24663011775918.58670630114424219627258", + "borrowBalanceTokens": "246628588661.936163058800477859", + "borrowCapTokens": "1e-18", + "borrowDistributions": [ + { + "apyPercentage": "0", + "dailyDistributedTokens": "0", + "token": { + "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", + "asset": "/src/libs/tokens/img/xvs.svg", + "decimals": 18, + "symbol": "XVS", + }, + "type": "rewardDistributor", + }, + { + "apyPercentage": "0.20019958435848473", + "referenceValues": { + "userBorrowBalanceTokens": "563078969.54779945903835725538", + "userSupplyBalanceTokens": "1071811362327614186.97785297335171745333", + "userXvsStakedTokens": "1000", + }, + "token": { + "address": "0x8301F2213c0eeD49a7E28Ae4c3e91722919B8B47", + "asset": "/src/libs/tokens/img/busd.svg", + "decimals": 18, + "symbol": "BUSD", + }, + "type": "primeSimulation", + }, + ], + "borrowerCount": 438, + "cashTokens": "1.00000000080503544824460983238917793784e+21", + "collateralFactor": 0, + "disabledTokenActions": [ + "supply", + "borrow", + ], + "exchangeRateVTokens": "49.19405324154271215086", + "isCollateralOfUser": true, + "liquidityCents": "1.000006200805040439464388948970138750743214608e+23", + "reserveFactor": 1, + "reserveTokens": "0", + "supplierCount": 933, + "supplyApyPercentage": "0", + "supplyBalanceCents": "1.000006201051670556767362816225462034303610544746e+23", + "supplyBalanceTokens": "1.00000000105166403645033682413715238395883e+21", + "supplyCapTokens": "0", + "supplyDistributions": [ + { + "apyPercentage": "0", + "dailyDistributedTokens": "0", + "token": { + "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", + "asset": "/src/libs/tokens/img/xvs.svg", + "decimals": 18, + "symbol": "XVS", + }, + "type": "rewardDistributor", + }, + { + "apyPercentage": "0.23026397657694986", + "referenceValues": { + "userBorrowBalanceTokens": "563078969.54779945903835725538", + "userSupplyBalanceTokens": "1071811362327614186.97785297335171745333", + "userXvsStakedTokens": "1000", + }, + "token": { + "address": "0x8301F2213c0eeD49a7E28Ae4c3e91722919B8B47", + "asset": "/src/libs/tokens/img/busd.svg", + "decimals": 18, + "symbol": "BUSD", + }, + "type": "primeSimulation", + }, + ], + "tokenPriceCents": "100.00062", + "userBorrowBalanceCents": "10.000062", + "userBorrowBalanceTokens": "0.1", + "userPercentOfLimit": 0, + "userSupplyBalanceCents": "200.00124", + "userSupplyBalanceTokens": "2", + "userWalletBalanceCents": "1000.0062", + "userWalletBalanceTokens": "10", + "vToken": { + "address": "0x08e0A5575De71037aE36AbfAfb516595fE68e5e4", + "decimals": 8, + "symbol": "vBUSD", + "underlyingToken": { + "address": "0x8301F2213c0eeD49a7E28Ae4c3e91722919B8B47", + "asset": "/src/libs/tokens/img/busd.svg", + "decimals": 18, + "symbol": "BUSD", + }, + }, + }, + { + "borrowApyPercentage": "12.72621843315593399", + "borrowBalanceCents": "3721959398.320962344455482972", + "borrowBalanceTokens": "15136.746248595758022748", + "borrowCapTokens": "0", + "borrowDistributions": [ + { + "apyPercentage": "1.5797413696681861", + "dailyDistributedTokens": "250.0000128", + "token": { + "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", + "asset": "/src/libs/tokens/img/xvs.svg", + "decimals": 18, + "symbol": "XVS", + }, + "type": "rewardDistributor", + }, + ], + "borrowerCount": 35, + "cashTokens": "0", + "collateralFactor": 0.8, + "disabledTokenActions": [], + "exchangeRateVTokens": "37.63966306652044917955", + "isCollateralOfUser": true, + "liquidityCents": "0", + "reserveFactor": 0.1, + "reserveTokens": "21.269535066688975633", + "supplierCount": 25, + "supplyApyPercentage": "11.401000590716290067", + "supplyBalanceCents": "3716729453.6129492577232450137", + "supplyBalanceTokens": "15115.4767135290690422233", + "supplyCapTokens": "1.15792089237316195423570985008687907853269984665640564039457584007913129639935e+59", + "supplyDistributions": [ + { + "apyPercentage": "1.5819817239252298", + "dailyDistributedTokens": "250.0000128", + "token": { + "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", + "asset": "/src/libs/tokens/img/xvs.svg", + "decimals": 18, + "symbol": "XVS", + }, + "type": "rewardDistributor", + }, + ], + "tokenPriceCents": "245889", + "userBorrowBalanceCents": "24588.9", + "userBorrowBalanceTokens": "0.1", + "userPercentOfLimit": 0, + "userSupplyBalanceCents": "491778", + "userSupplyBalanceTokens": "2", + "userWalletBalanceCents": "2458890", + "userWalletBalanceTokens": "10", + "vToken": { + "address": "0x162D005F0Fff510E54958Cfc5CF32A3180A84aab", + "decimals": 8, + "symbol": "vETH", + "underlyingToken": { + "address": "0x98f7A83361F7Ac8765CcEBAB1425da6b341958a7", + "asset": "/src/libs/tokens/img/eth.svg", + "decimals": 18, + "isNative": true, + "symbol": "ETH", + }, + }, + }, + { + "borrowApyPercentage": "179.96505731769223966", + "borrowBalanceCents": "54206766464.991794941213834066224", + "borrowBalanceTokens": "1032405.72373577234796371", + "borrowCapTokens": "0", + "borrowDistributions": [ + { + "apyPercentage": "0.6478221277312901", + "dailyDistributedTokens": "1499.9999904", + "token": { + "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", + "asset": "/src/libs/tokens/img/xvs.svg", + "decimals": 18, + "symbol": "XVS", + }, + "type": "rewardDistributor", + }, + ], + "borrowerCount": 263, + "cashTokens": "5.556233762724731858", + "collateralFactor": 0.8, + "disabledTokenActions": [], + "exchangeRateVTokens": "5.63429988023545433776", + "isCollateralOfUser": true, + "liquidityCents": "291731.6894670817923653489952", + "reserveFactor": 0.25, + "reserveTokens": "187487.447405339178551222", + "supplierCount": 923, + "supplyApyPercentage": "156.911092632839993416", + "supplyBalanceCents": "44362974574.359412320127072323564288", + "supplyBalanceTokens": "844923.83256419589412162352", + "supplyCapTokens": "1.15792089237316195423570985008687907853269984665640564039457584007913129639935e+59", + "supplyDistributions": [ + { + "apyPercentage": "0.7921351276470645", + "dailyDistributedTokens": "1499.9999904", + "token": { + "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", + "asset": "/src/libs/tokens/img/xvs.svg", + "decimals": 18, + "symbol": "XVS", + }, + "type": "rewardDistributor", + }, + ], + "tokenPriceCents": "52505.2944", + "userBorrowBalanceCents": "5250.52944", + "userBorrowBalanceTokens": "0.1", + "userPercentOfLimit": 0, + "userSupplyBalanceCents": "105010.5888", + "userSupplyBalanceTokens": "2", + "userWalletBalanceCents": "525052.944", + "userWalletBalanceTokens": "10", + "vToken": { + "address": "0x2E7222e51c0f6e98610A1543Aa3836E092CDe62c", + "decimals": 8, + "symbol": "vBNB", + "underlyingToken": { + "address": "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE", + "asset": "/src/libs/tokens/img/bnb.svg", + "decimals": 18, + "isNative": true, + "symbol": "BNB", + }, + }, + }, + { + "borrowApyPercentage": "16.800248594171254373", + "borrowBalanceCents": "266527277.02974427316207663041589", + "borrowBalanceTokens": "416884.364702270734855123", + "borrowCapTokens": "270000", + "borrowDistributions": [ + { + "apyPercentage": "0", + "dailyDistributedTokens": "0", + "token": { + "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", + "asset": "/src/libs/tokens/img/xvs.svg", + "decimals": 18, + "symbol": "XVS", + }, + "type": "rewardDistributor", + }, + ], + "borrowerCount": 68, + "cashTokens": "2259657.074761148481496107", + "collateralFactor": 0.6, + "disabledTokenActions": [], + "exchangeRateVTokens": "47.36910235297224095005", + "isCollateralOfUser": true, + "liquidityCents": "1444669788.91666196711723462774301", + "reserveFactor": 0.25, + "reserveTokens": "0", + "supplierCount": 274, + "supplyApyPercentage": "1.830999347346963073", + "supplyBalanceCents": "1711197065.9464062401284554003137589", + "supplyBalanceTokens": "2676541.43946341921611527123", + "supplyCapTokens": "3750000", + "supplyDistributions": [ + { + "apyPercentage": "0", + "dailyDistributedTokens": "0", + "token": { + "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", + "asset": "/src/libs/tokens/img/xvs.svg", + "decimals": 18, + "symbol": "XVS", + }, + "type": "rewardDistributor", + }, + ], + "tokenPriceCents": "639.33143", + "userBorrowBalanceCents": "63.933143", + "userBorrowBalanceTokens": "0.1", + "userPercentOfLimit": 0, + "userSupplyBalanceCents": "1278.66286", + "userSupplyBalanceTokens": "2", + "userWalletBalanceCents": "6393.3143", + "userWalletBalanceTokens": "10", + "vToken": { + "address": "0x6d6F697e34145Bb95c54E77482d97cc261Dc237E", + "decimals": 8, + "symbol": "vXVS", + "underlyingToken": { + "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", + "asset": "/src/libs/tokens/img/xvs.svg", + "decimals": 18, + "symbol": "XVS", + }, + }, + }, + { + "borrowApyPercentage": "2.014488268288307401", + "borrowBalanceCents": "743724749.881571973423", + "borrowBalanceTokens": "7437523.951581", + "borrowCapTokens": "0", + "borrowDistributions": [ + { + "apyPercentage": "16.981964056809385", + "dailyDistributedTokens": "499.9999968", + "token": { + "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", + "asset": "/src/libs/tokens/img/xvs.svg", + "decimals": 18, + "symbol": "XVS", + }, + "type": "rewardDistributor", + }, + { + "apyPercentage": "0.20019958435848473", + "referenceValues": { + "userBorrowBalanceTokens": "10009.21", + "userSupplyBalanceTokens": "5003.94", + "userXvsStakedTokens": "3731.33", + }, + "token": { + "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", + "asset": "/src/libs/tokens/img/usdt.svg", + "decimals": 6, + "symbol": "USDT", + }, + "type": "primeSimulation", + }, + ], + "borrowerCount": 249, + "cashTokens": "1.0000736633870942814396398228131475074669e+34", + "collateralFactor": 0.8, + "disabledTokenActions": [], + "exchangeRateVTokens": "49.8066352191466231613", + "isCollateralOfUser": true, + "liquidityCents": "1.000036490649026183145198711400933542774047455327e+36", + "reserveFactor": 0.1, + "reserveTokens": "0", + "supplierCount": 670, + "supplyApyPercentage": "0", + "supplyBalanceCents": "1.00003649064902618314530970887489046343322854178897705712904885e+36", + "supplyBalanceTokens": "1.000073663387094281439750824413033895903139261475326095e+34", + "supplyCapTokens": "1.15792089237316195423570985008687907853269984665640564039457584007913129639935e+71", + "supplyDistributions": [ + { + "apyPercentage": "0", + "dailyDistributedTokens": "499.9999968", + "token": { + "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", + "asset": "/src/libs/tokens/img/xvs.svg", + "decimals": 18, + "symbol": "XVS", + }, + "type": "rewardDistributor", + }, + { + "apyPercentage": "0.23026397657694986", + "referenceValues": { + "userBorrowBalanceTokens": "10009.21", + "userSupplyBalanceTokens": "5003.94", + "userXvsStakedTokens": "3731.33", + }, + "token": { + "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", + "asset": "/src/libs/tokens/img/usdt.svg", + "decimals": 6, + "symbol": "USDT", + }, + "type": "primeSimulation", + }, + ], + "tokenPriceCents": "99.996283", + "userBorrowBalanceCents": "9999628300000", + "userBorrowBalanceTokens": "100000000000", + "userPercentOfLimit": 3.1, + "userSupplyBalanceCents": "199992566000000", + "userSupplyBalanceTokens": "2000000000000", + "userWalletBalanceCents": "999962830000000", + "userWalletBalanceTokens": "10000000000000", + "vToken": { + "address": "0xb7526572FFE56AB9D7489838Bf2E18e3323b441A", + "decimals": 8, + "symbol": "vUSDT", + "underlyingToken": { + "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", + "asset": "/src/libs/tokens/img/usdt.svg", + "decimals": 6, + "symbol": "USDT", + }, + }, + }, + { + "borrowApyPercentage": "2.01448842548712155", + "borrowBalanceCents": "1562397934365776.075433634816", + "borrowBalanceTokens": "15624370577897.031296", + "borrowCapTokens": "0", + "borrowDistributions": [ + { + "apyPercentage": "0.000007467880158706", + "dailyDistributedTokens": "499.9999968", + "token": { + "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", + "asset": "/src/libs/tokens/img/xvs.svg", + "decimals": 18, + "symbol": "XVS", + }, + "type": "rewardDistributor", + }, + { + "apyPercentage": "0.20019958435848473", + "referenceValues": { + "userBorrowBalanceTokens": "2405.43", + "userSupplyBalanceTokens": "13068.75", + "userXvsStakedTokens": "3265.3", + }, + "token": { + "address": "0x16227D60f7a0e586C66B005219dfc887D13C9531", + "asset": "/src/libs/tokens/img/usdc.svg", + "decimals": 6, + "symbol": "USDC", + }, + "type": "primeSimulation", + }, + ], + "borrowerCount": 229, + "cashTokens": "1.010176805025969148511141552e+21", + "collateralFactor": 0.81, + "disabledTokenActions": [], + "exchangeRateVTokens": "47.12928141003911013496", + "isCollateralOfUser": true, + "liquidityCents": "1.01015151019877129824366283301553792e+23", + "reserveFactor": 0.1, + "reserveTokens": "0", + "supplierCount": 534, + "supplyApyPercentage": "2.7256320003e-8", + "supplyBalanceCents": "1.0101515258227468345608256850251328456045167117888e+23", + "supplyBalanceTokens": "1.01017682065033591897223674983334867265528e+21", + "supplyCapTokens": "1.15792089237316195423570985008687907853269984665640564039457584007913129639935e+71", + "supplyDistributions": [ + { + "apyPercentage": "0", + "dailyDistributedTokens": "499.9999968", + "token": { + "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", + "asset": "/src/libs/tokens/img/xvs.svg", + "decimals": 18, + "symbol": "XVS", + }, + "type": "rewardDistributor", + }, + { + "apyPercentage": "0.23026397657694986", + "referenceValues": { + "userBorrowBalanceTokens": "2405.43", + "userSupplyBalanceTokens": "13068.75", + "userXvsStakedTokens": "3265.3", + }, + "token": { + "address": "0x16227D60f7a0e586C66B005219dfc887D13C9531", + "asset": "/src/libs/tokens/img/usdc.svg", + "decimals": 6, + "symbol": "USDC", + }, + "type": "primeSimulation", + }, + ], + "tokenPriceCents": "99.997496", + "userBorrowBalanceCents": "9999749600000", + "userBorrowBalanceTokens": "100000000000", + "userPercentOfLimit": 3.1, + "userSupplyBalanceCents": "199994992000000", + "userSupplyBalanceTokens": "2000000000000", + "userWalletBalanceCents": "999974960000000", + "userWalletBalanceTokens": "10000000000000", + "vToken": { + "address": "0xD5C4C2e2facBEB59D0216D0595d63FcDc6F9A1a7", + "decimals": 8, + "symbol": "vUSDC", + "underlyingToken": { + "address": "0x16227D60f7a0e586C66B005219dfc887D13C9531", + "asset": "/src/libs/tokens/img/usdc.svg", + "decimals": 6, + "symbol": "USDC", + }, + }, + }, + ], + "comptrollerAddress": "0x94d1820b2D1c7c7452A163983Dc888CEC546b77D", + "isIsolated": false, + "name": "Core Pool", + "userBorrowBalanceCents": "19999377930013.362645", + "userBorrowLimitCents": "321989996798198.068756", + "userSupplyBalanceCents": "399987558598267.2529", + }, + { + "assets": [ + { + "borrowApyPercentage": "3.037255751760131518", + "borrowBalanceCents": "10266.891765447722", + "borrowBalanceTokens": "102.672734", + "borrowCapTokens": "14880000", + "borrowDistributions": [ + { + "apyPercentage": "0", + "dailyDistributedTokens": "0", + "token": { + "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", + "asset": "/src/libs/tokens/img/usdt.svg", + "decimals": 6, + "symbol": "USDT", + }, + "type": "rewardDistributor", + }, + ], + "borrowerCount": 20, + "cashTokens": "2649291.731707", + "collateralFactor": 0.8, + "disabledTokenActions": [], + "exchangeRateVTokens": "0.99999847176819609601", + "isCollateralOfUser": true, + "liquidityCents": "264919325.753333245081", + "reserveFactor": 0.1, + "reserveTokens": "0", + "supplierCount": 10, + "supplyApyPercentage": "0.000104360310305731", + "supplyBalanceCents": "264929592.64509868800383953542527752", + "supplyBalanceTokens": "2649394.40444099995200661144", + "supplyCapTokens": "18600000", + "supplyDistributions": [ + { + "apyPercentage": "0", + "dailyDistributedTokens": "0", + "token": { + "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", + "asset": "/src/libs/tokens/img/usdt.svg", + "decimals": 6, + "symbol": "USDT", + }, + "type": "rewardDistributor", + }, + ], + "tokenPriceCents": "99.996283", + "userBorrowBalanceCents": "9999628300000", + "userBorrowBalanceTokens": "100000000000", + "userPercentOfLimit": 6.25, + "userSupplyBalanceCents": "199992566000000", + "userSupplyBalanceTokens": "2000000000000", + "userWalletBalanceCents": "999962830000000", + "userWalletBalanceTokens": "10000000000000", + "vToken": { + "address": "0x80CC30811e362aC9aB857C3d7875CbcCc0b65750", + "decimals": 8, + "symbol": "vUSDT", + "underlyingToken": { + "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", + "asset": "/src/libs/tokens/img/usdt.svg", + "decimals": 6, + "symbol": "USDT", + }, + }, + }, + ], + "comptrollerAddress": "0x23a73971A6B9f6580c048B9CB188869B2A2aA2aD", + "isIsolated": true, + "name": "DeFi", + "userBorrowBalanceCents": "9999628300000", + "userBorrowLimitCents": "159994052800000", + "userSupplyBalanceCents": "199992566000000", + }, + { + "assets": [ + { + "borrowApyPercentage": "3.992487050504593481", + "borrowBalanceCents": "1032129.557718287222", + "borrowBalanceTokens": "10321.679234", + "borrowCapTokens": "14880000", + "borrowDistributions": [], + "borrowerCount": 20, + "cashTokens": "101166.023761", + "collateralFactor": 0.8, + "disabledTokenActions": [], + "exchangeRateVTokens": "0.997398625122774492", + "isCollateralOfUser": true, + "liquidityCents": "10116226.341989680363", + "reserveFactor": 0.1, + "reserveTokens": "0.000131", + "supplierCount": 10, + "supplyApyPercentage": "0.326746289860669541", + "supplyBalanceCents": "11148355.88660845370158439626770976", + "supplyBalanceTokens": "111487.70286399999189554272", + "supplyCapTokens": "18600000", + "supplyDistributions": [], + "tokenPriceCents": "99.996283", + "userBorrowBalanceCents": "9999628300000", + "userBorrowBalanceTokens": "100000000000", + "userPercentOfLimit": 6.25, + "userSupplyBalanceCents": "199992566000000", + "userSupplyBalanceTokens": "2000000000000", + "userWalletBalanceCents": "999962830000000", + "userWalletBalanceTokens": "10000000000000", + "vToken": { + "address": "0x0bFE4e0B8A2a096A27e5B18b078d25be57C08634", + "decimals": 8, + "symbol": "vUSDT", + "underlyingToken": { + "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", + "asset": "/src/libs/tokens/img/usdt.svg", + "decimals": 6, + "symbol": "USDT", + }, + }, + }, + ], + "comptrollerAddress": "0x1F4f0989C51f12DAcacD4025018176711f3Bf289", + "isIsolated": true, + "name": "GameFi", + "userBorrowBalanceCents": "9999628300000", + "userBorrowLimitCents": "159994052800000", + "userSupplyBalanceCents": "199992566000000", + }, + { + "assets": [ + { + "borrowApyPercentage": "3.03685757665446184", + "borrowBalanceCents": "0.000399985132", + "borrowBalanceTokens": "0.000004", + "borrowCapTokens": "14880000", + "borrowDistributions": [ + { + "apyPercentage": "0", + "dailyDistributedTokens": "0", + "token": { + "address": "0xe73774DfCD551BF75650772dC2cC56a2B6323453", + "asset": "/src/libs/tokens/img/lisUSD.png", + "decimals": 18, + "symbol": "lisUSD", + }, + "type": "rewardDistributor", + }, + { + "apyPercentage": "0.20019958435848473", + "referenceValues": { + "userBorrowBalanceTokens": "2e-7", + "userSupplyBalanceTokens": "1103100.00000039991050000018", + "userXvsStakedTokens": "1000", + }, + "token": { + "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", + "asset": "/src/libs/tokens/img/usdt.svg", + "decimals": 6, + "symbol": "USDT", + }, + "type": "primeSimulation", + }, + ], + "borrowerCount": 20, + "cashTokens": "11031000", + "collateralFactor": 0.8, + "disabledTokenActions": [], + "exchangeRateVTokens": "0.999999999999545", + "isCollateralOfUser": false, + "liquidityCents": "1103058997.773", + "reserveFactor": 0.1, + "reserveTokens": "0", + "supplierCount": 10, + "supplyApyPercentage": "0", + "supplyBalanceCents": "1103058997.77339989563532689599327223", + "supplyBalanceTokens": "11031000.00000399910500000181", + "supplyCapTokens": "18600000", + "supplyDistributions": [ + { + "apyPercentage": "0", + "dailyDistributedTokens": "0", + "token": { + "address": "0xe73774DfCD551BF75650772dC2cC56a2B6323453", + "asset": "/src/libs/tokens/img/lisUSD.png", + "decimals": 18, + "symbol": "lisUSD", + }, + "type": "rewardDistributor", + }, + { + "apyPercentage": "0.23026397657694986", + "referenceValues": { + "userBorrowBalanceTokens": "2e-7", + "userSupplyBalanceTokens": "1103100.00000039991050000018", + "userXvsStakedTokens": "1000", + }, + "token": { + "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", + "asset": "/src/libs/tokens/img/usdt.svg", + "decimals": 6, + "symbol": "USDT", + }, + "type": "primeSimulation", + }, + ], + "tokenPriceCents": "99.996283", + "userBorrowBalanceCents": "0", + "userBorrowBalanceTokens": "0", + "userPercentOfLimit": 0, + "userSupplyBalanceCents": "199992566000000", + "userSupplyBalanceTokens": "2000000000000", + "userWalletBalanceCents": "999962830000000", + "userWalletBalanceTokens": "10000000000000", + "vToken": { + "address": "0x2197d02cC9cd1ad51317A0a85A656a0c82383A7c", + "decimals": 8, + "symbol": "vUSDT", + "underlyingToken": { + "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", + "asset": "/src/libs/tokens/img/usdt.svg", + "decimals": 6, + "symbol": "USDT", + }, + }, + }, + { + "borrowApyPercentage": "397.358195317640926827", + "borrowBalanceCents": "14020.2378315565440147153504", + "borrowBalanceTokens": "0.267025220823379366", + "borrowCapTokens": "56000", + "borrowDistributions": [ + { + "apyPercentage": "0", + "dailyDistributedTokens": "0", + "token": { + "address": "0xe73774DfCD551BF75650772dC2cC56a2B6323453", + "asset": "/src/libs/tokens/img/lisUSD.png", + "decimals": 18, + "symbol": "lisUSD", + }, + "type": "rewardDistributor", + }, + ], + "borrowerCount": 20, + "cashTokens": "0.000705300034659891", + "collateralFactor": 0.45, + "disabledTokenActions": [], + "exchangeRateVTokens": "0.856077892298015039", + "isCollateralOfUser": true, + "liquidityCents": "37.0319859601477808269104", + "reserveFactor": 0.25, + "reserveTokens": "0", + "supplierCount": 10, + "supplyApyPercentage": "232.211474860496839891", + "supplyBalanceCents": "14057.269817516691795017207856", + "supplyBalanceTokens": "0.26773052085803925699", + "supplyCapTokens": "80000", + "supplyDistributions": [ + { + "apyPercentage": "0", + "dailyDistributedTokens": "0", + "token": { + "address": "0xe73774DfCD551BF75650772dC2cC56a2B6323453", + "asset": "/src/libs/tokens/img/lisUSD.png", + "decimals": 18, + "symbol": "lisUSD", + }, + "type": "rewardDistributor", + }, + ], + "tokenPriceCents": "52505.2944", + "userBorrowBalanceCents": "5250.52944", + "userBorrowBalanceTokens": "0.1", + "userPercentOfLimit": 11.11, + "userSupplyBalanceCents": "105010.5888", + "userSupplyBalanceTokens": "2", + "userWalletBalanceCents": "525052.944", + "userWalletBalanceTokens": "10", + "vToken": { + "address": "0x231dED0Dfc99634e52EE1a1329586bc970d773b3", + "decimals": 8, + "symbol": "vWBNB", + "underlyingToken": { + "address": "0xae13d989daC2f0dEbFf460aC112a837C89BAa7cd", + "asset": "/src/libs/tokens/img/wbnb.svg", + "decimals": 18, + "symbol": "WBNB", + }, + }, + }, + ], + "comptrollerAddress": "0x596B11acAACF03217287939f88d63b51d3771704", + "isIsolated": true, + "name": "Liquid Staked BNB", + "userBorrowBalanceCents": "5250.52944", + "userBorrowLimitCents": "47254.76496", + "userSupplyBalanceCents": "199992566105010.5888", + }, + { + "assets": [ + { + "borrowApyPercentage": "0.011616016420902095", + "borrowBalanceCents": "399.985132", + "borrowBalanceTokens": "4", + "borrowCapTokens": "900000", + "borrowDistributions": [], + "borrowerCount": 20, + "cashTokens": "6006", + "collateralFactor": 0.75, + "disabledTokenActions": [], + "exchangeRateVTokens": "1", + "isCollateralOfUser": true, + "liquidityCents": "600577.675698", + "reserveFactor": 0.1, + "reserveTokens": "0", + "supplierCount": 10, + "supplyApyPercentage": "0.00000695665176131", + "supplyBalanceCents": "600977.66083", + "supplyBalanceTokens": "6010", + "supplyCapTokens": "1000000", + "supplyDistributions": [], + "tokenPriceCents": "99.996283", + "userBorrowBalanceCents": "9999628300000", + "userBorrowBalanceTokens": "100000000000", + "userPercentOfLimit": 6.66, + "userSupplyBalanceCents": "199992566000000", + "userSupplyBalanceTokens": "2000000000000", + "userWalletBalanceCents": "999962830000000", + "userWalletBalanceTokens": "10000000000000", + "vToken": { + "address": "0x3AF2bE7AbEF0f840b196D99d79F4B803a5dB14a1", + "decimals": 8, + "symbol": "vUSDT", + "underlyingToken": { + "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", + "asset": "/src/libs/tokens/img/usdt.svg", + "decimals": 6, + "symbol": "USDT", + }, + }, + }, + ], + "comptrollerAddress": "0x92e8E3C202093A495e98C10f9fcaa5Abe288F74A", + "isIsolated": true, + "name": "Meme", + "userBorrowBalanceCents": "9999628300000", + "userBorrowLimitCents": "149994424500000", + "userSupplyBalanceCents": "199992566000000", + }, + { + "assets": [ + { + "borrowApyPercentage": "5.116012290184441153", + "borrowBalanceCents": "1030091.4588649133175062", + "borrowBalanceTokens": "10300.914588649133175062", + "borrowCapTokens": "200000", + "borrowDistributions": [], + "borrowerCount": 20, + "cashTokens": "32569.640339677929523638", + "collateralFactor": 0.65, + "disabledTokenActions": [], + "exchangeRateVTokens": "0.9930076443898276885", + "isCollateralOfUser": true, + "liquidityCents": "3256964.0339677929523638", + "reserveFactor": 0.2, + "reserveTokens": "0.000166728600388574", + "supplierCount": 10, + "supplyApyPercentage": "0.963756279976176856", + "supplyBalanceCents": "4287055.476159846231009819", + "supplyBalanceTokens": "42870.55476159846231009819", + "supplyCapTokens": "500000", + "supplyDistributions": [], + "tokenPriceCents": "100", + "userBorrowBalanceCents": "10", + "userBorrowBalanceTokens": "0.1", + "userPercentOfLimit": 0, + "userSupplyBalanceCents": "200", + "userSupplyBalanceTokens": "2", + "userWalletBalanceCents": "1000", + "userWalletBalanceTokens": "10", + "vToken": { + "address": "0x170d3b2da05cc2124334240fB34ad1359e34C562", + "decimals": 8, + "symbol": "vlisUSD", + "underlyingToken": { + "address": "0xe73774DfCD551BF75650772dC2cC56a2B6323453", + "asset": "/src/libs/tokens/img/lisUSD.png", + "decimals": 18, + "symbol": "lisUSD", + }, + }, + }, + { + "borrowApyPercentage": "2.023012476743554002", + "borrowBalanceCents": "100461.088822525373", + "borrowBalanceTokens": "1004.648231", + "borrowCapTokens": "400000", + "borrowDistributions": [ + { + "apyPercentage": "0", + "dailyDistributedTokens": "0", + "token": { + "address": "0xe73774DfCD551BF75650772dC2cC56a2B6323453", + "asset": "/src/libs/tokens/img/lisUSD.png", + "decimals": 18, + "symbol": "lisUSD", + }, + "type": "rewardDistributor", + }, + { + "apyPercentage": "0.20019958435848473", + "referenceValues": { + "userBorrowBalanceTokens": "50.23241155", + "userSupplyBalanceTokens": "99917.91834089999667918285", + "userXvsStakedTokens": "1000", + }, + "token": { + "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", + "asset": "/src/libs/tokens/img/usdt.svg", + "decimals": 6, + "symbol": "USDT", + }, + "type": "primeSimulation", + }, + ], + "borrowerCount": 20, + "cashTokens": "998174.53518", + "collateralFactor": 0.8, + "disabledTokenActions": [], + "exchangeRateVTokens": "0.99998934225265418908", + "isCollateralOfUser": true, + "liquidityCents": "99813743.30325273594", + "reserveFactor": 0.1, + "reserveTokens": "0.000002", + "supplierCount": 10, + "supplyApyPercentage": "0.001812471504422768", + "supplyBalanceCents": "99914204.39187526542630629377313097", + "supplyBalanceTokens": "999179.18340899996679182859", + "supplyCapTokens": "1000000", + "supplyDistributions": [ + { + "apyPercentage": "0", + "dailyDistributedTokens": "0", + "token": { + "address": "0xe73774DfCD551BF75650772dC2cC56a2B6323453", + "asset": "/src/libs/tokens/img/lisUSD.png", + "decimals": 18, + "symbol": "lisUSD", + }, + "type": "rewardDistributor", + }, + { + "apyPercentage": "0.23026397657694986", + "referenceValues": { + "userBorrowBalanceTokens": "50.23241155", + "userSupplyBalanceTokens": "99917.91834089999667918285", + "userXvsStakedTokens": "1000", + }, + "token": { + "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", + "asset": "/src/libs/tokens/img/usdt.svg", + "decimals": 6, + "symbol": "USDT", + }, + "type": "primeSimulation", + }, + ], + "tokenPriceCents": "99.996283", + "userBorrowBalanceCents": "9999628300000", + "userBorrowBalanceTokens": "100000000000", + "userPercentOfLimit": 6.24, + "userSupplyBalanceCents": "199992566000000", + "userSupplyBalanceTokens": "2000000000000", + "userWalletBalanceCents": "999962830000000", + "userWalletBalanceTokens": "10000000000000", + "vToken": { + "address": "0x3338988d0beb4419Acb8fE624218754053362D06", + "decimals": 8, + "symbol": "vUSDT", + "underlyingToken": { + "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", + "asset": "/src/libs/tokens/img/usdt.svg", + "decimals": 6, + "symbol": "USDT", + }, + }, + }, + ], + "comptrollerAddress": "0x10b57706AD2345e590c2eA4DC02faef0d9f5b08B", + "isIsolated": true, + "name": "Stablecoins", + "userBorrowBalanceCents": "9999628300010", + "userBorrowLimitCents": "159994052800130", + "userSupplyBalanceCents": "199992566000200", + }, + { + "assets": [ + { + "borrowApyPercentage": "3.03685757665446184", + "borrowBalanceCents": "0", + "borrowBalanceTokens": "0", + "borrowCapTokens": "14880000", + "borrowDistributions": [ + { + "apyPercentage": "0.20019958435848473", + "referenceValues": { + "userBorrowBalanceTokens": "0", + "userSupplyBalanceTokens": "1000", + "userXvsStakedTokens": "1000", + }, + "token": { + "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", + "asset": "/src/libs/tokens/img/usdt.svg", + "decimals": 6, + "symbol": "USDT", + }, + "type": "primeSimulation", + }, + ], + "borrowerCount": 20, + "cashTokens": "10000", + "collateralFactor": 0.8, + "disabledTokenActions": [], + "exchangeRateVTokens": "1", + "isCollateralOfUser": false, + "liquidityCents": "999962.83", + "reserveFactor": 0.1, + "reserveTokens": "0", + "supplierCount": 10, + "supplyApyPercentage": "0", + "supplyBalanceCents": "999962.83", + "supplyBalanceTokens": "10000", + "supplyCapTokens": "18600000", + "supplyDistributions": [ + { + "apyPercentage": "0.23026397657694986", + "referenceValues": { + "userBorrowBalanceTokens": "0", + "userSupplyBalanceTokens": "1000", + "userXvsStakedTokens": "1000", + }, + "token": { + "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", + "asset": "/src/libs/tokens/img/usdt.svg", + "decimals": 6, + "symbol": "USDT", + }, + "type": "primeSimulation", + }, + ], + "tokenPriceCents": "99.996283", + "userBorrowBalanceCents": "0", + "userBorrowBalanceTokens": "0", + "userPercentOfLimit": 0, + "userSupplyBalanceCents": "199992566000000", + "userSupplyBalanceTokens": "2000000000000", + "userWalletBalanceCents": "999962830000000", + "userWalletBalanceTokens": "10000000000000", + "vToken": { + "address": "0x712774CBFFCBD60e9825871CcEFF2F917442b2c3", + "decimals": 8, + "symbol": "vUSDT", + "underlyingToken": { + "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", + "asset": "/src/libs/tokens/img/usdt.svg", + "decimals": 6, + "symbol": "USDT", + }, + }, + }, + ], + "comptrollerAddress": "0x11537D023f489E4EF0C7157cc729C7B69CbE0c97", + "isIsolated": true, + "name": "Tron", + "userBorrowBalanceCents": "0", + "userBorrowLimitCents": "0", + "userSupplyBalanceCents": "199992566000000", + }, + ], +} +`; + +exports[`useGetPools > fetches and formats Prime distributions and Prime distribution simulations if user is Prime 1`] = ` +{ + "pools": [ + { + "assets": [ + { + "borrowApyPercentage": "2.014488270427066776", + "borrowBalanceCents": "24663011775918.58670630114424219627258", + "borrowBalanceTokens": "246628588661.936163058800477859", + "borrowCapTokens": "1e-18", + "borrowDistributions": [ + { + "apyPercentage": "0", + "dailyDistributedTokens": "0", + "token": { + "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", + "asset": "/src/libs/tokens/img/xvs.svg", + "decimals": 18, + "symbol": "XVS", + }, + "type": "rewardDistributor", + }, + { + "apyPercentage": "0.32051113933926345", + "token": { + "address": "0x8301F2213c0eeD49a7E28Ae4c3e91722919B8B47", + "asset": "/src/libs/tokens/img/busd.svg", + "decimals": 18, + "symbol": "BUSD", + }, + "type": "prime", + }, + { + "apyPercentage": "0.20019958435848473", + "referenceValues": { + "userBorrowBalanceTokens": "563078969.54779945903835725538", + "userSupplyBalanceTokens": "1071811362327614186.97785297335171745333", + "userXvsStakedTokens": "1000", + }, + "token": { + "address": "0x8301F2213c0eeD49a7E28Ae4c3e91722919B8B47", + "asset": "/src/libs/tokens/img/busd.svg", + "decimals": 18, + "symbol": "BUSD", + }, + "type": "primeSimulation", + }, + ], + "borrowerCount": 438, + "cashTokens": "1.00000000080503544824460983238917793784e+21", + "collateralFactor": 0, + "disabledTokenActions": [ + "supply", + "borrow", + ], + "exchangeRateVTokens": "49.19405324154271215086", + "isCollateralOfUser": true, + "liquidityCents": "1.000006200805040439464388948970138750743214608e+23", + "reserveFactor": 1, + "reserveTokens": "0", + "supplierCount": 933, + "supplyApyPercentage": "0", + "supplyBalanceCents": "1.000006201051670556767362816225462034303610544746e+23", + "supplyBalanceTokens": "1.00000000105166403645033682413715238395883e+21", + "supplyCapTokens": "0", + "supplyDistributions": [ + { + "apyPercentage": "0", + "dailyDistributedTokens": "0", + "token": { + "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", + "asset": "/src/libs/tokens/img/xvs.svg", + "decimals": 18, + "symbol": "XVS", + }, + "type": "rewardDistributor", + }, + { + "apyPercentage": "0.2904197513866391", + "token": { + "address": "0x8301F2213c0eeD49a7E28Ae4c3e91722919B8B47", + "asset": "/src/libs/tokens/img/busd.svg", + "decimals": 18, + "symbol": "BUSD", + }, + "type": "prime", + }, + { + "apyPercentage": "0.23026397657694986", + "referenceValues": { + "userBorrowBalanceTokens": "563078969.54779945903835725538", + "userSupplyBalanceTokens": "1071811362327614186.97785297335171745333", + "userXvsStakedTokens": "1000", + }, + "token": { + "address": "0x8301F2213c0eeD49a7E28Ae4c3e91722919B8B47", + "asset": "/src/libs/tokens/img/busd.svg", + "decimals": 18, + "symbol": "BUSD", + }, + "type": "primeSimulation", + }, + ], + "tokenPriceCents": "100.00062", + "userBorrowBalanceCents": "10.000062", + "userBorrowBalanceTokens": "0.1", + "userPercentOfLimit": 0, + "userSupplyBalanceCents": "200.00124", + "userSupplyBalanceTokens": "2", + "userWalletBalanceCents": "1000.0062", + "userWalletBalanceTokens": "10", + "vToken": { + "address": "0x08e0A5575De71037aE36AbfAfb516595fE68e5e4", + "decimals": 8, + "symbol": "vBUSD", + "underlyingToken": { + "address": "0x8301F2213c0eeD49a7E28Ae4c3e91722919B8B47", + "asset": "/src/libs/tokens/img/busd.svg", + "decimals": 18, + "symbol": "BUSD", + }, + }, + }, + { + "borrowApyPercentage": "12.72621843315593399", + "borrowBalanceCents": "3721959398.320962344455482972", + "borrowBalanceTokens": "15136.746248595758022748", + "borrowCapTokens": "0", + "borrowDistributions": [ + { + "apyPercentage": "1.5797413696681861", + "dailyDistributedTokens": "250.0000128", + "token": { + "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", + "asset": "/src/libs/tokens/img/xvs.svg", + "decimals": 18, + "symbol": "XVS", + }, + "type": "rewardDistributor", + }, + ], + "borrowerCount": 35, + "cashTokens": "0", + "collateralFactor": 0.8, + "disabledTokenActions": [], + "exchangeRateVTokens": "37.63966306652044917955", + "isCollateralOfUser": true, + "liquidityCents": "0", + "reserveFactor": 0.1, + "reserveTokens": "21.269535066688975633", + "supplierCount": 25, + "supplyApyPercentage": "11.401000590716290067", + "supplyBalanceCents": "3716729453.6129492577232450137", + "supplyBalanceTokens": "15115.4767135290690422233", + "supplyCapTokens": "1.15792089237316195423570985008687907853269984665640564039457584007913129639935e+59", + "supplyDistributions": [ + { + "apyPercentage": "1.5819817239252298", + "dailyDistributedTokens": "250.0000128", + "token": { + "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", + "asset": "/src/libs/tokens/img/xvs.svg", + "decimals": 18, + "symbol": "XVS", + }, + "type": "rewardDistributor", + }, + ], + "tokenPriceCents": "245889", + "userBorrowBalanceCents": "24588.9", + "userBorrowBalanceTokens": "0.1", + "userPercentOfLimit": 0, + "userSupplyBalanceCents": "491778", + "userSupplyBalanceTokens": "2", + "userWalletBalanceCents": "2458890", + "userWalletBalanceTokens": "10", + "vToken": { + "address": "0x162D005F0Fff510E54958Cfc5CF32A3180A84aab", + "decimals": 8, + "symbol": "vETH", + "underlyingToken": { + "address": "0x98f7A83361F7Ac8765CcEBAB1425da6b341958a7", + "asset": "/src/libs/tokens/img/eth.svg", + "decimals": 18, + "isNative": true, + "symbol": "ETH", + }, + }, + }, + { + "borrowApyPercentage": "179.96505731769223966", + "borrowBalanceCents": "54206766464.991794941213834066224", + "borrowBalanceTokens": "1032405.72373577234796371", + "borrowCapTokens": "0", + "borrowDistributions": [ + { + "apyPercentage": "0.6478221277312901", + "dailyDistributedTokens": "1499.9999904", + "token": { + "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", + "asset": "/src/libs/tokens/img/xvs.svg", + "decimals": 18, + "symbol": "XVS", + }, + "type": "rewardDistributor", + }, + ], + "borrowerCount": 263, + "cashTokens": "5.556233762724731858", + "collateralFactor": 0.8, + "disabledTokenActions": [], + "exchangeRateVTokens": "5.63429988023545433776", + "isCollateralOfUser": true, + "liquidityCents": "291731.6894670817923653489952", + "reserveFactor": 0.25, + "reserveTokens": "187487.447405339178551222", + "supplierCount": 923, + "supplyApyPercentage": "156.911092632839993416", + "supplyBalanceCents": "44362974574.359412320127072323564288", + "supplyBalanceTokens": "844923.83256419589412162352", + "supplyCapTokens": "1.15792089237316195423570985008687907853269984665640564039457584007913129639935e+59", + "supplyDistributions": [ + { + "apyPercentage": "0.7921351276470645", + "dailyDistributedTokens": "1499.9999904", + "token": { + "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", + "asset": "/src/libs/tokens/img/xvs.svg", + "decimals": 18, + "symbol": "XVS", + }, + "type": "rewardDistributor", + }, + ], + "tokenPriceCents": "52505.2944", + "userBorrowBalanceCents": "5250.52944", + "userBorrowBalanceTokens": "0.1", + "userPercentOfLimit": 0, + "userSupplyBalanceCents": "105010.5888", + "userSupplyBalanceTokens": "2", + "userWalletBalanceCents": "525052.944", + "userWalletBalanceTokens": "10", + "vToken": { + "address": "0x2E7222e51c0f6e98610A1543Aa3836E092CDe62c", + "decimals": 8, + "symbol": "vBNB", + "underlyingToken": { + "address": "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE", + "asset": "/src/libs/tokens/img/bnb.svg", + "decimals": 18, + "isNative": true, + "symbol": "BNB", + }, + }, + }, + { + "borrowApyPercentage": "16.800248594171254373", + "borrowBalanceCents": "266527277.02974427316207663041589", + "borrowBalanceTokens": "416884.364702270734855123", + "borrowCapTokens": "270000", + "borrowDistributions": [ + { + "apyPercentage": "0", + "dailyDistributedTokens": "0", + "token": { + "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", + "asset": "/src/libs/tokens/img/xvs.svg", + "decimals": 18, + "symbol": "XVS", + }, + "type": "rewardDistributor", + }, + ], + "borrowerCount": 68, + "cashTokens": "2259657.074761148481496107", + "collateralFactor": 0.6, + "disabledTokenActions": [], + "exchangeRateVTokens": "47.36910235297224095005", + "isCollateralOfUser": true, + "liquidityCents": "1444669788.91666196711723462774301", + "reserveFactor": 0.25, + "reserveTokens": "0", + "supplierCount": 274, + "supplyApyPercentage": "1.830999347346963073", + "supplyBalanceCents": "1711197065.9464062401284554003137589", + "supplyBalanceTokens": "2676541.43946341921611527123", + "supplyCapTokens": "3750000", + "supplyDistributions": [ + { + "apyPercentage": "0", + "dailyDistributedTokens": "0", + "token": { + "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", + "asset": "/src/libs/tokens/img/xvs.svg", + "decimals": 18, + "symbol": "XVS", + }, + "type": "rewardDistributor", + }, + ], + "tokenPriceCents": "639.33143", + "userBorrowBalanceCents": "63.933143", + "userBorrowBalanceTokens": "0.1", + "userPercentOfLimit": 0, + "userSupplyBalanceCents": "1278.66286", + "userSupplyBalanceTokens": "2", + "userWalletBalanceCents": "6393.3143", + "userWalletBalanceTokens": "10", + "vToken": { + "address": "0x6d6F697e34145Bb95c54E77482d97cc261Dc237E", + "decimals": 8, + "symbol": "vXVS", + "underlyingToken": { + "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", + "asset": "/src/libs/tokens/img/xvs.svg", + "decimals": 18, + "symbol": "XVS", + }, + }, + }, + { + "borrowApyPercentage": "2.014488268288307401", + "borrowBalanceCents": "743724749.881571973423", + "borrowBalanceTokens": "7437523.951581", + "borrowCapTokens": "0", + "borrowDistributions": [ + { + "apyPercentage": "16.981964056809385", + "dailyDistributedTokens": "499.9999968", + "token": { + "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", + "asset": "/src/libs/tokens/img/xvs.svg", + "decimals": 18, + "symbol": "XVS", + }, + "type": "rewardDistributor", + }, + { + "apyPercentage": "0.32051113933926345", + "token": { + "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", + "asset": "/src/libs/tokens/img/usdt.svg", + "decimals": 6, + "symbol": "USDT", + }, + "type": "prime", + }, + { + "apyPercentage": "0.20019958435848473", + "referenceValues": { + "userBorrowBalanceTokens": "10009.21", + "userSupplyBalanceTokens": "5003.94", + "userXvsStakedTokens": "3731.33", + }, + "token": { + "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", + "asset": "/src/libs/tokens/img/usdt.svg", + "decimals": 6, + "symbol": "USDT", + }, + "type": "primeSimulation", + }, + ], + "borrowerCount": 249, + "cashTokens": "1.0000736633870942814396398228131475074669e+34", + "collateralFactor": 0.8, + "disabledTokenActions": [], + "exchangeRateVTokens": "49.8066352191466231613", + "isCollateralOfUser": true, + "liquidityCents": "1.000036490649026183145198711400933542774047455327e+36", + "reserveFactor": 0.1, + "reserveTokens": "0", + "supplierCount": 670, + "supplyApyPercentage": "0", + "supplyBalanceCents": "1.00003649064902618314530970887489046343322854178897705712904885e+36", + "supplyBalanceTokens": "1.000073663387094281439750824413033895903139261475326095e+34", + "supplyCapTokens": "1.15792089237316195423570985008687907853269984665640564039457584007913129639935e+71", + "supplyDistributions": [ + { + "apyPercentage": "0", + "dailyDistributedTokens": "499.9999968", + "token": { + "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", + "asset": "/src/libs/tokens/img/xvs.svg", + "decimals": 18, + "symbol": "XVS", + }, + "type": "rewardDistributor", + }, + { + "apyPercentage": "0.2904197513866391", + "token": { + "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", + "asset": "/src/libs/tokens/img/usdt.svg", + "decimals": 6, + "symbol": "USDT", + }, + "type": "prime", + }, + { + "apyPercentage": "0.23026397657694986", + "referenceValues": { + "userBorrowBalanceTokens": "10009.21", + "userSupplyBalanceTokens": "5003.94", + "userXvsStakedTokens": "3731.33", + }, + "token": { + "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", + "asset": "/src/libs/tokens/img/usdt.svg", + "decimals": 6, + "symbol": "USDT", + }, + "type": "primeSimulation", + }, + ], + "tokenPriceCents": "99.996283", + "userBorrowBalanceCents": "9999628300000", + "userBorrowBalanceTokens": "100000000000", + "userPercentOfLimit": 3.1, + "userSupplyBalanceCents": "199992566000000", + "userSupplyBalanceTokens": "2000000000000", + "userWalletBalanceCents": "999962830000000", + "userWalletBalanceTokens": "10000000000000", + "vToken": { + "address": "0xb7526572FFE56AB9D7489838Bf2E18e3323b441A", + "decimals": 8, + "symbol": "vUSDT", + "underlyingToken": { + "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", + "asset": "/src/libs/tokens/img/usdt.svg", + "decimals": 6, + "symbol": "USDT", + }, + }, + }, + { + "borrowApyPercentage": "2.01448842548712155", + "borrowBalanceCents": "1562397934365776.075433634816", + "borrowBalanceTokens": "15624370577897.031296", + "borrowCapTokens": "0", + "borrowDistributions": [ + { + "apyPercentage": "0.000007467880158706", + "dailyDistributedTokens": "499.9999968", + "token": { + "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", + "asset": "/src/libs/tokens/img/xvs.svg", + "decimals": 18, + "symbol": "XVS", + }, + "type": "rewardDistributor", + }, + { + "apyPercentage": "0.32051113933926345", + "token": { + "address": "0x16227D60f7a0e586C66B005219dfc887D13C9531", + "asset": "/src/libs/tokens/img/usdc.svg", + "decimals": 6, + "symbol": "USDC", + }, + "type": "prime", + }, + { + "apyPercentage": "0.20019958435848473", + "referenceValues": { + "userBorrowBalanceTokens": "2405.43", + "userSupplyBalanceTokens": "13068.75", + "userXvsStakedTokens": "3265.3", + }, + "token": { + "address": "0x16227D60f7a0e586C66B005219dfc887D13C9531", + "asset": "/src/libs/tokens/img/usdc.svg", + "decimals": 6, + "symbol": "USDC", + }, + "type": "primeSimulation", + }, + ], + "borrowerCount": 229, + "cashTokens": "1.010176805025969148511141552e+21", + "collateralFactor": 0.81, + "disabledTokenActions": [], + "exchangeRateVTokens": "47.12928141003911013496", + "isCollateralOfUser": true, + "liquidityCents": "1.01015151019877129824366283301553792e+23", + "reserveFactor": 0.1, + "reserveTokens": "0", + "supplierCount": 534, + "supplyApyPercentage": "2.7256320003e-8", + "supplyBalanceCents": "1.0101515258227468345608256850251328456045167117888e+23", + "supplyBalanceTokens": "1.01017682065033591897223674983334867265528e+21", + "supplyCapTokens": "1.15792089237316195423570985008687907853269984665640564039457584007913129639935e+71", + "supplyDistributions": [ + { + "apyPercentage": "0", + "dailyDistributedTokens": "499.9999968", + "token": { + "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", + "asset": "/src/libs/tokens/img/xvs.svg", + "decimals": 18, + "symbol": "XVS", + }, + "type": "rewardDistributor", + }, + { + "apyPercentage": "0.2904197513866391", + "token": { + "address": "0x16227D60f7a0e586C66B005219dfc887D13C9531", + "asset": "/src/libs/tokens/img/usdc.svg", + "decimals": 6, + "symbol": "USDC", + }, + "type": "prime", + }, + { + "apyPercentage": "0.23026397657694986", + "referenceValues": { + "userBorrowBalanceTokens": "2405.43", + "userSupplyBalanceTokens": "13068.75", + "userXvsStakedTokens": "3265.3", + }, + "token": { + "address": "0x16227D60f7a0e586C66B005219dfc887D13C9531", + "asset": "/src/libs/tokens/img/usdc.svg", + "decimals": 6, + "symbol": "USDC", + }, + "type": "primeSimulation", + }, + ], + "tokenPriceCents": "99.997496", + "userBorrowBalanceCents": "9999749600000", + "userBorrowBalanceTokens": "100000000000", + "userPercentOfLimit": 3.1, + "userSupplyBalanceCents": "199994992000000", + "userSupplyBalanceTokens": "2000000000000", + "userWalletBalanceCents": "999974960000000", + "userWalletBalanceTokens": "10000000000000", + "vToken": { + "address": "0xD5C4C2e2facBEB59D0216D0595d63FcDc6F9A1a7", + "decimals": 8, + "symbol": "vUSDC", + "underlyingToken": { + "address": "0x16227D60f7a0e586C66B005219dfc887D13C9531", + "asset": "/src/libs/tokens/img/usdc.svg", + "decimals": 6, + "symbol": "USDC", + }, + }, + }, + ], + "comptrollerAddress": "0x94d1820b2D1c7c7452A163983Dc888CEC546b77D", + "isIsolated": false, + "name": "Core Pool", + "userBorrowBalanceCents": "19999377930013.362645", + "userBorrowLimitCents": "321989996798198.068756", + "userSupplyBalanceCents": "399987558598267.2529", + }, + { + "assets": [ + { + "borrowApyPercentage": "3.037255751760131518", + "borrowBalanceCents": "10266.891765447722", + "borrowBalanceTokens": "102.672734", + "borrowCapTokens": "14880000", + "borrowDistributions": [ + { + "apyPercentage": "0", + "dailyDistributedTokens": "0", + "token": { + "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", + "asset": "/src/libs/tokens/img/usdt.svg", + "decimals": 6, + "symbol": "USDT", + }, + "type": "rewardDistributor", + }, + ], + "borrowerCount": 20, + "cashTokens": "2649291.731707", + "collateralFactor": 0.8, + "disabledTokenActions": [], + "exchangeRateVTokens": "0.99999847176819609601", + "isCollateralOfUser": true, + "liquidityCents": "264919325.753333245081", + "reserveFactor": 0.1, + "reserveTokens": "0", + "supplierCount": 10, + "supplyApyPercentage": "0.000104360310305731", + "supplyBalanceCents": "264929592.64509868800383953542527752", + "supplyBalanceTokens": "2649394.40444099995200661144", + "supplyCapTokens": "18600000", + "supplyDistributions": [ + { + "apyPercentage": "0", + "dailyDistributedTokens": "0", + "token": { + "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", + "asset": "/src/libs/tokens/img/usdt.svg", + "decimals": 6, + "symbol": "USDT", + }, + "type": "rewardDistributor", + }, + ], + "tokenPriceCents": "99.996283", + "userBorrowBalanceCents": "9999628300000", + "userBorrowBalanceTokens": "100000000000", + "userPercentOfLimit": 6.25, + "userSupplyBalanceCents": "199992566000000", + "userSupplyBalanceTokens": "2000000000000", + "userWalletBalanceCents": "999962830000000", + "userWalletBalanceTokens": "10000000000000", + "vToken": { + "address": "0x80CC30811e362aC9aB857C3d7875CbcCc0b65750", + "decimals": 8, + "symbol": "vUSDT", + "underlyingToken": { + "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", + "asset": "/src/libs/tokens/img/usdt.svg", + "decimals": 6, + "symbol": "USDT", + }, + }, + }, + ], + "comptrollerAddress": "0x23a73971A6B9f6580c048B9CB188869B2A2aA2aD", + "isIsolated": true, + "name": "DeFi", + "userBorrowBalanceCents": "9999628300000", + "userBorrowLimitCents": "159994052800000", + "userSupplyBalanceCents": "199992566000000", + }, + { + "assets": [ + { + "borrowApyPercentage": "3.992487050504593481", + "borrowBalanceCents": "1032129.557718287222", + "borrowBalanceTokens": "10321.679234", + "borrowCapTokens": "14880000", + "borrowDistributions": [], + "borrowerCount": 20, + "cashTokens": "101166.023761", + "collateralFactor": 0.8, + "disabledTokenActions": [], + "exchangeRateVTokens": "0.997398625122774492", + "isCollateralOfUser": true, + "liquidityCents": "10116226.341989680363", + "reserveFactor": 0.1, + "reserveTokens": "0.000131", + "supplierCount": 10, + "supplyApyPercentage": "0.326746289860669541", + "supplyBalanceCents": "11148355.88660845370158439626770976", + "supplyBalanceTokens": "111487.70286399999189554272", + "supplyCapTokens": "18600000", + "supplyDistributions": [], + "tokenPriceCents": "99.996283", + "userBorrowBalanceCents": "9999628300000", + "userBorrowBalanceTokens": "100000000000", + "userPercentOfLimit": 6.25, + "userSupplyBalanceCents": "199992566000000", + "userSupplyBalanceTokens": "2000000000000", + "userWalletBalanceCents": "999962830000000", + "userWalletBalanceTokens": "10000000000000", + "vToken": { + "address": "0x0bFE4e0B8A2a096A27e5B18b078d25be57C08634", + "decimals": 8, + "symbol": "vUSDT", + "underlyingToken": { + "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", + "asset": "/src/libs/tokens/img/usdt.svg", + "decimals": 6, + "symbol": "USDT", + }, + }, + }, + ], + "comptrollerAddress": "0x1F4f0989C51f12DAcacD4025018176711f3Bf289", + "isIsolated": true, + "name": "GameFi", + "userBorrowBalanceCents": "9999628300000", + "userBorrowLimitCents": "159994052800000", + "userSupplyBalanceCents": "199992566000000", + }, + { + "assets": [ + { + "borrowApyPercentage": "3.03685757665446184", + "borrowBalanceCents": "0.000399985132", + "borrowBalanceTokens": "0.000004", + "borrowCapTokens": "14880000", + "borrowDistributions": [ + { + "apyPercentage": "0", + "dailyDistributedTokens": "0", + "token": { + "address": "0xe73774DfCD551BF75650772dC2cC56a2B6323453", + "asset": "/src/libs/tokens/img/lisUSD.png", + "decimals": 18, + "symbol": "lisUSD", + }, + "type": "rewardDistributor", + }, + { + "apyPercentage": "0.32051113933926345", + "token": { + "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", + "asset": "/src/libs/tokens/img/usdt.svg", + "decimals": 6, + "symbol": "USDT", + }, + "type": "prime", + }, + { + "apyPercentage": "0.20019958435848473", + "referenceValues": { + "userBorrowBalanceTokens": "2e-7", + "userSupplyBalanceTokens": "1103100.00000039991050000018", + "userXvsStakedTokens": "1000", + }, + "token": { + "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", + "asset": "/src/libs/tokens/img/usdt.svg", + "decimals": 6, + "symbol": "USDT", + }, + "type": "primeSimulation", + }, + ], + "borrowerCount": 20, + "cashTokens": "11031000", + "collateralFactor": 0.8, + "disabledTokenActions": [], + "exchangeRateVTokens": "0.999999999999545", + "isCollateralOfUser": false, + "liquidityCents": "1103058997.773", + "reserveFactor": 0.1, + "reserveTokens": "0", + "supplierCount": 10, + "supplyApyPercentage": "0", + "supplyBalanceCents": "1103058997.77339989563532689599327223", + "supplyBalanceTokens": "11031000.00000399910500000181", + "supplyCapTokens": "18600000", + "supplyDistributions": [ + { + "apyPercentage": "0", + "dailyDistributedTokens": "0", + "token": { + "address": "0xe73774DfCD551BF75650772dC2cC56a2B6323453", + "asset": "/src/libs/tokens/img/lisUSD.png", + "decimals": 18, + "symbol": "lisUSD", + }, + "type": "rewardDistributor", + }, + { + "apyPercentage": "0.2904197513866391", + "token": { + "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", + "asset": "/src/libs/tokens/img/usdt.svg", + "decimals": 6, + "symbol": "USDT", + }, + "type": "prime", + }, + { + "apyPercentage": "0.23026397657694986", + "referenceValues": { + "userBorrowBalanceTokens": "2e-7", + "userSupplyBalanceTokens": "1103100.00000039991050000018", + "userXvsStakedTokens": "1000", + }, + "token": { + "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", + "asset": "/src/libs/tokens/img/usdt.svg", + "decimals": 6, + "symbol": "USDT", + }, + "type": "primeSimulation", + }, + ], + "tokenPriceCents": "99.996283", + "userBorrowBalanceCents": "0", + "userBorrowBalanceTokens": "0", + "userPercentOfLimit": 0, + "userSupplyBalanceCents": "199992566000000", + "userSupplyBalanceTokens": "2000000000000", + "userWalletBalanceCents": "999962830000000", + "userWalletBalanceTokens": "10000000000000", + "vToken": { + "address": "0x2197d02cC9cd1ad51317A0a85A656a0c82383A7c", + "decimals": 8, + "symbol": "vUSDT", + "underlyingToken": { + "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", + "asset": "/src/libs/tokens/img/usdt.svg", + "decimals": 6, + "symbol": "USDT", + }, + }, + }, + { + "borrowApyPercentage": "397.358195317640926827", + "borrowBalanceCents": "14020.2378315565440147153504", + "borrowBalanceTokens": "0.267025220823379366", + "borrowCapTokens": "56000", + "borrowDistributions": [ + { + "apyPercentage": "0", + "dailyDistributedTokens": "0", + "token": { + "address": "0xe73774DfCD551BF75650772dC2cC56a2B6323453", + "asset": "/src/libs/tokens/img/lisUSD.png", + "decimals": 18, + "symbol": "lisUSD", + }, + "type": "rewardDistributor", + }, + ], + "borrowerCount": 20, + "cashTokens": "0.000705300034659891", + "collateralFactor": 0.45, + "disabledTokenActions": [], + "exchangeRateVTokens": "0.856077892298015039", + "isCollateralOfUser": true, + "liquidityCents": "37.0319859601477808269104", + "reserveFactor": 0.25, + "reserveTokens": "0", + "supplierCount": 10, + "supplyApyPercentage": "232.211474860496839891", + "supplyBalanceCents": "14057.269817516691795017207856", + "supplyBalanceTokens": "0.26773052085803925699", + "supplyCapTokens": "80000", + "supplyDistributions": [ + { + "apyPercentage": "0", + "dailyDistributedTokens": "0", + "token": { + "address": "0xe73774DfCD551BF75650772dC2cC56a2B6323453", + "asset": "/src/libs/tokens/img/lisUSD.png", + "decimals": 18, + "symbol": "lisUSD", + }, + "type": "rewardDistributor", + }, + ], + "tokenPriceCents": "52505.2944", + "userBorrowBalanceCents": "5250.52944", + "userBorrowBalanceTokens": "0.1", + "userPercentOfLimit": 11.11, + "userSupplyBalanceCents": "105010.5888", + "userSupplyBalanceTokens": "2", + "userWalletBalanceCents": "525052.944", + "userWalletBalanceTokens": "10", + "vToken": { + "address": "0x231dED0Dfc99634e52EE1a1329586bc970d773b3", + "decimals": 8, + "symbol": "vWBNB", + "underlyingToken": { + "address": "0xae13d989daC2f0dEbFf460aC112a837C89BAa7cd", + "asset": "/src/libs/tokens/img/wbnb.svg", + "decimals": 18, + "symbol": "WBNB", + }, + }, + }, + ], + "comptrollerAddress": "0x596B11acAACF03217287939f88d63b51d3771704", + "isIsolated": true, + "name": "Liquid Staked BNB", + "userBorrowBalanceCents": "5250.52944", + "userBorrowLimitCents": "47254.76496", + "userSupplyBalanceCents": "199992566105010.5888", + }, + { + "assets": [ + { + "borrowApyPercentage": "0.011616016420902095", + "borrowBalanceCents": "399.985132", + "borrowBalanceTokens": "4", + "borrowCapTokens": "900000", + "borrowDistributions": [], + "borrowerCount": 20, + "cashTokens": "6006", + "collateralFactor": 0.75, + "disabledTokenActions": [], + "exchangeRateVTokens": "1", + "isCollateralOfUser": true, + "liquidityCents": "600577.675698", + "reserveFactor": 0.1, + "reserveTokens": "0", + "supplierCount": 10, + "supplyApyPercentage": "0.00000695665176131", + "supplyBalanceCents": "600977.66083", + "supplyBalanceTokens": "6010", + "supplyCapTokens": "1000000", + "supplyDistributions": [], + "tokenPriceCents": "99.996283", + "userBorrowBalanceCents": "9999628300000", + "userBorrowBalanceTokens": "100000000000", + "userPercentOfLimit": 6.66, + "userSupplyBalanceCents": "199992566000000", + "userSupplyBalanceTokens": "2000000000000", + "userWalletBalanceCents": "999962830000000", + "userWalletBalanceTokens": "10000000000000", + "vToken": { + "address": "0x3AF2bE7AbEF0f840b196D99d79F4B803a5dB14a1", + "decimals": 8, + "symbol": "vUSDT", + "underlyingToken": { + "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", + "asset": "/src/libs/tokens/img/usdt.svg", + "decimals": 6, + "symbol": "USDT", + }, + }, + }, + ], + "comptrollerAddress": "0x92e8E3C202093A495e98C10f9fcaa5Abe288F74A", + "isIsolated": true, + "name": "Meme", + "userBorrowBalanceCents": "9999628300000", + "userBorrowLimitCents": "149994424500000", + "userSupplyBalanceCents": "199992566000000", + }, + { + "assets": [ + { + "borrowApyPercentage": "5.116012290184441153", + "borrowBalanceCents": "1030091.4588649133175062", + "borrowBalanceTokens": "10300.914588649133175062", + "borrowCapTokens": "200000", + "borrowDistributions": [], + "borrowerCount": 20, + "cashTokens": "32569.640339677929523638", + "collateralFactor": 0.65, + "disabledTokenActions": [], + "exchangeRateVTokens": "0.9930076443898276885", + "isCollateralOfUser": true, + "liquidityCents": "3256964.0339677929523638", + "reserveFactor": 0.2, + "reserveTokens": "0.000166728600388574", + "supplierCount": 10, + "supplyApyPercentage": "0.963756279976176856", + "supplyBalanceCents": "4287055.476159846231009819", + "supplyBalanceTokens": "42870.55476159846231009819", + "supplyCapTokens": "500000", + "supplyDistributions": [], + "tokenPriceCents": "100", + "userBorrowBalanceCents": "10", + "userBorrowBalanceTokens": "0.1", + "userPercentOfLimit": 0, + "userSupplyBalanceCents": "200", + "userSupplyBalanceTokens": "2", + "userWalletBalanceCents": "1000", + "userWalletBalanceTokens": "10", + "vToken": { + "address": "0x170d3b2da05cc2124334240fB34ad1359e34C562", + "decimals": 8, + "symbol": "vlisUSD", + "underlyingToken": { + "address": "0xe73774DfCD551BF75650772dC2cC56a2B6323453", + "asset": "/src/libs/tokens/img/lisUSD.png", + "decimals": 18, + "symbol": "lisUSD", + }, + }, + }, + { + "borrowApyPercentage": "2.023012476743554002", + "borrowBalanceCents": "100461.088822525373", + "borrowBalanceTokens": "1004.648231", + "borrowCapTokens": "400000", + "borrowDistributions": [ + { + "apyPercentage": "0", + "dailyDistributedTokens": "0", + "token": { + "address": "0xe73774DfCD551BF75650772dC2cC56a2B6323453", + "asset": "/src/libs/tokens/img/lisUSD.png", + "decimals": 18, + "symbol": "lisUSD", + }, + "type": "rewardDistributor", + }, + { + "apyPercentage": "0.32051113933926345", + "token": { + "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", + "asset": "/src/libs/tokens/img/usdt.svg", + "decimals": 6, + "symbol": "USDT", + }, + "type": "prime", + }, + { + "apyPercentage": "0.20019958435848473", + "referenceValues": { + "userBorrowBalanceTokens": "50.23241155", + "userSupplyBalanceTokens": "99917.91834089999667918285", + "userXvsStakedTokens": "1000", + }, + "token": { + "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", + "asset": "/src/libs/tokens/img/usdt.svg", + "decimals": 6, + "symbol": "USDT", + }, + "type": "primeSimulation", + }, + ], + "borrowerCount": 20, + "cashTokens": "998174.53518", + "collateralFactor": 0.8, + "disabledTokenActions": [], + "exchangeRateVTokens": "0.99998934225265418908", + "isCollateralOfUser": true, + "liquidityCents": "99813743.30325273594", + "reserveFactor": 0.1, + "reserveTokens": "0.000002", + "supplierCount": 10, + "supplyApyPercentage": "0.001812471504422768", + "supplyBalanceCents": "99914204.39187526542630629377313097", + "supplyBalanceTokens": "999179.18340899996679182859", + "supplyCapTokens": "1000000", + "supplyDistributions": [ + { + "apyPercentage": "0", + "dailyDistributedTokens": "0", + "token": { + "address": "0xe73774DfCD551BF75650772dC2cC56a2B6323453", + "asset": "/src/libs/tokens/img/lisUSD.png", + "decimals": 18, + "symbol": "lisUSD", + }, + "type": "rewardDistributor", + }, + { + "apyPercentage": "0.2904197513866391", + "token": { + "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", + "asset": "/src/libs/tokens/img/usdt.svg", + "decimals": 6, + "symbol": "USDT", + }, + "type": "prime", + }, + { + "apyPercentage": "0.23026397657694986", + "referenceValues": { + "userBorrowBalanceTokens": "50.23241155", + "userSupplyBalanceTokens": "99917.91834089999667918285", + "userXvsStakedTokens": "1000", + }, + "token": { + "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", + "asset": "/src/libs/tokens/img/usdt.svg", + "decimals": 6, + "symbol": "USDT", + }, + "type": "primeSimulation", + }, + ], + "tokenPriceCents": "99.996283", + "userBorrowBalanceCents": "9999628300000", + "userBorrowBalanceTokens": "100000000000", + "userPercentOfLimit": 6.24, + "userSupplyBalanceCents": "199992566000000", + "userSupplyBalanceTokens": "2000000000000", + "userWalletBalanceCents": "999962830000000", + "userWalletBalanceTokens": "10000000000000", + "vToken": { + "address": "0x3338988d0beb4419Acb8fE624218754053362D06", + "decimals": 8, + "symbol": "vUSDT", + "underlyingToken": { + "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", + "asset": "/src/libs/tokens/img/usdt.svg", + "decimals": 6, + "symbol": "USDT", + }, + }, + }, + ], + "comptrollerAddress": "0x10b57706AD2345e590c2eA4DC02faef0d9f5b08B", + "isIsolated": true, + "name": "Stablecoins", + "userBorrowBalanceCents": "9999628300010", + "userBorrowLimitCents": "159994052800130", + "userSupplyBalanceCents": "199992566000200", + }, + { + "assets": [ + { + "borrowApyPercentage": "3.03685757665446184", + "borrowBalanceCents": "0", + "borrowBalanceTokens": "0", + "borrowCapTokens": "14880000", + "borrowDistributions": [ + { + "apyPercentage": "0.32051113933926345", + "token": { + "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", + "asset": "/src/libs/tokens/img/usdt.svg", + "decimals": 6, + "symbol": "USDT", + }, + "type": "prime", + }, + { + "apyPercentage": "0.20019958435848473", + "referenceValues": { + "userBorrowBalanceTokens": "0", + "userSupplyBalanceTokens": "1000", + "userXvsStakedTokens": "1000", + }, + "token": { + "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", + "asset": "/src/libs/tokens/img/usdt.svg", + "decimals": 6, + "symbol": "USDT", + }, + "type": "primeSimulation", + }, + ], + "borrowerCount": 20, + "cashTokens": "10000", + "collateralFactor": 0.8, + "disabledTokenActions": [], + "exchangeRateVTokens": "1", + "isCollateralOfUser": false, + "liquidityCents": "999962.83", + "reserveFactor": 0.1, + "reserveTokens": "0", + "supplierCount": 10, + "supplyApyPercentage": "0", + "supplyBalanceCents": "999962.83", + "supplyBalanceTokens": "10000", + "supplyCapTokens": "18600000", + "supplyDistributions": [ + { + "apyPercentage": "0.2904197513866391", + "token": { + "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", + "asset": "/src/libs/tokens/img/usdt.svg", + "decimals": 6, + "symbol": "USDT", + }, + "type": "prime", + }, + { + "apyPercentage": "0.23026397657694986", + "referenceValues": { + "userBorrowBalanceTokens": "0", + "userSupplyBalanceTokens": "1000", + "userXvsStakedTokens": "1000", + }, + "token": { + "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", + "asset": "/src/libs/tokens/img/usdt.svg", + "decimals": 6, + "symbol": "USDT", + }, + "type": "primeSimulation", + }, + ], + "tokenPriceCents": "99.996283", + "userBorrowBalanceCents": "0", + "userBorrowBalanceTokens": "0", + "userPercentOfLimit": 0, + "userSupplyBalanceCents": "199992566000000", + "userSupplyBalanceTokens": "2000000000000", + "userWalletBalanceCents": "999962830000000", + "userWalletBalanceTokens": "10000000000000", + "vToken": { + "address": "0x712774CBFFCBD60e9825871CcEFF2F917442b2c3", + "decimals": 8, + "symbol": "vUSDT", + "underlyingToken": { + "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", + "asset": "/src/libs/tokens/img/usdt.svg", + "decimals": 6, + "symbol": "USDT", + }, + }, + }, + ], + "comptrollerAddress": "0x11537D023f489E4EF0C7157cc729C7B69CbE0c97", + "isIsolated": true, + "name": "Tron", + "userBorrowBalanceCents": "0", + "userBorrowLimitCents": "0", + "userSupplyBalanceCents": "199992566000000", + }, + ], +} +`; + +exports[`useGetPools > filters out Prime simulations that are 0 1`] = ` +{ + "pools": [ + { + "assets": [ + { + "borrowApyPercentage": "2.014488270427066776", + "borrowBalanceCents": "24663011775918.58670630114424219627258", + "borrowBalanceTokens": "246628588661.936163058800477859", + "borrowCapTokens": "1e-18", + "borrowDistributions": [ + { + "apyPercentage": "0", + "dailyDistributedTokens": "0", + "token": { + "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", + "asset": "/src/libs/tokens/img/xvs.svg", + "decimals": 18, + "symbol": "XVS", + }, + "type": "rewardDistributor", + }, + { + "apyPercentage": "0", + "token": { + "address": "0x8301F2213c0eeD49a7E28Ae4c3e91722919B8B47", + "asset": "/src/libs/tokens/img/busd.svg", + "decimals": 18, + "symbol": "BUSD", + }, + "type": "prime", + }, + ], + "borrowerCount": 438, + "cashTokens": "1.00000000080503544824460983238917793784e+21", + "collateralFactor": 0, + "disabledTokenActions": [ + "supply", + "borrow", + ], + "exchangeRateVTokens": "49.19405324154271215086", + "isCollateralOfUser": true, + "liquidityCents": "1.000006200805040439464388948970138750743214608e+23", + "reserveFactor": 1, + "reserveTokens": "0", + "supplierCount": 933, + "supplyApyPercentage": "0", + "supplyBalanceCents": "1.000006201051670556767362816225462034303610544746e+23", + "supplyBalanceTokens": "1.00000000105166403645033682413715238395883e+21", + "supplyCapTokens": "0", + "supplyDistributions": [ + { + "apyPercentage": "0", + "dailyDistributedTokens": "0", + "token": { + "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", + "asset": "/src/libs/tokens/img/xvs.svg", + "decimals": 18, + "symbol": "XVS", + }, + "type": "rewardDistributor", + }, + { + "apyPercentage": "0", + "token": { + "address": "0x8301F2213c0eeD49a7E28Ae4c3e91722919B8B47", + "asset": "/src/libs/tokens/img/busd.svg", + "decimals": 18, + "symbol": "BUSD", + }, + "type": "prime", + }, + ], + "tokenPriceCents": "100.00062", + "userBorrowBalanceCents": "10.000062", + "userBorrowBalanceTokens": "0.1", + "userPercentOfLimit": 0, + "userSupplyBalanceCents": "200.00124", + "userSupplyBalanceTokens": "2", + "userWalletBalanceCents": "1000.0062", + "userWalletBalanceTokens": "10", + "vToken": { + "address": "0x08e0A5575De71037aE36AbfAfb516595fE68e5e4", + "decimals": 8, + "symbol": "vBUSD", + "underlyingToken": { + "address": "0x8301F2213c0eeD49a7E28Ae4c3e91722919B8B47", + "asset": "/src/libs/tokens/img/busd.svg", + "decimals": 18, + "symbol": "BUSD", + }, + }, + }, + { + "borrowApyPercentage": "12.72621843315593399", + "borrowBalanceCents": "3721959398.320962344455482972", + "borrowBalanceTokens": "15136.746248595758022748", + "borrowCapTokens": "0", + "borrowDistributions": [ + { + "apyPercentage": "1.5797413696681861", + "dailyDistributedTokens": "250.0000128", + "token": { + "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", + "asset": "/src/libs/tokens/img/xvs.svg", + "decimals": 18, + "symbol": "XVS", + }, + "type": "rewardDistributor", + }, + ], + "borrowerCount": 35, + "cashTokens": "0", + "collateralFactor": 0.8, + "disabledTokenActions": [], + "exchangeRateVTokens": "37.63966306652044917955", + "isCollateralOfUser": true, + "liquidityCents": "0", + "reserveFactor": 0.1, + "reserveTokens": "21.269535066688975633", + "supplierCount": 25, + "supplyApyPercentage": "11.401000590716290067", + "supplyBalanceCents": "3716729453.6129492577232450137", + "supplyBalanceTokens": "15115.4767135290690422233", + "supplyCapTokens": "1.15792089237316195423570985008687907853269984665640564039457584007913129639935e+59", + "supplyDistributions": [ + { + "apyPercentage": "1.5819817239252298", + "dailyDistributedTokens": "250.0000128", + "token": { + "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", + "asset": "/src/libs/tokens/img/xvs.svg", + "decimals": 18, + "symbol": "XVS", + }, + "type": "rewardDistributor", + }, + ], + "tokenPriceCents": "245889", + "userBorrowBalanceCents": "24588.9", + "userBorrowBalanceTokens": "0.1", + "userPercentOfLimit": 0, + "userSupplyBalanceCents": "491778", + "userSupplyBalanceTokens": "2", + "userWalletBalanceCents": "2458890", + "userWalletBalanceTokens": "10", + "vToken": { + "address": "0x162D005F0Fff510E54958Cfc5CF32A3180A84aab", + "decimals": 8, + "symbol": "vETH", + "underlyingToken": { + "address": "0x98f7A83361F7Ac8765CcEBAB1425da6b341958a7", + "asset": "/src/libs/tokens/img/eth.svg", + "decimals": 18, + "isNative": true, + "symbol": "ETH", + }, + }, + }, + { + "borrowApyPercentage": "179.96505731769223966", + "borrowBalanceCents": "54206766464.991794941213834066224", + "borrowBalanceTokens": "1032405.72373577234796371", + "borrowCapTokens": "0", + "borrowDistributions": [ + { + "apyPercentage": "0.6478221277312901", + "dailyDistributedTokens": "1499.9999904", + "token": { + "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", + "asset": "/src/libs/tokens/img/xvs.svg", + "decimals": 18, + "symbol": "XVS", + }, + "type": "rewardDistributor", + }, + ], + "borrowerCount": 263, + "cashTokens": "5.556233762724731858", + "collateralFactor": 0.8, + "disabledTokenActions": [], + "exchangeRateVTokens": "5.63429988023545433776", + "isCollateralOfUser": true, + "liquidityCents": "291731.6894670817923653489952", + "reserveFactor": 0.25, + "reserveTokens": "187487.447405339178551222", + "supplierCount": 923, + "supplyApyPercentage": "156.911092632839993416", + "supplyBalanceCents": "44362974574.359412320127072323564288", + "supplyBalanceTokens": "844923.83256419589412162352", + "supplyCapTokens": "1.15792089237316195423570985008687907853269984665640564039457584007913129639935e+59", + "supplyDistributions": [ + { + "apyPercentage": "0.7921351276470645", + "dailyDistributedTokens": "1499.9999904", + "token": { + "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", + "asset": "/src/libs/tokens/img/xvs.svg", + "decimals": 18, + "symbol": "XVS", + }, + "type": "rewardDistributor", + }, + ], + "tokenPriceCents": "52505.2944", + "userBorrowBalanceCents": "5250.52944", + "userBorrowBalanceTokens": "0.1", + "userPercentOfLimit": 0, + "userSupplyBalanceCents": "105010.5888", + "userSupplyBalanceTokens": "2", + "userWalletBalanceCents": "525052.944", + "userWalletBalanceTokens": "10", + "vToken": { + "address": "0x2E7222e51c0f6e98610A1543Aa3836E092CDe62c", + "decimals": 8, + "symbol": "vBNB", + "underlyingToken": { + "address": "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE", + "asset": "/src/libs/tokens/img/bnb.svg", + "decimals": 18, + "isNative": true, + "symbol": "BNB", + }, + }, + }, + { + "borrowApyPercentage": "16.800248594171254373", + "borrowBalanceCents": "266527277.02974427316207663041589", + "borrowBalanceTokens": "416884.364702270734855123", + "borrowCapTokens": "270000", + "borrowDistributions": [ + { + "apyPercentage": "0", + "dailyDistributedTokens": "0", + "token": { + "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", + "asset": "/src/libs/tokens/img/xvs.svg", + "decimals": 18, + "symbol": "XVS", + }, + "type": "rewardDistributor", + }, + ], + "borrowerCount": 68, + "cashTokens": "2259657.074761148481496107", + "collateralFactor": 0.6, + "disabledTokenActions": [], + "exchangeRateVTokens": "47.36910235297224095005", + "isCollateralOfUser": true, + "liquidityCents": "1444669788.91666196711723462774301", + "reserveFactor": 0.25, + "reserveTokens": "0", + "supplierCount": 274, + "supplyApyPercentage": "1.830999347346963073", + "supplyBalanceCents": "1711197065.9464062401284554003137589", + "supplyBalanceTokens": "2676541.43946341921611527123", + "supplyCapTokens": "3750000", + "supplyDistributions": [ + { + "apyPercentage": "0", + "dailyDistributedTokens": "0", + "token": { + "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", + "asset": "/src/libs/tokens/img/xvs.svg", + "decimals": 18, + "symbol": "XVS", + }, + "type": "rewardDistributor", + }, + ], + "tokenPriceCents": "639.33143", + "userBorrowBalanceCents": "63.933143", + "userBorrowBalanceTokens": "0.1", + "userPercentOfLimit": 0, + "userSupplyBalanceCents": "1278.66286", + "userSupplyBalanceTokens": "2", + "userWalletBalanceCents": "6393.3143", + "userWalletBalanceTokens": "10", + "vToken": { + "address": "0x6d6F697e34145Bb95c54E77482d97cc261Dc237E", + "decimals": 8, + "symbol": "vXVS", + "underlyingToken": { + "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", + "asset": "/src/libs/tokens/img/xvs.svg", + "decimals": 18, + "symbol": "XVS", + }, + }, + }, + { + "borrowApyPercentage": "2.014488268288307401", + "borrowBalanceCents": "743724749.881571973423", + "borrowBalanceTokens": "7437523.951581", + "borrowCapTokens": "0", + "borrowDistributions": [ + { + "apyPercentage": "16.981964056809385", + "dailyDistributedTokens": "499.9999968", + "token": { + "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", + "asset": "/src/libs/tokens/img/xvs.svg", + "decimals": 18, + "symbol": "XVS", + }, + "type": "rewardDistributor", + }, + { + "apyPercentage": "0", + "token": { + "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", + "asset": "/src/libs/tokens/img/usdt.svg", + "decimals": 6, + "symbol": "USDT", + }, + "type": "prime", + }, + ], + "borrowerCount": 249, + "cashTokens": "1.0000736633870942814396398228131475074669e+34", + "collateralFactor": 0.8, + "disabledTokenActions": [], + "exchangeRateVTokens": "49.8066352191466231613", + "isCollateralOfUser": true, + "liquidityCents": "1.000036490649026183145198711400933542774047455327e+36", + "reserveFactor": 0.1, + "reserveTokens": "0", + "supplierCount": 670, + "supplyApyPercentage": "0", + "supplyBalanceCents": "1.00003649064902618314530970887489046343322854178897705712904885e+36", + "supplyBalanceTokens": "1.000073663387094281439750824413033895903139261475326095e+34", + "supplyCapTokens": "1.15792089237316195423570985008687907853269984665640564039457584007913129639935e+71", + "supplyDistributions": [ + { + "apyPercentage": "0", + "dailyDistributedTokens": "499.9999968", + "token": { + "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", + "asset": "/src/libs/tokens/img/xvs.svg", + "decimals": 18, + "symbol": "XVS", + }, + "type": "rewardDistributor", + }, + { + "apyPercentage": "0", + "token": { + "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", + "asset": "/src/libs/tokens/img/usdt.svg", + "decimals": 6, + "symbol": "USDT", + }, + "type": "prime", + }, + ], + "tokenPriceCents": "99.996283", + "userBorrowBalanceCents": "9999628300000", + "userBorrowBalanceTokens": "100000000000", + "userPercentOfLimit": 3.1, + "userSupplyBalanceCents": "199992566000000", + "userSupplyBalanceTokens": "2000000000000", + "userWalletBalanceCents": "999962830000000", + "userWalletBalanceTokens": "10000000000000", + "vToken": { + "address": "0xb7526572FFE56AB9D7489838Bf2E18e3323b441A", + "decimals": 8, + "symbol": "vUSDT", + "underlyingToken": { + "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", + "asset": "/src/libs/tokens/img/usdt.svg", + "decimals": 6, + "symbol": "USDT", + }, + }, + }, + { + "borrowApyPercentage": "2.01448842548712155", + "borrowBalanceCents": "1562397934365776.075433634816", + "borrowBalanceTokens": "15624370577897.031296", + "borrowCapTokens": "0", + "borrowDistributions": [ + { + "apyPercentage": "0.000007467880158706", + "dailyDistributedTokens": "499.9999968", + "token": { + "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", + "asset": "/src/libs/tokens/img/xvs.svg", + "decimals": 18, + "symbol": "XVS", + }, + "type": "rewardDistributor", + }, + { + "apyPercentage": "0", + "token": { + "address": "0x16227D60f7a0e586C66B005219dfc887D13C9531", + "asset": "/src/libs/tokens/img/usdc.svg", + "decimals": 6, + "symbol": "USDC", + }, + "type": "prime", + }, + ], + "borrowerCount": 229, + "cashTokens": "1.010176805025969148511141552e+21", + "collateralFactor": 0.81, + "disabledTokenActions": [], + "exchangeRateVTokens": "47.12928141003911013496", + "isCollateralOfUser": true, + "liquidityCents": "1.01015151019877129824366283301553792e+23", + "reserveFactor": 0.1, + "reserveTokens": "0", + "supplierCount": 534, + "supplyApyPercentage": "2.7256320003e-8", + "supplyBalanceCents": "1.0101515258227468345608256850251328456045167117888e+23", + "supplyBalanceTokens": "1.01017682065033591897223674983334867265528e+21", + "supplyCapTokens": "1.15792089237316195423570985008687907853269984665640564039457584007913129639935e+71", + "supplyDistributions": [ + { + "apyPercentage": "0", + "dailyDistributedTokens": "499.9999968", + "token": { + "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", + "asset": "/src/libs/tokens/img/xvs.svg", + "decimals": 18, + "symbol": "XVS", + }, + "type": "rewardDistributor", + }, + { + "apyPercentage": "0", + "token": { + "address": "0x16227D60f7a0e586C66B005219dfc887D13C9531", + "asset": "/src/libs/tokens/img/usdc.svg", + "decimals": 6, + "symbol": "USDC", + }, + "type": "prime", + }, + ], + "tokenPriceCents": "99.997496", + "userBorrowBalanceCents": "9999749600000", + "userBorrowBalanceTokens": "100000000000", + "userPercentOfLimit": 3.1, + "userSupplyBalanceCents": "199994992000000", + "userSupplyBalanceTokens": "2000000000000", + "userWalletBalanceCents": "999974960000000", + "userWalletBalanceTokens": "10000000000000", + "vToken": { + "address": "0xD5C4C2e2facBEB59D0216D0595d63FcDc6F9A1a7", + "decimals": 8, + "symbol": "vUSDC", + "underlyingToken": { + "address": "0x16227D60f7a0e586C66B005219dfc887D13C9531", + "asset": "/src/libs/tokens/img/usdc.svg", + "decimals": 6, + "symbol": "USDC", + }, + }, + }, + ], + "comptrollerAddress": "0x94d1820b2D1c7c7452A163983Dc888CEC546b77D", + "isIsolated": false, + "name": "Core Pool", + "userBorrowBalanceCents": "19999377930013.362645", + "userBorrowLimitCents": "321989996798198.068756", + "userSupplyBalanceCents": "399987558598267.2529", + }, + { + "assets": [ + { + "borrowApyPercentage": "3.037255751760131518", + "borrowBalanceCents": "10266.891765447722", + "borrowBalanceTokens": "102.672734", + "borrowCapTokens": "14880000", + "borrowDistributions": [ + { + "apyPercentage": "0", + "dailyDistributedTokens": "0", + "token": { + "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", + "asset": "/src/libs/tokens/img/usdt.svg", + "decimals": 6, + "symbol": "USDT", + }, + "type": "rewardDistributor", + }, + ], + "borrowerCount": 20, + "cashTokens": "2649291.731707", + "collateralFactor": 0.8, + "disabledTokenActions": [], + "exchangeRateVTokens": "0.99999847176819609601", + "isCollateralOfUser": true, + "liquidityCents": "264919325.753333245081", + "reserveFactor": 0.1, + "reserveTokens": "0", + "supplierCount": 10, + "supplyApyPercentage": "0.000104360310305731", + "supplyBalanceCents": "264929592.64509868800383953542527752", + "supplyBalanceTokens": "2649394.40444099995200661144", + "supplyCapTokens": "18600000", + "supplyDistributions": [ + { + "apyPercentage": "0", + "dailyDistributedTokens": "0", + "token": { + "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", + "asset": "/src/libs/tokens/img/usdt.svg", + "decimals": 6, + "symbol": "USDT", + }, + "type": "rewardDistributor", + }, + ], + "tokenPriceCents": "99.996283", + "userBorrowBalanceCents": "9999628300000", + "userBorrowBalanceTokens": "100000000000", + "userPercentOfLimit": 6.25, + "userSupplyBalanceCents": "199992566000000", + "userSupplyBalanceTokens": "2000000000000", + "userWalletBalanceCents": "999962830000000", + "userWalletBalanceTokens": "10000000000000", + "vToken": { + "address": "0x80CC30811e362aC9aB857C3d7875CbcCc0b65750", + "decimals": 8, + "symbol": "vUSDT", + "underlyingToken": { + "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", + "asset": "/src/libs/tokens/img/usdt.svg", + "decimals": 6, + "symbol": "USDT", + }, + }, + }, + ], + "comptrollerAddress": "0x23a73971A6B9f6580c048B9CB188869B2A2aA2aD", + "isIsolated": true, + "name": "DeFi", + "userBorrowBalanceCents": "9999628300000", + "userBorrowLimitCents": "159994052800000", + "userSupplyBalanceCents": "199992566000000", + }, + { + "assets": [ + { + "borrowApyPercentage": "3.992487050504593481", + "borrowBalanceCents": "1032129.557718287222", + "borrowBalanceTokens": "10321.679234", + "borrowCapTokens": "14880000", + "borrowDistributions": [], + "borrowerCount": 20, + "cashTokens": "101166.023761", + "collateralFactor": 0.8, + "disabledTokenActions": [], + "exchangeRateVTokens": "0.997398625122774492", + "isCollateralOfUser": true, + "liquidityCents": "10116226.341989680363", + "reserveFactor": 0.1, + "reserveTokens": "0.000131", + "supplierCount": 10, + "supplyApyPercentage": "0.326746289860669541", + "supplyBalanceCents": "11148355.88660845370158439626770976", + "supplyBalanceTokens": "111487.70286399999189554272", + "supplyCapTokens": "18600000", + "supplyDistributions": [], + "tokenPriceCents": "99.996283", + "userBorrowBalanceCents": "9999628300000", + "userBorrowBalanceTokens": "100000000000", + "userPercentOfLimit": 6.25, + "userSupplyBalanceCents": "199992566000000", + "userSupplyBalanceTokens": "2000000000000", + "userWalletBalanceCents": "999962830000000", + "userWalletBalanceTokens": "10000000000000", + "vToken": { + "address": "0x0bFE4e0B8A2a096A27e5B18b078d25be57C08634", + "decimals": 8, + "symbol": "vUSDT", + "underlyingToken": { + "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", + "asset": "/src/libs/tokens/img/usdt.svg", + "decimals": 6, + "symbol": "USDT", + }, + }, + }, + ], + "comptrollerAddress": "0x1F4f0989C51f12DAcacD4025018176711f3Bf289", + "isIsolated": true, + "name": "GameFi", + "userBorrowBalanceCents": "9999628300000", + "userBorrowLimitCents": "159994052800000", + "userSupplyBalanceCents": "199992566000000", + }, + { + "assets": [ + { + "borrowApyPercentage": "3.03685757665446184", + "borrowBalanceCents": "0.000399985132", + "borrowBalanceTokens": "0.000004", + "borrowCapTokens": "14880000", + "borrowDistributions": [ + { + "apyPercentage": "0", + "dailyDistributedTokens": "0", + "token": { + "address": "0xe73774DfCD551BF75650772dC2cC56a2B6323453", + "asset": "/src/libs/tokens/img/lisUSD.png", + "decimals": 18, + "symbol": "lisUSD", + }, + "type": "rewardDistributor", + }, + { + "apyPercentage": "0", + "token": { + "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", + "asset": "/src/libs/tokens/img/usdt.svg", + "decimals": 6, + "symbol": "USDT", + }, + "type": "prime", + }, + ], + "borrowerCount": 20, + "cashTokens": "11031000", + "collateralFactor": 0.8, + "disabledTokenActions": [], + "exchangeRateVTokens": "0.999999999999545", + "isCollateralOfUser": false, + "liquidityCents": "1103058997.773", + "reserveFactor": 0.1, + "reserveTokens": "0", + "supplierCount": 10, + "supplyApyPercentage": "0", + "supplyBalanceCents": "1103058997.77339989563532689599327223", + "supplyBalanceTokens": "11031000.00000399910500000181", + "supplyCapTokens": "18600000", + "supplyDistributions": [ + { + "apyPercentage": "0", + "dailyDistributedTokens": "0", + "token": { + "address": "0xe73774DfCD551BF75650772dC2cC56a2B6323453", + "asset": "/src/libs/tokens/img/lisUSD.png", + "decimals": 18, + "symbol": "lisUSD", + }, + "type": "rewardDistributor", + }, + { + "apyPercentage": "0", + "token": { + "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", + "asset": "/src/libs/tokens/img/usdt.svg", + "decimals": 6, + "symbol": "USDT", + }, + "type": "prime", + }, + ], + "tokenPriceCents": "99.996283", + "userBorrowBalanceCents": "0", + "userBorrowBalanceTokens": "0", + "userPercentOfLimit": 0, + "userSupplyBalanceCents": "199992566000000", + "userSupplyBalanceTokens": "2000000000000", + "userWalletBalanceCents": "999962830000000", + "userWalletBalanceTokens": "10000000000000", + "vToken": { + "address": "0x2197d02cC9cd1ad51317A0a85A656a0c82383A7c", + "decimals": 8, + "symbol": "vUSDT", + "underlyingToken": { + "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", + "asset": "/src/libs/tokens/img/usdt.svg", + "decimals": 6, + "symbol": "USDT", + }, + }, + }, + { + "borrowApyPercentage": "397.358195317640926827", + "borrowBalanceCents": "14020.2378315565440147153504", + "borrowBalanceTokens": "0.267025220823379366", + "borrowCapTokens": "56000", + "borrowDistributions": [ + { + "apyPercentage": "0", + "dailyDistributedTokens": "0", + "token": { + "address": "0xe73774DfCD551BF75650772dC2cC56a2B6323453", + "asset": "/src/libs/tokens/img/lisUSD.png", + "decimals": 18, + "symbol": "lisUSD", + }, + "type": "rewardDistributor", + }, + ], + "borrowerCount": 20, + "cashTokens": "0.000705300034659891", + "collateralFactor": 0.45, + "disabledTokenActions": [], + "exchangeRateVTokens": "0.856077892298015039", + "isCollateralOfUser": true, + "liquidityCents": "37.0319859601477808269104", + "reserveFactor": 0.25, + "reserveTokens": "0", + "supplierCount": 10, + "supplyApyPercentage": "232.211474860496839891", + "supplyBalanceCents": "14057.269817516691795017207856", + "supplyBalanceTokens": "0.26773052085803925699", + "supplyCapTokens": "80000", + "supplyDistributions": [ + { + "apyPercentage": "0", + "dailyDistributedTokens": "0", + "token": { + "address": "0xe73774DfCD551BF75650772dC2cC56a2B6323453", + "asset": "/src/libs/tokens/img/lisUSD.png", + "decimals": 18, + "symbol": "lisUSD", + }, + "type": "rewardDistributor", + }, + ], + "tokenPriceCents": "52505.2944", + "userBorrowBalanceCents": "5250.52944", + "userBorrowBalanceTokens": "0.1", + "userPercentOfLimit": 11.11, + "userSupplyBalanceCents": "105010.5888", + "userSupplyBalanceTokens": "2", + "userWalletBalanceCents": "525052.944", + "userWalletBalanceTokens": "10", + "vToken": { + "address": "0x231dED0Dfc99634e52EE1a1329586bc970d773b3", + "decimals": 8, + "symbol": "vWBNB", + "underlyingToken": { + "address": "0xae13d989daC2f0dEbFf460aC112a837C89BAa7cd", + "asset": "/src/libs/tokens/img/wbnb.svg", + "decimals": 18, + "symbol": "WBNB", + }, + }, + }, + ], + "comptrollerAddress": "0x596B11acAACF03217287939f88d63b51d3771704", + "isIsolated": true, + "name": "Liquid Staked BNB", + "userBorrowBalanceCents": "5250.52944", + "userBorrowLimitCents": "47254.76496", + "userSupplyBalanceCents": "199992566105010.5888", + }, + { + "assets": [ + { + "borrowApyPercentage": "0.011616016420902095", + "borrowBalanceCents": "399.985132", + "borrowBalanceTokens": "4", + "borrowCapTokens": "900000", + "borrowDistributions": [], + "borrowerCount": 20, + "cashTokens": "6006", + "collateralFactor": 0.75, + "disabledTokenActions": [], + "exchangeRateVTokens": "1", + "isCollateralOfUser": true, + "liquidityCents": "600577.675698", + "reserveFactor": 0.1, + "reserveTokens": "0", + "supplierCount": 10, + "supplyApyPercentage": "0.00000695665176131", + "supplyBalanceCents": "600977.66083", + "supplyBalanceTokens": "6010", + "supplyCapTokens": "1000000", + "supplyDistributions": [], + "tokenPriceCents": "99.996283", + "userBorrowBalanceCents": "9999628300000", + "userBorrowBalanceTokens": "100000000000", + "userPercentOfLimit": 6.66, + "userSupplyBalanceCents": "199992566000000", + "userSupplyBalanceTokens": "2000000000000", + "userWalletBalanceCents": "999962830000000", + "userWalletBalanceTokens": "10000000000000", + "vToken": { + "address": "0x3AF2bE7AbEF0f840b196D99d79F4B803a5dB14a1", + "decimals": 8, + "symbol": "vUSDT", + "underlyingToken": { + "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", + "asset": "/src/libs/tokens/img/usdt.svg", + "decimals": 6, + "symbol": "USDT", + }, + }, + }, + ], + "comptrollerAddress": "0x92e8E3C202093A495e98C10f9fcaa5Abe288F74A", + "isIsolated": true, + "name": "Meme", + "userBorrowBalanceCents": "9999628300000", + "userBorrowLimitCents": "149994424500000", + "userSupplyBalanceCents": "199992566000000", + }, + { + "assets": [ + { + "borrowApyPercentage": "5.116012290184441153", + "borrowBalanceCents": "1030091.4588649133175062", + "borrowBalanceTokens": "10300.914588649133175062", + "borrowCapTokens": "200000", + "borrowDistributions": [], + "borrowerCount": 20, + "cashTokens": "32569.640339677929523638", + "collateralFactor": 0.65, + "disabledTokenActions": [], + "exchangeRateVTokens": "0.9930076443898276885", + "isCollateralOfUser": true, + "liquidityCents": "3256964.0339677929523638", + "reserveFactor": 0.2, + "reserveTokens": "0.000166728600388574", + "supplierCount": 10, + "supplyApyPercentage": "0.963756279976176856", + "supplyBalanceCents": "4287055.476159846231009819", + "supplyBalanceTokens": "42870.55476159846231009819", + "supplyCapTokens": "500000", + "supplyDistributions": [], + "tokenPriceCents": "100", + "userBorrowBalanceCents": "10", + "userBorrowBalanceTokens": "0.1", + "userPercentOfLimit": 0, + "userSupplyBalanceCents": "200", + "userSupplyBalanceTokens": "2", + "userWalletBalanceCents": "1000", + "userWalletBalanceTokens": "10", + "vToken": { + "address": "0x170d3b2da05cc2124334240fB34ad1359e34C562", + "decimals": 8, + "symbol": "vlisUSD", + "underlyingToken": { + "address": "0xe73774DfCD551BF75650772dC2cC56a2B6323453", + "asset": "/src/libs/tokens/img/lisUSD.png", + "decimals": 18, + "symbol": "lisUSD", + }, + }, + }, + { + "borrowApyPercentage": "2.023012476743554002", + "borrowBalanceCents": "100461.088822525373", + "borrowBalanceTokens": "1004.648231", + "borrowCapTokens": "400000", + "borrowDistributions": [ + { + "apyPercentage": "0", + "dailyDistributedTokens": "0", + "token": { + "address": "0xe73774DfCD551BF75650772dC2cC56a2B6323453", + "asset": "/src/libs/tokens/img/lisUSD.png", + "decimals": 18, + "symbol": "lisUSD", + }, + "type": "rewardDistributor", + }, + { + "apyPercentage": "0", + "token": { + "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", + "asset": "/src/libs/tokens/img/usdt.svg", + "decimals": 6, + "symbol": "USDT", + }, + "type": "prime", + }, + ], + "borrowerCount": 20, + "cashTokens": "998174.53518", + "collateralFactor": 0.8, + "disabledTokenActions": [], + "exchangeRateVTokens": "0.99998934225265418908", + "isCollateralOfUser": true, + "liquidityCents": "99813743.30325273594", + "reserveFactor": 0.1, + "reserveTokens": "0.000002", + "supplierCount": 10, + "supplyApyPercentage": "0.001812471504422768", + "supplyBalanceCents": "99914204.39187526542630629377313097", + "supplyBalanceTokens": "999179.18340899996679182859", + "supplyCapTokens": "1000000", + "supplyDistributions": [ + { + "apyPercentage": "0", + "dailyDistributedTokens": "0", + "token": { + "address": "0xe73774DfCD551BF75650772dC2cC56a2B6323453", + "asset": "/src/libs/tokens/img/lisUSD.png", + "decimals": 18, + "symbol": "lisUSD", + }, + "type": "rewardDistributor", + }, + { + "apyPercentage": "0", + "token": { + "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", + "asset": "/src/libs/tokens/img/usdt.svg", + "decimals": 6, + "symbol": "USDT", + }, + "type": "prime", + }, + ], + "tokenPriceCents": "99.996283", + "userBorrowBalanceCents": "9999628300000", + "userBorrowBalanceTokens": "100000000000", + "userPercentOfLimit": 6.24, + "userSupplyBalanceCents": "199992566000000", + "userSupplyBalanceTokens": "2000000000000", + "userWalletBalanceCents": "999962830000000", + "userWalletBalanceTokens": "10000000000000", + "vToken": { + "address": "0x3338988d0beb4419Acb8fE624218754053362D06", + "decimals": 8, + "symbol": "vUSDT", + "underlyingToken": { + "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", + "asset": "/src/libs/tokens/img/usdt.svg", + "decimals": 6, + "symbol": "USDT", + }, + }, + }, + ], + "comptrollerAddress": "0x10b57706AD2345e590c2eA4DC02faef0d9f5b08B", + "isIsolated": true, + "name": "Stablecoins", + "userBorrowBalanceCents": "9999628300010", + "userBorrowLimitCents": "159994052800130", + "userSupplyBalanceCents": "199992566000200", + }, + { + "assets": [ + { + "borrowApyPercentage": "3.03685757665446184", + "borrowBalanceCents": "0", + "borrowBalanceTokens": "0", + "borrowCapTokens": "14880000", + "borrowDistributions": [ + { + "apyPercentage": "0", + "token": { + "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", + "asset": "/src/libs/tokens/img/usdt.svg", + "decimals": 6, + "symbol": "USDT", + }, + "type": "prime", + }, + ], + "borrowerCount": 20, + "cashTokens": "10000", + "collateralFactor": 0.8, + "disabledTokenActions": [], + "exchangeRateVTokens": "1", + "isCollateralOfUser": false, + "liquidityCents": "999962.83", + "reserveFactor": 0.1, + "reserveTokens": "0", + "supplierCount": 10, + "supplyApyPercentage": "0", + "supplyBalanceCents": "999962.83", + "supplyBalanceTokens": "10000", + "supplyCapTokens": "18600000", + "supplyDistributions": [ + { + "apyPercentage": "0", + "token": { + "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", + "asset": "/src/libs/tokens/img/usdt.svg", + "decimals": 6, + "symbol": "USDT", + }, + "type": "prime", + }, + ], + "tokenPriceCents": "99.996283", + "userBorrowBalanceCents": "0", + "userBorrowBalanceTokens": "0", + "userPercentOfLimit": 0, + "userSupplyBalanceCents": "199992566000000", + "userSupplyBalanceTokens": "2000000000000", + "userWalletBalanceCents": "999962830000000", + "userWalletBalanceTokens": "10000000000000", + "vToken": { + "address": "0x712774CBFFCBD60e9825871CcEFF2F917442b2c3", + "decimals": 8, + "symbol": "vUSDT", + "underlyingToken": { + "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", + "asset": "/src/libs/tokens/img/usdt.svg", + "decimals": 6, + "symbol": "USDT", + }, + }, + }, + ], + "comptrollerAddress": "0x11537D023f489E4EF0C7157cc729C7B69CbE0c97", + "isIsolated": true, + "name": "Tron", + "userBorrowBalanceCents": "0", + "userBorrowLimitCents": "0", + "userSupplyBalanceCents": "199992566000000", + }, + ], +} +`; diff --git a/apps/evm/src/clients/api/queries/getIsolatedPools/__tests__/__snapshots__/indexPrime.spec.ts.snap b/apps/evm/src/clients/api/queries/useGetPools/__tests__/__snapshots__/index.spec.ts.snap similarity index 50% rename from apps/evm/src/clients/api/queries/getIsolatedPools/__tests__/__snapshots__/indexPrime.spec.ts.snap rename to apps/evm/src/clients/api/queries/useGetPools/__tests__/__snapshots__/index.spec.ts.snap index 386aadb8d1..e05a20c58d 100644 --- a/apps/evm/src/clients/api/queries/getIsolatedPools/__tests__/__snapshots__/indexPrime.spec.ts.snap +++ b/apps/evm/src/clients/api/queries/useGetPools/__tests__/__snapshots__/index.spec.ts.snap @@ -1,12 +1,417 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`getIsolatedPools - Feature enabled: Prime > does not fetch Prime distributions if user is not Prime 1`] = ` +exports[`useGetPools > returns pools in the correct format 1`] = ` { "pools": [ { "assets": [ { - "borrowApyPercentage": "3.0457256612776096", + "borrowApyPercentage": "2.014488270427066776", + "borrowBalanceCents": "24663011775918.58670630114424219627258", + "borrowBalanceTokens": "246628588661.936163058800477859", + "borrowCapTokens": "1e-18", + "borrowDistributions": [ + { + "apyPercentage": "0", + "dailyDistributedTokens": "0", + "token": { + "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", + "asset": "/src/libs/tokens/img/xvs.svg", + "decimals": 18, + "symbol": "XVS", + }, + "type": "rewardDistributor", + }, + ], + "borrowerCount": 438, + "cashTokens": "1.00000000080503544824460983238917793784e+21", + "collateralFactor": 0, + "disabledTokenActions": [ + "supply", + "borrow", + ], + "exchangeRateVTokens": "49.19405324154271215086", + "isCollateralOfUser": false, + "liquidityCents": "1.000006200805040439464388948970138750743214608e+23", + "reserveFactor": 1, + "reserveTokens": "0", + "supplierCount": 933, + "supplyApyPercentage": "0", + "supplyBalanceCents": "1.000006201051670556767362816225462034303610544746e+23", + "supplyBalanceTokens": "1.00000000105166403645033682413715238395883e+21", + "supplyCapTokens": "0", + "supplyDistributions": [ + { + "apyPercentage": "0", + "dailyDistributedTokens": "0", + "token": { + "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", + "asset": "/src/libs/tokens/img/xvs.svg", + "decimals": 18, + "symbol": "XVS", + }, + "type": "rewardDistributor", + }, + ], + "tokenPriceCents": "100.00062", + "userBorrowBalanceCents": "0", + "userBorrowBalanceTokens": "0", + "userPercentOfLimit": 0, + "userSupplyBalanceCents": "0", + "userSupplyBalanceTokens": "0", + "userWalletBalanceCents": "0", + "userWalletBalanceTokens": "0", + "vToken": { + "address": "0x08e0A5575De71037aE36AbfAfb516595fE68e5e4", + "decimals": 8, + "symbol": "vBUSD", + "underlyingToken": { + "address": "0x8301F2213c0eeD49a7E28Ae4c3e91722919B8B47", + "asset": "/src/libs/tokens/img/busd.svg", + "decimals": 18, + "symbol": "BUSD", + }, + }, + }, + { + "borrowApyPercentage": "12.72621843315593399", + "borrowBalanceCents": "3721959398.320962344455482972", + "borrowBalanceTokens": "15136.746248595758022748", + "borrowCapTokens": "0", + "borrowDistributions": [ + { + "apyPercentage": "1.5797413696681861", + "dailyDistributedTokens": "250.0000128", + "token": { + "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", + "asset": "/src/libs/tokens/img/xvs.svg", + "decimals": 18, + "symbol": "XVS", + }, + "type": "rewardDistributor", + }, + ], + "borrowerCount": 35, + "cashTokens": "0", + "collateralFactor": 0.8, + "disabledTokenActions": [], + "exchangeRateVTokens": "37.63966306652044917955", + "isCollateralOfUser": false, + "liquidityCents": "0", + "reserveFactor": 0.1, + "reserveTokens": "21.269535066688975633", + "supplierCount": 25, + "supplyApyPercentage": "11.401000590716290067", + "supplyBalanceCents": "3716729453.6129492577232450137", + "supplyBalanceTokens": "15115.4767135290690422233", + "supplyCapTokens": "1.15792089237316195423570985008687907853269984665640564039457584007913129639935e+59", + "supplyDistributions": [ + { + "apyPercentage": "1.5819817239252298", + "dailyDistributedTokens": "250.0000128", + "token": { + "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", + "asset": "/src/libs/tokens/img/xvs.svg", + "decimals": 18, + "symbol": "XVS", + }, + "type": "rewardDistributor", + }, + ], + "tokenPriceCents": "245889", + "userBorrowBalanceCents": "0", + "userBorrowBalanceTokens": "0", + "userPercentOfLimit": 0, + "userSupplyBalanceCents": "0", + "userSupplyBalanceTokens": "0", + "userWalletBalanceCents": "0", + "userWalletBalanceTokens": "0", + "vToken": { + "address": "0x162D005F0Fff510E54958Cfc5CF32A3180A84aab", + "decimals": 8, + "symbol": "vETH", + "underlyingToken": { + "address": "0x98f7A83361F7Ac8765CcEBAB1425da6b341958a7", + "asset": "/src/libs/tokens/img/eth.svg", + "decimals": 18, + "isNative": true, + "symbol": "ETH", + }, + }, + }, + { + "borrowApyPercentage": "179.96505731769223966", + "borrowBalanceCents": "54206766464.991794941213834066224", + "borrowBalanceTokens": "1032405.72373577234796371", + "borrowCapTokens": "0", + "borrowDistributions": [ + { + "apyPercentage": "0.6478221277312901", + "dailyDistributedTokens": "1499.9999904", + "token": { + "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", + "asset": "/src/libs/tokens/img/xvs.svg", + "decimals": 18, + "symbol": "XVS", + }, + "type": "rewardDistributor", + }, + ], + "borrowerCount": 263, + "cashTokens": "5.556233762724731858", + "collateralFactor": 0.8, + "disabledTokenActions": [], + "exchangeRateVTokens": "5.63429988023545433776", + "isCollateralOfUser": false, + "liquidityCents": "291731.6894670817923653489952", + "reserveFactor": 0.25, + "reserveTokens": "187487.447405339178551222", + "supplierCount": 923, + "supplyApyPercentage": "156.911092632839993416", + "supplyBalanceCents": "44362974574.359412320127072323564288", + "supplyBalanceTokens": "844923.83256419589412162352", + "supplyCapTokens": "1.15792089237316195423570985008687907853269984665640564039457584007913129639935e+59", + "supplyDistributions": [ + { + "apyPercentage": "0.7921351276470645", + "dailyDistributedTokens": "1499.9999904", + "token": { + "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", + "asset": "/src/libs/tokens/img/xvs.svg", + "decimals": 18, + "symbol": "XVS", + }, + "type": "rewardDistributor", + }, + ], + "tokenPriceCents": "52505.2944", + "userBorrowBalanceCents": "0", + "userBorrowBalanceTokens": "0", + "userPercentOfLimit": 0, + "userSupplyBalanceCents": "0", + "userSupplyBalanceTokens": "0", + "userWalletBalanceCents": "0", + "userWalletBalanceTokens": "0", + "vToken": { + "address": "0x2E7222e51c0f6e98610A1543Aa3836E092CDe62c", + "decimals": 8, + "symbol": "vBNB", + "underlyingToken": { + "address": "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE", + "asset": "/src/libs/tokens/img/bnb.svg", + "decimals": 18, + "isNative": true, + "symbol": "BNB", + }, + }, + }, + { + "borrowApyPercentage": "16.800248594171254373", + "borrowBalanceCents": "266527277.02974427316207663041589", + "borrowBalanceTokens": "416884.364702270734855123", + "borrowCapTokens": "270000", + "borrowDistributions": [ + { + "apyPercentage": "0", + "dailyDistributedTokens": "0", + "token": { + "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", + "asset": "/src/libs/tokens/img/xvs.svg", + "decimals": 18, + "symbol": "XVS", + }, + "type": "rewardDistributor", + }, + ], + "borrowerCount": 68, + "cashTokens": "2259657.074761148481496107", + "collateralFactor": 0.6, + "disabledTokenActions": [], + "exchangeRateVTokens": "47.36910235297224095005", + "isCollateralOfUser": false, + "liquidityCents": "1444669788.91666196711723462774301", + "reserveFactor": 0.25, + "reserveTokens": "0", + "supplierCount": 274, + "supplyApyPercentage": "1.830999347346963073", + "supplyBalanceCents": "1711197065.9464062401284554003137589", + "supplyBalanceTokens": "2676541.43946341921611527123", + "supplyCapTokens": "3750000", + "supplyDistributions": [ + { + "apyPercentage": "0", + "dailyDistributedTokens": "0", + "token": { + "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", + "asset": "/src/libs/tokens/img/xvs.svg", + "decimals": 18, + "symbol": "XVS", + }, + "type": "rewardDistributor", + }, + ], + "tokenPriceCents": "639.33143", + "userBorrowBalanceCents": "0", + "userBorrowBalanceTokens": "0", + "userPercentOfLimit": 0, + "userSupplyBalanceCents": "0", + "userSupplyBalanceTokens": "0", + "userWalletBalanceCents": "0", + "userWalletBalanceTokens": "0", + "vToken": { + "address": "0x6d6F697e34145Bb95c54E77482d97cc261Dc237E", + "decimals": 8, + "symbol": "vXVS", + "underlyingToken": { + "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", + "asset": "/src/libs/tokens/img/xvs.svg", + "decimals": 18, + "symbol": "XVS", + }, + }, + }, + { + "borrowApyPercentage": "2.014488268288307401", + "borrowBalanceCents": "743724749.881571973423", + "borrowBalanceTokens": "7437523.951581", + "borrowCapTokens": "0", + "borrowDistributions": [ + { + "apyPercentage": "16.981964056809385", + "dailyDistributedTokens": "499.9999968", + "token": { + "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", + "asset": "/src/libs/tokens/img/xvs.svg", + "decimals": 18, + "symbol": "XVS", + }, + "type": "rewardDistributor", + }, + ], + "borrowerCount": 249, + "cashTokens": "1.0000736633870942814396398228131475074669e+34", + "collateralFactor": 0.8, + "disabledTokenActions": [], + "exchangeRateVTokens": "49.8066352191466231613", + "isCollateralOfUser": false, + "liquidityCents": "1.000036490649026183145198711400933542774047455327e+36", + "reserveFactor": 0.1, + "reserveTokens": "0", + "supplierCount": 670, + "supplyApyPercentage": "0", + "supplyBalanceCents": "1.00003649064902618314530970887489046343322854178897705712904885e+36", + "supplyBalanceTokens": "1.000073663387094281439750824413033895903139261475326095e+34", + "supplyCapTokens": "1.15792089237316195423570985008687907853269984665640564039457584007913129639935e+71", + "supplyDistributions": [ + { + "apyPercentage": "0", + "dailyDistributedTokens": "499.9999968", + "token": { + "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", + "asset": "/src/libs/tokens/img/xvs.svg", + "decimals": 18, + "symbol": "XVS", + }, + "type": "rewardDistributor", + }, + ], + "tokenPriceCents": "99.996283", + "userBorrowBalanceCents": "0", + "userBorrowBalanceTokens": "0", + "userPercentOfLimit": 0, + "userSupplyBalanceCents": "0", + "userSupplyBalanceTokens": "0", + "userWalletBalanceCents": "0", + "userWalletBalanceTokens": "0", + "vToken": { + "address": "0xb7526572FFE56AB9D7489838Bf2E18e3323b441A", + "decimals": 8, + "symbol": "vUSDT", + "underlyingToken": { + "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", + "asset": "/src/libs/tokens/img/usdt.svg", + "decimals": 6, + "symbol": "USDT", + }, + }, + }, + { + "borrowApyPercentage": "2.01448842548712155", + "borrowBalanceCents": "1562397934365776.075433634816", + "borrowBalanceTokens": "15624370577897.031296", + "borrowCapTokens": "0", + "borrowDistributions": [ + { + "apyPercentage": "0.000007467880158706", + "dailyDistributedTokens": "499.9999968", + "token": { + "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", + "asset": "/src/libs/tokens/img/xvs.svg", + "decimals": 18, + "symbol": "XVS", + }, + "type": "rewardDistributor", + }, + ], + "borrowerCount": 229, + "cashTokens": "1.010176805025969148511141552e+21", + "collateralFactor": 0.81, + "disabledTokenActions": [], + "exchangeRateVTokens": "47.12928141003911013496", + "isCollateralOfUser": false, + "liquidityCents": "1.01015151019877129824366283301553792e+23", + "reserveFactor": 0.1, + "reserveTokens": "0", + "supplierCount": 534, + "supplyApyPercentage": "2.7256320003e-8", + "supplyBalanceCents": "1.0101515258227468345608256850251328456045167117888e+23", + "supplyBalanceTokens": "1.01017682065033591897223674983334867265528e+21", + "supplyCapTokens": "1.15792089237316195423570985008687907853269984665640564039457584007913129639935e+71", + "supplyDistributions": [ + { + "apyPercentage": "0", + "dailyDistributedTokens": "499.9999968", + "token": { + "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", + "asset": "/src/libs/tokens/img/xvs.svg", + "decimals": 18, + "symbol": "XVS", + }, + "type": "rewardDistributor", + }, + ], + "tokenPriceCents": "99.997496", + "userBorrowBalanceCents": "0", + "userBorrowBalanceTokens": "0", + "userPercentOfLimit": 0, + "userSupplyBalanceCents": "0", + "userSupplyBalanceTokens": "0", + "userWalletBalanceCents": "0", + "userWalletBalanceTokens": "0", + "vToken": { + "address": "0xD5C4C2e2facBEB59D0216D0595d63FcDc6F9A1a7", + "decimals": 8, + "symbol": "vUSDC", + "underlyingToken": { + "address": "0x16227D60f7a0e586C66B005219dfc887D13C9531", + "asset": "/src/libs/tokens/img/usdc.svg", + "decimals": 6, + "symbol": "USDC", + }, + }, + }, + ], + "comptrollerAddress": "0x94d1820b2D1c7c7452A163983Dc888CEC546b77D", + "isIsolated": false, + "name": "Core Pool", + "userBorrowBalanceCents": "0", + "userBorrowLimitCents": "0", + "userSupplyBalanceCents": "0", + }, + { + "assets": [ + { + "borrowApyPercentage": "3.037255751760131518", "borrowBalanceCents": "10266.891765447722", "borrowBalanceTokens": "102.672734", "borrowCapTokens": "14880000", @@ -33,7 +438,7 @@ exports[`getIsolatedPools - Feature enabled: Prime > does not fetch Prime distri "reserveFactor": 0.1, "reserveTokens": "0", "supplierCount": 10, - "supplyApyPercentage": "0.000104647012366676", + "supplyApyPercentage": "0.000104360310305731", "supplyBalanceCents": "264929592.64509868800383953542527752", "supplyBalanceTokens": "2649394.40444099995200661144", "supplyCapTokens": "18600000", @@ -56,8 +461,8 @@ exports[`getIsolatedPools - Feature enabled: Prime > does not fetch Prime distri "userPercentOfLimit": 0, "userSupplyBalanceCents": "0", "userSupplyBalanceTokens": "0", - "userWalletBalanceCents": "999962830000000", - "userWalletBalanceTokens": "10000000000000", + "userWalletBalanceCents": "0", + "userWalletBalanceTokens": "0", "vToken": { "address": "0x80CC30811e362aC9aB857C3d7875CbcCc0b65750", "decimals": 8, @@ -72,7 +477,6 @@ exports[`getIsolatedPools - Feature enabled: Prime > does not fetch Prime distri }, ], "comptrollerAddress": "0x23a73971A6B9f6580c048B9CB188869B2A2aA2aD", - "description": "", "isIsolated": true, "name": "DeFi", "userBorrowBalanceCents": "0", @@ -82,7 +486,7 @@ exports[`getIsolatedPools - Feature enabled: Prime > does not fetch Prime distri { "assets": [ { - "borrowApyPercentage": "4.003672121275481", + "borrowApyPercentage": "3.992487050504593481", "borrowBalanceCents": "1032129.557718287222", "borrowBalanceTokens": "10321.679234", "borrowCapTokens": "14880000", @@ -97,7 +501,7 @@ exports[`getIsolatedPools - Feature enabled: Prime > does not fetch Prime distri "reserveFactor": 0.1, "reserveTokens": "0.000131", "supplierCount": 10, - "supplyApyPercentage": "0.32764541346423925", + "supplyApyPercentage": "0.326746289860669541", "supplyBalanceCents": "11148355.88660845370158439626770976", "supplyBalanceTokens": "111487.70286399999189554272", "supplyCapTokens": "18600000", @@ -108,8 +512,8 @@ exports[`getIsolatedPools - Feature enabled: Prime > does not fetch Prime distri "userPercentOfLimit": 0, "userSupplyBalanceCents": "0", "userSupplyBalanceTokens": "0", - "userWalletBalanceCents": "999962830000000", - "userWalletBalanceTokens": "10000000000000", + "userWalletBalanceCents": "0", + "userWalletBalanceTokens": "0", "vToken": { "address": "0x0bFE4e0B8A2a096A27e5B18b078d25be57C08634", "decimals": 8, @@ -124,7 +528,6 @@ exports[`getIsolatedPools - Feature enabled: Prime > does not fetch Prime distri }, ], "comptrollerAddress": "0x1F4f0989C51f12DAcacD4025018176711f3Bf289", - "description": "", "isIsolated": true, "name": "GameFi", "userBorrowBalanceCents": "0", @@ -134,7 +537,7 @@ exports[`getIsolatedPools - Feature enabled: Prime > does not fetch Prime distri { "assets": [ { - "borrowApyPercentage": "3.045326359470546", + "borrowApyPercentage": "3.03685757665446184", "borrowBalanceCents": "0.000399985132", "borrowBalanceTokens": "0.000004", "borrowCapTokens": "14880000", @@ -150,21 +553,6 @@ exports[`getIsolatedPools - Feature enabled: Prime > does not fetch Prime distri }, "type": "rewardDistributor", }, - { - "apyPercentage": "0.20019958435848473", - "referenceValues": { - "userBorrowBalanceTokens": "2e-7", - "userSupplyBalanceTokens": "1103100.00000039991050000018", - "userXvsStakedTokens": "1000", - }, - "token": { - "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", - "asset": "/src/libs/tokens/img/usdt.svg", - "decimals": 6, - "symbol": "USDT", - }, - "type": "primeSimulation", - }, ], "borrowerCount": 20, "cashTokens": "11031000", @@ -192,21 +580,6 @@ exports[`getIsolatedPools - Feature enabled: Prime > does not fetch Prime distri }, "type": "rewardDistributor", }, - { - "apyPercentage": "0.23026397657694986", - "referenceValues": { - "userBorrowBalanceTokens": "2e-7", - "userSupplyBalanceTokens": "1103100.00000039991050000018", - "userXvsStakedTokens": "1000", - }, - "token": { - "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", - "asset": "/src/libs/tokens/img/usdt.svg", - "decimals": 6, - "symbol": "USDT", - }, - "type": "primeSimulation", - }, ], "tokenPriceCents": "99.996283", "userBorrowBalanceCents": "0", @@ -214,8 +587,8 @@ exports[`getIsolatedPools - Feature enabled: Prime > does not fetch Prime distri "userPercentOfLimit": 0, "userSupplyBalanceCents": "0", "userSupplyBalanceTokens": "0", - "userWalletBalanceCents": "999962830000000", - "userWalletBalanceTokens": "10000000000000", + "userWalletBalanceCents": "0", + "userWalletBalanceTokens": "0", "vToken": { "address": "0x2197d02cC9cd1ad51317A0a85A656a0c82383A7c", "decimals": 8, @@ -229,7 +602,7 @@ exports[`getIsolatedPools - Feature enabled: Prime > does not fetch Prime distri }, }, { - "borrowApyPercentage": "399.5548791715505", + "borrowApyPercentage": "397.358195317640926827", "borrowBalanceCents": "14020.2378315565440147153504", "borrowBalanceTokens": "0.267025220823379366", "borrowCapTokens": "56000", @@ -256,7 +629,7 @@ exports[`getIsolatedPools - Feature enabled: Prime > does not fetch Prime distri "reserveFactor": 0.25, "reserveTokens": "0", "supplierCount": 10, - "supplyApyPercentage": "233.30903562118922", + "supplyApyPercentage": "232.211474860496839891", "supplyBalanceCents": "14057.269817516691795017207856", "supplyBalanceTokens": "0.26773052085803925699", "supplyCapTokens": "80000", @@ -279,8 +652,8 @@ exports[`getIsolatedPools - Feature enabled: Prime > does not fetch Prime distri "userPercentOfLimit": 0, "userSupplyBalanceCents": "0", "userSupplyBalanceTokens": "0", - "userWalletBalanceCents": "525052.944", - "userWalletBalanceTokens": "10", + "userWalletBalanceCents": "0", + "userWalletBalanceTokens": "0", "vToken": { "address": "0x231dED0Dfc99634e52EE1a1329586bc970d773b3", "decimals": 8, @@ -295,7 +668,6 @@ exports[`getIsolatedPools - Feature enabled: Prime > does not fetch Prime distri }, ], "comptrollerAddress": "0x596B11acAACF03217287939f88d63b51d3771704", - "description": "", "isIsolated": true, "name": "Liquid Staked BNB", "userBorrowBalanceCents": "0", @@ -305,12 +677,12 @@ exports[`getIsolatedPools - Feature enabled: Prime > does not fetch Prime distri { "assets": [ { - "borrowApyPercentage": "0.011647930409597329", + "borrowApyPercentage": "0.011616016420902095", "borrowBalanceCents": "399.985132", "borrowBalanceTokens": "4", "borrowCapTokens": "900000", "borrowDistributions": [], - "borrowerCount": 0, + "borrowerCount": 20, "cashTokens": "6006", "collateralFactor": 0.75, "disabledTokenActions": [], @@ -319,8 +691,8 @@ exports[`getIsolatedPools - Feature enabled: Prime > does not fetch Prime distri "liquidityCents": "600577.675698", "reserveFactor": 0.1, "reserveTokens": "0", - "supplierCount": 0, - "supplyApyPercentage": "0.000006975767097294", + "supplierCount": 10, + "supplyApyPercentage": "0.00000695665176131", "supplyBalanceCents": "600977.66083", "supplyBalanceTokens": "6010", "supplyCapTokens": "1000000", @@ -331,8 +703,8 @@ exports[`getIsolatedPools - Feature enabled: Prime > does not fetch Prime distri "userPercentOfLimit": 0, "userSupplyBalanceCents": "0", "userSupplyBalanceTokens": "0", - "userWalletBalanceCents": "999962830000000", - "userWalletBalanceTokens": "10000000000000", + "userWalletBalanceCents": "0", + "userWalletBalanceTokens": "0", "vToken": { "address": "0x3AF2bE7AbEF0f840b196D99d79F4B803a5dB14a1", "decimals": 8, @@ -347,7 +719,6 @@ exports[`getIsolatedPools - Feature enabled: Prime > does not fetch Prime distri }, ], "comptrollerAddress": "0x92e8E3C202093A495e98C10f9fcaa5Abe288F74A", - "description": "", "isIsolated": true, "name": "Meme", "userBorrowBalanceCents": "0", @@ -357,7 +728,7 @@ exports[`getIsolatedPools - Feature enabled: Prime > does not fetch Prime distri { "assets": [ { - "borrowApyPercentage": "5.130421804803698", + "borrowApyPercentage": "5.116012290184441153", "borrowBalanceCents": "1030091.4588649133175062", "borrowBalanceTokens": "10300.914588649133175062", "borrowCapTokens": "200000", @@ -372,7 +743,7 @@ exports[`getIsolatedPools - Feature enabled: Prime > does not fetch Prime distri "reserveFactor": 0.2, "reserveTokens": "0.000166728600388574", "supplierCount": 10, - "supplyApyPercentage": "0.966416714921392", + "supplyApyPercentage": "0.963756279976176856", "supplyBalanceCents": "4287055.476159846231009819", "supplyBalanceTokens": "42870.55476159846231009819", "supplyCapTokens": "500000", @@ -383,8 +754,8 @@ exports[`getIsolatedPools - Feature enabled: Prime > does not fetch Prime distri "userPercentOfLimit": 0, "userSupplyBalanceCents": "0", "userSupplyBalanceTokens": "0", - "userWalletBalanceCents": "1000", - "userWalletBalanceTokens": "10", + "userWalletBalanceCents": "0", + "userWalletBalanceTokens": "0", "vToken": { "address": "0x170d3b2da05cc2124334240fB34ad1359e34C562", "decimals": 8, @@ -398,7 +769,7 @@ exports[`getIsolatedPools - Feature enabled: Prime > does not fetch Prime distri }, }, { - "borrowApyPercentage": "2.028626199218375", + "borrowApyPercentage": "2.023012476743554002", "borrowBalanceCents": "100461.088822525373", "borrowBalanceTokens": "1004.648231", "borrowCapTokens": "400000", @@ -414,21 +785,6 @@ exports[`getIsolatedPools - Feature enabled: Prime > does not fetch Prime distri }, "type": "rewardDistributor", }, - { - "apyPercentage": "0.20019958435848473", - "referenceValues": { - "userBorrowBalanceTokens": "50.23241155", - "userSupplyBalanceTokens": "99917.91834089999667918285", - "userXvsStakedTokens": "1000", - }, - "token": { - "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", - "asset": "/src/libs/tokens/img/usdt.svg", - "decimals": 6, - "symbol": "USDT", - }, - "type": "primeSimulation", - }, ], "borrowerCount": 20, "cashTokens": "998174.53518", @@ -440,7 +796,7 @@ exports[`getIsolatedPools - Feature enabled: Prime > does not fetch Prime distri "reserveFactor": 0.1, "reserveTokens": "0.000002", "supplierCount": 10, - "supplyApyPercentage": "0.001817450869823211", + "supplyApyPercentage": "0.001812471504422768", "supplyBalanceCents": "99914204.39187526542630629377313097", "supplyBalanceTokens": "999179.18340899996679182859", "supplyCapTokens": "1000000", @@ -456,21 +812,6 @@ exports[`getIsolatedPools - Feature enabled: Prime > does not fetch Prime distri }, "type": "rewardDistributor", }, - { - "apyPercentage": "0.23026397657694986", - "referenceValues": { - "userBorrowBalanceTokens": "50.23241155", - "userSupplyBalanceTokens": "99917.91834089999667918285", - "userXvsStakedTokens": "1000", - }, - "token": { - "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", - "asset": "/src/libs/tokens/img/usdt.svg", - "decimals": 6, - "symbol": "USDT", - }, - "type": "primeSimulation", - }, ], "tokenPriceCents": "99.996283", "userBorrowBalanceCents": "0", @@ -478,8 +819,8 @@ exports[`getIsolatedPools - Feature enabled: Prime > does not fetch Prime distri "userPercentOfLimit": 0, "userSupplyBalanceCents": "0", "userSupplyBalanceTokens": "0", - "userWalletBalanceCents": "999962830000000", - "userWalletBalanceTokens": "10000000000000", + "userWalletBalanceCents": "0", + "userWalletBalanceTokens": "0", "vToken": { "address": "0x3338988d0beb4419Acb8fE624218754053362D06", "decimals": 8, @@ -494,7 +835,6 @@ exports[`getIsolatedPools - Feature enabled: Prime > does not fetch Prime distri }, ], "comptrollerAddress": "0x10b57706AD2345e590c2eA4DC02faef0d9f5b08B", - "description": "", "isIsolated": true, "name": "Stablecoins", "userBorrowBalanceCents": "0", @@ -504,27 +844,11 @@ exports[`getIsolatedPools - Feature enabled: Prime > does not fetch Prime distri { "assets": [ { - "borrowApyPercentage": "3.045326359470546", + "borrowApyPercentage": "3.03685757665446184", "borrowBalanceCents": "0", "borrowBalanceTokens": "0", "borrowCapTokens": "14880000", - "borrowDistributions": [ - { - "apyPercentage": "0.20019958435848473", - "referenceValues": { - "userBorrowBalanceTokens": "0", - "userSupplyBalanceTokens": "1000", - "userXvsStakedTokens": "1000", - }, - "token": { - "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", - "asset": "/src/libs/tokens/img/usdt.svg", - "decimals": 6, - "symbol": "USDT", - }, - "type": "primeSimulation", - }, - ], + "borrowDistributions": [], "borrowerCount": 20, "cashTokens": "10000", "collateralFactor": 0.8, @@ -539,31 +863,15 @@ exports[`getIsolatedPools - Feature enabled: Prime > does not fetch Prime distri "supplyBalanceCents": "999962.83", "supplyBalanceTokens": "10000", "supplyCapTokens": "18600000", - "supplyDistributions": [ - { - "apyPercentage": "0.23026397657694986", - "referenceValues": { - "userBorrowBalanceTokens": "0", - "userSupplyBalanceTokens": "1000", - "userXvsStakedTokens": "1000", - }, - "token": { - "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", - "asset": "/src/libs/tokens/img/usdt.svg", - "decimals": 6, - "symbol": "USDT", - }, - "type": "primeSimulation", - }, - ], + "supplyDistributions": [], "tokenPriceCents": "99.996283", "userBorrowBalanceCents": "0", "userBorrowBalanceTokens": "0", "userPercentOfLimit": 0, "userSupplyBalanceCents": "0", "userSupplyBalanceTokens": "0", - "userWalletBalanceCents": "999962830000000", - "userWalletBalanceTokens": "10000000000000", + "userWalletBalanceCents": "0", + "userWalletBalanceTokens": "0", "vToken": { "address": "0x712774CBFFCBD60e9825871CcEFF2F917442b2c3", "decimals": 8, @@ -578,7 +886,6 @@ exports[`getIsolatedPools - Feature enabled: Prime > does not fetch Prime distri }, ], "comptrollerAddress": "0x11537D023f489E4EF0C7157cc729C7B69CbE0c97", - "description": "", "isIsolated": true, "name": "Tron", "userBorrowBalanceCents": "0", @@ -589,13 +896,418 @@ exports[`getIsolatedPools - Feature enabled: Prime > does not fetch Prime distri } `; -exports[`getIsolatedPools - Feature enabled: Prime > fetches and formats Prime distributions and Prime distribution simulations if user is Prime 1`] = ` +exports[`useGetPools > returns pools with time based reward rates in the correct format 1`] = ` { "pools": [ { "assets": [ { - "borrowApyPercentage": "3.0457256612776096", + "borrowApyPercentage": "2.014488270427066776", + "borrowBalanceCents": "24663011775918.58670630114424219627258", + "borrowBalanceTokens": "246628588661.936163058800477859", + "borrowCapTokens": "1e-18", + "borrowDistributions": [ + { + "apyPercentage": "0", + "dailyDistributedTokens": "0", + "token": { + "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", + "asset": "/src/libs/tokens/img/xvs.svg", + "decimals": 18, + "symbol": "XVS", + }, + "type": "rewardDistributor", + }, + ], + "borrowerCount": 20, + "cashTokens": "1.00000000080503544824460983238917793784e+21", + "collateralFactor": 0, + "disabledTokenActions": [ + "supply", + "borrow", + ], + "exchangeRateVTokens": "49.19405324154271215086", + "isCollateralOfUser": false, + "liquidityCents": "1.000006200805040439464388948970138750743214608e+23", + "reserveFactor": 1, + "reserveTokens": "0", + "supplierCount": 10, + "supplyApyPercentage": "0", + "supplyBalanceCents": "1.000006201051670556767362816225462034303610544746e+23", + "supplyBalanceTokens": "1.00000000105166403645033682413715238395883e+21", + "supplyCapTokens": "0", + "supplyDistributions": [ + { + "apyPercentage": "0", + "dailyDistributedTokens": "0", + "token": { + "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", + "asset": "/src/libs/tokens/img/xvs.svg", + "decimals": 18, + "symbol": "XVS", + }, + "type": "rewardDistributor", + }, + ], + "tokenPriceCents": "100.00062", + "userBorrowBalanceCents": "0", + "userBorrowBalanceTokens": "0", + "userPercentOfLimit": 0, + "userSupplyBalanceCents": "0", + "userSupplyBalanceTokens": "0", + "userWalletBalanceCents": "0", + "userWalletBalanceTokens": "0", + "vToken": { + "address": "0x08e0A5575De71037aE36AbfAfb516595fE68e5e4", + "decimals": 8, + "symbol": "vBUSD", + "underlyingToken": { + "address": "0x8301F2213c0eeD49a7E28Ae4c3e91722919B8B47", + "asset": "/src/libs/tokens/img/busd.svg", + "decimals": 18, + "symbol": "BUSD", + }, + }, + }, + { + "borrowApyPercentage": "12.72621843315593399", + "borrowBalanceCents": "3721959398.320962344455482972", + "borrowBalanceTokens": "15136.746248595758022748", + "borrowCapTokens": "0", + "borrowDistributions": [ + { + "apyPercentage": "4.814274201887225", + "dailyDistributedTokens": "750.0000384", + "token": { + "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", + "asset": "/src/libs/tokens/img/xvs.svg", + "decimals": 18, + "symbol": "XVS", + }, + "type": "rewardDistributor", + }, + ], + "borrowerCount": 20, + "cashTokens": "0", + "collateralFactor": 0.8, + "disabledTokenActions": [], + "exchangeRateVTokens": "37.63966306652044917955", + "isCollateralOfUser": false, + "liquidityCents": "0", + "reserveFactor": 0.1, + "reserveTokens": "21.269535066688975633", + "supplierCount": 10, + "supplyApyPercentage": "11.401000590716290067", + "supplyBalanceCents": "3716729453.6129492577232450137", + "supplyBalanceTokens": "15115.4767135290690422233", + "supplyCapTokens": "1.15792089237316195423570985008687907853269984665640564039457584007913129639935e+59", + "supplyDistributions": [ + { + "apyPercentage": "4.8212088357220795", + "dailyDistributedTokens": "750.0000384", + "token": { + "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", + "asset": "/src/libs/tokens/img/xvs.svg", + "decimals": 18, + "symbol": "XVS", + }, + "type": "rewardDistributor", + }, + ], + "tokenPriceCents": "245889", + "userBorrowBalanceCents": "0", + "userBorrowBalanceTokens": "0", + "userPercentOfLimit": 0, + "userSupplyBalanceCents": "0", + "userSupplyBalanceTokens": "0", + "userWalletBalanceCents": "0", + "userWalletBalanceTokens": "0", + "vToken": { + "address": "0x162D005F0Fff510E54958Cfc5CF32A3180A84aab", + "decimals": 8, + "symbol": "vETH", + "underlyingToken": { + "address": "0x98f7A83361F7Ac8765CcEBAB1425da6b341958a7", + "asset": "/src/libs/tokens/img/eth.svg", + "decimals": 18, + "isNative": true, + "symbol": "ETH", + }, + }, + }, + { + "borrowApyPercentage": "179.96505731769223966", + "borrowBalanceCents": "54206766464.991794941213834066224", + "borrowBalanceTokens": "1032405.72373577234796371", + "borrowCapTokens": "0", + "borrowDistributions": [ + { + "apyPercentage": "1.9560488349289473", + "dailyDistributedTokens": "4499.9999712", + "token": { + "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", + "asset": "/src/libs/tokens/img/xvs.svg", + "decimals": 18, + "symbol": "XVS", + }, + "type": "rewardDistributor", + }, + ], + "borrowerCount": 20, + "cashTokens": "5.556233762724731858", + "collateralFactor": 0.8, + "disabledTokenActions": [], + "exchangeRateVTokens": "5.63429988023545433776", + "isCollateralOfUser": false, + "liquidityCents": "291731.6894670817923653489952", + "reserveFactor": 0.25, + "reserveTokens": "187487.447405339178551222", + "supplierCount": 10, + "supplyApyPercentage": "156.911092632839993416", + "supplyBalanceCents": "44362974574.359412320127072323564288", + "supplyBalanceTokens": "844923.83256419589412162352", + "supplyCapTokens": "1.15792089237316195423570985008687907853269984665640564039457584007913129639935e+59", + "supplyDistributions": [ + { + "apyPercentage": "2.3952270378375884", + "dailyDistributedTokens": "4499.9999712", + "token": { + "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", + "asset": "/src/libs/tokens/img/xvs.svg", + "decimals": 18, + "symbol": "XVS", + }, + "type": "rewardDistributor", + }, + ], + "tokenPriceCents": "52505.2944", + "userBorrowBalanceCents": "0", + "userBorrowBalanceTokens": "0", + "userPercentOfLimit": 0, + "userSupplyBalanceCents": "0", + "userSupplyBalanceTokens": "0", + "userWalletBalanceCents": "0", + "userWalletBalanceTokens": "0", + "vToken": { + "address": "0x2E7222e51c0f6e98610A1543Aa3836E092CDe62c", + "decimals": 8, + "symbol": "vBNB", + "underlyingToken": { + "address": "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE", + "asset": "/src/libs/tokens/img/bnb.svg", + "decimals": 18, + "isNative": true, + "symbol": "BNB", + }, + }, + }, + { + "borrowApyPercentage": "16.800248594171254373", + "borrowBalanceCents": "266527277.02974427316207663041589", + "borrowBalanceTokens": "416884.364702270734855123", + "borrowCapTokens": "270000", + "borrowDistributions": [ + { + "apyPercentage": "0", + "dailyDistributedTokens": "0", + "token": { + "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", + "asset": "/src/libs/tokens/img/xvs.svg", + "decimals": 18, + "symbol": "XVS", + }, + "type": "rewardDistributor", + }, + ], + "borrowerCount": 20, + "cashTokens": "2259657.074761148481496107", + "collateralFactor": 0.6, + "disabledTokenActions": [], + "exchangeRateVTokens": "47.36910235297224095005", + "isCollateralOfUser": false, + "liquidityCents": "1444669788.91666196711723462774301", + "reserveFactor": 0.25, + "reserveTokens": "0", + "supplierCount": 10, + "supplyApyPercentage": "1.830999347346963073", + "supplyBalanceCents": "1711197065.9464062401284554003137589", + "supplyBalanceTokens": "2676541.43946341921611527123", + "supplyCapTokens": "3750000", + "supplyDistributions": [ + { + "apyPercentage": "0", + "dailyDistributedTokens": "0", + "token": { + "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", + "asset": "/src/libs/tokens/img/xvs.svg", + "decimals": 18, + "symbol": "XVS", + }, + "type": "rewardDistributor", + }, + ], + "tokenPriceCents": "639.33143", + "userBorrowBalanceCents": "0", + "userBorrowBalanceTokens": "0", + "userPercentOfLimit": 0, + "userSupplyBalanceCents": "0", + "userSupplyBalanceTokens": "0", + "userWalletBalanceCents": "0", + "userWalletBalanceTokens": "0", + "vToken": { + "address": "0x6d6F697e34145Bb95c54E77482d97cc261Dc237E", + "decimals": 8, + "symbol": "vXVS", + "underlyingToken": { + "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", + "asset": "/src/libs/tokens/img/xvs.svg", + "decimals": 18, + "symbol": "XVS", + }, + }, + }, + { + "borrowApyPercentage": "2.014488268288307401", + "borrowBalanceCents": "743724749.881571973423", + "borrowBalanceTokens": "7437523.951581", + "borrowCapTokens": "0", + "borrowDistributions": [ + { + "apyPercentage": "60.0548989604708", + "dailyDistributedTokens": "1499.9999904", + "token": { + "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", + "asset": "/src/libs/tokens/img/xvs.svg", + "decimals": 18, + "symbol": "XVS", + }, + "type": "rewardDistributor", + }, + ], + "borrowerCount": 20, + "cashTokens": "1.0000736633870942814396398228131475074669e+34", + "collateralFactor": 0.8, + "disabledTokenActions": [], + "exchangeRateVTokens": "49.8066352191466231613", + "isCollateralOfUser": false, + "liquidityCents": "1.000036490649026183145198711400933542774047455327e+36", + "reserveFactor": 0.1, + "reserveTokens": "0", + "supplierCount": 10, + "supplyApyPercentage": "0", + "supplyBalanceCents": "1.00003649064902618314530970887489046343322854178897705712904885e+36", + "supplyBalanceTokens": "1.000073663387094281439750824413033895903139261475326095e+34", + "supplyCapTokens": "1.15792089237316195423570985008687907853269984665640564039457584007913129639935e+71", + "supplyDistributions": [ + { + "apyPercentage": "0", + "dailyDistributedTokens": "1499.9999904", + "token": { + "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", + "asset": "/src/libs/tokens/img/xvs.svg", + "decimals": 18, + "symbol": "XVS", + }, + "type": "rewardDistributor", + }, + ], + "tokenPriceCents": "99.996283", + "userBorrowBalanceCents": "0", + "userBorrowBalanceTokens": "0", + "userPercentOfLimit": 0, + "userSupplyBalanceCents": "0", + "userSupplyBalanceTokens": "0", + "userWalletBalanceCents": "0", + "userWalletBalanceTokens": "0", + "vToken": { + "address": "0xb7526572FFE56AB9D7489838Bf2E18e3323b441A", + "decimals": 8, + "symbol": "vUSDT", + "underlyingToken": { + "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", + "asset": "/src/libs/tokens/img/usdt.svg", + "decimals": 6, + "symbol": "USDT", + }, + }, + }, + { + "borrowApyPercentage": "2.01448842548712155", + "borrowBalanceCents": "1562397934365776.075433634816", + "borrowBalanceTokens": "15624370577897.031296", + "borrowCapTokens": "0", + "borrowDistributions": [ + { + "apyPercentage": "0.00002240364211925", + "dailyDistributedTokens": "1499.9999904", + "token": { + "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", + "asset": "/src/libs/tokens/img/xvs.svg", + "decimals": 18, + "symbol": "XVS", + }, + "type": "rewardDistributor", + }, + ], + "borrowerCount": 20, + "cashTokens": "1.010176805025969148511141552e+21", + "collateralFactor": 0.81, + "disabledTokenActions": [], + "exchangeRateVTokens": "47.12928141003911013496", + "isCollateralOfUser": false, + "liquidityCents": "1.01015151019877129824366283301553792e+23", + "reserveFactor": 0.1, + "reserveTokens": "0", + "supplierCount": 10, + "supplyApyPercentage": "2.7256320003e-8", + "supplyBalanceCents": "1.0101515258227468345608256850251328456045167117888e+23", + "supplyBalanceTokens": "1.01017682065033591897223674983334867265528e+21", + "supplyCapTokens": "1.15792089237316195423570985008687907853269984665640564039457584007913129639935e+71", + "supplyDistributions": [ + { + "apyPercentage": "0", + "dailyDistributedTokens": "1499.9999904", + "token": { + "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", + "asset": "/src/libs/tokens/img/xvs.svg", + "decimals": 18, + "symbol": "XVS", + }, + "type": "rewardDistributor", + }, + ], + "tokenPriceCents": "99.997496", + "userBorrowBalanceCents": "0", + "userBorrowBalanceTokens": "0", + "userPercentOfLimit": 0, + "userSupplyBalanceCents": "0", + "userSupplyBalanceTokens": "0", + "userWalletBalanceCents": "0", + "userWalletBalanceTokens": "0", + "vToken": { + "address": "0xD5C4C2e2facBEB59D0216D0595d63FcDc6F9A1a7", + "decimals": 8, + "symbol": "vUSDC", + "underlyingToken": { + "address": "0x16227D60f7a0e586C66B005219dfc887D13C9531", + "asset": "/src/libs/tokens/img/usdc.svg", + "decimals": 6, + "symbol": "USDC", + }, + }, + }, + ], + "comptrollerAddress": "0x94d1820b2D1c7c7452A163983Dc888CEC546b77D", + "isIsolated": true, + "name": "Core Pool", + "userBorrowBalanceCents": "0", + "userBorrowLimitCents": "0", + "userSupplyBalanceCents": "0", + }, + { + "assets": [ + { + "borrowApyPercentage": "3.037255751760131518", "borrowBalanceCents": "10266.891765447722", "borrowBalanceTokens": "102.672734", "borrowCapTokens": "14880000", @@ -622,7 +1334,7 @@ exports[`getIsolatedPools - Feature enabled: Prime > fetches and formats Prime d "reserveFactor": 0.1, "reserveTokens": "0", "supplierCount": 10, - "supplyApyPercentage": "0.000104647012366676", + "supplyApyPercentage": "0.000104360310305731", "supplyBalanceCents": "264929592.64509868800383953542527752", "supplyBalanceTokens": "2649394.40444099995200661144", "supplyCapTokens": "18600000", @@ -645,8 +1357,8 @@ exports[`getIsolatedPools - Feature enabled: Prime > fetches and formats Prime d "userPercentOfLimit": 0, "userSupplyBalanceCents": "0", "userSupplyBalanceTokens": "0", - "userWalletBalanceCents": "999962830000000", - "userWalletBalanceTokens": "10000000000000", + "userWalletBalanceCents": "0", + "userWalletBalanceTokens": "0", "vToken": { "address": "0x80CC30811e362aC9aB857C3d7875CbcCc0b65750", "decimals": 8, @@ -661,7 +1373,6 @@ exports[`getIsolatedPools - Feature enabled: Prime > fetches and formats Prime d }, ], "comptrollerAddress": "0x23a73971A6B9f6580c048B9CB188869B2A2aA2aD", - "description": "", "isIsolated": true, "name": "DeFi", "userBorrowBalanceCents": "0", @@ -671,7 +1382,7 @@ exports[`getIsolatedPools - Feature enabled: Prime > fetches and formats Prime d { "assets": [ { - "borrowApyPercentage": "4.003672121275481", + "borrowApyPercentage": "3.992487050504593481", "borrowBalanceCents": "1032129.557718287222", "borrowBalanceTokens": "10321.679234", "borrowCapTokens": "14880000", @@ -686,7 +1397,7 @@ exports[`getIsolatedPools - Feature enabled: Prime > fetches and formats Prime d "reserveFactor": 0.1, "reserveTokens": "0.000131", "supplierCount": 10, - "supplyApyPercentage": "0.32764541346423925", + "supplyApyPercentage": "0.326746289860669541", "supplyBalanceCents": "11148355.88660845370158439626770976", "supplyBalanceTokens": "111487.70286399999189554272", "supplyCapTokens": "18600000", @@ -697,8 +1408,8 @@ exports[`getIsolatedPools - Feature enabled: Prime > fetches and formats Prime d "userPercentOfLimit": 0, "userSupplyBalanceCents": "0", "userSupplyBalanceTokens": "0", - "userWalletBalanceCents": "999962830000000", - "userWalletBalanceTokens": "10000000000000", + "userWalletBalanceCents": "0", + "userWalletBalanceTokens": "0", "vToken": { "address": "0x0bFE4e0B8A2a096A27e5B18b078d25be57C08634", "decimals": 8, @@ -713,7 +1424,6 @@ exports[`getIsolatedPools - Feature enabled: Prime > fetches and formats Prime d }, ], "comptrollerAddress": "0x1F4f0989C51f12DAcacD4025018176711f3Bf289", - "description": "", "isIsolated": true, "name": "GameFi", "userBorrowBalanceCents": "0", @@ -723,7 +1433,7 @@ exports[`getIsolatedPools - Feature enabled: Prime > fetches and formats Prime d { "assets": [ { - "borrowApyPercentage": "3.045326359470546", + "borrowApyPercentage": "3.03685757665446184", "borrowBalanceCents": "0.000399985132", "borrowBalanceTokens": "0.000004", "borrowCapTokens": "14880000", @@ -739,31 +1449,6 @@ exports[`getIsolatedPools - Feature enabled: Prime > fetches and formats Prime d }, "type": "rewardDistributor", }, - { - "apyPercentage": "0.32051113933926345", - "token": { - "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", - "asset": "/src/libs/tokens/img/usdt.svg", - "decimals": 6, - "symbol": "USDT", - }, - "type": "prime", - }, - { - "apyPercentage": "0.20019958435848473", - "referenceValues": { - "userBorrowBalanceTokens": "2e-7", - "userSupplyBalanceTokens": "1103100.00000039991050000018", - "userXvsStakedTokens": "1000", - }, - "token": { - "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", - "asset": "/src/libs/tokens/img/usdt.svg", - "decimals": 6, - "symbol": "USDT", - }, - "type": "primeSimulation", - }, ], "borrowerCount": 20, "cashTokens": "11031000", @@ -791,31 +1476,6 @@ exports[`getIsolatedPools - Feature enabled: Prime > fetches and formats Prime d }, "type": "rewardDistributor", }, - { - "apyPercentage": "0.2904197513866391", - "token": { - "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", - "asset": "/src/libs/tokens/img/usdt.svg", - "decimals": 6, - "symbol": "USDT", - }, - "type": "prime", - }, - { - "apyPercentage": "0.23026397657694986", - "referenceValues": { - "userBorrowBalanceTokens": "2e-7", - "userSupplyBalanceTokens": "1103100.00000039991050000018", - "userXvsStakedTokens": "1000", - }, - "token": { - "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", - "asset": "/src/libs/tokens/img/usdt.svg", - "decimals": 6, - "symbol": "USDT", - }, - "type": "primeSimulation", - }, ], "tokenPriceCents": "99.996283", "userBorrowBalanceCents": "0", @@ -823,8 +1483,8 @@ exports[`getIsolatedPools - Feature enabled: Prime > fetches and formats Prime d "userPercentOfLimit": 0, "userSupplyBalanceCents": "0", "userSupplyBalanceTokens": "0", - "userWalletBalanceCents": "999962830000000", - "userWalletBalanceTokens": "10000000000000", + "userWalletBalanceCents": "0", + "userWalletBalanceTokens": "0", "vToken": { "address": "0x2197d02cC9cd1ad51317A0a85A656a0c82383A7c", "decimals": 8, @@ -838,7 +1498,7 @@ exports[`getIsolatedPools - Feature enabled: Prime > fetches and formats Prime d }, }, { - "borrowApyPercentage": "399.5548791715505", + "borrowApyPercentage": "397.358195317640926827", "borrowBalanceCents": "14020.2378315565440147153504", "borrowBalanceTokens": "0.267025220823379366", "borrowCapTokens": "56000", @@ -865,7 +1525,7 @@ exports[`getIsolatedPools - Feature enabled: Prime > fetches and formats Prime d "reserveFactor": 0.25, "reserveTokens": "0", "supplierCount": 10, - "supplyApyPercentage": "233.30903562118922", + "supplyApyPercentage": "232.211474860496839891", "supplyBalanceCents": "14057.269817516691795017207856", "supplyBalanceTokens": "0.26773052085803925699", "supplyCapTokens": "80000", @@ -888,8 +1548,8 @@ exports[`getIsolatedPools - Feature enabled: Prime > fetches and formats Prime d "userPercentOfLimit": 0, "userSupplyBalanceCents": "0", "userSupplyBalanceTokens": "0", - "userWalletBalanceCents": "525052.944", - "userWalletBalanceTokens": "10", + "userWalletBalanceCents": "0", + "userWalletBalanceTokens": "0", "vToken": { "address": "0x231dED0Dfc99634e52EE1a1329586bc970d773b3", "decimals": 8, @@ -904,7 +1564,6 @@ exports[`getIsolatedPools - Feature enabled: Prime > fetches and formats Prime d }, ], "comptrollerAddress": "0x596B11acAACF03217287939f88d63b51d3771704", - "description": "", "isIsolated": true, "name": "Liquid Staked BNB", "userBorrowBalanceCents": "0", @@ -914,12 +1573,12 @@ exports[`getIsolatedPools - Feature enabled: Prime > fetches and formats Prime d { "assets": [ { - "borrowApyPercentage": "0.011647930409597329", + "borrowApyPercentage": "0.011616016420902095", "borrowBalanceCents": "399.985132", "borrowBalanceTokens": "4", "borrowCapTokens": "900000", "borrowDistributions": [], - "borrowerCount": 0, + "borrowerCount": 20, "cashTokens": "6006", "collateralFactor": 0.75, "disabledTokenActions": [], @@ -928,8 +1587,8 @@ exports[`getIsolatedPools - Feature enabled: Prime > fetches and formats Prime d "liquidityCents": "600577.675698", "reserveFactor": 0.1, "reserveTokens": "0", - "supplierCount": 0, - "supplyApyPercentage": "0.000006975767097294", + "supplierCount": 10, + "supplyApyPercentage": "0.00000695665176131", "supplyBalanceCents": "600977.66083", "supplyBalanceTokens": "6010", "supplyCapTokens": "1000000", @@ -940,8 +1599,8 @@ exports[`getIsolatedPools - Feature enabled: Prime > fetches and formats Prime d "userPercentOfLimit": 0, "userSupplyBalanceCents": "0", "userSupplyBalanceTokens": "0", - "userWalletBalanceCents": "999962830000000", - "userWalletBalanceTokens": "10000000000000", + "userWalletBalanceCents": "0", + "userWalletBalanceTokens": "0", "vToken": { "address": "0x3AF2bE7AbEF0f840b196D99d79F4B803a5dB14a1", "decimals": 8, @@ -956,7 +1615,6 @@ exports[`getIsolatedPools - Feature enabled: Prime > fetches and formats Prime d }, ], "comptrollerAddress": "0x92e8E3C202093A495e98C10f9fcaa5Abe288F74A", - "description": "", "isIsolated": true, "name": "Meme", "userBorrowBalanceCents": "0", @@ -966,7 +1624,7 @@ exports[`getIsolatedPools - Feature enabled: Prime > fetches and formats Prime d { "assets": [ { - "borrowApyPercentage": "5.130421804803698", + "borrowApyPercentage": "5.116012290184441153", "borrowBalanceCents": "1030091.4588649133175062", "borrowBalanceTokens": "10300.914588649133175062", "borrowCapTokens": "200000", @@ -981,7 +1639,7 @@ exports[`getIsolatedPools - Feature enabled: Prime > fetches and formats Prime d "reserveFactor": 0.2, "reserveTokens": "0.000166728600388574", "supplierCount": 10, - "supplyApyPercentage": "0.966416714921392", + "supplyApyPercentage": "0.963756279976176856", "supplyBalanceCents": "4287055.476159846231009819", "supplyBalanceTokens": "42870.55476159846231009819", "supplyCapTokens": "500000", @@ -992,8 +1650,8 @@ exports[`getIsolatedPools - Feature enabled: Prime > fetches and formats Prime d "userPercentOfLimit": 0, "userSupplyBalanceCents": "0", "userSupplyBalanceTokens": "0", - "userWalletBalanceCents": "1000", - "userWalletBalanceTokens": "10", + "userWalletBalanceCents": "0", + "userWalletBalanceTokens": "0", "vToken": { "address": "0x170d3b2da05cc2124334240fB34ad1359e34C562", "decimals": 8, @@ -1007,7 +1665,7 @@ exports[`getIsolatedPools - Feature enabled: Prime > fetches and formats Prime d }, }, { - "borrowApyPercentage": "2.028626199218375", + "borrowApyPercentage": "2.023012476743554002", "borrowBalanceCents": "100461.088822525373", "borrowBalanceTokens": "1004.648231", "borrowCapTokens": "400000", @@ -1023,94 +1681,442 @@ exports[`getIsolatedPools - Feature enabled: Prime > fetches and formats Prime d }, "type": "rewardDistributor", }, + ], + "borrowerCount": 20, + "cashTokens": "998174.53518", + "collateralFactor": 0.8, + "disabledTokenActions": [], + "exchangeRateVTokens": "0.99998934225265418908", + "isCollateralOfUser": false, + "liquidityCents": "99813743.30325273594", + "reserveFactor": 0.1, + "reserveTokens": "0.000002", + "supplierCount": 10, + "supplyApyPercentage": "0.001812471504422768", + "supplyBalanceCents": "99914204.39187526542630629377313097", + "supplyBalanceTokens": "999179.18340899996679182859", + "supplyCapTokens": "1000000", + "supplyDistributions": [ { - "apyPercentage": "0.32051113933926345", + "apyPercentage": "0", + "dailyDistributedTokens": "0", "token": { - "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", - "asset": "/src/libs/tokens/img/usdt.svg", - "decimals": 6, - "symbol": "USDT", + "address": "0xe73774DfCD551BF75650772dC2cC56a2B6323453", + "asset": "/src/libs/tokens/img/lisUSD.png", + "decimals": 18, + "symbol": "lisUSD", + }, + "type": "rewardDistributor", + }, + ], + "tokenPriceCents": "99.996283", + "userBorrowBalanceCents": "0", + "userBorrowBalanceTokens": "0", + "userPercentOfLimit": 0, + "userSupplyBalanceCents": "0", + "userSupplyBalanceTokens": "0", + "userWalletBalanceCents": "0", + "userWalletBalanceTokens": "0", + "vToken": { + "address": "0x3338988d0beb4419Acb8fE624218754053362D06", + "decimals": 8, + "symbol": "vUSDT", + "underlyingToken": { + "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", + "asset": "/src/libs/tokens/img/usdt.svg", + "decimals": 6, + "symbol": "USDT", + }, + }, + }, + ], + "comptrollerAddress": "0x10b57706AD2345e590c2eA4DC02faef0d9f5b08B", + "isIsolated": true, + "name": "Stablecoins", + "userBorrowBalanceCents": "0", + "userBorrowLimitCents": "0", + "userSupplyBalanceCents": "0", + }, + { + "assets": [ + { + "borrowApyPercentage": "3.03685757665446184", + "borrowBalanceCents": "0", + "borrowBalanceTokens": "0", + "borrowCapTokens": "14880000", + "borrowDistributions": [], + "borrowerCount": 20, + "cashTokens": "10000", + "collateralFactor": 0.8, + "disabledTokenActions": [], + "exchangeRateVTokens": "1", + "isCollateralOfUser": false, + "liquidityCents": "999962.83", + "reserveFactor": 0.1, + "reserveTokens": "0", + "supplierCount": 10, + "supplyApyPercentage": "0", + "supplyBalanceCents": "999962.83", + "supplyBalanceTokens": "10000", + "supplyCapTokens": "18600000", + "supplyDistributions": [], + "tokenPriceCents": "99.996283", + "userBorrowBalanceCents": "0", + "userBorrowBalanceTokens": "0", + "userPercentOfLimit": 0, + "userSupplyBalanceCents": "0", + "userSupplyBalanceTokens": "0", + "userWalletBalanceCents": "0", + "userWalletBalanceTokens": "0", + "vToken": { + "address": "0x712774CBFFCBD60e9825871CcEFF2F917442b2c3", + "decimals": 8, + "symbol": "vUSDT", + "underlyingToken": { + "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", + "asset": "/src/libs/tokens/img/usdt.svg", + "decimals": 6, + "symbol": "USDT", + }, + }, + }, + ], + "comptrollerAddress": "0x11537D023f489E4EF0C7157cc729C7B69CbE0c97", + "isIsolated": true, + "name": "Tron", + "userBorrowBalanceCents": "0", + "userBorrowLimitCents": "0", + "userSupplyBalanceCents": "0", + }, + ], +} +`; + +exports[`useGetPools > returns pools with user data in the correct format 1`] = ` +{ + "pools": [ + { + "assets": [ + { + "borrowApyPercentage": "2.014488270427066776", + "borrowBalanceCents": "24663011775918.58670630114424219627258", + "borrowBalanceTokens": "246628588661.936163058800477859", + "borrowCapTokens": "1e-18", + "borrowDistributions": [ + { + "apyPercentage": "0", + "dailyDistributedTokens": "0", + "token": { + "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", + "asset": "/src/libs/tokens/img/xvs.svg", + "decimals": 18, + "symbol": "XVS", + }, + "type": "rewardDistributor", + }, + ], + "borrowerCount": 438, + "cashTokens": "1.00000000080503544824460983238917793784e+21", + "collateralFactor": 0, + "disabledTokenActions": [ + "supply", + "borrow", + ], + "exchangeRateVTokens": "49.19405324154271215086", + "isCollateralOfUser": true, + "liquidityCents": "1.000006200805040439464388948970138750743214608e+23", + "reserveFactor": 1, + "reserveTokens": "0", + "supplierCount": 933, + "supplyApyPercentage": "0", + "supplyBalanceCents": "1.000006201051670556767362816225462034303610544746e+23", + "supplyBalanceTokens": "1.00000000105166403645033682413715238395883e+21", + "supplyCapTokens": "0", + "supplyDistributions": [ + { + "apyPercentage": "0", + "dailyDistributedTokens": "0", + "token": { + "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", + "asset": "/src/libs/tokens/img/xvs.svg", + "decimals": 18, + "symbol": "XVS", + }, + "type": "rewardDistributor", + }, + ], + "tokenPriceCents": "100.00062", + "userBorrowBalanceCents": "10.000062", + "userBorrowBalanceTokens": "0.1", + "userPercentOfLimit": 0, + "userSupplyBalanceCents": "200.00124", + "userSupplyBalanceTokens": "2", + "userWalletBalanceCents": "1000.0062", + "userWalletBalanceTokens": "10", + "vToken": { + "address": "0x08e0A5575De71037aE36AbfAfb516595fE68e5e4", + "decimals": 8, + "symbol": "vBUSD", + "underlyingToken": { + "address": "0x8301F2213c0eeD49a7E28Ae4c3e91722919B8B47", + "asset": "/src/libs/tokens/img/busd.svg", + "decimals": 18, + "symbol": "BUSD", + }, + }, + }, + { + "borrowApyPercentage": "12.72621843315593399", + "borrowBalanceCents": "3721959398.320962344455482972", + "borrowBalanceTokens": "15136.746248595758022748", + "borrowCapTokens": "0", + "borrowDistributions": [ + { + "apyPercentage": "1.5797413696681861", + "dailyDistributedTokens": "250.0000128", + "token": { + "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", + "asset": "/src/libs/tokens/img/xvs.svg", + "decimals": 18, + "symbol": "XVS", }, - "type": "prime", + "type": "rewardDistributor", }, + ], + "borrowerCount": 35, + "cashTokens": "0", + "collateralFactor": 0.8, + "disabledTokenActions": [], + "exchangeRateVTokens": "37.63966306652044917955", + "isCollateralOfUser": true, + "liquidityCents": "0", + "reserveFactor": 0.1, + "reserveTokens": "21.269535066688975633", + "supplierCount": 25, + "supplyApyPercentage": "11.401000590716290067", + "supplyBalanceCents": "3716729453.6129492577232450137", + "supplyBalanceTokens": "15115.4767135290690422233", + "supplyCapTokens": "1.15792089237316195423570985008687907853269984665640564039457584007913129639935e+59", + "supplyDistributions": [ { - "apyPercentage": "0.20019958435848473", - "referenceValues": { - "userBorrowBalanceTokens": "50.23241155", - "userSupplyBalanceTokens": "99917.91834089999667918285", - "userXvsStakedTokens": "1000", + "apyPercentage": "1.5819817239252298", + "dailyDistributedTokens": "250.0000128", + "token": { + "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", + "asset": "/src/libs/tokens/img/xvs.svg", + "decimals": 18, + "symbol": "XVS", }, + "type": "rewardDistributor", + }, + ], + "tokenPriceCents": "245889", + "userBorrowBalanceCents": "24588.9", + "userBorrowBalanceTokens": "0.1", + "userPercentOfLimit": 0, + "userSupplyBalanceCents": "491778", + "userSupplyBalanceTokens": "2", + "userWalletBalanceCents": "2458890", + "userWalletBalanceTokens": "10", + "vToken": { + "address": "0x162D005F0Fff510E54958Cfc5CF32A3180A84aab", + "decimals": 8, + "symbol": "vETH", + "underlyingToken": { + "address": "0x98f7A83361F7Ac8765CcEBAB1425da6b341958a7", + "asset": "/src/libs/tokens/img/eth.svg", + "decimals": 18, + "isNative": true, + "symbol": "ETH", + }, + }, + }, + { + "borrowApyPercentage": "179.96505731769223966", + "borrowBalanceCents": "54206766464.991794941213834066224", + "borrowBalanceTokens": "1032405.72373577234796371", + "borrowCapTokens": "0", + "borrowDistributions": [ + { + "apyPercentage": "0.6478221277312901", + "dailyDistributedTokens": "1499.9999904", "token": { - "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", - "asset": "/src/libs/tokens/img/usdt.svg", - "decimals": 6, - "symbol": "USDT", + "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", + "asset": "/src/libs/tokens/img/xvs.svg", + "decimals": 18, + "symbol": "XVS", + }, + "type": "rewardDistributor", + }, + ], + "borrowerCount": 263, + "cashTokens": "5.556233762724731858", + "collateralFactor": 0.8, + "disabledTokenActions": [], + "exchangeRateVTokens": "5.63429988023545433776", + "isCollateralOfUser": true, + "liquidityCents": "291731.6894670817923653489952", + "reserveFactor": 0.25, + "reserveTokens": "187487.447405339178551222", + "supplierCount": 923, + "supplyApyPercentage": "156.911092632839993416", + "supplyBalanceCents": "44362974574.359412320127072323564288", + "supplyBalanceTokens": "844923.83256419589412162352", + "supplyCapTokens": "1.15792089237316195423570985008687907853269984665640564039457584007913129639935e+59", + "supplyDistributions": [ + { + "apyPercentage": "0.7921351276470645", + "dailyDistributedTokens": "1499.9999904", + "token": { + "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", + "asset": "/src/libs/tokens/img/xvs.svg", + "decimals": 18, + "symbol": "XVS", + }, + "type": "rewardDistributor", + }, + ], + "tokenPriceCents": "52505.2944", + "userBorrowBalanceCents": "5250.52944", + "userBorrowBalanceTokens": "0.1", + "userPercentOfLimit": 0, + "userSupplyBalanceCents": "105010.5888", + "userSupplyBalanceTokens": "2", + "userWalletBalanceCents": "525052.944", + "userWalletBalanceTokens": "10", + "vToken": { + "address": "0x2E7222e51c0f6e98610A1543Aa3836E092CDe62c", + "decimals": 8, + "symbol": "vBNB", + "underlyingToken": { + "address": "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE", + "asset": "/src/libs/tokens/img/bnb.svg", + "decimals": 18, + "isNative": true, + "symbol": "BNB", + }, + }, + }, + { + "borrowApyPercentage": "16.800248594171254373", + "borrowBalanceCents": "266527277.02974427316207663041589", + "borrowBalanceTokens": "416884.364702270734855123", + "borrowCapTokens": "270000", + "borrowDistributions": [ + { + "apyPercentage": "0", + "dailyDistributedTokens": "0", + "token": { + "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", + "asset": "/src/libs/tokens/img/xvs.svg", + "decimals": 18, + "symbol": "XVS", }, - "type": "primeSimulation", + "type": "rewardDistributor", }, ], - "borrowerCount": 20, - "cashTokens": "998174.53518", - "collateralFactor": 0.8, + "borrowerCount": 68, + "cashTokens": "2259657.074761148481496107", + "collateralFactor": 0.6, "disabledTokenActions": [], - "exchangeRateVTokens": "0.99998934225265418908", - "isCollateralOfUser": false, - "liquidityCents": "99813743.30325273594", - "reserveFactor": 0.1, - "reserveTokens": "0.000002", - "supplierCount": 10, - "supplyApyPercentage": "0.001817450869823211", - "supplyBalanceCents": "99914204.39187526542630629377313097", - "supplyBalanceTokens": "999179.18340899996679182859", - "supplyCapTokens": "1000000", + "exchangeRateVTokens": "47.36910235297224095005", + "isCollateralOfUser": true, + "liquidityCents": "1444669788.91666196711723462774301", + "reserveFactor": 0.25, + "reserveTokens": "0", + "supplierCount": 274, + "supplyApyPercentage": "1.830999347346963073", + "supplyBalanceCents": "1711197065.9464062401284554003137589", + "supplyBalanceTokens": "2676541.43946341921611527123", + "supplyCapTokens": "3750000", "supplyDistributions": [ { "apyPercentage": "0", "dailyDistributedTokens": "0", "token": { - "address": "0xe73774DfCD551BF75650772dC2cC56a2B6323453", - "asset": "/src/libs/tokens/img/lisUSD.png", + "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", + "asset": "/src/libs/tokens/img/xvs.svg", "decimals": 18, - "symbol": "lisUSD", + "symbol": "XVS", }, "type": "rewardDistributor", }, + ], + "tokenPriceCents": "639.33143", + "userBorrowBalanceCents": "63.933143", + "userBorrowBalanceTokens": "0.1", + "userPercentOfLimit": 0, + "userSupplyBalanceCents": "1278.66286", + "userSupplyBalanceTokens": "2", + "userWalletBalanceCents": "6393.3143", + "userWalletBalanceTokens": "10", + "vToken": { + "address": "0x6d6F697e34145Bb95c54E77482d97cc261Dc237E", + "decimals": 8, + "symbol": "vXVS", + "underlyingToken": { + "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", + "asset": "/src/libs/tokens/img/xvs.svg", + "decimals": 18, + "symbol": "XVS", + }, + }, + }, + { + "borrowApyPercentage": "2.014488268288307401", + "borrowBalanceCents": "743724749.881571973423", + "borrowBalanceTokens": "7437523.951581", + "borrowCapTokens": "0", + "borrowDistributions": [ { - "apyPercentage": "0.2904197513866391", + "apyPercentage": "16.981964056809385", + "dailyDistributedTokens": "499.9999968", "token": { - "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", - "asset": "/src/libs/tokens/img/usdt.svg", - "decimals": 6, - "symbol": "USDT", + "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", + "asset": "/src/libs/tokens/img/xvs.svg", + "decimals": 18, + "symbol": "XVS", }, - "type": "prime", + "type": "rewardDistributor", }, + ], + "borrowerCount": 249, + "cashTokens": "1.0000736633870942814396398228131475074669e+34", + "collateralFactor": 0.8, + "disabledTokenActions": [], + "exchangeRateVTokens": "49.8066352191466231613", + "isCollateralOfUser": true, + "liquidityCents": "1.000036490649026183145198711400933542774047455327e+36", + "reserveFactor": 0.1, + "reserveTokens": "0", + "supplierCount": 670, + "supplyApyPercentage": "0", + "supplyBalanceCents": "1.00003649064902618314530970887489046343322854178897705712904885e+36", + "supplyBalanceTokens": "1.000073663387094281439750824413033895903139261475326095e+34", + "supplyCapTokens": "1.15792089237316195423570985008687907853269984665640564039457584007913129639935e+71", + "supplyDistributions": [ { - "apyPercentage": "0.23026397657694986", - "referenceValues": { - "userBorrowBalanceTokens": "50.23241155", - "userSupplyBalanceTokens": "99917.91834089999667918285", - "userXvsStakedTokens": "1000", - }, + "apyPercentage": "0", + "dailyDistributedTokens": "499.9999968", "token": { - "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", - "asset": "/src/libs/tokens/img/usdt.svg", - "decimals": 6, - "symbol": "USDT", + "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", + "asset": "/src/libs/tokens/img/xvs.svg", + "decimals": 18, + "symbol": "XVS", }, - "type": "primeSimulation", + "type": "rewardDistributor", }, ], "tokenPriceCents": "99.996283", - "userBorrowBalanceCents": "0", - "userBorrowBalanceTokens": "0", - "userPercentOfLimit": 0, - "userSupplyBalanceCents": "0", - "userSupplyBalanceTokens": "0", + "userBorrowBalanceCents": "9999628300000", + "userBorrowBalanceTokens": "100000000000", + "userPercentOfLimit": 3.1, + "userSupplyBalanceCents": "199992566000000", + "userSupplyBalanceTokens": "2000000000000", "userWalletBalanceCents": "999962830000000", "userWalletBalanceTokens": "10000000000000", "vToken": { - "address": "0x3338988d0beb4419Acb8fE624218754053362D06", + "address": "0xb7526572FFE56AB9D7489838Bf2E18e3323b441A", "decimals": 8, "symbol": "vUSDT", "underlyingToken": { @@ -1121,130 +2127,83 @@ exports[`getIsolatedPools - Feature enabled: Prime > fetches and formats Prime d }, }, }, - ], - "comptrollerAddress": "0x10b57706AD2345e590c2eA4DC02faef0d9f5b08B", - "description": "", - "isIsolated": true, - "name": "Stablecoins", - "userBorrowBalanceCents": "0", - "userBorrowLimitCents": "0", - "userSupplyBalanceCents": "0", - }, - { - "assets": [ { - "borrowApyPercentage": "3.045326359470546", - "borrowBalanceCents": "0", - "borrowBalanceTokens": "0", - "borrowCapTokens": "14880000", + "borrowApyPercentage": "2.01448842548712155", + "borrowBalanceCents": "1562397934365776.075433634816", + "borrowBalanceTokens": "15624370577897.031296", + "borrowCapTokens": "0", "borrowDistributions": [ { - "apyPercentage": "0.32051113933926345", - "token": { - "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", - "asset": "/src/libs/tokens/img/usdt.svg", - "decimals": 6, - "symbol": "USDT", - }, - "type": "prime", - }, - { - "apyPercentage": "0.20019958435848473", - "referenceValues": { - "userBorrowBalanceTokens": "0", - "userSupplyBalanceTokens": "1000", - "userXvsStakedTokens": "1000", - }, + "apyPercentage": "0.000007467880158706", + "dailyDistributedTokens": "499.9999968", "token": { - "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", - "asset": "/src/libs/tokens/img/usdt.svg", - "decimals": 6, - "symbol": "USDT", + "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", + "asset": "/src/libs/tokens/img/xvs.svg", + "decimals": 18, + "symbol": "XVS", }, - "type": "primeSimulation", + "type": "rewardDistributor", }, ], - "borrowerCount": 20, - "cashTokens": "10000", - "collateralFactor": 0.8, + "borrowerCount": 229, + "cashTokens": "1.010176805025969148511141552e+21", + "collateralFactor": 0.81, "disabledTokenActions": [], - "exchangeRateVTokens": "1", - "isCollateralOfUser": false, - "liquidityCents": "999962.83", + "exchangeRateVTokens": "47.12928141003911013496", + "isCollateralOfUser": true, + "liquidityCents": "1.01015151019877129824366283301553792e+23", "reserveFactor": 0.1, "reserveTokens": "0", - "supplierCount": 10, - "supplyApyPercentage": "0", - "supplyBalanceCents": "999962.83", - "supplyBalanceTokens": "10000", - "supplyCapTokens": "18600000", + "supplierCount": 534, + "supplyApyPercentage": "2.7256320003e-8", + "supplyBalanceCents": "1.0101515258227468345608256850251328456045167117888e+23", + "supplyBalanceTokens": "1.01017682065033591897223674983334867265528e+21", + "supplyCapTokens": "1.15792089237316195423570985008687907853269984665640564039457584007913129639935e+71", "supplyDistributions": [ { - "apyPercentage": "0.2904197513866391", - "token": { - "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", - "asset": "/src/libs/tokens/img/usdt.svg", - "decimals": 6, - "symbol": "USDT", - }, - "type": "prime", - }, - { - "apyPercentage": "0.23026397657694986", - "referenceValues": { - "userBorrowBalanceTokens": "0", - "userSupplyBalanceTokens": "1000", - "userXvsStakedTokens": "1000", - }, + "apyPercentage": "0", + "dailyDistributedTokens": "499.9999968", "token": { - "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", - "asset": "/src/libs/tokens/img/usdt.svg", - "decimals": 6, - "symbol": "USDT", + "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", + "asset": "/src/libs/tokens/img/xvs.svg", + "decimals": 18, + "symbol": "XVS", }, - "type": "primeSimulation", + "type": "rewardDistributor", }, ], - "tokenPriceCents": "99.996283", - "userBorrowBalanceCents": "0", - "userBorrowBalanceTokens": "0", - "userPercentOfLimit": 0, - "userSupplyBalanceCents": "0", - "userSupplyBalanceTokens": "0", - "userWalletBalanceCents": "999962830000000", + "tokenPriceCents": "99.997496", + "userBorrowBalanceCents": "9999749600000", + "userBorrowBalanceTokens": "100000000000", + "userPercentOfLimit": 3.1, + "userSupplyBalanceCents": "199994992000000", + "userSupplyBalanceTokens": "2000000000000", + "userWalletBalanceCents": "999974960000000", "userWalletBalanceTokens": "10000000000000", "vToken": { - "address": "0x712774CBFFCBD60e9825871CcEFF2F917442b2c3", + "address": "0xD5C4C2e2facBEB59D0216D0595d63FcDc6F9A1a7", "decimals": 8, - "symbol": "vUSDT", + "symbol": "vUSDC", "underlyingToken": { - "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", - "asset": "/src/libs/tokens/img/usdt.svg", + "address": "0x16227D60f7a0e586C66B005219dfc887D13C9531", + "asset": "/src/libs/tokens/img/usdc.svg", "decimals": 6, - "symbol": "USDT", + "symbol": "USDC", }, }, }, ], - "comptrollerAddress": "0x11537D023f489E4EF0C7157cc729C7B69CbE0c97", - "description": "", - "isIsolated": true, - "name": "Tron", - "userBorrowBalanceCents": "0", - "userBorrowLimitCents": "0", - "userSupplyBalanceCents": "0", + "comptrollerAddress": "0x94d1820b2D1c7c7452A163983Dc888CEC546b77D", + "isIsolated": false, + "name": "Core Pool", + "userBorrowBalanceCents": "19999377930013.362645", + "userBorrowLimitCents": "321989996798198.068756", + "userSupplyBalanceCents": "399987558598267.2529", }, - ], -} -`; - -exports[`getIsolatedPools - Feature enabled: Prime > filters out Prime distributions and simulations that are 0 1`] = ` -{ - "pools": [ { "assets": [ { - "borrowApyPercentage": "3.0457256612776096", + "borrowApyPercentage": "3.037255751760131518", "borrowBalanceCents": "10266.891765447722", "borrowBalanceTokens": "102.672734", "borrowCapTokens": "14880000", @@ -1266,12 +2225,12 @@ exports[`getIsolatedPools - Feature enabled: Prime > filters out Prime distribut "collateralFactor": 0.8, "disabledTokenActions": [], "exchangeRateVTokens": "0.99999847176819609601", - "isCollateralOfUser": false, + "isCollateralOfUser": true, "liquidityCents": "264919325.753333245081", "reserveFactor": 0.1, "reserveTokens": "0", "supplierCount": 10, - "supplyApyPercentage": "0.000104647012366676", + "supplyApyPercentage": "0.000104360310305731", "supplyBalanceCents": "264929592.64509868800383953542527752", "supplyBalanceTokens": "2649394.40444099995200661144", "supplyCapTokens": "18600000", @@ -1289,11 +2248,11 @@ exports[`getIsolatedPools - Feature enabled: Prime > filters out Prime distribut }, ], "tokenPriceCents": "99.996283", - "userBorrowBalanceCents": "0", - "userBorrowBalanceTokens": "0", - "userPercentOfLimit": 0, - "userSupplyBalanceCents": "0", - "userSupplyBalanceTokens": "0", + "userBorrowBalanceCents": "9999628300000", + "userBorrowBalanceTokens": "100000000000", + "userPercentOfLimit": 6.25, + "userSupplyBalanceCents": "199992566000000", + "userSupplyBalanceTokens": "2000000000000", "userWalletBalanceCents": "999962830000000", "userWalletBalanceTokens": "10000000000000", "vToken": { @@ -1310,17 +2269,16 @@ exports[`getIsolatedPools - Feature enabled: Prime > filters out Prime distribut }, ], "comptrollerAddress": "0x23a73971A6B9f6580c048B9CB188869B2A2aA2aD", - "description": "", "isIsolated": true, "name": "DeFi", - "userBorrowBalanceCents": "0", - "userBorrowLimitCents": "0", - "userSupplyBalanceCents": "0", + "userBorrowBalanceCents": "9999628300000", + "userBorrowLimitCents": "159994052800000", + "userSupplyBalanceCents": "199992566000000", }, { "assets": [ { - "borrowApyPercentage": "4.003672121275481", + "borrowApyPercentage": "3.992487050504593481", "borrowBalanceCents": "1032129.557718287222", "borrowBalanceTokens": "10321.679234", "borrowCapTokens": "14880000", @@ -1330,22 +2288,22 @@ exports[`getIsolatedPools - Feature enabled: Prime > filters out Prime distribut "collateralFactor": 0.8, "disabledTokenActions": [], "exchangeRateVTokens": "0.997398625122774492", - "isCollateralOfUser": false, + "isCollateralOfUser": true, "liquidityCents": "10116226.341989680363", "reserveFactor": 0.1, "reserveTokens": "0.000131", "supplierCount": 10, - "supplyApyPercentage": "0.32764541346423925", + "supplyApyPercentage": "0.326746289860669541", "supplyBalanceCents": "11148355.88660845370158439626770976", "supplyBalanceTokens": "111487.70286399999189554272", "supplyCapTokens": "18600000", "supplyDistributions": [], "tokenPriceCents": "99.996283", - "userBorrowBalanceCents": "0", - "userBorrowBalanceTokens": "0", - "userPercentOfLimit": 0, - "userSupplyBalanceCents": "0", - "userSupplyBalanceTokens": "0", + "userBorrowBalanceCents": "9999628300000", + "userBorrowBalanceTokens": "100000000000", + "userPercentOfLimit": 6.25, + "userSupplyBalanceCents": "199992566000000", + "userSupplyBalanceTokens": "2000000000000", "userWalletBalanceCents": "999962830000000", "userWalletBalanceTokens": "10000000000000", "vToken": { @@ -1362,17 +2320,16 @@ exports[`getIsolatedPools - Feature enabled: Prime > filters out Prime distribut }, ], "comptrollerAddress": "0x1F4f0989C51f12DAcacD4025018176711f3Bf289", - "description": "", "isIsolated": true, "name": "GameFi", - "userBorrowBalanceCents": "0", - "userBorrowLimitCents": "0", - "userSupplyBalanceCents": "0", + "userBorrowBalanceCents": "9999628300000", + "userBorrowLimitCents": "159994052800000", + "userSupplyBalanceCents": "199992566000000", }, { "assets": [ { - "borrowApyPercentage": "3.045326359470546", + "borrowApyPercentage": "3.03685757665446184", "borrowBalanceCents": "0.000399985132", "borrowBalanceTokens": "0.000004", "borrowCapTokens": "14880000", @@ -1388,16 +2345,6 @@ exports[`getIsolatedPools - Feature enabled: Prime > filters out Prime distribut }, "type": "rewardDistributor", }, - { - "apyPercentage": "0", - "token": { - "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", - "asset": "/src/libs/tokens/img/usdt.svg", - "decimals": 6, - "symbol": "USDT", - }, - "type": "prime", - }, ], "borrowerCount": 20, "cashTokens": "11031000", @@ -1425,23 +2372,13 @@ exports[`getIsolatedPools - Feature enabled: Prime > filters out Prime distribut }, "type": "rewardDistributor", }, - { - "apyPercentage": "0", - "token": { - "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", - "asset": "/src/libs/tokens/img/usdt.svg", - "decimals": 6, - "symbol": "USDT", - }, - "type": "prime", - }, ], "tokenPriceCents": "99.996283", "userBorrowBalanceCents": "0", "userBorrowBalanceTokens": "0", "userPercentOfLimit": 0, - "userSupplyBalanceCents": "0", - "userSupplyBalanceTokens": "0", + "userSupplyBalanceCents": "199992566000000", + "userSupplyBalanceTokens": "2000000000000", "userWalletBalanceCents": "999962830000000", "userWalletBalanceTokens": "10000000000000", "vToken": { @@ -1457,7 +2394,7 @@ exports[`getIsolatedPools - Feature enabled: Prime > filters out Prime distribut }, }, { - "borrowApyPercentage": "399.5548791715505", + "borrowApyPercentage": "397.358195317640926827", "borrowBalanceCents": "14020.2378315565440147153504", "borrowBalanceTokens": "0.267025220823379366", "borrowCapTokens": "56000", @@ -1479,12 +2416,12 @@ exports[`getIsolatedPools - Feature enabled: Prime > filters out Prime distribut "collateralFactor": 0.45, "disabledTokenActions": [], "exchangeRateVTokens": "0.856077892298015039", - "isCollateralOfUser": false, + "isCollateralOfUser": true, "liquidityCents": "37.0319859601477808269104", "reserveFactor": 0.25, "reserveTokens": "0", "supplierCount": 10, - "supplyApyPercentage": "233.30903562118922", + "supplyApyPercentage": "232.211474860496839891", "supplyBalanceCents": "14057.269817516691795017207856", "supplyBalanceTokens": "0.26773052085803925699", "supplyCapTokens": "80000", @@ -1502,11 +2439,11 @@ exports[`getIsolatedPools - Feature enabled: Prime > filters out Prime distribut }, ], "tokenPriceCents": "52505.2944", - "userBorrowBalanceCents": "0", - "userBorrowBalanceTokens": "0", - "userPercentOfLimit": 0, - "userSupplyBalanceCents": "0", - "userSupplyBalanceTokens": "0", + "userBorrowBalanceCents": "5250.52944", + "userBorrowBalanceTokens": "0.1", + "userPercentOfLimit": 11.11, + "userSupplyBalanceCents": "105010.5888", + "userSupplyBalanceTokens": "2", "userWalletBalanceCents": "525052.944", "userWalletBalanceTokens": "10", "vToken": { @@ -1523,42 +2460,41 @@ exports[`getIsolatedPools - Feature enabled: Prime > filters out Prime distribut }, ], "comptrollerAddress": "0x596B11acAACF03217287939f88d63b51d3771704", - "description": "", "isIsolated": true, "name": "Liquid Staked BNB", - "userBorrowBalanceCents": "0", - "userBorrowLimitCents": "0", - "userSupplyBalanceCents": "0", + "userBorrowBalanceCents": "5250.52944", + "userBorrowLimitCents": "47254.76496", + "userSupplyBalanceCents": "199992566105010.5888", }, { "assets": [ { - "borrowApyPercentage": "0.011647930409597329", + "borrowApyPercentage": "0.011616016420902095", "borrowBalanceCents": "399.985132", "borrowBalanceTokens": "4", "borrowCapTokens": "900000", "borrowDistributions": [], - "borrowerCount": 0, + "borrowerCount": 20, "cashTokens": "6006", "collateralFactor": 0.75, "disabledTokenActions": [], "exchangeRateVTokens": "1", - "isCollateralOfUser": false, + "isCollateralOfUser": true, "liquidityCents": "600577.675698", "reserveFactor": 0.1, "reserveTokens": "0", - "supplierCount": 0, - "supplyApyPercentage": "0.000006975767097294", + "supplierCount": 10, + "supplyApyPercentage": "0.00000695665176131", "supplyBalanceCents": "600977.66083", "supplyBalanceTokens": "6010", "supplyCapTokens": "1000000", "supplyDistributions": [], "tokenPriceCents": "99.996283", - "userBorrowBalanceCents": "0", - "userBorrowBalanceTokens": "0", - "userPercentOfLimit": 0, - "userSupplyBalanceCents": "0", - "userSupplyBalanceTokens": "0", + "userBorrowBalanceCents": "9999628300000", + "userBorrowBalanceTokens": "100000000000", + "userPercentOfLimit": 6.66, + "userSupplyBalanceCents": "199992566000000", + "userSupplyBalanceTokens": "2000000000000", "userWalletBalanceCents": "999962830000000", "userWalletBalanceTokens": "10000000000000", "vToken": { @@ -1575,17 +2511,16 @@ exports[`getIsolatedPools - Feature enabled: Prime > filters out Prime distribut }, ], "comptrollerAddress": "0x92e8E3C202093A495e98C10f9fcaa5Abe288F74A", - "description": "", "isIsolated": true, "name": "Meme", - "userBorrowBalanceCents": "0", - "userBorrowLimitCents": "0", - "userSupplyBalanceCents": "0", + "userBorrowBalanceCents": "9999628300000", + "userBorrowLimitCents": "149994424500000", + "userSupplyBalanceCents": "199992566000000", }, { "assets": [ { - "borrowApyPercentage": "5.130421804803698", + "borrowApyPercentage": "5.116012290184441153", "borrowBalanceCents": "1030091.4588649133175062", "borrowBalanceTokens": "10300.914588649133175062", "borrowCapTokens": "200000", @@ -1595,22 +2530,22 @@ exports[`getIsolatedPools - Feature enabled: Prime > filters out Prime distribut "collateralFactor": 0.65, "disabledTokenActions": [], "exchangeRateVTokens": "0.9930076443898276885", - "isCollateralOfUser": false, + "isCollateralOfUser": true, "liquidityCents": "3256964.0339677929523638", "reserveFactor": 0.2, "reserveTokens": "0.000166728600388574", "supplierCount": 10, - "supplyApyPercentage": "0.966416714921392", + "supplyApyPercentage": "0.963756279976176856", "supplyBalanceCents": "4287055.476159846231009819", "supplyBalanceTokens": "42870.55476159846231009819", "supplyCapTokens": "500000", "supplyDistributions": [], "tokenPriceCents": "100", - "userBorrowBalanceCents": "0", - "userBorrowBalanceTokens": "0", + "userBorrowBalanceCents": "10", + "userBorrowBalanceTokens": "0.1", "userPercentOfLimit": 0, - "userSupplyBalanceCents": "0", - "userSupplyBalanceTokens": "0", + "userSupplyBalanceCents": "200", + "userSupplyBalanceTokens": "2", "userWalletBalanceCents": "1000", "userWalletBalanceTokens": "10", "vToken": { @@ -1626,7 +2561,7 @@ exports[`getIsolatedPools - Feature enabled: Prime > filters out Prime distribut }, }, { - "borrowApyPercentage": "2.028626199218375", + "borrowApyPercentage": "2.023012476743554002", "borrowBalanceCents": "100461.088822525373", "borrowBalanceTokens": "1004.648231", "borrowCapTokens": "400000", @@ -1642,28 +2577,18 @@ exports[`getIsolatedPools - Feature enabled: Prime > filters out Prime distribut }, "type": "rewardDistributor", }, - { - "apyPercentage": "0", - "token": { - "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", - "asset": "/src/libs/tokens/img/usdt.svg", - "decimals": 6, - "symbol": "USDT", - }, - "type": "prime", - }, ], "borrowerCount": 20, "cashTokens": "998174.53518", "collateralFactor": 0.8, "disabledTokenActions": [], "exchangeRateVTokens": "0.99998934225265418908", - "isCollateralOfUser": false, + "isCollateralOfUser": true, "liquidityCents": "99813743.30325273594", "reserveFactor": 0.1, "reserveTokens": "0.000002", "supplierCount": 10, - "supplyApyPercentage": "0.001817450869823211", + "supplyApyPercentage": "0.001812471504422768", "supplyBalanceCents": "99914204.39187526542630629377313097", "supplyBalanceTokens": "999179.18340899996679182859", "supplyCapTokens": "1000000", @@ -1679,23 +2604,13 @@ exports[`getIsolatedPools - Feature enabled: Prime > filters out Prime distribut }, "type": "rewardDistributor", }, - { - "apyPercentage": "0", - "token": { - "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", - "asset": "/src/libs/tokens/img/usdt.svg", - "decimals": 6, - "symbol": "USDT", - }, - "type": "prime", - }, ], "tokenPriceCents": "99.996283", - "userBorrowBalanceCents": "0", - "userBorrowBalanceTokens": "0", - "userPercentOfLimit": 0, - "userSupplyBalanceCents": "0", - "userSupplyBalanceTokens": "0", + "userBorrowBalanceCents": "9999628300000", + "userBorrowBalanceTokens": "100000000000", + "userPercentOfLimit": 6.24, + "userSupplyBalanceCents": "199992566000000", + "userSupplyBalanceTokens": "2000000000000", "userWalletBalanceCents": "999962830000000", "userWalletBalanceTokens": "10000000000000", "vToken": { @@ -1712,32 +2627,20 @@ exports[`getIsolatedPools - Feature enabled: Prime > filters out Prime distribut }, ], "comptrollerAddress": "0x10b57706AD2345e590c2eA4DC02faef0d9f5b08B", - "description": "", "isIsolated": true, "name": "Stablecoins", - "userBorrowBalanceCents": "0", - "userBorrowLimitCents": "0", - "userSupplyBalanceCents": "0", + "userBorrowBalanceCents": "9999628300010", + "userBorrowLimitCents": "159994052800130", + "userSupplyBalanceCents": "199992566000200", }, { "assets": [ { - "borrowApyPercentage": "3.045326359470546", + "borrowApyPercentage": "3.03685757665446184", "borrowBalanceCents": "0", "borrowBalanceTokens": "0", "borrowCapTokens": "14880000", - "borrowDistributions": [ - { - "apyPercentage": "0", - "token": { - "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", - "asset": "/src/libs/tokens/img/usdt.svg", - "decimals": 6, - "symbol": "USDT", - }, - "type": "prime", - }, - ], + "borrowDistributions": [], "borrowerCount": 20, "cashTokens": "10000", "collateralFactor": 0.8, @@ -1752,24 +2655,13 @@ exports[`getIsolatedPools - Feature enabled: Prime > filters out Prime distribut "supplyBalanceCents": "999962.83", "supplyBalanceTokens": "10000", "supplyCapTokens": "18600000", - "supplyDistributions": [ - { - "apyPercentage": "0", - "token": { - "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", - "asset": "/src/libs/tokens/img/usdt.svg", - "decimals": 6, - "symbol": "USDT", - }, - "type": "prime", - }, - ], + "supplyDistributions": [], "tokenPriceCents": "99.996283", "userBorrowBalanceCents": "0", "userBorrowBalanceTokens": "0", "userPercentOfLimit": 0, - "userSupplyBalanceCents": "0", - "userSupplyBalanceTokens": "0", + "userSupplyBalanceCents": "199992566000000", + "userSupplyBalanceTokens": "2000000000000", "userWalletBalanceCents": "999962830000000", "userWalletBalanceTokens": "10000000000000", "vToken": { @@ -1786,12 +2678,11 @@ exports[`getIsolatedPools - Feature enabled: Prime > filters out Prime distribut }, ], "comptrollerAddress": "0x11537D023f489E4EF0C7157cc729C7B69CbE0c97", - "description": "", "isIsolated": true, "name": "Tron", "userBorrowBalanceCents": "0", "userBorrowLimitCents": "0", - "userSupplyBalanceCents": "0", + "userSupplyBalanceCents": "199992566000000", }, ], } diff --git a/apps/evm/src/clients/api/queries/useGetPools/__tests__/index.prime.spec.ts b/apps/evm/src/clients/api/queries/useGetPools/__tests__/index.prime.spec.ts new file mode 100644 index 0000000000..46cbe27b19 --- /dev/null +++ b/apps/evm/src/clients/api/queries/useGetPools/__tests__/index.prime.spec.ts @@ -0,0 +1,115 @@ +import { waitFor } from '@testing-library/dom'; +import { BigNumber as BN } from 'ethers'; +import type Vi from 'vitest'; + +import apiPoolsResponse from '__mocks__/api/pools.json'; +import fakeAccountAddress from '__mocks__/models/address'; +import { getIsolatedPoolParticipantsCount } from 'clients/subgraph'; +import { type UseIsFeatureEnabled, useIsFeatureEnabled } from 'hooks/useIsFeatureEnabled'; +import { + type Prime, + getIsolatedPoolComptrollerContract, + useGetLegacyPoolComptrollerContract, + useGetPoolLensContract, + useGetPrimeContract, + useGetVaiControllerContract, + useGetVenusLensContract, +} from 'libs/contracts'; +import { renderHook } from 'testUtils/render'; +import { restService } from 'utilities/restService'; +import { useGetPools } from '..'; +import { + fakeIsolatedPoolComptrollerContract, + fakeIsolatedPoolParticipantsCount, + fakeLegacyPoolComptrollerContract, + fakePoolLensContract, + fakePrimeContract, + fakeVaiControllerContract, + fakeVenusLensContract, +} from '../__testUtils__/fakeData'; + +vi.mock('libs/contracts'); +vi.mock('utilities/restService'); + +describe('useGetPools', () => { + beforeEach(() => { + (useIsFeatureEnabled as Vi.Mock).mockImplementation( + ({ name }: UseIsFeatureEnabled) => name === 'prime', + ); + + (getIsolatedPoolComptrollerContract as Vi.Mock).mockImplementation( + () => fakeIsolatedPoolComptrollerContract, + ); + (useGetPoolLensContract as Vi.Mock).mockImplementation(() => fakePoolLensContract); + (useGetLegacyPoolComptrollerContract as Vi.Mock).mockImplementation( + () => fakeLegacyPoolComptrollerContract, + ); + (useGetVenusLensContract as Vi.Mock).mockImplementation(() => fakeVenusLensContract); + (useGetVaiControllerContract as Vi.Mock).mockImplementation(() => fakeVaiControllerContract); + (useGetPrimeContract as Vi.Mock).mockImplementation(() => fakePrimeContract); + + (restService as Vi.Mock).mockImplementation(async () => ({ + status: 200, + data: apiPoolsResponse, + })); + + (getIsolatedPoolParticipantsCount as Vi.Mock).mockImplementation( + () => fakeIsolatedPoolParticipantsCount, + ); + }); + + it('fetches and formats Prime distributions and Prime distribution simulations if user is Prime', async () => { + const { result } = renderHook(() => + useGetPools({ + accountAddress: fakeAccountAddress, + }), + ); + + await waitFor(() => expect(result.current.data).toBeDefined()); + expect(result.current.data).toMatchSnapshot(); + }); + + it('does not fetch Prime distributions if user is not Prime', async () => { + const customFakePrimeContract = { + ...fakePrimeContract, + tokens: async () => ({ + exists: false, + isIrrevocable: false, + }), + } as unknown as Prime; + (useGetPrimeContract as Vi.Mock).mockImplementation(() => customFakePrimeContract); + + const { result } = renderHook(() => + useGetPools({ + accountAddress: fakeAccountAddress, + }), + ); + + await waitFor(() => expect(result.current.data).toBeDefined()); + expect(result.current.data).toMatchSnapshot(); + }); + + it('filters out Prime simulations that are 0', async () => { + const customFakePrimeContract = { + ...fakePrimeContract, + estimateAPR: async () => ({ + borrowAPR: BN.from(0), + supplyAPR: BN.from(0), + }), + calculateAPR: async () => ({ + borrowAPR: BN.from(0), + supplyAPR: BN.from(0), + }), + } as unknown as Prime; + (useGetPrimeContract as Vi.Mock).mockImplementation(() => customFakePrimeContract); + + const { result } = renderHook(() => + useGetPools({ + accountAddress: fakeAccountAddress, + }), + ); + + await waitFor(() => expect(result.current.data).toBeDefined()); + expect(result.current.data).toMatchSnapshot(); + }); +}); diff --git a/apps/evm/src/clients/api/queries/useGetPools/__tests__/index.spec.ts b/apps/evm/src/clients/api/queries/useGetPools/__tests__/index.spec.ts new file mode 100644 index 0000000000..6ee707e77c --- /dev/null +++ b/apps/evm/src/clients/api/queries/useGetPools/__tests__/index.spec.ts @@ -0,0 +1,81 @@ +import { waitFor } from '@testing-library/dom'; +import type Vi from 'vitest'; + +import { ChainId } from '@venusprotocol/chains'; +import apiPoolsResponse from '__mocks__/api/pools.json'; +import fakeAccountAddress from '__mocks__/models/address'; +import { getIsolatedPoolParticipantsCount } from 'clients/subgraph'; +import { + getIsolatedPoolComptrollerContract, + useGetLegacyPoolComptrollerContract, + useGetPoolLensContract, + useGetVaiControllerContract, + useGetVenusLensContract, +} from 'libs/contracts'; +import { useChainId } from 'libs/wallet'; +import { renderHook } from 'testUtils/render'; +import { restService } from 'utilities/restService'; +import { useGetPools } from '..'; +import { + fakeIsolatedPoolComptrollerContract, + fakeIsolatedPoolParticipantsCount, + fakeLegacyPoolComptrollerContract, + fakePoolLensContract, + fakeVaiControllerContract, + fakeVenusLensContract, +} from '../__testUtils__/fakeData'; + +vi.mock('libs/contracts'); +vi.mock('utilities/restService'); + +describe('useGetPools', () => { + beforeEach(() => { + (getIsolatedPoolComptrollerContract as Vi.Mock).mockImplementation( + () => fakeIsolatedPoolComptrollerContract, + ); + (useGetPoolLensContract as Vi.Mock).mockImplementation(() => fakePoolLensContract); + (useGetLegacyPoolComptrollerContract as Vi.Mock).mockImplementation( + () => fakeLegacyPoolComptrollerContract, + ); + (useGetVenusLensContract as Vi.Mock).mockImplementation(() => fakeVenusLensContract); + (useGetVaiControllerContract as Vi.Mock).mockImplementation(() => fakeVaiControllerContract); + + (restService as Vi.Mock).mockImplementation(async () => ({ + status: 200, + data: apiPoolsResponse, + })); + + (getIsolatedPoolParticipantsCount as Vi.Mock).mockImplementation( + () => fakeIsolatedPoolParticipantsCount, + ); + }); + + it('returns pools in the correct format', async () => { + const { result } = renderHook(() => useGetPools()); + + await waitFor(() => expect(result.current.data).toBeDefined()); + expect(result.current.data).toMatchSnapshot(); + }); + + it('returns pools with user data in the correct format', async () => { + const { result } = renderHook(() => + useGetPools({ + accountAddress: fakeAccountAddress, + }), + ); + + await waitFor(() => expect(result.current.data).toBeDefined()); + expect(result.current.data).toMatchSnapshot(); + }); + + it('returns pools with time based reward rates in the correct format', async () => { + (useChainId as Vi.Mock).mockImplementation(() => ({ + chainId: ChainId.ARBITRUM_SEPOLIA, + })); + + const { result } = renderHook(() => useGetPools()); + + await waitFor(() => expect(result.current.data).toBeDefined()); + expect(result.current.data).toMatchSnapshot(); + }); +}); diff --git a/apps/evm/src/utilities/appendPrimeSimulationDistributions.ts b/apps/evm/src/clients/api/queries/useGetPools/getPools/appendPrimeSimulationDistributions/index.ts similarity index 100% rename from apps/evm/src/utilities/appendPrimeSimulationDistributions.ts rename to apps/evm/src/clients/api/queries/useGetPools/getPools/appendPrimeSimulationDistributions/index.ts diff --git a/apps/evm/src/clients/api/queries/getIsolatedPools/formatOutput/formatDistributions.ts b/apps/evm/src/clients/api/queries/useGetPools/getPools/formatOutput/formatDistributions/index.ts similarity index 65% rename from apps/evm/src/clients/api/queries/getIsolatedPools/formatOutput/formatDistributions.ts rename to apps/evm/src/clients/api/queries/useGetPools/getPools/formatOutput/formatDistributions/index.ts index 4e5566d348..816fe857ed 100644 --- a/apps/evm/src/clients/api/queries/getIsolatedPools/formatOutput/formatDistributions.ts +++ b/apps/evm/src/clients/api/queries/useGetPools/getPools/formatOutput/formatDistributions/index.ts @@ -1,37 +1,36 @@ import type BigNumber from 'bignumber.js'; -import type { AssetDistribution, PrimeApy, Token } from 'types'; +import type { AssetDistribution, Token } from 'types'; import { calculateDailyTokenRate } from 'utilities/calculateDailyTokenRate'; import findTokenByAddress from 'utilities/findTokenByAddress'; import formatRewardDistribution from 'utilities/formatRewardDistribution'; -import type { RewardsDistributorSettingsResult } from '../getRewardsDistributorSettingsMapping'; -import type { GetTokenPriceDollarsMappingOutput } from '../getTokenPriceDollarsMapping'; +import type { ApiRewardDistributor } from 'clients/api/queries/useGetPools/getPools/getApiPools'; +import { convertPriceMantissaToDollars } from 'utilities'; +import type { PrimeApy } from '../../../types'; import { isDistributingRewards } from './isDistributingRewards'; export type FormatDistributionsInput = { - underlyingToken: Token; underlyingTokenPriceDollars: BigNumber; tokens: Token[]; - tokenPriceDollarsMapping: GetTokenPriceDollarsMappingOutput; - rewardsDistributorSettings: RewardsDistributorSettingsResult[]; + apiRewardsDistributors: ApiRewardDistributor[]; currentBlockNumber: number; supplyBalanceTokens: BigNumber; borrowBalanceTokens: BigNumber; - blocksPerDay?: number; + underlyingToken: Token; primeApy?: PrimeApy; + blocksPerDay?: number; }; -const formatDistributions = ({ +export const formatDistributions = ({ blocksPerDay, - underlyingToken, underlyingTokenPriceDollars, tokens, - tokenPriceDollarsMapping, - rewardsDistributorSettings, + apiRewardsDistributors, currentBlockNumber, supplyBalanceTokens, borrowBalanceTokens, + underlyingToken, primeApy, }: FormatDistributionsInput) => { const supplyDistributions: AssetDistribution[] = []; @@ -40,13 +39,14 @@ const formatDistributions = ({ const supplyBalanceDollars = supplyBalanceTokens.multipliedBy(underlyingTokenPriceDollars); const borrowBalanceDollars = borrowBalanceTokens.multipliedBy(underlyingTokenPriceDollars); - rewardsDistributorSettings.forEach( + apiRewardsDistributors.forEach( ({ rewardTokenAddress, - rewardTokenLastRewardingSupplyBlockOrTimestamp, - rewardTokenLastRewardingBorrowBlockOrTimestamp, - rewardTokenSupplySpeeds, - rewardTokenBorrowSpeeds, + lastRewardingSupplyBlockOrTimestamp, + lastRewardingBorrowBlockOrTimestamp, + supplySpeed, + borrowSpeed, + priceMantissa, }) => { const rewardToken = findTokenByAddress({ tokens, @@ -57,28 +57,22 @@ const formatDistributions = ({ return; } - const rewardTokenPriceDollars = tokenPriceDollarsMapping[rewardToken.address.toLowerCase()]; - - if (!rewardTokenPriceDollars) { - return; - } - const isChainTimeBased = !blocksPerDay; + const rewardTokenPriceDollars = convertPriceMantissaToDollars({ + priceMantissa, + decimals: rewardToken.decimals, + }); const isDistributingSupplyRewards = isDistributingRewards({ isTimeBased: isChainTimeBased, - lastRewardingTimestamp: isChainTimeBased - ? rewardTokenLastRewardingSupplyBlockOrTimestamp.toNumber() - : undefined, - lastRewardingBlock: isChainTimeBased - ? undefined - : rewardTokenLastRewardingBorrowBlockOrTimestamp.toNumber(), + lastRewardingTimestamp: isChainTimeBased ? +lastRewardingSupplyBlockOrTimestamp : undefined, + lastRewardingBlock: isChainTimeBased ? undefined : +lastRewardingSupplyBlockOrTimestamp, currentBlockNumber, }); if (isDistributingSupplyRewards) { const dailyDistributedRewardTokens = calculateDailyTokenRate({ - rateMantissa: rewardTokenSupplySpeeds.toString(), + rateMantissa: supplySpeed, decimals: rewardToken.decimals, blocksPerDay, }); @@ -95,18 +89,14 @@ const formatDistributions = ({ const isDistributingBorrowRewards = isDistributingRewards({ isTimeBased: isChainTimeBased, - lastRewardingTimestamp: isChainTimeBased - ? rewardTokenLastRewardingBorrowBlockOrTimestamp.toNumber() - : undefined, - lastRewardingBlock: isChainTimeBased - ? undefined - : rewardTokenLastRewardingBorrowBlockOrTimestamp.toNumber(), + lastRewardingTimestamp: isChainTimeBased ? +lastRewardingBorrowBlockOrTimestamp : undefined, + lastRewardingBlock: isChainTimeBased ? undefined : +lastRewardingBorrowBlockOrTimestamp, currentBlockNumber, }); if (isDistributingBorrowRewards) { const dailyDistributedRewardTokens = calculateDailyTokenRate({ - rateMantissa: rewardTokenBorrowSpeeds.toString(), + rateMantissa: borrowSpeed, decimals: rewardToken.decimals, blocksPerDay, }); @@ -143,5 +133,3 @@ const formatDistributions = ({ borrowDistributions, }; }; - -export default formatDistributions; diff --git a/apps/evm/src/clients/api/queries/getIsolatedPools/formatOutput/isDistributingRewards.ts b/apps/evm/src/clients/api/queries/useGetPools/getPools/formatOutput/formatDistributions/isDistributingRewards/index.ts similarity index 100% rename from apps/evm/src/clients/api/queries/getIsolatedPools/formatOutput/isDistributingRewards.ts rename to apps/evm/src/clients/api/queries/useGetPools/getPools/formatOutput/formatDistributions/isDistributingRewards/index.ts diff --git a/apps/evm/src/clients/api/queries/useGetPools/getPools/formatOutput/index.ts b/apps/evm/src/clients/api/queries/useGetPools/getPools/formatOutput/index.ts new file mode 100644 index 0000000000..47f1a8a6c4 --- /dev/null +++ b/apps/evm/src/clients/api/queries/useGetPools/getPools/formatOutput/index.ts @@ -0,0 +1,291 @@ +import { chainMetadata } from '@venusprotocol/chains'; +import BigNumber from 'bignumber.js'; + +import { NATIVE_TOKEN_ADDRESS } from 'constants/address'; +import { COMPOUND_DECIMALS } from 'constants/compoundMantissa'; +import type { PoolLens } from 'libs/contracts'; +import type { Asset, ChainId, Pool, Token, TokenBalance, VToken } from 'types'; +import { + areAddressesEqual, + areTokensEqual, + convertDollarsToCents, + convertFactorFromSmartContract, + convertMantissaToTokens, + convertPriceMantissaToDollars, + findTokenByAddress, + getDisabledTokenActions, + isPoolIsolated, +} from 'utilities'; +import type { MarketParticipantsCounts, PrimeApy } from '../../types'; +import type { ApiPool } from '../getApiPools'; +import { formatDistributions } from './formatDistributions'; + +export const formatOutput = ({ + apiPools, + chainId, + tokens, + currentBlockNumber, + isolatedPoolParticipantsCountMap, + userPrimeApyMap, + userVTokenBalances = [], + userTokenBalances = [], + userCollateralVTokenAddresses = [], + userVaiBorrowBalanceMantissa, +}: { + chainId: ChainId; + tokens: Token[]; + currentBlockNumber: number; + apiPools: ApiPool[]; + isolatedPoolParticipantsCountMap?: Map; + userPrimeApyMap?: Map; + userCollateralVTokenAddresses?: string[]; + userVTokenBalances?: Awaited>; + userTokenBalances?: TokenBalance[]; + userVaiBorrowBalanceMantissa?: BigNumber; +}) => { + const pools: Pool[] = apiPools.map(apiPool => { + const { blocksPerDay } = chainMetadata[chainId]; + + const isIsolated = isPoolIsolated({ + chainId, + comptrollerAddress: apiPool.address, + }); + + let poolUserBorrowBalanceCents = new BigNumber(0); + let poolUserSupplyBalanceCents = new BigNumber(0); + let poolUserBorrowLimitCents = new BigNumber(0); + + const assets = apiPool.markets.reduce((acc, market) => { + // Remove unlisted tokens + if (!market.isListed) { + return acc; + } + + // Retrieve underlying token record + const underlyingToken = findTokenByAddress({ + tokens, + address: market.underlyingAddress || NATIVE_TOKEN_ADDRESS, + }); + + if (!underlyingToken) { + return acc; + } + + const tokenPriceDollars = convertPriceMantissaToDollars({ + priceMantissa: market.underlyingPriceMantissa, + decimals: underlyingToken.decimals, + }); + + // Shape vToken + const vToken: VToken = { + address: market.address, + decimals: 8, + symbol: `v${underlyingToken.symbol}`, + underlyingToken, + }; + + const borrowCapTokens = convertMantissaToTokens({ + value: new BigNumber(market.borrowCapsMantissa), + token: vToken.underlyingToken, + }); + + const supplyCapTokens = convertMantissaToTokens({ + value: new BigNumber(market.supplyCapsMantissa), + token: vToken.underlyingToken, + }); + + const reserveFactor = convertFactorFromSmartContract({ + factor: new BigNumber(market.reserveFactorMantissa), + }); + + const collateralFactor = convertFactorFromSmartContract({ + factor: new BigNumber(market.collateralFactorMantissa), + }); + + const cashTokens = convertMantissaToTokens({ + value: new BigNumber(market.cashMantissa), + token: vToken.underlyingToken, + }); + + const tokenPriceCents = convertDollarsToCents(tokenPriceDollars); + const liquidityCents = cashTokens.multipliedBy(tokenPriceCents); + + const reserveTokens = convertMantissaToTokens({ + value: new BigNumber(market.totalReservesMantissa), + token: vToken.underlyingToken, + }); + + const exchangeRateVTokens = new BigNumber(1).div( + new BigNumber(market.exchangeRateMantissa).div( + 10 ** (COMPOUND_DECIMALS + vToken.underlyingToken.decimals - vToken.decimals), + ), + ); + + const supplyBalanceVTokens = convertMantissaToTokens({ + value: new BigNumber(market.totalSupplyMantissa), + token: vToken, + }); + const supplyBalanceTokens = supplyBalanceVTokens.div(exchangeRateVTokens); + const supplyBalanceCents = supplyBalanceTokens.multipliedBy(tokenPriceCents); + + const borrowBalanceTokens = convertMantissaToTokens({ + value: new BigNumber(market.totalBorrowsMantissa), + token: vToken.underlyingToken, + }); + + const borrowBalanceCents = borrowBalanceTokens.multipliedBy(tokenPriceCents); + + const { supplyDistributions, borrowDistributions } = formatDistributions({ + blocksPerDay, + underlyingToken: vToken.underlyingToken, + underlyingTokenPriceDollars: tokenPriceDollars, + primeApy: userPrimeApyMap?.get(vToken.address), + tokens, + supplyBalanceTokens, + borrowBalanceTokens, + currentBlockNumber, + apiRewardsDistributors: market.rewardsDistributors, + }); + + const disabledTokenActions = getDisabledTokenActions({ + bitmask: market.pausedActionsBitmap, + tokenAddresses: [vToken.address, vToken.underlyingToken.address], + chainId, + }); + + // User-specific props + const userVTokenBalance = userVTokenBalances.find(tokenBalance => + areAddressesEqual(tokenBalance.vToken, vToken.address), + ); + + const userBorrowBalanceTokens = userVTokenBalance + ? convertMantissaToTokens({ + value: new BigNumber(userVTokenBalance.borrowBalanceCurrent.toString()), + token: vToken.underlyingToken, + }) + : new BigNumber(0); + + const userSupplyBalanceTokens = userVTokenBalance + ? convertMantissaToTokens({ + value: new BigNumber(userVTokenBalance.balanceOfUnderlying.toString()), + token: vToken.underlyingToken, + }) + : new BigNumber(0); + + const userTokenBalance = userTokenBalances.find(tokenBalance => + areTokensEqual(tokenBalance.token, vToken.underlyingToken), + ); + + const userWalletBalanceTokens = userTokenBalance + ? convertMantissaToTokens({ + value: userTokenBalance.balanceMantissa, + token: userTokenBalance.token, + }) + : new BigNumber(0); + + const userSupplyBalanceCents = userSupplyBalanceTokens.multipliedBy(tokenPriceCents); + const userBorrowBalanceCents = userBorrowBalanceTokens.multipliedBy(tokenPriceCents); + const userWalletBalanceCents = userWalletBalanceTokens.multipliedBy(tokenPriceCents); + + const isCollateralOfUser = !!userCollateralVTokenAddresses.some(address => + areAddressesEqual(address, vToken.address), + ); + + poolUserBorrowBalanceCents = poolUserBorrowBalanceCents.plus(userBorrowBalanceCents); + poolUserSupplyBalanceCents = poolUserSupplyBalanceCents.plus(userSupplyBalanceCents); + + if (isCollateralOfUser) { + poolUserBorrowLimitCents = (poolUserBorrowLimitCents || new BigNumber(0)).plus( + userSupplyBalanceCents.times(collateralFactor), + ); + } + + const supplierCount = isIsolated + ? isolatedPoolParticipantsCountMap?.get(vToken.address.toLowerCase())?.supplierCount ?? 0 + : market.supplierCount; + + const borrowerCount = isIsolated + ? isolatedPoolParticipantsCountMap?.get(vToken.address.toLowerCase())?.borrowerCount ?? 0 + : market.borrowerCount; + + const asset: Asset = { + vToken, + disabledTokenActions, + tokenPriceCents, + reserveFactor, + collateralFactor, + cashTokens, + liquidityCents, + reserveTokens, + exchangeRateVTokens, + supplierCount, + borrowerCount, + borrowApyPercentage: new BigNumber(market.borrowApy), + supplyApyPercentage: new BigNumber(market.supplyApy), + supplyBalanceTokens, + supplyBalanceCents, + borrowBalanceTokens, + borrowBalanceCents, + borrowCapTokens, + supplyCapTokens, + supplyDistributions, + borrowDistributions, + userSupplyBalanceTokens, + userSupplyBalanceCents, + userBorrowBalanceTokens, + userBorrowBalanceCents, + userWalletBalanceTokens, + userWalletBalanceCents, + // This will be calculated after all assets have been formatted + userPercentOfLimit: 0, + isCollateralOfUser, + }; + + return [...acc, asset]; + }, []); + + // Add user VAI loan to user borrow balance (only applies to legacy pool) + const vai = tokens.find(token => token.symbol === 'VAI'); + if (!isIsolated && vai && userVaiBorrowBalanceMantissa) { + const userVaiBorrowBalanceCents = convertMantissaToTokens({ + value: userVaiBorrowBalanceMantissa, + token: vai, + }) + // Convert VAI to dollar cents (we assume 1 VAI = 1 dollar) + .times(100); + + poolUserBorrowBalanceCents = poolUserBorrowBalanceCents.plus(userVaiBorrowBalanceCents); + } + + const pool: Pool = { + comptrollerAddress: apiPool.address, + name: apiPool.name, + isIsolated, + assets, + userBorrowBalanceCents: poolUserBorrowBalanceCents, + userSupplyBalanceCents: poolUserSupplyBalanceCents, + userBorrowLimitCents: poolUserBorrowLimitCents, + }; + + // Calculate userPercentOfLimit for each asset + const formattedAssets: Asset[] = assets.map(asset => ({ + ...asset, + userPercentOfLimit: + asset.userBorrowBalanceCents?.isGreaterThan(0) && + pool.userBorrowLimitCents?.isGreaterThan(0) + ? new BigNumber(asset.userBorrowBalanceCents) + .times(100) + .div(pool.userBorrowLimitCents) + .dp(2) + .toNumber() + : 0, + })); + + return { + ...pool, + assets: formattedAssets, + }; + }); + + return pools; +}; diff --git a/apps/evm/src/clients/api/queries/getApiMarkets/index.ts b/apps/evm/src/clients/api/queries/useGetPools/getPools/getApiPools/index.ts similarity index 54% rename from apps/evm/src/clients/api/queries/getApiMarkets/index.ts rename to apps/evm/src/clients/api/queries/useGetPools/getPools/getApiPools/index.ts index 5df368a6ce..1cb67ab912 100644 --- a/apps/evm/src/clients/api/queries/getApiMarkets/index.ts +++ b/apps/evm/src/clients/api/queries/useGetPools/getPools/getApiPools/index.ts @@ -1,7 +1,19 @@ -import type { ChainId, Market } from 'types'; -import { formatToMarket, restService } from 'utilities'; +import { VError } from 'libs/errors'; +import type { ChainId } from 'types'; +import { restService } from 'utilities/restService'; -export interface ApiMarketData { +export interface ApiRewardDistributor { + marketAddress: string; + rewardTokenAddress: string; + lastRewardingSupplyBlockOrTimestamp: string; + lastRewardingBorrowBlockOrTimestamp: string; + supplySpeed: string; + borrowSpeed: string; + priceMantissa: string; + rewardsDistributorContractAddress: string | null; +} + +export interface ApiMarket { address: string; symbol: string; name: string; @@ -40,56 +52,56 @@ export interface ApiMarketData { pausedActionsBitmap: number; isListed: boolean; poolComptrollerAddress: string; - rewardsDistributors: { - marketAddress: string; - rewardTokenAddress: string; - lastRewardingSupplyBlockOrTimestamp: string; - lastRewardingBorrowBlockOrTimestamp: string; - supplySpeed: string; - borrowSpeed: string; - priceMantissa: string; - rewardsDistributorContractAddress: string | null; - }[]; + rewardsDistributors: ApiRewardDistributor[]; } -export interface GetApiMarketsResponse { - result: ApiMarketData[]; - request: { addresses: string[] }; -} - -export interface GetApiMarketsInput { - chainId: ChainId; - poolComptrollerAddress?: string; +export interface ApiPool { + address: string; + name: string; + markets: ApiMarket[]; } -export interface GetApiMarketsOutput { - markets: Market[]; +export interface GetApiPoolsResponse { + result: ApiPool[]; + request: { addresses: string[] }; } -const getApiMarkets = async ({ +export const getApiPools = async ({ chainId, - poolComptrollerAddress, -}: GetApiMarketsInput): Promise => { - const response = await restService({ - endpoint: '/markets', +}: { + chainId: ChainId; +}) => { + const response = await restService({ + endpoint: '/pools', method: 'GET', params: { - limit: 50, - isListed: 1, chainId, - poolComptrollerAddress, }, }); const payload = response.data; - if (payload && 'error' in payload) { - throw new Error(payload.error); + if (!payload) { + throw new VError({ + type: 'unexpected', + code: 'somethingWentWrong', + data: { + message: 'Could not fetch pools from API', + }, + }); } - const markets: Market[] = (payload?.result || []).map(apiMarket => formatToMarket({ apiMarket })); + if (payload && 'error' in payload) { + throw new VError({ + type: 'unexpected', + code: 'somethingWentWrong', + data: { + message: payload.error, + }, + }); + } - return { markets }; + return { + pools: payload?.result || [], + }; }; - -export default getApiMarkets; diff --git a/apps/evm/src/clients/api/queries/useGetPools/getPools/getIsolatedPoolParticipantCounts/index.ts b/apps/evm/src/clients/api/queries/useGetPools/getPools/getIsolatedPoolParticipantCounts/index.ts new file mode 100644 index 0000000000..859b899fa3 --- /dev/null +++ b/apps/evm/src/clients/api/queries/useGetPools/getPools/getIsolatedPoolParticipantCounts/index.ts @@ -0,0 +1,19 @@ +import { getIsolatedPoolParticipantsCount } from 'clients/subgraph'; +import type { ChainId } from 'types'; +import type { MarketParticipantsCounts } from '../../types'; + +export const getIsolatedPoolParticipantCounts = async ({ chainId }: { chainId: ChainId }) => { + const isolatedPoolParticipantsCount = await getIsolatedPoolParticipantsCount({ chainId }); + + const isolatedPoolParticipantsCountMap = new Map(); + (isolatedPoolParticipantsCount?.pools || []).forEach(pool => + pool.markets.forEach(market => { + isolatedPoolParticipantsCountMap.set(market.id.toLowerCase(), { + borrowerCount: +market.borrowerCount, + supplierCount: +market.supplierCount, + }); + }), + ); + + return { isolatedPoolParticipantsCountMap }; +}; diff --git a/apps/evm/src/clients/api/queries/useGetPools/getPools/getUserCollateralAddresses/index.ts b/apps/evm/src/clients/api/queries/useGetPools/getPools/getUserCollateralAddresses/index.ts new file mode 100644 index 0000000000..1856002e34 --- /dev/null +++ b/apps/evm/src/clients/api/queries/useGetPools/getPools/getUserCollateralAddresses/index.ts @@ -0,0 +1,53 @@ +import { + type IsolatedPoolComptroller, + type LegacyPoolComptroller, + getIsolatedPoolComptrollerContract, +} from 'libs/contracts'; +import type { Provider } from 'libs/wallet'; +import type { ChainId } from 'types'; +import { isPoolIsolated } from 'utilities'; +import type { ApiPool } from '../getApiPools'; + +export const getUserCollateralAddresses = async ({ + accountAddress, + apiPools, + chainId, + provider, + legacyPoolComptrollerContract, +}: { + accountAddress: string; + apiPools: ApiPool[]; + chainId: ChainId; + provider: Provider; + legacyPoolComptrollerContract?: LegacyPoolComptroller; +}) => { + const getAssetsInPromises: ReturnType[] = []; + + apiPools.forEach(pool => { + const isIsolated = isPoolIsolated({ + chainId, + comptrollerAddress: pool.address, + }); + + if (!isIsolated) { + return; + } + + const comptrollerContract = getIsolatedPoolComptrollerContract({ + signerOrProvider: provider, + address: pool.address, + }); + + if (accountAddress) { + getAssetsInPromises.push(comptrollerContract.getAssetsIn(accountAddress)); + } + }); + + if (accountAddress && legacyPoolComptrollerContract) { + getAssetsInPromises.push(legacyPoolComptrollerContract.getAssetsIn(accountAddress)); + } + + const results = await Promise.all(getAssetsInPromises); + + return { userCollateralAddresses: results.flat() }; +}; diff --git a/apps/evm/src/clients/api/queries/useGetPools/getPools/getUserPrimeApys/index.ts b/apps/evm/src/clients/api/queries/useGetPools/getPools/getUserPrimeApys/index.ts new file mode 100644 index 0000000000..5d4d31bfd5 --- /dev/null +++ b/apps/evm/src/clients/api/queries/useGetPools/getPools/getUserPrimeApys/index.ts @@ -0,0 +1,27 @@ +import type { Prime } from 'libs/contracts'; +import { convertAprBipsToApy } from 'utilities'; +import type { PrimeApy } from '../../types'; + +export const getUserPrimeApys = async ({ + primeContract, + accountAddress, + primeVTokenAddresses, +}: { primeContract: Prime; accountAddress: string; primeVTokenAddresses: string[] }) => { + const primeAprs = await Promise.all( + primeVTokenAddresses.map(primeVTokenAddress => + primeContract.calculateAPR(primeVTokenAddress, accountAddress), + ), + ); + + const userPrimeApyMap = new Map(); + primeAprs.forEach((primeApr, index) => { + const apys: PrimeApy = { + borrowApy: convertAprBipsToApy({ aprBips: primeApr.borrowAPR.toString() || '0' }), + supplyApy: convertAprBipsToApy({ aprBips: primeApr.supplyAPR.toString() || '0' }), + }; + + userPrimeApyMap.set(primeVTokenAddresses[index], apys); + }); + + return { userPrimeApyMap }; +}; diff --git a/apps/evm/src/clients/api/queries/useGetPools/getPools/getUserTokenBalances/index.ts b/apps/evm/src/clients/api/queries/useGetPools/getPools/getUserTokenBalances/index.ts new file mode 100644 index 0000000000..8ee608f199 --- /dev/null +++ b/apps/evm/src/clients/api/queries/useGetPools/getPools/getUserTokenBalances/index.ts @@ -0,0 +1,89 @@ +import { getTokenBalances } from 'clients/api'; +import { NATIVE_TOKEN_ADDRESS } from 'constants/address'; +import type { PoolLens, VenusLens } from 'libs/contracts'; +import type { Provider } from 'libs/wallet'; +import type { ChainId, Token } from 'types'; +import { findTokenByAddress, isPoolIsolated } from 'utilities'; +import type { ApiPool } from '../getApiPools'; + +export const getUserTokenBalances = async ({ + accountAddress, + apiPools, + chainId, + tokens, + provider, + poolLensContract, + venusLensContract, +}: { + accountAddress: string; + apiPools: ApiPool[]; + chainId: ChainId; + tokens: Token[]; + provider: Provider; + poolLensContract: PoolLens; + venusLensContract?: VenusLens; +}) => { + // Extract token records and addresses + const [legacyPoolVTokenAddresses, isolatedPoolsVTokenAddresses, underlyingTokens] = + apiPools.reduce<[string[], string[], Token[]]>( + (acc, pool) => { + const newLegacyPoolVTokenAddresses: string[] = []; + const newIsolatedPoolsVTokenAddresses: string[] = []; + const newUnderlyingTokens: Token[] = []; + const newUnderlyingTokenAddresses: string[] = []; + + pool.markets.forEach(market => { + const isIsolated = isPoolIsolated({ + chainId, + comptrollerAddress: pool.address, + }); + + // VToken addresses are unique + if (isIsolated) { + newIsolatedPoolsVTokenAddresses.push(market.address.toLowerCase()); + } else { + newLegacyPoolVTokenAddresses.push(market.address.toLowerCase()); + } + + const underlyingToken = findTokenByAddress({ + address: market.underlyingAddress || NATIVE_TOKEN_ADDRESS, + tokens, + }); + + if ( + underlyingToken && + !newUnderlyingTokenAddresses.includes(underlyingToken.address.toLowerCase()) + ) { + newUnderlyingTokens.push(underlyingToken); + newUnderlyingTokenAddresses.push(underlyingToken.address.toLowerCase()); + } + }); + + return [ + acc[0].concat(newLegacyPoolVTokenAddresses), + acc[1].concat(newIsolatedPoolsVTokenAddresses), + acc[2].concat(newUnderlyingTokens), + ]; + }, + [[], [], []], + ); + + const [userTokenBalances, userIsolatedPoolVTokenBalances, userLegacyPoolVTokenBalances] = + await Promise.all([ + getTokenBalances({ + accountAddress, + tokens: underlyingTokens, + provider, + }), + poolLensContract.callStatic.vTokenBalancesAll(isolatedPoolsVTokenAddresses, accountAddress), + venusLensContract + ? venusLensContract.callStatic.vTokenBalancesAll(legacyPoolVTokenAddresses, accountAddress) + : undefined, + ]); + + return { + userTokenBalances, + userIsolatedPoolVTokenBalances, + userLegacyPoolVTokenBalances, + }; +}; diff --git a/apps/evm/src/clients/api/queries/useGetPools/getPools/getUserVaiBorrowBalance/index.ts b/apps/evm/src/clients/api/queries/useGetPools/getPools/getUserVaiBorrowBalance/index.ts new file mode 100644 index 0000000000..4f04e59c43 --- /dev/null +++ b/apps/evm/src/clients/api/queries/useGetPools/getPools/getUserVaiBorrowBalance/index.ts @@ -0,0 +1,21 @@ +import BigNumber from 'bignumber.js'; +import type { VaiController } from 'libs/contracts'; + +export const getUserVaiBorrowBalance = async ({ + accountAddress, + vaiControllerContract, +}: { accountAddress: string; vaiControllerContract?: VaiController }) => { + const [_accrueVaiInterest, vaiRepayAmountMantissa] = await Promise.all([ + // Call (statically) accrueVAIInterest to calculate past accrued interests before fetching all + // interests. Since multicall will batch these requests, the call to accrueVAIInterest and + // getVAIRepayAmount will happen in the same request (thus making the accrual possible) + vaiControllerContract ? vaiControllerContract.callStatic.accrueVAIInterest() : undefined, + vaiControllerContract ? vaiControllerContract.getVAIRepayAmount(accountAddress) : undefined, + ]); + + const userVaiBorrowBalanceMantissa = vaiRepayAmountMantissa + ? new BigNumber(vaiRepayAmountMantissa.toString()) + : undefined; + + return { userVaiBorrowBalanceMantissa }; +}; diff --git a/apps/evm/src/clients/api/queries/useGetPools/getPools/index.ts b/apps/evm/src/clients/api/queries/useGetPools/getPools/index.ts new file mode 100644 index 0000000000..bfcdffc84a --- /dev/null +++ b/apps/evm/src/clients/api/queries/useGetPools/getPools/index.ts @@ -0,0 +1,150 @@ +import BigNumber from 'bignumber.js'; + +import { getBlockNumber } from 'clients/api'; +import type { GetIsolatedPoolParticipantsCountInput } from 'clients/subgraph'; +import type { PoolLens } from 'libs/contracts'; +import type { Asset, TokenBalance } from 'types'; + +import { logError } from 'libs/errors'; +import type { GetPoolsInput, GetPoolsOutput, PrimeApy } from '../types'; +import { appendPrimeSimulationDistributions } from './appendPrimeSimulationDistributions'; +import { formatOutput } from './formatOutput'; +import { getApiPools } from './getApiPools'; +import { getIsolatedPoolParticipantCounts } from './getIsolatedPoolParticipantCounts'; +import { getUserCollateralAddresses } from './getUserCollateralAddresses'; +import { getUserPrimeApys } from './getUserPrimeApys'; +import { getUserTokenBalances } from './getUserTokenBalances'; +import { getUserVaiBorrowBalance } from './getUserVaiBorrowBalance'; + +const safeGetIsolatedPoolParticipantCount = async ( + input: GetIsolatedPoolParticipantsCountInput, +) => { + try { + const result = await getIsolatedPoolParticipantCounts(input); + return result; + } catch (error) { + // Log error without throwing to prevent the entire query from failing, since this relies on a + // third-party service that could be down and doesn't constitute a critical failure + logError(error); + } +}; + +export const getPools = async ({ + chainId, + accountAddress, + primeContract, + poolLensContract, + legacyPoolComptrollerContract, + vaiControllerContract, + venusLensContract, + provider, + tokens, +}: GetPoolsInput) => { + const [ + { pools: apiPools }, + isolatedPoolParticipantCounts, + { blockNumber: currentBlockNumber }, + unsafePrimeVTokenAddresses, + primeMinimumXvsToStakeMantissa, + userPrimeToken, + ] = await Promise.all([ + getApiPools({ chainId }), + safeGetIsolatedPoolParticipantCount({ chainId }), + // Fetch current block number + getBlockNumber({ provider }), + // Prime related calls + primeContract?.getAllMarkets(), // TODO: get from API + primeContract?.MINIMUM_STAKED_XVS(), // TODO: get from API + accountAddress ? primeContract?.tokens(accountAddress) : undefined, + ]); + + const primeVTokenAddresses = unsafePrimeVTokenAddresses ?? []; + const isUserPrime = userPrimeToken?.exists || false; + + let userCollateralVTokenAddresses: string[] | undefined; + let userVTokenBalances: + | Awaited> + | undefined; + let userTokenBalances: TokenBalance[] | undefined; + let userVaiBorrowBalanceMantissa: BigNumber | undefined; + let userPrimeApyMap: Map | undefined; + + if (accountAddress) { + const [userCollaterals, userBalances, userVaiBorrowBalance, userPrimeApys] = await Promise.all([ + getUserCollateralAddresses({ + chainId, + accountAddress, + legacyPoolComptrollerContract, + apiPools, + provider, + }), + getUserTokenBalances({ + accountAddress, + apiPools, + chainId, + tokens, + provider, + poolLensContract, + venusLensContract, + }), + getUserVaiBorrowBalance({ + accountAddress, + vaiControllerContract, + }), + isUserPrime && primeContract + ? getUserPrimeApys({ + accountAddress, + primeContract, + primeVTokenAddresses, + }) + : undefined, + ]); + + userCollateralVTokenAddresses = userCollaterals.userCollateralAddresses; + + userVTokenBalances = [ + ...(userBalances.userIsolatedPoolVTokenBalances || []), + ...(userBalances.userLegacyPoolVTokenBalances || []), + ]; + + userTokenBalances = userBalances.userTokenBalances?.tokenBalances; + + userVaiBorrowBalanceMantissa = userVaiBorrowBalance.userVaiBorrowBalanceMantissa; + + userPrimeApyMap = userPrimeApys?.userPrimeApyMap; + } + + const pools = formatOutput({ + chainId, + tokens, + currentBlockNumber, + apiPools, + isolatedPoolParticipantsCountMap: + isolatedPoolParticipantCounts?.isolatedPoolParticipantsCountMap, + userPrimeApyMap, + userCollateralVTokenAddresses, + userVTokenBalances, + userTokenBalances, + userVaiBorrowBalanceMantissa, + }); + + // Add Prime simulations + // TODO: get Prime simulations from API + const xvs = tokens.find(token => token.symbol === 'XVS'); + if (primeContract && primeMinimumXvsToStakeMantissa && xvs) { + await appendPrimeSimulationDistributions({ + assets: pools.reduce((acc, pool) => acc.concat(pool.assets), []), + primeContract, + primeVTokenAddresses, + primeMinimumXvsToStakeMantissa: new BigNumber(primeMinimumXvsToStakeMantissa.toString()), + xvs, + chainId, + }); + } + + const output: GetPoolsOutput = { + pools, + }; + + return output; +}; diff --git a/apps/evm/src/clients/api/queries/useGetPools/index.spec.tsx b/apps/evm/src/clients/api/queries/useGetPools/index.spec.tsx deleted file mode 100644 index 8b9e97b4da..0000000000 --- a/apps/evm/src/clients/api/queries/useGetPools/index.spec.tsx +++ /dev/null @@ -1,35 +0,0 @@ -import { waitFor } from '@testing-library/react'; -import type Vi from 'vitest'; - -import fakeAddress from '__mocks__/models/address'; -import { poolData } from '__mocks__/models/pools'; -import { renderComponent } from 'testUtils/render'; - -import { useGetLegacyPool } from 'clients/api'; - -import useGetPools, { type UseGetPoolsOutput } from '.'; - -describe('api/queries/useGetPools', () => { - beforeEach(() => { - (useGetLegacyPool as Vi.Mock).mockImplementation(() => ({ - data: { - pool: poolData[0], - }, - isLoading: false, - })); - }); - - it('returns data in the correct format', async () => { - let data: Partial = {}; - - const CallMarketContext = () => { - ({ data } = useGetPools({ accountAddress: fakeAddress })); - return
; - }; - - renderComponent(); - - await waitFor(() => expect(!!data).toBe(true)); - expect(data).toMatchSnapshot(); - }); -}); diff --git a/apps/evm/src/clients/api/queries/useGetPools/index.ts b/apps/evm/src/clients/api/queries/useGetPools/index.ts new file mode 100644 index 0000000000..ea53045ed9 --- /dev/null +++ b/apps/evm/src/clients/api/queries/useGetPools/index.ts @@ -0,0 +1,82 @@ +import { type QueryObserverOptions, useQuery } from '@tanstack/react-query'; + +import FunctionKey from 'constants/functionKey'; +import { useIsFeatureEnabled } from 'hooks/useIsFeatureEnabled'; +import { + useGetLegacyPoolComptrollerContract, + useGetPoolLensContract, + useGetPrimeContract, + useGetVaiControllerContract, + useGetVenusLensContract, +} from 'libs/contracts'; +import { useGetTokens } from 'libs/tokens'; +import { useChainId, useProvider } from 'libs/wallet'; +import type { ChainId } from 'types'; +import { callOrThrow, generatePseudoRandomRefetchInterval } from 'utilities'; + +import { getPools } from './getPools'; +import type { GetPoolsInput, GetPoolsOutput } from './types'; + +type TrimmedInput = Omit< + GetPoolsInput, + 'chainId' | 'xvs' | 'tokens' | 'provider' | 'primeContract' | 'poolLensContract' | 'blocksPerDay' +>; + +export type UseGetPoolsQueryKey = [ + FunctionKey.GET_POOLS, + TrimmedInput & { + chainId: ChainId; + }, +]; + +type Options = QueryObserverOptions< + GetPoolsOutput, + Error, + GetPoolsOutput, + GetPoolsOutput, + UseGetPoolsQueryKey +>; + +const refetchInterval = generatePseudoRandomRefetchInterval(); + +export const useGetPools = (input?: TrimmedInput, options?: Options) => { + const isPrimeEnabled = useIsFeatureEnabled({ + name: 'prime', + }); + + const accountAddress = input?.accountAddress; + const { provider } = useProvider(); + const { chainId } = useChainId(); + const tokens = useGetTokens(); + + const primeContract = useGetPrimeContract(); + const poolLensContract = useGetPoolLensContract(); + const legacyPoolComptrollerContract = useGetLegacyPoolComptrollerContract(); + const venusLensContract = useGetVenusLensContract(); + const vaiControllerContract = useGetVaiControllerContract(); + + return useQuery({ + queryKey: [FunctionKey.GET_POOLS, { ...input, chainId, accountAddress }], + queryFn: () => + callOrThrow({ poolLensContract }, params => + getPools({ + chainId, + provider, + tokens, + legacyPoolComptrollerContract, + venusLensContract, + vaiControllerContract, + primeContract: isPrimeEnabled ? primeContract : undefined, + ...params, + ...input, + }), + ), + placeholderData: (previousOutput, previousInput) => { + // Return previous data if chain ID param hasn't changed + const previousChainId = previousInput?.queryKey[1]?.chainId; + return previousChainId === chainId ? previousOutput : undefined; + }, + refetchInterval, + ...options, + }); +}; diff --git a/apps/evm/src/clients/api/queries/useGetPools/index.tsx b/apps/evm/src/clients/api/queries/useGetPools/index.tsx deleted file mode 100644 index 74debf652b..0000000000 --- a/apps/evm/src/clients/api/queries/useGetPools/index.tsx +++ /dev/null @@ -1,46 +0,0 @@ -import { useMemo } from 'react'; - -import { useGetIsolatedPools, useGetLegacyPool } from 'clients/api'; -import type { Pool } from 'types'; - -export interface UseGetPoolsInput { - accountAddress?: string; -} - -export interface UseGetPoolsOutput { - isLoading: boolean; - data?: { - pools: Pool[]; - }; -} - -const useGetPools = ({ accountAddress }: UseGetPoolsInput): UseGetPoolsOutput => { - const { data: getLegacyPoolData, isLoading: isGetLegacyPoolDataLoading } = useGetLegacyPool({ - accountAddress, - }); - - const { data: getIsolatedPoolsData, isLoading: isGetIsolatedPoolsDataLoading } = - useGetIsolatedPools({ - accountAddress, - }); - - const isLoading = isGetLegacyPoolDataLoading || isGetIsolatedPoolsDataLoading; - - const data = useMemo(() => { - if (isLoading) { - return undefined; - } - - const pools = (getLegacyPoolData?.pool ? [getLegacyPoolData?.pool] : []).concat( - getIsolatedPoolsData?.pools || [], - ); - - return { - pools, - }; - }, [getLegacyPoolData?.pool, getIsolatedPoolsData?.pools, isLoading]); - - return { isLoading, data }; -}; - -export default useGetPools; diff --git a/apps/evm/src/clients/api/queries/useGetPools/types.ts b/apps/evm/src/clients/api/queries/useGetPools/types.ts new file mode 100644 index 0000000000..5c093e4c1c --- /dev/null +++ b/apps/evm/src/clients/api/queries/useGetPools/types.ts @@ -0,0 +1,35 @@ +import type BigNumber from 'bignumber.js'; +import type { + LegacyPoolComptroller, + PoolLens, + Prime, + VaiController, + VenusLens, +} from 'libs/contracts'; +import type { Provider } from 'libs/wallet'; +import type { ChainId, Pool, Token } from 'types'; + +export interface MarketParticipantsCounts { + borrowerCount: number; + supplierCount: number; +} + +export interface PrimeApy { + borrowApy: BigNumber; + supplyApy: BigNumber; +} +export interface GetPoolsInput { + chainId: ChainId; + tokens: Token[]; + provider: Provider; + poolLensContract: PoolLens; + legacyPoolComptrollerContract?: LegacyPoolComptroller; + venusLensContract?: VenusLens; + vaiControllerContract?: VaiController; + accountAddress?: string; + primeContract?: Prime; +} + +export interface GetPoolsOutput { + pools: Pool[]; +} diff --git a/apps/evm/src/config/subgraphUrls.ts b/apps/evm/src/config/subgraphUrls.ts index 7fef79c943..f163a655f4 100644 --- a/apps/evm/src/config/subgraphUrls.ts +++ b/apps/evm/src/config/subgraphUrls.ts @@ -12,7 +12,7 @@ export const getIsolatedPoolsSubgraphUrls = ({ } = { [ChainId.BSC_MAINNET]: `https://gateway-arbitrum.network.thegraph.com/api/${theGraphApiKey}/deployments/id/QmVMKvBgAgnqVrLmRUurMiziH3Q55Fa5VoYJXN4TVLZgsw`, [ChainId.BSC_TESTNET]: - 'https://api.studio.thegraph.com/query/77761/venus-isolated-pools-chapel/version/latest', + 'https://api.studio.thegraph.com/query/64786/venus-isolated-pools-chapel/version/latest', [ChainId.OPBNB_MAINNET]: `https://open-platform-ap.nodereal.io/${nodeRealApiKey}/opbnb-mainnet-graph-query/subgraphs/name/venusprotocol/venus-isolated-pools-opbnb`, [ChainId.OPBNB_TESTNET]: undefined, [ChainId.ETHEREUM]: `https://gateway-arbitrum.network.thegraph.com/api/${theGraphApiKey}/deployments/id/Qmazi4kSKzahgR5G6U7FVUoUGLQZQVPohRX6zbuxbC8YX1`, diff --git a/apps/evm/src/constants/functionKey.ts b/apps/evm/src/constants/functionKey.ts index 5fede7f061..372dd6cc3c 100644 --- a/apps/evm/src/constants/functionKey.ts +++ b/apps/evm/src/constants/functionKey.ts @@ -71,7 +71,6 @@ enum FunctionKey { GET_ISOLATED_POOL_V_TOKEN_LIQUIDATION_THRESHOLD = 'GET_ISOLATED_POOL_V_TOKEN_LIQUIDATION_THRESHOLD', GET_ARE_ISOLATED_POOLS_TIME_BASED = 'GET_ARE_ISOLATED_POOLS_TIME_BASED', GET_PAYMASTER_INFO = 'GET_PAYMASTER_INFO', - GET_MARKETS = 'GET_MARKETS', GET_POOLS = 'GET_POOLS', GET_ADDRESS_DOMAIN_NAME = 'GET_ADDRESS_DOMAIN_NAME', diff --git a/apps/evm/src/containers/AssetAccessor/index.tsx b/apps/evm/src/containers/AssetAccessor/index.tsx index 22294b261e..809fe21382 100644 --- a/apps/evm/src/containers/AssetAccessor/index.tsx +++ b/apps/evm/src/containers/AssetAccessor/index.tsx @@ -21,11 +21,11 @@ const AssetAccessor: React.FC = ({ }) => { const { accountAddress } = useAccountAddress(); - const { data: getPoolData } = useGetPool({ + const { data: getPools } = useGetPool({ poolComptrollerAddress, accountAddress, }); - const pool = getPoolData?.pool; + const pool = getPools?.pool; const asset = pool?.assets.find(item => areTokensEqual(item.vToken, vToken)); if (!pool || !asset) { diff --git a/apps/evm/src/containers/Layout/ClaimRewardButton/__testUtils__/fakeData.ts b/apps/evm/src/containers/Layout/ClaimRewardButton/__testUtils__/fakeData.ts index 1b36e91817..6d634be6a1 100644 --- a/apps/evm/src/containers/Layout/ClaimRewardButton/__testUtils__/fakeData.ts +++ b/apps/evm/src/containers/Layout/ClaimRewardButton/__testUtils__/fakeData.ts @@ -1,6 +1,6 @@ import { BigNumber } from 'bignumber.js'; -import { apiPoolsData } from '__mocks__/models/pools'; +import { poolData } from '__mocks__/models/pools'; import { vai, xvs } from '__mocks__/models/tokens'; import type { PendingRewardGroup } from 'clients/api/queries/getPendingRewards/types'; @@ -8,7 +8,7 @@ import type { PendingRewardGroup } from 'clients/api/queries/getPendingRewards/t export const fakePendingRewardGroups: PendingRewardGroup[] = [ { type: 'legacyPool', - comptrollerAddress: apiPoolsData[0].address, + comptrollerAddress: poolData[0].comptrollerAddress, rewardToken: xvs, rewardAmountMantissa: new BigNumber('1000000000000000000000000000'), rewardAmountCents: new BigNumber('40000000'), @@ -20,7 +20,7 @@ export const fakePendingRewardGroups: PendingRewardGroup[] = [ }, { type: 'isolatedPool', - comptrollerAddress: apiPoolsData[1].address, + comptrollerAddress: poolData[1].comptrollerAddress, pendingRewards: [ { rewardToken: vai, diff --git a/apps/evm/src/containers/Layout/ClaimRewardButton/__tests__/__snapshots__/index.spec.tsx.snap b/apps/evm/src/containers/Layout/ClaimRewardButton/__tests__/__snapshots__/index.spec.tsx.snap index 134e8d249b..a02165c507 100644 --- a/apps/evm/src/containers/Layout/ClaimRewardButton/__tests__/__snapshots__/index.spec.tsx.snap +++ b/apps/evm/src/containers/Layout/ClaimRewardButton/__tests__/__snapshots__/index.spec.tsx.snap @@ -5,7 +5,28 @@ exports[`ClaimRewardButton > it claims only selected and enabled rewards on subm "accountAddress": "0x3d759121234cd36F8124C21aFe1c6852d2bEd848", "claims": [ { - "contract": "vaiVault", + "comptrollerContractAddress": "0x10b57706ad2345e590c2ea4dc02faef0d9f5b08b", + "contract": "rewardsDistributor", + "contractAddress": "0xa14c236372228b6e8182748f3ebbfb4bfeea3574", + "vTokenAddressesWithPendingReward": [ + "0xcfc8a73f9c888eea9af9ccca24646e84a915510b", + "0x12d3a3aa7f4917ea3b8ee34f99a9a7eec521fa61", + ], + }, + { + "comptrollerContractAddress": "0x10b57706ad2345e590c2ea4dc02faef0d9f5b08b", + "contract": "rewardsDistributor", + "contractAddress": "0xadbed07126b7b70cbc5e07bf73599d55be571b9c", + "vTokenAddressesWithPendingReward": [ + "0xcfc8a73f9c888eea9af9ccca24646e84a915510b", + ], + }, + { + "contract": "prime", + "vTokenAddressesWithPendingReward": [ + "0xcfc8a73f9c888eea9af9ccca24646e84a915510b", + "0x12d3a3aa7f4917ea3b8ee34f99a9a7eec521fa61", + ], }, ], } @@ -23,6 +44,23 @@ exports[`ClaimRewardButton > it claims reward on submit button click and closes "0x08e0A5575De71037aE36AbfAfb516595fE68e5e4", ], }, + { + "comptrollerContractAddress": "0x10b57706ad2345e590c2ea4dc02faef0d9f5b08b", + "contract": "rewardsDistributor", + "contractAddress": "0xa14c236372228b6e8182748f3ebbfb4bfeea3574", + "vTokenAddressesWithPendingReward": [ + "0xcfc8a73f9c888eea9af9ccca24646e84a915510b", + "0x12d3a3aa7f4917ea3b8ee34f99a9a7eec521fa61", + ], + }, + { + "comptrollerContractAddress": "0x10b57706ad2345e590c2ea4dc02faef0d9f5b08b", + "contract": "rewardsDistributor", + "contractAddress": "0xadbed07126b7b70cbc5e07bf73599d55be571b9c", + "vTokenAddressesWithPendingReward": [ + "0xcfc8a73f9c888eea9af9ccca24646e84a915510b", + ], + }, { "contract": "vaiVault", }, @@ -47,4 +85,4 @@ exports[`ClaimRewardButton > it claims reward on submit button click and closes } `; -exports[`ClaimRewardButton > renders correct reward breakdown in modal 1`] = `"VenusXVS$400K1B XVSVAI vaultXVS$123B XVSXVS vesting vaultXVS$1.654B XVSPrimeVAI$32B VAIXVS$1.123B XVS"`; +exports[`ClaimRewardButton > renders correct reward breakdown in modal 1`] = `"VenusXVS$400K1B XVSMetaverseVAI$32B VAIXVS$1.123B XVSVAI vaultXVS$123B XVSXVS vesting vaultXVS$1.654B XVSPrimeVAI$32B VAIXVS$1.123B XVS"`; diff --git a/apps/evm/src/containers/Layout/Header/MarketInfo/index.tsx b/apps/evm/src/containers/Layout/Header/MarketInfo/index.tsx index 164fd89b0e..5b74114799 100644 --- a/apps/evm/src/containers/Layout/Header/MarketInfo/index.tsx +++ b/apps/evm/src/containers/Layout/Header/MarketInfo/index.tsx @@ -51,10 +51,10 @@ export const MarketInfo = () => { const { accountAddress } = useAccountAddress(); const isUserConnected = !!accountAddress; - const { data: getPoolData } = useGetPool({ + const { data: getPools } = useGetPool({ poolComptrollerAddress, }); - const pool = getPoolData?.pool; + const pool = getPools?.pool; const handleGoBack = () => window.history.back(); diff --git a/apps/evm/src/containers/Layout/Header/TopBar/Breadcrumbs/PoolName/index.tsx b/apps/evm/src/containers/Layout/Header/TopBar/Breadcrumbs/PoolName/index.tsx index 9a28986820..f0debc4a45 100644 --- a/apps/evm/src/containers/Layout/Header/TopBar/Breadcrumbs/PoolName/index.tsx +++ b/apps/evm/src/containers/Layout/Header/TopBar/Breadcrumbs/PoolName/index.tsx @@ -6,11 +6,11 @@ export interface PoolNameProps { } const PoolName: React.FC = ({ poolComptrollerAddress }) => { - const { data: getPoolData } = useGetPool({ + const { data: getPools } = useGetPool({ poolComptrollerAddress, }); - return <>{getPoolData?.pool?.name || PLACEHOLDER_KEY}; + return <>{getPools?.pool?.name || PLACEHOLDER_KEY}; }; export default PoolName; diff --git a/apps/evm/src/containers/MarketLoader/index.tsx b/apps/evm/src/containers/MarketLoader/index.tsx index 7bf2c9ae7b..61192140e9 100644 --- a/apps/evm/src/containers/MarketLoader/index.tsx +++ b/apps/evm/src/containers/MarketLoader/index.tsx @@ -30,11 +30,11 @@ export const MarketLoader: React.FC = ({ const asset = getAssetData?.asset; const isVTokenAddressInvalid = !isGetAssetLoading && !asset; - const { data: getPoolData } = useGetPool({ + const { data: getPools } = useGetPool({ poolComptrollerAddress: poolComptrollerAddress || '', accountAddress, }); - const pool = getPoolData?.pool; + const pool = getPools?.pool; // Redirect to dashboard page if params are invalid if (isVTokenAddressInvalid || !poolComptrollerAddress) { diff --git a/apps/evm/src/containers/PoolStats/__tests__/index.spec.tsx b/apps/evm/src/containers/PoolStats/__tests__/index.spec.tsx index 84bcdaf661..299b44c925 100644 --- a/apps/evm/src/containers/PoolStats/__tests__/index.spec.tsx +++ b/apps/evm/src/containers/PoolStats/__tests__/index.spec.tsx @@ -1,11 +1,18 @@ import { waitFor } from '@testing-library/dom'; +import fakeAddress from '__mocks__/models/address'; import { poolData } from '__mocks__/models/pools'; +import { useGetVTreasuryContractAddress } from 'hooks/useGetVTreasuryContractAddress'; import { renderComponent } from 'testUtils/render'; +import type Vi from 'vitest'; import { PoolStats } from '..'; -vi.mock('libs/contracts'); +vi.mock('hooks/useGetVTreasuryContractAddress'); describe('PoolStats', () => { + beforeEach(() => { + (useGetVTreasuryContractAddress as Vi.Mock).mockReturnValue(fakeAddress); + }); + it('renders without crashing', async () => { renderComponent(); }); diff --git a/apps/evm/src/hooks/useGetSwapInfo/__tests__/__snapshots__/useGetTokenCombinations.spec.tsx.snap b/apps/evm/src/hooks/useGetSwapInfo/__tests__/__snapshots__/useGetTokenCombinations.spec.tsx.snap index d662fca43b..c5ddd04d20 100644 --- a/apps/evm/src/hooks/useGetSwapInfo/__tests__/__snapshots__/useGetTokenCombinations.spec.tsx.snap +++ b/apps/evm/src/hooks/useGetSwapInfo/__tests__/__snapshots__/useGetTokenCombinations.spec.tsx.snap @@ -80,14 +80,14 @@ exports[`pages/Swap/useGetSwapInfo/useGetTokenCombinations > returns all possibl "symbol": "BUSD", }, Token { - "address": "0xA808e341e8e723DC6BA0Bb5204Bafc2330d7B8e4", + "address": "0xae13d989daC2f0dEbFf460aC112a837C89BAa7cd", "chainId": 97, "decimals": 18, "isNative": false, "isToken": true, "name": undefined, "projectLink": undefined, - "symbol": "BTCB", + "symbol": "WBNB", }, ], [ @@ -112,50 +112,6 @@ exports[`pages/Swap/useGetSwapInfo/useGetTokenCombinations > returns all possibl "symbol": "ETH", }, ], - [ - Token { - "address": "0x8301F2213c0eeD49a7E28Ae4c3e91722919B8B47", - "chainId": 97, - "decimals": 18, - "isNative": false, - "isToken": true, - "name": undefined, - "projectLink": undefined, - "symbol": "BUSD", - }, - Token { - "address": "0xe8bd7cCC165FAEb9b81569B05424771B9A20cbEF", - "chainId": 97, - "decimals": 18, - "isNative": false, - "isToken": true, - "name": undefined, - "projectLink": undefined, - "symbol": "CAKE", - }, - ], - [ - Token { - "address": "0x8301F2213c0eeD49a7E28Ae4c3e91722919B8B47", - "chainId": 97, - "decimals": 18, - "isNative": false, - "isToken": true, - "name": undefined, - "projectLink": undefined, - "symbol": "BUSD", - }, - Token { - "address": "0xae13d989daC2f0dEbFf460aC112a837C89BAa7cd", - "chainId": 97, - "decimals": 18, - "isNative": false, - "isToken": true, - "name": undefined, - "projectLink": undefined, - "symbol": "WBNB", - }, - ], [ Token { "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", @@ -212,14 +168,14 @@ exports[`pages/Swap/useGetSwapInfo/useGetTokenCombinations > returns all possibl "symbol": "XVS", }, Token { - "address": "0xA808e341e8e723DC6BA0Bb5204Bafc2330d7B8e4", + "address": "0xae13d989daC2f0dEbFf460aC112a837C89BAa7cd", "chainId": 97, "decimals": 18, "isNative": false, "isToken": true, "name": undefined, "projectLink": undefined, - "symbol": "BTCB", + "symbol": "WBNB", }, ], [ @@ -244,50 +200,6 @@ exports[`pages/Swap/useGetSwapInfo/useGetTokenCombinations > returns all possibl "symbol": "ETH", }, ], - [ - Token { - "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", - "chainId": 97, - "decimals": 18, - "isNative": false, - "isToken": true, - "name": undefined, - "projectLink": undefined, - "symbol": "XVS", - }, - Token { - "address": "0xe8bd7cCC165FAEb9b81569B05424771B9A20cbEF", - "chainId": 97, - "decimals": 18, - "isNative": false, - "isToken": true, - "name": undefined, - "projectLink": undefined, - "symbol": "CAKE", - }, - ], - [ - Token { - "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", - "chainId": 97, - "decimals": 18, - "isNative": false, - "isToken": true, - "name": undefined, - "projectLink": undefined, - "symbol": "XVS", - }, - Token { - "address": "0xae13d989daC2f0dEbFf460aC112a837C89BAa7cd", - "chainId": 97, - "decimals": 18, - "isNative": false, - "isToken": true, - "name": undefined, - "projectLink": undefined, - "symbol": "WBNB", - }, - ], [ Token { "address": "0x16227D60f7a0e586C66B005219dfc887D13C9531", @@ -322,14 +234,14 @@ exports[`pages/Swap/useGetSwapInfo/useGetTokenCombinations > returns all possibl "symbol": "USDC", }, Token { - "address": "0xA808e341e8e723DC6BA0Bb5204Bafc2330d7B8e4", + "address": "0xae13d989daC2f0dEbFf460aC112a837C89BAa7cd", "chainId": 97, "decimals": 18, "isNative": false, "isToken": true, "name": undefined, "projectLink": undefined, - "symbol": "BTCB", + "symbol": "WBNB", }, ], [ @@ -356,36 +268,14 @@ exports[`pages/Swap/useGetSwapInfo/useGetTokenCombinations > returns all possibl ], [ Token { - "address": "0x16227D60f7a0e586C66B005219dfc887D13C9531", - "chainId": 97, - "decimals": 6, - "isNative": false, - "isToken": true, - "name": undefined, - "projectLink": undefined, - "symbol": "USDC", - }, - Token { - "address": "0xe8bd7cCC165FAEb9b81569B05424771B9A20cbEF", - "chainId": 97, - "decimals": 18, - "isNative": false, - "isToken": true, - "name": undefined, - "projectLink": undefined, - "symbol": "CAKE", - }, - ], - [ - Token { - "address": "0x16227D60f7a0e586C66B005219dfc887D13C9531", + "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", "chainId": 97, "decimals": 6, "isNative": false, "isToken": true, "name": undefined, "projectLink": undefined, - "symbol": "USDC", + "symbol": "USDT", }, Token { "address": "0xae13d989daC2f0dEbFf460aC112a837C89BAa7cd", @@ -410,26 +300,26 @@ exports[`pages/Swap/useGetSwapInfo/useGetTokenCombinations > returns all possibl "symbol": "USDT", }, Token { - "address": "0xA808e341e8e723DC6BA0Bb5204Bafc2330d7B8e4", + "address": "0x98f7A83361F7Ac8765CcEBAB1425da6b341958a7", "chainId": 97, "decimals": 18, "isNative": false, "isToken": true, "name": undefined, "projectLink": undefined, - "symbol": "BTCB", + "symbol": "ETH", }, ], [ Token { - "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", + "address": "0xae13d989daC2f0dEbFf460aC112a837C89BAa7cd", "chainId": 97, - "decimals": 6, + "decimals": 18, "isNative": false, "isToken": true, "name": undefined, "projectLink": undefined, - "symbol": "USDT", + "symbol": "WBNB", }, Token { "address": "0x98f7A83361F7Ac8765CcEBAB1425da6b341958a7", @@ -442,307 +332,307 @@ exports[`pages/Swap/useGetSwapInfo/useGetTokenCombinations > returns all possibl "symbol": "ETH", }, ], +] +`; + +exports[`pages/Swap/useGetSwapInfo/useGetTokenCombinations > uses wBNB when BNB is provided 1`] = ` +[ [ Token { - "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", + "address": "0xae13d989daC2f0dEbFf460aC112a837C89BAa7cd", "chainId": 97, - "decimals": 6, + "decimals": 18, "isNative": false, "isToken": true, "name": undefined, "projectLink": undefined, - "symbol": "USDT", + "symbol": "WBNB", }, Token { - "address": "0xe8bd7cCC165FAEb9b81569B05424771B9A20cbEF", + "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", "chainId": 97, "decimals": 18, "isNative": false, "isToken": true, "name": undefined, "projectLink": undefined, - "symbol": "CAKE", + "symbol": "XVS", }, ], [ Token { - "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", + "address": "0xae13d989daC2f0dEbFf460aC112a837C89BAa7cd", "chainId": 97, - "decimals": 6, + "decimals": 18, "isNative": false, "isToken": true, "name": undefined, "projectLink": undefined, - "symbol": "USDT", + "symbol": "WBNB", }, Token { - "address": "0xae13d989daC2f0dEbFf460aC112a837C89BAa7cd", + "address": "0x16227D60f7a0e586C66B005219dfc887D13C9531", "chainId": 97, - "decimals": 18, + "decimals": 6, "isNative": false, "isToken": true, "name": undefined, "projectLink": undefined, - "symbol": "WBNB", + "symbol": "USDC", }, ], [ Token { - "address": "0xA808e341e8e723DC6BA0Bb5204Bafc2330d7B8e4", + "address": "0xae13d989daC2f0dEbFf460aC112a837C89BAa7cd", "chainId": 97, "decimals": 18, "isNative": false, "isToken": true, "name": undefined, "projectLink": undefined, - "symbol": "BTCB", + "symbol": "WBNB", }, Token { - "address": "0x98f7A83361F7Ac8765CcEBAB1425da6b341958a7", + "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", "chainId": 97, - "decimals": 18, + "decimals": 6, "isNative": false, "isToken": true, "name": undefined, "projectLink": undefined, - "symbol": "ETH", + "symbol": "USDT", }, ], [ Token { - "address": "0xA808e341e8e723DC6BA0Bb5204Bafc2330d7B8e4", + "address": "0xae13d989daC2f0dEbFf460aC112a837C89BAa7cd", "chainId": 97, "decimals": 18, "isNative": false, "isToken": true, "name": undefined, "projectLink": undefined, - "symbol": "BTCB", + "symbol": "WBNB", }, Token { - "address": "0xe8bd7cCC165FAEb9b81569B05424771B9A20cbEF", + "address": "0x8301F2213c0eeD49a7E28Ae4c3e91722919B8B47", "chainId": 97, "decimals": 18, "isNative": false, "isToken": true, "name": undefined, "projectLink": undefined, - "symbol": "CAKE", + "symbol": "BUSD", }, ], [ Token { - "address": "0xA808e341e8e723DC6BA0Bb5204Bafc2330d7B8e4", + "address": "0xae13d989daC2f0dEbFf460aC112a837C89BAa7cd", "chainId": 97, "decimals": 18, "isNative": false, "isToken": true, "name": undefined, "projectLink": undefined, - "symbol": "BTCB", + "symbol": "WBNB", }, Token { - "address": "0xae13d989daC2f0dEbFf460aC112a837C89BAa7cd", + "address": "0x98f7A83361F7Ac8765CcEBAB1425da6b341958a7", "chainId": 97, "decimals": 18, "isNative": false, "isToken": true, "name": undefined, "projectLink": undefined, - "symbol": "WBNB", + "symbol": "ETH", }, ], [ Token { - "address": "0x98f7A83361F7Ac8765CcEBAB1425da6b341958a7", + "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", "chainId": 97, "decimals": 18, "isNative": false, "isToken": true, "name": undefined, "projectLink": undefined, - "symbol": "ETH", + "symbol": "XVS", }, Token { - "address": "0xe8bd7cCC165FAEb9b81569B05424771B9A20cbEF", + "address": "0x16227D60f7a0e586C66B005219dfc887D13C9531", "chainId": 97, - "decimals": 18, + "decimals": 6, "isNative": false, "isToken": true, "name": undefined, "projectLink": undefined, - "symbol": "CAKE", + "symbol": "USDC", }, ], [ Token { - "address": "0x98f7A83361F7Ac8765CcEBAB1425da6b341958a7", + "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", "chainId": 97, "decimals": 18, "isNative": false, "isToken": true, "name": undefined, "projectLink": undefined, - "symbol": "ETH", + "symbol": "XVS", }, Token { - "address": "0xae13d989daC2f0dEbFf460aC112a837C89BAa7cd", + "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", "chainId": 97, - "decimals": 18, + "decimals": 6, "isNative": false, "isToken": true, "name": undefined, "projectLink": undefined, - "symbol": "WBNB", + "symbol": "USDT", }, ], [ Token { - "address": "0xe8bd7cCC165FAEb9b81569B05424771B9A20cbEF", + "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", "chainId": 97, "decimals": 18, "isNative": false, "isToken": true, "name": undefined, "projectLink": undefined, - "symbol": "CAKE", + "symbol": "XVS", }, Token { - "address": "0xae13d989daC2f0dEbFf460aC112a837C89BAa7cd", + "address": "0x8301F2213c0eeD49a7E28Ae4c3e91722919B8B47", "chainId": 97, "decimals": 18, "isNative": false, "isToken": true, "name": undefined, "projectLink": undefined, - "symbol": "WBNB", + "symbol": "BUSD", }, ], -] -`; - -exports[`pages/Swap/useGetSwapInfo/useGetTokenCombinations > uses wBNB when BNB is provided 1`] = ` -[ [ Token { - "address": "0xae13d989daC2f0dEbFf460aC112a837C89BAa7cd", + "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", "chainId": 97, "decimals": 18, "isNative": false, "isToken": true, "name": undefined, "projectLink": undefined, - "symbol": "WBNB", + "symbol": "XVS", }, Token { - "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", + "address": "0x98f7A83361F7Ac8765CcEBAB1425da6b341958a7", "chainId": 97, "decimals": 18, "isNative": false, "isToken": true, "name": undefined, "projectLink": undefined, - "symbol": "XVS", + "symbol": "ETH", }, ], [ Token { - "address": "0xae13d989daC2f0dEbFf460aC112a837C89BAa7cd", + "address": "0x16227D60f7a0e586C66B005219dfc887D13C9531", "chainId": 97, - "decimals": 18, + "decimals": 6, "isNative": false, "isToken": true, "name": undefined, "projectLink": undefined, - "symbol": "WBNB", + "symbol": "USDC", }, Token { - "address": "0x16227D60f7a0e586C66B005219dfc887D13C9531", + "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", "chainId": 97, "decimals": 6, "isNative": false, "isToken": true, "name": undefined, "projectLink": undefined, - "symbol": "USDC", + "symbol": "USDT", }, ], [ Token { - "address": "0xae13d989daC2f0dEbFf460aC112a837C89BAa7cd", + "address": "0x16227D60f7a0e586C66B005219dfc887D13C9531", "chainId": 97, - "decimals": 18, + "decimals": 6, "isNative": false, "isToken": true, "name": undefined, "projectLink": undefined, - "symbol": "WBNB", + "symbol": "USDC", }, Token { - "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", + "address": "0x8301F2213c0eeD49a7E28Ae4c3e91722919B8B47", "chainId": 97, - "decimals": 6, + "decimals": 18, "isNative": false, "isToken": true, "name": undefined, "projectLink": undefined, - "symbol": "USDT", + "symbol": "BUSD", }, ], [ Token { - "address": "0xae13d989daC2f0dEbFf460aC112a837C89BAa7cd", + "address": "0x16227D60f7a0e586C66B005219dfc887D13C9531", "chainId": 97, - "decimals": 18, + "decimals": 6, "isNative": false, "isToken": true, "name": undefined, "projectLink": undefined, - "symbol": "WBNB", + "symbol": "USDC", }, Token { - "address": "0x8301F2213c0eeD49a7E28Ae4c3e91722919B8B47", + "address": "0x98f7A83361F7Ac8765CcEBAB1425da6b341958a7", "chainId": 97, "decimals": 18, "isNative": false, "isToken": true, "name": undefined, "projectLink": undefined, - "symbol": "BUSD", + "symbol": "ETH", }, ], [ Token { - "address": "0xae13d989daC2f0dEbFf460aC112a837C89BAa7cd", + "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", "chainId": 97, - "decimals": 18, + "decimals": 6, "isNative": false, "isToken": true, "name": undefined, "projectLink": undefined, - "symbol": "WBNB", + "symbol": "USDT", }, Token { - "address": "0xA808e341e8e723DC6BA0Bb5204Bafc2330d7B8e4", + "address": "0x8301F2213c0eeD49a7E28Ae4c3e91722919B8B47", "chainId": 97, "decimals": 18, "isNative": false, "isToken": true, "name": undefined, "projectLink": undefined, - "symbol": "BTCB", + "symbol": "BUSD", }, ], [ Token { - "address": "0xae13d989daC2f0dEbFf460aC112a837C89BAa7cd", + "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", "chainId": 97, - "decimals": 18, + "decimals": 6, "isNative": false, "isToken": true, "name": undefined, "projectLink": undefined, - "symbol": "WBNB", + "symbol": "USDT", }, Token { "address": "0x98f7A83361F7Ac8765CcEBAB1425da6b341958a7", @@ -757,325 +647,17 @@ exports[`pages/Swap/useGetSwapInfo/useGetTokenCombinations > uses wBNB when BNB ], [ Token { - "address": "0xae13d989daC2f0dEbFf460aC112a837C89BAa7cd", + "address": "0x8301F2213c0eeD49a7E28Ae4c3e91722919B8B47", "chainId": 97, "decimals": 18, "isNative": false, "isToken": true, "name": undefined, "projectLink": undefined, - "symbol": "WBNB", + "symbol": "BUSD", }, Token { - "address": "0xe8bd7cCC165FAEb9b81569B05424771B9A20cbEF", - "chainId": 97, - "decimals": 18, - "isNative": false, - "isToken": true, - "name": undefined, - "projectLink": undefined, - "symbol": "CAKE", - }, - ], - [ - Token { - "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", - "chainId": 97, - "decimals": 18, - "isNative": false, - "isToken": true, - "name": undefined, - "projectLink": undefined, - "symbol": "XVS", - }, - Token { - "address": "0x16227D60f7a0e586C66B005219dfc887D13C9531", - "chainId": 97, - "decimals": 6, - "isNative": false, - "isToken": true, - "name": undefined, - "projectLink": undefined, - "symbol": "USDC", - }, - ], - [ - Token { - "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", - "chainId": 97, - "decimals": 18, - "isNative": false, - "isToken": true, - "name": undefined, - "projectLink": undefined, - "symbol": "XVS", - }, - Token { - "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", - "chainId": 97, - "decimals": 6, - "isNative": false, - "isToken": true, - "name": undefined, - "projectLink": undefined, - "symbol": "USDT", - }, - ], - [ - Token { - "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", - "chainId": 97, - "decimals": 18, - "isNative": false, - "isToken": true, - "name": undefined, - "projectLink": undefined, - "symbol": "XVS", - }, - Token { - "address": "0x8301F2213c0eeD49a7E28Ae4c3e91722919B8B47", - "chainId": 97, - "decimals": 18, - "isNative": false, - "isToken": true, - "name": undefined, - "projectLink": undefined, - "symbol": "BUSD", - }, - ], - [ - Token { - "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", - "chainId": 97, - "decimals": 18, - "isNative": false, - "isToken": true, - "name": undefined, - "projectLink": undefined, - "symbol": "XVS", - }, - Token { - "address": "0xA808e341e8e723DC6BA0Bb5204Bafc2330d7B8e4", - "chainId": 97, - "decimals": 18, - "isNative": false, - "isToken": true, - "name": undefined, - "projectLink": undefined, - "symbol": "BTCB", - }, - ], - [ - Token { - "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", - "chainId": 97, - "decimals": 18, - "isNative": false, - "isToken": true, - "name": undefined, - "projectLink": undefined, - "symbol": "XVS", - }, - Token { - "address": "0x98f7A83361F7Ac8765CcEBAB1425da6b341958a7", - "chainId": 97, - "decimals": 18, - "isNative": false, - "isToken": true, - "name": undefined, - "projectLink": undefined, - "symbol": "ETH", - }, - ], - [ - Token { - "address": "0xB9e0E753630434d7863528cc73CB7AC638a7c8ff", - "chainId": 97, - "decimals": 18, - "isNative": false, - "isToken": true, - "name": undefined, - "projectLink": undefined, - "symbol": "XVS", - }, - Token { - "address": "0xe8bd7cCC165FAEb9b81569B05424771B9A20cbEF", - "chainId": 97, - "decimals": 18, - "isNative": false, - "isToken": true, - "name": undefined, - "projectLink": undefined, - "symbol": "CAKE", - }, - ], - [ - Token { - "address": "0x16227D60f7a0e586C66B005219dfc887D13C9531", - "chainId": 97, - "decimals": 6, - "isNative": false, - "isToken": true, - "name": undefined, - "projectLink": undefined, - "symbol": "USDC", - }, - Token { - "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", - "chainId": 97, - "decimals": 6, - "isNative": false, - "isToken": true, - "name": undefined, - "projectLink": undefined, - "symbol": "USDT", - }, - ], - [ - Token { - "address": "0x16227D60f7a0e586C66B005219dfc887D13C9531", - "chainId": 97, - "decimals": 6, - "isNative": false, - "isToken": true, - "name": undefined, - "projectLink": undefined, - "symbol": "USDC", - }, - Token { - "address": "0x8301F2213c0eeD49a7E28Ae4c3e91722919B8B47", - "chainId": 97, - "decimals": 18, - "isNative": false, - "isToken": true, - "name": undefined, - "projectLink": undefined, - "symbol": "BUSD", - }, - ], - [ - Token { - "address": "0x16227D60f7a0e586C66B005219dfc887D13C9531", - "chainId": 97, - "decimals": 6, - "isNative": false, - "isToken": true, - "name": undefined, - "projectLink": undefined, - "symbol": "USDC", - }, - Token { - "address": "0xA808e341e8e723DC6BA0Bb5204Bafc2330d7B8e4", - "chainId": 97, - "decimals": 18, - "isNative": false, - "isToken": true, - "name": undefined, - "projectLink": undefined, - "symbol": "BTCB", - }, - ], - [ - Token { - "address": "0x16227D60f7a0e586C66B005219dfc887D13C9531", - "chainId": 97, - "decimals": 6, - "isNative": false, - "isToken": true, - "name": undefined, - "projectLink": undefined, - "symbol": "USDC", - }, - Token { - "address": "0x98f7A83361F7Ac8765CcEBAB1425da6b341958a7", - "chainId": 97, - "decimals": 18, - "isNative": false, - "isToken": true, - "name": undefined, - "projectLink": undefined, - "symbol": "ETH", - }, - ], - [ - Token { - "address": "0x16227D60f7a0e586C66B005219dfc887D13C9531", - "chainId": 97, - "decimals": 6, - "isNative": false, - "isToken": true, - "name": undefined, - "projectLink": undefined, - "symbol": "USDC", - }, - Token { - "address": "0xe8bd7cCC165FAEb9b81569B05424771B9A20cbEF", - "chainId": 97, - "decimals": 18, - "isNative": false, - "isToken": true, - "name": undefined, - "projectLink": undefined, - "symbol": "CAKE", - }, - ], - [ - Token { - "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", - "chainId": 97, - "decimals": 6, - "isNative": false, - "isToken": true, - "name": undefined, - "projectLink": undefined, - "symbol": "USDT", - }, - Token { - "address": "0x8301F2213c0eeD49a7E28Ae4c3e91722919B8B47", - "chainId": 97, - "decimals": 18, - "isNative": false, - "isToken": true, - "name": undefined, - "projectLink": undefined, - "symbol": "BUSD", - }, - ], - [ - Token { - "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", - "chainId": 97, - "decimals": 6, - "isNative": false, - "isToken": true, - "name": undefined, - "projectLink": undefined, - "symbol": "USDT", - }, - Token { - "address": "0xA808e341e8e723DC6BA0Bb5204Bafc2330d7B8e4", - "chainId": 97, - "decimals": 18, - "isNative": false, - "isToken": true, - "name": undefined, - "projectLink": undefined, - "symbol": "BTCB", - }, - ], - [ - Token { - "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", - "chainId": 97, - "decimals": 6, - "isNative": false, - "isToken": true, - "name": undefined, - "projectLink": undefined, - "symbol": "USDT", - }, - Token { - "address": "0x98f7A83361F7Ac8765CcEBAB1425da6b341958a7", + "address": "0x98f7A83361F7Ac8765CcEBAB1425da6b341958a7", "chainId": 97, "decimals": 18, "isNative": false, @@ -1085,159 +667,5 @@ exports[`pages/Swap/useGetSwapInfo/useGetTokenCombinations > uses wBNB when BNB "symbol": "ETH", }, ], - [ - Token { - "address": "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c", - "chainId": 97, - "decimals": 6, - "isNative": false, - "isToken": true, - "name": undefined, - "projectLink": undefined, - "symbol": "USDT", - }, - Token { - "address": "0xe8bd7cCC165FAEb9b81569B05424771B9A20cbEF", - "chainId": 97, - "decimals": 18, - "isNative": false, - "isToken": true, - "name": undefined, - "projectLink": undefined, - "symbol": "CAKE", - }, - ], - [ - Token { - "address": "0x8301F2213c0eeD49a7E28Ae4c3e91722919B8B47", - "chainId": 97, - "decimals": 18, - "isNative": false, - "isToken": true, - "name": undefined, - "projectLink": undefined, - "symbol": "BUSD", - }, - Token { - "address": "0xA808e341e8e723DC6BA0Bb5204Bafc2330d7B8e4", - "chainId": 97, - "decimals": 18, - "isNative": false, - "isToken": true, - "name": undefined, - "projectLink": undefined, - "symbol": "BTCB", - }, - ], - [ - Token { - "address": "0x8301F2213c0eeD49a7E28Ae4c3e91722919B8B47", - "chainId": 97, - "decimals": 18, - "isNative": false, - "isToken": true, - "name": undefined, - "projectLink": undefined, - "symbol": "BUSD", - }, - Token { - "address": "0x98f7A83361F7Ac8765CcEBAB1425da6b341958a7", - "chainId": 97, - "decimals": 18, - "isNative": false, - "isToken": true, - "name": undefined, - "projectLink": undefined, - "symbol": "ETH", - }, - ], - [ - Token { - "address": "0x8301F2213c0eeD49a7E28Ae4c3e91722919B8B47", - "chainId": 97, - "decimals": 18, - "isNative": false, - "isToken": true, - "name": undefined, - "projectLink": undefined, - "symbol": "BUSD", - }, - Token { - "address": "0xe8bd7cCC165FAEb9b81569B05424771B9A20cbEF", - "chainId": 97, - "decimals": 18, - "isNative": false, - "isToken": true, - "name": undefined, - "projectLink": undefined, - "symbol": "CAKE", - }, - ], - [ - Token { - "address": "0xA808e341e8e723DC6BA0Bb5204Bafc2330d7B8e4", - "chainId": 97, - "decimals": 18, - "isNative": false, - "isToken": true, - "name": undefined, - "projectLink": undefined, - "symbol": "BTCB", - }, - Token { - "address": "0x98f7A83361F7Ac8765CcEBAB1425da6b341958a7", - "chainId": 97, - "decimals": 18, - "isNative": false, - "isToken": true, - "name": undefined, - "projectLink": undefined, - "symbol": "ETH", - }, - ], - [ - Token { - "address": "0xA808e341e8e723DC6BA0Bb5204Bafc2330d7B8e4", - "chainId": 97, - "decimals": 18, - "isNative": false, - "isToken": true, - "name": undefined, - "projectLink": undefined, - "symbol": "BTCB", - }, - Token { - "address": "0xe8bd7cCC165FAEb9b81569B05424771B9A20cbEF", - "chainId": 97, - "decimals": 18, - "isNative": false, - "isToken": true, - "name": undefined, - "projectLink": undefined, - "symbol": "CAKE", - }, - ], - [ - Token { - "address": "0x98f7A83361F7Ac8765CcEBAB1425da6b341958a7", - "chainId": 97, - "decimals": 18, - "isNative": false, - "isToken": true, - "name": undefined, - "projectLink": undefined, - "symbol": "ETH", - }, - Token { - "address": "0xe8bd7cCC165FAEb9b81569B05424771B9A20cbEF", - "chainId": 97, - "decimals": 18, - "isNative": false, - "isToken": true, - "name": undefined, - "projectLink": undefined, - "symbol": "CAKE", - }, - ], ] `; diff --git a/apps/evm/src/libs/contracts/config/externalAbis/PoolLens.json b/apps/evm/src/libs/contracts/config/externalAbis/PoolLens.json index 4fce8377ba..b6ee427d3b 100644 --- a/apps/evm/src/libs/contracts/config/externalAbis/PoolLens.json +++ b/apps/evm/src/libs/contracts/config/externalAbis/PoolLens.json @@ -216,7 +216,7 @@ "type": "tuple" } ], - "name": "getPoolDataFromVenusPool", + "name": "getPoolsFromVenusPool", "outputs": [ { "components": [ diff --git a/apps/evm/src/libs/tokens/__mocks__/index.ts b/apps/evm/src/libs/tokens/__mocks__/index.ts index da1277d234..ab65cf7409 100644 --- a/apps/evm/src/libs/tokens/__mocks__/index.ts +++ b/apps/evm/src/libs/tokens/__mocks__/index.ts @@ -1,10 +1,13 @@ import tokens from '__mocks__/models/tokens'; -export * from 'libs/tokens/hooks/useGetToken'; -export * from 'libs/tokens/hooks/useGetTokens'; -export * from 'libs/tokens/hooks/useGetSwapTokens'; export * from 'libs/tokens/infos'; +export const useGetToken = vi.fn(({ symbol }) => tokens.find(token => token.symbol === symbol)); + +export const useGetTokens = vi.fn(() => tokens); export const getTokens = vi.fn(() => tokens); + +export const useGetSwapTokens = vi.fn(() => tokens); export const getSwapTokens = vi.fn(() => tokens); + export const getDisabledTokenActions = vi.fn(() => []); diff --git a/apps/evm/src/pages/ConvertVrt/Withdraw/index.spec.tsx b/apps/evm/src/pages/ConvertVrt/Withdraw/index.spec.tsx index 2bb1af166f..3c0d102d71 100644 --- a/apps/evm/src/pages/ConvertVrt/Withdraw/index.spec.tsx +++ b/apps/evm/src/pages/ConvertVrt/Withdraw/index.spec.tsx @@ -7,14 +7,14 @@ import fakeContractTransaction from '__mocks__/models/contractTransaction'; import { poolData } from '__mocks__/models/pools'; import { renderComponent } from 'testUtils/render'; -import { useGetLegacyPool } from 'clients/api'; +import { useGetPool } from 'clients/api'; import { en } from 'libs/translations'; import Withdraw from '.'; describe('Withdraw', () => { beforeEach(() => { - (useGetLegacyPool as Vi.Mock).mockImplementation(() => ({ + (useGetPool as Vi.Mock).mockImplementation(() => ({ data: { pool: { ...poolData[0], diff --git a/apps/evm/src/pages/Dashboard/index.tsx b/apps/evm/src/pages/Dashboard/index.tsx index 3bff829a68..a460cbac03 100644 --- a/apps/evm/src/pages/Dashboard/index.tsx +++ b/apps/evm/src/pages/Dashboard/index.tsx @@ -24,10 +24,11 @@ const Dashboard: React.FC = () => { const handleSearchInputChange: InputHTMLAttributes['onChange'] = changeEvent => setSearchValue(changeEvent.currentTarget.value); - const { data: getPoolData, isLoading: isGetPoolsLoading } = useGetPools({ + const { data: getPools, isLoading: isGetPoolsLoading } = useGetPools({ accountAddress, }); - const pools = getPoolData?.pools || []; + + const pools = getPools?.pools || []; const columns = useMarketTableColumns(); const pausedAssetsExist = useMemo( diff --git a/apps/evm/src/pages/IsolatedPools/PoolTable/index.spec.tsx b/apps/evm/src/pages/IsolatedPools/PoolTable/index.spec.tsx index 0d938244da..47a45a2df5 100644 --- a/apps/evm/src/pages/IsolatedPools/PoolTable/index.spec.tsx +++ b/apps/evm/src/pages/IsolatedPools/PoolTable/index.spec.tsx @@ -4,7 +4,7 @@ import { poolData } from '__mocks__/models/pools'; import { renderComponent } from 'testUtils/render'; import { chainMetadata } from '@venusprotocol/chains'; -import { useGetIsolatedPools } from 'clients/api'; +import { useGetPools } from 'clients/api'; import { useGetChainMetadata } from 'hooks/useGetChainMetadata'; import { ChainId } from 'types'; @@ -22,7 +22,7 @@ describe('PoolTable', () => { }); it('filters out the core pool', () => { - (useGetIsolatedPools as Vi.Mock).mockImplementation(() => ({ + (useGetPools as Vi.Mock).mockImplementation(() => ({ data: { pools: [ { diff --git a/apps/evm/src/pages/IsolatedPools/PoolTable/index.tsx b/apps/evm/src/pages/IsolatedPools/PoolTable/index.tsx index fe8af78a4d..2d355caae4 100644 --- a/apps/evm/src/pages/IsolatedPools/PoolTable/index.tsx +++ b/apps/evm/src/pages/IsolatedPools/PoolTable/index.tsx @@ -2,7 +2,7 @@ import BigNumber from 'bignumber.js'; import { useMemo } from 'react'; -import { useGetIsolatedPools } from 'clients/api'; +import { useGetPools } from 'clients/api'; import { Table, type TableColumn, TokenGroup } from 'components'; import { routes } from 'constants/routing'; import { useGetChainMetadata } from 'hooks/useGetChainMetadata'; @@ -140,14 +140,16 @@ export const PoolTableUi: React.FC = ({ pools, isFetchingPools } const PoolTable = () => { const { accountAddress } = useAccountAddress(); - const { data: poolData, isLoading } = useGetIsolatedPools({ accountAddress }); + const { data: poolData, isLoading } = useGetPools({ accountAddress }); const { corePoolComptrollerContractAddress } = useGetChainMetadata(); // Filter out core pool (on some chains the core pool is one of the isolated pools) const pools = useMemo( () => (poolData?.pools || []).filter( - pool => !areAddressesEqual(pool.comptrollerAddress, corePoolComptrollerContractAddress), + pool => + pool.isIsolated && + !areAddressesEqual(pool.comptrollerAddress, corePoolComptrollerContractAddress), ), [poolData?.pools, corePoolComptrollerContractAddress], ); diff --git a/apps/evm/src/pages/IsolatedPools/useGetFilteredPools/index.tsx b/apps/evm/src/pages/IsolatedPools/useGetFilteredPools/index.tsx index 0be6f87ba1..7eddf7669b 100644 --- a/apps/evm/src/pages/IsolatedPools/useGetFilteredPools/index.tsx +++ b/apps/evm/src/pages/IsolatedPools/useGetFilteredPools/index.tsx @@ -1,15 +1,17 @@ -import { useGetIsolatedPools } from 'clients/api'; +import { useGetPools } from 'clients/api'; import { useGetChainMetadata } from 'hooks/useGetChainMetadata'; import { useMemo } from 'react'; export const useGetFilteredPools = () => { - const { data: getPoolsData } = useGetIsolatedPools(); + const { data: getPoolsData } = useGetPools(); const chainMetaData = useGetChainMetadata(); const pools = useMemo( () => (getPoolsData?.pools || []).filter( - pool => pool.comptrollerAddress !== chainMetaData.corePoolComptrollerContractAddress, + pool => + pool.isIsolated && + pool.comptrollerAddress !== chainMetaData.corePoolComptrollerContractAddress, ), [getPoolsData?.pools, chainMetaData.corePoolComptrollerContractAddress], ); diff --git a/apps/evm/src/pages/Market/Page/MarketHistory/Card/useGetLiquidationThresholdPercentage.tsx b/apps/evm/src/pages/Market/Page/MarketHistory/Card/useGetLiquidationThresholdPercentage.tsx index 52ce03acc2..8f264ca13b 100644 --- a/apps/evm/src/pages/Market/Page/MarketHistory/Card/useGetLiquidationThresholdPercentage.tsx +++ b/apps/evm/src/pages/Market/Page/MarketHistory/Card/useGetLiquidationThresholdPercentage.tsx @@ -1,8 +1,7 @@ import { useGetIsolatedPoolVTokenLiquidationThreshold } from 'clients/api'; -import { useGetChainMetadata } from 'hooks/useGetChainMetadata'; import { useChainId } from 'libs/wallet'; -import { type Asset, ChainId } from 'types'; -import { areAddressesEqual } from 'utilities'; +import type { Asset } from 'types'; +import { isPoolIsolated } from 'utilities'; export const useGetLiquidationThresholdPercentage = ( { @@ -12,11 +11,11 @@ export const useGetLiquidationThresholdPercentage = ( { enabled }: { enabled: boolean }, ) => { const { chainId } = useChainId(); - const { corePoolComptrollerContractAddress } = useGetChainMetadata(); - const isLegacyCorePoolVToken = - areAddressesEqual(corePoolComptrollerContractAddress, poolComptrollerContractAddress) && - (chainId === ChainId.BSC_MAINNET || chainId === ChainId.BSC_TESTNET); + const isIsolated = isPoolIsolated({ + chainId, + comptrollerAddress: poolComptrollerContractAddress, + }); const { data: getIsolatedPoolVTokenLiquidationThresholdData } = useGetIsolatedPoolVTokenLiquidationThreshold( @@ -25,11 +24,11 @@ export const useGetLiquidationThresholdPercentage = ( vTokenAddress: asset.vToken.address, }, { - enabled: enabled && !isLegacyCorePoolVToken, + enabled: enabled && isIsolated, }, ); - return isLegacyCorePoolVToken - ? asset.collateralFactor * 100 - : getIsolatedPoolVTokenLiquidationThresholdData?.liquidationThresholdPercentage; + return isIsolated + ? getIsolatedPoolVTokenLiquidationThresholdData?.liquidationThresholdPercentage + : asset.collateralFactor * 100; }; diff --git a/apps/evm/src/pages/Pool/index.tsx b/apps/evm/src/pages/Pool/index.tsx index 08cf35dd7e..720be1a6d0 100644 --- a/apps/evm/src/pages/Pool/index.tsx +++ b/apps/evm/src/pages/Pool/index.tsx @@ -62,19 +62,19 @@ interface PoolPageProps { const PoolPage: React.FC = ({ poolComptrollerAddress }) => { const { accountAddress } = useAccountAddress(); - const { data: getPoolData, isLoading: isGetPoolLoading } = useGetPool({ + const { data: getPools, isLoading: isGetPoolLoading } = useGetPool({ accountAddress, poolComptrollerAddress, }); // Redirect to Dashboard page if pool Comptroller address is incorrect - if (!isGetPoolLoading && !getPoolData?.pool) { + if (!isGetPoolLoading && !getPools?.pool) { return ; } return ( - + ); }; diff --git a/apps/evm/src/pages/Vai/AccountVaiData/index.tsx b/apps/evm/src/pages/Vai/AccountVaiData/index.tsx index 2fd269d193..f9e6be11db 100644 --- a/apps/evm/src/pages/Vai/AccountVaiData/index.tsx +++ b/apps/evm/src/pages/Vai/AccountVaiData/index.tsx @@ -2,13 +2,14 @@ import BigNumber from 'bignumber.js'; import { useMemo } from 'react'; import { - useGetLegacyPool, + useGetPool, useGetTokenUsdPrice, useGetVaiRepayAmountWithInterests, useGetVaiRepayApr, } from 'clients/api'; import { Spinner } from 'components'; import { AccountData, type AccountDataProps } from 'containers/AccountData'; +import { useGetChainMetadata } from 'hooks/useGetChainMetadata'; import { useGetToken } from 'libs/tokens'; import { useAccountAddress } from 'libs/wallet'; import type { Asset } from 'types'; @@ -21,6 +22,7 @@ export interface AccountVaiDataProps { export const AccountVaiData: React.FC = ({ amountTokens, action }) => { const { accountAddress } = useAccountAddress(); + const { corePoolComptrollerContractAddress } = useGetChainMetadata(); const vai = useGetToken({ symbol: 'VAI', @@ -34,8 +36,9 @@ export const AccountVaiData: React.FC = ({ amountTokens, ac }); const vaiPriceDollars = getVaiUsdPrice?.tokenPriceUsd; - const { data: getLegacyPoolData } = useGetLegacyPool({ + const { data: getLegacyPoolData } = useGetPool({ accountAddress, + poolComptrollerAddress: corePoolComptrollerContractAddress, }); const legacyPool = getLegacyPoolData?.pool; diff --git a/apps/evm/src/pages/Vai/Borrow/__tests__/index.spec.tsx b/apps/evm/src/pages/Vai/Borrow/__tests__/index.spec.tsx index 98219297cc..8b6fbff65c 100644 --- a/apps/evm/src/pages/Vai/Borrow/__tests__/index.spec.tsx +++ b/apps/evm/src/pages/Vai/Borrow/__tests__/index.spec.tsx @@ -13,8 +13,8 @@ import { renderComponent } from 'testUtils/render'; import { getVaiTreasuryPercentage, mintVai, - useGetLegacyPool, useGetMintableVai, + useGetPool, useGetTokenUsdPrice, } from 'clients/api'; import formatToMintableVaiOutput from 'clients/api/queries/getMintableVai/formatToOutput'; @@ -45,7 +45,7 @@ describe('Borrow', () => { data: fakeGetMintableVaiOutput, })); - (useGetLegacyPool as Vi.Mock).mockImplementation(() => ({ + (useGetPool as Vi.Mock).mockImplementation(() => ({ isLoading: false, data: { pool: { diff --git a/apps/evm/src/pages/Vai/Borrow/index.tsx b/apps/evm/src/pages/Vai/Borrow/index.tsx index 9cf387617a..dec131fc24 100644 --- a/apps/evm/src/pages/Vai/Borrow/index.tsx +++ b/apps/evm/src/pages/Vai/Borrow/index.tsx @@ -3,8 +3,8 @@ import { useCallback, useMemo } from 'react'; import type { SubmitHandler } from 'react-hook-form'; import { - useGetLegacyPool, useGetMintableVai, + useGetPool, useGetPrimeToken, useGetTokenUsdPrice, useGetVaiRepayApr, @@ -31,6 +31,7 @@ import { } from 'utilities'; import { RhfSubmitButton, RhfTokenTextField } from 'containers/Form'; +import { useGetChainMetadata } from 'hooks/useGetChainMetadata'; import { AccountVaiData } from '../AccountVaiData'; import type { FormValues } from '../types'; import TEST_IDS from './testIds'; @@ -40,13 +41,15 @@ export const Borrow: React.FC = () => { const { t, Trans } = useTranslation(); const { accountAddress } = useAccountAddress(); const isUserConnected = !!accountAddress; + const { corePoolComptrollerContractAddress } = useGetChainMetadata(); const vai = useGetToken({ symbol: 'VAI', })!; - const { data: getLegacyPoolData } = useGetLegacyPool({ + const { data: getLegacyPoolData } = useGetPool({ accountAddress, + poolComptrollerAddress: corePoolComptrollerContractAddress, }); const legacyPool = getLegacyPoolData?.pool; diff --git a/apps/evm/src/pages/Vai/Repay/__tests__/index.spec.tsx b/apps/evm/src/pages/Vai/Repay/__tests__/index.spec.tsx index 5da71ed854..041658baac 100644 --- a/apps/evm/src/pages/Vai/Repay/__tests__/index.spec.tsx +++ b/apps/evm/src/pages/Vai/Repay/__tests__/index.spec.tsx @@ -11,7 +11,7 @@ import { renderComponent } from 'testUtils/render'; import { repayVai, useGetBalanceOf, - useGetLegacyPool, + useGetPool, useGetTokenUsdPrice, useGetVaiRepayAmountWithInterests, useGetVaiRepayApr, @@ -62,7 +62,7 @@ describe('Repay', () => { isLoading: false, })); - (useGetLegacyPool as Vi.Mock).mockImplementation(() => ({ + (useGetPool as Vi.Mock).mockImplementation(() => ({ isLoading: false, data: { pool: { diff --git a/apps/evm/src/setupTests.tsx b/apps/evm/src/setupTests.tsx index 42b6daaa9a..abd08ec219 100644 --- a/apps/evm/src/setupTests.tsx +++ b/apps/evm/src/setupTests.tsx @@ -24,6 +24,9 @@ vi.mock('hooks/useDebounceValue', () => ({ // Mock zustand library (optimized state manager) vi.mock('zustand'); +// Mock Venus chains library +vi.mock('@venusprotocol/chains'); + // Mock React Markdown library vi.mock('@uiw/react-md-editor', () => ({ default: ({ diff --git a/apps/evm/src/types/index.ts b/apps/evm/src/types/index.ts index 88d236421d..1200aea0f9 100644 --- a/apps/evm/src/types/index.ts +++ b/apps/evm/src/types/index.ts @@ -117,7 +117,6 @@ export interface SwapRouterAddressMapping { export interface Pool { comptrollerAddress: string; name: string; - description: string; isIsolated: boolean; assets: Asset[]; // User-specific props @@ -458,11 +457,6 @@ export type SwapError = export type PSTokenCombination = [PSToken, PSToken]; -export interface PrimeApy { - borrowApy: BigNumber; - supplyApy: BigNumber; -} - export type ContractTxData< TContract extends BaseContract, TMethodName extends keyof TContract['functions'], diff --git a/apps/evm/src/utilities/convertAprBipsToApy/index.ts b/apps/evm/src/utilities/convertAprBipsToApy/index.ts index 53072a0580..aac65d7582 100644 --- a/apps/evm/src/utilities/convertAprBipsToApy/index.ts +++ b/apps/evm/src/utilities/convertAprBipsToApy/index.ts @@ -1,12 +1,10 @@ -import BigNumber from 'bignumber.js'; - import { DAYS_PER_YEAR } from 'constants/time'; import { calculateYearlyPercentageRate } from '../calculateYearlyPercentageRate'; export const convertAprBipsToApy = ({ aprBips }: { aprBips: string }) => { // Convert bips to daily rate - const dailyPercentageRate = new BigNumber(aprBips).div(10000).div(DAYS_PER_YEAR); + const dailyPercentageRate = +aprBips / 10000 / DAYS_PER_YEAR; // Convert daily rate to APY return calculateYearlyPercentageRate({ dailyPercentageRate }); }; diff --git a/apps/evm/src/utilities/formatToMarket/index.ts b/apps/evm/src/utilities/formatToMarket/index.ts deleted file mode 100644 index 1a7f22a610..0000000000 --- a/apps/evm/src/utilities/formatToMarket/index.ts +++ /dev/null @@ -1,53 +0,0 @@ -import BigNumber from 'bignumber.js'; -import type { ApiMarketData } from 'clients/api'; -import { NATIVE_TOKEN_ADDRESS } from 'constants/address'; -import type { Market } from 'types'; - -interface FormatToMarketInput { - apiMarket: ApiMarketData; -} - -const formatToMarket = ({ apiMarket }: FormatToMarketInput) => { - const market: Market = { - vTokenAddress: apiMarket.address, - borrowerCount: apiMarket.borrowerCount, - supplierCount: apiMarket.supplierCount, - supplyApyPercentage: new BigNumber(apiMarket.supplyApy), - borrowApyPercentage: new BigNumber(apiMarket.borrowApy), - borrowRatePerBlockOrTimestamp: new BigNumber(apiMarket.borrowRatePerBlock), - supplyRatePerBlockOrTimestamp: new BigNumber(apiMarket.supplyRatePerBlock), - exchangeRateMantissa: new BigNumber(apiMarket.exchangeRateMantissa), - underlyingTokenAddress: apiMarket.underlyingAddress ?? NATIVE_TOKEN_ADDRESS, - underlyingTokenPriceMantissa: new BigNumber(apiMarket.underlyingPriceMantissa), - supplyCapsMantissa: new BigNumber(apiMarket.supplyCapsMantissa), - borrowCapsMantissa: new BigNumber(apiMarket.borrowCapsMantissa), - cashMantissa: new BigNumber(apiMarket.cashMantissa), - reserveFactorMantissa: new BigNumber(apiMarket.reserveFactorMantissa), - collateralFactorMantissa: new BigNumber(apiMarket.collateralFactorMantissa), - totalReservesMantissa: new BigNumber(apiMarket.totalReservesMantissa), - totalBorrowsMantissa: new BigNumber(apiMarket.totalBorrowsMantissa), - totalSupplyMantissa: new BigNumber(apiMarket.totalSupplyMantissa), - estimatedPrimeBorrowApyBoost: apiMarket.estimatedPrimeBorrowApyBoost - ? new BigNumber(apiMarket.estimatedPrimeBorrowApyBoost) - : undefined, - estimatedPrimeSupplyApyBoost: apiMarket.estimatedPrimeSupplyApyBoost - ? new BigNumber(apiMarket.estimatedPrimeSupplyApyBoost) - : undefined, - pausedActionsBitmap: apiMarket.pausedActionsBitmap, - isListed: apiMarket.isListed, - rewardsDistributors: apiMarket.rewardsDistributors.map(rd => ({ - vTokenAddress: rd.marketAddress, - rewardTokenAddress: rd.rewardTokenAddress, - lastRewardingSupplyBlockOrTimestamp: new BigNumber(rd.lastRewardingSupplyBlockOrTimestamp), - lastRewardingBorrowBlockOrTimestamp: new BigNumber(rd.lastRewardingBorrowBlockOrTimestamp), - supplySpeed: new BigNumber(rd.supplySpeed), - borrowSpeed: new BigNumber(rd.borrowSpeed), - priceMantissa: new BigNumber(rd.priceMantissa), - rewardsDistributorContractAddress: rd.rewardsDistributorContractAddress || '', - })), - }; - - return market; -}; - -export default formatToMarket; diff --git a/apps/evm/src/utilities/index.ts b/apps/evm/src/utilities/index.ts index 6c7b18c7bb..61c698ec0a 100755 --- a/apps/evm/src/utilities/index.ts +++ b/apps/evm/src/utilities/index.ts @@ -3,7 +3,6 @@ export { default as calculateCollateralValue } from './calculateCollateralValue' export { default as convertPercentageFromSmartContract } from './convertPercentageFromSmartContract'; export { default as encodeParameters } from './encodeParameters'; export { default as shortenValueWithSuffix } from './shortenValueWithSuffix'; -export { default as formatToMarket } from './formatToMarket'; export { default as formatCentsToReadableValue } from './formatCentsToReadableValue'; export { default as formatPercentageToReadableValue } from './formatPercentageToReadableValue'; export { default as convertTokensToMantissa } from './convertTokensToMantissa'; @@ -31,10 +30,8 @@ export * from './cn'; export * from './createStoreSelectors'; export * from './convertAprBipsToApy'; export { default as extractSettledPromiseValue } from './extractSettledPromiseValue'; -export { appendPrimeSimulationDistributions } from './appendPrimeSimulationDistributions'; export { default as getUniqueTokenBalances } from './getUniqueTokenBalances'; export { getDisabledTokenActions } from './getDisabledTokenActions'; -export * from './appendPrimeSimulationDistributions'; export * from './getDisabledTokenActions'; export * from './isAssetPaused'; export * from './restService'; @@ -56,3 +53,4 @@ export * from './getProposalState'; export * from './getUserVoteSupport'; export * from './getProposalStateLabel'; export * from './isProposalExecutable'; +export * from './isPoolIsolated'; diff --git a/apps/evm/src/utilities/isPoolIsolated/__tests__/index.spec.tsx b/apps/evm/src/utilities/isPoolIsolated/__tests__/index.spec.tsx new file mode 100644 index 0000000000..d8c601efd3 --- /dev/null +++ b/apps/evm/src/utilities/isPoolIsolated/__tests__/index.spec.tsx @@ -0,0 +1,56 @@ +import { ChainId } from '@venusprotocol/chains'; +import type Vi from 'vitest'; + +import areAddressesEqual from 'utilities/areAddressesEqual'; +import { isPoolIsolated } from '..'; + +vi.mock('utilities/areAddressesEqual', () => ({ + default: vi.fn(), +})); + +describe('isPoolIsolated', () => { + it('returns true for chainId not BSC_MAINNET or BSC_TESTNET regardless of address', () => { + (areAddressesEqual as Vi.Mock).mockReturnValueOnce(true); + const result = isPoolIsolated({ + chainId: ChainId.ARBITRUM_ONE, + comptrollerAddress: '0xAnyAddress', + }); + expect(result).toBe(true); + }); + + it('returns false for BSC_MAINNET with matching address', () => { + (areAddressesEqual as Vi.Mock).mockReturnValueOnce(true); + const result = isPoolIsolated({ + chainId: ChainId.BSC_MAINNET, + comptrollerAddress: '0xCoreComptrollerMainnet', + }); + expect(result).toBe(false); + }); + + it('returns false for BSC_TESTNET with matching address', () => { + (areAddressesEqual as Vi.Mock).mockReturnValueOnce(true); + const result = isPoolIsolated({ + chainId: ChainId.BSC_TESTNET, + comptrollerAddress: '0xCoreComptrollerMainnet', + }); + expect(result).toBe(false); + }); + + it('returns true for BSC_MAINNET with non-matching address', () => { + (areAddressesEqual as Vi.Mock).mockReturnValueOnce(false); + const result = isPoolIsolated({ + chainId: ChainId.BSC_MAINNET, + comptrollerAddress: '0xDifferentAddress', + }); + expect(result).toBe(true); + }); + + it('returns true for BSC_TESTNET with non-matching address', () => { + (areAddressesEqual as Vi.Mock).mockReturnValueOnce(false); + const result = isPoolIsolated({ + chainId: ChainId.BSC_TESTNET, + comptrollerAddress: '0xDifferentAddress', + }); + expect(result).toBe(true); + }); +}); diff --git a/apps/evm/src/utilities/isPoolIsolated/index.tsx b/apps/evm/src/utilities/isPoolIsolated/index.tsx new file mode 100644 index 0000000000..a786986bbe --- /dev/null +++ b/apps/evm/src/utilities/isPoolIsolated/index.tsx @@ -0,0 +1,14 @@ +import { ChainId, chainMetadata } from '@venusprotocol/chains'; +import areAddressesEqual from 'utilities/areAddressesEqual'; + +export const isPoolIsolated = ({ + chainId, + comptrollerAddress, +}: { chainId: ChainId; comptrollerAddress: string }) => { + const { corePoolComptrollerContractAddress } = chainMetadata[chainId]; + + return ( + (chainId !== ChainId.BSC_MAINNET && chainId !== ChainId.BSC_TESTNET) || + !areAddressesEqual(corePoolComptrollerContractAddress, comptrollerAddress) + ); +};