@defisaver/sdk 0.1.22 → 0.2.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/ACTIONS.md +20 -254
- 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 +4 -0
- package/package.json +1 -1
- package/src/Action.js +36 -6
- 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/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/SendTokenAndUnwrapAction.js +36 -0
- package/src/actions/basic/SumInputsAction.js +8 -3
- package/src/actions/basic/UnwrapEthAction.js +8 -3
- package/src/actions/basic/UpdateSubAction.js +19 -0
- package/src/actions/basic/WrapEthAction.js +5 -1
- package/src/actions/basic/index.js +6 -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/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 +2 -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 +91 -91
- 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 +15 -0
- package/src/triggers/MakerRatioTrigger.js +15 -0
- package/src/triggers/ReflexerRatioTrigger.js +10 -0
- package/src/triggers/TimestampTrigger.js +11 -0
- package/src/triggers/UniV3CurrentTickTrigger.js +12 -0
- package/src/triggers/index.js +19 -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/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/src/addresses.js
CHANGED
|
@@ -1,133 +1,133 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
3
|
const actionAddresses = {
|
|
4
|
-
'
|
|
5
|
-
'DFSRegistry': '
|
|
4
|
+
'RecipeExecutor': '0xe822d76c2632FC52f3eaa686bDA9Cea3212579D8',
|
|
5
|
+
'DFSRegistry': '0x287778F121F134C66212FB16c9b53eC991D32f5b',
|
|
6
6
|
|
|
7
7
|
// utils
|
|
8
|
-
'WrapEth': '
|
|
9
|
-
'UnwrapEth': '
|
|
10
|
-
'PullToken': '
|
|
11
|
-
'SendToken': '
|
|
12
|
-
'SumInputs': '
|
|
13
|
-
'SubInputs': '
|
|
14
|
-
'ChangeProxyOwner': '
|
|
15
|
-
'TokenBalance': '
|
|
16
|
-
'AutomationV2Unsub': '
|
|
8
|
+
'WrapEth': '0x8EbBd35f84D7f0DFCBEf08fD30CD09176133251A',
|
|
9
|
+
'UnwrapEth': '0xDB6C8cFDd7c1C0F8895CDBC01Dbf4A6D4B6d2a29',
|
|
10
|
+
'PullToken': '0x254cA89a00d53ab61de2Ba5641DBDC01aE48aed4',
|
|
11
|
+
'SendToken': '0x5612e490c9549486dF16b34EBfD0E8b6cF6a1717',
|
|
12
|
+
'SumInputs': '0x70907d840aBBc984Fd949311d2f005e6aC4a4D7a',
|
|
13
|
+
'SubInputs': '0xe1804b756188F63f723d2FECc02988D0Cc1aB823',
|
|
14
|
+
'ChangeProxyOwner': '0x81cA52CfE66421d0ceF82d5F33230e43b5F23D2B',
|
|
15
|
+
'TokenBalance': '0xa92B177950F1460119940436515FD857C24494BC',
|
|
16
|
+
'AutomationV2Unsub': '0xe35Fb12fE9796847751076aCf5ee7d124108612C',
|
|
17
|
+
'SendTokenAndUnwrap': '0xeecd376026335261c89faD40D89625391b1eFF6a',
|
|
17
18
|
|
|
18
19
|
// exchange
|
|
19
|
-
'DFSSell': '
|
|
20
|
-
'DFSBuy': '0x939dCad6A3D1fEACccB60Af90876D904468CbF66',
|
|
20
|
+
'DFSSell': '0x1abDDCae131ce200e66140d9fBd0C37F7a40e642',
|
|
21
21
|
|
|
22
22
|
// maker
|
|
23
|
-
'McdGenerate': '
|
|
24
|
-
'McdGive': '
|
|
25
|
-
'McdMerge': '
|
|
26
|
-
'McdOpen': '
|
|
27
|
-
'McdPayback': '
|
|
28
|
-
'McdSupply': '
|
|
29
|
-
'McdWithdraw': '
|
|
30
|
-
'McdClaim': '
|
|
23
|
+
'McdGenerate': '0xCb50a91C0f12f439b8bf11E9474B9c1ED62Bf7a3',
|
|
24
|
+
'McdGive': '0xf9556A87BF424834FDe7De0547b58E36Cb42EF01',
|
|
25
|
+
'McdMerge': '0x6D06C6c2BCeaEC31b0F8Cd68C594120dDCcCC427',
|
|
26
|
+
'McdOpen': '0x1b54e8b6073ac7382c42830BE715466aDA11Cf37',
|
|
27
|
+
'McdPayback': '0xE68AeD979Af6f85516fF485D098804c0f9eD9A5b',
|
|
28
|
+
'McdSupply': '0x84372e73e1A2E95510869D2D81A3ef1AEC9e0Da8',
|
|
29
|
+
'McdWithdraw': '0xa704FBBe2f7ea8eF45a8280f6Bf96939eBC73252',
|
|
30
|
+
'McdClaim': '0xc0FC0f5Ba156E16217F8C7f400AEc0a658419C13',
|
|
31
31
|
|
|
32
32
|
// reflexer
|
|
33
|
-
'ReflexerSupply': '
|
|
34
|
-
'ReflexerWithdraw': '
|
|
35
|
-
'ReflexerPayback': '
|
|
36
|
-
'ReflexerGenerate': '
|
|
37
|
-
'ReflexerOpen': '
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
'
|
|
33
|
+
'ReflexerSupply': '0xd7a36CD4ce7CCc2F1376Dc5C48BaC84380A4f698',
|
|
34
|
+
'ReflexerWithdraw': '0xD8a14d447AB6789F3bf1Eb763b6306db3FC3d666',
|
|
35
|
+
'ReflexerPayback': '0xcC6838d8a61a4b29Ea565d39C38b830f1491cb29',
|
|
36
|
+
'ReflexerGenerate': '0x8e8Fd178A5FAE3A29F9CB1A06aBBBCFd5B83beb7',
|
|
37
|
+
'ReflexerOpen': '0x4704a7cBd4d913d1233765B70531D601b4384011',
|
|
38
|
+
|
|
39
|
+
// not deployed as currently not used
|
|
40
|
+
'ReflexerNativeUniV2SaviourDeposit':'0x0000000000000000000000000000000000000000',
|
|
41
|
+
'ReflexerNativeUniV2SaviourGetReserves':'0x0000000000000000000000000000000000000000',
|
|
42
|
+
'ReflexerNativeUniV2SaviourWithdraw':'0x0000000000000000000000000000000000000000',
|
|
41
43
|
|
|
42
44
|
// aave
|
|
43
|
-
'AaveBorrow': '
|
|
44
|
-
'AavePayback': '
|
|
45
|
-
'AaveSupply': '
|
|
46
|
-
'AaveWithdraw': '
|
|
47
|
-
'AaveCollateralSwitch': '
|
|
45
|
+
'AaveBorrow': '0x1B95E800a869bc3F89914470a7901D93D1401cD1',
|
|
46
|
+
'AavePayback': '0x066225964999F1D07C888c5Ac4a6C885bDa88b9A',
|
|
47
|
+
'AaveSupply': '0xEbB200a529058B561B42Eab510DA157a63243CEc',
|
|
48
|
+
'AaveWithdraw': '0x754C58fA92246414a448c1ed44ea3D1AD446d482',
|
|
49
|
+
'AaveCollateralSwitch': '0xFf5dfF1B90bd5Aa6E12768AB497dB90cc9DE6F5d',
|
|
48
50
|
|
|
49
51
|
// compound
|
|
50
|
-
'CompBorrow': '
|
|
51
|
-
'CompClaim': '
|
|
52
|
-
'CompPayback': '
|
|
53
|
-
'CompSupply': '
|
|
54
|
-
'CompWithdraw': '
|
|
55
|
-
'CompGetDebt': '
|
|
56
|
-
'CompCollateralSwitch': '
|
|
52
|
+
'CompBorrow': '0x8495579BF6Ae848f7E59686536F834f1d2CCd79C',
|
|
53
|
+
'CompClaim': '0x81F488cF7A0128A9DB5e7207042cCAB1CB0ac902',
|
|
54
|
+
'CompPayback': '0x2881590d5FfBd1e88BFc0Dc292f10e5377977f87',
|
|
55
|
+
'CompSupply': '0xB4CEDe40b249b756Ce0EAa3e14F6af89f25f9a3d',
|
|
56
|
+
'CompWithdraw': '0x3792F83D6A82091cb53052458038CC86e206463F',
|
|
57
|
+
'CompGetDebt': '0xc2B8f8423bc8Fe2e9A44cA9d364d835D1751b725',
|
|
58
|
+
'CompCollateralSwitch': '0xC3d89139508A3883775D3d1E62E2A0fea363b448',
|
|
57
59
|
|
|
58
60
|
// flashloan
|
|
59
|
-
'FLAaveV2': '
|
|
60
|
-
'FLDyDx': '
|
|
61
|
-
'FLMaker': '
|
|
62
|
-
'FLBalancer': '
|
|
61
|
+
'FLAaveV2': '0xa4d52ED15018a5be4adE5796899e5d75cc8759C1',
|
|
62
|
+
'FLDyDx': '0x08AC78B418fCB0DDF1096533856A757C28d430d7',
|
|
63
|
+
'FLMaker': '0xd393582bE148A45585aB202Fa7Cc789Fa5127223',
|
|
64
|
+
'FLBalancer': '0x5C7a9f4635AE4F95da2e45317311AAe255FB71B3',
|
|
63
65
|
|
|
64
66
|
// uniswap
|
|
65
|
-
'UniSupply': '
|
|
66
|
-
'UniWithdraw': '
|
|
67
|
+
'UniSupply': '0x9935e12F0218E61c27D7f23eAC9A9D6881a078eC',
|
|
68
|
+
'UniWithdraw': '0xf8bb8F68b0A45DC315F3f7602a60cfb274B00951',
|
|
67
69
|
|
|
68
70
|
// uniswap V3
|
|
69
|
-
'UniCollectV3': '
|
|
70
|
-
'UniMintV3': '
|
|
71
|
-
'UniSupplyV3': '
|
|
72
|
-
'UniWithdrawV3': '
|
|
73
|
-
'UniCreatePoolV3': '
|
|
71
|
+
'UniCollectV3': '0x331D7C3F6E710cB6cFE94c4Aa04AC3345AC00e00',
|
|
72
|
+
'UniMintV3': '0x3dF75BE8Fb0a6186BE9705cACaa6dD2a4Ec3e40C',
|
|
73
|
+
'UniSupplyV3': '0x0CA4255b37DD083dBD48Ca74d575F46037992520',
|
|
74
|
+
'UniWithdrawV3': '0xe06224593D9c860B2fBF39eEA3b9B8A85b77Fbc4',
|
|
75
|
+
'UniCreatePoolV3': '0x9058aAbEdEfe652b1d85DBBAB48Dfa78db613C44',
|
|
74
76
|
|
|
75
77
|
// dydx
|
|
76
|
-
'
|
|
77
|
-
'DyDxWithdraw': '0x55AA33F42D79DbD3f1885b410e4796d641549bC3',
|
|
78
|
+
'DyDxWithdraw': '0x827089C5Fc7653655c4080c660Cd8f755F818443',
|
|
78
79
|
|
|
79
80
|
// yearn
|
|
80
|
-
'YearnSupply': '
|
|
81
|
-
'YearnWithdraw': '
|
|
81
|
+
'YearnSupply': '0x837D6E7F469b3cC820B0a6Da25415D5aE0A861c4',
|
|
82
|
+
'YearnWithdraw': '0x563eF9b1075628E62aDc657702517dEA72ca08d6',
|
|
82
83
|
|
|
83
84
|
// liquity
|
|
84
|
-
'LiquityClose': '
|
|
85
|
-
'LiquityBorrow': '
|
|
86
|
-
'LiquityOpen': '
|
|
87
|
-
'LiquityPayback': '
|
|
88
|
-
'LiquityWithdraw': '
|
|
89
|
-
'LiquitySupply': '
|
|
90
|
-
'LiquitySPDeposit': '
|
|
91
|
-
'LiquitySPWithdraw': '
|
|
92
|
-
'LiquityStake': '
|
|
93
|
-
'LiquityUnstake': '
|
|
94
|
-
'LiquityEthGainToTrove': '
|
|
95
|
-
'LiquityClaim': '
|
|
96
|
-
'LiquityRedeem': '
|
|
85
|
+
'LiquityClose': '0x4B2d174129789a88e92D46342201F207132144b7',
|
|
86
|
+
'LiquityBorrow': '0xF978d6C5c8af80a059AdB85EEb64F14C9c436D68',
|
|
87
|
+
'LiquityOpen': '0x4EFF392cc69B31Ad159EcfA10305251b2d8E40E0',
|
|
88
|
+
'LiquityPayback': '0x8fc7D24414e9740ed9841d9205D458e3677e71f7',
|
|
89
|
+
'LiquityWithdraw': '0x733F53579bEcdd3Ed07e745A55Ee9af8B9669048',
|
|
90
|
+
'LiquitySupply': '0xD539943e080C2a29e3f1DB2d45Ea7240d7ddDEE2',
|
|
91
|
+
'LiquitySPDeposit': '0x5aB0244a00a733f16E6b238B462bdF3538C698E1',
|
|
92
|
+
'LiquitySPWithdraw': '0xa71817957eaF993fAA9a1F4B5c2402c0aeFCd9C6',
|
|
93
|
+
'LiquityStake': '0x671280800B540cbF073561d84A297a2c4c5D529F',
|
|
94
|
+
'LiquityUnstake': '0x86FDD4A6438D448a794A44ABBe47D57590b3350d',
|
|
95
|
+
'LiquityEthGainToTrove': '0x65e19f967B3F3cB6466110aD238039F5423E3177',
|
|
96
|
+
'LiquityClaim': '0x526735aDcBe5c9059275c5ED2E0574b4a24b875e',
|
|
97
|
+
'LiquityRedeem': '0x20B78854658011394C931EF2BF3cEEA2Fe62E7f0',
|
|
97
98
|
|
|
98
99
|
// lido
|
|
99
|
-
'LidoStake': '
|
|
100
|
-
'LidoWrap': '
|
|
101
|
-
'LidoUnwrap': '
|
|
100
|
+
'LidoStake': '0x4a7dd38D2BcA817fb68165155F869ca4179d8060',
|
|
101
|
+
'LidoWrap': '0xE637544390db79EdDE0a9CAF352ED0FfF7451bDB',
|
|
102
|
+
'LidoUnwrap': '0x910F73Fb8C0Bd15423c0D0BaD9F1ed95187a48fD',
|
|
102
103
|
|
|
103
104
|
// insta
|
|
104
|
-
'
|
|
105
|
-
'InstPullTokens': '0x37FC940Be30e11d578243dEBea4f9B950E22aC99',
|
|
105
|
+
'InstPullTokens': '0xf2c87782D6Eff0511e82007119BAC40e9ba86F69',
|
|
106
106
|
|
|
107
107
|
// balancer
|
|
108
|
-
'BalancerV2Supply': '
|
|
109
|
-
'BalancerV2Withdraw': '
|
|
110
|
-
'BalancerV2Claim': '
|
|
108
|
+
'BalancerV2Supply': '0xE48123018Db5e9075841C61EA702cEca51621191',
|
|
109
|
+
'BalancerV2Withdraw': '0xbED38692438b90AF738F8A7A3142C217DE8fB069',
|
|
110
|
+
'BalancerV2Claim': '0xEac7c5bEFaA6E17f1A2e86947eEd6419c74A7C03',
|
|
111
111
|
|
|
112
112
|
// GUni
|
|
113
|
-
|
|
114
|
-
|
|
113
|
+
'GUniWithdraw': '0x6F7cD7C0Dd3634E14bAB91FDF3bCE0a4315b3C59',
|
|
114
|
+
'GUniDeposit': '0xb247cD4cab056800cCDa7cE1AFB781a8bFA9b57A',
|
|
115
|
+
|
|
116
|
+
// Rari
|
|
117
|
+
'RariDeposit': '0x77A05c15f62F1fA6471D466001E21C1B189fcA9F',
|
|
118
|
+
'RariWithdraw': '0xa052eD427EFa63B5bb87c409449a47e7C50317e3',
|
|
115
119
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
120
|
+
// mStable
|
|
121
|
+
'MStableDeposit': '0xdf24ed1250fbfa274316b50Bc9A009aFA8F61E16',
|
|
122
|
+
'MStableWithdraw': '0xa4d5d3e56012C1eD8aba4bE246964962DC3F735f',
|
|
119
123
|
|
|
120
|
-
|
|
121
|
-
'MStableDeposit': '0x1887235CFE1927782a3e7eD15fb073586c949858',
|
|
122
|
-
'MStableWithdraw': '0xb164456190577fbBe8FB8bF5Fa48a106b328A579',
|
|
124
|
+
'MStableClaim': '0xD56F0EC66267958e08c91547c259cCAC006BF118',
|
|
123
125
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
+
'McdRatioCheck': '0x3f09773e5e945C6Aa1bc8a8B3492f507620DE1e1',
|
|
127
|
+
'GasFeeTaker': '0x431F1E1A9859EF99953801dbdeB31d2846ADcc0d',
|
|
126
128
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
'CurveStethPoolDeposit': '0x0f042a5CC97C4cd8D8136c28F966839f195D08B9',
|
|
130
|
-
'CurveStethPoolWithdraw': '0x2F4ad71Bd8045d0633B304BD2d94ef349eB09105',
|
|
129
|
+
'CurveStethPoolDeposit': '0x5Ae5870dC0C780e9eb68bE7a223eCd7F3BDad12B',
|
|
130
|
+
'CurveStethPoolWithdraw': '0x4089731d843Ce52699Fe64F68556aBbD95D70D00',
|
|
131
131
|
};
|
|
132
132
|
|
|
133
133
|
const otherAddresses = {
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
const Action = require("../Action");
|
|
2
|
+
const {getAddr} = require("../addresses.js");
|
|
3
|
+
|
|
4
|
+
class ChainLinkPriceTrigger extends Action {
|
|
5
|
+
|
|
6
|
+
constructor(tokenAddr, price, state) {
|
|
7
|
+
super("ChainLinkPriceTrigger", getAddr("ChainLinkPriceTrigger"), [["address", "uint256", "uint8"]], [[...arguments]]);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
module.exports = ChainLinkPriceTrigger;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
const Action = require("../Action");
|
|
2
|
+
const {getAddr} = require("../addresses.js");
|
|
3
|
+
|
|
4
|
+
class CompoundRatioTrigger extends Action {
|
|
5
|
+
|
|
6
|
+
constructor(user, ratio, state) {
|
|
7
|
+
super("CompoundRatioTrigger", getAddr("CompoundRatioTrigger"), [["address", "uint256", "uint8"]], [[...arguments]]);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
module.exports = CompoundRatioTrigger;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
const Action = require("../Action");
|
|
2
|
+
const {getAddr} = require("../addresses.js");
|
|
3
|
+
|
|
4
|
+
class GasPriceTrigger extends Action {
|
|
5
|
+
|
|
6
|
+
constructor(maxGasPrice) {
|
|
7
|
+
super("GasPriceTrigger", getAddr("GasPriceTrigger"), [["uint256"]], [[...arguments]]);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
module.exports = GasPriceTrigger;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const Action = require("../Action");
|
|
2
|
+
|
|
3
|
+
class LiquityRatioTrigger extends Action {
|
|
4
|
+
|
|
5
|
+
constructor(troveOwner, ratio, state) {
|
|
6
|
+
super(
|
|
7
|
+
"LiquityRatioTrigger",
|
|
8
|
+
getAddr("LiquityRatioTrigger"),
|
|
9
|
+
[["addresss", "uint256", "uint8"]],
|
|
10
|
+
[[...arguments]]
|
|
11
|
+
);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
module.exports = LiquityRatioTrigger;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const Action = require("../Action");
|
|
2
|
+
const {getAddr} = require("../addresses.js");
|
|
3
|
+
|
|
4
|
+
class MakerRatioTrigger extends Action {
|
|
5
|
+
|
|
6
|
+
constructor(vaultId, ratio, state) {
|
|
7
|
+
super("McdRatioTrigger", getAddr("McdRatioTrigger"), [["uint256", "uint256", "uint8"]], [[...arguments]]);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
async getEthValue() {
|
|
11
|
+
return this.args[0];
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
module.exports = MakerRatioTrigger;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
const Action = require("../Action");
|
|
2
|
+
|
|
3
|
+
class ReflexerRatioTrigger extends Action {
|
|
4
|
+
|
|
5
|
+
constructor(vaultId, ratio, state) {
|
|
6
|
+
super("ReflexerRatioTrigger", getAddr("ReflexerRatioTrigger"), [["uint256", "uint256", "uint8"]], [[...arguments]]);
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
module.exports = ReflexerRatioTrigger;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
const Action = require("../Action");
|
|
2
|
+
const {getAddr} = require("../addresses.js");
|
|
3
|
+
|
|
4
|
+
class TimestampTrigger extends Action {
|
|
5
|
+
|
|
6
|
+
constructor(nextTimestamp) {
|
|
7
|
+
super("TimestampTrigger", getAddr("TimestampTrigger"), [["uint256"]], [[...arguments]]);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
module.exports = TimestampTrigger;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
const Action = require("../Action");
|
|
2
|
+
const {getAddr} = require("../addresses.js");
|
|
3
|
+
|
|
4
|
+
class UniV3CurrentTickTrigger extends Action {
|
|
5
|
+
|
|
6
|
+
constructor(tokenId, state) {
|
|
7
|
+
super("UniV3CurrentTickTrigger", getAddr("UniV3CurrentTickTrigger"), [["uint256", "uint8"]], [[...arguments]]);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
module.exports = UniV3CurrentTickTrigger;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
const MakerRatioTrigger = require('./MakerRatioTrigger');
|
|
2
|
+
const ChainLinkPriceTrigger = require('./ChainLinkPriceTrigger');
|
|
3
|
+
const UniV3CurrentTickTrigger = require('./UniV3CurrentTickTrigger');
|
|
4
|
+
const TimestampTrigger = require('./TimestampTrigger');
|
|
5
|
+
const GasPriceTrigger = require('./GasPriceTrigger');
|
|
6
|
+
const CompoundRatioTrigger = require('./CompoundRatioTrigger');
|
|
7
|
+
const ReflexerRatioTrigger = require('./ReflexerRatioTrigger');
|
|
8
|
+
const LiquityRatioTrigger = require('./LiquityRatioTrigger');
|
|
9
|
+
|
|
10
|
+
module.exports = {
|
|
11
|
+
MakerRatioTrigger,
|
|
12
|
+
ChainLinkPriceTrigger,
|
|
13
|
+
UniV3CurrentTickTrigger,
|
|
14
|
+
TimestampTrigger,
|
|
15
|
+
GasPriceTrigger,
|
|
16
|
+
CompoundRatioTrigger,
|
|
17
|
+
ReflexerRatioTrigger,
|
|
18
|
+
LiquityRatioTrigger,
|
|
19
|
+
}
|
package/src/utils/general.js
CHANGED
|
@@ -2,6 +2,8 @@ const Dec = require('decimal.js');
|
|
|
2
2
|
const {getAssetInfo} = require('@defisaver/tokens');
|
|
3
3
|
|
|
4
4
|
module.exports.requireAddress = (address) => {
|
|
5
|
+
if (address.startsWith('%') || address.startsWith('&')) return;
|
|
6
|
+
|
|
5
7
|
if (typeof address !== 'string') throw new Error('Address is not a string');
|
|
6
8
|
if (address === '') throw new Error('Address is empty string');
|
|
7
9
|
if (address.length < 42) throw new Error(`Address too short (${address.length} instead of 42)`);
|
|
@@ -7,7 +7,6 @@ const axios = require('axios');
|
|
|
7
7
|
const {assetAmountInWei, getAssetInfo} = require('@defisaver/tokens');
|
|
8
8
|
|
|
9
9
|
const SellAction = require('../actions/basic/SellAction');
|
|
10
|
-
const BuyAction = require('../actions/basic/BuyAction');
|
|
11
10
|
const {parsePriceFromContract, formatPriceForContract} = require('./general');
|
|
12
11
|
const API_URL = 'https://api.0x.org/swap/v1/';
|
|
13
12
|
const ZEROX_WRAPPER = '0x0c4e16899f2059F4e41ddB164317414a5c0d2988';
|
|
@@ -124,7 +123,7 @@ module.exports.estimateBuyPrice = async (buyAmount, buyToken, sellToken) => esti
|
|
|
124
123
|
* @param shouldSell {Boolean} look for price to sell or to buy (if false sellToken becomes becomes buyToken and vice-versa)
|
|
125
124
|
* @param fromAccount {EthAddress} Withdraw funds from this addr
|
|
126
125
|
* @param toAccount {EthAddress} Send funds to this addr
|
|
127
|
-
* @return {Promise<(SellAction
|
|
126
|
+
* @return {Promise<(SellAction>} SellAction
|
|
128
127
|
*
|
|
129
128
|
* @private
|
|
130
129
|
*/
|
|
@@ -179,9 +178,7 @@ const createExchangeAction = async (
|
|
|
179
178
|
'0x', // wrapperData,
|
|
180
179
|
offchainDataArray,
|
|
181
180
|
];
|
|
182
|
-
return
|
|
183
|
-
? new SellAction(orderData, fromAccount, toAccount, protocolFee)
|
|
184
|
-
: new BuyAction(orderData, fromAccount, toAccount, protocolFee)
|
|
181
|
+
return new SellAction(orderData, fromAccount, toAccount, protocolFee)
|
|
185
182
|
};
|
|
186
183
|
|
|
187
184
|
/**
|
|
@@ -217,38 +214,3 @@ module.exports.createSellAction = async (
|
|
|
217
214
|
fromAccount,
|
|
218
215
|
toAccount,
|
|
219
216
|
);
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
/**
|
|
223
|
-
* Fetches prices and creates order ready to be passed to transaction.
|
|
224
|
-
* This should only be called when before sending tx, not to be used for just querying the price.
|
|
225
|
-
* For that purpose, the estimateBuyPrice method can be used.
|
|
226
|
-
*
|
|
227
|
-
* @param buyAmount {string} Amount of asset being bought ('1500.123')
|
|
228
|
-
* @param buyToken {string} Symbol for asset being bought ('DAI')
|
|
229
|
-
* @param sellToken {string} Symbol for asset being sold ('ETH')
|
|
230
|
-
* @param expectedPrice {string} Price received from estimatePrice (so minPrice can be calculated based on what user saw)
|
|
231
|
-
* @param acceptedSlippagePercent {string|Number} Slippage percentage tolerated [0-100]
|
|
232
|
-
* @param fromAccount {EthAddress} Withdraw funds from this addr
|
|
233
|
-
* @param toAccount {EthAddress} Send funds to this addr
|
|
234
|
-
* @return {Promise<BuyAction>}
|
|
235
|
-
*/
|
|
236
|
-
module.exports.createBuyAction = async (
|
|
237
|
-
buyAmount,
|
|
238
|
-
buyToken,
|
|
239
|
-
sellToken,
|
|
240
|
-
expectedPrice,
|
|
241
|
-
acceptedSlippagePercent,
|
|
242
|
-
fromAccount,
|
|
243
|
-
toAccount,
|
|
244
|
-
) => createExchangeAction(
|
|
245
|
-
sellToken,
|
|
246
|
-
buyToken,
|
|
247
|
-
'0',
|
|
248
|
-
buyAmount,
|
|
249
|
-
expectedPrice,
|
|
250
|
-
acceptedSlippagePercent,
|
|
251
|
-
false,
|
|
252
|
-
fromAccount,
|
|
253
|
-
toAccount,
|
|
254
|
-
);
|
|
@@ -626,23 +626,6 @@
|
|
|
626
626
|
]
|
|
627
627
|
]
|
|
628
628
|
],
|
|
629
|
-
"DyDxSupply": [
|
|
630
|
-
[
|
|
631
|
-
"0xA8D1C1eea86573cBcC919fbf28Db542bDfE7Ed5b",
|
|
632
|
-
[ 1, 0, 14, 5, 3, 12 ]
|
|
633
|
-
],
|
|
634
|
-
[
|
|
635
|
-
"0x1E0447b19BB6EcFdAe1e4AE1694b0C3659614e4e",
|
|
636
|
-
[ 13, 1, 12, 10, 9 ]
|
|
637
|
-
],
|
|
638
|
-
[
|
|
639
|
-
"0x5c55B921f590a89C1Ebe84dF170E655a82b62126",
|
|
640
|
-
[
|
|
641
|
-
10, 6, 1, 7,
|
|
642
|
-
0, 5, 13
|
|
643
|
-
]
|
|
644
|
-
]
|
|
645
|
-
],
|
|
646
629
|
"DyDxWithdraw": [
|
|
647
630
|
[
|
|
648
631
|
"0x55AA33F42D79DbD3f1885b410e4796d641549bC3",
|
|
@@ -893,41 +876,6 @@
|
|
|
893
876
|
[ 3, 5, 14, 7, 6, 11 ]
|
|
894
877
|
]
|
|
895
878
|
],
|
|
896
|
-
"ClaimInstMaker": [
|
|
897
|
-
[
|
|
898
|
-
"0x15E22A8160F0bDb619C6846C982F8D208A5670D2",
|
|
899
|
-
[
|
|
900
|
-
0, 12, 6, 1,
|
|
901
|
-
13, 5, 9
|
|
902
|
-
]
|
|
903
|
-
],
|
|
904
|
-
[
|
|
905
|
-
"0x2971AdFa57b20E5a416aE5a708A8655A9c74f723",
|
|
906
|
-
[ 7, 3, 9, 5, 15 ]
|
|
907
|
-
],
|
|
908
|
-
[
|
|
909
|
-
"0x5ef30b9986345249bc32d8928B7ee64DE9435E39",
|
|
910
|
-
[ 3, 8, 1, 9, 4, 7 ]
|
|
911
|
-
],
|
|
912
|
-
[
|
|
913
|
-
"0xAC838332afc2937FdED89c16a59b2ED8e8e2743c",
|
|
914
|
-
[ 10, 4, 3, 0, 1, 15 ]
|
|
915
|
-
],
|
|
916
|
-
[
|
|
917
|
-
"0x6f40d4A6237C257fff2dB00FA0510DeEECd303eb",
|
|
918
|
-
[
|
|
919
|
-
14, 11, 5, 10,
|
|
920
|
-
6, 9, 12, 13
|
|
921
|
-
]
|
|
922
|
-
],
|
|
923
|
-
[
|
|
924
|
-
"0x5c55B921f590a89C1Ebe84dF170E655a82b62126",
|
|
925
|
-
[
|
|
926
|
-
12, 4, 1, 9,
|
|
927
|
-
5, 10, 11, 0
|
|
928
|
-
]
|
|
929
|
-
]
|
|
930
|
-
],
|
|
931
879
|
"InstPullTokens": [
|
|
932
880
|
[
|
|
933
881
|
"0x37FC940Be30e11d578243dEBea4f9B950E22aC99",
|
|
@@ -1397,26 +1345,6 @@
|
|
|
1397
1345
|
[ 10, 3, 8, 13, 6, 9 ]
|
|
1398
1346
|
]
|
|
1399
1347
|
],
|
|
1400
|
-
"DFSBuy": [
|
|
1401
|
-
[
|
|
1402
|
-
"0x939dCad6A3D1fEACccB60Af90876D904468CbF66",
|
|
1403
|
-
[ 11, 5, 8, 0, 9, 12 ]
|
|
1404
|
-
],
|
|
1405
|
-
[
|
|
1406
|
-
"0x25dd3F51e0C3c3Ff164DDC02A8E4D65Bb9cBB12D",
|
|
1407
|
-
[
|
|
1408
|
-
1, 5, 3, 14,
|
|
1409
|
-
7, 11, 12, 4
|
|
1410
|
-
]
|
|
1411
|
-
],
|
|
1412
|
-
[
|
|
1413
|
-
"0x5c55B921f590a89C1Ebe84dF170E655a82b62126",
|
|
1414
|
-
[
|
|
1415
|
-
1, 3, 2, 9,
|
|
1416
|
-
0, 15, 6
|
|
1417
|
-
]
|
|
1418
|
-
]
|
|
1419
|
-
],
|
|
1420
1348
|
"SendToken": [
|
|
1421
1349
|
[
|
|
1422
1350
|
"0xBbe0D7f2AF01aE678f8A873CB2d2EB73871C9b5A",
|
|
@@ -21,7 +21,7 @@ class Recipe {
|
|
|
21
21
|
|
|
22
22
|
this.name = name;
|
|
23
23
|
this.actions = actions;
|
|
24
|
-
this.
|
|
24
|
+
this.recipeExecutorAddress = getAddr('RecipeExecutor');
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
/**
|
|
@@ -56,7 +56,7 @@ class Recipe {
|
|
|
56
56
|
encodeForDsProxyCall() {
|
|
57
57
|
const executeTaskAbi = RecipeAbi.find(({name}) => name === 'executeTask');
|
|
58
58
|
return [
|
|
59
|
-
this.
|
|
59
|
+
this.recipeExecutorAddress,
|
|
60
60
|
AbiCoder.encodeFunctionCall(executeTaskAbi, this._encodeForCall()),
|
|
61
61
|
];
|
|
62
62
|
}
|
|
@@ -107,7 +107,7 @@ class Recipe {
|
|
|
107
107
|
*/
|
|
108
108
|
getAccessList() {
|
|
109
109
|
const addressMapping = {
|
|
110
|
-
[getAddr('
|
|
110
|
+
[getAddr('RecipeExecutor')]: [],
|
|
111
111
|
[getAddr('DFSRegistry')]: [],
|
|
112
112
|
};
|
|
113
113
|
this.actions.forEach((action) => {
|
|
@@ -3,14 +3,14 @@ const {encodeForDsProxyCall, encodeForRecipe} = require('../../_actionUtils');
|
|
|
3
3
|
const {assert} = require('chai');
|
|
4
4
|
const { getAddr } = require('../../../src/addresses.js');
|
|
5
5
|
|
|
6
|
-
describe('Action:
|
|
6
|
+
describe('Action: InstPullTokensAction', () => {
|
|
7
7
|
let action;
|
|
8
8
|
|
|
9
9
|
const dsaAddress = '0x63bf1D484d7D799722b1BA9c91f5ffa6d416D60A';
|
|
10
10
|
const to = '0x0a80C3C540eEF99811f4579fa7b1A0617294e06f';
|
|
11
11
|
|
|
12
12
|
|
|
13
|
-
context('
|
|
13
|
+
context('InstPullTokensAction action test', () => {
|
|
14
14
|
it('constructor', () => {
|
|
15
15
|
action = new dfs.actions.insta.InstPullTokensAction(
|
|
16
16
|
dsaAddress,
|
|
@@ -83,12 +83,4 @@ describe('Exchange utils', () => {
|
|
|
83
83
|
}).timeout(10000);
|
|
84
84
|
})
|
|
85
85
|
|
|
86
|
-
context('Get BuyAction via 0x', function() {
|
|
87
|
-
it('Creates action', async () => {
|
|
88
|
-
const action = await exchangeUtils.createBuyAction('10000', 'DAI', 'ETH', '0', 0, myAddr, myAddr);
|
|
89
|
-
assert.instanceOf(action, dfs.actions.basic.BuyAction);
|
|
90
|
-
assert.equal(action.args[1], myAddr);
|
|
91
|
-
assert.equal(action.args[2], myAddr);
|
|
92
|
-
}).timeout(10000);
|
|
93
|
-
})
|
|
94
86
|
})
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
const Action = require("../../Action");
|
|
2
|
-
const {requireAddress} = require("../../utils/general");
|
|
3
|
-
const {getAssetInfoByAddress} = require("@defisaver/tokens");
|
|
4
|
-
const {getAddr} = require('../../addresses.js');
|
|
5
|
-
const Dec = require('decimal.js');
|
|
6
|
-
const {parsePriceFromContract} = require('../../utils/general');
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Buys an exact amount of dest token on DeFi Saver exchange aggregator
|
|
10
|
-
*/
|
|
11
|
-
class BuyAction extends Action {
|
|
12
|
-
/**
|
|
13
|
-
* @param exchangeOrder {Array} Standard DFS Exchange data
|
|
14
|
-
* @param from {string} Order sender
|
|
15
|
-
* @param to {string} Order recipient
|
|
16
|
-
* @param protocolFee {string} 0x fee (amount of ETH in Wei)
|
|
17
|
-
*/
|
|
18
|
-
constructor(exchangeOrder, from, to, protocolFee) {
|
|
19
|
-
requireAddress(to);
|
|
20
|
-
super(
|
|
21
|
-
'DFSBuy',
|
|
22
|
-
getAddr('DFSBuy'),
|
|
23
|
-
[
|
|
24
|
-
["address","address","uint256","uint256","uint256","uint256","address","address","bytes",["address","address","address","uint256","uint256","bytes"]],
|
|
25
|
-
"address",
|
|
26
|
-
"address",
|
|
27
|
-
],
|
|
28
|
-
[exchangeOrder, from, to]
|
|
29
|
-
);
|
|
30
|
-
|
|
31
|
-
this.protocolFee = protocolFee;
|
|
32
|
-
|
|
33
|
-
this.mappableArgs = [
|
|
34
|
-
this.args[0][0],
|
|
35
|
-
this.args[0][1],
|
|
36
|
-
this.args[0][3],
|
|
37
|
-
this.args[1],
|
|
38
|
-
this.args[2],
|
|
39
|
-
];
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
async getAssetsToApprove() {
|
|
43
|
-
const asset = getAssetInfoByAddress(this.args[0][0]);
|
|
44
|
-
if (asset.symbol !== 'ETH') return [{asset: this.args[0][0], owner: this.args[1]}];
|
|
45
|
-
return [];
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
async getEthValue() {
|
|
49
|
-
return this.protocolFee || '0';
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
module.exports = BuyAction;
|