@defisaver/sdk 0.1.23 → 0.1.24
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/ACTIONS.md +20 -311
- package/AccessLists/DyDxAccessLists.js +0 -4
- package/AccessLists/InstaAccessLists.js +0 -8
- package/AccessLists/UtilsAccessLists.js +0 -5
- package/DEV.md +0 -7
- package/index.js +15 -2
- package/package.json +1 -1
- package/src/Action.js +52 -12
- package/src/L2Action.js +44 -0
- package/src/Recipe.js +5 -4
- package/src/Strategy.js +63 -0
- package/src/abis/Action.json +157 -11
- package/src/abis/Recipe.json +92 -47
- package/src/actions/aave/AaveBorrowAction.js +11 -2
- package/src/actions/aave/AavePaybackAction.js +11 -2
- package/src/actions/aave/AaveSupplyAction.js +9 -1
- package/src/actions/aave/AaveWithdrawAction.js +8 -1
- package/src/actions/aaveV3/AaveV3ATokenPaybackAction.js +53 -0
- package/src/actions/aaveV3/AaveV3BorrowAction.js +54 -0
- package/src/actions/aaveV3/AaveV3CollateralSwitchAction.js +41 -0
- package/src/actions/aaveV3/AaveV3PaybackAction.js +63 -0
- package/src/actions/aaveV3/AaveV3SetEModeAction.js +35 -0
- package/src/actions/aaveV3/AaveV3SupplyAction.js +64 -0
- package/src/actions/aaveV3/AaveV3WithdrawAction.js +41 -0
- package/src/actions/aaveV3/index.js +17 -0
- package/src/actions/basic/GasFeeAction.js +27 -0
- package/src/actions/basic/PullTokenAction.js +9 -3
- package/src/actions/basic/SellAction.js +6 -5
- package/src/actions/basic/SendTokenAction.js +9 -3
- package/src/actions/basic/SumInputsAction.js +8 -3
- package/src/actions/basic/UnwrapEthAction.js +8 -3
- package/src/actions/basic/WrapEthAction.js +5 -1
- package/src/actions/basic/index.js +2 -2
- package/src/actions/checkers/MakerRatioCheckAction.js +29 -0
- package/src/actions/checkers/index.js +5 -0
- package/src/actions/compound/CompoundBorrowAction.js +7 -1
- package/src/actions/compound/CompoundClaimAction.js +6 -1
- package/src/actions/compound/CompoundPaybackAction.js +7 -1
- package/src/actions/compound/CompoundSupplyAction.js +7 -1
- package/src/actions/compound/CompoundWithdrawAction.js +7 -1
- package/src/actions/curve/CurveStethPoolDepositAction.js +2 -2
- package/src/actions/curve/CurveStethPoolWithdrawAction.js +3 -5
- package/src/actions/dydx/DyDxWithdrawAction.js +7 -1
- package/src/actions/dydx/index.js +0 -2
- package/src/actions/flashloan/AaveV2FlashLoanAction.js +2 -2
- package/src/actions/flashloan/BalancerFlashLoanAction.js +2 -2
- package/src/actions/flashloan/DyDxFlashLoanAction.js +1 -1
- package/src/actions/flashloan/MakerFlashLoanAction.js +2 -2
- package/src/actions/index.js +4 -0
- package/src/actions/insta/index.js +0 -2
- package/src/actions/liquity/LiquityClaimAction.js +6 -2
- package/src/actions/liquity/LiquityCloseAction.js +7 -2
- package/src/actions/maker/MakerGenerateAction.js +8 -1
- package/src/actions/maker/MakerGiveAction.js +7 -1
- package/src/actions/maker/MakerMergeAction.js +7 -1
- package/src/actions/maker/MakerOpenVaultAction.js +6 -1
- package/src/actions/maker/MakerPaybackAction.js +1 -0
- package/src/actions/maker/MakerRatioAction.js +20 -0
- package/src/actions/maker/MakerSupplyAction.js +9 -1
- package/src/actions/maker/MakerWithdrawAction.js +10 -2
- package/src/actions/maker/index.js +2 -0
- package/src/actions/mstable/MStableDepositAction.js +2 -2
- package/src/actions/mstable/MStableWithdrawAction.js +2 -2
- package/src/actions/reflexer/ReflexerGenerateAction.js +7 -1
- package/src/actions/reflexer/ReflexerOpenSafeAction.js +5 -1
- package/src/actions/reflexer/ReflexerPaybackAction.js +7 -1
- package/src/actions/reflexer/ReflexerSupplyAction.js +8 -1
- package/src/actions/reflexer/ReflexerWithdrawAction.js +8 -1
- package/src/addresses.js +179 -143
- package/src/config.js +74 -0
- package/src/triggers/ChainLinkPriceTrigger.js +12 -0
- package/src/triggers/CompoundRatioTrigger.js +11 -0
- package/src/triggers/GasPriceTrigger.js +11 -0
- package/src/triggers/LiquityRatioTrigger.js +16 -0
- package/src/triggers/MakerRatioTrigger.js +15 -0
- package/src/triggers/ReflexerRatioTrigger.js +11 -0
- package/src/triggers/TimestampTrigger.js +11 -0
- package/src/triggers/UniV3CurrentTickTrigger.js +12 -0
- package/src/triggers/index.js +19 -0
- package/src/types.js +33 -0
- package/src/utils/general.js +2 -0
- package/src/utils/zeroExExchange.js +2 -40
- package/test/accessLists/MockAccessLists.json +0 -72
- package/test/accessLists/Recipe.js +3 -3
- package/test/actions/insta/InstPullTokensAction.js +2 -2
- package/test/index.js +4 -1
- package/test/utils/zeroExExchange.js +0 -8
- package/src/actions/basic/BuyAction.js +0 -53
- package/src/actions/dydx/DyDxSupplyAction.js +0 -25
- package/src/actions/insta/ClaimInstMakerAction.js +0 -21
- package/test/actions/basic/BuyAction.js +0 -100
- package/test/actions/dydx/DyDxSupplyAction.js +0 -78
- package/test/actions/insta/ClaimInstMakerAction.js +0 -46
package/ACTIONS.md
CHANGED
|
@@ -10,6 +10,9 @@
|
|
|
10
10
|
<dt><a href="#AaveCollateralSwitchAction">AaveCollateralSwitchAction</a></dt>
|
|
11
11
|
<dd><p>AaveCollateralSwitchAction - Aave enable/disable token usage as collateral</p>
|
|
12
12
|
</dd>
|
|
13
|
+
<dt><a href="#AaveMigrateLendAction">AaveMigrateLendAction</a></dt>
|
|
14
|
+
<dd><p>AaveMigrateLendAction - Migrates Lend to Aave</p>
|
|
15
|
+
</dd>
|
|
13
16
|
<dt><a href="#AavePaybackAction">AavePaybackAction</a></dt>
|
|
14
17
|
<dd><p>AavePaybackAction - Payback borrowed tokens from Aave</p>
|
|
15
18
|
</dd>
|
|
@@ -26,9 +29,6 @@
|
|
|
26
29
|
<dt><a href="#BalancerV2WithdrawAction">BalancerV2WithdrawAction</a></dt>
|
|
27
30
|
<dd><p>BalancerV2WithdrawAction - Withdraw tokens from Balancer pool</p>
|
|
28
31
|
</dd>
|
|
29
|
-
<dt><a href="#BuyAction">BuyAction</a></dt>
|
|
30
|
-
<dd><p>Buys an exact amount of dest token on DeFi Saver exchange aggregator</p>
|
|
31
|
-
</dd>
|
|
32
32
|
<dt><a href="#ChangeProxyOwnerAction">ChangeProxyOwnerAction</a></dt>
|
|
33
33
|
<dd><p>ChangeProxyOwnerAction - Changes EOA which owns the proxy that is being called</p>
|
|
34
34
|
</dd>
|
|
@@ -71,29 +71,6 @@
|
|
|
71
71
|
<dt><a href="#CompoundWithdrawAction">CompoundWithdrawAction</a></dt>
|
|
72
72
|
<dd><p>CompoundWithdrawAction - Withdraw token from an Compound position</p>
|
|
73
73
|
</dd>
|
|
74
|
-
<dt><a href="#CurveClaimFeesAction">CurveClaimFeesAction</a></dt>
|
|
75
|
-
<dd></dd>
|
|
76
|
-
<dt><a href="#CurveDepositAction">CurveDepositAction</a></dt>
|
|
77
|
-
<dd></dd>
|
|
78
|
-
<dt><a href="#CurveGaugeDepositAction">CurveGaugeDepositAction</a></dt>
|
|
79
|
-
<dd></dd>
|
|
80
|
-
<dt><a href="#CurveGaugeWithdrawAction">CurveGaugeWithdrawAction</a></dt>
|
|
81
|
-
<dd></dd>
|
|
82
|
-
<dt><a href="#CurveMintCrvAction">CurveMintCrvAction</a></dt>
|
|
83
|
-
<dd></dd>
|
|
84
|
-
<dt><a href="#CurveStethPoolDepositAction">CurveStethPoolDepositAction</a></dt>
|
|
85
|
-
<dd><p>CurveStethPoolDepositAction - Deposits tokens into curve steth pool</p>
|
|
86
|
-
</dd>
|
|
87
|
-
<dt><a href="#CurveStethPoolWithdrawAction">CurveStethPoolWithdrawAction</a></dt>
|
|
88
|
-
<dd><p>CurveStethPoolWithdrawAction - Withdraws tokens from curve steth pool</p>
|
|
89
|
-
</dd>
|
|
90
|
-
<dt><a href="#CurveSwapAction">CurveSwapAction</a></dt>
|
|
91
|
-
<dd></dd>
|
|
92
|
-
<dt><a href="#CurveWithdrawAction">CurveWithdrawAction</a></dt>
|
|
93
|
-
<dd></dd>
|
|
94
|
-
<dt><a href="#DyDxSupplyAction">DyDxSupplyAction</a></dt>
|
|
95
|
-
<dd><p>DyDxSupplyAction - Supply token to an DyDx position</p>
|
|
96
|
-
</dd>
|
|
97
74
|
<dt><a href="#DyDxWithdrawAction">DyDxWithdrawAction</a></dt>
|
|
98
75
|
<dd><p>DyDxWithdrawAction - Withdraw token from an DyDx position</p>
|
|
99
76
|
</dd>
|
|
@@ -115,27 +92,9 @@
|
|
|
115
92
|
<dt><a href="#DyDxFlashLoanPaybackAction">DyDxFlashLoanPaybackAction</a></dt>
|
|
116
93
|
<dd><p>Pays back a flashloan from DyDx</p>
|
|
117
94
|
</dd>
|
|
118
|
-
<dt><a href="#MakerFlashLoanAction">MakerFlashLoanAction</a></dt>
|
|
119
|
-
<dd><p>Gets a flashloan from Maker</p>
|
|
120
|
-
</dd>
|
|
121
|
-
<dt><a href="#MakerFlashLoanPaybackAction">MakerFlashLoanPaybackAction</a></dt>
|
|
122
|
-
<dd><p>Pays back a flashloan from Maker</p>
|
|
123
|
-
</dd>
|
|
124
|
-
<dt><a href="#GUniDeposit">GUniDeposit</a></dt>
|
|
125
|
-
<dd><p>Action that adds liquidity to G-UNI pool of interest (mints G-UNI LP tokens)</p>
|
|
126
|
-
</dd>
|
|
127
|
-
<dt><a href="#GUniWithdraw">GUniWithdraw</a></dt>
|
|
128
|
-
<dd><p>Action that removes liquidity from a G-UNI pool and burns G-UNI LP tokens</p>
|
|
129
|
-
</dd>
|
|
130
95
|
<dt><a href="#LidoStakeAction">LidoStakeAction</a></dt>
|
|
131
96
|
<dd><p>LidoStakeAction - Receives WETH, transforms it to ETH then sends it to Lido staking contract receiving stETH in return</p>
|
|
132
97
|
</dd>
|
|
133
|
-
<dt><a href="#LidoUnwrapAction">LidoUnwrapAction</a></dt>
|
|
134
|
-
<dd><p>LidoUnwrapAction - Unwraps WStEth into StEth</p>
|
|
135
|
-
</dd>
|
|
136
|
-
<dt><a href="#LidoWrapAction">LidoWrapAction</a></dt>
|
|
137
|
-
<dd><p>LidoWrapAction - Turns WETH or StEth into WStEth</p>
|
|
138
|
-
</dd>
|
|
139
98
|
<dt><a href="#LiquityBorrowAction">LiquityBorrowAction</a></dt>
|
|
140
99
|
<dd><p>LiquityBorrowAction - Borrows LUSD from the trove</p>
|
|
141
100
|
</dd>
|
|
@@ -181,9 +140,6 @@
|
|
|
181
140
|
<dt><a href="#LiquityWithdrawAction">LiquityWithdrawAction</a></dt>
|
|
182
141
|
<dd><p>LiquityWithdrawAction - Withdraws collateral from the trove</p>
|
|
183
142
|
</dd>
|
|
184
|
-
<dt><a href="#MakerClaimAction">MakerClaimAction</a></dt>
|
|
185
|
-
<dd><p>MakerClaimAction - Claim bonus tokens in CropJoin types</p>
|
|
186
|
-
</dd>
|
|
187
143
|
<dt><a href="#MakerGenerateAction">MakerGenerateAction</a></dt>
|
|
188
144
|
<dd><p>MakerGenerateAction - Generated Dai from a Vault</p>
|
|
189
145
|
</dd>
|
|
@@ -302,6 +258,18 @@ AaveClaimStkAaveAction - Claims stkAave from incentives controller
|
|
|
302
258
|
## AaveCollateralSwitchAction
|
|
303
259
|
AaveCollateralSwitchAction - Aave enable/disable token usage as collateral
|
|
304
260
|
|
|
261
|
+
**Kind**: global class
|
|
262
|
+
<a name="AaveMigrateLendAction"></a>
|
|
263
|
+
|
|
264
|
+
## AaveClaimStkAaveAction
|
|
265
|
+
AaveClaimStkAaveAction - Claims stkAave from incentives controller
|
|
266
|
+
|
|
267
|
+
**Kind**: global class
|
|
268
|
+
<a name="AaveCollateralSwitchAction"></a>
|
|
269
|
+
|
|
270
|
+
## AaveCollateralSwitchAction
|
|
271
|
+
AaveCollateralSwitchAction - Aave enable/disable token usage as collateral
|
|
272
|
+
|
|
305
273
|
**Kind**: global class
|
|
306
274
|
<a name="AavePaybackAction"></a>
|
|
307
275
|
|
|
@@ -405,22 +373,6 @@ BalancerV2WithdrawAction - Withdraw tokens from Balancer pool
|
|
|
405
373
|
- minAmountsOut <code>Array.<uint256></code>
|
|
406
374
|
- userData <code>bytes</code>
|
|
407
375
|
|
|
408
|
-
<a name="BuyAction"></a>
|
|
409
|
-
|
|
410
|
-
## BuyAction
|
|
411
|
-
Buys an exact amount of dest token on DeFi Saver exchange aggregator
|
|
412
|
-
|
|
413
|
-
**Kind**: global class
|
|
414
|
-
<a name="new_BuyAction_new"></a>
|
|
415
|
-
|
|
416
|
-
### new BuyAction(exchangeOrder, from, to, protocolFee)
|
|
417
|
-
**Params**
|
|
418
|
-
|
|
419
|
-
- exchangeOrder <code>Array</code> - Standard DFS Exchange data
|
|
420
|
-
- from <code>string</code> - Order sender
|
|
421
|
-
- to <code>string</code> - Order recipient
|
|
422
|
-
- protocolFee <code>string</code> - 0x fee (amount of ETH in Wei)
|
|
423
|
-
|
|
424
376
|
<a name="ChangeProxyOwnerAction"></a>
|
|
425
377
|
|
|
426
378
|
## ChangeProxyOwnerAction
|
|
@@ -570,7 +522,7 @@ CompoundPaybackAction - Payback borrowed tokens from Compound
|
|
|
570
522
|
- cTokenAddr <code>EthAddress</code>
|
|
571
523
|
- amount <code>string</code> - Wei amount in underlying asset decimals (not cAsset) - ie. 18 dec for cETH, not 8
|
|
572
524
|
- from <code>EthAddress</code>
|
|
573
|
-
- onBehalf <code>EthAddress
|
|
525
|
+
- onBehalf <code>Array.<EthAddress></code>
|
|
574
526
|
|
|
575
527
|
<a name="CompoundSupplyAction"></a>
|
|
576
528
|
|
|
@@ -603,163 +555,6 @@ CompoundWithdrawAction - Withdraw token from an Compound position
|
|
|
603
555
|
- amount <code>string</code> - Wei amount in underlying asset decimals (not cAsset) - ie. 18 dec for cETH, not 8
|
|
604
556
|
- to <code>EthAddress</code>
|
|
605
557
|
|
|
606
|
-
<a name="CurveClaimFeesAction"></a>
|
|
607
|
-
|
|
608
|
-
## CurveClaimFeesAction
|
|
609
|
-
**Kind**: global class
|
|
610
|
-
<a name="new_CurveClaimFeesAction_new"></a>
|
|
611
|
-
|
|
612
|
-
### new CurveClaimFeesAction(claimFor, receiver)
|
|
613
|
-
**Params**
|
|
614
|
-
|
|
615
|
-
- claimFor <code>EthAddress</code>
|
|
616
|
-
- receiver <code>EthAddress</code>
|
|
617
|
-
|
|
618
|
-
<a name="CurveDepositAction"></a>
|
|
619
|
-
|
|
620
|
-
## CurveDepositAction
|
|
621
|
-
**Kind**: global class
|
|
622
|
-
<a name="new_CurveDepositAction_new"></a>
|
|
623
|
-
|
|
624
|
-
### new CurveDepositAction(sender, receiver, depositTarget, lpToken, sig, minMintAmount, amounts, tokens, useUnderlying)
|
|
625
|
-
**Params**
|
|
626
|
-
|
|
627
|
-
- sender <code>EthAddress</code>
|
|
628
|
-
- receiver <code>EthAddress</code>
|
|
629
|
-
- depositTarget <code>EthAddress</code>
|
|
630
|
-
- lpToken <code>EthAddress</code>
|
|
631
|
-
- sig <code>bytes4</code>
|
|
632
|
-
- minMintAmount <code>string</code>
|
|
633
|
-
- amounts <code>Array.<string></code>
|
|
634
|
-
- tokens <code>Array.<EthAddress></code>
|
|
635
|
-
- useUnderlying <code>boolean</code>
|
|
636
|
-
|
|
637
|
-
<a name="CurveGaugeDepositAction"></a>
|
|
638
|
-
|
|
639
|
-
## CurveGaugeDepositAction
|
|
640
|
-
**Kind**: global class
|
|
641
|
-
<a name="new_CurveGaugeDepositAction_new"></a>
|
|
642
|
-
|
|
643
|
-
### new CurveGaugeDepositAction(gaugeAddr, lpToken, sender, onBehalfOf, amount)
|
|
644
|
-
**Params**
|
|
645
|
-
|
|
646
|
-
- gaugeAddr <code>EthAddress</code>
|
|
647
|
-
- lpToken <code>EthAddress</code>
|
|
648
|
-
- sender <code>EthAddress</code>
|
|
649
|
-
- onBehalfOf <code>EthAddress</code>
|
|
650
|
-
- amount <code>string</code>
|
|
651
|
-
|
|
652
|
-
<a name="CurveGaugeWithdrawAction"></a>
|
|
653
|
-
|
|
654
|
-
## CurveGaugeWithdrawAction
|
|
655
|
-
**Kind**: global class
|
|
656
|
-
<a name="new_CurveGaugeWithdrawAction_new"></a>
|
|
657
|
-
|
|
658
|
-
### new CurveGaugeWithdrawAction(gaugeAddr, lpToken, receiver, amount)
|
|
659
|
-
**Params**
|
|
660
|
-
|
|
661
|
-
- gaugeAddr <code>EthAddress</code>
|
|
662
|
-
- lpToken <code>EthAddress</code>
|
|
663
|
-
- receiver <code>EthAddress</code>
|
|
664
|
-
- amount <code>string</code>
|
|
665
|
-
|
|
666
|
-
<a name="CurveMintCrvAction"></a>
|
|
667
|
-
|
|
668
|
-
## CurveMintCrvAction
|
|
669
|
-
**Kind**: global class
|
|
670
|
-
<a name="new_CurveMintCrvAction_new"></a>
|
|
671
|
-
|
|
672
|
-
### new CurveMintCrvAction(gaugeAddrs, receiver)
|
|
673
|
-
**Params**
|
|
674
|
-
|
|
675
|
-
- gaugeAddrs <code>Array.<EthAddress></code>
|
|
676
|
-
- receiver <code>EthAddress</code>
|
|
677
|
-
|
|
678
|
-
<a name="CurveStethPoolDepositAction"></a>
|
|
679
|
-
|
|
680
|
-
## CurveStethPoolDepositAction
|
|
681
|
-
CurveStethPoolDepositAction - Deposits tokens into curve steth pool
|
|
682
|
-
|
|
683
|
-
**Kind**: global class
|
|
684
|
-
<a name="new_CurveStethPoolDepositAction_new"></a>
|
|
685
|
-
|
|
686
|
-
### new CurveStethPoolDepositAction(from, to, amounts, minMintAmount)
|
|
687
|
-
**Params**
|
|
688
|
-
|
|
689
|
-
- from <code>address</code>
|
|
690
|
-
- to <code>address</code>
|
|
691
|
-
- amounts <code>Array.<string></code>
|
|
692
|
-
- minMintAmount <code>string</code>
|
|
693
|
-
|
|
694
|
-
<a name="CurveStethPoolWithdrawAction"></a>
|
|
695
|
-
|
|
696
|
-
## CurveStethPoolWithdrawAction
|
|
697
|
-
CurveStethPoolWithdrawAction - Withdraws tokens from curve steth pool
|
|
698
|
-
|
|
699
|
-
**Kind**: global class
|
|
700
|
-
<a name="new_CurveStethPoolWithdrawAction_new"></a>
|
|
701
|
-
|
|
702
|
-
### new CurveStethPoolWithdrawAction(from, to, amounts, maxBurnAmount, returnValue)
|
|
703
|
-
**Params**
|
|
704
|
-
|
|
705
|
-
- from <code>address</code>
|
|
706
|
-
- to <code>address</code>
|
|
707
|
-
- amounts <code>Array.<string></code>
|
|
708
|
-
- maxBurnAmount <code>string</code>
|
|
709
|
-
- returnValue <code>string</code>
|
|
710
|
-
|
|
711
|
-
<a name="CurveSwapAction"></a>
|
|
712
|
-
|
|
713
|
-
## CurveSwapAction
|
|
714
|
-
**Kind**: global class
|
|
715
|
-
<a name="new_CurveSwapAction_new"></a>
|
|
716
|
-
|
|
717
|
-
### new CurveSwapAction(sender, receiver, pool, tokenA, tokenB, amount, expected)
|
|
718
|
-
**Params**
|
|
719
|
-
|
|
720
|
-
- sender <code>EthAddress</code>
|
|
721
|
-
- receiver <code>EthAddress</code>
|
|
722
|
-
- pool <code>EthAddress</code>
|
|
723
|
-
- tokenA <code>EthAddress</code>
|
|
724
|
-
- tokenB <code>EthAddress</code>
|
|
725
|
-
- amount <code>string</code>
|
|
726
|
-
- expected <code>string</code>
|
|
727
|
-
|
|
728
|
-
<a name="CurveWithdrawAction"></a>
|
|
729
|
-
|
|
730
|
-
## CurveWithdrawAction
|
|
731
|
-
**Kind**: global class
|
|
732
|
-
<a name="new_CurveWithdrawAction_new"></a>
|
|
733
|
-
|
|
734
|
-
### new CurveWithdrawAction(sender, receiver, depositTarget, lpToken, sig, burnAmount, minAmounts, tokens, withdrawExact, useUnderlying)
|
|
735
|
-
**Params**
|
|
736
|
-
|
|
737
|
-
- sender <code>EthAddress</code>
|
|
738
|
-
- receiver <code>EthAddress</code>
|
|
739
|
-
- depositTarget <code>EthAddress</code>
|
|
740
|
-
- lpToken <code>EthAddress</code>
|
|
741
|
-
- sig <code>bytes4</code>
|
|
742
|
-
- burnAmount <code>string</code>
|
|
743
|
-
- minAmounts <code>Array.<string></code>
|
|
744
|
-
- tokens <code>Array.<EthAddress></code>
|
|
745
|
-
- withdrawExact <code>boolean</code>
|
|
746
|
-
- useUnderlying <code>boolean</code>
|
|
747
|
-
|
|
748
|
-
<a name="DyDxSupplyAction"></a>
|
|
749
|
-
|
|
750
|
-
## DyDxSupplyAction
|
|
751
|
-
DyDxSupplyAction - Supply token to an DyDx position
|
|
752
|
-
|
|
753
|
-
**Kind**: global class
|
|
754
|
-
<a name="new_DyDxSupplyAction_new"></a>
|
|
755
|
-
|
|
756
|
-
### new DyDxSupplyAction(tokenAddr, amount, from)
|
|
757
|
-
**Params**
|
|
758
|
-
|
|
759
|
-
- tokenAddr <code>EthAddress</code>
|
|
760
|
-
- amount <code>string</code>
|
|
761
|
-
- from <code>EthAddress</code> - Tokens will be supplied from this address
|
|
762
|
-
|
|
763
558
|
<a name="DyDxWithdrawAction"></a>
|
|
764
559
|
|
|
765
560
|
## DyDxWithdrawAction
|
|
@@ -867,46 +662,6 @@ Pays back a flashloan from DyDx
|
|
|
867
662
|
- loanAmount <code>string</code>
|
|
868
663
|
- tokenAddr <code>EthAddress</code>
|
|
869
664
|
|
|
870
|
-
<a name="MakerFlashLoanAction"></a>
|
|
871
|
-
|
|
872
|
-
## MakerFlashLoanAction
|
|
873
|
-
Gets a flashloan from Maker
|
|
874
|
-
|
|
875
|
-
**Kind**: global class
|
|
876
|
-
<a name="new_MakerFlashLoanAction_new"></a>
|
|
877
|
-
|
|
878
|
-
### new MakerFlashLoanAction(amount, flParamGetterAddr, flParamGetterData)
|
|
879
|
-
**Params**
|
|
880
|
-
|
|
881
|
-
- amount <code>string</code>
|
|
882
|
-
- flParamGetterAddr <code>EthAddress</code>
|
|
883
|
-
- flParamGetterData <code>bytes</code>
|
|
884
|
-
|
|
885
|
-
<a name="MakerFlashLoanPaybackAction"></a>
|
|
886
|
-
|
|
887
|
-
## MakerFlashLoanPaybackAction
|
|
888
|
-
Pays back a flashloan from Maker
|
|
889
|
-
|
|
890
|
-
**Kind**: global class
|
|
891
|
-
<a name="new_MakerFlashLoanPaybackAction_new"></a>
|
|
892
|
-
|
|
893
|
-
### new MakerFlashLoanPaybackAction(loanAmount)
|
|
894
|
-
**Params**
|
|
895
|
-
|
|
896
|
-
- loanAmount <code>string</code>
|
|
897
|
-
|
|
898
|
-
<a name="GUniDeposit"></a>
|
|
899
|
-
|
|
900
|
-
## GUniDeposit
|
|
901
|
-
Action that adds liquidity to G-UNI pool of interest (mints G-UNI LP tokens)
|
|
902
|
-
|
|
903
|
-
**Kind**: global class
|
|
904
|
-
<a name="GUniWithdraw"></a>
|
|
905
|
-
|
|
906
|
-
## GUniWithdraw
|
|
907
|
-
Action that removes liquidity from a G-UNI pool and burns G-UNI LP tokens
|
|
908
|
-
|
|
909
|
-
**Kind**: global class
|
|
910
665
|
<a name="LidoStakeAction"></a>
|
|
911
666
|
|
|
912
667
|
## LidoStakeAction
|
|
@@ -922,37 +677,6 @@ LidoStakeAction - Receives WETH, transforms it to ETH then sends it to Lido stak
|
|
|
922
677
|
- from <code>EthAddress</code> - WETH will be taken from this address
|
|
923
678
|
- to <code>EthAddress</code> - stETH will be sent to this address
|
|
924
679
|
|
|
925
|
-
<a name="LidoUnwrapAction"></a>
|
|
926
|
-
|
|
927
|
-
## LidoUnwrapAction
|
|
928
|
-
LidoUnwrapAction - Unwraps WStEth into StEth
|
|
929
|
-
|
|
930
|
-
**Kind**: global class
|
|
931
|
-
<a name="new_LidoUnwrapAction_new"></a>
|
|
932
|
-
|
|
933
|
-
### new LidoUnwrapAction(amount, from, to)
|
|
934
|
-
**Params**
|
|
935
|
-
|
|
936
|
-
- amount <code>string</code> - amount of WStEth to pull and Unwrap
|
|
937
|
-
- from <code>EthAddress</code> - WstEth will be taken from this address
|
|
938
|
-
- to <code>EthAddress</code> - stETH will be sent to this address
|
|
939
|
-
|
|
940
|
-
<a name="LidoWrapAction"></a>
|
|
941
|
-
|
|
942
|
-
## LidoWrapAction
|
|
943
|
-
LidoWrapAction - Turns WETH or StEth into WStEth
|
|
944
|
-
|
|
945
|
-
**Kind**: global class
|
|
946
|
-
<a name="new_LidoWrapAction_new"></a>
|
|
947
|
-
|
|
948
|
-
### new LidoWrapAction(amount, from, to, useEth)
|
|
949
|
-
**Params**
|
|
950
|
-
|
|
951
|
-
- amount <code>string</code> - amount to pull and stake
|
|
952
|
-
- from <code>EthAddress</code> - tokens will be taken from this address
|
|
953
|
-
- to <code>EthAddress</code> - WStEth will be sent to this address
|
|
954
|
-
- useEth <code>boolean</code> - true for using WETH, false for using stEth
|
|
955
|
-
|
|
956
680
|
<a name="LiquityBorrowAction"></a>
|
|
957
681
|
|
|
958
682
|
## LiquityBorrowAction
|
|
@@ -1175,21 +899,6 @@ LiquityWithdrawAction - Withdraws collateral from the trove
|
|
|
1175
899
|
- collAmount - Amount of WETH tokens to withdraw
|
|
1176
900
|
- to - Address that will receive the withdrawn tokens
|
|
1177
901
|
|
|
1178
|
-
<a name="MakerClaimAction"></a>
|
|
1179
|
-
|
|
1180
|
-
## MakerClaimAction
|
|
1181
|
-
MakerClaimAction - Claim bonus tokens in CropJoin types
|
|
1182
|
-
|
|
1183
|
-
**Kind**: global class
|
|
1184
|
-
<a name="new_MakerClaimAction_new"></a>
|
|
1185
|
-
|
|
1186
|
-
### new MakerClaimAction(vaultId, joinAddr, to)
|
|
1187
|
-
**Params**
|
|
1188
|
-
|
|
1189
|
-
- vaultId <code>VaultId</code>
|
|
1190
|
-
- joinAddr <code>EthAddress</code>
|
|
1191
|
-
- to <code>EthAddress</code> - Tokens will be sent to this address
|
|
1192
|
-
|
|
1193
902
|
<a name="MakerGenerateAction"></a>
|
|
1194
903
|
|
|
1195
904
|
## MakerGenerateAction
|
|
@@ -1325,7 +1034,7 @@ MStableDepositAction
|
|
|
1325
1034
|
**Kind**: global class
|
|
1326
1035
|
<a name="new_MStableDepositAction_new"></a>
|
|
1327
1036
|
|
|
1328
|
-
### new MStableDepositAction(bAsset, mAsset, saveAddress, vaultAddress, from, to, amount, minOut,
|
|
1037
|
+
### new MStableDepositAction(bAsset, mAsset, saveAddress, vaultAddress, from, to, amount, minOut, stake)
|
|
1329
1038
|
**Params**
|
|
1330
1039
|
|
|
1331
1040
|
- bAsset
|
|
@@ -1336,7 +1045,7 @@ MStableDepositAction
|
|
|
1336
1045
|
- to
|
|
1337
1046
|
- amount
|
|
1338
1047
|
- minOut
|
|
1339
|
-
-
|
|
1048
|
+
- stake
|
|
1340
1049
|
|
|
1341
1050
|
<a name="MStableWithdrawAction"></a>
|
|
1342
1051
|
|
|
@@ -1346,7 +1055,7 @@ MStableWithdrawAction
|
|
|
1346
1055
|
**Kind**: global class
|
|
1347
1056
|
<a name="new_MStableWithdrawAction_new"></a>
|
|
1348
1057
|
|
|
1349
|
-
### new MStableWithdrawAction(bAsset, mAsset, saveAddress, vaultAddress, from, to, amount, minOut,
|
|
1058
|
+
### new MStableWithdrawAction(bAsset, mAsset, saveAddress, vaultAddress, from, to, amount, minOut, stake)
|
|
1350
1059
|
**Params**
|
|
1351
1060
|
|
|
1352
1061
|
- bAsset
|
|
@@ -1357,7 +1066,7 @@ MStableWithdrawAction
|
|
|
1357
1066
|
- to
|
|
1358
1067
|
- amount
|
|
1359
1068
|
- minOut
|
|
1360
|
-
-
|
|
1069
|
+
- stake
|
|
1361
1070
|
|
|
1362
1071
|
<a name="RariDepositAction"></a>
|
|
1363
1072
|
|
|
@@ -1,8 +1,4 @@
|
|
|
1
1
|
const DyDxAccessLists = {
|
|
2
|
-
DyDxSupply: [
|
|
3
|
-
['0x1E0447b19BB6EcFdAe1e4AE1694b0C3659614e4e', []], // SoloMargin
|
|
4
|
-
['0x5c55B921f590a89C1Ebe84dF170E655a82b62126', []], // DefisaverLogger
|
|
5
|
-
],
|
|
6
2
|
DyDxWithdraw: [
|
|
7
3
|
['0x1E0447b19BB6EcFdAe1e4AE1694b0C3659614e4e', []], // SoloMargin
|
|
8
4
|
['0x5c55B921f590a89C1Ebe84dF170E655a82b62126', []], // DefisaverLogger
|
|
@@ -1,12 +1,4 @@
|
|
|
1
1
|
const InstaAccessLists = {
|
|
2
|
-
ClaimInstMaker: [
|
|
3
|
-
['0x2971AdFa57b20E5a416aE5a708A8655A9c74f723', []], // InstaIndex
|
|
4
|
-
['0x5ef30b9986345249bc32d8928B7ee64DE9435E39', []], // DssCdpManager
|
|
5
|
-
['0xAC838332afc2937FdED89c16a59b2ED8e8e2743c', []], // InstaMakerDAOMerkleDistributor
|
|
6
|
-
['0x6f40d4A6237C257fff2dB00FA0510DeEECd303eb', []], // InstaToken
|
|
7
|
-
['0x5c55B921f590a89C1Ebe84dF170E655a82b62126', []], // DefisaverLogger
|
|
8
|
-
],
|
|
9
|
-
|
|
10
2
|
InstPullTokens: [
|
|
11
3
|
['0x5c55B921f590a89C1Ebe84dF170E655a82b62126', []], // DefisaverLogger
|
|
12
4
|
],
|
|
@@ -12,11 +12,6 @@ const UtilsAccessLists = {
|
|
|
12
12
|
['0x5c55B921f590a89C1Ebe84dF170E655a82b62126', []], // DefisaverLogger
|
|
13
13
|
],
|
|
14
14
|
|
|
15
|
-
DFSBuy: [
|
|
16
|
-
['0x25dd3F51e0C3c3Ff164DDC02A8E4D65Bb9cBB12D', []], // SaverExchangeRegistry
|
|
17
|
-
['0x5c55B921f590a89C1Ebe84dF170E655a82b62126', []], // DefisaverLogger
|
|
18
|
-
],
|
|
19
|
-
|
|
20
15
|
SendToken: [],
|
|
21
16
|
|
|
22
17
|
PullToken: [],
|
package/DEV.md
CHANGED
|
@@ -85,7 +85,6 @@ Source: https://uniswap.org/docs/v2/javascript-SDK/getting-pair-addresses/#types
|
|
|
85
85
|
* [.estimateSellPrice(sellAmount, sellToken, buyToken)](#utils.module_zeroExExchange.estimateSellPrice) ⇒ <code>Promise.<string></code>
|
|
86
86
|
* [.estimateBuyPrice(buyAmount, buyToken, sellToken)](#utils.module_zeroExExchange.estimateBuyPrice) ⇒ <code>Promise.<string></code>
|
|
87
87
|
* [.createSellAction(sellAmount, sellToken, buyToken, expectedPrice, acceptedSlippagePercent, fromAccount, toAccount)](#utils.module_zeroExExchange.createSellAction) ⇒ <code>Promise.<SellAction></code>
|
|
88
|
-
* [.createBuyAction(buyAmount, buyToken, sellToken, expectedPrice, acceptedSlippagePercent, fromAccount, toAccount)](#utils.module_zeroExExchange.createBuyAction) ⇒ <code>Promise.<BuyAction></code>
|
|
89
88
|
|
|
90
89
|
<a name="utils.module_zeroExExchange.estimateSellPrice"></a>
|
|
91
90
|
|
|
@@ -133,12 +132,6 @@ For that purpose, the estimateSellPrice method can be used.
|
|
|
133
132
|
- fromAccount [<code>EthAddress</code>](#EthAddress) - Withdraw funds from this addr
|
|
134
133
|
- toAccount [<code>EthAddress</code>](#EthAddress) - Send funds to this addr
|
|
135
134
|
|
|
136
|
-
<a name="utils.module_zeroExExchange.createBuyAction"></a>
|
|
137
|
-
|
|
138
|
-
### zeroExExchange.createBuyAction(buyAmount, buyToken, sellToken, expectedPrice, acceptedSlippagePercent, fromAccount, toAccount) ⇒ <code>Promise.<BuyAction></code>
|
|
139
|
-
Fetches prices and creates order ready to be passed to transaction.
|
|
140
|
-
This should only be called when before sending tx, not to be used for just querying the price.
|
|
141
|
-
For that purpose, the estimateBuyPrice method can be used.
|
|
142
135
|
|
|
143
136
|
**Kind**: static method of [<code>zeroExExchange</code>](#utils.module_zeroExExchange)
|
|
144
137
|
**Params**
|
package/index.js
CHANGED
|
@@ -1,16 +1,29 @@
|
|
|
1
1
|
const Action = require('./src/Action');
|
|
2
2
|
const Recipe = require('./src/Recipe');
|
|
3
|
+
const Strategy = require('./src/Strategy');
|
|
3
4
|
const DfsWeb3 = require('./src/DfsWeb3');
|
|
5
|
+
const {
|
|
6
|
+
configure, getNetworkData, CONFIG, NETWORKS,
|
|
7
|
+
} = require('./src/config');
|
|
4
8
|
|
|
5
9
|
const actions = require('./src/actions/');
|
|
10
|
+
const triggers = require('./src/triggers/');
|
|
6
11
|
const utils = require('./src/utils/');
|
|
7
12
|
const { actionAddresses } = require('./src/addresses');
|
|
8
13
|
|
|
9
14
|
module.exports = {
|
|
10
15
|
Action,
|
|
11
16
|
Recipe,
|
|
17
|
+
Strategy,
|
|
18
|
+
DfsWeb3,
|
|
19
|
+
|
|
12
20
|
actions,
|
|
13
|
-
|
|
21
|
+
triggers,
|
|
14
22
|
utils,
|
|
15
|
-
|
|
23
|
+
|
|
24
|
+
configure,
|
|
25
|
+
getNetworkData,
|
|
26
|
+
networks: NETWORKS,
|
|
27
|
+
actionAddressesAllChains: actionAddresses,
|
|
28
|
+
actionAddresses: actionAddresses[CONFIG.chainId],
|
|
16
29
|
}
|
package/package.json
CHANGED
package/src/Action.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const AbiCoder = require('web3-eth-abi');
|
|
2
2
|
const { keccak256, padLeft, toHex } = require('web3-utils');
|
|
3
|
+
const { CONFIG } = require('./config');
|
|
3
4
|
|
|
4
5
|
const ActionAbi = require('./abis/Action.json');
|
|
5
6
|
|
|
@@ -31,24 +32,46 @@ class Action {
|
|
|
31
32
|
* @returns {string}
|
|
32
33
|
* @private
|
|
33
34
|
*/
|
|
34
|
-
|
|
35
|
-
return keccak256(this.name);
|
|
35
|
+
getId() {
|
|
36
|
+
return keccak256(this.name).substr(0, 10);
|
|
36
37
|
}
|
|
37
38
|
|
|
38
39
|
/**
|
|
39
40
|
* @returns {Array<number>}
|
|
40
41
|
* @private
|
|
41
42
|
*/
|
|
42
|
-
|
|
43
|
+
_getArgumentMappingWithSlots(subSlots) {
|
|
43
44
|
return this.mappableArgs.map(arg => {
|
|
44
45
|
if (new RegExp(/\$\d+/).test(arg)) {
|
|
45
46
|
if (Array.isArray(arg)) throw TypeError('Input can\'t be mapped to arrays (tuples/structs). Specify `mappableArgs` array in constructor.');
|
|
46
47
|
return parseInt(arg.substr(1))
|
|
47
48
|
}
|
|
49
|
+
|
|
50
|
+
// Handle SubSlots placeholder values in strategies
|
|
51
|
+
if (new RegExp(/\&\w+/).test(arg)) {
|
|
52
|
+
if (arg === '&proxy') return 254;
|
|
53
|
+
if (arg === '&eoa') return 255;
|
|
54
|
+
return parseInt(subSlots[arg].index);
|
|
55
|
+
}
|
|
56
|
+
|
|
48
57
|
return 0;
|
|
49
58
|
});
|
|
50
59
|
}
|
|
51
60
|
|
|
61
|
+
/**
|
|
62
|
+
* @returns {Array<number>}
|
|
63
|
+
* @private
|
|
64
|
+
*/
|
|
65
|
+
_getArgumentMapping() {
|
|
66
|
+
return this.mappableArgs.map(arg => {
|
|
67
|
+
if (new RegExp(/\$\d+/).test(arg)) {
|
|
68
|
+
if (Array.isArray(arg)) throw TypeError('Input can\'t be mapped to arrays (tuples/structs). Specify `mappableArgs` array in constructor.');
|
|
69
|
+
return parseInt(arg.substr(1))
|
|
70
|
+
}
|
|
71
|
+
return 0;
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
|
|
52
75
|
/**
|
|
53
76
|
* @param type {string}
|
|
54
77
|
* @private
|
|
@@ -67,6 +90,7 @@ class Action {
|
|
|
67
90
|
_replaceWithPlaceholders(arg, paramType) {
|
|
68
91
|
if (Array.isArray(arg)) return arg.map((_arg, i) => this._replaceWithPlaceholders(_arg, paramType[i]));
|
|
69
92
|
if (new RegExp(/\$\d+/).test(arg)) return this._getPlaceholderForType(paramType);
|
|
93
|
+
if (new RegExp(/\&\w+/).test(arg)) return this._getPlaceholderForType(paramType);
|
|
70
94
|
return arg;
|
|
71
95
|
}
|
|
72
96
|
|
|
@@ -84,13 +108,18 @@ class Action {
|
|
|
84
108
|
* @private
|
|
85
109
|
*/
|
|
86
110
|
_encodeForCall() {
|
|
87
|
-
|
|
111
|
+
return this.args.map((arg, i) => {
|
|
88
112
|
let paramType = this.paramTypes[i];
|
|
89
113
|
let _arg = this._replaceWithPlaceholders(arg, paramType);
|
|
90
114
|
let _paramType = this._formatType(paramType);
|
|
91
115
|
return AbiCoder.encodeParameter(_paramType, _arg);
|
|
92
116
|
});
|
|
93
|
-
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
encodeForL2DsProxyCall() {
|
|
120
|
+
// TODO fix this mess
|
|
121
|
+
const executeActionDirectAbi = ActionAbi.find(({ name }) => name === 'executeActionDirect');
|
|
122
|
+
return AbiCoder.encodeFunctionCall(executeActionDirectAbi, this._encodeForCall());
|
|
94
123
|
}
|
|
95
124
|
|
|
96
125
|
/**
|
|
@@ -98,11 +127,15 @@ class Action {
|
|
|
98
127
|
* @returns {Array<string>} `address` & `data` to be passed on to DSProxy's `execute(address _target, bytes memory _data)`
|
|
99
128
|
*/
|
|
100
129
|
encodeForDsProxyCall() {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
130
|
+
if (CONFIG.chainId === 1) {
|
|
131
|
+
const executeActionDirectAbi = ActionAbi.find(({ name }) => name === 'executeActionDirect');
|
|
132
|
+
return [
|
|
133
|
+
this.contractAddress,
|
|
134
|
+
AbiCoder.encodeFunctionCall(executeActionDirectAbi, this._encodeForCall()),
|
|
135
|
+
];
|
|
136
|
+
} else {
|
|
137
|
+
return [this.contractAddress, this.encodeForL2DsProxyCall()];
|
|
138
|
+
}
|
|
106
139
|
}
|
|
107
140
|
|
|
108
141
|
/**
|
|
@@ -112,12 +145,19 @@ class Action {
|
|
|
112
145
|
encodeForRecipe() {
|
|
113
146
|
return [
|
|
114
147
|
this._encodeForCall()[0], // actionCallData
|
|
115
|
-
|
|
116
|
-
this.
|
|
148
|
+
"0x0000000000000000000000000000000000000000000000000000000000000000", // subData
|
|
149
|
+
this.getId(), // actionIds
|
|
117
150
|
this._getArgumentMapping(), // paramMappings
|
|
118
151
|
]
|
|
119
152
|
}
|
|
120
153
|
|
|
154
|
+
encodeForStrategy(subSlots) {
|
|
155
|
+
return [
|
|
156
|
+
this.getId(),
|
|
157
|
+
this._getArgumentMappingWithSlots(subSlots), // paramMappings
|
|
158
|
+
]
|
|
159
|
+
}
|
|
160
|
+
|
|
121
161
|
/**
|
|
122
162
|
* Assets requiring approval to be used by DsProxy
|
|
123
163
|
* Approval is done from owner to DsProxy
|