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,180 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
const ethers_1 = require("ethers");
|
|
13
|
+
const types_1 = require("../../types");
|
|
14
|
+
const types_2 = require("../../../config/types");
|
|
15
|
+
const weths_1 = require("../../../config/contracts/weths");
|
|
16
|
+
const general_1 = require("../../../config/general");
|
|
17
|
+
const MAX_UINT256 = ethers_1.ethers.constants.MaxUint256;
|
|
18
|
+
const EIP712DOMAIN = [
|
|
19
|
+
{ name: "name", type: "string" },
|
|
20
|
+
{ name: "version", type: "string" },
|
|
21
|
+
{ name: "chainId", type: "uint256" },
|
|
22
|
+
{ name: "verifyingContract", type: "address" },
|
|
23
|
+
];
|
|
24
|
+
const PERMIT = [
|
|
25
|
+
{ name: "owner", type: "address" },
|
|
26
|
+
{ name: "spender", type: "address" },
|
|
27
|
+
{ name: "value", type: "uint256" },
|
|
28
|
+
{ name: "nonce", type: "uint256" },
|
|
29
|
+
{ name: "deadline", type: "uint256" },
|
|
30
|
+
];
|
|
31
|
+
const TYPES = {
|
|
32
|
+
EIP712Domain: EIP712DOMAIN,
|
|
33
|
+
Permit: PERMIT,
|
|
34
|
+
BorrowPermit: PERMIT,
|
|
35
|
+
};
|
|
36
|
+
class PoolToken {
|
|
37
|
+
constructor() {
|
|
38
|
+
this.getOnchain = () => this.getInteractions().account.router;
|
|
39
|
+
this.getPoolToken = () => this.accountPoolToken.poolToken;
|
|
40
|
+
}
|
|
41
|
+
send(method, onTransactionHash, value) {
|
|
42
|
+
return this.getInteractions().send(method, onTransactionHash, value);
|
|
43
|
+
}
|
|
44
|
+
//send = this.getInteractions().send;
|
|
45
|
+
getOwnerSpender() {
|
|
46
|
+
return {
|
|
47
|
+
owner: this.getAccountAddress(),
|
|
48
|
+
spender: this.getRouterContract()._address,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
isWETH() {
|
|
52
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
53
|
+
const token = yield this.getPoolToken().getToken();
|
|
54
|
+
return token._address.toLowerCase() == weths_1.WETH[this.getOnchain().network].toLowerCase();
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
getAllowance(approvalType) {
|
|
58
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
59
|
+
const poolToken = yield this.getPoolToken().getPoolToken();
|
|
60
|
+
const token = yield this.getPoolToken().getToken();
|
|
61
|
+
if ((yield this.isWETH()) && approvalType == types_1.ApprovalType.UNDERLYING)
|
|
62
|
+
return MAX_UINT256;
|
|
63
|
+
const { owner, spender } = this.getOwnerSpender();
|
|
64
|
+
const allowance = (approvalType == types_1.ApprovalType.POOL_TOKEN) ? yield poolToken.methods.allowance(owner, spender).call() :
|
|
65
|
+
(approvalType == types_1.ApprovalType.UNDERLYING) ? yield token.methods.allowance(owner, spender).call() :
|
|
66
|
+
(approvalType == types_1.ApprovalType.BORROW) ? yield poolToken.methods.borrowAllowance(owner, spender).call() : 0;
|
|
67
|
+
return ethers_1.BigNumber.from(allowance);
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
approve(approvalType, amount, onTransactionHash) {
|
|
71
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
72
|
+
const { spender } = this.getOwnerSpender();
|
|
73
|
+
const poolToken = yield this.getPoolToken().getPoolToken();
|
|
74
|
+
const token = yield this.getPoolToken().getToken();
|
|
75
|
+
let method;
|
|
76
|
+
if (approvalType == types_1.ApprovalType.POOL_TOKEN)
|
|
77
|
+
method = poolToken.methods.approve(spender, amount);
|
|
78
|
+
if (approvalType == types_1.ApprovalType.UNDERLYING)
|
|
79
|
+
method = token.methods.approve(spender, amount);
|
|
80
|
+
if (approvalType == types_1.ApprovalType.BORROW)
|
|
81
|
+
method = poolToken.methods.borrowApprove(spender, amount);
|
|
82
|
+
return this.send(method, onTransactionHash);
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
getPermitData(approvalType, amount, deadlineArg, callBack) {
|
|
86
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
87
|
+
if (approvalType === types_1.ApprovalType.UNDERLYING && this.getPoolToken().poolTokenType != types_2.PoolTokenType.Collateral)
|
|
88
|
+
return callBack(null);
|
|
89
|
+
const { owner, spender } = this.getOwnerSpender();
|
|
90
|
+
const poolToken = yield this.getPoolToken().getPoolToken();
|
|
91
|
+
const token = yield this.getPoolToken().getToken();
|
|
92
|
+
const contract = approvalType == types_1.ApprovalType.UNDERLYING ? token : poolToken;
|
|
93
|
+
const nonce = yield contract.methods.nonces(owner).call();
|
|
94
|
+
const name = yield contract.methods.name().call();
|
|
95
|
+
const deadline = deadlineArg ? deadlineArg : general_1.DEADLINE;
|
|
96
|
+
const data = JSON.stringify({
|
|
97
|
+
types: TYPES,
|
|
98
|
+
domain: {
|
|
99
|
+
name: name,
|
|
100
|
+
version: "1",
|
|
101
|
+
chainId: this.getOnchain().chainId,
|
|
102
|
+
verifyingContract: contract._address,
|
|
103
|
+
},
|
|
104
|
+
primaryType: approvalType == types_1.ApprovalType.BORROW ? "BorrowPermit" : "Permit",
|
|
105
|
+
message: {
|
|
106
|
+
owner: owner,
|
|
107
|
+
spender: spender,
|
|
108
|
+
value: amount.toString(),
|
|
109
|
+
nonce: ethers_1.BigNumber.from(nonce).toHexString(),
|
|
110
|
+
deadline: deadline.toNumber(),
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
this.getOnchain().web3.currentProvider.send({
|
|
114
|
+
method: "eth_signTypedData_v4",
|
|
115
|
+
params: [owner, data],
|
|
116
|
+
from: owner
|
|
117
|
+
}, (err, data) => {
|
|
118
|
+
if (err) {
|
|
119
|
+
console.error(err);
|
|
120
|
+
return callBack(null);
|
|
121
|
+
}
|
|
122
|
+
const signature = data.result.substring(2);
|
|
123
|
+
const r = "0x" + signature.substring(0, 64);
|
|
124
|
+
const s = "0x" + signature.substring(64, 128);
|
|
125
|
+
let v = parseInt(signature.substring(128, 130), 16);
|
|
126
|
+
if (v == 0 || v == 1)
|
|
127
|
+
v = v + 27;
|
|
128
|
+
//console.log(v, r, s);
|
|
129
|
+
const permitData = ethers_1.ethers.utils.defaultAbiCoder.encode(['bool', 'uint8', 'bytes32', 'bytes32'], [false, v, r, s]);
|
|
130
|
+
callBack({ permitData, deadline, amount });
|
|
131
|
+
});
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
getSendData(permitData) {
|
|
135
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
136
|
+
return {
|
|
137
|
+
router: this.getRouterContract(),
|
|
138
|
+
ptAddress: (yield this.getPoolToken().getPoolToken())._address,
|
|
139
|
+
account: this.accountPoolToken.getAccountAddress(),
|
|
140
|
+
data: permitData ? permitData.permitData : '0x',
|
|
141
|
+
deadline: permitData ? permitData.deadline : general_1.DEADLINE,
|
|
142
|
+
};
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
mintETH(amount, permitData, onTransactionHash) {
|
|
146
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
147
|
+
const { router, ptAddress, account, deadline } = yield this.getSendData(permitData);
|
|
148
|
+
return this.send(router.methods.mintETH(ptAddress, account, deadline), onTransactionHash, amount);
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
mint(amount, permitData, onTransactionHash) {
|
|
152
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
153
|
+
const { router, ptAddress, account, deadline } = yield this.getSendData(permitData);
|
|
154
|
+
return this.send(router.methods.mint(ptAddress, amount, account, deadline), onTransactionHash);
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
;
|
|
158
|
+
deposit(amount, permitData, onTransactionHash) {
|
|
159
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
160
|
+
if (yield this.isWETH()) {
|
|
161
|
+
return this.mintETH(amount, permitData, onTransactionHash);
|
|
162
|
+
}
|
|
163
|
+
else {
|
|
164
|
+
return this.mint(amount, permitData, onTransactionHash);
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
withdraw(tokens, permitData, onTransactionHash) {
|
|
169
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
170
|
+
const { router, ptAddress, account, data, deadline } = yield this.getSendData(permitData);
|
|
171
|
+
if (yield this.isWETH()) {
|
|
172
|
+
return this.send(router.methods.redeemETH(ptAddress, tokens, account, deadline, data), onTransactionHash);
|
|
173
|
+
}
|
|
174
|
+
else {
|
|
175
|
+
return this.send(router.methods.redeem(ptAddress, tokens, account, deadline, data), onTransactionHash);
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
exports.default = PoolToken;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { PoolTokenType } from '../../../config/types';
|
|
2
|
+
import LendingPool from './index';
|
|
3
|
+
import * as onchain from '../../index';
|
|
4
|
+
import PoolToken from '../poolToken';
|
|
5
|
+
export default class Borrowable extends PoolToken {
|
|
6
|
+
accountLendingPool: LendingPool;
|
|
7
|
+
poolToken: onchain.impermaxFactory.lendingPool.Borrowable;
|
|
8
|
+
borrowableCache: {
|
|
9
|
+
borrowed?: Promise<number>;
|
|
10
|
+
farmingShares?: Promise<number>;
|
|
11
|
+
availableFarmingReward?: Promise<number>;
|
|
12
|
+
availableRewarderReward?: Promise<number>;
|
|
13
|
+
};
|
|
14
|
+
constructor(accountLendingPool: LendingPool, poolTokenType: PoolTokenType);
|
|
15
|
+
cleanCache(): void;
|
|
16
|
+
getSupplyAPR: () => Promise<number>;
|
|
17
|
+
getBorrowRate: () => Promise<number>;
|
|
18
|
+
getAccrualTimestamp: () => Promise<number>;
|
|
19
|
+
private initializeBorrowed;
|
|
20
|
+
getBorrowed(): Promise<number>;
|
|
21
|
+
getBorrowedUSD(): Promise<number>;
|
|
22
|
+
getMaxBorrowable(): Promise<number>;
|
|
23
|
+
private initializeFarmingShares;
|
|
24
|
+
getFarmingShares(): Promise<number>;
|
|
25
|
+
private initializeAvailableFarmingReward;
|
|
26
|
+
getAvailableFarmingReward(): Promise<number>;
|
|
27
|
+
private initializeAvailableRewarderReward;
|
|
28
|
+
getAvailableRewarderReward(): Promise<number>;
|
|
29
|
+
}
|
|
@@ -0,0 +1,135 @@
|
|
|
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("../../types");
|
|
16
|
+
const types_2 = require("../../../config/types");
|
|
17
|
+
const poolToken_1 = __importDefault(require("../poolToken"));
|
|
18
|
+
class Borrowable extends poolToken_1.default {
|
|
19
|
+
constructor(accountLendingPool, poolTokenType) {
|
|
20
|
+
super();
|
|
21
|
+
this.borrowableCache = {};
|
|
22
|
+
// Shortcuts
|
|
23
|
+
this.getSupplyAPR = () => __awaiter(this, void 0, void 0, function* () { return (yield this.onchainPoolToken.getOffchainPoolToken()).getSupplyAPR(); });
|
|
24
|
+
this.getBorrowRate = () => __awaiter(this, void 0, void 0, function* () { return (yield this.onchainPoolToken.getOffchainPoolToken()).getBorrowRate(); });
|
|
25
|
+
this.getAccrualTimestamp = () => __awaiter(this, void 0, void 0, function* () { return (yield this.onchainPoolToken.getOffchainPoolToken()).getAccrualTimestamp(); });
|
|
26
|
+
this.accountLendingPool = accountLendingPool;
|
|
27
|
+
this.account = accountLendingPool.account;
|
|
28
|
+
this.poolToken = accountLendingPool.lendingPool.poolTokens[poolTokenType];
|
|
29
|
+
}
|
|
30
|
+
cleanCache() {
|
|
31
|
+
super.cleanCache();
|
|
32
|
+
this.borrowableCache = {};
|
|
33
|
+
}
|
|
34
|
+
// Borrowed
|
|
35
|
+
initializeBorrowed() {
|
|
36
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
37
|
+
const borrowable = yield this.onchainPoolToken.getPoolToken();
|
|
38
|
+
const balance = yield borrowable.methods.borrowBalance(this.getAccountAddress()).call();
|
|
39
|
+
const storedAmount = yield yield this.onchainPoolToken.normalize(balance);
|
|
40
|
+
const accrualTimestamp = yield this.getAccrualTimestamp();
|
|
41
|
+
const borrowRate = yield this.getBorrowRate();
|
|
42
|
+
return storedAmount * (1 + (Date.now() / 1000 - accrualTimestamp) * borrowRate);
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
getBorrowed() {
|
|
46
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
47
|
+
if (!this.borrowableCache.borrowed)
|
|
48
|
+
this.borrowableCache.borrowed = this.initializeBorrowed();
|
|
49
|
+
return this.borrowableCache.borrowed;
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
getBorrowedUSD() {
|
|
53
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
54
|
+
const borrowed = yield this.getBorrowed();
|
|
55
|
+
const tokenPrice = yield this.getTokenPriceAccurate();
|
|
56
|
+
return borrowed * tokenPrice;
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
// Max OffchainBorrowable
|
|
60
|
+
getMaxBorrowable() {
|
|
61
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
62
|
+
const availableCash = yield this.onchainPoolToken.getTotalBalance();
|
|
63
|
+
const { valueCollateral, valueA, valueB } = yield this.lendingPool.getValues(types_1.NO_CHANGES);
|
|
64
|
+
const [valueBorrowed, valueOther] = this.onchainPoolToken.poolTokenType == types_2.PoolTokenType.BorrowableA ? [valueA, valueB] : [valueB, valueA];
|
|
65
|
+
const safetyMargin = (yield this.lendingPool.getSafetyMargin()) * this.getUiMargin();
|
|
66
|
+
const liquidationPenalty = yield this.lendingPool.getLiquidationPenalty();
|
|
67
|
+
const actualCollateral = valueCollateral / liquidationPenalty;
|
|
68
|
+
const totalValueBorrowable1 = (actualCollateral * Math.sqrt(safetyMargin) - valueOther) / safetyMargin;
|
|
69
|
+
const totalValueBorrowable2 = (actualCollateral / Math.sqrt(safetyMargin) - valueOther) * safetyMargin;
|
|
70
|
+
const maxValueBorrowable = Math.min(totalValueBorrowable1, totalValueBorrowable2) - valueBorrowed;
|
|
71
|
+
const price = yield this.onchainPoolToken.getMarketPriceDenomLP();
|
|
72
|
+
return Math.max(0, Math.min(availableCash, maxValueBorrowable / price));
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
// Farming Shares
|
|
76
|
+
initializeFarmingShares() {
|
|
77
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
78
|
+
if (!(yield this.onchainPoolToken.hasImpermaxChef()))
|
|
79
|
+
return 0;
|
|
80
|
+
return (yield this.onchainPoolToken.getImpermaxChef().methods.userInfo(yield this.onchainPoolToken.getPoolTokenAddress(), this.getAccountAddress()).call()).shares;
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
getFarmingShares() {
|
|
84
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
85
|
+
if (!this.borrowableCache.farmingShares)
|
|
86
|
+
this.borrowableCache.farmingShares = this.initializeFarmingShares();
|
|
87
|
+
return this.borrowableCache.farmingShares;
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
// Available Reward
|
|
91
|
+
initializeAvailableFarmingReward() {
|
|
92
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
93
|
+
if (!(yield this.onchainPoolToken.hasImpermaxChef()))
|
|
94
|
+
return 0;
|
|
95
|
+
const borrowableAddress = yield this.onchainPoolToken.getPoolTokenAddress();
|
|
96
|
+
try {
|
|
97
|
+
return (yield this.onchainPoolToken.getImpermaxChef().methods.pendingReward(borrowableAddress, this.getAccountAddress()).call()) / 1e18;
|
|
98
|
+
}
|
|
99
|
+
catch (_a) {
|
|
100
|
+
console.log("Warning: pending reward negative");
|
|
101
|
+
return 0;
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
getAvailableFarmingReward() {
|
|
106
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
107
|
+
if (!this.borrowableCache.availableFarmingReward)
|
|
108
|
+
this.borrowableCache.availableFarmingReward = this.initializeAvailableFarmingReward();
|
|
109
|
+
return this.borrowableCache.availableFarmingReward;
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
initializeAvailableRewarderReward() {
|
|
113
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
114
|
+
if (!(yield this.onchainPoolToken.hasRewarder()))
|
|
115
|
+
return 0;
|
|
116
|
+
const borrowableAddress = yield this.onchainPoolToken.getPoolTokenAddress();
|
|
117
|
+
const rewarder = yield this.onchainPoolToken.getRewarder();
|
|
118
|
+
try {
|
|
119
|
+
return (yield rewarder.methods.pendingReward(borrowableAddress, this.getAccountAddress()).call()) / 1e18;
|
|
120
|
+
}
|
|
121
|
+
catch (_a) {
|
|
122
|
+
console.log("Warning: pending reward negative");
|
|
123
|
+
return 0;
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
getAvailableRewarderReward() {
|
|
128
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
129
|
+
if (!this.borrowableCache.availableRewarderReward)
|
|
130
|
+
this.borrowableCache.availableRewarderReward = this.initializeAvailableRewarderReward();
|
|
131
|
+
return this.borrowableCache.availableRewarderReward;
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
exports.default = Borrowable;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import LendingPool from './index';
|
|
2
|
+
import { PoolTokenType } from '../../../config/types';
|
|
3
|
+
import * as onchain from '../../index';
|
|
4
|
+
import PoolToken from '../poolToken';
|
|
5
|
+
export default class Collateral extends PoolToken {
|
|
6
|
+
accountLendingPool: LendingPool;
|
|
7
|
+
poolToken: onchain.impermaxFactory.lendingPool.Collateral;
|
|
8
|
+
collateralCache: {};
|
|
9
|
+
constructor(accountLendingPool: LendingPool, poolTokenType: PoolTokenType);
|
|
10
|
+
cleanCache(): void;
|
|
11
|
+
fixStakedLPExchangeRate(n: Promise<number>): Promise<number>;
|
|
12
|
+
getAvailableBalanceUSD(): Promise<number>;
|
|
13
|
+
getDepositedUSD(): Promise<number>;
|
|
14
|
+
getMaxWithdrawable(): Promise<number>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
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("../../types");
|
|
16
|
+
const poolToken_1 = __importDefault(require("../poolToken"));
|
|
17
|
+
class Collateral extends poolToken_1.default {
|
|
18
|
+
constructor(accountLendingPool, poolTokenType) {
|
|
19
|
+
super();
|
|
20
|
+
this.collateralCache = {};
|
|
21
|
+
this.accountLendingPool = accountLendingPool;
|
|
22
|
+
this.account = accountLendingPool.account;
|
|
23
|
+
this.poolToken = accountLendingPool.lendingPool.poolTokens[poolTokenType];
|
|
24
|
+
}
|
|
25
|
+
cleanCache() {
|
|
26
|
+
super.cleanCache();
|
|
27
|
+
this.collateralCache = {};
|
|
28
|
+
}
|
|
29
|
+
fixStakedLPExchangeRate(n) {
|
|
30
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
31
|
+
const stakedLPExchangeRate = yield this.onchainPoolToken.lendingPool.getStakedLPExchangeRate();
|
|
32
|
+
return (yield n) / stakedLPExchangeRate;
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
getAvailableBalanceUSD() {
|
|
36
|
+
const _super = Object.create(null, {
|
|
37
|
+
getAvailableBalanceUSD: { get: () => super.getAvailableBalanceUSD }
|
|
38
|
+
});
|
|
39
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
40
|
+
return this.fixStakedLPExchangeRate(_super.getAvailableBalanceUSD.call(this));
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
getDepositedUSD() {
|
|
44
|
+
const _super = Object.create(null, {
|
|
45
|
+
getDepositedUSD: { get: () => super.getDepositedUSD }
|
|
46
|
+
});
|
|
47
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
48
|
+
return this.fixStakedLPExchangeRate(_super.getDepositedUSD.call(this));
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
// Max Withdrawable
|
|
52
|
+
getMaxWithdrawable() {
|
|
53
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
54
|
+
const deposited = yield this.getDeposited();
|
|
55
|
+
const availableCash = yield this.onchainPoolToken.getTotalBalance();
|
|
56
|
+
const { valueCollateral, valueA, valueB } = yield this.lendingPool.getValues(types_1.NO_CHANGES);
|
|
57
|
+
const safetyMargin = (yield this.lendingPool.getSafetyMargin()) * this.getUiMargin();
|
|
58
|
+
const liquidationPenalty = yield this.lendingPool.getLiquidationPenalty();
|
|
59
|
+
const actualCollateral = valueCollateral / liquidationPenalty;
|
|
60
|
+
const maxWithdrawable1 = (actualCollateral - (valueA + valueB * safetyMargin) / Math.sqrt(safetyMargin)) * liquidationPenalty;
|
|
61
|
+
const maxWithdrawable2 = (actualCollateral - (valueB + valueA * safetyMargin) / Math.sqrt(safetyMargin)) * liquidationPenalty;
|
|
62
|
+
return Math.max(0, Math.min(deposited, availableCash, maxWithdrawable1, maxWithdrawable2) / this.getDust());
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
exports.default = Collateral;
|
|
@@ -1,5 +1,12 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import * as nftlp from './nftlp';
|
|
2
|
+
import OnchainAccountBorrowable from "./onchainAccountBorrowable";
|
|
3
|
+
import OnchainAccountBorrowableV2 from "./onchainAccountBorrowableV2";
|
|
4
|
+
import OnchainAccountBorrowableV3 from "./onchainAccountBorrowableV3";
|
|
5
|
+
import OnchainAccountCollateral from "./onchainAccountCollateral";
|
|
6
|
+
import OnchainAccountCollateralV2 from "./onchainAccountCollateralV2";
|
|
7
|
+
import OnchainAccountCollateralV3 from "./onchainAccountCollateralV3";
|
|
8
|
+
import OnchainAccountLendingPool from './onchainAccountLendingPool';
|
|
9
|
+
import OnchainAccountLendingPoolV2 from "./onchainAccountLendingPoolV2";
|
|
10
|
+
import OnchainAccountLendingPoolV3 from "./onchainAccountLendingPoolV3";
|
|
11
|
+
export { nftlp, OnchainAccountBorrowable, OnchainAccountCollateral, OnchainAccountLendingPoolV2, OnchainAccountBorrowableV2, OnchainAccountCollateralV2, OnchainAccountLendingPoolV3, OnchainAccountBorrowableV3, OnchainAccountCollateralV3, };
|
|
12
|
+
export default OnchainAccountLendingPool;
|
|
@@ -1,12 +1,49 @@
|
|
|
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.OnchainAccountCollateralV3 = exports.OnchainAccountBorrowableV3 = exports.OnchainAccountLendingPoolV3 = exports.OnchainAccountCollateralV2 = exports.OnchainAccountBorrowableV2 = exports.OnchainAccountLendingPoolV2 = exports.OnchainAccountCollateral = exports.OnchainAccountBorrowable = exports.nftlp = void 0;
|
|
30
|
+
const nftlp = __importStar(require("./nftlp"));
|
|
31
|
+
exports.nftlp = nftlp;
|
|
32
|
+
const onchainAccountBorrowable_1 = __importDefault(require("./onchainAccountBorrowable"));
|
|
33
|
+
exports.OnchainAccountBorrowable = onchainAccountBorrowable_1.default;
|
|
34
|
+
const onchainAccountBorrowableV2_1 = __importDefault(require("./onchainAccountBorrowableV2"));
|
|
35
|
+
exports.OnchainAccountBorrowableV2 = onchainAccountBorrowableV2_1.default;
|
|
36
|
+
const onchainAccountBorrowableV3_1 = __importDefault(require("./onchainAccountBorrowableV3"));
|
|
37
|
+
exports.OnchainAccountBorrowableV3 = onchainAccountBorrowableV3_1.default;
|
|
38
|
+
const onchainAccountCollateral_1 = __importDefault(require("./onchainAccountCollateral"));
|
|
39
|
+
exports.OnchainAccountCollateral = onchainAccountCollateral_1.default;
|
|
40
|
+
const onchainAccountCollateralV2_1 = __importDefault(require("./onchainAccountCollateralV2"));
|
|
41
|
+
exports.OnchainAccountCollateralV2 = onchainAccountCollateralV2_1.default;
|
|
42
|
+
const onchainAccountCollateralV3_1 = __importDefault(require("./onchainAccountCollateralV3"));
|
|
43
|
+
exports.OnchainAccountCollateralV3 = onchainAccountCollateralV3_1.default;
|
|
44
|
+
const onchainAccountLendingPool_1 = __importDefault(require("./onchainAccountLendingPool"));
|
|
45
|
+
const onchainAccountLendingPoolV2_1 = __importDefault(require("./onchainAccountLendingPoolV2"));
|
|
46
|
+
exports.OnchainAccountLendingPoolV2 = onchainAccountLendingPoolV2_1.default;
|
|
47
|
+
const onchainAccountLendingPoolV3_1 = __importDefault(require("./onchainAccountLendingPoolV3"));
|
|
48
|
+
exports.OnchainAccountLendingPoolV3 = onchainAccountLendingPoolV3_1.default;
|
|
49
|
+
exports.default = onchainAccountLendingPool_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.OnchainAccountNftlpUniswapV3 = exports.OnchainAccountNftlp = void 0;
|
|
7
|
+
const onchainAccountNftlp_1 = __importDefault(require("./onchainAccountNftlp"));
|
|
8
|
+
exports.OnchainAccountNftlp = onchainAccountNftlp_1.default;
|
|
9
|
+
const onchainAccountNftlpUniswapV3_1 = __importDefault(require("./onchainAccountNftlpUniswapV3"));
|
|
10
|
+
exports.OnchainAccountNftlpUniswapV3 = onchainAccountNftlpUniswapV3_1.default;
|
|
11
|
+
exports.default = onchainAccountNftlp_1.default;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import OnchainAccountLendingPoolV3 from "../onchainAccountLendingPoolV3";
|
|
2
|
+
export default abstract class OnchainAccountNftlp {
|
|
3
|
+
protected readonly lendingPool: OnchainAccountLendingPoolV3;
|
|
4
|
+
protected cache: {};
|
|
5
|
+
constructor(lendingPool: OnchainAccountLendingPoolV3);
|
|
6
|
+
cleanCache(): void;
|
|
7
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
class OnchainAccountNftlp {
|
|
4
|
+
constructor(lendingPool) {
|
|
5
|
+
this.cache = {};
|
|
6
|
+
this.lendingPool = lendingPool;
|
|
7
|
+
}
|
|
8
|
+
cleanCache() {
|
|
9
|
+
this.cache = {};
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
exports.default = OnchainAccountNftlp;
|
|
@@ -0,0 +1,13 @@
|
|
|
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 onchainAccountNftlp_1 = __importDefault(require("./onchainAccountNftlp"));
|
|
7
|
+
class OnchainAccountNftlpUniswapV3 extends onchainAccountNftlp_1.default {
|
|
8
|
+
constructor() {
|
|
9
|
+
super(...arguments);
|
|
10
|
+
this.cache = {};
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
exports.default = OnchainAccountNftlpUniswapV3;
|
|
@@ -1,34 +1,39 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import OnchainAccountLendingPool from './index';
|
|
3
|
-
import OnchainAccountPoolToken from '../onchainAccountPoolToken';
|
|
4
|
-
import OnchainBorrowable from '../../impermaxFactory/lendingPool/onchainBorrowable';
|
|
5
|
-
import OnchainInteractionsBorrowable from '../../interactions/lendingPool/onchainInteractionsBorrowable';
|
|
6
|
-
import OffchainAccountBorrowable from '../../../offchain/account/lendingPool/offchainAccountBorrowable';
|
|
7
|
-
export default class OnchainAccountBorrowable extends OnchainAccountPoolToken {
|
|
8
|
-
|
|
9
|
-
protected readonly poolToken: OnchainBorrowable;
|
|
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 { Borrowable } from '../../../config/types';
|
|
2
|
+
import OnchainAccountLendingPool from './index';
|
|
3
|
+
import OnchainAccountPoolToken from '../onchainAccountPoolToken';
|
|
4
|
+
import OnchainBorrowable from '../../impermaxFactory/lendingPool/onchainBorrowable';
|
|
5
|
+
import OnchainInteractionsBorrowable from '../../interactions/lendingPool/onchainInteractionsBorrowable';
|
|
6
|
+
import OffchainAccountBorrowable from '../../../offchain/account/lendingPool/offchainAccountBorrowable';
|
|
7
|
+
export default abstract class OnchainAccountBorrowable extends OnchainAccountPoolToken {
|
|
8
|
+
protected readonly lendingPool: OnchainAccountLendingPool;
|
|
9
|
+
protected readonly poolToken: OnchainBorrowable;
|
|
10
|
+
protected borrowableCache: {
|
|
11
|
+
borrowed?: Promise<number>;
|
|
12
|
+
farmingShares?: Promise<number>;
|
|
13
|
+
availableFarmingReward?: Promise<number>;
|
|
14
|
+
availableRewarderReward?: Promise<number>;
|
|
15
|
+
};
|
|
16
|
+
constructor(lendingPool: OnchainAccountLendingPool, borrowable: Borrowable);
|
|
17
|
+
getLendingPool: () => OnchainAccountLendingPool;
|
|
18
|
+
getPoolToken: () => OnchainBorrowable;
|
|
19
|
+
getAccount: () => import("..").default;
|
|
20
|
+
getInteractionsPoolToken(): OnchainInteractionsBorrowable;
|
|
21
|
+
getInteractionsBorrowable: () => OnchainInteractionsBorrowable;
|
|
22
|
+
getOffchainAccountPoolToken(): Promise<OffchainAccountBorrowable>;
|
|
23
|
+
getOffchainAccountBorrowable: () => Promise<OffchainAccountBorrowable>;
|
|
24
|
+
cleanCache(): void;
|
|
25
|
+
protected getBorrowableType: () => Borrowable;
|
|
26
|
+
getSupplyAPR: () => Promise<number>;
|
|
27
|
+
getBorrowRate: () => Promise<number>;
|
|
28
|
+
getAccrualTimestamp: () => Promise<number>;
|
|
29
|
+
private initializeBorrowed;
|
|
30
|
+
getBorrowed(): Promise<number>;
|
|
31
|
+
getBorrowedUSD(): Promise<number>;
|
|
32
|
+
abstract getMaxBorrowable(): Promise<number>;
|
|
33
|
+
private initializeFarmingShares;
|
|
34
|
+
getFarmingShares(): Promise<number>;
|
|
35
|
+
private initializeAvailableFarmingReward;
|
|
36
|
+
getAvailableFarmingReward(): Promise<number>;
|
|
37
|
+
private initializeAvailableRewarderReward;
|
|
38
|
+
getAvailableRewarderReward(): Promise<number>;
|
|
39
|
+
}
|