@defisaver/sdk 1.0.0 → 1.0.1
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/esm/AccessLists/AaveAccessLists.d.ts +2 -0
- package/esm/AccessLists/AaveAccessLists.js +19 -0
- package/esm/AccessLists/BalancerAccessLists.d.ts +2 -0
- package/esm/AccessLists/BalancerAccessLists.js +14 -0
- package/esm/AccessLists/CompoundAccessLists.d.ts +2 -0
- package/esm/AccessLists/CompoundAccessLists.js +23 -0
- package/esm/AccessLists/DyDxAccessLists.d.ts +2 -0
- package/esm/AccessLists/DyDxAccessLists.js +6 -0
- package/esm/AccessLists/FlashLoanAccessLists.d.ts +2 -0
- package/esm/AccessLists/FlashLoanAccessLists.js +20 -0
- package/esm/AccessLists/GuniAccessLists.d.ts +2 -0
- package/esm/AccessLists/GuniAccessLists.js +10 -0
- package/esm/AccessLists/InstaAccessLists.d.ts +2 -0
- package/esm/AccessLists/InstaAccessLists.js +5 -0
- package/esm/AccessLists/LidoAccessLists.d.ts +2 -0
- package/esm/AccessLists/LidoAccessLists.js +15 -0
- package/esm/AccessLists/LiquityAccessLists.d.ts +2 -0
- package/esm/AccessLists/LiquityAccessLists.js +65 -0
- package/esm/AccessLists/MStableAccessLists.d.ts +2 -0
- package/esm/AccessLists/MStableAccessLists.js +12 -0
- package/esm/AccessLists/MakerAccessLists.d.ts +2 -0
- package/esm/AccessLists/MakerAccessLists.js +34 -0
- package/esm/AccessLists/RariAccessLists.d.ts +2 -0
- package/esm/AccessLists/RariAccessLists.js +8 -0
- package/esm/AccessLists/ReflexerAccessLists.d.ts +2 -0
- package/esm/AccessLists/ReflexerAccessLists.js +42 -0
- package/esm/AccessLists/UniswapAccessLists.d.ts +2 -0
- package/esm/AccessLists/UniswapAccessLists.js +31 -0
- package/esm/AccessLists/UtilsAccessLists.d.ts +2 -0
- package/esm/AccessLists/UtilsAccessLists.js +23 -0
- package/esm/AccessLists/YearnAccessLists.d.ts +2 -0
- package/esm/AccessLists/YearnAccessLists.js +9 -0
- package/esm/AccessLists/index.d.ts +3 -0
- package/esm/AccessLists/index.js +17 -0
- package/esm/src/Action.d.ts +77 -0
- package/esm/src/Action.js +193 -0
- package/esm/src/ActionWithL2.d.ts +20 -0
- package/esm/src/ActionWithL2.js +49 -0
- package/esm/src/DfsWeb3.d.ts +31 -0
- package/esm/src/DfsWeb3.js +124 -0
- package/esm/src/Recipe.d.ts +49 -0
- package/esm/src/Recipe.js +135 -0
- package/esm/src/Strategy.d.ts +19 -0
- package/esm/src/Strategy.js +47 -0
- package/esm/src/abis/Action.json +247 -0
- package/esm/src/abis/DFSProxyRegistry.json +193 -0
- package/esm/src/abis/DsProxy.json +218 -0
- package/esm/src/abis/Erc20.json +222 -0
- package/esm/src/abis/ProxyRegistry.json +65 -0
- package/esm/src/abis/Recipe.json +254 -0
- package/esm/src/actions/aave/AaveBorrowAction.d.ts +18 -0
- package/esm/src/actions/aave/AaveBorrowAction.js +22 -0
- package/esm/src/actions/aave/AaveClaimStkAaveAction.d.ts +15 -0
- package/esm/src/actions/aave/AaveClaimStkAaveAction.js +23 -0
- package/esm/src/actions/aave/AaveCollateralSwitchAction.d.ts +15 -0
- package/esm/src/actions/aave/AaveCollateralSwitchAction.js +18 -0
- package/esm/src/actions/aave/AavePaybackAction.d.ts +22 -0
- package/esm/src/actions/aave/AavePaybackAction.js +38 -0
- package/esm/src/actions/aave/AaveSupplyAction.d.ts +22 -0
- package/esm/src/actions/aave/AaveSupplyAction.js +45 -0
- package/esm/src/actions/aave/AaveWithdrawAction.d.ts +16 -0
- package/esm/src/actions/aave/AaveWithdrawAction.js +20 -0
- package/esm/src/actions/aave/index.d.ts +6 -0
- package/esm/src/actions/aave/index.js +6 -0
- package/esm/src/actions/aaveV3/AaveV3ATokenPaybackAction.d.ts +25 -0
- package/esm/src/actions/aaveV3/AaveV3ATokenPaybackAction.js +64 -0
- package/esm/src/actions/aaveV3/AaveV3BorrowAction.d.ts +21 -0
- package/esm/src/actions/aaveV3/AaveV3BorrowAction.js +59 -0
- package/esm/src/actions/aaveV3/AaveV3ClaimRewardsAction.d.ts +18 -0
- package/esm/src/actions/aaveV3/AaveV3ClaimRewardsAction.js +40 -0
- package/esm/src/actions/aaveV3/AaveV3CollateralSwitchAction.d.ts +18 -0
- package/esm/src/actions/aaveV3/AaveV3CollateralSwitchAction.js +39 -0
- package/esm/src/actions/aaveV3/AaveV3PaybackAction.d.ts +27 -0
- package/esm/src/actions/aaveV3/AaveV3PaybackAction.js +77 -0
- package/esm/src/actions/aaveV3/AaveV3SetEModeAction.d.ts +16 -0
- package/esm/src/actions/aaveV3/AaveV3SetEModeAction.js +33 -0
- package/esm/src/actions/aaveV3/AaveV3SupplyAction.d.ts +27 -0
- package/esm/src/actions/aaveV3/AaveV3SupplyAction.js +77 -0
- package/esm/src/actions/aaveV3/AaveV3SwapBorrowRateModeAction.d.ts +18 -0
- package/esm/src/actions/aaveV3/AaveV3SwapBorrowRateModeAction.js +38 -0
- package/esm/src/actions/aaveV3/AaveV3WithdrawAction.d.ts +18 -0
- package/esm/src/actions/aaveV3/AaveV3WithdrawAction.js +45 -0
- package/esm/src/actions/aaveV3/index.d.ts +9 -0
- package/esm/src/actions/aaveV3/index.js +9 -0
- package/esm/src/actions/balancer/BalancerV2ClaimAction.d.ts +20 -0
- package/esm/src/actions/balancer/BalancerV2ClaimAction.js +49 -0
- package/esm/src/actions/balancer/BalancerV2SupplyAction.d.ts +22 -0
- package/esm/src/actions/balancer/BalancerV2SupplyAction.js +52 -0
- package/esm/src/actions/balancer/BalancerV2WithdrawAction.d.ts +24 -0
- package/esm/src/actions/balancer/BalancerV2WithdrawAction.js +56 -0
- package/esm/src/actions/balancer/index.d.ts +3 -0
- package/esm/src/actions/balancer/index.js +3 -0
- package/esm/src/actions/basic/AutomationV2Unsub.d.ts +9 -0
- package/esm/src/actions/basic/AutomationV2Unsub.js +11 -0
- package/esm/src/actions/basic/ChangeProxyOwnerAction.d.ts +13 -0
- package/esm/src/actions/basic/ChangeProxyOwnerAction.js +15 -0
- package/esm/src/actions/basic/GasFeeAction.d.ts +14 -0
- package/esm/src/actions/basic/GasFeeAction.js +21 -0
- package/esm/src/actions/basic/GasFeeActionL2.d.ts +15 -0
- package/esm/src/actions/basic/GasFeeActionL2.js +22 -0
- package/esm/src/actions/basic/PullTokenAction.d.ts +19 -0
- package/esm/src/actions/basic/PullTokenAction.js +41 -0
- package/esm/src/actions/basic/SellAction.d.ts +23 -0
- package/esm/src/actions/basic/SellAction.js +61 -0
- package/esm/src/actions/basic/SendTokenAction.d.ts +15 -0
- package/esm/src/actions/basic/SendTokenAction.js +23 -0
- package/esm/src/actions/basic/SendTokenAndUnwrapAction.d.ts +15 -0
- package/esm/src/actions/basic/SendTokenAndUnwrapAction.js +23 -0
- package/esm/src/actions/basic/SubInputsAction.d.ts +10 -0
- package/esm/src/actions/basic/SubInputsAction.js +15 -0
- package/esm/src/actions/basic/SumInputsAction.d.ts +10 -0
- package/esm/src/actions/basic/SumInputsAction.js +15 -0
- package/esm/src/actions/basic/ToggleSubAction.d.ts +14 -0
- package/esm/src/actions/basic/ToggleSubAction.js +16 -0
- package/esm/src/actions/basic/TokenBalanceAction.d.ts +8 -0
- package/esm/src/actions/basic/TokenBalanceAction.js +13 -0
- package/esm/src/actions/basic/TransferNFTAction.d.ts +8 -0
- package/esm/src/actions/basic/TransferNFTAction.js +17 -0
- package/esm/src/actions/basic/UnwrapEthAction.d.ts +15 -0
- package/esm/src/actions/basic/UnwrapEthAction.js +30 -0
- package/esm/src/actions/basic/UpdateSubAction.d.ts +14 -0
- package/esm/src/actions/basic/UpdateSubAction.js +16 -0
- package/esm/src/actions/basic/WrapEthAction.d.ts +15 -0
- package/esm/src/actions/basic/WrapEthAction.js +36 -0
- package/esm/src/actions/basic/index.d.ts +16 -0
- package/esm/src/actions/basic/index.js +16 -0
- package/esm/src/actions/checkers/AaveV3RatioCheckAction.d.ts +14 -0
- package/esm/src/actions/checkers/AaveV3RatioCheckAction.js +20 -0
- package/esm/src/actions/checkers/CompoundV3RatioCheckAction.d.ts +16 -0
- package/esm/src/actions/checkers/CompoundV3RatioCheckAction.js +24 -0
- package/esm/src/actions/checkers/MakerRatioCheckAction.d.ts +17 -0
- package/esm/src/actions/checkers/MakerRatioCheckAction.js +25 -0
- package/esm/src/actions/checkers/index.d.ts +3 -0
- package/esm/src/actions/checkers/index.js +3 -0
- package/esm/src/actions/chickenBonds/CBChickenInAction.d.ts +14 -0
- package/esm/src/actions/chickenBonds/CBChickenInAction.js +18 -0
- package/esm/src/actions/chickenBonds/CBChickenOutAction.d.ts +15 -0
- package/esm/src/actions/chickenBonds/CBChickenOutAction.js +19 -0
- package/esm/src/actions/chickenBonds/CBCreateAction.d.ts +18 -0
- package/esm/src/actions/chickenBonds/CBCreateAction.js +32 -0
- package/esm/src/actions/chickenBonds/CBRedeemAction.d.ts +20 -0
- package/esm/src/actions/chickenBonds/CBRedeemAction.js +35 -0
- package/esm/src/actions/chickenBonds/index.d.ts +4 -0
- package/esm/src/actions/chickenBonds/index.js +4 -0
- package/esm/src/actions/compound/CompoundBorrowAction.d.ts +15 -0
- package/esm/src/actions/compound/CompoundBorrowAction.js +19 -0
- package/esm/src/actions/compound/CompoundClaimAction.d.ts +16 -0
- package/esm/src/actions/compound/CompoundClaimAction.js +24 -0
- package/esm/src/actions/compound/CompoundCollateralSwitchAction.d.ts +10 -0
- package/esm/src/actions/compound/CompoundCollateralSwitchAction.js +12 -0
- package/esm/src/actions/compound/CompoundGetDebtAction.d.ts +8 -0
- package/esm/src/actions/compound/CompoundGetDebtAction.js +13 -0
- package/esm/src/actions/compound/CompoundPaybackAction.d.ts +20 -0
- package/esm/src/actions/compound/CompoundPaybackAction.js +38 -0
- package/esm/src/actions/compound/CompoundSupplyAction.d.ts +20 -0
- package/esm/src/actions/compound/CompoundSupplyAction.js +43 -0
- package/esm/src/actions/compound/CompoundWithdrawAction.d.ts +15 -0
- package/esm/src/actions/compound/CompoundWithdrawAction.js +19 -0
- package/esm/src/actions/compound/index.d.ts +7 -0
- package/esm/src/actions/compound/index.js +7 -0
- package/esm/src/actions/compoundV3/CompoundV3AllowAction.d.ts +15 -0
- package/esm/src/actions/compoundV3/CompoundV3AllowAction.js +24 -0
- package/esm/src/actions/compoundV3/CompoundV3BorrowAction.d.ts +16 -0
- package/esm/src/actions/compoundV3/CompoundV3BorrowAction.js +26 -0
- package/esm/src/actions/compoundV3/CompoundV3ClaimAction.d.ts +16 -0
- package/esm/src/actions/compoundV3/CompoundV3ClaimAction.js +27 -0
- package/esm/src/actions/compoundV3/CompoundV3PaybackAction.d.ts +22 -0
- package/esm/src/actions/compoundV3/CompoundV3PaybackAction.js +48 -0
- package/esm/src/actions/compoundV3/CompoundV3SupplyAction.d.ts +22 -0
- package/esm/src/actions/compoundV3/CompoundV3SupplyAction.js +45 -0
- package/esm/src/actions/compoundV3/CompoundV3TransferAction.d.ts +17 -0
- package/esm/src/actions/compoundV3/CompoundV3TransferAction.js +30 -0
- package/esm/src/actions/compoundV3/CompoundV3WithdrawAction.d.ts +17 -0
- package/esm/src/actions/compoundV3/CompoundV3WithdrawAction.js +29 -0
- package/esm/src/actions/compoundV3/index.d.ts +7 -0
- package/esm/src/actions/compoundV3/index.js +7 -0
- package/esm/src/actions/convex/ConvexClaimAction.d.ts +17 -0
- package/esm/src/actions/convex/ConvexClaimAction.js +59 -0
- package/esm/src/actions/convex/ConvexDepositAction.d.ts +22 -0
- package/esm/src/actions/convex/ConvexDepositAction.js +66 -0
- package/esm/src/actions/convex/ConvexWithdrawAction.d.ts +22 -0
- package/esm/src/actions/convex/ConvexWithdrawAction.js +63 -0
- package/esm/src/actions/convex/index.d.ts +3 -0
- package/esm/src/actions/convex/index.js +3 -0
- package/esm/src/actions/curve/CurveClaimFeesAction.d.ts +13 -0
- package/esm/src/actions/curve/CurveClaimFeesAction.js +22 -0
- package/esm/src/actions/curve/CurveDepositAction.d.ts +18 -0
- package/esm/src/actions/curve/CurveDepositAction.js +78 -0
- package/esm/src/actions/curve/CurveGaugeDepositAction.d.ts +20 -0
- package/esm/src/actions/curve/CurveGaugeDepositAction.js +40 -0
- package/esm/src/actions/curve/CurveGaugeWithdrawAction.d.ts +14 -0
- package/esm/src/actions/curve/CurveGaugeWithdrawAction.js +22 -0
- package/esm/src/actions/curve/CurveMintCrvAction.d.ts +12 -0
- package/esm/src/actions/curve/CurveMintCrvAction.js +19 -0
- package/esm/src/actions/curve/CurveStethPoolDepositAction.d.ts +16 -0
- package/esm/src/actions/curve/CurveStethPoolDepositAction.js +27 -0
- package/esm/src/actions/curve/CurveStethPoolWithdrawAction.d.ts +17 -0
- package/esm/src/actions/curve/CurveStethPoolWithdrawAction.js +28 -0
- package/esm/src/actions/curve/CurveSwapAction.d.ts +22 -0
- package/esm/src/actions/curve/CurveSwapAction.js +43 -0
- package/esm/src/actions/curve/CurveWithdrawAction.d.ts +22 -0
- package/esm/src/actions/curve/CurveWithdrawAction.js +72 -0
- package/esm/src/actions/curve/index.d.ts +9 -0
- package/esm/src/actions/curve/index.js +9 -0
- package/esm/src/actions/dydx/DyDxWithdrawAction.d.ts +15 -0
- package/esm/src/actions/dydx/DyDxWithdrawAction.js +19 -0
- package/esm/src/actions/dydx/index.d.ts +1 -0
- package/esm/src/actions/dydx/index.js +1 -0
- package/esm/src/actions/flashloan/AaveV2FlashLoanAction.d.ts +18 -0
- package/esm/src/actions/flashloan/AaveV2FlashLoanAction.js +20 -0
- package/esm/src/actions/flashloan/AaveV2FlashLoanPaybackAction.d.ts +14 -0
- package/esm/src/actions/flashloan/AaveV2FlashLoanPaybackAction.js +16 -0
- package/esm/src/actions/flashloan/AaveV3FlashLoanAction.d.ts +18 -0
- package/esm/src/actions/flashloan/AaveV3FlashLoanAction.js +20 -0
- package/esm/src/actions/flashloan/AaveV3FlashLoanPaybackAction.d.ts +14 -0
- package/esm/src/actions/flashloan/AaveV3FlashLoanPaybackAction.js +16 -0
- package/esm/src/actions/flashloan/BalancerFlashLoanAction.d.ts +16 -0
- package/esm/src/actions/flashloan/BalancerFlashLoanAction.js +18 -0
- package/esm/src/actions/flashloan/BalancerFlashLoanPaybackAction.d.ts +14 -0
- package/esm/src/actions/flashloan/BalancerFlashLoanPaybackAction.js +16 -0
- package/esm/src/actions/flashloan/DyDxFlashLoanAction.d.ts +16 -0
- package/esm/src/actions/flashloan/DyDxFlashLoanAction.js +18 -0
- package/esm/src/actions/flashloan/DyDxFlashLoanPaybackAction.d.ts +14 -0
- package/esm/src/actions/flashloan/DyDxFlashLoanPaybackAction.js +16 -0
- package/esm/src/actions/flashloan/EulerFlashLoanAction.d.ts +16 -0
- package/esm/src/actions/flashloan/EulerFlashLoanAction.js +18 -0
- package/esm/src/actions/flashloan/EulerFlashLoanPaybackAction.d.ts +13 -0
- package/esm/src/actions/flashloan/EulerFlashLoanPaybackAction.js +15 -0
- package/esm/src/actions/flashloan/MakerFlashLoanAction.d.ts +15 -0
- package/esm/src/actions/flashloan/MakerFlashLoanAction.js +17 -0
- package/esm/src/actions/flashloan/MakerFlashLoanPaybackAction.d.ts +13 -0
- package/esm/src/actions/flashloan/MakerFlashLoanPaybackAction.js +15 -0
- package/esm/src/actions/flashloan/index.d.ts +12 -0
- package/esm/src/actions/flashloan/index.js +12 -0
- package/esm/src/actions/guni/GUniDeposit.d.ts +24 -0
- package/esm/src/actions/guni/GUniDeposit.js +47 -0
- package/esm/src/actions/guni/GUniWithdraw.d.ts +22 -0
- package/esm/src/actions/guni/GUniWithdraw.js +39 -0
- package/esm/src/actions/guni/index.d.ts +2 -0
- package/esm/src/actions/guni/index.js +2 -0
- package/esm/src/actions/index.d.ts +24 -0
- package/esm/src/actions/index.js +24 -0
- package/esm/src/actions/insta/InstPullTokensAction.d.ts +18 -0
- package/esm/src/actions/insta/InstPullTokensAction.js +36 -0
- package/esm/src/actions/insta/index.d.ts +1 -0
- package/esm/src/actions/insta/index.js +1 -0
- package/esm/src/actions/lido/LidoStakeAction.d.ts +19 -0
- package/esm/src/actions/lido/LidoStakeAction.js +34 -0
- package/esm/src/actions/lido/LidoUnwrapAction.d.ts +19 -0
- package/esm/src/actions/lido/LidoUnwrapAction.js +33 -0
- package/esm/src/actions/lido/LidoWrapAction.d.ts +20 -0
- package/esm/src/actions/lido/LidoWrapAction.js +45 -0
- package/esm/src/actions/lido/index.d.ts +3 -0
- package/esm/src/actions/lido/index.js +3 -0
- package/esm/src/actions/liquity/LiquityBorrowAction.d.ts +15 -0
- package/esm/src/actions/liquity/LiquityBorrowAction.js +24 -0
- package/esm/src/actions/liquity/LiquityClaimAction.d.ts +13 -0
- package/esm/src/actions/liquity/LiquityClaimAction.js +20 -0
- package/esm/src/actions/liquity/LiquityClaimSPRewardsAction.d.ts +14 -0
- package/esm/src/actions/liquity/LiquityClaimSPRewardsAction.js +18 -0
- package/esm/src/actions/liquity/LiquityClaimStakingRewardsAction.d.ts +14 -0
- package/esm/src/actions/liquity/LiquityClaimStakingRewardsAction.js +18 -0
- package/esm/src/actions/liquity/LiquityCloseAction.d.ts +18 -0
- package/esm/src/actions/liquity/LiquityCloseAction.js +38 -0
- package/esm/src/actions/liquity/LiquityEthGainToTroveAction.d.ts +13 -0
- package/esm/src/actions/liquity/LiquityEthGainToTroveAction.js +20 -0
- package/esm/src/actions/liquity/LiquityOpenAction.d.ts +21 -0
- package/esm/src/actions/liquity/LiquityOpenAction.js +44 -0
- package/esm/src/actions/liquity/LiquityPaybackAction.d.ts +18 -0
- package/esm/src/actions/liquity/LiquityPaybackAction.js +37 -0
- package/esm/src/actions/liquity/LiquityRedeemAction.d.ts +20 -0
- package/esm/src/actions/liquity/LiquityRedeemAction.js +42 -0
- package/esm/src/actions/liquity/LiquitySPDepositAction.d.ts +20 -0
- package/esm/src/actions/liquity/LiquitySPDepositAction.js +43 -0
- package/esm/src/actions/liquity/LiquitySPWithdrawAction.d.ts +16 -0
- package/esm/src/actions/liquity/LiquitySPWithdrawAction.js +28 -0
- package/esm/src/actions/liquity/LiquityStakeAction.d.ts +20 -0
- package/esm/src/actions/liquity/LiquityStakeAction.js +43 -0
- package/esm/src/actions/liquity/LiquitySupplyAction.d.ts +18 -0
- package/esm/src/actions/liquity/LiquitySupplyAction.js +37 -0
- package/esm/src/actions/liquity/LiquityUnstakeAction.d.ts +16 -0
- package/esm/src/actions/liquity/LiquityUnstakeAction.js +28 -0
- package/esm/src/actions/liquity/LiquityWithdrawAction.d.ts +14 -0
- package/esm/src/actions/liquity/LiquityWithdrawAction.js +22 -0
- package/esm/src/actions/liquity/index.d.ts +15 -0
- package/esm/src/actions/liquity/index.js +15 -0
- package/esm/src/actions/maker/MakerClaimAction.d.ts +15 -0
- package/esm/src/actions/maker/MakerClaimAction.js +24 -0
- package/esm/src/actions/maker/MakerGenerateAction.d.ts +16 -0
- package/esm/src/actions/maker/MakerGenerateAction.js +20 -0
- package/esm/src/actions/maker/MakerGiveAction.d.ts +16 -0
- package/esm/src/actions/maker/MakerGiveAction.js +25 -0
- package/esm/src/actions/maker/MakerMergeAction.d.ts +15 -0
- package/esm/src/actions/maker/MakerMergeAction.js +17 -0
- package/esm/src/actions/maker/MakerOpenVaultAction.d.ts +14 -0
- package/esm/src/actions/maker/MakerOpenVaultAction.js +16 -0
- package/esm/src/actions/maker/MakerPaybackAction.d.ts +20 -0
- package/esm/src/actions/maker/MakerPaybackAction.js +33 -0
- package/esm/src/actions/maker/MakerRatioAction.d.ts +13 -0
- package/esm/src/actions/maker/MakerRatioAction.js +15 -0
- package/esm/src/actions/maker/MakerSupplyAction.d.ts +21 -0
- package/esm/src/actions/maker/MakerSupplyAction.js +37 -0
- package/esm/src/actions/maker/MakerWithdrawAction.d.ts +17 -0
- package/esm/src/actions/maker/MakerWithdrawAction.js +21 -0
- package/esm/src/actions/maker/index.d.ts +9 -0
- package/esm/src/actions/maker/index.js +9 -0
- package/esm/src/actions/mstable/MStableClaimAction.d.ts +16 -0
- package/esm/src/actions/mstable/MStableClaimAction.js +25 -0
- package/esm/src/actions/mstable/MStableDepositAction.d.ts +25 -0
- package/esm/src/actions/mstable/MStableDepositAction.js +75 -0
- package/esm/src/actions/mstable/MStableWithdrawAction.d.ts +25 -0
- package/esm/src/actions/mstable/MStableWithdrawAction.js +74 -0
- package/esm/src/actions/mstable/index.d.ts +3 -0
- package/esm/src/actions/mstable/index.js +3 -0
- package/esm/src/actions/rari/RariDepositAction.d.ts +22 -0
- package/esm/src/actions/rari/RariDepositAction.js +41 -0
- package/esm/src/actions/rari/RariWithdrawAction.d.ts +23 -0
- package/esm/src/actions/rari/RariWithdrawAction.js +43 -0
- package/esm/src/actions/rari/index.d.ts +2 -0
- package/esm/src/actions/rari/index.js +2 -0
- package/esm/src/actions/reflexer/ReflexerGenerateAction.d.ts +15 -0
- package/esm/src/actions/reflexer/ReflexerGenerateAction.js +19 -0
- package/esm/src/actions/reflexer/ReflexerNativeUniV2SaviourDepositAction.d.ts +19 -0
- package/esm/src/actions/reflexer/ReflexerNativeUniV2SaviourDepositAction.js +37 -0
- package/esm/src/actions/reflexer/ReflexerNativeUniV2SaviourGetReservesAction.d.ts +14 -0
- package/esm/src/actions/reflexer/ReflexerNativeUniV2SaviourGetReservesAction.js +21 -0
- package/esm/src/actions/reflexer/ReflexerNativeUniV2SaviourWithdrawAction.d.ts +15 -0
- package/esm/src/actions/reflexer/ReflexerNativeUniV2SaviourWithdrawAction.js +23 -0
- package/esm/src/actions/reflexer/ReflexerOpenSafeAction.d.ts +13 -0
- package/esm/src/actions/reflexer/ReflexerOpenSafeAction.js +15 -0
- package/esm/src/actions/reflexer/ReflexerPaybackAction.d.ts +19 -0
- package/esm/src/actions/reflexer/ReflexerPaybackAction.js +32 -0
- package/esm/src/actions/reflexer/ReflexerSupplyAction.d.ts +21 -0
- package/esm/src/actions/reflexer/ReflexerSupplyAction.js +44 -0
- package/esm/src/actions/reflexer/ReflexerWithdrawAction.d.ts +16 -0
- package/esm/src/actions/reflexer/ReflexerWithdrawAction.js +20 -0
- package/esm/src/actions/reflexer/index.d.ts +8 -0
- package/esm/src/actions/reflexer/index.js +8 -0
- package/esm/src/actions/uniswap/UniswapSupplyAction.d.ts +26 -0
- package/esm/src/actions/uniswap/UniswapSupplyAction.js +65 -0
- package/esm/src/actions/uniswap/UniswapWithdrawAction.d.ts +25 -0
- package/esm/src/actions/uniswap/UniswapWithdrawAction.js +56 -0
- package/esm/src/actions/uniswap/index.d.ts +2 -0
- package/esm/src/actions/uniswap/index.js +2 -0
- package/esm/src/actions/uniswapV3/UniswapV3CollectAction.d.ts +24 -0
- package/esm/src/actions/uniswapV3/UniswapV3CollectAction.js +47 -0
- package/esm/src/actions/uniswapV3/UniswapV3CreatePoolAction.d.ts +30 -0
- package/esm/src/actions/uniswapV3/UniswapV3CreatePoolAction.js +69 -0
- package/esm/src/actions/uniswapV3/UniswapV3MintAction.d.ts +29 -0
- package/esm/src/actions/uniswapV3/UniswapV3MintAction.js +67 -0
- package/esm/src/actions/uniswapV3/UniswapV3SupplyAction.d.ts +26 -0
- package/esm/src/actions/uniswapV3/UniswapV3SupplyAction.js +60 -0
- package/esm/src/actions/uniswapV3/UniswapV3WithdrawAction.d.ts +28 -0
- package/esm/src/actions/uniswapV3/UniswapV3WithdrawAction.js +58 -0
- package/esm/src/actions/uniswapV3/index.d.ts +5 -0
- package/esm/src/actions/uniswapV3/index.js +5 -0
- package/esm/src/actions/yearn/YearnSupplyAction.d.ts +21 -0
- package/esm/src/actions/yearn/YearnSupplyAction.js +43 -0
- package/esm/src/actions/yearn/YearnWithdrawAction.d.ts +21 -0
- package/esm/src/actions/yearn/YearnWithdrawAction.js +43 -0
- package/esm/src/actions/yearn/index.d.ts +2 -0
- package/esm/src/actions/yearn/index.js +2 -0
- package/esm/src/addresses.d.ts +410 -0
- package/esm/src/addresses.js +257 -0
- package/esm/src/config.d.ts +20 -0
- package/esm/src/config.js +69 -0
- package/esm/src/index.d.ts +1549 -0
- package/esm/src/index.js +22 -0
- package/esm/src/triggers/AaveV3RatioTrigger.d.ts +10 -0
- package/esm/src/triggers/AaveV3RatioTrigger.js +12 -0
- package/esm/src/triggers/ChainLinkPriceTrigger.d.ts +10 -0
- package/esm/src/triggers/ChainLinkPriceTrigger.js +12 -0
- package/esm/src/triggers/CompV3RatioTrigger.d.ts +10 -0
- package/esm/src/triggers/CompV3RatioTrigger.js +12 -0
- package/esm/src/triggers/CompoundRatioTrigger.d.ts +10 -0
- package/esm/src/triggers/CompoundRatioTrigger.js +12 -0
- package/esm/src/triggers/GasPriceTrigger.d.ts +10 -0
- package/esm/src/triggers/GasPriceTrigger.js +12 -0
- package/esm/src/triggers/LiquityRatioTrigger.d.ts +10 -0
- package/esm/src/triggers/LiquityRatioTrigger.js +12 -0
- package/esm/src/triggers/MakerRatioTrigger.d.ts +10 -0
- package/esm/src/triggers/MakerRatioTrigger.js +12 -0
- package/esm/src/triggers/ReflexerRatioTrigger.d.ts +10 -0
- package/esm/src/triggers/ReflexerRatioTrigger.js +12 -0
- package/esm/src/triggers/TimestampTrigger.d.ts +10 -0
- package/esm/src/triggers/TimestampTrigger.js +12 -0
- package/esm/src/triggers/TrailingStopTrigger.d.ts +10 -0
- package/esm/src/triggers/TrailingStopTrigger.js +12 -0
- package/esm/src/triggers/UniV3CurrentTickTrigger.d.ts +10 -0
- package/esm/src/triggers/UniV3CurrentTickTrigger.js +12 -0
- package/esm/src/triggers/index.d.ts +11 -0
- package/esm/src/triggers/index.js +11 -0
- package/esm/src/types.d.ts +43 -0
- package/esm/src/types.js +1 -0
- package/esm/src/utils/convex-utils.d.ts +42 -0
- package/esm/src/utils/convex-utils.js +16 -0
- package/esm/src/utils/convexPoolInfo.json +1039 -0
- package/esm/src/utils/curve-utils.d.ts +4 -0
- package/esm/src/utils/curve-utils.js +6 -0
- package/esm/src/utils/curvePoolInfo.json +203 -0
- package/esm/src/utils/general.d.ts +17 -0
- package/esm/src/utils/general.js +39 -0
- package/esm/src/utils/index.d.ts +5 -0
- package/esm/src/utils/index.js +5 -0
- package/esm/src/utils/mstableAssetPairs.d.ts +9 -0
- package/esm/src/utils/mstableAssetPairs.js +8 -0
- package/esm/src/utils/uniswapLP.d.ts +19 -0
- package/esm/src/utils/uniswapLP.js +33 -0
- package/esm/src/utils/zeroExExchange.d.ts +39 -0
- package/esm/src/utils/zeroExExchange.js +169 -0
- package/package.json +3 -3
- package/{index.ts → src/index.ts} +13 -13
- package/tsconfig.json +1 -2
- package/umd/index.js +8639 -0
- package/webpack.umd.js +1 -1
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
11
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
12
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
13
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
14
|
+
};
|
|
15
|
+
var _Action_instances, _Action__getArgumentMappingWithSlots, _Action__getPlaceholderForType;
|
|
16
|
+
import AbiCoder from 'web3-eth-abi';
|
|
17
|
+
import { keccak256, padLeft, toHex } from 'web3-utils';
|
|
18
|
+
import { CONFIG } from './config';
|
|
19
|
+
import ActionAbi from './abis/Action.json';
|
|
20
|
+
import { AccessLists } from '../AccessLists';
|
|
21
|
+
/**
|
|
22
|
+
* Single action that can be executed directly, or combined into a set (ie. supply a vault)
|
|
23
|
+
*
|
|
24
|
+
* @category Base Classes
|
|
25
|
+
*/
|
|
26
|
+
export class Action {
|
|
27
|
+
/**
|
|
28
|
+
* @param name
|
|
29
|
+
* @param contractAddress
|
|
30
|
+
* @param paramTypes
|
|
31
|
+
* @param args
|
|
32
|
+
*/
|
|
33
|
+
constructor(name, contractAddress, paramTypes, args) {
|
|
34
|
+
// if (new.target === Action) throw new TypeError("Actions are instantiated using derived classes");
|
|
35
|
+
_Action_instances.add(this);
|
|
36
|
+
if (paramTypes.length !== args.length)
|
|
37
|
+
throw new Error('Parameters/arguments length mismatch');
|
|
38
|
+
this.contractAddress = contractAddress;
|
|
39
|
+
this.paramTypes = paramTypes;
|
|
40
|
+
this.name = name;
|
|
41
|
+
this.args = args;
|
|
42
|
+
this.mappableArgs = args; // TODO change to class method
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
*
|
|
46
|
+
*/
|
|
47
|
+
getId() {
|
|
48
|
+
return keccak256(this.name).substr(0, 10);
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
*
|
|
52
|
+
*/
|
|
53
|
+
_getArgumentMapping() {
|
|
54
|
+
return this.mappableArgs.map(arg => {
|
|
55
|
+
if (new RegExp(/\$\d+/).test(arg)) {
|
|
56
|
+
if (Array.isArray(arg))
|
|
57
|
+
throw TypeError('Input can\'t be mapped to arrays (tuples/structs). Specify `mappableArgs` array in constructor.');
|
|
58
|
+
return parseInt(arg.substr(1));
|
|
59
|
+
}
|
|
60
|
+
return 0;
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
*
|
|
65
|
+
*/
|
|
66
|
+
_replaceWithPlaceholders(arg, paramType) {
|
|
67
|
+
if (Array.isArray(arg))
|
|
68
|
+
return arg.map((_arg, i) => this._replaceWithPlaceholders(_arg, paramType[i]));
|
|
69
|
+
if (typeof (paramType) === 'string') {
|
|
70
|
+
if (new RegExp(/\$\d+/).test(arg))
|
|
71
|
+
return __classPrivateFieldGet(this, _Action_instances, "m", _Action__getPlaceholderForType).call(this, paramType);
|
|
72
|
+
if (new RegExp(/&\w+/).test(arg))
|
|
73
|
+
return __classPrivateFieldGet(this, _Action_instances, "m", _Action__getPlaceholderForType).call(this, paramType);
|
|
74
|
+
}
|
|
75
|
+
return arg;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
*
|
|
79
|
+
*/
|
|
80
|
+
_formatType(paramType) {
|
|
81
|
+
if (Array.isArray(paramType))
|
|
82
|
+
return `(${paramType.map((_paramType) => this._formatType(_paramType))})`;
|
|
83
|
+
return paramType;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Encode arguments for calling the action directly
|
|
87
|
+
* @returns bytes-encoded args
|
|
88
|
+
*
|
|
89
|
+
*/
|
|
90
|
+
_encodeForCall() {
|
|
91
|
+
const _arg = this._replaceWithPlaceholders(this.args, this.paramTypes);
|
|
92
|
+
const _paramType = this._formatType(this.paramTypes);
|
|
93
|
+
return [AbiCoder.encodeParameter(_paramType, _arg)];
|
|
94
|
+
}
|
|
95
|
+
encodeForL2DsProxyCall() {
|
|
96
|
+
return this._encodeForCall()[0];
|
|
97
|
+
}
|
|
98
|
+
encodeForL2Recipe() {
|
|
99
|
+
return this._encodeForCall()[0];
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Encode arguments for calling the action via DsProxy
|
|
103
|
+
* @returns `address` & `data` to be passed on to DSProxy's `execute(address _target, bytes memory _data)`
|
|
104
|
+
*/
|
|
105
|
+
encodeForDsProxyCall() {
|
|
106
|
+
if (CONFIG.chainId === 1) {
|
|
107
|
+
const executeActionDirectAbi = (ActionAbi.find(({ name }) => name === 'executeActionDirect'));
|
|
108
|
+
return [
|
|
109
|
+
this.contractAddress,
|
|
110
|
+
AbiCoder.encodeFunctionCall(executeActionDirectAbi, this._encodeForCall()),
|
|
111
|
+
];
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
return [this.contractAddress, this.encodeForL2DsProxyCall()];
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Encodes action for Recipe call
|
|
119
|
+
*/
|
|
120
|
+
encodeForRecipe() {
|
|
121
|
+
return [
|
|
122
|
+
this._encodeForCall()[0],
|
|
123
|
+
"0x0000000000000000000000000000000000000000000000000000000000000000",
|
|
124
|
+
this.getId(),
|
|
125
|
+
this._getArgumentMapping(), // paramMappings
|
|
126
|
+
];
|
|
127
|
+
}
|
|
128
|
+
encodeForStrategy(subSlots) {
|
|
129
|
+
return [
|
|
130
|
+
this.getId(),
|
|
131
|
+
__classPrivateFieldGet(this, _Action_instances, "m", _Action__getArgumentMappingWithSlots).call(this, subSlots), // paramMappings
|
|
132
|
+
];
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Assets requiring approval to be used by DsProxy
|
|
136
|
+
* Approval is done from owner to DsProxy
|
|
137
|
+
*/
|
|
138
|
+
getAssetsToApprove() {
|
|
139
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
140
|
+
return [];
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* ETH value to be sent with transaction
|
|
145
|
+
* @returns ETH value in wei
|
|
146
|
+
*/
|
|
147
|
+
getEthValue() {
|
|
148
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
149
|
+
return '0';
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Access list for single action
|
|
154
|
+
*/
|
|
155
|
+
getAccessList(chainId) {
|
|
156
|
+
if (chainId != 1)
|
|
157
|
+
return [];
|
|
158
|
+
return [
|
|
159
|
+
[this.contractAddress, []],
|
|
160
|
+
...(AccessLists[this.name] || []),
|
|
161
|
+
].map(([address, storageKeys]) => ({
|
|
162
|
+
address: address,
|
|
163
|
+
storageKeys: storageKeys.map((num) => padLeft(toHex(num), 64)),
|
|
164
|
+
}));
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
_Action_instances = new WeakSet(), _Action__getArgumentMappingWithSlots = function _Action__getArgumentMappingWithSlots(subSlots) {
|
|
168
|
+
return this.mappableArgs.map(arg => {
|
|
169
|
+
if (new RegExp(/\$\d+/).test(arg)) {
|
|
170
|
+
if (Array.isArray(arg))
|
|
171
|
+
throw TypeError('Input can\'t be mapped to arrays (tuples/structs). Specify `mappableArgs` array in constructor.');
|
|
172
|
+
return parseInt(arg.substr(1));
|
|
173
|
+
}
|
|
174
|
+
// Handle SubSlots placeholder values in strategies
|
|
175
|
+
if (new RegExp(/&\w+/).test(arg)) {
|
|
176
|
+
if (arg === '&proxy')
|
|
177
|
+
return 254;
|
|
178
|
+
if (arg === '&eoa')
|
|
179
|
+
return 255;
|
|
180
|
+
return parseInt(subSlots[arg].index);
|
|
181
|
+
}
|
|
182
|
+
return 0;
|
|
183
|
+
});
|
|
184
|
+
}, _Action__getPlaceholderForType = function _Action__getPlaceholderForType(type) {
|
|
185
|
+
// TODO handle arrays?
|
|
186
|
+
if (type.startsWith('bytes'))
|
|
187
|
+
return `0x${'0'.repeat(parseInt(type.substr(5)))}`;
|
|
188
|
+
if (type === 'address')
|
|
189
|
+
return `0x${'0'.repeat(40)}`;
|
|
190
|
+
if (type === 'string')
|
|
191
|
+
return '';
|
|
192
|
+
return '0';
|
|
193
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Action } from './Action';
|
|
2
|
+
/**
|
|
3
|
+
* Single L2 action that can be executed directly, or combined into a set (ie. supply a vault)
|
|
4
|
+
*
|
|
5
|
+
* @category Base Classes
|
|
6
|
+
*/
|
|
7
|
+
export declare class ActionWithL2 extends Action {
|
|
8
|
+
/**
|
|
9
|
+
* Encode arguments for calling the action via DsProxy
|
|
10
|
+
*/
|
|
11
|
+
encodeForL2DsProxyCall(): string;
|
|
12
|
+
encodeForL2Recipe(): string;
|
|
13
|
+
encodeInputs(): string;
|
|
14
|
+
addressToBytes20(address: string): string;
|
|
15
|
+
boolToBytes1(bool: boolean): "01" | "00";
|
|
16
|
+
getEthValue(): Promise<string>;
|
|
17
|
+
numberToBytes2(number: number): string;
|
|
18
|
+
numberToBytes1(number: number): string;
|
|
19
|
+
numberToBytes32(number: number): string;
|
|
20
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { Action } from './Action';
|
|
11
|
+
import Dec from 'decimal.js';
|
|
12
|
+
import AbiCoder from 'web3-eth-abi';
|
|
13
|
+
import ActionAbi from './abis/Action.json';
|
|
14
|
+
/**
|
|
15
|
+
* Single L2 action that can be executed directly, or combined into a set (ie. supply a vault)
|
|
16
|
+
*
|
|
17
|
+
* @category Base Classes
|
|
18
|
+
*/
|
|
19
|
+
export class ActionWithL2 extends Action {
|
|
20
|
+
/**
|
|
21
|
+
* Encode arguments for calling the action via DsProxy
|
|
22
|
+
*/
|
|
23
|
+
encodeForL2DsProxyCall() { return this.encodeInputs(); }
|
|
24
|
+
encodeForL2Recipe() { return `0x${this.encodeInputs().slice(10)}`; } // cut the method id
|
|
25
|
+
encodeInputs() {
|
|
26
|
+
const _arg = this._replaceWithPlaceholders(this.args, this.paramTypes);
|
|
27
|
+
const _paramType = this._formatType(this.paramTypes);
|
|
28
|
+
const executeActionDirectAbi = ActionAbi.find(({ name }) => name === 'executeActionDirect');
|
|
29
|
+
return AbiCoder.encodeFunctionCall(executeActionDirectAbi, [AbiCoder.encodeParameter(_paramType, _arg)]);
|
|
30
|
+
}
|
|
31
|
+
addressToBytes20(address) { return address.slice(2); }
|
|
32
|
+
boolToBytes1(bool) { return bool ? '01' : '00'; }
|
|
33
|
+
getEthValue() {
|
|
34
|
+
return __awaiter(this, void 0, void 0, function* () { return '0'; });
|
|
35
|
+
}
|
|
36
|
+
numberToBytes2(number) {
|
|
37
|
+
const hexNumber = number.toString(16);
|
|
38
|
+
return hexNumber.padStart(4, '0');
|
|
39
|
+
}
|
|
40
|
+
numberToBytes1(number) {
|
|
41
|
+
const hexNumber = number.toString(16);
|
|
42
|
+
return hexNumber.padStart(2, '0');
|
|
43
|
+
}
|
|
44
|
+
numberToBytes32(number) {
|
|
45
|
+
let hexNumber = new Dec(number).toHex();
|
|
46
|
+
hexNumber = hexNumber.slice(2);
|
|
47
|
+
return hexNumber.padStart(64, '0');
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Action } from "./Action";
|
|
2
|
+
import { Recipe } from "./Recipe";
|
|
3
|
+
import { EthAddress } from './types';
|
|
4
|
+
import Web3 from 'web3';
|
|
5
|
+
/**
|
|
6
|
+
*
|
|
7
|
+
* @category Base Classes
|
|
8
|
+
*/
|
|
9
|
+
export declare class DfsWeb3 {
|
|
10
|
+
web3: Web3;
|
|
11
|
+
accountReady: boolean;
|
|
12
|
+
account?: EthAddress;
|
|
13
|
+
proxy?: EthAddress;
|
|
14
|
+
constructor(web3: Web3);
|
|
15
|
+
onAccountsChanged(_arg0: string, _onAccountsChanged: any): void;
|
|
16
|
+
prepareAccount(): Promise<void>;
|
|
17
|
+
createSmartWallet(): Promise<any>;
|
|
18
|
+
/**
|
|
19
|
+
* @param action
|
|
20
|
+
*/
|
|
21
|
+
prepareBeforeExecute(action: Action): Promise<any>;
|
|
22
|
+
execute(address: EthAddress, params: Array<any>): Promise<any>;
|
|
23
|
+
/**
|
|
24
|
+
* @param action
|
|
25
|
+
*/
|
|
26
|
+
executeAction(action: Action): Promise<Action>;
|
|
27
|
+
/**
|
|
28
|
+
* @param recipe
|
|
29
|
+
*/
|
|
30
|
+
executeRecipe(recipe: Recipe): Promise<Recipe>;
|
|
31
|
+
}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import DFSPRoxyRegistyAbi from './abis/DFSProxyRegistry.json';
|
|
11
|
+
import ProxyRegistryAbi from './abis/ProxyRegistry.json';
|
|
12
|
+
import DsProxyAbi from './abis/DsProxy.json';
|
|
13
|
+
import Erc20Abi from './abis/Erc20.json';
|
|
14
|
+
import { getAddr } from './addresses';
|
|
15
|
+
import { CONFIG } from './config';
|
|
16
|
+
/**
|
|
17
|
+
*
|
|
18
|
+
* @category Base Classes
|
|
19
|
+
*/
|
|
20
|
+
export class DfsWeb3 {
|
|
21
|
+
constructor(web3) {
|
|
22
|
+
// const networkId = await web3.eth.net.getId();
|
|
23
|
+
// if (networkId !== 1) throw new Error('Supplied web3 is not on Mainnet');
|
|
24
|
+
this.web3 = web3;
|
|
25
|
+
this.accountReady = false;
|
|
26
|
+
this.prepareAccount();
|
|
27
|
+
/* if (this.web3.currentProvider!.on) {
|
|
28
|
+
this.web3.currentProvider!.on('accountsChanged', this.onAccountsChanged);
|
|
29
|
+
} */
|
|
30
|
+
}
|
|
31
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
32
|
+
onAccountsChanged(_arg0, _onAccountsChanged) {
|
|
33
|
+
throw new Error('Method not implemented.');
|
|
34
|
+
}
|
|
35
|
+
prepareAccount() {
|
|
36
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
37
|
+
const accounts = yield this.web3.eth.getAccounts();
|
|
38
|
+
if (!accounts || !accounts.length)
|
|
39
|
+
throw new Error('Supplied web3 has no account');
|
|
40
|
+
this.account = accounts[0];
|
|
41
|
+
const DFSPRoxyRegistyAbiItems = DFSPRoxyRegistyAbi.map(item => {
|
|
42
|
+
return Object.assign(Object.assign({}, item), { stateMutability: item.stateMutability, type: item.type });
|
|
43
|
+
});
|
|
44
|
+
const dfsRegistry = new this.web3.eth.Contract(DFSPRoxyRegistyAbiItems, getAddr('DFSProxyRegistry', CONFIG.chainId));
|
|
45
|
+
const proxies = yield dfsRegistry.methods.getAllProxies(this.account).call();
|
|
46
|
+
if (proxies[0] !== '0x0000000000000000000000000000000000000000') {
|
|
47
|
+
this.proxy = proxies[0];
|
|
48
|
+
}
|
|
49
|
+
this.accountReady = true;
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
createSmartWallet() {
|
|
53
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
54
|
+
if (!this.accountReady)
|
|
55
|
+
yield this.prepareAccount();
|
|
56
|
+
if (!this.account)
|
|
57
|
+
throw new Error('DfsWeb3 has not been instantiated properly');
|
|
58
|
+
if (this.proxy)
|
|
59
|
+
throw new Error('Account already has DsProxy');
|
|
60
|
+
const ProxyRegistryAbiItems = ProxyRegistryAbi.map(item => {
|
|
61
|
+
return Object.assign(Object.assign({}, item), { stateMutability: item.stateMutability, type: item.type });
|
|
62
|
+
});
|
|
63
|
+
const makerRegistry = new this.web3.eth.Contract(ProxyRegistryAbiItems, getAddr('ProxyRegistry', CONFIG.chainId));
|
|
64
|
+
return makerRegistry.methods.build();
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* @param action
|
|
69
|
+
*/
|
|
70
|
+
prepareBeforeExecute(action) {
|
|
71
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
72
|
+
if (!this.accountReady)
|
|
73
|
+
yield this.prepareAccount();
|
|
74
|
+
if (!this.proxy)
|
|
75
|
+
throw new Error('Account does not have a Smart Wallet');
|
|
76
|
+
const transactions = [];
|
|
77
|
+
const approvals = yield action.getAssetsToApprove();
|
|
78
|
+
yield Promise.all(approvals.map((a) => __awaiter(this, void 0, void 0, function* () {
|
|
79
|
+
if (a.owner.toLowerCase() === this.proxy.toLowerCase()) {
|
|
80
|
+
const Erc20AbiItems = Erc20Abi.map(item => {
|
|
81
|
+
return Object.assign(Object.assign({}, item), { stateMutability: item.stateMutability, type: item.type });
|
|
82
|
+
});
|
|
83
|
+
const tokenContract = new this.web3.eth.Contract(Erc20AbiItems, a.asset);
|
|
84
|
+
const allowance = yield tokenContract.methods.allowance(this.account, this.proxy).call();
|
|
85
|
+
if (parseFloat(allowance.toString()) === 0) {
|
|
86
|
+
transactions.push(tokenContract.methods.approve(this.proxy, '-1'));
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
})));
|
|
90
|
+
return transactions;
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
execute(address, params) {
|
|
94
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
95
|
+
if (!this.accountReady)
|
|
96
|
+
yield this.prepareAccount();
|
|
97
|
+
if (!this.proxy)
|
|
98
|
+
throw new Error('Account does not have a Smart Wallet. Run createSmartWallet first');
|
|
99
|
+
const DsProxyAbiItems = DsProxyAbi.map(item => {
|
|
100
|
+
return Object.assign(Object.assign({}, item), { stateMutability: item.stateMutability, type: item.type });
|
|
101
|
+
});
|
|
102
|
+
const proxyContract = new this.web3.eth.Contract(DsProxyAbiItems, this.proxy);
|
|
103
|
+
return proxyContract.methods['execute(address,bytes)'](address, params);
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* @param action
|
|
108
|
+
*/
|
|
109
|
+
executeAction(action) {
|
|
110
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
111
|
+
const encoded = action.encodeForDsProxyCall();
|
|
112
|
+
return this.execute(encoded[0], encoded[1]);
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* @param recipe
|
|
117
|
+
*/
|
|
118
|
+
executeRecipe(recipe) {
|
|
119
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
120
|
+
const encoded = recipe.encodeForDsProxyCall();
|
|
121
|
+
return this.execute(encoded[0], encoded[1]);
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { Action } from './Action';
|
|
2
|
+
import { AccessListItem } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Set of Actions to be performed sequentially in a single transaction
|
|
5
|
+
*
|
|
6
|
+
* @category Base Classes
|
|
7
|
+
*/
|
|
8
|
+
export declare class Recipe {
|
|
9
|
+
#private;
|
|
10
|
+
name: string;
|
|
11
|
+
actions: Array<Action>;
|
|
12
|
+
recipeExecutorAddress: string;
|
|
13
|
+
extraGas: number;
|
|
14
|
+
/**
|
|
15
|
+
* @param name
|
|
16
|
+
* @param actions
|
|
17
|
+
*/
|
|
18
|
+
constructor(name: string, actions?: Array<Action>);
|
|
19
|
+
/**
|
|
20
|
+
* @param action
|
|
21
|
+
*/
|
|
22
|
+
addAction(action: Action): Recipe;
|
|
23
|
+
/**
|
|
24
|
+
* Encode arguments for calling the action set via DsProxy
|
|
25
|
+
* @returns `address` & `data` to be passed on to DSProxy's `execute(address _target, bytes memory _data)`
|
|
26
|
+
*/
|
|
27
|
+
encodeForDsProxyCall(): Array<string>;
|
|
28
|
+
/**
|
|
29
|
+
* Logs parameter mapping in verbose format for validation. Used for testing in development.
|
|
30
|
+
*/
|
|
31
|
+
_validateParamMappings(): void;
|
|
32
|
+
/**
|
|
33
|
+
* Assets requiring approval to be used by DsProxy
|
|
34
|
+
* Approval is done from owner to DsProxy
|
|
35
|
+
*/
|
|
36
|
+
getAssetsToApprove(): Promise<Array<{
|
|
37
|
+
owner: string;
|
|
38
|
+
asset: string;
|
|
39
|
+
}>>;
|
|
40
|
+
/**
|
|
41
|
+
* ETH value to be sent with transaction
|
|
42
|
+
* @returns ETH value in wei
|
|
43
|
+
*/
|
|
44
|
+
getEthValue(): Promise<string>;
|
|
45
|
+
/**
|
|
46
|
+
* Generates an access list for the recipe
|
|
47
|
+
*/
|
|
48
|
+
getAccessList(): Array<AccessListItem>;
|
|
49
|
+
}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
11
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
12
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
13
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
14
|
+
};
|
|
15
|
+
var _Recipe_instances, _Recipe__encodeForCall;
|
|
16
|
+
import AbiCoder from 'web3-eth-abi';
|
|
17
|
+
import { toBN } from 'web3-utils';
|
|
18
|
+
import { getAssetInfo, utils } from "@defisaver/tokens";
|
|
19
|
+
import { Action } from './Action';
|
|
20
|
+
import { getAddr } from './addresses';
|
|
21
|
+
import RecipeAbi from './abis/Recipe.json';
|
|
22
|
+
import { CONFIG } from './config';
|
|
23
|
+
/**
|
|
24
|
+
* Set of Actions to be performed sequentially in a single transaction
|
|
25
|
+
*
|
|
26
|
+
* @category Base Classes
|
|
27
|
+
*/
|
|
28
|
+
export class Recipe {
|
|
29
|
+
/**
|
|
30
|
+
* @param name
|
|
31
|
+
* @param actions
|
|
32
|
+
*/
|
|
33
|
+
constructor(name, actions = []) {
|
|
34
|
+
_Recipe_instances.add(this);
|
|
35
|
+
actions.forEach((action) => {
|
|
36
|
+
if (!(action instanceof Action))
|
|
37
|
+
throw new TypeError('Supplied action does not inherit Action');
|
|
38
|
+
});
|
|
39
|
+
this.name = name;
|
|
40
|
+
this.actions = actions;
|
|
41
|
+
this.extraGas = 0;
|
|
42
|
+
this.recipeExecutorAddress = getAddr('RecipeExecutor', CONFIG.chainId);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* @param action
|
|
46
|
+
*/
|
|
47
|
+
addAction(action) {
|
|
48
|
+
if (!(action instanceof Action))
|
|
49
|
+
throw new TypeError('Supplied action does not inherit Action');
|
|
50
|
+
this.actions.push(action);
|
|
51
|
+
return this;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Encode arguments for calling the action set via DsProxy
|
|
55
|
+
* @returns `address` & `data` to be passed on to DSProxy's `execute(address _target, bytes memory _data)`
|
|
56
|
+
*/
|
|
57
|
+
encodeForDsProxyCall() {
|
|
58
|
+
const executeTaskAbi = RecipeAbi.find(({ name }) => name === 'executeRecipe');
|
|
59
|
+
const encoded = __classPrivateFieldGet(this, _Recipe_instances, "m", _Recipe__encodeForCall).call(this);
|
|
60
|
+
return [
|
|
61
|
+
this.recipeExecutorAddress,
|
|
62
|
+
// @ts-expect-error Interface of AbiCoder is wrong :(
|
|
63
|
+
AbiCoder.encodeFunctionCall(executeTaskAbi, encoded),
|
|
64
|
+
];
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Logs parameter mapping in verbose format for validation. Used for testing in development.
|
|
68
|
+
*/
|
|
69
|
+
_validateParamMappings() {
|
|
70
|
+
this.actions.forEach((action, i) => {
|
|
71
|
+
action._getArgumentMapping().forEach((source, j) => {
|
|
72
|
+
if (source)
|
|
73
|
+
console.log(`${this.actions[i].name} takes argument #${j + 1} from ${this.actions[source - 1].name} (action #${source})`);
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Assets requiring approval to be used by DsProxy
|
|
79
|
+
* Approval is done from owner to DsProxy
|
|
80
|
+
*/
|
|
81
|
+
getAssetsToApprove() {
|
|
82
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
83
|
+
const uniqueAssetOwnerPairs = [];
|
|
84
|
+
const assetOwnerPairs = yield Promise.all(this.actions.map(a => a.getAssetsToApprove()));
|
|
85
|
+
for (const pairsPerAction of assetOwnerPairs) {
|
|
86
|
+
for (const pair of pairsPerAction) {
|
|
87
|
+
const isNft = !pair.asset;
|
|
88
|
+
if (!uniqueAssetOwnerPairs.find(_pair => _pair.owner === pair.owner && (isNft ? _pair.tokenId === pair.tokenId : _pair.asset === pair.asset))) {
|
|
89
|
+
uniqueAssetOwnerPairs.push({ owner: pair.owner, asset: pair.asset });
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
return uniqueAssetOwnerPairs.filter(({ address }) => !utils.compare(address, getAssetInfo('ETH').address));
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* ETH value to be sent with transaction
|
|
98
|
+
* @returns ETH value in wei
|
|
99
|
+
*/
|
|
100
|
+
getEthValue() {
|
|
101
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
102
|
+
return (yield Promise.all(this.actions.map(a => a.getEthValue())))
|
|
103
|
+
.reduce((acc, val) => acc.add(toBN(val)), toBN(0))
|
|
104
|
+
.toString();
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Generates an access list for the recipe
|
|
109
|
+
*/
|
|
110
|
+
getAccessList() {
|
|
111
|
+
const addressMapping = {
|
|
112
|
+
[getAddr('RecipeExecutor', CONFIG.chainId)]: [],
|
|
113
|
+
[getAddr('DFSRegistry', CONFIG.chainId)]: [],
|
|
114
|
+
};
|
|
115
|
+
this.actions.forEach((action) => {
|
|
116
|
+
const accessList = action.getAccessList(CONFIG.chainId);
|
|
117
|
+
accessList.forEach(({ address, storageKeys }) => {
|
|
118
|
+
addressMapping[address] = new Set([...storageKeys, ...(addressMapping[address] || [])]);
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
return Object.keys(addressMapping).map((address) => ({
|
|
122
|
+
address,
|
|
123
|
+
storageKeys: [...addressMapping[address]],
|
|
124
|
+
}));
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
_Recipe_instances = new WeakSet(), _Recipe__encodeForCall = function _Recipe__encodeForCall() {
|
|
128
|
+
const encoded = this.actions.map(action => action.encodeForRecipe());
|
|
129
|
+
const transposed = encoded[0].map((_, colIndex) => encoded.map(row => row[colIndex]));
|
|
130
|
+
const taskStruct = [
|
|
131
|
+
this.name,
|
|
132
|
+
...transposed,
|
|
133
|
+
];
|
|
134
|
+
return [taskStruct];
|
|
135
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Action } from './Action';
|
|
2
|
+
/**
|
|
3
|
+
*
|
|
4
|
+
* @category Base Classes
|
|
5
|
+
*/
|
|
6
|
+
export declare class Strategy {
|
|
7
|
+
name: string;
|
|
8
|
+
subSlots: any;
|
|
9
|
+
actions: Array<Action>;
|
|
10
|
+
triggers: Array<Action>;
|
|
11
|
+
numSubSlots: number;
|
|
12
|
+
constructor(name: string);
|
|
13
|
+
addSubSlot(name: string, type: string): void;
|
|
14
|
+
addTrigger(newTrigger: Action): void;
|
|
15
|
+
addAction(newAction: Action): void;
|
|
16
|
+
print(): void;
|
|
17
|
+
getSubSlots(): any;
|
|
18
|
+
encodeForDsProxyCall(): (string | string[] | number[][])[];
|
|
19
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* @category Base Classes
|
|
4
|
+
*/
|
|
5
|
+
export class Strategy {
|
|
6
|
+
constructor(name) {
|
|
7
|
+
this.name = name;
|
|
8
|
+
this.subSlots = {};
|
|
9
|
+
this.actions = [];
|
|
10
|
+
this.triggers = [];
|
|
11
|
+
this.numSubSlots = 0;
|
|
12
|
+
}
|
|
13
|
+
addSubSlot(name, type) {
|
|
14
|
+
this.subSlots[name] = { type, index: this.numSubSlots + 128 };
|
|
15
|
+
this.numSubSlots++;
|
|
16
|
+
}
|
|
17
|
+
addTrigger(newTrigger) {
|
|
18
|
+
this.triggers.push(newTrigger);
|
|
19
|
+
}
|
|
20
|
+
addAction(newAction) {
|
|
21
|
+
this.actions.push(newAction);
|
|
22
|
+
}
|
|
23
|
+
print() {
|
|
24
|
+
console.log(`Name: ${this.name}`);
|
|
25
|
+
console.log(`Slots: ${this.subSlots}`);
|
|
26
|
+
console.log(`Action: ${this.actions[0]}`);
|
|
27
|
+
}
|
|
28
|
+
getSubSlots() {
|
|
29
|
+
return this.subSlots;
|
|
30
|
+
}
|
|
31
|
+
encodeForDsProxyCall() {
|
|
32
|
+
const triggerIds = this.triggers.map((trigger) => trigger.getId());
|
|
33
|
+
const paramMappings = [];
|
|
34
|
+
const actionIds = [];
|
|
35
|
+
this.actions.forEach(action => {
|
|
36
|
+
const actionEncoded = action.encodeForStrategy(this.subSlots);
|
|
37
|
+
actionIds.push(actionEncoded[0]);
|
|
38
|
+
paramMappings.push(actionEncoded[1]);
|
|
39
|
+
});
|
|
40
|
+
return [
|
|
41
|
+
this.name,
|
|
42
|
+
triggerIds,
|
|
43
|
+
actionIds,
|
|
44
|
+
paramMappings
|
|
45
|
+
];
|
|
46
|
+
}
|
|
47
|
+
}
|