impermax-sdk 1.2.112 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/abis/ImpermaxABI.d.ts +2 -2
- package/lib/abis/ImpermaxABI.js +3 -3
- package/lib/abis/contracts/ClaimAggregator.json +2015 -2015
- package/lib/abis/contracts/IAllowanceTransfer.json +3772 -0
- package/lib/abis/contracts/IBorrowable.json +13207 -13207
- package/lib/abis/contracts/IClaimable.json +406 -406
- package/lib/abis/contracts/ICollateral.json +9052 -9052
- package/lib/abis/contracts/IERC20.json +2376 -2376
- package/lib/abis/contracts/IERC721.json +3515 -0
- package/lib/abis/contracts/IFactory.json +3660 -3660
- package/lib/abis/contracts/IFarmingPool.json +3584 -3584
- package/lib/abis/contracts/ILendingVaultV1.json +8358 -8358
- package/lib/abis/contracts/IMerkleDistributor.json +1134 -1134
- package/lib/abis/contracts/IRouter02.json +7283 -7283
- package/lib/abis/contracts/ISimpleUniswapOracle.json +1469 -1469
- package/lib/abis/contracts/IStakedLPToken.json +7309 -7309
- package/lib/abis/contracts/IStakingRewards.json +1036 -1036
- package/lib/abis/contracts/ITokenizedUniswapV2Position.json +4167 -0
- package/lib/abis/contracts/ITokenizedUniswapV3Position.json +5539 -0
- package/lib/abis/contracts/IUniswapV2Factory.json +1690 -1690
- package/lib/abis/contracts/IUniswapV2Pair.json +6761 -6761
- package/lib/abis/contracts/IUniswapV3Pool.json +6606 -0
- package/lib/abis/contracts/ImpermaxChef.json +20945 -20945
- package/lib/abis/contracts/ImpermaxConfigManager.json +31595 -31595
- package/lib/abis/contracts/ImpermaxV3Borrowable.json +22131 -0
- package/lib/abis/contracts/ImpermaxV3Collateral.json +22988 -0
- package/lib/abis/contracts/ImpermaxV3Factory.json +17645 -0
- package/lib/abis/contracts/ImpermaxV3UniV2Router01.json +32488 -0
- package/lib/abis/contracts/ImpermaxV3UniV3Router01.json +37742 -0
- package/lib/abis/contracts/LendingVaultWatcher01.json +4076 -4076
- package/lib/abis/contracts/PoolTokenRouter01.json +9058 -0
- package/lib/config/amms.d.ts +102 -104
- package/lib/config/amms.js +433 -436
- package/lib/config/chainId.d.ts +2 -0
- package/lib/config/chainId.js +26 -0
- package/lib/config/contracts/claim-aggregators.d.ts +2 -2
- package/lib/config/contracts/claim-aggregators.js +26 -26
- package/lib/config/contracts/impermax-chef.d.ts +2 -2
- package/lib/config/contracts/impermax-chef.js +27 -27
- package/lib/config/contracts/impermax-config-manager.d.ts +2 -2
- package/lib/config/contracts/impermax-config-manager.js +26 -26
- package/lib/config/contracts/impermax-factories.d.ts +4 -4
- package/lib/config/contracts/impermax-factories.js +87 -87
- package/lib/config/contracts/imxes.d.ts +2 -2
- package/lib/config/contracts/imxes.js +26 -26
- package/lib/config/contracts/lending-vault-watcher.d.ts +2 -2
- package/lib/config/contracts/lending-vault-watcher.js +26 -26
- package/lib/config/contracts/merkle-distributors.d.ts +4 -4
- package/lib/config/contracts/merkle-distributors.js +70 -70
- package/lib/config/contracts/routers.d.ts +4 -3
- package/lib/config/contracts/routers.js +118 -94
- package/lib/config/contracts/simple-uniswap-oracles.d.ts +2 -2
- package/lib/config/contracts/simple-uniswap-oracles.js +49 -49
- package/lib/config/contracts/weths.d.ts +2 -2
- package/lib/config/contracts/weths.js +27 -27
- package/lib/config/debank-ids.d.ts +2 -2
- package/lib/config/debank-ids.js +26 -26
- package/lib/config/endpoints/merkle-distributors.d.ts +4 -4
- package/lib/config/endpoints/merkle-distributors.js +70 -70
- package/lib/config/eth.d.ts +3 -3
- package/lib/config/eth.js +48 -48
- package/lib/config/factories.d.ts +7 -7
- package/lib/config/factories.js +31 -30
- package/lib/config/farms.d.ts +109 -111
- package/lib/config/farms.js +207 -210
- package/lib/config/general.d.ts +5 -5
- package/lib/config/general.js +8 -8
- package/lib/config/subgraphs.d.ts +45 -45
- package/lib/config/subgraphs.js +187 -187
- package/lib/config/types.d.ts +85 -72
- package/lib/config/types.js +72 -58
- package/lib/index.d.ts +36 -35
- package/lib/index.js +159 -152
- package/lib/offchain/account/index.d.ts +9 -7
- package/lib/offchain/account/index.js +43 -39
- package/lib/offchain/account/lendingPool/borrowable.d.ts +14 -0
- package/lib/offchain/account/lendingPool/borrowable.js +73 -0
- package/lib/offchain/account/lendingPool/collateral.d.ts +12 -0
- package/lib/offchain/account/lendingPool/collateral.js +42 -0
- package/lib/offchain/account/lendingPool/index.d.ts +6 -5
- package/lib/offchain/account/lendingPool/index.js +14 -12
- package/lib/offchain/account/lendingPool/offchainAccountBorrowable.d.ts +14 -17
- package/lib/offchain/account/lendingPool/offchainAccountBorrowable.js +45 -71
- package/lib/offchain/account/lendingPool/offchainAccountCollateral.d.ts +11 -13
- package/lib/offchain/account/lendingPool/offchainAccountCollateral.js +31 -43
- package/lib/offchain/account/lendingPool/offchainAccountLendingPool.d.ts +28 -21
- package/lib/offchain/account/lendingPool/offchainAccountLendingPool.js +69 -68
- package/lib/offchain/account/lendingPool/offchainLeveragedPosition.d.ts +25 -0
- package/lib/offchain/account/lendingPool/offchainLeveragedPosition.js +116 -0
- package/lib/offchain/account/lendingVault.d.ts +11 -0
- package/lib/offchain/account/lendingVault.js +38 -0
- package/lib/offchain/account/offchainAccount.d.ts +25 -25
- package/lib/offchain/account/offchainAccount.js +129 -129
- package/lib/offchain/account/offchainAccountLendingVault.d.ts +16 -16
- package/lib/offchain/account/offchainAccountLendingVault.js +64 -64
- package/lib/offchain/account/offchainAccountPoolToken.d.ts +7 -7
- package/lib/offchain/account/offchainAccountPoolToken.js +24 -24
- package/lib/offchain/account/offchainMultichainAccount.d.ts +34 -0
- package/lib/offchain/account/offchainMultichainAccount.js +66 -0
- package/lib/offchain/account/poolToken.d.ts +6 -0
- package/lib/offchain/account/poolToken.js +21 -0
- package/lib/offchain/account/vault/index.d.ts +3 -0
- package/lib/offchain/account/vault/index.js +7 -0
- package/lib/offchain/account/vault/offchainAccountVault.d.ts +16 -0
- package/lib/offchain/account/vault/offchainAccountVault.js +64 -0
- package/lib/offchain/configManager/index.d.ts +5 -5
- package/lib/offchain/configManager/index.js +12 -12
- package/lib/offchain/configManager/offchainConfigManager.d.ts +25 -25
- package/lib/offchain/configManager/offchainConfigManager.js +76 -76
- package/lib/offchain/configManager/offchainConfigManagerInitializer.d.ts +6 -6
- package/lib/offchain/configManager/offchainConfigManagerInitializer.js +53 -53
- package/lib/offchain/configManager/offchainPairConfig.d.ts +40 -40
- package/lib/offchain/configManager/offchainPairConfig.js +86 -86
- package/lib/offchain/configManager/offchainProposal.d.ts +17 -17
- package/lib/offchain/configManager/offchainProposal.js +53 -53
- package/lib/offchain/index.d.ts +15 -14
- package/lib/offchain/index.js +55 -53
- package/lib/offchain/initializer.d.ts +32 -0
- package/lib/offchain/initializer.js +627 -0
- package/lib/offchain/lendingPool/borrowable.d.ts +55 -0
- package/lib/offchain/lendingPool/borrowable.js +351 -0
- package/lib/offchain/lendingPool/collateral.d.ts +17 -0
- package/lib/offchain/lendingPool/collateral.js +72 -0
- package/lib/offchain/lendingPool/index.d.ts +5 -5
- package/lib/offchain/lendingPool/index.js +12 -12
- package/lib/offchain/lendingPool/offchainBorrowable.d.ts +59 -59
- package/lib/offchain/lendingPool/offchainBorrowable.js +366 -366
- package/lib/offchain/lendingPool/offchainCollateral.d.ts +20 -19
- package/lib/offchain/lendingPool/offchainCollateral.js +81 -75
- package/lib/offchain/lendingPool/offchainLendingPool.d.ts +60 -47
- package/lib/offchain/lendingPool/offchainLendingPool.js +277 -230
- package/lib/offchain/lendingVault.d.ts +22 -0
- package/lib/offchain/lendingVault.js +115 -0
- package/lib/offchain/offchain.d.ts +106 -113
- package/lib/offchain/offchain.js +248 -251
- package/lib/offchain/offchainAPRHelper.d.ts +45 -45
- package/lib/offchain/offchainAPRHelper.js +239 -239
- package/lib/offchain/offchainEndpointManager.d.ts +25 -25
- package/lib/offchain/offchainEndpointManager.js +126 -126
- package/lib/offchain/offchainInitializer.d.ts +52 -52
- package/lib/offchain/offchainInitializer.js +792 -792
- package/lib/offchain/offchainLendingVault.d.ts +25 -25
- package/lib/offchain/offchainLendingVault.js +114 -114
- package/lib/offchain/offchainMultichain.d.ts +50 -0
- package/lib/offchain/offchainMultichain.js +75 -0
- package/lib/offchain/offchainPoolToken.d.ts +21 -21
- package/lib/offchain/offchainPoolToken.js +128 -128
- package/lib/offchain/offchainPriceHelper.d.ts +22 -22
- package/lib/offchain/offchainPriceHelper.js +364 -364
- package/lib/offchain/offchainSolidexHelper.d.ts +16 -16
- package/lib/offchain/offchainSolidexHelper.js +58 -58
- package/lib/offchain/offchainTypes.d.ts +212 -212
- package/lib/offchain/offchainTypes.js +3 -3
- package/lib/offchain/poolToken.d.ts +20 -0
- package/lib/offchain/poolToken.js +120 -0
- package/lib/offchain/priceHelper.d.ts +21 -0
- package/lib/offchain/priceHelper.js +195 -0
- package/lib/offchain/queries/apis/ponder/index.d.ts +14 -14
- package/lib/offchain/queries/apis/ponder/index.js +281 -281
- package/lib/offchain/queries/apis/thegraph/index.d.ts +19 -19
- package/lib/offchain/queries/apis/thegraph/index.js +355 -355
- package/lib/offchain/queries/index.d.ts +20 -20
- package/lib/offchain/queries/index.js +51 -51
- package/lib/offchain/queries/interfaces/query-builder.d.ts +19 -19
- package/lib/offchain/queries/interfaces/query-builder.js +2 -2
- package/lib/offchain/queries/interfaces/transformers.js +9 -9
- package/lib/offchain/query.d.ts +15 -0
- package/lib/offchain/query.js +323 -0
- package/lib/offchain/solidexHelper.d.ts +16 -0
- package/lib/offchain/solidexHelper.js +58 -0
- package/lib/offchain/types.d.ts +150 -0
- package/lib/offchain/types.js +3 -0
- package/lib/offchain/vault/index.d.ts +6 -0
- package/lib/offchain/vault/index.js +14 -0
- package/lib/offchain/vault/offchainHedgedVault.d.ts +9 -0
- package/lib/offchain/vault/offchainHedgedVault.js +57 -0
- package/lib/offchain/vault/offchainLendingVault.d.ts +16 -0
- package/lib/offchain/vault/offchainLendingVault.js +73 -0
- package/lib/offchain/vault/offchainLeveragedVault.d.ts +9 -0
- package/lib/offchain/vault/offchainLeveragedVault.js +57 -0
- package/lib/offchain/vault/offchainVault.d.ts +34 -0
- package/lib/offchain/vault/offchainVault.js +130 -0
- package/lib/onchain/account/index.d.ts +6 -6
- package/lib/onchain/account/index.js +38 -38
- package/lib/onchain/account/interactions/index.d.ts +28 -0
- package/lib/onchain/account/interactions/index.js +158 -0
- package/lib/onchain/account/interactions/lendingPool/borrowable.d.ts +16 -0
- package/lib/onchain/account/interactions/lendingPool/borrowable.js +49 -0
- package/lib/onchain/account/interactions/lendingPool/collateral.d.ts +15 -0
- package/lib/onchain/account/interactions/lendingPool/collateral.js +33 -0
- package/lib/onchain/account/interactions/lendingPool/index.d.ts +41 -0
- package/lib/onchain/account/interactions/lendingPool/index.js +120 -0
- package/lib/onchain/account/interactions/lendingVault.d.ts +10 -0
- package/lib/onchain/account/interactions/lendingVault.js +12 -0
- package/lib/onchain/account/interactions/poolToken.d.ts +33 -0
- package/lib/onchain/account/interactions/poolToken.js +180 -0
- package/lib/onchain/account/lendingPool/borrowable.d.ts +29 -0
- package/lib/onchain/account/lendingPool/borrowable.js +135 -0
- package/lib/onchain/account/lendingPool/collateral.d.ts +15 -0
- package/lib/onchain/account/lendingPool/collateral.js +66 -0
- package/lib/onchain/account/lendingPool/index.d.ts +12 -5
- package/lib/onchain/account/lendingPool/index.js +49 -12
- package/lib/onchain/account/lendingPool/nftlp/index.d.ts +4 -0
- package/lib/onchain/account/lendingPool/nftlp/index.js +11 -0
- package/lib/onchain/account/lendingPool/nftlp/onchainAccountNftlp.d.ts +7 -0
- package/lib/onchain/account/lendingPool/nftlp/onchainAccountNftlp.js +12 -0
- package/lib/onchain/account/lendingPool/nftlp/onchainAccountNftlpUniswapV3.d.ts +4 -0
- package/lib/onchain/account/lendingPool/nftlp/onchainAccountNftlpUniswapV3.js +13 -0
- package/lib/onchain/account/lendingPool/onchainAccountBorrowable.d.ts +39 -34
- package/lib/onchain/account/lendingPool/onchainAccountBorrowable.js +131 -176
- package/lib/onchain/account/lendingPool/onchainAccountBorrowableV2.d.ts +10 -0
- package/lib/onchain/account/lendingPool/onchainAccountBorrowableV2.js +55 -0
- package/lib/onchain/account/lendingPool/onchainAccountBorrowableV3.d.ts +10 -0
- package/lib/onchain/account/lendingPool/onchainAccountBorrowableV3.js +28 -0
- package/lib/onchain/account/lendingPool/onchainAccountCollateral.d.ts +10 -23
- package/lib/onchain/account/lendingPool/onchainAccountCollateral.js +26 -109
- package/lib/onchain/account/lendingPool/onchainAccountCollateralV2.d.ts +25 -0
- package/lib/onchain/account/lendingPool/onchainAccountCollateralV2.js +99 -0
- package/lib/onchain/account/lendingPool/onchainAccountCollateralV3.d.ts +18 -0
- package/lib/onchain/account/lendingPool/onchainAccountCollateralV3.js +44 -0
- package/lib/onchain/account/lendingPool/onchainAccountLendingPool.d.ts +42 -57
- package/lib/onchain/account/lendingPool/onchainAccountLendingPool.js +142 -352
- package/lib/onchain/account/lendingPool/onchainAccountLendingPoolV2.d.ts +44 -0
- package/lib/onchain/account/lendingPool/onchainAccountLendingPoolV2.js +285 -0
- package/lib/onchain/account/lendingPool/onchainAccountLendingPoolV3.d.ts +27 -0
- package/lib/onchain/account/lendingPool/onchainAccountLendingPoolV3.js +32 -0
- package/lib/onchain/account/lendingVault.d.ts +10 -0
- package/lib/onchain/account/lendingVault.js +35 -0
- package/lib/onchain/account/onchainAccount.d.ts +32 -32
- package/lib/onchain/account/onchainAccount.js +166 -167
- package/lib/onchain/account/onchainAccountLendingVault.d.ts +19 -19
- package/lib/onchain/account/onchainAccountLendingVault.js +48 -48
- package/lib/onchain/account/onchainAccountPoolToken.d.ts +30 -30
- package/lib/onchain/account/onchainAccountPoolToken.js +86 -86
- package/lib/onchain/account/poolToken.d.ts +24 -0
- package/lib/onchain/account/poolToken.js +84 -0
- package/lib/onchain/configManager/index.d.ts +5 -5
- package/lib/onchain/configManager/index.js +12 -12
- package/lib/onchain/configManager/onchainConfigManager.d.ts +12 -12
- package/lib/onchain/configManager/onchainConfigManager.js +38 -38
- package/lib/onchain/configManager/onchainPairConfig.d.ts +38 -38
- package/lib/onchain/configManager/onchainPairConfig.js +85 -85
- package/lib/onchain/configManager/onchainProposal.d.ts +17 -17
- package/lib/onchain/configManager/onchainProposal.js +55 -55
- package/lib/onchain/contractsHelper.d.ts +29 -0
- package/lib/onchain/contractsHelper.js +52 -0
- package/lib/onchain/impermaxFactory/index.d.ts +7 -5
- package/lib/onchain/impermaxFactory/index.js +39 -35
- package/lib/onchain/impermaxFactory/lendingPool/borrowable.d.ts +36 -0
- package/lib/onchain/impermaxFactory/lendingPool/borrowable.js +153 -0
- package/lib/onchain/impermaxFactory/lendingPool/collateral.d.ts +17 -0
- package/lib/onchain/impermaxFactory/lendingPool/collateral.js +59 -0
- package/lib/onchain/impermaxFactory/lendingPool/index.d.ts +12 -5
- package/lib/onchain/impermaxFactory/lendingPool/index.js +50 -12
- package/lib/onchain/impermaxFactory/lendingPool/nftlp/index.d.ts +4 -0
- package/lib/onchain/impermaxFactory/lendingPool/nftlp/index.js +11 -0
- package/lib/onchain/impermaxFactory/lendingPool/nftlp/onchainNftlp.d.ts +22 -0
- package/lib/onchain/impermaxFactory/lendingPool/nftlp/onchainNftlp.js +19 -0
- package/lib/onchain/impermaxFactory/lendingPool/nftlp/onchainNftlpUniswapV3.d.ts +24 -0
- package/lib/onchain/impermaxFactory/lendingPool/nftlp/onchainNftlpUniswapV3.js +90 -0
- package/lib/onchain/impermaxFactory/lendingPool/onchainBorrowable.d.ts +38 -34
- package/lib/onchain/impermaxFactory/lendingPool/onchainBorrowable.js +137 -156
- package/lib/onchain/impermaxFactory/lendingPool/onchainBorrowableV2.d.ts +9 -0
- package/lib/onchain/impermaxFactory/lendingPool/onchainBorrowableV2.js +36 -0
- package/lib/onchain/impermaxFactory/lendingPool/onchainBorrowableV3.d.ts +7 -0
- package/lib/onchain/impermaxFactory/lendingPool/onchainBorrowableV3.js +23 -0
- package/lib/onchain/impermaxFactory/lendingPool/onchainCollateral.d.ts +8 -19
- package/lib/onchain/impermaxFactory/lendingPool/onchainCollateral.js +24 -61
- package/lib/onchain/impermaxFactory/lendingPool/onchainCollateralV2.d.ts +20 -0
- package/lib/onchain/impermaxFactory/lendingPool/onchainCollateralV2.js +58 -0
- package/lib/onchain/impermaxFactory/lendingPool/onchainCollateralV3.d.ts +13 -0
- package/lib/onchain/impermaxFactory/lendingPool/onchainCollateralV3.js +36 -0
- package/lib/onchain/impermaxFactory/lendingPool/onchainLendingPool.d.ts +43 -58
- package/lib/onchain/impermaxFactory/lendingPool/onchainLendingPool.js +81 -367
- package/lib/onchain/impermaxFactory/lendingPool/onchainLendingPoolV2.d.ts +76 -0
- package/lib/onchain/impermaxFactory/lendingPool/onchainLendingPoolV2.js +338 -0
- package/lib/onchain/impermaxFactory/lendingPool/onchainLendingPoolV3.d.ts +42 -0
- package/lib/onchain/impermaxFactory/lendingPool/onchainLendingPoolV3.js +39 -0
- package/lib/onchain/impermaxFactory/onchainImpermaxFactory.d.ts +26 -16
- package/lib/onchain/impermaxFactory/onchainImpermaxFactory.js +42 -52
- package/lib/onchain/impermaxFactory/onchainImpermaxFactoryV2.d.ts +16 -0
- package/lib/onchain/impermaxFactory/onchainImpermaxFactoryV2.js +81 -0
- package/lib/onchain/impermaxFactory/onchainImpermaxFactoryV3.d.ts +16 -0
- package/lib/onchain/impermaxFactory/onchainImpermaxFactoryV3.js +88 -0
- package/lib/onchain/index.d.ts +10 -10
- package/lib/onchain/index.js +49 -49
- package/lib/onchain/interactions/index.d.ts +8 -8
- package/lib/onchain/interactions/index.js +41 -41
- package/lib/onchain/interactions/lendingPool/borrowable.d.ts +14 -0
- package/lib/onchain/interactions/lendingPool/borrowable.js +47 -0
- package/lib/onchain/interactions/lendingPool/collateral.d.ts +13 -0
- package/lib/onchain/interactions/lendingPool/collateral.js +31 -0
- package/lib/onchain/interactions/lendingPool/index.d.ts +12 -5
- package/lib/onchain/interactions/lendingPool/index.js +49 -12
- package/lib/onchain/interactions/lendingPool/nftlp/index.d.ts +4 -0
- package/lib/onchain/interactions/lendingPool/nftlp/index.js +11 -0
- package/lib/onchain/interactions/lendingPool/nftlp/onchainInteractionsNftlp.d.ts +7 -0
- package/lib/onchain/interactions/lendingPool/nftlp/onchainInteractionsNftlp.js +12 -0
- package/lib/onchain/interactions/lendingPool/nftlp/onchainInteractionsNftlpUniswapV3.d.ts +4 -0
- package/lib/onchain/interactions/lendingPool/nftlp/onchainInteractionsNftlpUniswapV3.js +13 -0
- package/lib/onchain/interactions/lendingPool/onchainInteractionsBorrowable.d.ts +17 -21
- package/lib/onchain/interactions/lendingPool/onchainInteractionsBorrowable.js +24 -56
- package/lib/onchain/interactions/lendingPool/onchainInteractionsBorrowableV2.d.ts +15 -0
- package/lib/onchain/interactions/lendingPool/onchainInteractionsBorrowableV2.js +63 -0
- package/lib/onchain/interactions/lendingPool/onchainInteractionsBorrowableV3.d.ts +9 -0
- package/lib/onchain/interactions/lendingPool/onchainInteractionsBorrowableV3.js +14 -0
- package/lib/onchain/interactions/lendingPool/onchainInteractionsCollateral.d.ts +7 -19
- package/lib/onchain/interactions/lendingPool/onchainInteractionsCollateral.js +11 -43
- package/lib/onchain/interactions/lendingPool/onchainInteractionsCollateralV2.d.ts +20 -0
- package/lib/onchain/interactions/lendingPool/onchainInteractionsCollateralV2.js +48 -0
- package/lib/onchain/interactions/lendingPool/onchainInteractionsCollateralV3.d.ts +13 -0
- package/lib/onchain/interactions/lendingPool/onchainInteractionsCollateralV3.js +20 -0
- package/lib/onchain/interactions/lendingPool/onchainInteractionsLendingPool.d.ts +31 -46
- package/lib/onchain/interactions/lendingPool/onchainInteractionsLendingPool.js +53 -135
- package/lib/onchain/interactions/lendingPool/onchainInteractionsLendingPoolV2.d.ts +42 -0
- package/lib/onchain/interactions/lendingPool/onchainInteractionsLendingPoolV2.js +114 -0
- package/lib/onchain/interactions/lendingPool/onchainInteractionsLendingPoolV3.d.ts +27 -0
- package/lib/onchain/interactions/lendingPool/onchainInteractionsLendingPoolV3.js +32 -0
- package/lib/onchain/interactions/lendingVault.d.ts +8 -0
- package/lib/onchain/interactions/lendingVault.js +15 -0
- package/lib/onchain/interactions/onchainInteractions.d.ts +31 -31
- package/lib/onchain/interactions/onchainInteractions.js +136 -137
- package/lib/onchain/interactions/onchainInteractionsConfigManager.d.ts +17 -17
- package/lib/onchain/interactions/onchainInteractionsConfigManager.js +44 -44
- package/lib/onchain/interactions/onchainInteractionsLendingVault.d.ts +14 -14
- package/lib/onchain/interactions/onchainInteractionsLendingVault.js +21 -21
- package/lib/onchain/interactions/onchainInteractionsPoolToken.d.ts +35 -35
- package/lib/onchain/interactions/onchainInteractionsPoolToken.js +134 -186
- package/lib/onchain/interactions/poolToken.d.ts +31 -0
- package/lib/onchain/interactions/poolToken.js +181 -0
- package/lib/onchain/lendingVault.d.ts +17 -0
- package/lib/onchain/lendingVault.js +56 -0
- package/lib/onchain/onchain.d.ts +38 -35
- package/lib/onchain/onchain.js +78 -70
- package/lib/onchain/onchainContractsHelper.d.ts +42 -31
- package/lib/onchain/onchainContractsHelper.js +90 -56
- package/lib/onchain/onchainLendingVault.d.ts +22 -22
- package/lib/onchain/onchainLendingVault.js +69 -69
- package/lib/onchain/onchainPermitHelper.d.ts +21 -0
- package/lib/onchain/onchainPermitHelper.js +198 -0
- package/lib/onchain/onchainPoolToken.d.ts +35 -35
- package/lib/onchain/onchainPoolToken.js +129 -129
- package/lib/onchain/onchainTypes.d.ts +70 -64
- package/lib/onchain/onchainTypes.js +14 -14
- package/lib/onchain/poolToken.d.ts +32 -0
- package/lib/onchain/poolToken.js +121 -0
- package/lib/onchain/types.d.ts +45 -0
- package/lib/onchain/types.js +14 -0
- package/lib/utils/ether-utils.d.ts +5 -5
- package/lib/utils/ether-utils.js +26 -26
- package/lib/utils/index.d.ts +3 -3
- package/lib/utils/index.js +16 -16
- package/lib/utils/lliquidity-math.d.ts +30 -30
- package/lib/utils/lliquidity-math.js +139 -139
- package/lib/utils/price-from-reserves.d.ts +2 -0
- package/lib/utils/price-from-reserves.js +19 -0
- package/package.json +36 -36
|
@@ -1,239 +1,239 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
const types_1 = require("../config/types");
|
|
13
|
-
// Map of OUR chains to the chain names used by llama in their `poolsOld`
|
|
14
|
-
const LlamaChains = {
|
|
15
|
-
[types_1.Networks.Ropsten]: "ropsten",
|
|
16
|
-
[types_1.Networks.Mainnet]: "ethereum",
|
|
17
|
-
[types_1.Networks.Polygon]: "polygon",
|
|
18
|
-
[types_1.Networks.Arbitrum]: "arbitrum",
|
|
19
|
-
[types_1.Networks.Avalanche]: "avalanche",
|
|
20
|
-
[types_1.Networks.Moonriver]: "moonriver",
|
|
21
|
-
[types_1.Networks.Aurora]: "aurora",
|
|
22
|
-
[types_1.Networks.Cronos]: "cronos",
|
|
23
|
-
[types_1.Networks.Fantom]: "fantom",
|
|
24
|
-
[types_1.Networks.Harmony]: "harmony",
|
|
25
|
-
[types_1.Networks.Moonbeam]: "moonbeam",
|
|
26
|
-
[types_1.Networks.Sxnetwork]: "sxnetwork",
|
|
27
|
-
[types_1.Networks.Canto]: "canto",
|
|
28
|
-
[types_1.Networks.ZksyncEra]: "zksync era",
|
|
29
|
-
[types_1.Networks.Base]: "base",
|
|
30
|
-
[types_1.Networks.Mantle]: "mantle",
|
|
31
|
-
[types_1.Networks.Scroll]: "scroll",
|
|
32
|
-
[types_1.Networks.Optimism]: "optimism",
|
|
33
|
-
[types_1.Networks.Real]: "re.al",
|
|
34
|
-
[types_1.Networks.Blast]: "blast",
|
|
35
|
-
};
|
|
36
|
-
// Class to get the APR from DefiLlama directly, only makes 1 call to api and caches all pools
|
|
37
|
-
class OffchainAPRHelper {
|
|
38
|
-
constructor(offchain) {
|
|
39
|
-
this.llamaAllPools = {};
|
|
40
|
-
this.initialized = null;
|
|
41
|
-
this.chainTvls = {};
|
|
42
|
-
this.tvlInitialized = null;
|
|
43
|
-
this.chainsTotalSupplied = {};
|
|
44
|
-
this.totalSuppliedInitialized = null;
|
|
45
|
-
// Charts
|
|
46
|
-
this.chainTvlCharts = {};
|
|
47
|
-
this.protocolTvlChart = [];
|
|
48
|
-
this.blacklistedProjects = new Set([
|
|
49
|
-
"extra-finance",
|
|
50
|
-
"beefy"
|
|
51
|
-
]);
|
|
52
|
-
this.offchain = offchain;
|
|
53
|
-
}
|
|
54
|
-
cleanCache() {
|
|
55
|
-
this.llamaAllPools = {};
|
|
56
|
-
this.initialized = null;
|
|
57
|
-
this.chainTvls = {};
|
|
58
|
-
this.tvlInitialized = null;
|
|
59
|
-
this.chainsTotalSupplied = {};
|
|
60
|
-
this.totalSuppliedInitialized = null;
|
|
61
|
-
}
|
|
62
|
-
// Blacklist certain projects which might report same pool as dex (aggregators, etc.)
|
|
63
|
-
// Reason we need this is that we want the DEX APR and not the APR of other projects
|
|
64
|
-
// using that same LP on their strategies, and sometimes pools_old from defillama
|
|
65
|
-
// shares lp address across different projects.
|
|
66
|
-
isBlacklisted(project) {
|
|
67
|
-
return this.blacklistedProjects.has(project);
|
|
68
|
-
}
|
|
69
|
-
// Initializes all llama pools
|
|
70
|
-
initializeYields() {
|
|
71
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
72
|
-
try {
|
|
73
|
-
const response = yield fetch("https://yields.llama.fi/poolsOld").then((i) => i.json());
|
|
74
|
-
const pools = response.data;
|
|
75
|
-
const filteredPools = pools.filter((i) => !this.isBlacklisted(i.project));
|
|
76
|
-
// i.pool_old is the pool address with sometimes -{chain} separator if
|
|
77
|
-
// contracts exists on diff chains
|
|
78
|
-
this.llamaAllPools = filteredPools.reduce((acc, i) => {
|
|
79
|
-
const pool = i.pool_old.split("-")[0];
|
|
80
|
-
const llamaChain = i.chain;
|
|
81
|
-
const llamaId = pool.concat("-", llamaChain).toLowerCase();
|
|
82
|
-
acc[llamaId] = i;
|
|
83
|
-
return acc;
|
|
84
|
-
}, {});
|
|
85
|
-
}
|
|
86
|
-
catch (err) {
|
|
87
|
-
console.warn("The llamas yields down?");
|
|
88
|
-
this.llamaAllPools = {};
|
|
89
|
-
}
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
// Initializes all our chain tvl and borrows from llama
|
|
93
|
-
initializeTvls() {
|
|
94
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
95
|
-
try {
|
|
96
|
-
const response = yield fetch("https://api.llama.fi/protocol/impermax-finance").then((i) => i.json());
|
|
97
|
-
// Simple TVL of all chains
|
|
98
|
-
const currentChainTvls = response.currentChainTvls;
|
|
99
|
-
// For charts of our tvl and tvl by chains
|
|
100
|
-
const chainTvlCharts = response.chainTvls;
|
|
101
|
-
const protocolTvlChart = response.tvl;
|
|
102
|
-
// Get the chain tvls
|
|
103
|
-
this.chainTvls = Object.entries(currentChainTvls).reduce((acc, [chain, tvl]) => {
|
|
104
|
-
acc[chain.toLowerCase()] = tvl;
|
|
105
|
-
return acc;
|
|
106
|
-
}, {});
|
|
107
|
-
// Get the chain tvls day data to build charts
|
|
108
|
-
this.chainTvlCharts = Object.entries(chainTvlCharts).reduce((acc, [chain, dayData]) => {
|
|
109
|
-
acc[chain.toLowerCase()] = dayData.tvl;
|
|
110
|
-
return acc;
|
|
111
|
-
}, {});
|
|
112
|
-
this.protocolTvlChart = protocolTvlChart;
|
|
113
|
-
}
|
|
114
|
-
catch (err) {
|
|
115
|
-
console.warn("The llamas TVL down?");
|
|
116
|
-
this.chainTvls = {};
|
|
117
|
-
this.protocolTvlChart = [];
|
|
118
|
-
this.chainTvlCharts = {};
|
|
119
|
-
}
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
// Initializes the `totalSupplyUsd` from our yields
|
|
123
|
-
initializePoolsBorrow() {
|
|
124
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
125
|
-
try {
|
|
126
|
-
const response = yield fetch("https://yields.llama.fi/poolsBorrow").then((i) => i.json());
|
|
127
|
-
const impermaxPools = response.data.filter((i) => i.project === 'impermax-finance');
|
|
128
|
-
this.chainsTotalSupplied = impermaxPools.reduce((acc, pool) => {
|
|
129
|
-
acc[pool.chain.toLowerCase()] = (acc[pool.chain.toLowerCase()] || 0) + pool.totalSupplyUsd;
|
|
130
|
-
return acc;
|
|
131
|
-
}, {});
|
|
132
|
-
}
|
|
133
|
-
catch (err) {
|
|
134
|
-
console.warn("The llamas poolsBorrow down?");
|
|
135
|
-
this.chainsTotalSupplied = {};
|
|
136
|
-
}
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
|
-
getLlamaYields() {
|
|
140
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
141
|
-
// First call initializes
|
|
142
|
-
if (!this.initialized)
|
|
143
|
-
this.initialized = this.initializeYields();
|
|
144
|
-
// async mutex to only call llama api once
|
|
145
|
-
yield this.initialized;
|
|
146
|
-
return this.llamaAllPools;
|
|
147
|
-
});
|
|
148
|
-
}
|
|
149
|
-
getLlamaTvls() {
|
|
150
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
151
|
-
// First call initializes
|
|
152
|
-
if (!this.tvlInitialized)
|
|
153
|
-
this.tvlInitialized = this.initializeTvls();
|
|
154
|
-
// async mutex to only call llama api once
|
|
155
|
-
yield this.tvlInitialized;
|
|
156
|
-
return this.chainTvls;
|
|
157
|
-
});
|
|
158
|
-
}
|
|
159
|
-
getChainsTotalSupplied() {
|
|
160
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
161
|
-
if (!this.totalSuppliedInitialized)
|
|
162
|
-
this.totalSuppliedInitialized = this.initializePoolsBorrow();
|
|
163
|
-
yield this.totalSuppliedInitialized;
|
|
164
|
-
return this.chainsTotalSupplied;
|
|
165
|
-
});
|
|
166
|
-
}
|
|
167
|
-
// ---------------- Getters ---------------- //
|
|
168
|
-
getLlamaAPR(pool, chain) {
|
|
169
|
-
var _a;
|
|
170
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
171
|
-
// Get or initialize the pools
|
|
172
|
-
const llamaAllPools = yield this.getLlamaYields();
|
|
173
|
-
// Map to llama chain names, if not supported, then fetch native way
|
|
174
|
-
const llamaChain = LlamaChains[chain];
|
|
175
|
-
if (!llamaChain)
|
|
176
|
-
return 0;
|
|
177
|
-
// Make pool unique ({poolAddress}-{chain})
|
|
178
|
-
const llamaId = pool.concat("-", llamaChain).toLowerCase();
|
|
179
|
-
// Convert to decimals to match `getUniswapAPR` and `getStakingAPR`
|
|
180
|
-
const apy = ((_a = llamaAllPools[llamaId]) === null || _a === void 0 ? void 0 : _a.apy) / 100;
|
|
181
|
-
// If 0 then should fetch native way to make sure
|
|
182
|
-
return apy || 0;
|
|
183
|
-
});
|
|
184
|
-
}
|
|
185
|
-
getLlamaTvlAndBorrows(chain) {
|
|
186
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
187
|
-
// Get or initialize the tvl for all chains
|
|
188
|
-
const [llamaTvls, totalSuppliedYields] = yield Promise.all([
|
|
189
|
-
this.getLlamaTvls(),
|
|
190
|
-
this.getChainsTotalSupplied()
|
|
191
|
-
]);
|
|
192
|
-
const llamaChain = LlamaChains[chain];
|
|
193
|
-
if (!llamaChain)
|
|
194
|
-
return { tvl: 0, borrowed: 0, totalSupplied: 0 };
|
|
195
|
-
const tvl = llamaTvls[llamaChain];
|
|
196
|
-
const borrowed = llamaTvls[llamaChain.concat("-borrowed")];
|
|
197
|
-
const totalSupplied = totalSuppliedYields[chain];
|
|
198
|
-
return { tvl, borrowed, totalSupplied };
|
|
199
|
-
});
|
|
200
|
-
}
|
|
201
|
-
// Overall Cross-chain stats
|
|
202
|
-
getImpermaxBorrows() {
|
|
203
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
204
|
-
const llamaTvls = yield this.getLlamaTvls();
|
|
205
|
-
return llamaTvls.borrowed;
|
|
206
|
-
});
|
|
207
|
-
}
|
|
208
|
-
getImpermaxTvl() {
|
|
209
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
210
|
-
const llamaTvls = yield this.getLlamaTvls();
|
|
211
|
-
let crossChainTvl = 0;
|
|
212
|
-
// LLama key is `{chain}` or `{chain}-borrowed`, need to manually add the tvl
|
|
213
|
-
for (const [chain, tvl] of Object.entries(llamaTvls)) {
|
|
214
|
-
if (!chain.includes("borrowed"))
|
|
215
|
-
crossChainTvl += tvl;
|
|
216
|
-
}
|
|
217
|
-
return crossChainTvl;
|
|
218
|
-
});
|
|
219
|
-
}
|
|
220
|
-
// Charts
|
|
221
|
-
// Impermax historic TVL chart
|
|
222
|
-
getProtocolTvlChart() {
|
|
223
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
224
|
-
// Initialize tvls
|
|
225
|
-
yield this.getLlamaTvls();
|
|
226
|
-
return this.protocolTvlChart;
|
|
227
|
-
});
|
|
228
|
-
}
|
|
229
|
-
// Impermax historic TVL chart by chain
|
|
230
|
-
getChainTvlChart(chain) {
|
|
231
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
232
|
-
// Initialize tvls
|
|
233
|
-
yield this.getLlamaTvls();
|
|
234
|
-
const llamaChain = LlamaChains[chain];
|
|
235
|
-
return this.chainTvlCharts[llamaChain];
|
|
236
|
-
});
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
exports.default = OffchainAPRHelper;
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
const types_1 = require("../config/types");
|
|
13
|
+
// Map of OUR chains to the chain names used by llama in their `poolsOld`
|
|
14
|
+
const LlamaChains = {
|
|
15
|
+
[types_1.Networks.Ropsten]: "ropsten",
|
|
16
|
+
[types_1.Networks.Mainnet]: "ethereum",
|
|
17
|
+
[types_1.Networks.Polygon]: "polygon",
|
|
18
|
+
[types_1.Networks.Arbitrum]: "arbitrum",
|
|
19
|
+
[types_1.Networks.Avalanche]: "avalanche",
|
|
20
|
+
[types_1.Networks.Moonriver]: "moonriver",
|
|
21
|
+
[types_1.Networks.Aurora]: "aurora",
|
|
22
|
+
[types_1.Networks.Cronos]: "cronos",
|
|
23
|
+
[types_1.Networks.Fantom]: "fantom",
|
|
24
|
+
[types_1.Networks.Harmony]: "harmony",
|
|
25
|
+
[types_1.Networks.Moonbeam]: "moonbeam",
|
|
26
|
+
[types_1.Networks.Sxnetwork]: "sxnetwork",
|
|
27
|
+
[types_1.Networks.Canto]: "canto",
|
|
28
|
+
[types_1.Networks.ZksyncEra]: "zksync era",
|
|
29
|
+
[types_1.Networks.Base]: "base",
|
|
30
|
+
[types_1.Networks.Mantle]: "mantle",
|
|
31
|
+
[types_1.Networks.Scroll]: "scroll",
|
|
32
|
+
[types_1.Networks.Optimism]: "optimism",
|
|
33
|
+
[types_1.Networks.Real]: "re.al",
|
|
34
|
+
[types_1.Networks.Blast]: "blast",
|
|
35
|
+
};
|
|
36
|
+
// Class to get the APR from DefiLlama directly, only makes 1 call to api and caches all pools
|
|
37
|
+
class OffchainAPRHelper {
|
|
38
|
+
constructor(offchain) {
|
|
39
|
+
this.llamaAllPools = {};
|
|
40
|
+
this.initialized = null;
|
|
41
|
+
this.chainTvls = {};
|
|
42
|
+
this.tvlInitialized = null;
|
|
43
|
+
this.chainsTotalSupplied = {};
|
|
44
|
+
this.totalSuppliedInitialized = null;
|
|
45
|
+
// Charts
|
|
46
|
+
this.chainTvlCharts = {};
|
|
47
|
+
this.protocolTvlChart = [];
|
|
48
|
+
this.blacklistedProjects = new Set([
|
|
49
|
+
"extra-finance",
|
|
50
|
+
"beefy"
|
|
51
|
+
]);
|
|
52
|
+
this.offchain = offchain;
|
|
53
|
+
}
|
|
54
|
+
cleanCache() {
|
|
55
|
+
this.llamaAllPools = {};
|
|
56
|
+
this.initialized = null;
|
|
57
|
+
this.chainTvls = {};
|
|
58
|
+
this.tvlInitialized = null;
|
|
59
|
+
this.chainsTotalSupplied = {};
|
|
60
|
+
this.totalSuppliedInitialized = null;
|
|
61
|
+
}
|
|
62
|
+
// Blacklist certain projects which might report same pool as dex (aggregators, etc.)
|
|
63
|
+
// Reason we need this is that we want the DEX APR and not the APR of other projects
|
|
64
|
+
// using that same LP on their strategies, and sometimes pools_old from defillama
|
|
65
|
+
// shares lp address across different projects.
|
|
66
|
+
isBlacklisted(project) {
|
|
67
|
+
return this.blacklistedProjects.has(project);
|
|
68
|
+
}
|
|
69
|
+
// Initializes all llama pools
|
|
70
|
+
initializeYields() {
|
|
71
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
72
|
+
try {
|
|
73
|
+
const response = yield fetch("https://yields.llama.fi/poolsOld").then((i) => i.json());
|
|
74
|
+
const pools = response.data;
|
|
75
|
+
const filteredPools = pools.filter((i) => !this.isBlacklisted(i.project));
|
|
76
|
+
// i.pool_old is the pool address with sometimes -{chain} separator if
|
|
77
|
+
// contracts exists on diff chains
|
|
78
|
+
this.llamaAllPools = filteredPools.reduce((acc, i) => {
|
|
79
|
+
const pool = i.pool_old.split("-")[0];
|
|
80
|
+
const llamaChain = i.chain;
|
|
81
|
+
const llamaId = pool.concat("-", llamaChain).toLowerCase();
|
|
82
|
+
acc[llamaId] = i;
|
|
83
|
+
return acc;
|
|
84
|
+
}, {});
|
|
85
|
+
}
|
|
86
|
+
catch (err) {
|
|
87
|
+
console.warn("The llamas yields down?");
|
|
88
|
+
this.llamaAllPools = {};
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
// Initializes all our chain tvl and borrows from llama
|
|
93
|
+
initializeTvls() {
|
|
94
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
95
|
+
try {
|
|
96
|
+
const response = yield fetch("https://api.llama.fi/protocol/impermax-finance").then((i) => i.json());
|
|
97
|
+
// Simple TVL of all chains
|
|
98
|
+
const currentChainTvls = response.currentChainTvls;
|
|
99
|
+
// For charts of our tvl and tvl by chains
|
|
100
|
+
const chainTvlCharts = response.chainTvls;
|
|
101
|
+
const protocolTvlChart = response.tvl;
|
|
102
|
+
// Get the chain tvls
|
|
103
|
+
this.chainTvls = Object.entries(currentChainTvls).reduce((acc, [chain, tvl]) => {
|
|
104
|
+
acc[chain.toLowerCase()] = tvl;
|
|
105
|
+
return acc;
|
|
106
|
+
}, {});
|
|
107
|
+
// Get the chain tvls day data to build charts
|
|
108
|
+
this.chainTvlCharts = Object.entries(chainTvlCharts).reduce((acc, [chain, dayData]) => {
|
|
109
|
+
acc[chain.toLowerCase()] = dayData.tvl;
|
|
110
|
+
return acc;
|
|
111
|
+
}, {});
|
|
112
|
+
this.protocolTvlChart = protocolTvlChart;
|
|
113
|
+
}
|
|
114
|
+
catch (err) {
|
|
115
|
+
console.warn("The llamas TVL down?");
|
|
116
|
+
this.chainTvls = {};
|
|
117
|
+
this.protocolTvlChart = [];
|
|
118
|
+
this.chainTvlCharts = {};
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
// Initializes the `totalSupplyUsd` from our yields
|
|
123
|
+
initializePoolsBorrow() {
|
|
124
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
125
|
+
try {
|
|
126
|
+
const response = yield fetch("https://yields.llama.fi/poolsBorrow").then((i) => i.json());
|
|
127
|
+
const impermaxPools = response.data.filter((i) => i.project === 'impermax-finance');
|
|
128
|
+
this.chainsTotalSupplied = impermaxPools.reduce((acc, pool) => {
|
|
129
|
+
acc[pool.chain.toLowerCase()] = (acc[pool.chain.toLowerCase()] || 0) + pool.totalSupplyUsd;
|
|
130
|
+
return acc;
|
|
131
|
+
}, {});
|
|
132
|
+
}
|
|
133
|
+
catch (err) {
|
|
134
|
+
console.warn("The llamas poolsBorrow down?");
|
|
135
|
+
this.chainsTotalSupplied = {};
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
getLlamaYields() {
|
|
140
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
141
|
+
// First call initializes
|
|
142
|
+
if (!this.initialized)
|
|
143
|
+
this.initialized = this.initializeYields();
|
|
144
|
+
// async mutex to only call llama api once
|
|
145
|
+
yield this.initialized;
|
|
146
|
+
return this.llamaAllPools;
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
getLlamaTvls() {
|
|
150
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
151
|
+
// First call initializes
|
|
152
|
+
if (!this.tvlInitialized)
|
|
153
|
+
this.tvlInitialized = this.initializeTvls();
|
|
154
|
+
// async mutex to only call llama api once
|
|
155
|
+
yield this.tvlInitialized;
|
|
156
|
+
return this.chainTvls;
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
getChainsTotalSupplied() {
|
|
160
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
161
|
+
if (!this.totalSuppliedInitialized)
|
|
162
|
+
this.totalSuppliedInitialized = this.initializePoolsBorrow();
|
|
163
|
+
yield this.totalSuppliedInitialized;
|
|
164
|
+
return this.chainsTotalSupplied;
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
// ---------------- Getters ---------------- //
|
|
168
|
+
getLlamaAPR(pool, chain) {
|
|
169
|
+
var _a;
|
|
170
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
171
|
+
// Get or initialize the pools
|
|
172
|
+
const llamaAllPools = yield this.getLlamaYields();
|
|
173
|
+
// Map to llama chain names, if not supported, then fetch native way
|
|
174
|
+
const llamaChain = LlamaChains[chain];
|
|
175
|
+
if (!llamaChain)
|
|
176
|
+
return 0;
|
|
177
|
+
// Make pool unique ({poolAddress}-{chain})
|
|
178
|
+
const llamaId = pool.concat("-", llamaChain).toLowerCase();
|
|
179
|
+
// Convert to decimals to match `getUniswapAPR` and `getStakingAPR`
|
|
180
|
+
const apy = ((_a = llamaAllPools[llamaId]) === null || _a === void 0 ? void 0 : _a.apy) / 100;
|
|
181
|
+
// If 0 then should fetch native way to make sure
|
|
182
|
+
return apy || 0;
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
getLlamaTvlAndBorrows(chain) {
|
|
186
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
187
|
+
// Get or initialize the tvl for all chains
|
|
188
|
+
const [llamaTvls, totalSuppliedYields] = yield Promise.all([
|
|
189
|
+
this.getLlamaTvls(),
|
|
190
|
+
this.getChainsTotalSupplied()
|
|
191
|
+
]);
|
|
192
|
+
const llamaChain = LlamaChains[chain];
|
|
193
|
+
if (!llamaChain)
|
|
194
|
+
return { tvl: 0, borrowed: 0, totalSupplied: 0 };
|
|
195
|
+
const tvl = llamaTvls[llamaChain];
|
|
196
|
+
const borrowed = llamaTvls[llamaChain.concat("-borrowed")];
|
|
197
|
+
const totalSupplied = totalSuppliedYields[chain];
|
|
198
|
+
return { tvl, borrowed, totalSupplied };
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
// Overall Cross-chain stats
|
|
202
|
+
getImpermaxBorrows() {
|
|
203
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
204
|
+
const llamaTvls = yield this.getLlamaTvls();
|
|
205
|
+
return llamaTvls.borrowed;
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
getImpermaxTvl() {
|
|
209
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
210
|
+
const llamaTvls = yield this.getLlamaTvls();
|
|
211
|
+
let crossChainTvl = 0;
|
|
212
|
+
// LLama key is `{chain}` or `{chain}-borrowed`, need to manually add the tvl
|
|
213
|
+
for (const [chain, tvl] of Object.entries(llamaTvls)) {
|
|
214
|
+
if (!chain.includes("borrowed"))
|
|
215
|
+
crossChainTvl += tvl;
|
|
216
|
+
}
|
|
217
|
+
return crossChainTvl;
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
// Charts
|
|
221
|
+
// Impermax historic TVL chart
|
|
222
|
+
getProtocolTvlChart() {
|
|
223
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
224
|
+
// Initialize tvls
|
|
225
|
+
yield this.getLlamaTvls();
|
|
226
|
+
return this.protocolTvlChart;
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
// Impermax historic TVL chart by chain
|
|
230
|
+
getChainTvlChart(chain) {
|
|
231
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
232
|
+
// Initialize tvls
|
|
233
|
+
yield this.getLlamaTvls();
|
|
234
|
+
const llamaChain = LlamaChains[chain];
|
|
235
|
+
return this.chainTvlCharts[llamaChain];
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
exports.default = OffchainAPRHelper;
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import { DocumentNode } from "graphql";
|
|
2
|
-
import { IQueryBuilder } from "./queries/interfaces/query-builder";
|
|
3
|
-
import { Networks } from "../config/types";
|
|
4
|
-
export default class OffchainEndpointManager {
|
|
5
|
-
private endpoint;
|
|
6
|
-
constructor();
|
|
7
|
-
/**
|
|
8
|
-
* Main fetcher function to query from multiple endpoints. The query MUST have _meta included.
|
|
9
|
-
*
|
|
10
|
-
* @param endpoints - Array of endpoints
|
|
11
|
-
* @param network - The network of the request (needed for the block due to ponder's `_meta` result)
|
|
12
|
-
* @param queryBuilder - The query requested from IQueryBuilder interface (ie. `lendingPoolQuery`, `tvlQuery`, etc.)
|
|
13
|
-
*/
|
|
14
|
-
fetch(endpoints: string[], network: Networks, queryBuilder: (builder: IQueryBuilder) => DocumentNode): Promise<any>;
|
|
15
|
-
/**
|
|
16
|
-
* Fetch a query from an endpoint (ponder, thegraph, etc.)
|
|
17
|
-
*/
|
|
18
|
-
private fetchFromEndpoint;
|
|
19
|
-
/**
|
|
20
|
-
* Given an array of responses from endpoint query, get the response wiht the latest block number
|
|
21
|
-
*/
|
|
22
|
-
private bestEndpointBlock;
|
|
23
|
-
private filterEndpoints;
|
|
24
|
-
private getPreferredEndpoint;
|
|
25
|
-
}
|
|
1
|
+
import { DocumentNode } from "graphql";
|
|
2
|
+
import { IQueryBuilder } from "./queries/interfaces/query-builder";
|
|
3
|
+
import { Networks } from "../config/types";
|
|
4
|
+
export default class OffchainEndpointManager {
|
|
5
|
+
private endpoint;
|
|
6
|
+
constructor();
|
|
7
|
+
/**
|
|
8
|
+
* Main fetcher function to query from multiple endpoints. The query MUST have _meta included.
|
|
9
|
+
*
|
|
10
|
+
* @param endpoints - Array of endpoints
|
|
11
|
+
* @param network - The network of the request (needed for the block due to ponder's `_meta` result)
|
|
12
|
+
* @param queryBuilder - The query requested from IQueryBuilder interface (ie. `lendingPoolQuery`, `tvlQuery`, etc.)
|
|
13
|
+
*/
|
|
14
|
+
fetch(endpoints: string[], network: Networks, queryBuilder: (builder: IQueryBuilder) => DocumentNode): Promise<any>;
|
|
15
|
+
/**
|
|
16
|
+
* Fetch a query from an endpoint (ponder, thegraph, etc.)
|
|
17
|
+
*/
|
|
18
|
+
private fetchFromEndpoint;
|
|
19
|
+
/**
|
|
20
|
+
* Given an array of responses from endpoint query, get the response wiht the latest block number
|
|
21
|
+
*/
|
|
22
|
+
private bestEndpointBlock;
|
|
23
|
+
private filterEndpoints;
|
|
24
|
+
private getPreferredEndpoint;
|
|
25
|
+
}
|