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,153 @@
|
|
|
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 poolToken_1 = __importDefault(require("../../poolToken"));
|
|
17
|
+
class Borrowable extends poolToken_1.default {
|
|
18
|
+
constructor(lendingPool, poolTokenType) {
|
|
19
|
+
super();
|
|
20
|
+
this.borrowableCache = {};
|
|
21
|
+
this.getContractHelper = () => this.lendingPool.factory.onchain.contractsHelper;
|
|
22
|
+
// Impermax Chef
|
|
23
|
+
this.getImpermaxChef = () => this.getContractHelper().impermaxChef;
|
|
24
|
+
this.lendingPool = lendingPool;
|
|
25
|
+
this.poolTokenType = poolTokenType;
|
|
26
|
+
}
|
|
27
|
+
cleanCache() {
|
|
28
|
+
super.cleanCache();
|
|
29
|
+
this.borrowableCache = {};
|
|
30
|
+
}
|
|
31
|
+
getPoolTokenAddress() {
|
|
32
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
33
|
+
return (yield this.lendingPool.getPoolTokenAddresses())[this.poolTokenType];
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
getOffchainPoolToken() {
|
|
37
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
38
|
+
const lendingPool = yield this.lendingPool.getOffchainLendingPool();
|
|
39
|
+
return lendingPool.poolTokens[this.poolTokenType];
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
initializePoolToken() {
|
|
43
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
44
|
+
return this.getContractHelper().newBorrowable(yield this.getPoolTokenAddress());
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
initializeToken() {
|
|
48
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
49
|
+
const poolToken = yield this.getPoolToken();
|
|
50
|
+
return this.getContractHelper().newERC20(yield poolToken.methods.underlying().call());
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
// Price Denom LP
|
|
54
|
+
getPriceDenomLP() {
|
|
55
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
56
|
+
const prices = yield this.lendingPool.getPriceDenomLP();
|
|
57
|
+
return prices[this.poolTokenType === types_1.PoolTokenType.BorrowableA ? 0 : 1];
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
getMarketPriceDenomLP() {
|
|
61
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
62
|
+
const prices = yield this.lendingPool.getMarketPriceDenomLP();
|
|
63
|
+
return prices[this.poolTokenType === types_1.PoolTokenType.BorrowableA ? 0 : 1];
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
// Farming Pool
|
|
67
|
+
initializeBorrowTracker() {
|
|
68
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
69
|
+
const borrowable = yield this.getPoolToken();
|
|
70
|
+
return borrowable.methods.borrowTracker().call();
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
getBorrowTracker() {
|
|
74
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
75
|
+
if (!this.borrowableCache.borrowTracker)
|
|
76
|
+
this.borrowableCache.borrowTracker = this.initializeBorrowTracker();
|
|
77
|
+
return this.borrowableCache.borrowTracker;
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
hasFarming() {
|
|
81
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
82
|
+
// remove old farming contracts, now it only has farming if it has the impermaxChef
|
|
83
|
+
return this.hasImpermaxChef();
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
hasImpermaxChef() {
|
|
87
|
+
var _a;
|
|
88
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
89
|
+
const borrowTracker = yield this.getBorrowTracker();
|
|
90
|
+
return borrowTracker.toLowerCase() === ((_a = this.getImpermaxChef()._address) !== null && _a !== void 0 ? _a : "").toLowerCase();
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
initializeFarmingTokenSymbol() {
|
|
94
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
95
|
+
if (!(yield this.hasImpermaxChef()))
|
|
96
|
+
return "";
|
|
97
|
+
const impermaxChef = yield this.getImpermaxChef();
|
|
98
|
+
const farmingTokenAddress = yield impermaxChef.methods.rewardToken().call();
|
|
99
|
+
return this.getContractHelper().newERC20(farmingTokenAddress).methods.symbol().call();
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
getFarmingTokenSymbol() {
|
|
103
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
104
|
+
if (!this.borrowableCache.farmingTokenSymbol)
|
|
105
|
+
this.borrowableCache.farmingTokenSymbol = this.initializeFarmingTokenSymbol();
|
|
106
|
+
return this.borrowableCache.farmingTokenSymbol;
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
// Farming Pool Rewarder
|
|
110
|
+
initializeRewarder() {
|
|
111
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
112
|
+
const poolTokenAddress = yield this.getPoolTokenAddress();
|
|
113
|
+
try {
|
|
114
|
+
const { rewarder } = yield this.getImpermaxChef().methods.poolInfo(poolTokenAddress).call();
|
|
115
|
+
if (rewarder == "0x0000000000000000000000000000000000000000")
|
|
116
|
+
return null;
|
|
117
|
+
return this.getContractHelper().newImpermaxChef(rewarder);
|
|
118
|
+
}
|
|
119
|
+
catch (_a) {
|
|
120
|
+
return null;
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
getRewarder() {
|
|
125
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
126
|
+
if (!this.borrowableCache.rewarder)
|
|
127
|
+
this.borrowableCache.rewarder = this.initializeRewarder();
|
|
128
|
+
return this.borrowableCache.rewarder;
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
hasRewarder() {
|
|
132
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
133
|
+
return (yield this.getRewarder()) !== null;
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
initializeRewarderTokenSymbol() {
|
|
137
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
138
|
+
if (!(yield this.hasRewarder()))
|
|
139
|
+
return "";
|
|
140
|
+
const rewarder = yield this.getRewarder();
|
|
141
|
+
const rewardTokenAddress = yield rewarder.methods.rewardToken().call();
|
|
142
|
+
return this.getContractHelper().newERC20(rewardTokenAddress).methods.symbol().call();
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
getRewarderTokenSymbol() {
|
|
146
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
147
|
+
if (!this.borrowableCache.rewarderTokenSymbol)
|
|
148
|
+
this.borrowableCache.rewarderTokenSymbol = this.initializeRewarderTokenSymbol();
|
|
149
|
+
return this.borrowableCache.rewarderTokenSymbol;
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
exports.default = Borrowable;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Contract } from "../../types";
|
|
2
|
+
import LendingPool from './index';
|
|
3
|
+
import { Address, PoolTokenType } from '../../../config/types';
|
|
4
|
+
import * as offchain from '../../../offchain';
|
|
5
|
+
import PoolToken from '../../poolToken';
|
|
6
|
+
export default class Collateral extends PoolToken {
|
|
7
|
+
lendingPool: LendingPool;
|
|
8
|
+
collateralCache: {};
|
|
9
|
+
constructor(lendingPool: LendingPool, poolTokenType: PoolTokenType);
|
|
10
|
+
cleanCache(): void;
|
|
11
|
+
getContractHelper: () => import("../..").ContractsHelper;
|
|
12
|
+
getPoolTokenAddress(): Promise<Address>;
|
|
13
|
+
getOffchainPoolToken(): Promise<offchain.lendingPool.OffchainCollateral>;
|
|
14
|
+
initializePoolToken(): Promise<Contract>;
|
|
15
|
+
initializeToken(): Promise<Contract>;
|
|
16
|
+
protected initializeExchangeRate(): Promise<number>;
|
|
17
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
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 poolToken_1 = __importDefault(require("../../poolToken"));
|
|
16
|
+
class Collateral extends poolToken_1.default {
|
|
17
|
+
constructor(lendingPool, poolTokenType) {
|
|
18
|
+
super();
|
|
19
|
+
this.collateralCache = {};
|
|
20
|
+
this.getContractHelper = () => this.lendingPool.factory.onchain.contractsHelper;
|
|
21
|
+
this.lendingPool = lendingPool;
|
|
22
|
+
this.poolTokenType = poolTokenType;
|
|
23
|
+
}
|
|
24
|
+
cleanCache() {
|
|
25
|
+
super.cleanCache();
|
|
26
|
+
this.collateralCache = {};
|
|
27
|
+
}
|
|
28
|
+
getPoolTokenAddress() {
|
|
29
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
30
|
+
return (yield this.lendingPool.getPoolTokenAddresses())[this.poolTokenType];
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
getOffchainPoolToken() {
|
|
34
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
35
|
+
const lendingPool = yield this.lendingPool.getOffchainLendingPool();
|
|
36
|
+
return lendingPool.poolTokens[this.poolTokenType];
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
initializePoolToken() {
|
|
40
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
41
|
+
return this.getContractHelper().newCollateral(yield this.getPoolTokenAddress());
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
initializeToken() {
|
|
45
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
46
|
+
return this.lendingPool.getUniswapV2Pair();
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
initializeExchangeRate() {
|
|
50
|
+
const _super = Object.create(null, {
|
|
51
|
+
initializeExchangeRate: { get: () => super.initializeExchangeRate }
|
|
52
|
+
});
|
|
53
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
54
|
+
let exchangeRate = yield _super.initializeExchangeRate.call(this);
|
|
55
|
+
return exchangeRate * (yield this.lendingPool.getStakedLPExchangeRate());
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
exports.default = Collateral;
|
|
@@ -1,5 +1,12 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import * as nftlp from './nftlp';
|
|
2
|
+
import OnchainCollateral from "./onchainCollateral";
|
|
3
|
+
import OnchainBorrowable from "./onchainBorrowable";
|
|
4
|
+
import OnchainLendingPool from './onchainLendingPool';
|
|
5
|
+
import OnchainLendingPoolV2 from "./onchainLendingPoolV2";
|
|
6
|
+
import OnchainBorrowableV2 from "./onchainBorrowableV2";
|
|
7
|
+
import OnchainCollateralV2 from "./onchainCollateralV2";
|
|
8
|
+
import OnchainLendingPoolV3 from "./onchainLendingPoolV3";
|
|
9
|
+
import OnchainBorrowableV3 from "./onchainBorrowableV3";
|
|
10
|
+
import OnchainCollateralV3 from "./onchainCollateralV3";
|
|
11
|
+
export { nftlp, OnchainBorrowable, OnchainCollateral, OnchainLendingPool, OnchainLendingPoolV2, OnchainBorrowableV2, OnchainCollateralV2, OnchainLendingPoolV3, OnchainBorrowableV3, OnchainCollateralV3, };
|
|
12
|
+
export default OnchainLendingPool;
|
|
@@ -1,12 +1,50 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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 __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.OnchainCollateralV3 = exports.OnchainBorrowableV3 = exports.OnchainLendingPoolV3 = exports.OnchainCollateralV2 = exports.OnchainBorrowableV2 = exports.OnchainLendingPoolV2 = exports.OnchainLendingPool = exports.OnchainCollateral = exports.OnchainBorrowable = exports.nftlp = void 0;
|
|
30
|
+
const nftlp = __importStar(require("./nftlp"));
|
|
31
|
+
exports.nftlp = nftlp;
|
|
32
|
+
const onchainCollateral_1 = __importDefault(require("./onchainCollateral"));
|
|
33
|
+
exports.OnchainCollateral = onchainCollateral_1.default;
|
|
34
|
+
const onchainBorrowable_1 = __importDefault(require("./onchainBorrowable"));
|
|
35
|
+
exports.OnchainBorrowable = onchainBorrowable_1.default;
|
|
36
|
+
const onchainLendingPool_1 = __importDefault(require("./onchainLendingPool"));
|
|
37
|
+
exports.OnchainLendingPool = onchainLendingPool_1.default;
|
|
38
|
+
const onchainLendingPoolV2_1 = __importDefault(require("./onchainLendingPoolV2"));
|
|
39
|
+
exports.OnchainLendingPoolV2 = onchainLendingPoolV2_1.default;
|
|
40
|
+
const onchainBorrowableV2_1 = __importDefault(require("./onchainBorrowableV2"));
|
|
41
|
+
exports.OnchainBorrowableV2 = onchainBorrowableV2_1.default;
|
|
42
|
+
const onchainCollateralV2_1 = __importDefault(require("./onchainCollateralV2"));
|
|
43
|
+
exports.OnchainCollateralV2 = onchainCollateralV2_1.default;
|
|
44
|
+
const onchainLendingPoolV3_1 = __importDefault(require("./onchainLendingPoolV3"));
|
|
45
|
+
exports.OnchainLendingPoolV3 = onchainLendingPoolV3_1.default;
|
|
46
|
+
const onchainBorrowableV3_1 = __importDefault(require("./onchainBorrowableV3"));
|
|
47
|
+
exports.OnchainBorrowableV3 = onchainBorrowableV3_1.default;
|
|
48
|
+
const onchainCollateralV3_1 = __importDefault(require("./onchainCollateralV3"));
|
|
49
|
+
exports.OnchainCollateralV3 = onchainCollateralV3_1.default;
|
|
50
|
+
exports.default = onchainLendingPool_1.default;
|
|
@@ -0,0 +1,11 @@
|
|
|
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
|
+
exports.OnchainNftlpUniswapV3 = exports.OnchainNftlp = void 0;
|
|
7
|
+
const onchainNftlp_1 = __importDefault(require("./onchainNftlp"));
|
|
8
|
+
exports.OnchainNftlp = onchainNftlp_1.default;
|
|
9
|
+
const onchainNftlpUniswapV3_1 = __importDefault(require("./onchainNftlpUniswapV3"));
|
|
10
|
+
exports.OnchainNftlpUniswapV3 = onchainNftlpUniswapV3_1.default;
|
|
11
|
+
exports.default = onchainNftlp_1.default;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import OnchainLendingPoolV3 from "../onchainLendingPoolV3";
|
|
2
|
+
import { Contract } from "../../../onchainTypes";
|
|
3
|
+
import { OnchainAccountLendingPoolV3 } from "../../../account/lendingPool";
|
|
4
|
+
import OnchainAccountNftlp from "../../../account/lendingPool/nftlp";
|
|
5
|
+
import { OnchainInteractionsLendingPoolV3 } from "../../../interactions/lendingPool";
|
|
6
|
+
import OnchainInteractionsNftlp from "../../../interactions/lendingPool/nftlp";
|
|
7
|
+
export default abstract class OnchainNftlp {
|
|
8
|
+
protected readonly lendingPool: OnchainLendingPoolV3;
|
|
9
|
+
protected cache: {
|
|
10
|
+
nftlp?: Contract;
|
|
11
|
+
};
|
|
12
|
+
abstract getNewAccountNftlpObject(accountLendingPool: OnchainAccountLendingPoolV3): OnchainAccountNftlp;
|
|
13
|
+
abstract getNewInteractionsNftlpObject(accountLendingPool: OnchainInteractionsLendingPoolV3): OnchainInteractionsNftlp;
|
|
14
|
+
constructor(lendingPool: OnchainLendingPoolV3);
|
|
15
|
+
cleanCache(): void;
|
|
16
|
+
protected getContractHelper: () => import("../../..").OnchainContractsHelper;
|
|
17
|
+
getNftlpAddress: () => string;
|
|
18
|
+
protected abstract initializeNftlp(): Contract;
|
|
19
|
+
getNftlp(): any;
|
|
20
|
+
abstract getMarketPrice(): Promise<number>;
|
|
21
|
+
abstract getOraclePrice(): Promise<number>;
|
|
22
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
class OnchainNftlp {
|
|
4
|
+
constructor(lendingPool) {
|
|
5
|
+
this.cache = {};
|
|
6
|
+
this.getContractHelper = () => this.lendingPool.getImpermaxFactory().getOnchain().getContractHelper();
|
|
7
|
+
this.getNftlpAddress = () => this.lendingPool.getId();
|
|
8
|
+
this.lendingPool = lendingPool;
|
|
9
|
+
}
|
|
10
|
+
cleanCache() {
|
|
11
|
+
this.cache = {};
|
|
12
|
+
}
|
|
13
|
+
getNftlp() {
|
|
14
|
+
if (!this.cache.nftlp)
|
|
15
|
+
this.cache.nftlp = this.initializeNftlp();
|
|
16
|
+
return this.cache.nftlp;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
exports.default = OnchainNftlp;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import OnchainNftlp from "./onchainNftlp";
|
|
2
|
+
import { Contract } from "../../../onchainTypes";
|
|
3
|
+
import { OnchainAccountLendingPoolV3 } from "../../../account/lendingPool";
|
|
4
|
+
import { OnchainAccountNftlpUniswapV3 } from "../../../account/lendingPool/nftlp";
|
|
5
|
+
import { OnchainInteractionsNftlpUniswapV3 } from "../../../interactions/lendingPool/nftlp";
|
|
6
|
+
import { OnchainInteractionsLendingPoolV3 } from "../../../interactions/lendingPool";
|
|
7
|
+
export default class OnchainNftlpUniswapV3 extends OnchainNftlp {
|
|
8
|
+
protected cache: {
|
|
9
|
+
nftlp?: Contract;
|
|
10
|
+
uniswapV3Pools?: {
|
|
11
|
+
[key in number]: Promise<Contract | null>;
|
|
12
|
+
};
|
|
13
|
+
marketPrice?: Promise<number>;
|
|
14
|
+
oraclePrice?: Promise<number>;
|
|
15
|
+
};
|
|
16
|
+
getNewAccountNftlpObject(accountNftlp: OnchainAccountLendingPoolV3): OnchainAccountNftlpUniswapV3;
|
|
17
|
+
getNewInteractionsNftlpObject(interactionsNftlp: OnchainInteractionsLendingPoolV3): OnchainInteractionsNftlpUniswapV3;
|
|
18
|
+
initializeNftlp(): any;
|
|
19
|
+
initializeUniswapV3Pool(fee: number): Promise<Contract | null>;
|
|
20
|
+
getUniswapV3Pool(fee: number): Promise<any>;
|
|
21
|
+
getMarketPrice(): Promise<number>;
|
|
22
|
+
private initializeOraclePrice;
|
|
23
|
+
getOraclePrice(): Promise<number>;
|
|
24
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
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 onchainNftlp_1 = __importDefault(require("./onchainNftlp"));
|
|
16
|
+
const nftlp_1 = require("../../../account/lendingPool/nftlp");
|
|
17
|
+
const nftlp_2 = require("../../../interactions/lendingPool/nftlp");
|
|
18
|
+
const FEES = [
|
|
19
|
+
100,
|
|
20
|
+
500,
|
|
21
|
+
3000,
|
|
22
|
+
10000,
|
|
23
|
+
];
|
|
24
|
+
class OnchainNftlpUniswapV3 extends onchainNftlp_1.default {
|
|
25
|
+
constructor() {
|
|
26
|
+
super(...arguments);
|
|
27
|
+
this.cache = {};
|
|
28
|
+
}
|
|
29
|
+
getNewAccountNftlpObject(accountNftlp) {
|
|
30
|
+
return new nftlp_1.OnchainAccountNftlpUniswapV3(accountNftlp);
|
|
31
|
+
}
|
|
32
|
+
getNewInteractionsNftlpObject(interactionsNftlp) {
|
|
33
|
+
return new nftlp_2.OnchainInteractionsNftlpUniswapV3(interactionsNftlp);
|
|
34
|
+
}
|
|
35
|
+
initializeNftlp() {
|
|
36
|
+
return this.getContractHelper().newNftlpUniV3(this.getNftlpAddress());
|
|
37
|
+
}
|
|
38
|
+
initializeUniswapV3Pool(fee) {
|
|
39
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
40
|
+
const nftlp = this.getNftlp();
|
|
41
|
+
try {
|
|
42
|
+
const poolAddress = yield nftlp.methods.getPool(fee).call();
|
|
43
|
+
return this.getContractHelper().newUniswapV3Pool(poolAddress);
|
|
44
|
+
}
|
|
45
|
+
catch (_a) {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
getUniswapV3Pool(fee) {
|
|
51
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
52
|
+
if (!this.cache.uniswapV3Pools)
|
|
53
|
+
this.cache.uniswapV3Pools = {};
|
|
54
|
+
if (!this.cache.uniswapV3Pools[fee])
|
|
55
|
+
this.cache.uniswapV3Pools[fee] = this.initializeUniswapV3Pool(fee);
|
|
56
|
+
return this.cache.uniswapV3Pools[fee];
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
getMarketPrice() {
|
|
60
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
61
|
+
let priceCumulative = 0;
|
|
62
|
+
let liquidityCumulative = 0;
|
|
63
|
+
for (const fee of FEES) {
|
|
64
|
+
const pool = yield this.getUniswapV3Pool(fee);
|
|
65
|
+
if (!pool)
|
|
66
|
+
continue;
|
|
67
|
+
const price = Math.pow(((yield pool.methods.slot0().call()).sqrtPriceX96 / Math.pow(2, 96)), 2);
|
|
68
|
+
const liquidity = (yield pool.methods.liquidity().call()) * 1;
|
|
69
|
+
priceCumulative += price * liquidity;
|
|
70
|
+
liquidityCumulative += liquidity;
|
|
71
|
+
}
|
|
72
|
+
return priceCumulative / liquidityCumulative;
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
;
|
|
76
|
+
initializeOraclePrice() {
|
|
77
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
78
|
+
const nftlp = yield this.getNftlp();
|
|
79
|
+
return Math.pow((nftlp.methods.oraclePriceSqrtX96().call() / Math.pow(2, 96)), 2);
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
getOraclePrice() {
|
|
83
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
84
|
+
if (!this.cache.oraclePrice)
|
|
85
|
+
this.cache.oraclePrice = this.initializeOraclePrice();
|
|
86
|
+
return this.cache.oraclePrice;
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
exports.default = OnchainNftlpUniswapV3;
|
|
@@ -1,34 +1,38 @@
|
|
|
1
|
-
import { Contract } from "../../onchainTypes";
|
|
2
|
-
import { Address,
|
|
3
|
-
import OnchainLendingPool from './index';
|
|
4
|
-
import OnchainPoolToken from '../../onchainPoolToken';
|
|
5
|
-
import OffchainBorrowable from '../../../offchain/lendingPool/offchainBorrowable';
|
|
6
|
-
export default class OnchainBorrowable extends OnchainPoolToken {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
1
|
+
import { Contract } from "../../onchainTypes";
|
|
2
|
+
import { Address, Borrowable } from '../../../config/types';
|
|
3
|
+
import OnchainLendingPool from './index';
|
|
4
|
+
import OnchainPoolToken from '../../onchainPoolToken';
|
|
5
|
+
import OffchainBorrowable from '../../../offchain/lendingPool/offchainBorrowable';
|
|
6
|
+
export default abstract class OnchainBorrowable extends OnchainPoolToken {
|
|
7
|
+
protected readonly lendingPool: OnchainLendingPool;
|
|
8
|
+
protected readonly borrowable: Borrowable;
|
|
9
|
+
protected borrowableCache: {
|
|
10
|
+
borrowTracker?: Promise<Address>;
|
|
11
|
+
rewarder?: Promise<Contract>;
|
|
12
|
+
rewarderTokenSymbol?: Promise<string>;
|
|
13
|
+
farmingTokenSymbol?: Promise<string>;
|
|
14
|
+
rewardSpeed?: Promise<number>;
|
|
15
|
+
};
|
|
16
|
+
constructor(lendingPool: OnchainLendingPool, borrowable: Borrowable);
|
|
17
|
+
getLendingPool: () => OnchainLendingPool;
|
|
18
|
+
getBorrowableType: () => Borrowable;
|
|
19
|
+
cleanCache(): void;
|
|
20
|
+
protected getContractHelper: () => import("../..").OnchainContractsHelper;
|
|
21
|
+
getPoolTokenAddress(): Promise<Address>;
|
|
22
|
+
getOffchainPoolToken(): Promise<OffchainBorrowable>;
|
|
23
|
+
getOffchainBorrowable: () => Promise<OffchainBorrowable>;
|
|
24
|
+
protected abstract initializePoolToken(): Promise<Contract>;
|
|
25
|
+
protected initializeToken(): Promise<Contract>;
|
|
26
|
+
private initializeBorrowTracker;
|
|
27
|
+
getBorrowTracker(): Promise<string>;
|
|
28
|
+
hasFarming(): Promise<boolean>;
|
|
29
|
+
getImpermaxChef: () => any;
|
|
30
|
+
hasImpermaxChef(): Promise<boolean>;
|
|
31
|
+
private initializeFarmingTokenSymbol;
|
|
32
|
+
getFarmingTokenSymbol(): Promise<string>;
|
|
33
|
+
private initializeRewarder;
|
|
34
|
+
getRewarder(): Promise<any>;
|
|
35
|
+
hasRewarder(): Promise<boolean>;
|
|
36
|
+
private initializeRewarderTokenSymbol;
|
|
37
|
+
getRewarderTokenSymbol(): Promise<string>;
|
|
38
|
+
}
|