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
|
@@ -0,0 +1,338 @@
|
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const types_1 = require("../../../config/types");
|
|
16
|
+
const factories_1 = require("../../../config/factories");
|
|
17
|
+
const lliquidity_math_1 = require("../../../utils/lliquidity-math");
|
|
18
|
+
const onchainLendingPool_1 = __importDefault(require("./onchainLendingPool"));
|
|
19
|
+
const onchainCollateralV2_1 = __importDefault(require("./onchainCollateralV2"));
|
|
20
|
+
const onchainBorrowableV2_1 = __importDefault(require("./onchainBorrowableV2"));
|
|
21
|
+
const lendingPool_1 = require("../../account/lendingPool");
|
|
22
|
+
const onchainInteractionsLendingPoolV2_1 = __importDefault(require("../../interactions/lendingPool/onchainInteractionsLendingPoolV2"));
|
|
23
|
+
class OnchainLendingPoolV2 extends onchainLendingPool_1.default {
|
|
24
|
+
constructor() {
|
|
25
|
+
super(...arguments);
|
|
26
|
+
this.cache = {};
|
|
27
|
+
// Shortcuts
|
|
28
|
+
this.getBorrowable = (borrowable) => this.borrowables[borrowable];
|
|
29
|
+
this.getBorrowableA = () => this.getBorrowable(types_1.Borrowable.A);
|
|
30
|
+
this.getBorrowableB = () => this.getBorrowable(types_1.Borrowable.B);
|
|
31
|
+
this.getCollateral = () => this.collateral;
|
|
32
|
+
}
|
|
33
|
+
getNewCollateralObject() {
|
|
34
|
+
return new onchainCollateralV2_1.default(this);
|
|
35
|
+
}
|
|
36
|
+
getNewBorrowableObject(borrowable) {
|
|
37
|
+
return new onchainBorrowableV2_1.default(this, borrowable);
|
|
38
|
+
}
|
|
39
|
+
getNewAccountLendingPoolObject(account) {
|
|
40
|
+
return new lendingPool_1.OnchainAccountLendingPoolV2(account, this);
|
|
41
|
+
}
|
|
42
|
+
getNewInteractionLendingPoolObject(interactions) {
|
|
43
|
+
return new onchainInteractionsLendingPoolV2_1.default(interactions, this);
|
|
44
|
+
}
|
|
45
|
+
// Lending Pool V2 functions
|
|
46
|
+
initializeIsStakedLPToken() {
|
|
47
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
48
|
+
try {
|
|
49
|
+
return yield this.impermaxFactory.getRouter().methods.isStakedLPToken(this.id).call();
|
|
50
|
+
}
|
|
51
|
+
catch (e) {
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
getIsStakedLPToken() {
|
|
57
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
58
|
+
if (!this.cache.isStakedLPToken)
|
|
59
|
+
this.cache.isStakedLPToken = this.initializeIsStakedLPToken();
|
|
60
|
+
return this.cache.isStakedLPToken;
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
initializeStakedLPToken() {
|
|
64
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
65
|
+
if (!(yield this.getIsStakedLPToken()))
|
|
66
|
+
return null;
|
|
67
|
+
return this.getContractHelper().newStakedLPToken(this.id);
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
getStakedLPToken() {
|
|
71
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
72
|
+
if (!this.cache.stakedLPToken)
|
|
73
|
+
this.cache.stakedLPToken = this.initializeStakedLPToken();
|
|
74
|
+
return this.cache.stakedLPToken;
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
initializeUniswapV2Pair() {
|
|
78
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
79
|
+
const stakedLPToken = yield this.getStakedLPToken();
|
|
80
|
+
return this.getContractHelper().newUniswapV2Pair(stakedLPToken
|
|
81
|
+
? yield (stakedLPToken.methods.underlying().call())
|
|
82
|
+
: this.id);
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
getUniswapV2Pair() {
|
|
86
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
87
|
+
if (!this.cache.uniswapV2Pair)
|
|
88
|
+
this.cache.uniswapV2Pair = this.initializeUniswapV2Pair();
|
|
89
|
+
return this.cache.uniswapV2Pair;
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
// Reserves
|
|
93
|
+
initializeReserves() {
|
|
94
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
95
|
+
const uniswapV2Pair = yield this.getUniswapV2Pair();
|
|
96
|
+
const { reserve0, reserve1 } = yield uniswapV2Pair.methods.getReserves().call();
|
|
97
|
+
return [
|
|
98
|
+
yield this.getBorrowableA().normalize(reserve0),
|
|
99
|
+
yield this.getBorrowableB().normalize(reserve1),
|
|
100
|
+
];
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
getReserves() {
|
|
104
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
105
|
+
if (!this.cache.reserves)
|
|
106
|
+
this.cache.reserves = this.initializeReserves();
|
|
107
|
+
return this.cache.reserves;
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
// LP Total Supply
|
|
111
|
+
initializeLPTotalSupply() {
|
|
112
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
113
|
+
const uniswapV2Pair = yield this.getUniswapV2Pair();
|
|
114
|
+
const totalSupply = yield uniswapV2Pair.methods.totalSupply().call();
|
|
115
|
+
return this.getCollateral().normalize(totalSupply);
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
getLPTotalSupply() {
|
|
119
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
120
|
+
if (!this.cache.LPTotalSupply)
|
|
121
|
+
this.cache.LPTotalSupply = this.initializeLPTotalSupply();
|
|
122
|
+
return this.cache.LPTotalSupply;
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
// Price Denom LP
|
|
126
|
+
initializePriceDenomLP() {
|
|
127
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
128
|
+
const collateral = yield this.getCollateral().getPoolToken();
|
|
129
|
+
const { price0, price1 } = yield collateral.methods.getPrices().call();
|
|
130
|
+
const decimalsA = yield this.getBorrowableA().getDecimals();
|
|
131
|
+
const decimalsB = yield this.getBorrowableB().getDecimals();
|
|
132
|
+
let stakedLPExchangeRate = yield this.getStakedLPExchangeRate();
|
|
133
|
+
return [
|
|
134
|
+
price0 / 1e18 / 1e18 * Math.pow(10, decimalsA) * stakedLPExchangeRate,
|
|
135
|
+
price1 / 1e18 / 1e18 * Math.pow(10, decimalsB) * stakedLPExchangeRate
|
|
136
|
+
];
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
getPriceDenomLP() {
|
|
140
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
141
|
+
if (!this.cache.priceDenomLP)
|
|
142
|
+
this.cache.priceDenomLP = this.initializePriceDenomLP();
|
|
143
|
+
return this.cache.priceDenomLP;
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
getMarketPriceDenomLP() {
|
|
147
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
148
|
+
const [reserve0, reserve1] = yield this.getReserves();
|
|
149
|
+
const totalSupply = yield this.getLPTotalSupply();
|
|
150
|
+
const [reservesWeight0, reservesWeight1] = yield this.getMarketReservesWeights();
|
|
151
|
+
return [
|
|
152
|
+
totalSupply / reserve0 * reservesWeight0,
|
|
153
|
+
totalSupply / reserve1 * reservesWeight1,
|
|
154
|
+
];
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
// Market Price
|
|
158
|
+
getMarketPrice() {
|
|
159
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
160
|
+
const [reserve0, reserve1] = yield this.getReserves();
|
|
161
|
+
const priceInverted = this.impermaxFactory.getOnchain().priceInverted;
|
|
162
|
+
if (factories_1.STABLE_FACTORIES.includes(this.impermaxFactory.getFactory()))
|
|
163
|
+
return (0, lliquidity_math_1.solidlyStable_getPriceFromReserves)(reserve0, reserve1, priceInverted);
|
|
164
|
+
else
|
|
165
|
+
return (0, lliquidity_math_1.uniswapV2_getPriceFromReserves)(reserve0, reserve1, priceInverted);
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
// Value of reserveA / reserveB
|
|
169
|
+
initializeTwapReservesValueRatio() {
|
|
170
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
171
|
+
if (factories_1.STABLE_FACTORIES.includes(this.impermaxFactory.getFactory())) {
|
|
172
|
+
const collateral = yield this.getCollateral().getPoolToken();
|
|
173
|
+
let { twapReserve0, twapReserve1 } = yield collateral.methods.getTwapReserves().call();
|
|
174
|
+
const [price0, price1] = yield this.getPriceDenomLP();
|
|
175
|
+
twapReserve0 = yield this.getBorrowableA().normalize(twapReserve0);
|
|
176
|
+
twapReserve1 = yield this.getBorrowableB().normalize(twapReserve1);
|
|
177
|
+
return twapReserve0 * price0 / (twapReserve1 * price1);
|
|
178
|
+
}
|
|
179
|
+
else {
|
|
180
|
+
return 1;
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
getTwapReservesValueRatio() {
|
|
185
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
186
|
+
if (!this.cache.twapReservesValueRatio)
|
|
187
|
+
this.cache.twapReservesValueRatio = this.initializeTwapReservesValueRatio();
|
|
188
|
+
return this.cache.twapReservesValueRatio;
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
getTwapReservesWeights() {
|
|
192
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
193
|
+
const reservesRatio = yield this.getTwapReservesValueRatio();
|
|
194
|
+
const reservesWeight0 = reservesRatio / (1 + reservesRatio);
|
|
195
|
+
const reservesWeight1 = 1 / (1 + reservesRatio);
|
|
196
|
+
return [reservesWeight0, reservesWeight1];
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
initializeMarketReservesValueRatio() {
|
|
200
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
201
|
+
if (factories_1.STABLE_FACTORIES.includes(this.impermaxFactory.getFactory())) {
|
|
202
|
+
const [reserve0, reserve1] = yield this.getReserves();
|
|
203
|
+
const price = (0, lliquidity_math_1.solidlyStable_getPriceFromReserves)(reserve0, reserve1);
|
|
204
|
+
return reserve0 * price / reserve1;
|
|
205
|
+
}
|
|
206
|
+
else {
|
|
207
|
+
return 1;
|
|
208
|
+
}
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
getMarketReservesValueRatio() {
|
|
212
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
213
|
+
if (!this.cache.marketReservesValueRatio)
|
|
214
|
+
this.cache.marketReservesValueRatio = this.initializeMarketReservesValueRatio();
|
|
215
|
+
return this.cache.marketReservesValueRatio;
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
getMarketReservesWeights() {
|
|
219
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
220
|
+
const reservesRatio = yield this.getMarketReservesValueRatio();
|
|
221
|
+
const reservesWeight0 = reservesRatio / (1 + reservesRatio);
|
|
222
|
+
const reservesWeight1 = 1 / (1 + reservesRatio);
|
|
223
|
+
return [reservesWeight0, reservesWeight1];
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
// TWAP Price
|
|
227
|
+
initializeTWAPPrice() {
|
|
228
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
229
|
+
try {
|
|
230
|
+
const collateral = yield this.getCollateral().getPoolToken();
|
|
231
|
+
const decimalsA = yield this.getBorrowableA().getDecimals();
|
|
232
|
+
const decimalsB = yield this.getBorrowableB().getDecimals();
|
|
233
|
+
if (factories_1.STABLE_FACTORIES.includes(this.impermaxFactory.getFactory())) {
|
|
234
|
+
const { twapReserve0, twapReserve1 } = yield collateral.methods.getTwapReserves().call();
|
|
235
|
+
return (0, lliquidity_math_1.solidlyStable_getPriceFromReserves)(twapReserve0 / Math.pow(10, decimalsA), twapReserve1 / Math.pow(10, decimalsB));
|
|
236
|
+
}
|
|
237
|
+
let price;
|
|
238
|
+
if (factories_1.SOLIDEX_FACTORIES.includes(this.impermaxFactory.getFactory())) {
|
|
239
|
+
price = yield collateral.methods.getTwapPrice112x112().call();
|
|
240
|
+
}
|
|
241
|
+
else {
|
|
242
|
+
price = (yield this.impermaxFactory.getSimpleUniswapOracle().methods.getResult(this.id).call()).price;
|
|
243
|
+
}
|
|
244
|
+
return price / Math.pow(2, 112) * Math.pow(10, decimalsA) / Math.pow(10, decimalsB);
|
|
245
|
+
}
|
|
246
|
+
catch (e) {
|
|
247
|
+
// Oracle is not initialized yet
|
|
248
|
+
return 0;
|
|
249
|
+
}
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
getTWAPPrice() {
|
|
253
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
254
|
+
if (!this.cache.TWAPPrice)
|
|
255
|
+
this.cache.TWAPPrice = this.initializeTWAPPrice();
|
|
256
|
+
return !this.impermaxFactory.getOnchain().priceInverted ? (yield this.cache.TWAPPrice) : 1 / (yield this.cache.TWAPPrice);
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
// Exchange rate
|
|
260
|
+
initializeStakedLPExchangeRate() {
|
|
261
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
262
|
+
const stakedLPToken = yield this.getStakedLPToken();
|
|
263
|
+
if (!stakedLPToken)
|
|
264
|
+
return 1;
|
|
265
|
+
return (yield stakedLPToken.methods.exchangeRate().call()) / 1e18;
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
getStakedLPExchangeRate() {
|
|
269
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
270
|
+
if (!this.cache.stakedLPExchangeRate)
|
|
271
|
+
this.cache.stakedLPExchangeRate = this.initializeStakedLPExchangeRate();
|
|
272
|
+
return this.cache.stakedLPExchangeRate;
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
// Pending Reward
|
|
276
|
+
initializePendingReward() {
|
|
277
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
278
|
+
const stakedLPToken = yield this.getStakedLPToken();
|
|
279
|
+
if (!stakedLPToken)
|
|
280
|
+
return null;
|
|
281
|
+
const rewardTokenAddress = yield stakedLPToken.methods.rewardsToken().call();
|
|
282
|
+
const rewardToken = this.getContractHelper().newERC20(rewardTokenAddress);
|
|
283
|
+
const decimals = yield rewardToken.methods.decimals().call();
|
|
284
|
+
let result = {
|
|
285
|
+
amount: 0,
|
|
286
|
+
symbol: yield rewardToken.methods.symbol().call(),
|
|
287
|
+
};
|
|
288
|
+
try {
|
|
289
|
+
const pendingReward = yield stakedLPToken.methods.getReward().call();
|
|
290
|
+
result.amount = pendingReward / Math.pow(10, decimals);
|
|
291
|
+
}
|
|
292
|
+
catch (_a) {
|
|
293
|
+
try {
|
|
294
|
+
const stakingRewardsAddress = yield stakedLPToken.methods.stakingRewards().call();
|
|
295
|
+
const stakingRewards = this.getContractHelper().newStakingRewards(stakingRewardsAddress);
|
|
296
|
+
const earned = yield stakingRewards.methods.earned(stakedLPToken._address).call();
|
|
297
|
+
result.amount = earned / Math.pow(10, decimals);
|
|
298
|
+
}
|
|
299
|
+
catch (_b) { }
|
|
300
|
+
}
|
|
301
|
+
return result;
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
getPendingReward() {
|
|
305
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
306
|
+
if (!this.cache.pendingReward)
|
|
307
|
+
this.cache.pendingReward = this.initializePendingReward();
|
|
308
|
+
return this.cache.pendingReward;
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
// Reinvest Bounty Factor
|
|
312
|
+
initializeReinvestBountyFactor() {
|
|
313
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
314
|
+
const stakedLPToken = yield this.getStakedLPToken();
|
|
315
|
+
if (!stakedLPToken)
|
|
316
|
+
return 0;
|
|
317
|
+
return (yield stakedLPToken.methods.REINVEST_BOUNTY().call()) / 1e18;
|
|
318
|
+
});
|
|
319
|
+
}
|
|
320
|
+
getReinvestBountyFactor() {
|
|
321
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
322
|
+
if (!this.cache.reinvestBountyFactor)
|
|
323
|
+
this.cache.reinvestBountyFactor = this.initializeReinvestBountyFactor();
|
|
324
|
+
return this.cache.reinvestBountyFactor;
|
|
325
|
+
});
|
|
326
|
+
}
|
|
327
|
+
// Reinvest Bounty
|
|
328
|
+
getReinvestBounty() {
|
|
329
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
330
|
+
const pendingReward = yield this.getPendingReward();
|
|
331
|
+
if (!pendingReward)
|
|
332
|
+
return 0;
|
|
333
|
+
const reinvestBountyFactor = yield this.getReinvestBountyFactor();
|
|
334
|
+
return pendingReward.amount * reinvestBountyFactor;
|
|
335
|
+
});
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
exports.default = OnchainLendingPoolV2;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Address, Borrowable } from '../../../config/types';
|
|
2
|
+
import { Contract } from '../../onchainTypes';
|
|
3
|
+
import OnchainLendingPool from "./onchainLendingPool";
|
|
4
|
+
import { OnchainAccountLendingPoolV3 } from "../../account/lendingPool";
|
|
5
|
+
import OnchainAccount from "../../account";
|
|
6
|
+
import OnchainInteractions from "../../interactions";
|
|
7
|
+
import OnchainImpermaxFactoryV3 from "../onchainImpermaxFactoryV3";
|
|
8
|
+
import OnchainCollateralV3 from './onchainCollateralV3';
|
|
9
|
+
import OnchainBorrowableV3 from "./onchainBorrowableV3";
|
|
10
|
+
import { OnchainInteractionsLendingPoolV3 } from "../../interactions/lendingPool";
|
|
11
|
+
import OnchainImpermaxFactory from "../index";
|
|
12
|
+
import OnchainNftlp from "./nftlp";
|
|
13
|
+
export default class OnchainLendingPoolV3 extends OnchainLendingPool {
|
|
14
|
+
protected readonly impermaxFactory: OnchainImpermaxFactoryV3;
|
|
15
|
+
protected readonly collateral: OnchainCollateralV3;
|
|
16
|
+
protected readonly borrowables: {
|
|
17
|
+
[Borrowable.A]: OnchainBorrowableV3;
|
|
18
|
+
[Borrowable.B]: OnchainBorrowableV3;
|
|
19
|
+
};
|
|
20
|
+
protected readonly nftlp: OnchainNftlp;
|
|
21
|
+
protected cache: {
|
|
22
|
+
lendingPoolAddresses?: Promise<{
|
|
23
|
+
collateral: Address;
|
|
24
|
+
borrowables: {
|
|
25
|
+
[key in Borrowable]: Address;
|
|
26
|
+
};
|
|
27
|
+
}>;
|
|
28
|
+
uniswapV2Pair?: Promise<Contract>;
|
|
29
|
+
marketPrice?: Promise<number>;
|
|
30
|
+
TWAPPrice?: Promise<number>;
|
|
31
|
+
};
|
|
32
|
+
constructor(impermaxFactory: OnchainImpermaxFactory, id: Address);
|
|
33
|
+
protected getNewCollateralObject(): OnchainCollateralV3;
|
|
34
|
+
protected getNewBorrowableObject(borrowable: Borrowable): OnchainBorrowableV3;
|
|
35
|
+
getNewAccountLendingPoolObject(account: OnchainAccount): OnchainAccountLendingPoolV3;
|
|
36
|
+
getNewInteractionLendingPoolObject(interactions: OnchainInteractions): OnchainInteractionsLendingPoolV3;
|
|
37
|
+
getBorrowable: (borrowable: Borrowable) => OnchainBorrowableV3;
|
|
38
|
+
getBorrowableA: () => OnchainBorrowableV3;
|
|
39
|
+
getBorrowableB: () => OnchainBorrowableV3;
|
|
40
|
+
getCollateral: () => OnchainCollateralV3;
|
|
41
|
+
getNftlp: () => OnchainNftlp;
|
|
42
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const types_1 = require("../../../config/types");
|
|
7
|
+
const onchainLendingPool_1 = __importDefault(require("./onchainLendingPool"));
|
|
8
|
+
const lendingPool_1 = require("../../account/lendingPool");
|
|
9
|
+
const onchainCollateralV3_1 = __importDefault(require("./onchainCollateralV3"));
|
|
10
|
+
const onchainBorrowableV3_1 = __importDefault(require("./onchainBorrowableV3"));
|
|
11
|
+
const lendingPool_2 = require("../../interactions/lendingPool");
|
|
12
|
+
const nftlp_1 = require("./nftlp");
|
|
13
|
+
class OnchainLendingPoolV3 extends onchainLendingPool_1.default {
|
|
14
|
+
constructor(impermaxFactory, id) {
|
|
15
|
+
super(impermaxFactory, id);
|
|
16
|
+
this.cache = {};
|
|
17
|
+
// Shortcuts
|
|
18
|
+
this.getBorrowable = (borrowable) => this.borrowables[borrowable];
|
|
19
|
+
this.getBorrowableA = () => this.getBorrowable(types_1.Borrowable.A);
|
|
20
|
+
this.getBorrowableB = () => this.getBorrowable(types_1.Borrowable.B);
|
|
21
|
+
this.getCollateral = () => this.collateral;
|
|
22
|
+
this.getNftlp = () => this.nftlp;
|
|
23
|
+
// TODO use the offchain object to get the type of nftlp
|
|
24
|
+
this.nftlp = new nftlp_1.OnchainNftlpUniswapV3(this);
|
|
25
|
+
}
|
|
26
|
+
getNewCollateralObject() {
|
|
27
|
+
return new onchainCollateralV3_1.default(this);
|
|
28
|
+
}
|
|
29
|
+
getNewBorrowableObject(borrowable) {
|
|
30
|
+
return new onchainBorrowableV3_1.default(this, borrowable);
|
|
31
|
+
}
|
|
32
|
+
getNewAccountLendingPoolObject(account) {
|
|
33
|
+
return new lendingPool_1.OnchainAccountLendingPoolV3(account, this);
|
|
34
|
+
}
|
|
35
|
+
getNewInteractionLendingPoolObject(interactions) {
|
|
36
|
+
return new lendingPool_2.OnchainInteractionsLendingPoolV3(interactions, this);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
exports.default = OnchainLendingPoolV3;
|
|
@@ -1,16 +1,26 @@
|
|
|
1
|
-
import OnChain from '../index';
|
|
2
|
-
import { Address, Factory } from '../../config/types';
|
|
3
|
-
import OnchainLendingPool from './lendingPool';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
import OnChain from '../index';
|
|
2
|
+
import { Address, AddressIndex, Factory } from '../../config/types';
|
|
3
|
+
import OnchainLendingPool from './lendingPool';
|
|
4
|
+
import { Contract } from '../onchainTypes';
|
|
5
|
+
export declare enum Version {
|
|
6
|
+
V2 = 0,
|
|
7
|
+
V3 = 1
|
|
8
|
+
}
|
|
9
|
+
export default abstract class OnchainImpermaxFactory {
|
|
10
|
+
readonly version: Version;
|
|
11
|
+
protected readonly onchain: OnChain;
|
|
12
|
+
protected readonly factory: Factory;
|
|
13
|
+
protected readonly lendingPools: AddressIndex<OnchainLendingPool>;
|
|
14
|
+
protected cache: {
|
|
15
|
+
poolTokenRouterContract?: Contract;
|
|
16
|
+
factoryContract?: Contract;
|
|
17
|
+
};
|
|
18
|
+
constructor(router: OnChain, factory: Factory);
|
|
19
|
+
getOnchain: () => OnChain;
|
|
20
|
+
getFactory: () => Factory;
|
|
21
|
+
cleanCache(): void;
|
|
22
|
+
protected abstract getNewLendingPoolObject(id: Address): OnchainLendingPool;
|
|
23
|
+
getLendingPool(id: Address): OnchainLendingPool;
|
|
24
|
+
getPoolTokenRouter(): any;
|
|
25
|
+
abstract getFactoryContract(): any;
|
|
26
|
+
}
|
|
@@ -1,52 +1,42 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
this.
|
|
13
|
-
this.
|
|
14
|
-
this.
|
|
15
|
-
this.
|
|
16
|
-
this.
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
-
return this.cache.routerContract;
|
|
45
|
-
}
|
|
46
|
-
getLendingPool(uniswapV2PairAddress) {
|
|
47
|
-
if (!this.lendingPools[uniswapV2PairAddress])
|
|
48
|
-
this.lendingPools[uniswapV2PairAddress] = new lendingPool_1.default(this, uniswapV2PairAddress);
|
|
49
|
-
return this.lendingPools[uniswapV2PairAddress];
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
exports.default = OnchainImpermaxFactory;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Version = void 0;
|
|
4
|
+
const routers_1 = require("../../config/contracts/routers");
|
|
5
|
+
var Version;
|
|
6
|
+
(function (Version) {
|
|
7
|
+
Version[Version["V2"] = 0] = "V2";
|
|
8
|
+
Version[Version["V3"] = 1] = "V3";
|
|
9
|
+
})(Version = exports.Version || (exports.Version = {}));
|
|
10
|
+
class OnchainImpermaxFactory {
|
|
11
|
+
constructor(router, factory) {
|
|
12
|
+
this.cache = {};
|
|
13
|
+
this.getOnchain = () => this.onchain;
|
|
14
|
+
this.getFactory = () => this.factory;
|
|
15
|
+
this.onchain = router;
|
|
16
|
+
this.factory = factory;
|
|
17
|
+
this.lendingPools = {};
|
|
18
|
+
}
|
|
19
|
+
cleanCache() {
|
|
20
|
+
this.cache = {};
|
|
21
|
+
for (const pairAddress of Object.keys(this.lendingPools)) {
|
|
22
|
+
this.lendingPools[pairAddress].cleanCache();
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
getLendingPool(id) {
|
|
26
|
+
if (!this.lendingPools[id])
|
|
27
|
+
this.lendingPools[id] = this.getNewLendingPoolObject(id);
|
|
28
|
+
return this.lendingPools[id];
|
|
29
|
+
}
|
|
30
|
+
getPoolTokenRouter() {
|
|
31
|
+
if (!this.cache.poolTokenRouterContract) {
|
|
32
|
+
const address = routers_1.POOL_TOKEN_ROUTER[this.onchain.network];
|
|
33
|
+
if (!address) {
|
|
34
|
+
console.error("Pool token router address not found");
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
this.cache.poolTokenRouterContract = this.onchain.getContractHelper().newPoolTokenRouter(address);
|
|
38
|
+
}
|
|
39
|
+
return this.cache.poolTokenRouterContract;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
exports.default = OnchainImpermaxFactory;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Address } from '../../config/types';
|
|
2
|
+
import { Contract } from '../onchainTypes';
|
|
3
|
+
import OnchainImpermaxFactory, { Version } from "./onchainImpermaxFactory";
|
|
4
|
+
export default class OnchainImpermaxFactoryV2 extends OnchainImpermaxFactory {
|
|
5
|
+
readonly version = Version.V2;
|
|
6
|
+
protected cache: {
|
|
7
|
+
simpleUniswapOracleContract?: Contract;
|
|
8
|
+
poolTokenRouterContract?: Contract;
|
|
9
|
+
factoryContract?: Contract;
|
|
10
|
+
routerContract?: Contract;
|
|
11
|
+
};
|
|
12
|
+
protected getNewLendingPoolObject(id: Address): any;
|
|
13
|
+
getRouter(): any;
|
|
14
|
+
getFactoryContract(): Promise<any>;
|
|
15
|
+
getSimpleUniswapOracle(): any;
|
|
16
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
+
const lendingPool_1 = require("./lendingPool");
|
|
36
|
+
const simple_uniswap_oracles_1 = require("../../config/contracts/simple-uniswap-oracles");
|
|
37
|
+
const onchainImpermaxFactory_1 = __importStar(require("./onchainImpermaxFactory"));
|
|
38
|
+
const routers_1 = require("../../config/contracts/routers");
|
|
39
|
+
class OnchainImpermaxFactoryV2 extends onchainImpermaxFactory_1.default {
|
|
40
|
+
constructor() {
|
|
41
|
+
super(...arguments);
|
|
42
|
+
this.version = onchainImpermaxFactory_1.Version.V2;
|
|
43
|
+
this.cache = {};
|
|
44
|
+
}
|
|
45
|
+
getNewLendingPoolObject(id) {
|
|
46
|
+
return new lendingPool_1.OnchainLendingPoolV2(this, id);
|
|
47
|
+
}
|
|
48
|
+
getRouter() {
|
|
49
|
+
if (!this.cache.routerContract) {
|
|
50
|
+
const address = routers_1.ROUTER[this.onchain.network][this.factory];
|
|
51
|
+
if (!address) {
|
|
52
|
+
console.error("Router address not found");
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
this.cache.routerContract = this.onchain.getContractHelper().newRouterV2(address);
|
|
56
|
+
}
|
|
57
|
+
return this.cache.routerContract;
|
|
58
|
+
}
|
|
59
|
+
getFactoryContract() {
|
|
60
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
61
|
+
if (!this.cache.factoryContract) {
|
|
62
|
+
const router = this.getRouter();
|
|
63
|
+
const factoryAddress = router.methods.factory().call();
|
|
64
|
+
this.cache.factoryContract = this.onchain.getContractHelper().newFactoryV2(factoryAddress);
|
|
65
|
+
}
|
|
66
|
+
return this.cache.factoryContract;
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
getSimpleUniswapOracle() {
|
|
70
|
+
if (!this.cache.simpleUniswapOracleContract) {
|
|
71
|
+
const address = simple_uniswap_oracles_1.SIMPLE_UNISWAP_ORACLE[this.onchain.network][this.factory];
|
|
72
|
+
if (!address) {
|
|
73
|
+
console.error("SimpleUniswapOracle address not found");
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
this.cache.simpleUniswapOracleContract = this.onchain.getContractHelper().newSimpleUniswapOracle(address);
|
|
77
|
+
}
|
|
78
|
+
return this.cache.simpleUniswapOracleContract;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
exports.default = OnchainImpermaxFactoryV2;
|