@gearbox-protocol/sdk 1.22.4 → 1.23.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/apy/convexAPY.d.ts +10 -10
- package/lib/apy/convexAPY.js +100 -121
- package/lib/apy/curveAPY.d.ts +3 -4
- package/lib/apy/curveAPY.js +57 -111
- package/lib/apy/index.js +4 -6
- package/lib/apy/lidoAPY.d.ts +1 -2
- package/lib/apy/lidoAPY.js +14 -62
- package/lib/apy/yearnAPY.d.ts +2 -3
- package/lib/apy/yearnAPY.js +26 -82
- package/lib/contracts/contracts.js +9 -22
- package/lib/contracts/contractsRegister.js +39 -51
- package/lib/contracts/protocols.js +10 -11
- package/lib/core/adapter.js +9 -4
- package/lib/core/assets.d.ts +6 -7
- package/lib/core/assets.js +60 -70
- package/lib/core/chains.js +30 -80
- package/lib/core/constants.d.ts +9 -10
- package/lib/core/constants.js +9 -12
- package/lib/core/creditAccount.d.ts +20 -20
- package/lib/core/creditAccount.js +123 -134
- package/lib/core/creditAccount.spec.js +50 -52
- package/lib/core/creditManager.d.ts +26 -26
- package/lib/core/creditManager.js +172 -136
- package/lib/core/creditManager.spec.js +59 -61
- package/lib/core/creditSession.d.ts +12 -13
- package/lib/core/creditSession.js +120 -77
- package/lib/core/errors.d.ts +2 -3
- package/lib/core/errors.js +11 -27
- package/lib/core/eventOrTx.js +35 -73
- package/lib/core/events.d.ts +19 -20
- package/lib/core/events.js +698 -711
- package/lib/core/operations.js +11 -5
- package/lib/core/pool/data.d.ts +29 -29
- package/lib/core/pool/data.js +153 -112
- package/lib/core/pool/operation.d.ts +1 -2
- package/lib/core/pool/operation.js +23 -35
- package/lib/core/priceOracle.d.ts +6 -6
- package/lib/core/priceOracle.js +23 -29
- package/lib/core/rewardClaimer.d.ts +2 -2
- package/lib/core/rewardClaimer.js +5 -48
- package/lib/core/rewardConvex.js +54 -114
- package/lib/core/rewardConvex.spec.js +41 -43
- package/lib/core/strategy.d.ts +5 -6
- package/lib/core/strategy.js +67 -69
- package/lib/core/strategy.spec.js +32 -34
- package/lib/core/tokenDistributor.d.ts +1 -2
- package/lib/core/trade.d.ts +6 -6
- package/lib/core/trade.js +70 -115
- package/lib/core/transactions.d.ts +21 -22
- package/lib/core/transactions.js +285 -308
- package/lib/index.d.ts +0 -2
- package/lib/index.js +0 -2
- package/lib/oracles/oracles.d.ts +1 -2
- package/lib/oracles/priceFeeds.js +2 -3
- package/lib/parsers/ERC20Parser.js +20 -38
- package/lib/parsers/abstractParser.js +33 -31
- package/lib/parsers/addressProviderParser.js +12 -30
- package/lib/parsers/airdropDistributorParser.js +12 -30
- package/lib/parsers/convexBaseRewardPoolAdapterParser.js +24 -42
- package/lib/parsers/convexBaseRewardPoolAdapterParser.spec.js +11 -11
- package/lib/parsers/convexBoosterAdapterParser.js +26 -44
- package/lib/parsers/convexBoosterAdapterParser.spec.js +10 -10
- package/lib/parsers/convextRewardPoolParser.js +12 -30
- package/lib/parsers/creditFacadeParser.js +26 -45
- package/lib/parsers/creditFacadeParser.spec.js +13 -13
- package/lib/parsers/creditManagerParser.js +12 -30
- package/lib/parsers/curveAdapterParser.js +60 -78
- package/lib/parsers/curveAdapterParser.spec.js +20 -27
- package/lib/parsers/dataCompressorParser.js +12 -30
- package/lib/parsers/lidoAdapterParser.js +15 -33
- package/lib/parsers/lidoAdapterParser.spec.js +9 -9
- package/lib/parsers/lidoOracleParser.js +12 -30
- package/lib/parsers/lidoSTETHParser.js +19 -37
- package/lib/parsers/multicallParser.js +16 -34
- package/lib/parsers/offchainOracleParser.js +13 -31
- package/lib/parsers/poolParser.js +11 -29
- package/lib/parsers/priceOracleParser.js +13 -31
- package/lib/parsers/txParser.js +86 -96
- package/lib/parsers/uniV2AdapterParser.js +35 -55
- package/lib/parsers/uniV2AdapterParser.spec.js +15 -16
- package/lib/parsers/uniV3AdapterParser.js +56 -74
- package/lib/parsers/uniV3AdapterParser.spec.js +23 -24
- package/lib/parsers/wstETHAdapterParser.js +25 -43
- package/lib/parsers/wstETHAdapterParser.spec.js +11 -11
- package/lib/parsers/yearnAdapterParser.spec.js +17 -17
- package/lib/parsers/yearnV2AdapterParser.js +25 -43
- package/lib/pathfinder/core.d.ts +3 -4
- package/lib/pathfinder/pathOptions.js +52 -101
- package/lib/pathfinder/pathOptions.spec.js +55 -57
- package/lib/pathfinder/pathfinder.d.ts +3 -3
- package/lib/pathfinder/pathfinder.js +109 -202
- package/lib/pathfinder/pathfinder.spec.js +13 -13
- package/lib/strategies/convex.js +111 -123
- package/lib/strategies/creditFacade.js +34 -37
- package/lib/strategies/curve.js +74 -80
- package/lib/strategies/lido.js +26 -32
- package/lib/strategies/uniswapV2.js +21 -24
- package/lib/strategies/uniswapV3.js +33 -36
- package/lib/strategies/yearn.js +47 -59
- package/lib/tokens/balancer.js +3 -5
- package/lib/tokens/convex.js +14 -29
- package/lib/tokens/curveLP.js +22 -28
- package/lib/tokens/gear.js +1 -1
- package/lib/tokens/normal.js +3 -5
- package/lib/tokens/token.js +29 -35
- package/lib/tokens/tokenData.d.ts +0 -9
- package/lib/tokens/tokenData.js +17 -15
- package/lib/tokens/yearn.js +3 -5
- package/lib/types/factories/@chainlink/contracts/src/v0.8/interfaces/AggregatorInterface__factory.js +9 -12
- package/lib/types/factories/@chainlink/contracts/src/v0.8/interfaces/AggregatorV2V3Interface__factory.js +9 -12
- package/lib/types/factories/@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IACL.sol/IACLEvents__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IACL.sol/IACLExceptions__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IACL.sol/IACL__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IAccountFactory.sol/IAccountFactoryEvents__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IAccountFactory.sol/IAccountFactoryGetters__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IAccountFactory.sol/IAccountFactory__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IAddressProvider.sol/IAddressProviderEvents__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IAddressProvider.sol/IAddressProvider__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IAirdropDistributor.sol/IAirdropDistributorEvents__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IAirdropDistributor.sol/IAirdropDistributor__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IContractsRegister.sol/IContractsRegisterEvents__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IContractsRegister.sol/IContractsRegister__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/ICreditAccount.sol/ICrediAccountExceptions__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/ICreditAccount.sol/ICreditAccount__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/ICreditConfigurator.sol/ICreditConfiguratorEvents__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/ICreditConfigurator.sol/ICreditConfiguratorExceptions__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/ICreditConfigurator.sol/ICreditConfigurator__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/ICreditFacade.sol/ICreditFacadeEvents__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/ICreditFacade.sol/ICreditFacadeExceptions__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/ICreditFacade.sol/ICreditFacadeExtended__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/ICreditFacade.sol/ICreditFacade__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/ICreditManagerV2.sol/ICreditManagerV2Events__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/ICreditManagerV2.sol/ICreditManagerV2Exceptions__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/ICreditManagerV2.sol/ICreditManagerV2__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IDataCompressor.sol/IDataCompressorExceptions__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IDataCompressor.sol/IDataCompressor__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IDegenDistributor.sol/IDegenDistributorEvents__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IDegenDistributor.sol/IDegenDistributor__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IDegenNFT.sol/IDegenNFTEvents__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IDegenNFT.sol/IDegenNFTExceptions__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IDegenNFT.sol/IDegenNFT__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IDieselToken.sol/IDieselTokenExceptions__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IDieselToken.sol/IDieselToken__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IInterestRateModel__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/ILPPriceFeed.sol/ILPPriceFeedEvents__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/ILPPriceFeed.sol/ILPPriceFeedExceptions__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/ILPPriceFeed.sol/ILPPriceFeed__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IPhantomERC20__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IPoolService.sol/IPoolServiceEvents__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IPoolService.sol/IPoolService__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IPriceFeedType__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IPriceOracle.sol/IPriceOracleV2Events__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IPriceOracle.sol/IPriceOracleV2Exceptions__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IPriceOracle.sol/IPriceOracleV2Ext__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IPriceOracle.sol/IPriceOracleV2__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IVersion__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IWETHGateway__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/V1/ICreditFilter__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/V1/ICreditManager__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/adapters/IAdapter.sol/IAdapterExceptions__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/adapters/IAdapter.sol/IAdapter__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/adapters/IUniversalAdapter.sol/IUniversalAdapterExceptions__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/adapters/IUniversalAdapter.sol/IUniversalAdapter__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/external/IWETH__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/pool/PoolService__factory.js +27 -50
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/test/interfaces/ITokenTestSuite__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/convex/IBaseRewardPool__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/convex/IBooster__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/convex/IClaimZap__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/convex/IConvexToken__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/convex/IRewards.sol/IBasicRewards__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/convex/IRewards.sol/IRewards__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/convex/Interfaces.sol/ICrvDeposit__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/convex/Interfaces.sol/ICurveGauge__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/convex/Interfaces.sol/ICurveVoteEscrow__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/convex/Interfaces.sol/IDeposit__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/convex/Interfaces.sol/IFeeDistro__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/convex/Interfaces.sol/IMinter__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/convex/Interfaces.sol/IPools__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/convex/Interfaces.sol/IRegistry__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/convex/Interfaces.sol/IRewardFactory__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/convex/Interfaces.sol/IRewards__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/convex/Interfaces.sol/IStaker__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/convex/Interfaces.sol/IStashFactory__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/convex/Interfaces.sol/IStash__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/convex/Interfaces.sol/ITokenFactory__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/convex/Interfaces.sol/ITokenMinter__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/convex/Interfaces.sol/IVestedEscrow__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/convex/Interfaces.sol/IVoting__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/convex/Interfaces.sol/IWalletChecker__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/curve/ICurvePoolStETH__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/curve/ICurvePool_2.sol/ICurvePool2Assets__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/curve/ICurvePool_3.sol/ICurvePool3Assets__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/curve/ICurvePool_4.sol/ICurvePool4Assets__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/curve/ICurvePool__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/curve/ICurveRegistry__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/lido/ILidoOracle__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/lido/IstETH.sol/IstETHGetters__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/lido/IstETH.sol/IstETH__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/lido/IwstETH.sol/IwstETHGetters__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/lido/IwstETH.sol/IwstETH__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/lido/IwstETHGateway.sol/IwstETHGateWay__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/uniswap/IQuoter__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/uniswap/IUniswapV2Router01__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/uniswap/IUniswapV2Router02__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/uniswap/IUniswapV3.sol/ISwapRouter__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/yearn/IYVault__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/interfaces/convex/IConvexV1BaseRewardPoolAdapter.sol/IConvexV1BaseRewardPoolAdapterErrors__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/interfaces/convex/IConvexV1BaseRewardPoolAdapter.sol/IConvexV1BaseRewardPoolAdapter__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/interfaces/convex/IConvexV1BoosterAdapter__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/interfaces/curve/ICurveV1Adapter.sol/ICurveV1AdapterExceptions__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/interfaces/curve/ICurveV1Adapter.sol/ICurveV1Adapter__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/interfaces/curve/ICurveV1_2AssetsAdapter__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/interfaces/curve/ICurveV1_3AssetsAdapter__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/interfaces/curve/ICurveV1_4AssetsAdapter__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/interfaces/lido/ILidoV1Adapter.sol/ILidoV1AdapterEvents__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/interfaces/lido/ILidoV1Adapter.sol/ILidoV1AdapterExceptions__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/interfaces/lido/ILidoV1Adapter.sol/ILidoV1Adapter__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/interfaces/lido/IwstETHV1Adapter__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/interfaces/uniswap/IUniswapPathChecker__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/interfaces/uniswap/IUniswapV2Adapter.sol/IUniswapV2AdapterExceptions__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/interfaces/uniswap/IUniswapV2Adapter.sol/IUniswapV2Adapter__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/interfaces/uniswap/IUniswapV3Adapter.sol/IUniswapV3AdapterExceptions__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/interfaces/uniswap/IUniswapV3Adapter.sol/IUniswapV3Adapter__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/interfaces/yearn/IYearnV2Adapter__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/test/config/SupportedContracts.sol/ISupportedContracts__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/test/mocks/integrations/LidoMock.sol/ILidoMockEvents__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/router/contracts/interfaces/IClosePathResolver__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/router/contracts/interfaces/IDepositor.sol/IDepositorOptions__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/router/contracts/interfaces/IDepositor.sol/IDepositor__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/router/contracts/interfaces/IGasPricer__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/router/contracts/interfaces/ILPWorker.sol/ILPWorkerOptions__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/router/contracts/interfaces/ILPWorker.sol/ILPWorker__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/router/contracts/interfaces/IPathResolver__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/router/contracts/interfaces/IRouterComponent__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/router/contracts/interfaces/IRouter__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/router/contracts/interfaces/ISwapAggregator__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/router/contracts/interfaces/ISwapper__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/router/contracts/interfaces/IWithdrawer.sol/IWithdrawerOptions__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/router/contracts/interfaces/IWithdrawer.sol/IWithdrawer__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/router/contracts/interfaces/IWrapper__factory.js +9 -12
- package/lib/types/factories/@openzeppelin/contracts/token/ERC20/IERC20__factory.js +9 -12
- package/lib/types/factories/@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata__factory.js +9 -12
- package/lib/types/factories/@openzeppelin/contracts/token/ERC721/IERC721Receiver__factory.js +9 -12
- package/lib/types/factories/@openzeppelin/contracts/token/ERC721/IERC721__factory.js +9 -12
- package/lib/types/factories/@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata__factory.js +9 -12
- package/lib/types/factories/@openzeppelin/contracts/utils/introspection/IERC165__factory.js +9 -12
- package/lib/types/factories/contracts/IGas__factory.js +9 -12
- package/lib/types/factories/contracts/IGnosisSafeSignatureValidator__factory.js +9 -12
- package/lib/types/factories/contracts/ITokenDistributor.sol/ITokenDistributorEvents__factory.js +9 -12
- package/lib/types/factories/contracts/ITokenDistributor.sol/ITokenDistributorExceptions__factory.js +9 -12
- package/lib/types/factories/contracts/ITokenDistributor.sol/ITokenDistributor__factory.js +9 -12
- package/lib/types/factories/contracts/support/IOffchainOracle__factory.js +9 -12
- package/lib/types/factories/contracts/support/MultiCall.sol/Multicall2__factory.js +27 -50
- package/lib/utils/errors.js +1 -1
- package/lib/utils/extracter.js +4 -4
- package/lib/utils/formatter.d.ts +8 -8
- package/lib/utils/formatter.js +73 -87
- package/lib/utils/loading.js +3 -3
- package/lib/utils/mappers.js +7 -34
- package/lib/utils/math.d.ts +10 -7
- package/lib/utils/math.js +22 -25
- package/lib/utils/multicall.js +32 -98
- package/lib/utils/price.d.ts +3 -4
- package/lib/utils/price.js +8 -20
- package/lib/utils/repeater.js +12 -53
- package/lib/utils/validate.js +2 -2
- package/lib/watchers/creditAccountWatcher.js +136 -237
- package/lib/watchers/creditAccountWatcher.spec.js +51 -68
- package/lib/watchers/creditManagerWatcher.js +21 -71
- package/lib/watchers/creditManagerWatcher.spec.js +20 -23
- package/package.json +2 -2
- package/lib/core/history.d.ts +0 -42
- package/lib/core/history.js +0 -2
- package/lib/core/wcOperation/abstractOperations.d.ts +0 -23
- package/lib/core/wcOperation/abstractOperations.js +0 -39
- package/lib/core/wcOperation/index.d.ts +0 -11
- package/lib/core/wcOperation/index.js +0 -30
- package/lib/core/wcOperation/operations.d.ts +0 -88
- package/lib/core/wcOperation/operations.js +0 -146
- package/lib/core/wcOperation/types.d.ts +0 -15
- package/lib/core/wcOperation/types.js +0 -2
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var _a, _b;
|
|
3
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
var lidoPayload = {
|
|
3
|
+
const chai_1 = require("chai");
|
|
4
|
+
const decimals_1 = require("../tokens/decimals");
|
|
5
|
+
const token_1 = require("../tokens/token");
|
|
6
|
+
const formatter_1 = require("../utils/formatter");
|
|
7
|
+
const constants_1 = require("./constants");
|
|
8
|
+
const strategy_1 = require("./strategy");
|
|
9
|
+
const lidoPayload = {
|
|
12
10
|
name: "Lido",
|
|
13
11
|
lpToken: token_1.tokenDataByNetwork.Mainnet.STETH,
|
|
14
12
|
apy: 38434,
|
|
@@ -21,8 +19,8 @@ var lidoPayload = {
|
|
|
21
19
|
leveragableCollateral: [],
|
|
22
20
|
baseAssets: [token_1.tokenDataByNetwork.Mainnet.WETH],
|
|
23
21
|
};
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
const lidoStrategy = new strategy_1.Strategy(lidoPayload);
|
|
23
|
+
const pools = {
|
|
26
24
|
"0x1": {
|
|
27
25
|
borrowRate: 27543,
|
|
28
26
|
},
|
|
@@ -30,29 +28,29 @@ var pools = {
|
|
|
30
28
|
borrowRate: 5736,
|
|
31
29
|
},
|
|
32
30
|
};
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
describe("Strategy test",
|
|
44
|
-
it("maxAPY calculation is correct",
|
|
45
|
-
|
|
31
|
+
const prices = {
|
|
32
|
+
[token_1.tokenDataByNetwork.Mainnet.WETH.toLowerCase()]: (0, formatter_1.toBN)("1738.11830000", constants_1.PRICE_DECIMALS_POW),
|
|
33
|
+
[token_1.tokenDataByNetwork.Mainnet.DAI.toLowerCase()]: (0, formatter_1.toBN)("0.99941103", constants_1.PRICE_DECIMALS_POW),
|
|
34
|
+
[token_1.tokenDataByNetwork.Mainnet.STETH.toLowerCase()]: (0, formatter_1.toBN)("1703.87588096", constants_1.PRICE_DECIMALS_POW),
|
|
35
|
+
};
|
|
36
|
+
const liquidationThresholds = {
|
|
37
|
+
[token_1.tokenDataByNetwork.Mainnet.DAI.toLowerCase()]: 9300n,
|
|
38
|
+
[token_1.tokenDataByNetwork.Mainnet.WETH.toLowerCase()]: 8500n,
|
|
39
|
+
[token_1.tokenDataByNetwork.Mainnet.STETH.toLowerCase()]: 9000n,
|
|
40
|
+
};
|
|
41
|
+
describe("Strategy test", () => {
|
|
42
|
+
it("maxAPY calculation is correct", () => {
|
|
43
|
+
const result = lidoStrategy.maxAPY(53203, 10 * Number(constants_1.LEVERAGE_DECIMALS), pools["0x1"].borrowRate);
|
|
46
44
|
(0, chai_1.expect)(result).to.be.eq(284143);
|
|
47
45
|
});
|
|
48
|
-
it("overallAPY calculation is correct",
|
|
49
|
-
|
|
46
|
+
it("overallAPY calculation is correct", () => {
|
|
47
|
+
const result = lidoStrategy.overallAPY(lidoStrategy.apy || 0, 10 * Number(constants_1.LEVERAGE_DECIMALS), token_1.tokenDataByNetwork.Mainnet.WETH, pools["0x2"].borrowRate);
|
|
50
48
|
(0, chai_1.expect)(result).to.be.eq(332716);
|
|
51
49
|
});
|
|
52
|
-
it("liquidationPrice calculation is correct",
|
|
53
|
-
|
|
54
|
-
liquidationThresholds
|
|
55
|
-
prices
|
|
50
|
+
it("liquidationPrice calculation is correct", () => {
|
|
51
|
+
const result = strategy_1.Strategy.liquidationPrice({
|
|
52
|
+
liquidationThresholds,
|
|
53
|
+
prices,
|
|
56
54
|
borrowed: (0, formatter_1.toBN)("350", decimals_1.decimals.WETH),
|
|
57
55
|
underlyingToken: token_1.tokenDataByNetwork.Mainnet.WETH,
|
|
58
56
|
lpAmount: (0, formatter_1.toBN)("400", decimals_1.decimals.STETH),
|
|
@@ -60,10 +58,10 @@ describe("Strategy test", function () {
|
|
|
60
58
|
});
|
|
61
59
|
(0, chai_1.expect)(Number((0, formatter_1.toSignificant)(result, constants_1.WAD_DECIMALS_POW)).toFixed(3)).to.be.eq("0.992");
|
|
62
60
|
});
|
|
63
|
-
it("maxLeverage is correct",
|
|
64
|
-
|
|
65
|
-
{ address: "0x1", liquidationThresholds
|
|
61
|
+
it("maxLeverage is correct", () => {
|
|
62
|
+
const result = strategy_1.Strategy.maxLeverage(token_1.tokenDataByNetwork.Mainnet.STETH, [
|
|
63
|
+
{ address: "0x1", liquidationThresholds },
|
|
66
64
|
]);
|
|
67
|
-
(0, chai_1.expect)(result).to.be.eq(9 * constants_1.LEVERAGE_DECIMALS);
|
|
65
|
+
(0, chai_1.expect)(result).to.be.eq(9 * Number(constants_1.LEVERAGE_DECIMALS));
|
|
68
66
|
});
|
|
69
67
|
});
|
package/lib/core/trade.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Signer } from "ethers";
|
|
2
2
|
import { AdapterInterface } from "../contracts/adapters";
|
|
3
3
|
import { MultiCall, PathFinderResult, SwapOperation } from "../pathfinder/core";
|
|
4
4
|
import { ICreditFacade } from "../types";
|
|
@@ -6,8 +6,8 @@ import { BaseAdapter } from "./adapter";
|
|
|
6
6
|
import { EVMTx } from "./eventOrTx";
|
|
7
7
|
interface BaseTradeInterface {
|
|
8
8
|
swapType: SwapOperation;
|
|
9
|
-
sourceAmount:
|
|
10
|
-
expectedAmount:
|
|
9
|
+
sourceAmount: bigint;
|
|
10
|
+
expectedAmount: bigint;
|
|
11
11
|
tokenFrom: string;
|
|
12
12
|
tokenTo: string;
|
|
13
13
|
operationName: TradeOperations;
|
|
@@ -23,9 +23,9 @@ export declare class Trade implements BaseTradeInterface {
|
|
|
23
23
|
readonly tradePath: PathFinderResult;
|
|
24
24
|
readonly creditFacade: string;
|
|
25
25
|
readonly swapType: SwapOperation;
|
|
26
|
-
readonly sourceAmount:
|
|
27
|
-
readonly expectedAmount:
|
|
28
|
-
readonly rate:
|
|
26
|
+
readonly sourceAmount: bigint;
|
|
27
|
+
readonly expectedAmount: bigint;
|
|
28
|
+
readonly rate: bigint;
|
|
29
29
|
readonly tokenFrom: string;
|
|
30
30
|
readonly tokenTo: string;
|
|
31
31
|
readonly operationName: TradeOperations;
|
package/lib/core/trade.js
CHANGED
|
@@ -1,122 +1,87 @@
|
|
|
1
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 __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
3
|
exports.Trade = void 0;
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
4
|
+
const decimals_1 = require("../tokens/decimals");
|
|
5
|
+
const token_1 = require("../tokens/token");
|
|
6
|
+
const types_1 = require("../types");
|
|
7
|
+
const formatter_1 = require("../utils/formatter");
|
|
8
|
+
const constants_1 = require("./constants");
|
|
9
|
+
const transactions_1 = require("./transactions");
|
|
10
|
+
const OPERATION_NAMES = {
|
|
47
11
|
farmWithdraw: "Farm withdraw",
|
|
48
12
|
farmDeposit: "Farm deposit",
|
|
49
13
|
swap: "Swap",
|
|
50
14
|
unknownOperation: "Unknown operation",
|
|
51
15
|
};
|
|
52
|
-
|
|
53
|
-
|
|
16
|
+
class Trade {
|
|
17
|
+
helper;
|
|
18
|
+
tradePath;
|
|
19
|
+
creditFacade;
|
|
20
|
+
swapType;
|
|
21
|
+
sourceAmount;
|
|
22
|
+
expectedAmount;
|
|
23
|
+
rate;
|
|
24
|
+
tokenFrom;
|
|
25
|
+
tokenTo;
|
|
26
|
+
operationName;
|
|
27
|
+
constructor(props) {
|
|
54
28
|
this.helper = props.adapter;
|
|
55
29
|
this.tradePath = props.tradePath;
|
|
56
30
|
this.creditFacade = props.creditFacade;
|
|
57
31
|
this.swapType = props.swapType;
|
|
58
32
|
this.sourceAmount = props.sourceAmount;
|
|
59
33
|
this.expectedAmount = props.expectedAmount;
|
|
60
|
-
this.rate = constants_1.WAD
|
|
34
|
+
this.rate = (constants_1.WAD * props.expectedAmount) / props.sourceAmount;
|
|
61
35
|
this.tokenFrom = props.tokenFrom;
|
|
62
36
|
this.tokenTo = props.tokenTo;
|
|
63
37
|
this.operationName = props.operationName;
|
|
64
38
|
}
|
|
65
|
-
|
|
39
|
+
getName() {
|
|
66
40
|
return this.helper.name;
|
|
67
|
-
}
|
|
68
|
-
|
|
41
|
+
}
|
|
42
|
+
getAdapterInterface() {
|
|
69
43
|
return this.helper.adapterInterface;
|
|
70
|
-
}
|
|
71
|
-
|
|
44
|
+
}
|
|
45
|
+
getContractAddress() {
|
|
72
46
|
return this.helper.contractAddress;
|
|
73
|
-
}
|
|
74
|
-
|
|
47
|
+
}
|
|
48
|
+
getAdapterAddress() {
|
|
75
49
|
return this.helper.adapterAddress;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
amountFrom: this.sourceAmount,
|
|
90
|
-
amountTo: this.expectedAmount,
|
|
91
|
-
tokenFrom: this.tokenFrom,
|
|
92
|
-
tokenTo: this.tokenTo,
|
|
93
|
-
creditManager: this.helper.creditManager,
|
|
94
|
-
timestamp: 0,
|
|
95
|
-
})];
|
|
96
|
-
}
|
|
97
|
-
});
|
|
50
|
+
}
|
|
51
|
+
async execute(signer) {
|
|
52
|
+
const receipt = await Trade.executeMulticallPath(this.creditFacade, signer, this.tradePath.calls);
|
|
53
|
+
return new transactions_1.TXSwap({
|
|
54
|
+
txHash: receipt.hash,
|
|
55
|
+
protocol: this.helper.contractAddress,
|
|
56
|
+
operation: OPERATION_NAMES[this.operationName],
|
|
57
|
+
amountFrom: this.sourceAmount,
|
|
58
|
+
amountTo: this.expectedAmount,
|
|
59
|
+
tokenFrom: this.tokenFrom,
|
|
60
|
+
tokenTo: this.tokenTo,
|
|
61
|
+
creditManager: this.helper.creditManager,
|
|
62
|
+
timestamp: 0,
|
|
98
63
|
});
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
64
|
+
}
|
|
65
|
+
toString() {
|
|
66
|
+
const symbolFrom = token_1.tokenSymbolByAddress[this.tokenFrom.toLowerCase()];
|
|
67
|
+
const symbolTo = token_1.tokenSymbolByAddress[this.tokenTo.toLowerCase()];
|
|
103
68
|
if (!symbolFrom)
|
|
104
|
-
throw new Error(
|
|
69
|
+
throw new Error(`Unknown token: ${this.tokenFrom}`);
|
|
105
70
|
if (!symbolTo)
|
|
106
|
-
throw new Error(
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
return
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
71
|
+
throw new Error(`Unknown token: ${this.tokenTo}`);
|
|
72
|
+
const decimalsFrom = decimals_1.decimals[symbolFrom];
|
|
73
|
+
const decimalsTo = decimals_1.decimals[symbolTo];
|
|
74
|
+
return `${this.operationName} ${(0, formatter_1.formatBN)(this.sourceAmount, decimalsFrom)} ${symbolFrom} ⇒ ${(0, formatter_1.formatBN)(this.expectedAmount, decimalsTo)} ${symbolTo} on ${this.helper.name}`;
|
|
75
|
+
}
|
|
76
|
+
static getOperationName(tokenInAddress, tokenOutAddress) {
|
|
77
|
+
const tokenInSymbol = token_1.tokenSymbolByAddress[tokenInAddress];
|
|
78
|
+
const tokenOutSymbol = token_1.tokenSymbolByAddress[tokenOutAddress];
|
|
79
|
+
const tokenInIsLp = (0, token_1.isLPToken)(tokenInSymbol);
|
|
80
|
+
const tokenOutIsLp = (0, token_1.isLPToken)(tokenOutSymbol);
|
|
116
81
|
if (!tokenInSymbol)
|
|
117
|
-
throw new Error(
|
|
82
|
+
throw new Error(`Unknown token: ${tokenInAddress}`);
|
|
118
83
|
if (!tokenOutSymbol)
|
|
119
|
-
throw new Error(
|
|
84
|
+
throw new Error(`Unknown token: ${tokenOutAddress}`);
|
|
120
85
|
if (tokenInIsLp && !tokenOutIsLp)
|
|
121
86
|
return "farmWithdraw";
|
|
122
87
|
if (!tokenInIsLp && tokenOutIsLp)
|
|
@@ -124,27 +89,17 @@ var Trade = /** @class */ (function () {
|
|
|
124
89
|
if (!tokenInIsLp && !tokenOutIsLp)
|
|
125
90
|
return "swap";
|
|
126
91
|
return "unknownOperation";
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
};
|
|
141
|
-
Trade.executeOnCreditFacade = function (calls, creditFacade) {
|
|
142
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
143
|
-
return __generator(this, function (_a) {
|
|
144
|
-
return [2 /*return*/, creditFacade.multicall(calls)];
|
|
145
|
-
});
|
|
146
|
-
});
|
|
147
|
-
};
|
|
148
|
-
return Trade;
|
|
149
|
-
}());
|
|
92
|
+
}
|
|
93
|
+
static async executeMulticallPath(creditFacade, signer, calls) {
|
|
94
|
+
if (calls.length < 1)
|
|
95
|
+
throw new Error("No path to execute");
|
|
96
|
+
const safeCreditFacade = typeof creditFacade === "string"
|
|
97
|
+
? types_1.ICreditFacade__factory.connect(creditFacade, signer)
|
|
98
|
+
: creditFacade;
|
|
99
|
+
return this.executeOnCreditFacade(calls, safeCreditFacade);
|
|
100
|
+
}
|
|
101
|
+
static async executeOnCreditFacade(calls, creditFacade) {
|
|
102
|
+
return creditFacade.multicall(calls);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
150
105
|
exports.Trade = Trade;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { BigNumber } from "ethers";
|
|
2
1
|
import { SupportedContract } from "../contracts/contracts";
|
|
3
2
|
import { EVMTx, EVMTxProps } from "./eventOrTx";
|
|
4
3
|
export interface TxSerialized {
|
|
@@ -10,12 +9,12 @@ export declare class TxSerializer {
|
|
|
10
9
|
static deserialize(data: string): Array<EVMTx>;
|
|
11
10
|
}
|
|
12
11
|
interface AddLiquidityProps extends EVMTxProps {
|
|
13
|
-
amount:
|
|
12
|
+
amount: bigint;
|
|
14
13
|
underlyingToken: string;
|
|
15
14
|
pool: string;
|
|
16
15
|
}
|
|
17
16
|
export declare class TxAddLiquidity extends EVMTx {
|
|
18
|
-
readonly amount:
|
|
17
|
+
readonly amount: bigint;
|
|
19
18
|
readonly underlyingToken: string;
|
|
20
19
|
readonly pool: string;
|
|
21
20
|
constructor(opts: AddLiquidityProps);
|
|
@@ -23,12 +22,12 @@ export declare class TxAddLiquidity extends EVMTx {
|
|
|
23
22
|
serialize(): TxSerialized;
|
|
24
23
|
}
|
|
25
24
|
interface RemoveLiquidityProps extends EVMTxProps {
|
|
26
|
-
amount:
|
|
25
|
+
amount: bigint;
|
|
27
26
|
dieselToken: string;
|
|
28
27
|
pool: string;
|
|
29
28
|
}
|
|
30
29
|
export declare class TxRemoveLiquidity extends EVMTx {
|
|
31
|
-
readonly amount:
|
|
30
|
+
readonly amount: bigint;
|
|
32
31
|
readonly dieselToken: string;
|
|
33
32
|
readonly pool: string;
|
|
34
33
|
constructor(opts: RemoveLiquidityProps);
|
|
@@ -38,8 +37,8 @@ export declare class TxRemoveLiquidity extends EVMTx {
|
|
|
38
37
|
interface SwapProps extends EVMTxProps {
|
|
39
38
|
protocol: string;
|
|
40
39
|
operation: string;
|
|
41
|
-
amountFrom:
|
|
42
|
-
amountTo?:
|
|
40
|
+
amountFrom: bigint;
|
|
41
|
+
amountTo?: bigint;
|
|
43
42
|
tokenFrom: string;
|
|
44
43
|
tokenTo?: string;
|
|
45
44
|
creditManager: string;
|
|
@@ -47,8 +46,8 @@ interface SwapProps extends EVMTxProps {
|
|
|
47
46
|
export declare class TXSwap extends EVMTx {
|
|
48
47
|
readonly protocol: string;
|
|
49
48
|
readonly operation: string;
|
|
50
|
-
readonly amountFrom:
|
|
51
|
-
readonly amountTo?:
|
|
49
|
+
readonly amountFrom: bigint;
|
|
50
|
+
readonly amountTo?: bigint;
|
|
52
51
|
readonly tokenFrom: string;
|
|
53
52
|
readonly tokenTo?: string;
|
|
54
53
|
readonly creditManager: string;
|
|
@@ -57,12 +56,12 @@ export declare class TXSwap extends EVMTx {
|
|
|
57
56
|
serialize(): TxSerialized;
|
|
58
57
|
}
|
|
59
58
|
interface AddCollateralProps extends EVMTxProps {
|
|
60
|
-
amount:
|
|
59
|
+
amount: bigint;
|
|
61
60
|
addedToken: string;
|
|
62
61
|
creditManager: string;
|
|
63
62
|
}
|
|
64
63
|
export declare class TxAddCollateral extends EVMTx {
|
|
65
|
-
readonly amount:
|
|
64
|
+
readonly amount: bigint;
|
|
66
65
|
readonly addedToken: string;
|
|
67
66
|
readonly creditManager: string;
|
|
68
67
|
constructor(opts: AddCollateralProps);
|
|
@@ -70,12 +69,12 @@ export declare class TxAddCollateral extends EVMTx {
|
|
|
70
69
|
serialize(): TxSerialized;
|
|
71
70
|
}
|
|
72
71
|
interface IncreaseBorrowAmountProps extends EVMTxProps {
|
|
73
|
-
amount:
|
|
72
|
+
amount: bigint;
|
|
74
73
|
underlyingToken: string;
|
|
75
74
|
creditManager: string;
|
|
76
75
|
}
|
|
77
76
|
export declare class TxIncreaseBorrowAmount extends EVMTx {
|
|
78
|
-
readonly amount:
|
|
77
|
+
readonly amount: bigint;
|
|
79
78
|
readonly underlyingToken: string;
|
|
80
79
|
readonly creditManager: string;
|
|
81
80
|
constructor(opts: IncreaseBorrowAmountProps);
|
|
@@ -83,12 +82,12 @@ export declare class TxIncreaseBorrowAmount extends EVMTx {
|
|
|
83
82
|
serialize(): TxSerialized;
|
|
84
83
|
}
|
|
85
84
|
interface DecreaseBorrowAmountProps extends EVMTxProps {
|
|
86
|
-
amount:
|
|
85
|
+
amount: bigint;
|
|
87
86
|
underlyingToken: string;
|
|
88
87
|
creditManager: string;
|
|
89
88
|
}
|
|
90
89
|
export declare class TxDecreaseBorrowAmount extends EVMTx {
|
|
91
|
-
readonly amount:
|
|
90
|
+
readonly amount: bigint;
|
|
92
91
|
readonly underlyingToken: string;
|
|
93
92
|
readonly creditManager: string;
|
|
94
93
|
constructor(opts: DecreaseBorrowAmountProps);
|
|
@@ -96,13 +95,13 @@ export declare class TxDecreaseBorrowAmount extends EVMTx {
|
|
|
96
95
|
serialize(): TxSerialized;
|
|
97
96
|
}
|
|
98
97
|
interface OpenAccountProps extends EVMTxProps {
|
|
99
|
-
amount:
|
|
98
|
+
amount: bigint;
|
|
100
99
|
underlyingToken: string;
|
|
101
100
|
leverage: number;
|
|
102
101
|
creditManager: string;
|
|
103
102
|
}
|
|
104
103
|
export declare class TxOpenAccount extends EVMTx {
|
|
105
|
-
readonly amount:
|
|
104
|
+
readonly amount: bigint;
|
|
106
105
|
readonly underlyingToken: string;
|
|
107
106
|
readonly leverage: number;
|
|
108
107
|
readonly creditManager: string;
|
|
@@ -111,13 +110,13 @@ export declare class TxOpenAccount extends EVMTx {
|
|
|
111
110
|
serialize(): TxSerialized;
|
|
112
111
|
}
|
|
113
112
|
interface TxOpenMultitokenAccountProps extends EVMTxProps {
|
|
114
|
-
borrowedAmount:
|
|
113
|
+
borrowedAmount: bigint;
|
|
115
114
|
creditManager: string;
|
|
116
115
|
underlyingToken: string;
|
|
117
116
|
assets: Array<string>;
|
|
118
117
|
}
|
|
119
118
|
export declare class TxOpenMultitokenAccount extends EVMTx {
|
|
120
|
-
readonly borrowedAmount:
|
|
119
|
+
readonly borrowedAmount: bigint;
|
|
121
120
|
readonly creditManager: string;
|
|
122
121
|
readonly underlyingToken: string;
|
|
123
122
|
readonly assets: Array<string>;
|
|
@@ -142,11 +141,11 @@ export declare class TxClaimNFT extends EVMTx {
|
|
|
142
141
|
}
|
|
143
142
|
interface TxClaimGearRewardsProps extends EVMTxProps {
|
|
144
143
|
token: string;
|
|
145
|
-
amount:
|
|
144
|
+
amount: bigint;
|
|
146
145
|
}
|
|
147
146
|
export declare class TxClaimGearRewards extends EVMTx {
|
|
148
|
-
token: string;
|
|
149
|
-
amount:
|
|
147
|
+
readonly token: string;
|
|
148
|
+
readonly amount: bigint;
|
|
150
149
|
constructor(opts: TxClaimGearRewardsProps);
|
|
151
150
|
toString(): string;
|
|
152
151
|
serialize(): TxSerialized;
|