impermax-sdk 1.2.112 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/abis/ImpermaxABI.d.ts +2 -2
- package/lib/abis/ImpermaxABI.js +3 -3
- package/lib/abis/contracts/ClaimAggregator.json +2015 -2015
- package/lib/abis/contracts/IAllowanceTransfer.json +3772 -0
- package/lib/abis/contracts/IBorrowable.json +13207 -13207
- package/lib/abis/contracts/IClaimable.json +406 -406
- package/lib/abis/contracts/ICollateral.json +9052 -9052
- package/lib/abis/contracts/IERC20.json +2376 -2376
- package/lib/abis/contracts/IERC721.json +3515 -0
- package/lib/abis/contracts/IFactory.json +3660 -3660
- package/lib/abis/contracts/IFarmingPool.json +3584 -3584
- package/lib/abis/contracts/ILendingVaultV1.json +8358 -8358
- package/lib/abis/contracts/IMerkleDistributor.json +1134 -1134
- package/lib/abis/contracts/IRouter02.json +7283 -7283
- package/lib/abis/contracts/ISimpleUniswapOracle.json +1469 -1469
- package/lib/abis/contracts/IStakedLPToken.json +7309 -7309
- package/lib/abis/contracts/IStakingRewards.json +1036 -1036
- package/lib/abis/contracts/ITokenizedUniswapV2Position.json +4167 -0
- package/lib/abis/contracts/ITokenizedUniswapV3Position.json +5539 -0
- package/lib/abis/contracts/IUniswapV2Factory.json +1690 -1690
- package/lib/abis/contracts/IUniswapV2Pair.json +6761 -6761
- package/lib/abis/contracts/IUniswapV3Pool.json +6606 -0
- package/lib/abis/contracts/ImpermaxChef.json +20945 -20945
- package/lib/abis/contracts/ImpermaxConfigManager.json +31595 -31595
- package/lib/abis/contracts/ImpermaxV3Borrowable.json +22131 -0
- package/lib/abis/contracts/ImpermaxV3Collateral.json +22988 -0
- package/lib/abis/contracts/ImpermaxV3Factory.json +17645 -0
- package/lib/abis/contracts/ImpermaxV3UniV2Router01.json +32488 -0
- package/lib/abis/contracts/ImpermaxV3UniV3Router01.json +37742 -0
- package/lib/abis/contracts/LendingVaultWatcher01.json +4076 -4076
- package/lib/abis/contracts/PoolTokenRouter01.json +9058 -0
- package/lib/config/amms.d.ts +102 -104
- package/lib/config/amms.js +433 -436
- package/lib/config/chainId.d.ts +2 -0
- package/lib/config/chainId.js +26 -0
- package/lib/config/contracts/claim-aggregators.d.ts +2 -2
- package/lib/config/contracts/claim-aggregators.js +26 -26
- package/lib/config/contracts/impermax-chef.d.ts +2 -2
- package/lib/config/contracts/impermax-chef.js +27 -27
- package/lib/config/contracts/impermax-config-manager.d.ts +2 -2
- package/lib/config/contracts/impermax-config-manager.js +26 -26
- package/lib/config/contracts/impermax-factories.d.ts +4 -4
- package/lib/config/contracts/impermax-factories.js +87 -87
- package/lib/config/contracts/imxes.d.ts +2 -2
- package/lib/config/contracts/imxes.js +26 -26
- package/lib/config/contracts/lending-vault-watcher.d.ts +2 -2
- package/lib/config/contracts/lending-vault-watcher.js +26 -26
- package/lib/config/contracts/merkle-distributors.d.ts +4 -4
- package/lib/config/contracts/merkle-distributors.js +70 -70
- package/lib/config/contracts/routers.d.ts +4 -3
- package/lib/config/contracts/routers.js +118 -94
- package/lib/config/contracts/simple-uniswap-oracles.d.ts +2 -2
- package/lib/config/contracts/simple-uniswap-oracles.js +49 -49
- package/lib/config/contracts/weths.d.ts +2 -2
- package/lib/config/contracts/weths.js +27 -27
- package/lib/config/debank-ids.d.ts +2 -2
- package/lib/config/debank-ids.js +26 -26
- package/lib/config/endpoints/merkle-distributors.d.ts +4 -4
- package/lib/config/endpoints/merkle-distributors.js +70 -70
- package/lib/config/eth.d.ts +3 -3
- package/lib/config/eth.js +48 -48
- package/lib/config/factories.d.ts +7 -7
- package/lib/config/factories.js +31 -30
- package/lib/config/farms.d.ts +109 -111
- package/lib/config/farms.js +207 -210
- package/lib/config/general.d.ts +5 -5
- package/lib/config/general.js +8 -8
- package/lib/config/subgraphs.d.ts +45 -45
- package/lib/config/subgraphs.js +187 -187
- package/lib/config/types.d.ts +85 -72
- package/lib/config/types.js +72 -58
- package/lib/index.d.ts +36 -35
- package/lib/index.js +159 -152
- package/lib/offchain/account/index.d.ts +9 -7
- package/lib/offchain/account/index.js +43 -39
- package/lib/offchain/account/lendingPool/borrowable.d.ts +14 -0
- package/lib/offchain/account/lendingPool/borrowable.js +73 -0
- package/lib/offchain/account/lendingPool/collateral.d.ts +12 -0
- package/lib/offchain/account/lendingPool/collateral.js +42 -0
- package/lib/offchain/account/lendingPool/index.d.ts +6 -5
- package/lib/offchain/account/lendingPool/index.js +14 -12
- package/lib/offchain/account/lendingPool/offchainAccountBorrowable.d.ts +14 -17
- package/lib/offchain/account/lendingPool/offchainAccountBorrowable.js +45 -71
- package/lib/offchain/account/lendingPool/offchainAccountCollateral.d.ts +11 -13
- package/lib/offchain/account/lendingPool/offchainAccountCollateral.js +31 -43
- package/lib/offchain/account/lendingPool/offchainAccountLendingPool.d.ts +28 -21
- package/lib/offchain/account/lendingPool/offchainAccountLendingPool.js +69 -68
- package/lib/offchain/account/lendingPool/offchainLeveragedPosition.d.ts +25 -0
- package/lib/offchain/account/lendingPool/offchainLeveragedPosition.js +116 -0
- package/lib/offchain/account/lendingVault.d.ts +11 -0
- package/lib/offchain/account/lendingVault.js +38 -0
- package/lib/offchain/account/offchainAccount.d.ts +25 -25
- package/lib/offchain/account/offchainAccount.js +129 -129
- package/lib/offchain/account/offchainAccountLendingVault.d.ts +16 -16
- package/lib/offchain/account/offchainAccountLendingVault.js +64 -64
- package/lib/offchain/account/offchainAccountPoolToken.d.ts +7 -7
- package/lib/offchain/account/offchainAccountPoolToken.js +24 -24
- package/lib/offchain/account/offchainMultichainAccount.d.ts +34 -0
- package/lib/offchain/account/offchainMultichainAccount.js +66 -0
- package/lib/offchain/account/poolToken.d.ts +6 -0
- package/lib/offchain/account/poolToken.js +21 -0
- package/lib/offchain/account/vault/index.d.ts +3 -0
- package/lib/offchain/account/vault/index.js +7 -0
- package/lib/offchain/account/vault/offchainAccountVault.d.ts +16 -0
- package/lib/offchain/account/vault/offchainAccountVault.js +64 -0
- package/lib/offchain/configManager/index.d.ts +5 -5
- package/lib/offchain/configManager/index.js +12 -12
- package/lib/offchain/configManager/offchainConfigManager.d.ts +25 -25
- package/lib/offchain/configManager/offchainConfigManager.js +76 -76
- package/lib/offchain/configManager/offchainConfigManagerInitializer.d.ts +6 -6
- package/lib/offchain/configManager/offchainConfigManagerInitializer.js +53 -53
- package/lib/offchain/configManager/offchainPairConfig.d.ts +40 -40
- package/lib/offchain/configManager/offchainPairConfig.js +86 -86
- package/lib/offchain/configManager/offchainProposal.d.ts +17 -17
- package/lib/offchain/configManager/offchainProposal.js +53 -53
- package/lib/offchain/index.d.ts +15 -14
- package/lib/offchain/index.js +55 -53
- package/lib/offchain/initializer.d.ts +32 -0
- package/lib/offchain/initializer.js +627 -0
- package/lib/offchain/lendingPool/borrowable.d.ts +55 -0
- package/lib/offchain/lendingPool/borrowable.js +351 -0
- package/lib/offchain/lendingPool/collateral.d.ts +17 -0
- package/lib/offchain/lendingPool/collateral.js +72 -0
- package/lib/offchain/lendingPool/index.d.ts +5 -5
- package/lib/offchain/lendingPool/index.js +12 -12
- package/lib/offchain/lendingPool/offchainBorrowable.d.ts +59 -59
- package/lib/offchain/lendingPool/offchainBorrowable.js +366 -366
- package/lib/offchain/lendingPool/offchainCollateral.d.ts +20 -19
- package/lib/offchain/lendingPool/offchainCollateral.js +81 -75
- package/lib/offchain/lendingPool/offchainLendingPool.d.ts +60 -47
- package/lib/offchain/lendingPool/offchainLendingPool.js +277 -230
- package/lib/offchain/lendingVault.d.ts +22 -0
- package/lib/offchain/lendingVault.js +115 -0
- package/lib/offchain/offchain.d.ts +106 -113
- package/lib/offchain/offchain.js +248 -251
- package/lib/offchain/offchainAPRHelper.d.ts +45 -45
- package/lib/offchain/offchainAPRHelper.js +239 -239
- package/lib/offchain/offchainEndpointManager.d.ts +25 -25
- package/lib/offchain/offchainEndpointManager.js +126 -126
- package/lib/offchain/offchainInitializer.d.ts +52 -52
- package/lib/offchain/offchainInitializer.js +792 -792
- package/lib/offchain/offchainLendingVault.d.ts +25 -25
- package/lib/offchain/offchainLendingVault.js +114 -114
- package/lib/offchain/offchainMultichain.d.ts +50 -0
- package/lib/offchain/offchainMultichain.js +75 -0
- package/lib/offchain/offchainPoolToken.d.ts +21 -21
- package/lib/offchain/offchainPoolToken.js +128 -128
- package/lib/offchain/offchainPriceHelper.d.ts +22 -22
- package/lib/offchain/offchainPriceHelper.js +364 -364
- package/lib/offchain/offchainSolidexHelper.d.ts +16 -16
- package/lib/offchain/offchainSolidexHelper.js +58 -58
- package/lib/offchain/offchainTypes.d.ts +212 -212
- package/lib/offchain/offchainTypes.js +3 -3
- package/lib/offchain/poolToken.d.ts +20 -0
- package/lib/offchain/poolToken.js +120 -0
- package/lib/offchain/priceHelper.d.ts +21 -0
- package/lib/offchain/priceHelper.js +195 -0
- package/lib/offchain/queries/apis/ponder/index.d.ts +14 -14
- package/lib/offchain/queries/apis/ponder/index.js +281 -281
- package/lib/offchain/queries/apis/thegraph/index.d.ts +19 -19
- package/lib/offchain/queries/apis/thegraph/index.js +355 -355
- package/lib/offchain/queries/index.d.ts +20 -20
- package/lib/offchain/queries/index.js +51 -51
- package/lib/offchain/queries/interfaces/query-builder.d.ts +19 -19
- package/lib/offchain/queries/interfaces/query-builder.js +2 -2
- package/lib/offchain/queries/interfaces/transformers.js +9 -9
- package/lib/offchain/query.d.ts +15 -0
- package/lib/offchain/query.js +323 -0
- package/lib/offchain/solidexHelper.d.ts +16 -0
- package/lib/offchain/solidexHelper.js +58 -0
- package/lib/offchain/types.d.ts +150 -0
- package/lib/offchain/types.js +3 -0
- package/lib/offchain/vault/index.d.ts +6 -0
- package/lib/offchain/vault/index.js +14 -0
- package/lib/offchain/vault/offchainHedgedVault.d.ts +9 -0
- package/lib/offchain/vault/offchainHedgedVault.js +57 -0
- package/lib/offchain/vault/offchainLendingVault.d.ts +16 -0
- package/lib/offchain/vault/offchainLendingVault.js +73 -0
- package/lib/offchain/vault/offchainLeveragedVault.d.ts +9 -0
- package/lib/offchain/vault/offchainLeveragedVault.js +57 -0
- package/lib/offchain/vault/offchainVault.d.ts +34 -0
- package/lib/offchain/vault/offchainVault.js +130 -0
- package/lib/onchain/account/index.d.ts +6 -6
- package/lib/onchain/account/index.js +38 -38
- package/lib/onchain/account/interactions/index.d.ts +28 -0
- package/lib/onchain/account/interactions/index.js +158 -0
- package/lib/onchain/account/interactions/lendingPool/borrowable.d.ts +16 -0
- package/lib/onchain/account/interactions/lendingPool/borrowable.js +49 -0
- package/lib/onchain/account/interactions/lendingPool/collateral.d.ts +15 -0
- package/lib/onchain/account/interactions/lendingPool/collateral.js +33 -0
- package/lib/onchain/account/interactions/lendingPool/index.d.ts +41 -0
- package/lib/onchain/account/interactions/lendingPool/index.js +120 -0
- package/lib/onchain/account/interactions/lendingVault.d.ts +10 -0
- package/lib/onchain/account/interactions/lendingVault.js +12 -0
- package/lib/onchain/account/interactions/poolToken.d.ts +33 -0
- package/lib/onchain/account/interactions/poolToken.js +180 -0
- package/lib/onchain/account/lendingPool/borrowable.d.ts +29 -0
- package/lib/onchain/account/lendingPool/borrowable.js +135 -0
- package/lib/onchain/account/lendingPool/collateral.d.ts +15 -0
- package/lib/onchain/account/lendingPool/collateral.js +66 -0
- package/lib/onchain/account/lendingPool/index.d.ts +12 -5
- package/lib/onchain/account/lendingPool/index.js +49 -12
- package/lib/onchain/account/lendingPool/nftlp/index.d.ts +4 -0
- package/lib/onchain/account/lendingPool/nftlp/index.js +11 -0
- package/lib/onchain/account/lendingPool/nftlp/onchainAccountNftlp.d.ts +7 -0
- package/lib/onchain/account/lendingPool/nftlp/onchainAccountNftlp.js +12 -0
- package/lib/onchain/account/lendingPool/nftlp/onchainAccountNftlpUniswapV3.d.ts +4 -0
- package/lib/onchain/account/lendingPool/nftlp/onchainAccountNftlpUniswapV3.js +13 -0
- package/lib/onchain/account/lendingPool/onchainAccountBorrowable.d.ts +39 -34
- package/lib/onchain/account/lendingPool/onchainAccountBorrowable.js +131 -176
- package/lib/onchain/account/lendingPool/onchainAccountBorrowableV2.d.ts +10 -0
- package/lib/onchain/account/lendingPool/onchainAccountBorrowableV2.js +55 -0
- package/lib/onchain/account/lendingPool/onchainAccountBorrowableV3.d.ts +10 -0
- package/lib/onchain/account/lendingPool/onchainAccountBorrowableV3.js +28 -0
- package/lib/onchain/account/lendingPool/onchainAccountCollateral.d.ts +10 -23
- package/lib/onchain/account/lendingPool/onchainAccountCollateral.js +26 -109
- package/lib/onchain/account/lendingPool/onchainAccountCollateralV2.d.ts +25 -0
- package/lib/onchain/account/lendingPool/onchainAccountCollateralV2.js +99 -0
- package/lib/onchain/account/lendingPool/onchainAccountCollateralV3.d.ts +18 -0
- package/lib/onchain/account/lendingPool/onchainAccountCollateralV3.js +44 -0
- package/lib/onchain/account/lendingPool/onchainAccountLendingPool.d.ts +42 -57
- package/lib/onchain/account/lendingPool/onchainAccountLendingPool.js +142 -352
- package/lib/onchain/account/lendingPool/onchainAccountLendingPoolV2.d.ts +44 -0
- package/lib/onchain/account/lendingPool/onchainAccountLendingPoolV2.js +285 -0
- package/lib/onchain/account/lendingPool/onchainAccountLendingPoolV3.d.ts +27 -0
- package/lib/onchain/account/lendingPool/onchainAccountLendingPoolV3.js +32 -0
- package/lib/onchain/account/lendingVault.d.ts +10 -0
- package/lib/onchain/account/lendingVault.js +35 -0
- package/lib/onchain/account/onchainAccount.d.ts +32 -32
- package/lib/onchain/account/onchainAccount.js +166 -167
- package/lib/onchain/account/onchainAccountLendingVault.d.ts +19 -19
- package/lib/onchain/account/onchainAccountLendingVault.js +48 -48
- package/lib/onchain/account/onchainAccountPoolToken.d.ts +30 -30
- package/lib/onchain/account/onchainAccountPoolToken.js +86 -86
- package/lib/onchain/account/poolToken.d.ts +24 -0
- package/lib/onchain/account/poolToken.js +84 -0
- package/lib/onchain/configManager/index.d.ts +5 -5
- package/lib/onchain/configManager/index.js +12 -12
- package/lib/onchain/configManager/onchainConfigManager.d.ts +12 -12
- package/lib/onchain/configManager/onchainConfigManager.js +38 -38
- package/lib/onchain/configManager/onchainPairConfig.d.ts +38 -38
- package/lib/onchain/configManager/onchainPairConfig.js +85 -85
- package/lib/onchain/configManager/onchainProposal.d.ts +17 -17
- package/lib/onchain/configManager/onchainProposal.js +55 -55
- package/lib/onchain/contractsHelper.d.ts +29 -0
- package/lib/onchain/contractsHelper.js +52 -0
- package/lib/onchain/impermaxFactory/index.d.ts +7 -5
- package/lib/onchain/impermaxFactory/index.js +39 -35
- package/lib/onchain/impermaxFactory/lendingPool/borrowable.d.ts +36 -0
- package/lib/onchain/impermaxFactory/lendingPool/borrowable.js +153 -0
- package/lib/onchain/impermaxFactory/lendingPool/collateral.d.ts +17 -0
- package/lib/onchain/impermaxFactory/lendingPool/collateral.js +59 -0
- package/lib/onchain/impermaxFactory/lendingPool/index.d.ts +12 -5
- package/lib/onchain/impermaxFactory/lendingPool/index.js +50 -12
- package/lib/onchain/impermaxFactory/lendingPool/nftlp/index.d.ts +4 -0
- package/lib/onchain/impermaxFactory/lendingPool/nftlp/index.js +11 -0
- package/lib/onchain/impermaxFactory/lendingPool/nftlp/onchainNftlp.d.ts +22 -0
- package/lib/onchain/impermaxFactory/lendingPool/nftlp/onchainNftlp.js +19 -0
- package/lib/onchain/impermaxFactory/lendingPool/nftlp/onchainNftlpUniswapV3.d.ts +24 -0
- package/lib/onchain/impermaxFactory/lendingPool/nftlp/onchainNftlpUniswapV3.js +90 -0
- package/lib/onchain/impermaxFactory/lendingPool/onchainBorrowable.d.ts +38 -34
- package/lib/onchain/impermaxFactory/lendingPool/onchainBorrowable.js +137 -156
- package/lib/onchain/impermaxFactory/lendingPool/onchainBorrowableV2.d.ts +9 -0
- package/lib/onchain/impermaxFactory/lendingPool/onchainBorrowableV2.js +36 -0
- package/lib/onchain/impermaxFactory/lendingPool/onchainBorrowableV3.d.ts +7 -0
- package/lib/onchain/impermaxFactory/lendingPool/onchainBorrowableV3.js +23 -0
- package/lib/onchain/impermaxFactory/lendingPool/onchainCollateral.d.ts +8 -19
- package/lib/onchain/impermaxFactory/lendingPool/onchainCollateral.js +24 -61
- package/lib/onchain/impermaxFactory/lendingPool/onchainCollateralV2.d.ts +20 -0
- package/lib/onchain/impermaxFactory/lendingPool/onchainCollateralV2.js +58 -0
- package/lib/onchain/impermaxFactory/lendingPool/onchainCollateralV3.d.ts +13 -0
- package/lib/onchain/impermaxFactory/lendingPool/onchainCollateralV3.js +36 -0
- package/lib/onchain/impermaxFactory/lendingPool/onchainLendingPool.d.ts +43 -58
- package/lib/onchain/impermaxFactory/lendingPool/onchainLendingPool.js +81 -367
- package/lib/onchain/impermaxFactory/lendingPool/onchainLendingPoolV2.d.ts +76 -0
- package/lib/onchain/impermaxFactory/lendingPool/onchainLendingPoolV2.js +338 -0
- package/lib/onchain/impermaxFactory/lendingPool/onchainLendingPoolV3.d.ts +42 -0
- package/lib/onchain/impermaxFactory/lendingPool/onchainLendingPoolV3.js +39 -0
- package/lib/onchain/impermaxFactory/onchainImpermaxFactory.d.ts +26 -16
- package/lib/onchain/impermaxFactory/onchainImpermaxFactory.js +42 -52
- package/lib/onchain/impermaxFactory/onchainImpermaxFactoryV2.d.ts +16 -0
- package/lib/onchain/impermaxFactory/onchainImpermaxFactoryV2.js +81 -0
- package/lib/onchain/impermaxFactory/onchainImpermaxFactoryV3.d.ts +16 -0
- package/lib/onchain/impermaxFactory/onchainImpermaxFactoryV3.js +88 -0
- package/lib/onchain/index.d.ts +10 -10
- package/lib/onchain/index.js +49 -49
- package/lib/onchain/interactions/index.d.ts +8 -8
- package/lib/onchain/interactions/index.js +41 -41
- package/lib/onchain/interactions/lendingPool/borrowable.d.ts +14 -0
- package/lib/onchain/interactions/lendingPool/borrowable.js +47 -0
- package/lib/onchain/interactions/lendingPool/collateral.d.ts +13 -0
- package/lib/onchain/interactions/lendingPool/collateral.js +31 -0
- package/lib/onchain/interactions/lendingPool/index.d.ts +12 -5
- package/lib/onchain/interactions/lendingPool/index.js +49 -12
- package/lib/onchain/interactions/lendingPool/nftlp/index.d.ts +4 -0
- package/lib/onchain/interactions/lendingPool/nftlp/index.js +11 -0
- package/lib/onchain/interactions/lendingPool/nftlp/onchainInteractionsNftlp.d.ts +7 -0
- package/lib/onchain/interactions/lendingPool/nftlp/onchainInteractionsNftlp.js +12 -0
- package/lib/onchain/interactions/lendingPool/nftlp/onchainInteractionsNftlpUniswapV3.d.ts +4 -0
- package/lib/onchain/interactions/lendingPool/nftlp/onchainInteractionsNftlpUniswapV3.js +13 -0
- package/lib/onchain/interactions/lendingPool/onchainInteractionsBorrowable.d.ts +17 -21
- package/lib/onchain/interactions/lendingPool/onchainInteractionsBorrowable.js +24 -56
- package/lib/onchain/interactions/lendingPool/onchainInteractionsBorrowableV2.d.ts +15 -0
- package/lib/onchain/interactions/lendingPool/onchainInteractionsBorrowableV2.js +63 -0
- package/lib/onchain/interactions/lendingPool/onchainInteractionsBorrowableV3.d.ts +9 -0
- package/lib/onchain/interactions/lendingPool/onchainInteractionsBorrowableV3.js +14 -0
- package/lib/onchain/interactions/lendingPool/onchainInteractionsCollateral.d.ts +7 -19
- package/lib/onchain/interactions/lendingPool/onchainInteractionsCollateral.js +11 -43
- package/lib/onchain/interactions/lendingPool/onchainInteractionsCollateralV2.d.ts +20 -0
- package/lib/onchain/interactions/lendingPool/onchainInteractionsCollateralV2.js +48 -0
- package/lib/onchain/interactions/lendingPool/onchainInteractionsCollateralV3.d.ts +13 -0
- package/lib/onchain/interactions/lendingPool/onchainInteractionsCollateralV3.js +20 -0
- package/lib/onchain/interactions/lendingPool/onchainInteractionsLendingPool.d.ts +31 -46
- package/lib/onchain/interactions/lendingPool/onchainInteractionsLendingPool.js +53 -135
- package/lib/onchain/interactions/lendingPool/onchainInteractionsLendingPoolV2.d.ts +42 -0
- package/lib/onchain/interactions/lendingPool/onchainInteractionsLendingPoolV2.js +114 -0
- package/lib/onchain/interactions/lendingPool/onchainInteractionsLendingPoolV3.d.ts +27 -0
- package/lib/onchain/interactions/lendingPool/onchainInteractionsLendingPoolV3.js +32 -0
- package/lib/onchain/interactions/lendingVault.d.ts +8 -0
- package/lib/onchain/interactions/lendingVault.js +15 -0
- package/lib/onchain/interactions/onchainInteractions.d.ts +31 -31
- package/lib/onchain/interactions/onchainInteractions.js +136 -137
- package/lib/onchain/interactions/onchainInteractionsConfigManager.d.ts +17 -17
- package/lib/onchain/interactions/onchainInteractionsConfigManager.js +44 -44
- package/lib/onchain/interactions/onchainInteractionsLendingVault.d.ts +14 -14
- package/lib/onchain/interactions/onchainInteractionsLendingVault.js +21 -21
- package/lib/onchain/interactions/onchainInteractionsPoolToken.d.ts +35 -35
- package/lib/onchain/interactions/onchainInteractionsPoolToken.js +134 -186
- package/lib/onchain/interactions/poolToken.d.ts +31 -0
- package/lib/onchain/interactions/poolToken.js +181 -0
- package/lib/onchain/lendingVault.d.ts +17 -0
- package/lib/onchain/lendingVault.js +56 -0
- package/lib/onchain/onchain.d.ts +38 -35
- package/lib/onchain/onchain.js +78 -70
- package/lib/onchain/onchainContractsHelper.d.ts +42 -31
- package/lib/onchain/onchainContractsHelper.js +90 -56
- package/lib/onchain/onchainLendingVault.d.ts +22 -22
- package/lib/onchain/onchainLendingVault.js +69 -69
- package/lib/onchain/onchainPermitHelper.d.ts +21 -0
- package/lib/onchain/onchainPermitHelper.js +198 -0
- package/lib/onchain/onchainPoolToken.d.ts +35 -35
- package/lib/onchain/onchainPoolToken.js +129 -129
- package/lib/onchain/onchainTypes.d.ts +70 -64
- package/lib/onchain/onchainTypes.js +14 -14
- package/lib/onchain/poolToken.d.ts +32 -0
- package/lib/onchain/poolToken.js +121 -0
- package/lib/onchain/types.d.ts +45 -0
- package/lib/onchain/types.js +14 -0
- package/lib/utils/ether-utils.d.ts +5 -5
- package/lib/utils/ether-utils.js +26 -26
- package/lib/utils/index.d.ts +3 -3
- package/lib/utils/index.js +16 -16
- package/lib/utils/lliquidity-math.d.ts +30 -30
- package/lib/utils/lliquidity-math.js +139 -139
- package/lib/utils/price-from-reserves.d.ts +2 -0
- package/lib/utils/price-from-reserves.js +19 -0
- package/package.json +36 -36
|
@@ -1,176 +1,131 @@
|
|
|
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
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
this.
|
|
21
|
-
this.
|
|
22
|
-
this.
|
|
23
|
-
this.
|
|
24
|
-
this.
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
this.
|
|
28
|
-
this.
|
|
29
|
-
this.
|
|
30
|
-
this.
|
|
31
|
-
this.
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
const
|
|
51
|
-
const
|
|
52
|
-
const
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
const
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
}
|
|
86
|
-
//
|
|
87
|
-
|
|
88
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
initializeAvailableFarmingReward() {
|
|
133
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
134
|
-
if (!(yield this.poolToken.hasImpermaxChef()))
|
|
135
|
-
return 0;
|
|
136
|
-
const borrowableAddress = yield this.poolToken.getPoolTokenAddress();
|
|
137
|
-
try {
|
|
138
|
-
return (yield this.poolToken.getImpermaxChef().methods.pendingReward(borrowableAddress, this.getAccountAddress()).call()) / 1e18;
|
|
139
|
-
}
|
|
140
|
-
catch (_a) {
|
|
141
|
-
console.log("Warning: pending reward negative");
|
|
142
|
-
return 0;
|
|
143
|
-
}
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
getAvailableFarmingReward() {
|
|
147
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
148
|
-
if (!this.borrowableCache.availableFarmingReward)
|
|
149
|
-
this.borrowableCache.availableFarmingReward = this.initializeAvailableFarmingReward();
|
|
150
|
-
return this.borrowableCache.availableFarmingReward;
|
|
151
|
-
});
|
|
152
|
-
}
|
|
153
|
-
initializeAvailableRewarderReward() {
|
|
154
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
155
|
-
if (!(yield this.poolToken.hasRewarder()))
|
|
156
|
-
return 0;
|
|
157
|
-
const borrowableAddress = yield this.poolToken.getPoolTokenAddress();
|
|
158
|
-
const rewarder = yield this.poolToken.getRewarder();
|
|
159
|
-
try {
|
|
160
|
-
return (yield rewarder.methods.pendingReward(borrowableAddress, this.getAccountAddress()).call()) / 1e18;
|
|
161
|
-
}
|
|
162
|
-
catch (_a) {
|
|
163
|
-
console.log("Warning: pending reward negative");
|
|
164
|
-
return 0;
|
|
165
|
-
}
|
|
166
|
-
});
|
|
167
|
-
}
|
|
168
|
-
getAvailableRewarderReward() {
|
|
169
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
170
|
-
if (!this.borrowableCache.availableRewarderReward)
|
|
171
|
-
this.borrowableCache.availableRewarderReward = this.initializeAvailableRewarderReward();
|
|
172
|
-
return this.borrowableCache.availableRewarderReward;
|
|
173
|
-
});
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
exports.default = OnchainAccountBorrowable;
|
|
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 onchainAccountPoolToken_1 = __importDefault(require("../onchainAccountPoolToken"));
|
|
16
|
+
class OnchainAccountBorrowable extends onchainAccountPoolToken_1.default {
|
|
17
|
+
constructor(lendingPool, borrowable) {
|
|
18
|
+
super();
|
|
19
|
+
this.borrowableCache = {};
|
|
20
|
+
this.getLendingPool = () => this.lendingPool;
|
|
21
|
+
this.getPoolToken = () => this.poolToken;
|
|
22
|
+
this.getAccount = () => this.lendingPool.getAccount();
|
|
23
|
+
this.getInteractionsBorrowable = this.getInteractionsPoolToken;
|
|
24
|
+
this.getOffchainAccountBorrowable = this.getOffchainAccountPoolToken;
|
|
25
|
+
// Shortcuts
|
|
26
|
+
this.getBorrowableType = () => this.poolToken.getBorrowableType();
|
|
27
|
+
this.getSupplyAPR = () => __awaiter(this, void 0, void 0, function* () { return (yield this.poolToken.getOffchainPoolToken()).getSupplyAPR(); });
|
|
28
|
+
this.getBorrowRate = () => __awaiter(this, void 0, void 0, function* () { return (yield this.poolToken.getOffchainPoolToken()).getBorrowRate(); });
|
|
29
|
+
this.getAccrualTimestamp = () => __awaiter(this, void 0, void 0, function* () { return (yield this.poolToken.getOffchainPoolToken()).getAccrualTimestamp(); });
|
|
30
|
+
this.lendingPool = lendingPool;
|
|
31
|
+
this.poolToken = lendingPool.getLendingPool().getBorrowable(borrowable);
|
|
32
|
+
}
|
|
33
|
+
getInteractionsPoolToken() {
|
|
34
|
+
return this.lendingPool.getInteractionsLendingPool().getBorrowable(this.getBorrowableType());
|
|
35
|
+
}
|
|
36
|
+
getOffchainAccountPoolToken() {
|
|
37
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
38
|
+
const offchainAccountLendingPool = yield this.lendingPool.getOffchainAccountLendingPool();
|
|
39
|
+
return offchainAccountLendingPool.getBorrowable(this.getBorrowableType());
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
cleanCache() {
|
|
43
|
+
super.cleanCache();
|
|
44
|
+
this.borrowableCache = {};
|
|
45
|
+
}
|
|
46
|
+
// Borrowed
|
|
47
|
+
initializeBorrowed() {
|
|
48
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
49
|
+
const borrowable = yield this.poolToken.getPoolToken();
|
|
50
|
+
const balance = yield borrowable.methods.borrowBalance(this.getAccountAddress()).call();
|
|
51
|
+
const storedAmount = yield yield this.poolToken.normalize(balance);
|
|
52
|
+
const accrualTimestamp = yield this.getAccrualTimestamp();
|
|
53
|
+
const borrowRate = yield this.getBorrowRate();
|
|
54
|
+
return storedAmount * (1 + (Date.now() / 1000 - accrualTimestamp) * borrowRate);
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
getBorrowed() {
|
|
58
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
59
|
+
if (!this.borrowableCache.borrowed)
|
|
60
|
+
this.borrowableCache.borrowed = this.initializeBorrowed();
|
|
61
|
+
return this.borrowableCache.borrowed;
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
getBorrowedUSD() {
|
|
65
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
66
|
+
const borrowed = yield this.getBorrowed();
|
|
67
|
+
const tokenPrice = yield this.getTokenPriceAccurate();
|
|
68
|
+
return borrowed * tokenPrice;
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
// Farming Shares
|
|
72
|
+
initializeFarmingShares() {
|
|
73
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
74
|
+
if (!(yield this.poolToken.hasImpermaxChef()))
|
|
75
|
+
return 0;
|
|
76
|
+
return (yield this.poolToken.getImpermaxChef().methods.userInfo(yield this.poolToken.getPoolTokenAddress(), this.getAccountAddress()).call()).shares;
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
getFarmingShares() {
|
|
80
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
81
|
+
if (!this.borrowableCache.farmingShares)
|
|
82
|
+
this.borrowableCache.farmingShares = this.initializeFarmingShares();
|
|
83
|
+
return this.borrowableCache.farmingShares;
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
// Available Reward
|
|
87
|
+
initializeAvailableFarmingReward() {
|
|
88
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
89
|
+
if (!(yield this.poolToken.hasImpermaxChef()))
|
|
90
|
+
return 0;
|
|
91
|
+
const borrowableAddress = yield this.poolToken.getPoolTokenAddress();
|
|
92
|
+
try {
|
|
93
|
+
return (yield this.poolToken.getImpermaxChef().methods.pendingReward(borrowableAddress, this.getAccountAddress()).call()) / 1e18;
|
|
94
|
+
}
|
|
95
|
+
catch (_a) {
|
|
96
|
+
console.log("Warning: pending reward negative");
|
|
97
|
+
return 0;
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
getAvailableFarmingReward() {
|
|
102
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
103
|
+
if (!this.borrowableCache.availableFarmingReward)
|
|
104
|
+
this.borrowableCache.availableFarmingReward = this.initializeAvailableFarmingReward();
|
|
105
|
+
return this.borrowableCache.availableFarmingReward;
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
initializeAvailableRewarderReward() {
|
|
109
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
110
|
+
if (!(yield this.poolToken.hasRewarder()))
|
|
111
|
+
return 0;
|
|
112
|
+
const borrowableAddress = yield this.poolToken.getPoolTokenAddress();
|
|
113
|
+
const rewarder = yield this.poolToken.getRewarder();
|
|
114
|
+
try {
|
|
115
|
+
return (yield rewarder.methods.pendingReward(borrowableAddress, this.getAccountAddress()).call()) / 1e18;
|
|
116
|
+
}
|
|
117
|
+
catch (_a) {
|
|
118
|
+
console.log("Warning: pending reward negative");
|
|
119
|
+
return 0;
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
getAvailableRewarderReward() {
|
|
124
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
125
|
+
if (!this.borrowableCache.availableRewarderReward)
|
|
126
|
+
this.borrowableCache.availableRewarderReward = this.initializeAvailableRewarderReward();
|
|
127
|
+
return this.borrowableCache.availableRewarderReward;
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
exports.default = OnchainAccountBorrowable;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import OnchainAccountBorrowable from "./onchainAccountBorrowable";
|
|
2
|
+
import OnchainAccountLendingPoolV2 from "./onchainAccountLendingPoolV2";
|
|
3
|
+
import { OnchainBorrowableV2 } from "../../impermaxFactory/lendingPool";
|
|
4
|
+
export default class OnchainAccountBorrowableV2 extends OnchainAccountBorrowable {
|
|
5
|
+
protected readonly lendingPool: OnchainAccountLendingPoolV2;
|
|
6
|
+
protected readonly poolToken: OnchainBorrowableV2;
|
|
7
|
+
getLendingPool: () => OnchainAccountLendingPoolV2;
|
|
8
|
+
getPoolToken: () => OnchainBorrowableV2;
|
|
9
|
+
getMaxBorrowable(): Promise<number>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
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 onchainAccountBorrowable_1 = __importDefault(require("./onchainAccountBorrowable"));
|
|
17
|
+
class OnchainAccountBorrowableV2 extends onchainAccountBorrowable_1.default {
|
|
18
|
+
constructor() {
|
|
19
|
+
super(...arguments);
|
|
20
|
+
this.getLendingPool = () => this.lendingPool;
|
|
21
|
+
this.getPoolToken = () => this.poolToken;
|
|
22
|
+
}
|
|
23
|
+
// Max OffchainBorrowable
|
|
24
|
+
// binary search approach
|
|
25
|
+
getMaxBorrowable() {
|
|
26
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
27
|
+
const availableCash = yield this.poolToken.getTotalBalance();
|
|
28
|
+
const twapPrice = yield this.lendingPool.getLendingPool().getTWAPPrice();
|
|
29
|
+
// start search
|
|
30
|
+
let borrowAmount = availableCash;
|
|
31
|
+
let borrowAmountPrev = 0;
|
|
32
|
+
let bestAmount = 0;
|
|
33
|
+
for (let i = 0; i < 1000; i++) {
|
|
34
|
+
const jump = Math.abs(borrowAmount - borrowAmountPrev) / 2;
|
|
35
|
+
if (jump / availableCash < 1e-9)
|
|
36
|
+
break;
|
|
37
|
+
borrowAmountPrev = borrowAmount;
|
|
38
|
+
const changeCollateral = 0;
|
|
39
|
+
const changeBorrowedA = this.getBorrowableType() == types_1.Borrowable.A ? borrowAmount : 0;
|
|
40
|
+
const changeBorrowedB = this.getBorrowableType() == types_1.Borrowable.B ? borrowAmount : 0;
|
|
41
|
+
const changes = { changeCollateral, changeBorrowedA, changeBorrowedB };
|
|
42
|
+
const [liqPriceA, liqPriceB] = yield this.lendingPool.getLiquidationPrices(changes);
|
|
43
|
+
if (liqPriceA * this.getUiMargin() > twapPrice || liqPriceB / this.getUiMargin() < twapPrice)
|
|
44
|
+
borrowAmount -= jump;
|
|
45
|
+
else {
|
|
46
|
+
bestAmount = borrowAmount;
|
|
47
|
+
borrowAmount += jump;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
bestAmount = bestAmount > availableCash ? availableCash : bestAmount;
|
|
51
|
+
return bestAmount;
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
exports.default = OnchainAccountBorrowableV2;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import OnchainAccountBorrowable from "./onchainAccountBorrowable";
|
|
2
|
+
import { OnchainBorrowableV3 } from "../../impermaxFactory/lendingPool";
|
|
3
|
+
import OnchainAccountLendingPoolV3 from "./onchainAccountLendingPoolV3";
|
|
4
|
+
export default class OnchainAccountBorrowableV3 extends OnchainAccountBorrowable {
|
|
5
|
+
protected readonly lendingPool: OnchainAccountLendingPoolV3;
|
|
6
|
+
protected readonly poolToken: OnchainBorrowableV3;
|
|
7
|
+
getLendingPool: () => OnchainAccountLendingPoolV3;
|
|
8
|
+
getPoolToken: () => OnchainBorrowableV3;
|
|
9
|
+
getMaxBorrowable(): Promise<number>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
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 onchainAccountBorrowable_1 = __importDefault(require("./onchainAccountBorrowable"));
|
|
16
|
+
class OnchainAccountBorrowableV3 extends onchainAccountBorrowable_1.default {
|
|
17
|
+
constructor() {
|
|
18
|
+
super(...arguments);
|
|
19
|
+
this.getLendingPool = () => this.lendingPool;
|
|
20
|
+
this.getPoolToken = () => this.poolToken;
|
|
21
|
+
}
|
|
22
|
+
getMaxBorrowable() {
|
|
23
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
24
|
+
return 0;
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.default = OnchainAccountBorrowableV3;
|
|
@@ -1,23 +1,10 @@
|
|
|
1
|
-
import OnchainAccountLendingPool from './index';
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
getLendingPool: () => OnchainAccountLendingPool;
|
|
12
|
-
getPoolToken: () => OnchainCollateral;
|
|
13
|
-
getAccount: () => import("..").default;
|
|
14
|
-
getInteractionsPoolToken(): OnchainInteractionsCollateral;
|
|
15
|
-
getInteractionsCollateral: () => OnchainInteractionsCollateral;
|
|
16
|
-
getOffchainAccountPoolToken(): Promise<OffchainAccountCollateral>;
|
|
17
|
-
getOffchainAccountCollateral: () => Promise<OffchainAccountCollateral>;
|
|
18
|
-
cleanCache(): void;
|
|
19
|
-
fixStakedLPExchangeRate(n: Promise<number>): Promise<number>;
|
|
20
|
-
getAvailableBalanceUSD(): Promise<number>;
|
|
21
|
-
getDepositedUSD(): Promise<number>;
|
|
22
|
-
getMaxWithdrawable(): Promise<number>;
|
|
23
|
-
}
|
|
1
|
+
import OnchainAccountLendingPool from './index';
|
|
2
|
+
import OffchainAccountCollateral from '../../../offchain/account/lendingPool/offchainAccountCollateral';
|
|
3
|
+
export default abstract class OnchainAccountCollateral {
|
|
4
|
+
abstract getLendingPool(): OnchainAccountLendingPool;
|
|
5
|
+
abstract cleanCache(): any;
|
|
6
|
+
getAccount: () => import("..").default;
|
|
7
|
+
getInteractionsCollateral(): import("../../..").OnchainInteractionsCollateral;
|
|
8
|
+
getOffchainAccountCollateral(): Promise<OffchainAccountCollateral>;
|
|
9
|
+
abstract getDepositedUSD(): Promise<number>;
|
|
10
|
+
}
|
|
@@ -1,109 +1,26 @@
|
|
|
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
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
this
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
this.poolToken = lendingPool.getLendingPool().getCollateral();
|
|
28
|
-
}
|
|
29
|
-
getInteractionsPoolToken() {
|
|
30
|
-
return this.lendingPool.getInteractionsLendingPool().getCollateral();
|
|
31
|
-
}
|
|
32
|
-
getOffchainAccountPoolToken() {
|
|
33
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
34
|
-
const offchainAccountLendingPool = yield this.lendingPool.getOffchainAccountLendingPool();
|
|
35
|
-
return offchainAccountLendingPool.getCollateral();
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
cleanCache() {
|
|
39
|
-
super.cleanCache();
|
|
40
|
-
this.collateralCache = {};
|
|
41
|
-
}
|
|
42
|
-
fixStakedLPExchangeRate(n) {
|
|
43
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
44
|
-
const stakedLPExchangeRate = yield this.poolToken.getLendingPool().getStakedLPExchangeRate();
|
|
45
|
-
return (yield n) / stakedLPExchangeRate;
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
getAvailableBalanceUSD() {
|
|
49
|
-
const _super = Object.create(null, {
|
|
50
|
-
getAvailableBalanceUSD: { get: () => super.getAvailableBalanceUSD }
|
|
51
|
-
});
|
|
52
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
53
|
-
return this.fixStakedLPExchangeRate(_super.getAvailableBalanceUSD.call(this));
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
getDepositedUSD() {
|
|
57
|
-
const _super = Object.create(null, {
|
|
58
|
-
getDepositedUSD: { get: () => super.getDepositedUSD }
|
|
59
|
-
});
|
|
60
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
61
|
-
return this.fixStakedLPExchangeRate(_super.getDepositedUSD.call(this));
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
// Max Withdrawable
|
|
65
|
-
/*public async getMaxWithdrawable() : Promise<number> {
|
|
66
|
-
const deposited = await this.getDeposited();
|
|
67
|
-
const availableCash = await this.poolToken.getTotalBalance();
|
|
68
|
-
const { valueCollateral, valueA, valueB } = await this.lendingPool.getValues(NO_CHANGES);
|
|
69
|
-
const safetyMargin = (await this.lendingPool.getSafetyMargin()) * this.getUiMargin();
|
|
70
|
-
const liquidationPenalty = await this.lendingPool.getLiquidationPenalty();
|
|
71
|
-
const actualCollateral = valueCollateral / liquidationPenalty;
|
|
72
|
-
const maxWithdrawable1 = (actualCollateral - (valueA + valueB * safetyMargin) / Math.sqrt(safetyMargin)) * liquidationPenalty / this.getDust();
|
|
73
|
-
const maxWithdrawable2 = (actualCollateral - (valueB + valueA * safetyMargin) / Math.sqrt(safetyMargin)) * liquidationPenalty / this.getDust();
|
|
74
|
-
return Math.max(0, Math.min(deposited, availableCash, maxWithdrawable1, maxWithdrawable2));
|
|
75
|
-
}*/
|
|
76
|
-
// binary search approach
|
|
77
|
-
getMaxWithdrawable() {
|
|
78
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
79
|
-
const collateralAmount = yield this.getDeposited();
|
|
80
|
-
const twapPrice = yield this.lendingPool.getLendingPool().getTWAPPrice();
|
|
81
|
-
const [liqPriceA, liqPriceB] = yield this.lendingPool.getLiquidationPrices(onchainTypes_1.NO_CHANGES);
|
|
82
|
-
// start search
|
|
83
|
-
let withdrawAmount = collateralAmount;
|
|
84
|
-
let withdrawAmountPrev = 0;
|
|
85
|
-
let bestAmount = 0;
|
|
86
|
-
for (let i = 0; i < 1000; i++) {
|
|
87
|
-
const jump = Math.abs(withdrawAmount - withdrawAmountPrev) / 2;
|
|
88
|
-
if (jump / collateralAmount < 0.000001)
|
|
89
|
-
break;
|
|
90
|
-
withdrawAmountPrev = withdrawAmount;
|
|
91
|
-
const changeCollateral = -1 * Math.min(withdrawAmount, collateralAmount);
|
|
92
|
-
const changeBorrowedA = 0;
|
|
93
|
-
const changeBorrowedB = 0;
|
|
94
|
-
const changes = { changeCollateral, changeBorrowedA, changeBorrowedB };
|
|
95
|
-
const [liqPriceA, liqPriceB] = yield this.lendingPool.getLiquidationPrices(changes);
|
|
96
|
-
if (liqPriceA * this.getUiMargin() > twapPrice || liqPriceB / this.getUiMargin() < twapPrice)
|
|
97
|
-
withdrawAmount -= jump;
|
|
98
|
-
else {
|
|
99
|
-
bestAmount = withdrawAmount;
|
|
100
|
-
withdrawAmount += jump;
|
|
101
|
-
if (withdrawAmount > collateralAmount)
|
|
102
|
-
break;
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
return bestAmount * this.getDust();
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
exports.default = OnchainAccountCollateral;
|
|
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
|
+
class OnchainAccountCollateral {
|
|
13
|
+
constructor() {
|
|
14
|
+
this.getAccount = () => this.getLendingPool().getAccount();
|
|
15
|
+
}
|
|
16
|
+
getInteractionsCollateral() {
|
|
17
|
+
return this.getLendingPool().getInteractionsLendingPool().getCollateral();
|
|
18
|
+
}
|
|
19
|
+
getOffchainAccountCollateral() {
|
|
20
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
21
|
+
const offchainAccountLendingPool = yield this.getLendingPool().getOffchainAccountLendingPool();
|
|
22
|
+
return offchainAccountLendingPool.getCollateral();
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
exports.default = OnchainAccountCollateral;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import OnchainAccountPoolToken from '../onchainAccountPoolToken';
|
|
2
|
+
import OffchainAccountCollateral from '../../../offchain/account/lendingPool/offchainAccountCollateral';
|
|
3
|
+
import OnchainAccountCollateral from "./onchainAccountCollateral";
|
|
4
|
+
import { OnchainCollateralV2 } from "../../impermaxFactory/lendingPool";
|
|
5
|
+
import OnchainAccountLendingPoolV2 from "./onchainAccountLendingPoolV2";
|
|
6
|
+
import OnchainInteractionsCollateralV2 from "../../interactions/lendingPool/onchainInteractionsCollateralV2";
|
|
7
|
+
export default class OnchainAccountCollateralV2 extends OnchainAccountPoolToken implements OnchainAccountCollateral {
|
|
8
|
+
protected readonly lendingPool: OnchainAccountLendingPoolV2;
|
|
9
|
+
protected readonly poolToken: OnchainCollateralV2;
|
|
10
|
+
protected collateralCache: {};
|
|
11
|
+
constructor(lendingPool: OnchainAccountLendingPoolV2);
|
|
12
|
+
getLendingPool: () => OnchainAccountLendingPoolV2;
|
|
13
|
+
getPoolToken: () => OnchainCollateralV2;
|
|
14
|
+
getCollateral: () => OnchainCollateralV2;
|
|
15
|
+
getAccount: () => import("..").default;
|
|
16
|
+
getInteractionsPoolToken(): OnchainInteractionsCollateralV2;
|
|
17
|
+
getInteractionsCollateral: () => OnchainInteractionsCollateralV2;
|
|
18
|
+
getOffchainAccountPoolToken(): Promise<OffchainAccountCollateral>;
|
|
19
|
+
getOffchainAccountCollateral: () => Promise<OffchainAccountCollateral>;
|
|
20
|
+
cleanCache(): void;
|
|
21
|
+
fixStakedLPExchangeRate(n: Promise<number>): Promise<number>;
|
|
22
|
+
getAvailableBalanceUSD(): Promise<number>;
|
|
23
|
+
getDepositedUSD(): Promise<number>;
|
|
24
|
+
getMaxWithdrawable(): Promise<number>;
|
|
25
|
+
}
|