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,285 @@
|
|
|
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 onchainTypes_1 = require("../../onchainTypes");
|
|
17
|
+
const factories_1 = require("../../../config/factories");
|
|
18
|
+
const lliquidity_math_1 = require("../../../utils/lliquidity-math");
|
|
19
|
+
const utils_1 = require("../../../utils");
|
|
20
|
+
const onchainAccountLendingPool_1 = __importDefault(require("./onchainAccountLendingPool"));
|
|
21
|
+
const onchainAccountBorrowableV2_1 = __importDefault(require("./onchainAccountBorrowableV2"));
|
|
22
|
+
const onchainAccountCollateralV2_1 = __importDefault(require("./onchainAccountCollateralV2"));
|
|
23
|
+
class OnchainAccountLendingPoolV2 extends onchainAccountLendingPool_1.default {
|
|
24
|
+
constructor() {
|
|
25
|
+
super(...arguments);
|
|
26
|
+
// Shortcuts
|
|
27
|
+
this.getLendingPool = () => this.lendingPool;
|
|
28
|
+
this.getBorrowable = (borrowable) => this.borrowables[borrowable];
|
|
29
|
+
this.getBorrowableA = () => this.getBorrowable(types_1.Borrowable.A);
|
|
30
|
+
this.getBorrowableB = () => this.getBorrowable(types_1.Borrowable.B);
|
|
31
|
+
this.getCollateral = () => this.collateral;
|
|
32
|
+
}
|
|
33
|
+
getNewCollateralObject() {
|
|
34
|
+
return new onchainAccountCollateralV2_1.default(this);
|
|
35
|
+
}
|
|
36
|
+
getNewBorrowableObject(borrowable) {
|
|
37
|
+
return new onchainAccountBorrowableV2_1.default(this, borrowable);
|
|
38
|
+
}
|
|
39
|
+
getInteractionsLendingPool() {
|
|
40
|
+
return this.account.getInteractions().getLendingPool(this.getFactory(), this.getId());
|
|
41
|
+
}
|
|
42
|
+
// LP equity number in LPs
|
|
43
|
+
getLPEquity() {
|
|
44
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
45
|
+
const lpEquityUSD = yield this.getLPEquityUSD();
|
|
46
|
+
const tokenPrice = yield this.getCollateral().getTokenPriceAccurate();
|
|
47
|
+
const stakedLPExchangeRate = yield this.lendingPool.getStakedLPExchangeRate();
|
|
48
|
+
return lpEquityUSD / tokenPrice * stakedLPExchangeRate;
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
// Values
|
|
52
|
+
getValuesFromPrice(changes, priceA, priceB) {
|
|
53
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
54
|
+
const valueCollateral = (yield this.getCollateral().getDeposited()) + changes.changeCollateral;
|
|
55
|
+
const amountA = (yield this.getBorrowableA().getBorrowed()) + changes.changeBorrowedA;
|
|
56
|
+
const amountB = (yield this.getBorrowableB().getBorrowed()) + changes.changeBorrowedB;
|
|
57
|
+
const valueA = amountA * priceA;
|
|
58
|
+
const valueB = amountB * priceB;
|
|
59
|
+
return {
|
|
60
|
+
valueCollateral: valueCollateral > 0 ? valueCollateral : 0,
|
|
61
|
+
valueA: valueA > 0 ? valueA : 0,
|
|
62
|
+
valueB: valueB > 0 ? valueB : 0,
|
|
63
|
+
};
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
getValues(changes) {
|
|
67
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
68
|
+
const [priceA, priceB] = yield this.lendingPool.getPriceDenomLP();
|
|
69
|
+
return this.getValuesFromPrice(changes, priceA, priceB);
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
getMarketValues(changes) {
|
|
73
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
74
|
+
const [priceA, priceB] = yield this.lendingPool.getMarketPriceDenomLP();
|
|
75
|
+
return this.getValuesFromPrice(changes, priceA, priceB);
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
// Leverage
|
|
79
|
+
getLeverage(changes) {
|
|
80
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
81
|
+
if (!changes)
|
|
82
|
+
changes = onchainTypes_1.NO_CHANGES;
|
|
83
|
+
const { valueCollateral, valueA, valueB } = yield this.getValues(changes);
|
|
84
|
+
const valueDebt = valueA + valueB;
|
|
85
|
+
if (valueDebt == 0)
|
|
86
|
+
return 1;
|
|
87
|
+
const equity = valueCollateral - valueDebt;
|
|
88
|
+
if (equity <= 0)
|
|
89
|
+
return Infinity;
|
|
90
|
+
return valueDebt / equity + 1;
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
// Liquidation Threshold
|
|
94
|
+
/*public async getLiquidationPriceSwingsGivenValues(values: Values) : Promise<[number, number]> {
|
|
95
|
+
if (!values) return [Infinity, Infinity];
|
|
96
|
+
const { valueCollateral, valueA, valueB } = values;
|
|
97
|
+
if (valueA + valueB == 0) return [Infinity, Infinity];
|
|
98
|
+
const safetyMargin = await this.getSafetyMargin();
|
|
99
|
+
const liquidationPenalty = await this.getLiquidationPenalty();
|
|
100
|
+
const actualCollateral = valueCollateral / liquidationPenalty;
|
|
101
|
+
const rad = Math.sqrt(actualCollateral ** 2 - 4 * valueA * valueB);
|
|
102
|
+
if (!rad) return [0, 0];
|
|
103
|
+
const t = (actualCollateral + rad) / (2 * Math.sqrt(safetyMargin));
|
|
104
|
+
let priceSwingA = (t / valueA) ** 2;
|
|
105
|
+
let priceSwingB = (t / valueB) ** 2;
|
|
106
|
+
return [priceSwingA, priceSwingB];
|
|
107
|
+
}
|
|
108
|
+
public async getLiquidationPricesGivenValues(values: Values) : Promise<[number, number]> {
|
|
109
|
+
const currentPrice = await this.lendingPool.getTWAPPrice();
|
|
110
|
+
const [priceSwingA, priceSwingB] = await this.getLiquidationPriceSwingsGivenValues(values);
|
|
111
|
+
return !this.account.getOnchain().priceInverted ? [currentPrice / priceSwingB, currentPrice * priceSwingA] : [currentPrice / priceSwingA, currentPrice * priceSwingB];
|
|
112
|
+
}
|
|
113
|
+
public async getLiquidationPriceSwings(changes?: Changes) {
|
|
114
|
+
if (!changes) changes = NO_CHANGES;
|
|
115
|
+
const values = await this.getValues(changes);
|
|
116
|
+
return this.getLiquidationPriceSwingsGivenValues(values);
|
|
117
|
+
}
|
|
118
|
+
public async getLiquidationPrices(changes?: Changes) {
|
|
119
|
+
if (!changes) changes = NO_CHANGES;
|
|
120
|
+
const values = await this.getValues(changes);
|
|
121
|
+
return this.getLiquidationPricesGivenValues(values);
|
|
122
|
+
}*/
|
|
123
|
+
getLiquidationPrices(changes) {
|
|
124
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
125
|
+
if (!changes)
|
|
126
|
+
changes = onchainTypes_1.NO_CHANGES;
|
|
127
|
+
const collateralAmount = Math.max((yield this.getCollateral().getDeposited()) + changes.changeCollateral, 0);
|
|
128
|
+
const debtA = Math.max((yield this.getBorrowableA().getBorrowed()) + changes.changeBorrowedA, 0);
|
|
129
|
+
const debtB = Math.max((yield this.getBorrowableB().getBorrowed()) + changes.changeBorrowedB, 0);
|
|
130
|
+
const safetyMargin = yield this.getSafetyMargin();
|
|
131
|
+
const liquidationPenalty = yield this.getLiquidationPenalty();
|
|
132
|
+
const actualCollateral = collateralAmount / liquidationPenalty;
|
|
133
|
+
const [reservesWeight0, reservesWeight1] = yield this.lendingPool.getTwapReservesWeights();
|
|
134
|
+
const [priceA, priceB] = yield this.lendingPool.getPriceDenomLP();
|
|
135
|
+
const collateralA = actualCollateral * reservesWeight0 / priceA;
|
|
136
|
+
const collateralB = actualCollateral * reservesWeight1 / priceB;
|
|
137
|
+
let priceSwingA, priceSwingB;
|
|
138
|
+
if (factories_1.STABLE_FACTORIES.includes(this.lendingPool.getImpermaxFactory().getFactory())) {
|
|
139
|
+
priceSwingA = (0, lliquidity_math_1.solidlyStable_getLiquidatableXPriceDecrease)(collateralA, collateralB, debtA, debtB) * safetyMargin;
|
|
140
|
+
priceSwingB = (0, lliquidity_math_1.solidlyStable_getLiquidatableXPriceDecrease)(collateralB, collateralA, debtB, debtA) * safetyMargin;
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
priceSwingA = (0, lliquidity_math_1.uniswapV2_getLiquidatableXPriceDecrease)(collateralA, collateralB, debtA, debtB) * safetyMargin;
|
|
144
|
+
priceSwingB = (0, lliquidity_math_1.uniswapV2_getLiquidatableXPriceDecrease)(collateralB, collateralA, debtB, debtA) * safetyMargin;
|
|
145
|
+
}
|
|
146
|
+
const twapPrice = yield this.lendingPool.getTWAPPrice();
|
|
147
|
+
return !this.account.getOnchain().priceInverted
|
|
148
|
+
? [twapPrice * priceSwingA, twapPrice / priceSwingB]
|
|
149
|
+
: [twapPrice * priceSwingB, twapPrice / priceSwingA];
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
// Max Leverage
|
|
153
|
+
/*public async getMaxLeverage() : Promise<number> {
|
|
154
|
+
const availableCashA = await this.getBorrowableA().getPoolToken().getTotalBalance();
|
|
155
|
+
const availableCashB = await this.getBorrowableB().getPoolToken().getTotalBalance();
|
|
156
|
+
const [priceA, priceB] = await this.lendingPool.getMarketPriceDenomLP();
|
|
157
|
+
const [priceATWAP,] = await this.lendingPool.getPriceDenomLP();
|
|
158
|
+
const diff = priceA > priceATWAP ? priceA / priceATWAP : priceATWAP / priceA;
|
|
159
|
+
const adjustFactor = 1 / diff;
|
|
160
|
+
const availableCashValue1 = availableCashA * priceA;
|
|
161
|
+
const availableCashValue2 = availableCashB * priceB;
|
|
162
|
+
const { valueCollateral, valueA, valueB } = await this.getValues(NO_CHANGES);
|
|
163
|
+
const safetyMargin = (await this.getSafetyMargin()) * this.getUiMargin();
|
|
164
|
+
const liquidationPenalty = await this.getLiquidationPenalty();
|
|
165
|
+
const actualCollateral = valueCollateral / liquidationPenalty;
|
|
166
|
+
const num1 = actualCollateral * Math.sqrt(safetyMargin) - valueA * safetyMargin - valueB;
|
|
167
|
+
const num2 = actualCollateral * Math.sqrt(safetyMargin) - valueB * safetyMargin - valueA;
|
|
168
|
+
const den = safetyMargin + 1 - 2 * Math.sqrt(safetyMargin) / liquidationPenalty;
|
|
169
|
+
const additionalValueBorrowablePerSide = Math.min(num1 / den, num2 / den, availableCashValue1, availableCashValue2) * adjustFactor;
|
|
170
|
+
const valueDebt = valueA + valueB;
|
|
171
|
+
const equity = valueCollateral - valueDebt;
|
|
172
|
+
if (equity == 0) return 1;
|
|
173
|
+
return (valueDebt + additionalValueBorrowablePerSide * 2) / equity + 1;
|
|
174
|
+
}*/
|
|
175
|
+
// binary search how much additional leverage we can get
|
|
176
|
+
getMaxLeverage() {
|
|
177
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
178
|
+
const availableCashA = yield this.getBorrowableA().getPoolToken().getTotalBalance();
|
|
179
|
+
const availableCashB = yield this.getBorrowableB().getPoolToken().getTotalBalance();
|
|
180
|
+
const collateralAmount = yield this.getCollateral().getDeposited();
|
|
181
|
+
const [reservesWeight0, reservesWeight1] = yield this.lendingPool.getMarketReservesWeights();
|
|
182
|
+
//const [priceA, priceB] = await this.lendingPool.getPriceDenomLP();
|
|
183
|
+
//TODO come posso adattare l'aggiustamento alle stable pairs?
|
|
184
|
+
const [priceA, priceB] = yield this.lendingPool.getMarketPriceDenomLP();
|
|
185
|
+
const [priceATWAP,] = yield this.lendingPool.getPriceDenomLP();
|
|
186
|
+
const diff = priceA > priceATWAP ? priceA / priceATWAP : priceATWAP / priceA;
|
|
187
|
+
const collateralA = collateralAmount * reservesWeight0 / priceA;
|
|
188
|
+
const collateralB = collateralAmount * reservesWeight1 / priceB;
|
|
189
|
+
const twapPrice = yield this.lendingPool.getTWAPPrice();
|
|
190
|
+
// start search
|
|
191
|
+
let addLev = 100;
|
|
192
|
+
let addLevPrev = 0;
|
|
193
|
+
let bestChanges = onchainTypes_1.NO_CHANGES;
|
|
194
|
+
for (let i = 0; i < 1000; i++) {
|
|
195
|
+
const jump = Math.abs(addLev - addLevPrev) / 2;
|
|
196
|
+
if (jump < 0.01)
|
|
197
|
+
break;
|
|
198
|
+
addLevPrev = addLev;
|
|
199
|
+
const adjustFactor = Math.pow((0, utils_1.impermanentLoss)(Math.pow(diff, 2)), addLev);
|
|
200
|
+
const actualAddLev = addLev * adjustFactor;
|
|
201
|
+
const changeCollateral = collateralAmount * actualAddLev;
|
|
202
|
+
const changeBorrowedA = collateralA * actualAddLev;
|
|
203
|
+
const changeBorrowedB = collateralB * actualAddLev;
|
|
204
|
+
if (changeBorrowedA > availableCashA || changeBorrowedB > availableCashB) {
|
|
205
|
+
addLev -= jump;
|
|
206
|
+
continue;
|
|
207
|
+
}
|
|
208
|
+
const changes = { changeCollateral, changeBorrowedA, changeBorrowedB };
|
|
209
|
+
const [liqPriceA, liqPriceB] = yield this.getLiquidationPrices(changes);
|
|
210
|
+
if (liqPriceA * this.getUiMargin() > twapPrice || liqPriceB / this.getUiMargin() < twapPrice)
|
|
211
|
+
addLev -= jump;
|
|
212
|
+
else {
|
|
213
|
+
bestChanges = changes;
|
|
214
|
+
addLev += jump;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
const maxLeverage = yield this.getLeverage(bestChanges);
|
|
218
|
+
return Math.floor(maxLeverage * 100) / 100;
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
// Max Deleverage
|
|
222
|
+
getMaxDeleverage(slippage) {
|
|
223
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
224
|
+
const { valueCollateral, valueA, valueB } = yield this.getMarketValues(onchainTypes_1.NO_CHANGES);
|
|
225
|
+
const [reservesWeight0, reservesWeight1] = yield this.lendingPool.getMarketReservesWeights();
|
|
226
|
+
const collateralValueA = valueCollateral * reservesWeight0;
|
|
227
|
+
const collateralValueB = valueCollateral * reservesWeight1;
|
|
228
|
+
if (collateralValueA >= valueA && collateralValueB >= valueB) {
|
|
229
|
+
return (yield this.getCollateral().getDeposited()) * this.account.getOnchain().dust;
|
|
230
|
+
}
|
|
231
|
+
if (valueCollateral < valueA + valueB) {
|
|
232
|
+
return 0;
|
|
233
|
+
}
|
|
234
|
+
if (valueA / collateralValueA < valueB / collateralValueB) {
|
|
235
|
+
return (valueA + valueA / collateralValueA * collateralValueB);
|
|
236
|
+
}
|
|
237
|
+
else {
|
|
238
|
+
return (valueB + valueB / collateralValueB * collateralValueA);
|
|
239
|
+
}
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
// Available Reward
|
|
243
|
+
getAvailableReward() {
|
|
244
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
245
|
+
const result = [];
|
|
246
|
+
const farmingAmount = (yield this.getBorrowableA().getAvailableFarmingReward()) + (yield this.getBorrowableB().getAvailableFarmingReward());
|
|
247
|
+
if (farmingAmount > 0) {
|
|
248
|
+
const farmingSymbol = yield this.getBorrowableA().getPoolToken().getFarmingTokenSymbol();
|
|
249
|
+
result.push({
|
|
250
|
+
symbol: farmingSymbol,
|
|
251
|
+
amount: farmingAmount
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
const rewarderSymbols = [
|
|
255
|
+
yield this.getBorrowableA().getPoolToken().getRewarderTokenSymbol(),
|
|
256
|
+
yield this.getBorrowableB().getPoolToken().getRewarderTokenSymbol()
|
|
257
|
+
];
|
|
258
|
+
const rewarderAmounts = [
|
|
259
|
+
yield this.getBorrowableA().getAvailableRewarderReward(),
|
|
260
|
+
yield this.getBorrowableB().getAvailableRewarderReward()
|
|
261
|
+
];
|
|
262
|
+
if (rewarderSymbols[0] === rewarderSymbols[1]) {
|
|
263
|
+
const rewarderAmount = rewarderAmounts[0] + rewarderAmounts[1];
|
|
264
|
+
if (rewarderAmount === 0)
|
|
265
|
+
return result;
|
|
266
|
+
result.push({
|
|
267
|
+
symbol: rewarderSymbols[0],
|
|
268
|
+
amount: rewarderAmount
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
else {
|
|
272
|
+
for (let i = 0; i < 2; i++) {
|
|
273
|
+
if (rewarderAmounts[i] === 0)
|
|
274
|
+
continue;
|
|
275
|
+
result.push({
|
|
276
|
+
symbol: rewarderSymbols[i],
|
|
277
|
+
amount: rewarderAmounts[i]
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
return result;
|
|
282
|
+
});
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
exports.default = OnchainAccountLendingPoolV2;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Borrowable } from '../../../config/types';
|
|
2
|
+
import { OnchainLendingPoolV3 } from '../../impermaxFactory/lendingPool';
|
|
3
|
+
import OnchainAccountLendingPool from "./onchainAccountLendingPool";
|
|
4
|
+
import OnchainAccountCollateralV3 from "./onchainAccountCollateralV3";
|
|
5
|
+
import OnchainAccountBorrowableV3 from "./onchainAccountBorrowableV3";
|
|
6
|
+
import { OnchainInteractionsLendingPoolV3 } from "../../interactions/lendingPool";
|
|
7
|
+
import OnchainAccountNftlp from "./nftlp";
|
|
8
|
+
import OnchainAccount from "../index";
|
|
9
|
+
export default class OnchainAccountLendingPoolV3 extends OnchainAccountLendingPool {
|
|
10
|
+
protected readonly lendingPool: OnchainLendingPoolV3;
|
|
11
|
+
protected readonly collateral: OnchainAccountCollateralV3;
|
|
12
|
+
protected readonly borrowables: {
|
|
13
|
+
[Borrowable.A]: OnchainAccountBorrowableV3;
|
|
14
|
+
[Borrowable.B]: OnchainAccountBorrowableV3;
|
|
15
|
+
};
|
|
16
|
+
protected readonly nftlp: OnchainAccountNftlp;
|
|
17
|
+
constructor(account: OnchainAccount, lendingPool: OnchainLendingPoolV3);
|
|
18
|
+
protected getNewCollateralObject(): OnchainAccountCollateralV3;
|
|
19
|
+
protected getNewBorrowableObject(borrowable: Borrowable): OnchainAccountBorrowableV3;
|
|
20
|
+
getLendingPool: () => OnchainLendingPoolV3;
|
|
21
|
+
getBorrowable: (borrowable: Borrowable) => OnchainAccountBorrowableV3;
|
|
22
|
+
getBorrowableA: () => OnchainAccountBorrowableV3;
|
|
23
|
+
getBorrowableB: () => OnchainAccountBorrowableV3;
|
|
24
|
+
getCollateral: () => OnchainAccountCollateralV3;
|
|
25
|
+
getNftlp: () => OnchainAccountNftlp;
|
|
26
|
+
getInteractionsLendingPool(): OnchainInteractionsLendingPoolV3;
|
|
27
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const types_1 = require("../../../config/types");
|
|
7
|
+
const onchainAccountLendingPool_1 = __importDefault(require("./onchainAccountLendingPool"));
|
|
8
|
+
const onchainAccountCollateralV3_1 = __importDefault(require("./onchainAccountCollateralV3"));
|
|
9
|
+
const onchainAccountBorrowableV3_1 = __importDefault(require("./onchainAccountBorrowableV3"));
|
|
10
|
+
class OnchainAccountLendingPoolV3 extends onchainAccountLendingPool_1.default {
|
|
11
|
+
constructor(account, lendingPool) {
|
|
12
|
+
super(account, lendingPool);
|
|
13
|
+
// Shortcuts
|
|
14
|
+
this.getLendingPool = () => this.lendingPool;
|
|
15
|
+
this.getBorrowable = (borrowable) => this.borrowables[borrowable];
|
|
16
|
+
this.getBorrowableA = () => this.getBorrowable(types_1.Borrowable.A);
|
|
17
|
+
this.getBorrowableB = () => this.getBorrowable(types_1.Borrowable.B);
|
|
18
|
+
this.getCollateral = () => this.collateral;
|
|
19
|
+
this.getNftlp = () => this.nftlp;
|
|
20
|
+
this.nftlp = lendingPool.getNftlp().getNewAccountNftlpObject(this);
|
|
21
|
+
}
|
|
22
|
+
getNewCollateralObject() {
|
|
23
|
+
return new onchainAccountCollateralV3_1.default(this);
|
|
24
|
+
}
|
|
25
|
+
getNewBorrowableObject(borrowable) {
|
|
26
|
+
return new onchainAccountBorrowableV3_1.default(this, borrowable);
|
|
27
|
+
}
|
|
28
|
+
getInteractionsLendingPool() {
|
|
29
|
+
return this.account.getInteractions().getLendingPool(this.getFactory(), this.getId());
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
exports.default = OnchainAccountLendingPoolV3;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import Account from "./";
|
|
2
|
+
import PoolToken from './poolToken';
|
|
3
|
+
import * as onchain from '../index';
|
|
4
|
+
export default class LendingVault extends PoolToken {
|
|
5
|
+
poolToken: onchain.LendingVault;
|
|
6
|
+
lendingVaultCache: {};
|
|
7
|
+
constructor(account: Account, lendingVault: onchain.LendingVault);
|
|
8
|
+
cleanCache(): void;
|
|
9
|
+
getMaxWithdrawable(): Promise<number>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
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 LendingVault extends poolToken_1.default {
|
|
17
|
+
constructor(account, lendingVault) {
|
|
18
|
+
super();
|
|
19
|
+
this.lendingVaultCache = {};
|
|
20
|
+
this.account = account;
|
|
21
|
+
this.poolToken = lendingVault;
|
|
22
|
+
}
|
|
23
|
+
cleanCache() {
|
|
24
|
+
this.cache = {};
|
|
25
|
+
this.lendingVaultCache = {};
|
|
26
|
+
}
|
|
27
|
+
// OnchainInteractions
|
|
28
|
+
getMaxWithdrawable() {
|
|
29
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
30
|
+
return Math.min(yield this.getDeposited(), yield this.onchainPoolToken.getAvailableLiquidity()) / this.getDust();
|
|
31
|
+
// TODO remove dust?
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
exports.default = LendingVault;
|
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
import OnChain from '../index';
|
|
2
|
-
import { Address, Factory, FactoryIndex, LendingPoolIndex } from '../../config/types';
|
|
3
|
-
import OnchainAccountLendingPool from './lendingPool';
|
|
4
|
-
import OnchainAccountLendingVault from './onchainAccountLendingVault';
|
|
5
|
-
import { AirdropData, PendingRewardUI } from '../onchainTypes';
|
|
6
|
-
export default class OnchainAccount {
|
|
7
|
-
private readonly onchain;
|
|
8
|
-
private readonly accountAddress;
|
|
9
|
-
private readonly lendingPools;
|
|
10
|
-
private readonly lendingVaults;
|
|
11
|
-
private cache;
|
|
12
|
-
constructor(onchain: OnChain, account: Address);
|
|
13
|
-
getOnchain: () => OnChain;
|
|
14
|
-
getAccountAddress: () => string;
|
|
15
|
-
getInteractions: () => import("../index").OnchainInteractions;
|
|
16
|
-
getOffchainAccount: () => import("../..").OffchainAccount;
|
|
17
|
-
cleanCache(): Promise<void>;
|
|
18
|
-
private initializeLendingPool;
|
|
19
|
-
getLendingPool(factory: Factory, pair: Address): OnchainAccountLendingPool;
|
|
20
|
-
private initializeLendingVault;
|
|
21
|
-
getLendingVault(vaultAddress: Address): OnchainAccountLendingVault;
|
|
22
|
-
getMassAvailableReward(pairs: FactoryIndex<Address[]>): Promise<LendingPoolIndex<PendingRewardUI[]>>;
|
|
23
|
-
private initializeAirdropData;
|
|
24
|
-
private getAirdropData;
|
|
25
|
-
getIbexAirdropData(): Promise<AirdropData>;
|
|
26
|
-
getIbex2AirdropData(): Promise<AirdropData>;
|
|
27
|
-
getEthAirdropData(): Promise<AirdropData>;
|
|
28
|
-
hasIbexClaimableAirdrop(): Promise<boolean>;
|
|
29
|
-
hasEthClaimableAirdrop(): Promise<boolean>;
|
|
30
|
-
private initializeClaimableIBEX;
|
|
31
|
-
getClaimableIBEX(claimableAddress: Address): Promise<number>;
|
|
32
|
-
}
|
|
1
|
+
import OnChain from '../index';
|
|
2
|
+
import { Address, Factory, FactoryIndex, LendingPoolIndex } from '../../config/types';
|
|
3
|
+
import OnchainAccountLendingPool from './lendingPool';
|
|
4
|
+
import OnchainAccountLendingVault from './onchainAccountLendingVault';
|
|
5
|
+
import { AirdropData, PendingRewardUI } from '../onchainTypes';
|
|
6
|
+
export default class OnchainAccount {
|
|
7
|
+
private readonly onchain;
|
|
8
|
+
private readonly accountAddress;
|
|
9
|
+
private readonly lendingPools;
|
|
10
|
+
private readonly lendingVaults;
|
|
11
|
+
private cache;
|
|
12
|
+
constructor(onchain: OnChain, account: Address);
|
|
13
|
+
getOnchain: () => OnChain;
|
|
14
|
+
getAccountAddress: () => string;
|
|
15
|
+
getInteractions: () => import("../index").OnchainInteractions;
|
|
16
|
+
getOffchainAccount: () => import("../..").OffchainAccount;
|
|
17
|
+
cleanCache(): Promise<void>;
|
|
18
|
+
private initializeLendingPool;
|
|
19
|
+
getLendingPool(factory: Factory, pair: Address): OnchainAccountLendingPool;
|
|
20
|
+
private initializeLendingVault;
|
|
21
|
+
getLendingVault(vaultAddress: Address): OnchainAccountLendingVault;
|
|
22
|
+
getMassAvailableReward(pairs: FactoryIndex<Address[]>): Promise<LendingPoolIndex<PendingRewardUI[]>>;
|
|
23
|
+
private initializeAirdropData;
|
|
24
|
+
private getAirdropData;
|
|
25
|
+
getIbexAirdropData(): Promise<AirdropData>;
|
|
26
|
+
getIbex2AirdropData(): Promise<AirdropData>;
|
|
27
|
+
getEthAirdropData(): Promise<AirdropData>;
|
|
28
|
+
hasIbexClaimableAirdrop(): Promise<boolean>;
|
|
29
|
+
hasEthClaimableAirdrop(): Promise<boolean>;
|
|
30
|
+
private initializeClaimableIBEX;
|
|
31
|
+
getClaimableIBEX(claimableAddress: Address): Promise<number>;
|
|
32
|
+
}
|