@defisaver/sdk 0.2.0 → 0.2.4

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.
Files changed (113) hide show
  1. package/ACTIONS.md +379 -21
  2. package/DEV.md +0 -298
  3. package/package.json +2 -2
  4. package/src/Action.js +3 -7
  5. package/src/actions/aave/AaveBorrowAction.js +2 -11
  6. package/src/actions/aave/AaveClaimStkAaveAction.js +5 -5
  7. package/src/actions/aave/AaveCollateralSwitchAction.js +4 -5
  8. package/src/actions/aave/AavePaybackAction.js +2 -11
  9. package/src/actions/aave/AaveSupplyAction.js +6 -6
  10. package/src/actions/aave/AaveWithdrawAction.js +1 -8
  11. package/src/actions/balancer/BalancerV2ClaimAction.js +10 -12
  12. package/src/actions/balancer/BalancerV2SupplyAction.js +14 -16
  13. package/src/actions/balancer/BalancerV2WithdrawAction.js +15 -17
  14. package/src/actions/basic/AutomationV2Unsub.js +3 -3
  15. package/src/actions/basic/ChangeProxyOwnerAction.js +2 -4
  16. package/src/actions/basic/GasFeeAction.js +6 -6
  17. package/src/actions/basic/PullTokenAction.js +3 -9
  18. package/src/actions/basic/SellAction.js +5 -6
  19. package/src/actions/basic/SendTokenAction.js +3 -9
  20. package/src/actions/basic/SendTokenAndUnwrapAction.js +3 -9
  21. package/src/actions/basic/SubInputsAction.js +3 -8
  22. package/src/actions/basic/SumInputsAction.js +3 -8
  23. package/src/actions/basic/ToggleSubAction.js +19 -0
  24. package/src/actions/basic/TokenBalanceAction.js +3 -3
  25. package/src/actions/basic/UnwrapEthAction.js +3 -8
  26. package/src/actions/basic/UpdateSubAction.js +1 -1
  27. package/src/actions/basic/WrapEthAction.js +1 -5
  28. package/src/actions/basic/index.js +2 -0
  29. package/src/actions/checkers/MakerRatioCheckAction.js +5 -5
  30. package/src/actions/compound/CompoundBorrowAction.js +1 -7
  31. package/src/actions/compound/CompoundClaimAction.js +3 -3
  32. package/src/actions/compound/CompoundCollateralSwitchAction.js +2 -4
  33. package/src/actions/compound/CompoundGetDebtAction.js +3 -3
  34. package/src/actions/compound/CompoundPaybackAction.js +1 -7
  35. package/src/actions/compound/CompoundSupplyAction.js +4 -4
  36. package/src/actions/compound/CompoundWithdrawAction.js +1 -7
  37. package/src/actions/curve/CurveClaimFeesAction.js +4 -4
  38. package/src/actions/curve/CurveDepositAction.js +7 -7
  39. package/src/actions/curve/CurveGaugeDepositAction.js +6 -6
  40. package/src/actions/curve/CurveGaugeWithdrawAction.js +4 -4
  41. package/src/actions/curve/CurveMintCrvAction.js +3 -3
  42. package/src/actions/curve/CurveStethPoolDepositAction.js +9 -9
  43. package/src/actions/curve/CurveStethPoolWithdrawAction.js +11 -9
  44. package/src/actions/curve/CurveSwapAction.js +15 -15
  45. package/src/actions/curve/CurveWithdrawAction.js +7 -7
  46. package/src/actions/dydx/DyDxWithdrawAction.js +1 -7
  47. package/src/actions/flashloan/AaveV2FlashLoanAction.js +2 -2
  48. package/src/actions/flashloan/BalancerFlashLoanAction.js +2 -2
  49. package/src/actions/flashloan/DyDxFlashLoanAction.js +5 -1
  50. package/src/actions/flashloan/MakerFlashLoanAction.js +2 -2
  51. package/src/actions/guni/GUniDeposit.js +9 -9
  52. package/src/actions/guni/GUniWithdraw.js +5 -5
  53. package/src/actions/insta/InstPullTokensAction.js +4 -4
  54. package/src/actions/lido/LidoStakeAction.js +2 -7
  55. package/src/actions/lido/LidoUnwrapAction.js +2 -7
  56. package/src/actions/lido/LidoWrapAction.js +7 -7
  57. package/src/actions/liquity/LiquityBorrowAction.js +5 -5
  58. package/src/actions/liquity/LiquityClaimAction.js +3 -3
  59. package/src/actions/liquity/LiquityCloseAction.js +4 -4
  60. package/src/actions/liquity/LiquityEthGainToTroveAction.js +3 -3
  61. package/src/actions/liquity/LiquityOpenAction.js +8 -8
  62. package/src/actions/liquity/LiquityPaybackAction.js +5 -5
  63. package/src/actions/liquity/LiquityRedeemAction.js +7 -7
  64. package/src/actions/liquity/LiquitySPDepositAction.js +7 -7
  65. package/src/actions/liquity/LiquitySPWithdrawAction.js +6 -6
  66. package/src/actions/liquity/LiquityStakeAction.js +7 -7
  67. package/src/actions/liquity/LiquitySupplyAction.js +5 -5
  68. package/src/actions/liquity/LiquityUnstakeAction.js +6 -6
  69. package/src/actions/liquity/LiquityWithdrawAction.js +4 -4
  70. package/src/actions/maker/MakerClaimAction.js +4 -4
  71. package/src/actions/maker/MakerGenerateAction.js +1 -8
  72. package/src/actions/maker/MakerGiveAction.js +4 -4
  73. package/src/actions/maker/MakerMergeAction.js +1 -7
  74. package/src/actions/maker/MakerOpenVaultAction.js +1 -6
  75. package/src/actions/maker/MakerPaybackAction.js +2 -9
  76. package/src/actions/maker/MakerRatioAction.js +1 -5
  77. package/src/actions/maker/MakerSupplyAction.js +1 -9
  78. package/src/actions/maker/MakerWithdrawAction.js +1 -9
  79. package/src/actions/mstable/MStableClaimAction.js +4 -4
  80. package/src/actions/mstable/MStableDepositAction.js +16 -16
  81. package/src/actions/mstable/MStableWithdrawAction.js +15 -15
  82. package/src/actions/rari/RariDepositAction.js +5 -5
  83. package/src/actions/rari/RariWithdrawAction.js +6 -6
  84. package/src/actions/reflexer/ReflexerGenerateAction.js +1 -7
  85. package/src/actions/reflexer/ReflexerNativeUniV2SaviourDepositAction.js +5 -5
  86. package/src/actions/reflexer/ReflexerNativeUniV2SaviourGetReservesAction.js +3 -8
  87. package/src/actions/reflexer/ReflexerNativeUniV2SaviourWithdrawAction.js +4 -9
  88. package/src/actions/reflexer/ReflexerOpenSafeAction.js +1 -5
  89. package/src/actions/reflexer/ReflexerPaybackAction.js +1 -7
  90. package/src/actions/reflexer/ReflexerSupplyAction.js +1 -8
  91. package/src/actions/reflexer/ReflexerWithdrawAction.js +1 -8
  92. package/src/actions/uniswap/UniswapSupplyAction.js +20 -22
  93. package/src/actions/uniswap/UniswapWithdrawAction.js +16 -18
  94. package/src/actions/uniswapV3/UniswapV3CollectAction.js +7 -9
  95. package/src/actions/uniswapV3/UniswapV3CreatePoolAction.js +20 -22
  96. package/src/actions/uniswapV3/UniswapV3MintAction.js +19 -21
  97. package/src/actions/uniswapV3/UniswapV3SupplyAction.js +17 -19
  98. package/src/actions/uniswapV3/UniswapV3WithdrawAction.js +12 -14
  99. package/src/actions/yearn/YearnSupplyAction.js +6 -6
  100. package/src/actions/yearn/YearnWithdrawAction.js +6 -6
  101. package/src/addresses.js +3 -0
  102. package/src/triggers/ChainLinkPriceTrigger.js +2 -2
  103. package/src/triggers/CompoundRatioTrigger.js +1 -1
  104. package/src/triggers/GasPriceTrigger.js +1 -1
  105. package/src/triggers/LiquityRatioTrigger.js +3 -2
  106. package/src/triggers/MakerRatioTrigger.js +1 -5
  107. package/src/triggers/ReflexerRatioTrigger.js +2 -1
  108. package/src/triggers/TimestampTrigger.js +1 -1
  109. package/src/triggers/UniV3CurrentTickTrigger.js +1 -1
  110. package/test/Action.js +2 -1
  111. package/test/Strategy.js +44 -0
  112. package/test/accessLists/access-lists.js +1 -2
  113. package/test/actions/maker/MakerPaybackAction.js +2 -2
package/DEV.md CHANGED
@@ -1,298 +0,0 @@
1
- ## Modules
2
-
3
- <dl>
4
- <dt><a href="#utils.module_uniswapLP">uniswapLP</a></dt>
5
- <dd></dd>
6
- <dt><a href="#utils.module_uniV3">uniV3</a></dt>
7
- <dd></dd>
8
- <dt><a href="#utils.module_zeroExExchange">zeroExExchange</a></dt>
9
- <dd></dd>
10
- </dl>
11
-
12
- ## Classes
13
-
14
- <dl>
15
- <dt><a href="#Action">Action</a></dt>
16
- <dd><p>Single action that can be executed directly, or combined into a set (ie. supply a vault)</p>
17
- </dd>
18
- <dt><a href="#Recipe">Recipe</a></dt>
19
- <dd><p>Set of Actions to be performed sequentially in a single transaction</p>
20
- </dd>
21
- </dl>
22
-
23
- ## Typedefs
24
-
25
- <dl>
26
- <dt><a href="#EthAddress">EthAddress</a> : <code>string</code></dt>
27
- <dd><p>Ethereum address</p>
28
- </dd>
29
- <dt><a href="#VaultId">VaultId</a> : <code>string</code> | <code>number</code></dt>
30
- <dd><p>Maker vault ID</p>
31
- </dd>
32
- <dt><a href="#AccessListItem">AccessListItem</a> : <code>Object</code></dt>
33
- <dd><p>Access list item</p>
34
- </dd>
35
- <dt><a href="#AccessList">AccessList</a> : <code><a href="#AccessListItem">Array.&lt;AccessListItem&gt;</a></code></dt>
36
- <dd></dd>
37
- </dl>
38
-
39
- <a name="utils.module_uniswapLP"></a>
40
-
41
- ## uniswapLP
42
-
43
- * [uniswapLP](#utils.module_uniswapLP)
44
- * [.getPoolAddressByAddresses(tokenA, tokenB)](#utils.module_uniswapLP.getPoolAddressByAddresses) ⇒ [<code>EthAddress</code>](#EthAddress)
45
- * [.getPoolAddressBySymbols(symbolA, symbolB)](#utils.module_uniswapLP.getPoolAddressBySymbols) ⇒ [<code>EthAddress</code>](#EthAddress)
46
-
47
- <a name="utils.module_uniswapLP.getPoolAddressByAddresses"></a>
48
-
49
- ### uniswapLP.getPoolAddressByAddresses(tokenA, tokenB) ⇒ [<code>EthAddress</code>](#EthAddress)
50
- Computes deterministic LP address.
51
- Source: https://uniswap.org/docs/v2/javascript-SDK/getting-pair-addresses/#typescript
52
-
53
- **Kind**: static method of [<code>uniswapLP</code>](#utils.module_uniswapLP)
54
- **Params**
55
-
56
- - tokenA [<code>EthAddress</code>](#EthAddress) - Use WETH for ETH
57
- - tokenB [<code>EthAddress</code>](#EthAddress) - Use WETH for ETH
58
-
59
- <a name="utils.module_uniswapLP.getPoolAddressBySymbols"></a>
60
-
61
- ### uniswapLP.getPoolAddressBySymbols(symbolA, symbolB) ⇒ [<code>EthAddress</code>](#EthAddress)
62
- **Kind**: static method of [<code>uniswapLP</code>](#utils.module_uniswapLP)
63
- **Params**
64
-
65
- - symbolA <code>string</code>
66
- - symbolB <code>string</code>
67
-
68
- <a name="utils.module_uniV3"></a>
69
-
70
- ## uniV3
71
- <a name="utils.module_uniV3.getAssetAddrByTokenId"></a>
72
-
73
- ### uniV3.getAssetAddrByTokenId(web3, tokenId) ⇒ <code>Promise.&lt;Array.&lt;string&gt;&gt;</code>
74
- **Kind**: static method of [<code>uniV3</code>](#utils.module_uniV3)
75
- **Params**
76
-
77
- - web3 <code>Object</code> - Web3 instance
78
- - tokenId <code>string</code>
79
-
80
- <a name="utils.module_zeroExExchange"></a>
81
-
82
- ## zeroExExchange
83
-
84
- * [zeroExExchange](#utils.module_zeroExExchange)
85
- * [.estimateSellPrice(sellAmount, sellToken, buyToken)](#utils.module_zeroExExchange.estimateSellPrice) ⇒ <code>Promise.&lt;string&gt;</code>
86
- * [.estimateBuyPrice(buyAmount, buyToken, sellToken)](#utils.module_zeroExExchange.estimateBuyPrice) ⇒ <code>Promise.&lt;string&gt;</code>
87
- * [.createSellAction(sellAmount, sellToken, buyToken, expectedPrice, acceptedSlippagePercent, fromAccount, toAccount)](#utils.module_zeroExExchange.createSellAction) ⇒ <code>Promise.&lt;SellAction&gt;</code>
88
-
89
- <a name="utils.module_zeroExExchange.estimateSellPrice"></a>
90
-
91
- ### zeroExExchange.estimateSellPrice(sellAmount, sellToken, buyToken) ⇒ <code>Promise.&lt;string&gt;</code>
92
- Gets price estimate for selling a specific amount.
93
- Example: getBestExchangePrice('1', 'ETH', 'DAI') - swapping 1 ETH for some DAI
94
-
95
- **Kind**: static method of [<code>zeroExExchange</code>](#utils.module_zeroExExchange)
96
- **Returns**: <code>Promise.&lt;string&gt;</code> - price of sellToken in buyToken
97
- **Params**
98
-
99
- - sellAmount <code>String</code> - amount of sellToken (not in wei)
100
- - sellToken <code>String</code> - Symbol for asset being sold
101
- - buyToken <code>String</code> - Symbol for asset being bought
102
-
103
- <a name="utils.module_zeroExExchange.estimateBuyPrice"></a>
104
-
105
- ### zeroExExchange.estimateBuyPrice(buyAmount, buyToken, sellToken) ⇒ <code>Promise.&lt;string&gt;</code>
106
- Gets price estimate for buying a specific amount.
107
- Example: estimateBuyPrice('1000', 'DAI', 'ETH') - swapping 1000 DAI for some ETH
108
-
109
- **Kind**: static method of [<code>zeroExExchange</code>](#utils.module_zeroExExchange)
110
- **Returns**: <code>Promise.&lt;string&gt;</code> - price of sellToken in buyToken
111
- **Params**
112
-
113
- - buyAmount <code>String</code> - amount of buyToken (not in wei)
114
- - buyToken <code>String</code> - Symbol for asset being bought
115
- - sellToken <code>String</code> - Symbol for asset being sold
116
-
117
- <a name="utils.module_zeroExExchange.createSellAction"></a>
118
-
119
- ### zeroExExchange.createSellAction(sellAmount, sellToken, buyToken, expectedPrice, acceptedSlippagePercent, fromAccount, toAccount) ⇒ <code>Promise.&lt;SellAction&gt;</code>
120
- Fetches prices and creates order ready to be passed to transaction.
121
- This should only be called when before sending tx, not to be used for just querying the price.
122
- For that purpose, the estimateSellPrice method can be used.
123
-
124
- **Kind**: static method of [<code>zeroExExchange</code>](#utils.module_zeroExExchange)
125
- **Params**
126
-
127
- - sellAmount <code>string</code> - Amount of asset being sold ('1.5')
128
- - sellToken <code>string</code> - Symbol for asset being sold ('ETH')
129
- - buyToken <code>string</code> - Symbol for asset being bought ('DAI')
130
- - expectedPrice <code>string</code> - Price received from estimatePrice (so minPrice can be calculated based on what user saw)
131
- - acceptedSlippagePercent <code>string</code> | <code>Number</code> - Slippage percentage tolerated [0-100]
132
- - fromAccount [<code>EthAddress</code>](#EthAddress) - Withdraw funds from this addr
133
- - toAccount [<code>EthAddress</code>](#EthAddress) - Send funds to this addr
134
-
135
-
136
- **Kind**: static method of [<code>zeroExExchange</code>](#utils.module_zeroExExchange)
137
- **Params**
138
-
139
- - buyAmount <code>string</code> - Amount of asset being bought ('1500.123')
140
- - buyToken <code>string</code> - Symbol for asset being bought ('DAI')
141
- - sellToken <code>string</code> - Symbol for asset being sold ('ETH')
142
- - expectedPrice <code>string</code> - Price received from estimatePrice (so minPrice can be calculated based on what user saw)
143
- - acceptedSlippagePercent <code>string</code> | <code>Number</code> - Slippage percentage tolerated [0-100]
144
- - fromAccount [<code>EthAddress</code>](#EthAddress) - Withdraw funds from this addr
145
- - toAccount [<code>EthAddress</code>](#EthAddress) - Send funds to this addr
146
-
147
- <a name="Action"></a>
148
-
149
- ## Action
150
- Single action that can be executed directly, or combined into a set (ie. supply a vault)
151
-
152
- **Kind**: global class
153
-
154
- * [Action](#Action)
155
- * [new Action(name, contractAddress, paramTypes, args)](#new_Action_new)
156
- * [.encodeForDsProxyCall()](#Action+encodeForDsProxyCall) ⇒ <code>Array.&lt;string&gt;</code>
157
- * [.encodeForRecipe()](#Action+encodeForRecipe) ⇒ <code>Array.&lt;string&gt;</code>
158
- * [.getAssetsToApprove()](#Action+getAssetsToApprove) ⇒ <code>Promise.&lt;Array.&lt;{owner: string, asset: string}&gt;&gt;</code>
159
- * [.getEthValue()](#Action+getEthValue) ⇒ <code>Promise.&lt;string&gt;</code>
160
- * [.getAccessList()](#Action+getAccessList) ⇒ [<code>AccessList</code>](#AccessList)
161
-
162
- <a name="new_Action_new"></a>
163
-
164
- ### new Action(name, contractAddress, paramTypes, args)
165
- **Params**
166
-
167
- - name <code>string</code>
168
- - contractAddress <code>string</code>
169
- - paramTypes <code>Array.&lt;string&gt;</code>
170
- - args <code>Array.&lt;\*&gt;</code>
171
-
172
- <a name="Action+encodeForDsProxyCall"></a>
173
-
174
- ### action.encodeForDsProxyCall() ⇒ <code>Array.&lt;string&gt;</code>
175
- Encode arguments for calling the action via DsProxy
176
-
177
- **Kind**: instance method of [<code>Action</code>](#Action)
178
- **Returns**: <code>Array.&lt;string&gt;</code> - `address` & `data` to be passed on to DSProxy's `execute(address _target, bytes memory _data)`
179
- <a name="Action+encodeForRecipe"></a>
180
-
181
- ### action.encodeForRecipe() ⇒ <code>Array.&lt;string&gt;</code>
182
- Encodes action for Recipe call
183
-
184
- **Kind**: instance method of [<code>Action</code>](#Action)
185
- <a name="Action+getAssetsToApprove"></a>
186
-
187
- ### action.getAssetsToApprove() ⇒ <code>Promise.&lt;Array.&lt;{owner: string, asset: string}&gt;&gt;</code>
188
- Assets requiring approval to be used by DsProxy
189
- Approval is done from owner to DsProxy
190
-
191
- **Kind**: instance method of [<code>Action</code>](#Action)
192
- <a name="Action+getEthValue"></a>
193
-
194
- ### action.getEthValue() ⇒ <code>Promise.&lt;string&gt;</code>
195
- ETH value to be sent with transaction
196
-
197
- **Kind**: instance method of [<code>Action</code>](#Action)
198
- **Returns**: <code>Promise.&lt;string&gt;</code> - ETH value in wei
199
- <a name="Action+getAccessList"></a>
200
-
201
- ### action.getAccessList() ⇒ [<code>AccessList</code>](#AccessList)
202
- Access list for single action
203
-
204
- **Kind**: instance method of [<code>Action</code>](#Action)
205
- <a name="Recipe"></a>
206
-
207
- ## Recipe
208
- Set of Actions to be performed sequentially in a single transaction
209
-
210
- **Kind**: global class
211
-
212
- * [Recipe](#Recipe)
213
- * [new Recipe(name, actions)](#new_Recipe_new)
214
- * [.addAction(action)](#Recipe+addAction) ⇒ [<code>Recipe</code>](#Recipe)
215
- * [.encodeForDsProxyCall()](#Recipe+encodeForDsProxyCall) ⇒ <code>Array.&lt;string&gt;</code>
216
- * [._validateParamMappings()](#Recipe+_validateParamMappings)
217
- * [.getAssetsToApprove()](#Recipe+getAssetsToApprove) ⇒ <code>Promise.&lt;Array.&lt;{owner: string, asset: string}&gt;&gt;</code>
218
- * [.getEthValue()](#Recipe+getEthValue) ⇒ <code>Promise.&lt;string&gt;</code>
219
- * [.getAccessList()](#Recipe+getAccessList) ⇒ [<code>AccessList</code>](#AccessList)
220
-
221
- <a name="new_Recipe_new"></a>
222
-
223
- ### new Recipe(name, actions)
224
- **Params**
225
-
226
- - name <code>string</code>
227
- - actions [<code>Array.&lt;Action&gt;</code>](#Action)
228
-
229
- <a name="Recipe+addAction"></a>
230
-
231
- ### recipe.addAction(action) ⇒ [<code>Recipe</code>](#Recipe)
232
- **Kind**: instance method of [<code>Recipe</code>](#Recipe)
233
- **Params**
234
-
235
- - action [<code>Action</code>](#Action)
236
-
237
- <a name="Recipe+encodeForDsProxyCall"></a>
238
-
239
- ### recipe.encodeForDsProxyCall() ⇒ <code>Array.&lt;string&gt;</code>
240
- Encode arguments for calling the action set via DsProxy
241
-
242
- **Kind**: instance method of [<code>Recipe</code>](#Recipe)
243
- **Returns**: <code>Array.&lt;string&gt;</code> - `address` & `data` to be passed on to DSProxy's `execute(address _target, bytes memory _data)`
244
- <a name="Recipe+_validateParamMappings"></a>
245
-
246
- ### recipe.\_validateParamMappings()
247
- Logs parameter mapping in verbose format for validation. Used for testing in development.
248
-
249
- **Kind**: instance method of [<code>Recipe</code>](#Recipe)
250
- <a name="Recipe+getAssetsToApprove"></a>
251
-
252
- ### recipe.getAssetsToApprove() ⇒ <code>Promise.&lt;Array.&lt;{owner: string, asset: string}&gt;&gt;</code>
253
- Assets requiring approval to be used by DsProxy
254
- Approval is done from owner to DsProxy
255
-
256
- **Kind**: instance method of [<code>Recipe</code>](#Recipe)
257
- <a name="Recipe+getEthValue"></a>
258
-
259
- ### recipe.getEthValue() ⇒ <code>Promise.&lt;string&gt;</code>
260
- ETH value to be sent with transaction
261
-
262
- **Kind**: instance method of [<code>Recipe</code>](#Recipe)
263
- **Returns**: <code>Promise.&lt;string&gt;</code> - ETH value in wei
264
- <a name="Recipe+getAccessList"></a>
265
-
266
- ### recipe.getAccessList() ⇒ [<code>AccessList</code>](#AccessList)
267
- Generates an access list for the recipe
268
-
269
- **Kind**: instance method of [<code>Recipe</code>](#Recipe)
270
- <a name="EthAddress"></a>
271
-
272
- ## EthAddress : <code>string</code>
273
- Ethereum address
274
-
275
- **Kind**: global typedef
276
- <a name="VaultId"></a>
277
-
278
- ## VaultId : <code>string</code> \| <code>number</code>
279
- Maker vault ID
280
-
281
- **Kind**: global typedef
282
- <a name="AccessListItem"></a>
283
-
284
- ## AccessListItem : <code>Object</code>
285
- Access list item
286
-
287
- **Kind**: global typedef
288
- **Properties**
289
-
290
- | Name | Type |
291
- | --- | --- |
292
- | address | <code>string</code> |
293
- | storageKeys | <code>Array.&lt;string&gt;</code> |
294
-
295
- <a name="AccessList"></a>
296
-
297
- ## AccessList : [<code>Array.&lt;AccessListItem&gt;</code>](#AccessListItem)
298
- **Kind**: global typedef
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@defisaver/sdk",
3
- "version": "0.2.0",
3
+ "version": "0.2.4",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -13,7 +13,7 @@
13
13
  "repository": "https://github.com/DecenterApps/defisaver-sdk",
14
14
  "license": "ISC",
15
15
  "dependencies": {
16
- "@defisaver/tokens": "^1.4.7",
16
+ "@defisaver/tokens": "^1.4.12",
17
17
  "@ethersproject/address": "^5.0.10",
18
18
  "@ethersproject/solidity": "^5.0.9",
19
19
  "axios": "^0.21.1",
package/src/Action.js CHANGED
@@ -107,13 +107,9 @@ class Action {
107
107
  * @private
108
108
  */
109
109
  _encodeForCall() {
110
- const bytesEncodedArgs = this.args.map((arg, i) => {
111
- let paramType = this.paramTypes[i];
112
- let _arg = this._replaceWithPlaceholders(arg, paramType);
113
- let _paramType = this._formatType(paramType);
114
- return AbiCoder.encodeParameter(_paramType, _arg);
115
- });
116
- return bytesEncodedArgs;
110
+ let _arg = this._replaceWithPlaceholders(this.args, this.paramTypes);
111
+ let _paramType = this._formatType(this.paramTypes);
112
+ return [AbiCoder.encodeParameter(_paramType, _arg)];
117
113
  }
118
114
 
119
115
  /**
@@ -19,18 +19,9 @@ class AaveBorrowAction extends Action {
19
19
  super(
20
20
  'AaveBorrow',
21
21
  getAddr('AaveBorrow'),
22
- [['address', 'address', 'uint256', 'uint256', 'address', 'address']],
23
- [[market, tokenAddr, amount, rateMode, to, onBehalf]],
22
+ ['address', 'address', 'uint256', 'uint256', 'address', 'address'],
23
+ [market, tokenAddr, amount, rateMode, to, onBehalf],
24
24
  );
25
-
26
- this.mappableArgs = [
27
- this.args[0][0],
28
- this.args[0][1],
29
- this.args[0][2],
30
- this.args[0][3],
31
- this.args[0][4],
32
- this.args[0][5],
33
- ];
34
25
  }
35
26
  }
36
27
 
@@ -11,13 +11,13 @@ class AaveClaimStkAaveAction extends Action {
11
11
  super(
12
12
  'AaveClaimStkAave',
13
13
  getAddr('AaveClaimStkAave'),
14
- [['address[]', 'uint256', 'address']],
15
- [[...arguments]],
14
+ ['address[]', 'uint256', 'address'],
15
+ [...arguments],
16
16
  );
17
17
  this.mappableArgs = [
18
- this.args[0][1],
19
- this.args[0][2],
20
- ];
18
+ this.args[1],
19
+ this.args[2],
20
+ ];
21
21
  }
22
22
  }
23
23
 
@@ -1,6 +1,6 @@
1
1
  const Action = require("../../Action");
2
2
  const {requireAddress} = require("../../utils/general.js");
3
- const { getAddr } = require('../../addresses.js');
3
+ const {getAddr} = require('../../addresses.js');
4
4
 
5
5
  /**
6
6
  * AaveCollateralSwitchAction - Aave enable/disable token usage as collateral
@@ -10,11 +10,10 @@ class AaveCollateralSwitchAction extends Action {
10
10
  super(
11
11
  'AaveCollateralSwitch',
12
12
  getAddr('AaveCollateralSwitch'),
13
- [['address', 'address[]', 'bool[]']],
14
- [[...arguments]],
13
+ ['address', 'address[]', 'bool[]'],
14
+ [...arguments],
15
15
  );
16
- this.mappableArgs = [
17
- ];
16
+ this.mappableArgs = [];
18
17
  }
19
18
  }
20
19
 
@@ -17,18 +17,9 @@ class AavePaybackAction extends Action {
17
17
  constructor(market, tokenAddr, amount, rateMode, from, onBehalf = getAddr('Empty')) {
18
18
  super('AavePayback',
19
19
  getAddr('AavePayback'),
20
- [['address', 'address', 'uint256', 'uint256', 'address', 'address']],
21
- [[market, tokenAddr, amount, rateMode, from, onBehalf]],
20
+ ['address', 'address', 'uint256', 'uint256', 'address', 'address'],
21
+ [market, tokenAddr, amount, rateMode, from, onBehalf],
22
22
  );
23
-
24
- this.mappableArgs = [
25
- this.args[0][0],
26
- this.args[0][1],
27
- this.args[0][2],
28
- this.args[0][3],
29
- this.args[0][4],
30
- this.args[0][5],
31
- ];
32
23
  }
33
24
 
34
25
  async getAssetsToApprove() {
@@ -15,14 +15,14 @@ class AaveSupplyAction extends Action {
15
15
  * @param enableAsColl {boolean} If we need to enable asset as collateral
16
16
  */
17
17
  constructor(market, tokenAddr, amount, from, onBehalf = getAddr('Empty'), enableAsColl) {
18
- super('AaveSupply', getAddr('AaveSupply'), [['address','address','uint256','address','address','bool']], [[market, tokenAddr, amount, from, onBehalf, enableAsColl]]);
18
+ super('AaveSupply', getAddr('AaveSupply'), ['address','address','uint256','address','address','bool'], [market, tokenAddr, amount, from, onBehalf, enableAsColl]);
19
19
 
20
20
  this.mappableArgs = [
21
- this.args[0][0],
22
- this.args[0][1],
23
- this.args[0][2],
24
- this.args[0][3],
25
- this.args[0][4],
21
+ this.args[0],
22
+ this.args[1],
23
+ this.args[2],
24
+ this.args[3],
25
+ this.args[4],
26
26
  ];
27
27
  }
28
28
 
@@ -14,14 +14,7 @@ class AaveWithdrawAction extends Action {
14
14
  */
15
15
  constructor(market, tokenAddr, amount, to) {
16
16
  requireAddress(to);
17
- super('AaveWithdraw', getAddr('AaveWithdraw'), [['address','address','uint256','address']], [[...arguments]]);
18
-
19
- this.mappableArgs = [
20
- this.args[0][0],
21
- this.args[0][1],
22
- this.args[0][2],
23
- this.args[0][3],
24
- ];
17
+ super('AaveWithdraw', getAddr('AaveWithdraw'), ['address','address','uint256','address'], [...arguments]);
25
18
  }
26
19
  }
27
20
 
@@ -17,29 +17,27 @@ class BalancerV2ClaimAction extends Action {
17
17
  'BalancerV2Claim',
18
18
  getAddr('BalancerV2Claim'),
19
19
  [
20
- [
21
- "address",
22
- "address",
23
- "uint256[]",
24
- "uint256[]",
25
- "bytes32[][]",
26
- ],
20
+ "address",
21
+ "address",
22
+ "uint256[]",
23
+ "uint256[]",
24
+ "bytes32[][]",
27
25
  ],
28
- [[liquidityProvider, to, weeks, balances, merkleProofs]]
26
+ [liquidityProvider, to, weeks, balances, merkleProofs]
29
27
  );
30
28
 
31
29
  this.mappableArgs = [
32
- this.args[0][0],
33
- this.args[0][1],
30
+ this.args[0],
31
+ this.args[1],
34
32
  ];
35
33
  }
36
34
 
37
35
  async getAssetsToApprove() {
38
36
 
39
37
  const approveArr = [];
40
- if (this.args[0][0] !== this.args[0][1]){
38
+ if (this.args[0] !== this.args[1]){
41
39
  const tokenAddress = getAddr('BalancerToken');
42
- approveArr.push({asset: tokenAddress, owner: this.args[0][0]});
40
+ approveArr.push({asset: tokenAddress, owner: this.args[0]});
43
41
  }
44
42
  return approveArr;
45
43
  }
@@ -18,32 +18,30 @@ class BalancerV2SupplyAction extends Action {
18
18
  'BalancerV2Supply',
19
19
  getAddr('BalancerV2Supply'),
20
20
  [
21
- [
22
- "bytes32",
23
- "address",
24
- "address",
25
- "address[]",
26
- "uint256[]",
27
- "bytes",
28
- ],
21
+ "bytes32",
22
+ "address",
23
+ "address",
24
+ "address[]",
25
+ "uint256[]",
26
+ "bytes",
29
27
  ],
30
- [[poolId, from, to, tokens, maxAmountsIn, userData]]
28
+ [poolId, from, to, tokens, maxAmountsIn, userData]
31
29
  );
32
30
 
33
31
  this.mappableArgs = [
34
- this.args[0][1],
35
- this.args[0][2],
32
+ this.args[1],
33
+ this.args[2],
36
34
  ];
37
- for (let i = 0; i < this.args[0][4].length; i++){
38
- this.mappableArgs.push(this.args[0][4][i]);
35
+ for (let i = 0; i < this.args[4].length; i++){
36
+ this.mappableArgs.push(this.args[4][i]);
39
37
  }
40
38
  }
41
39
 
42
40
  async getAssetsToApprove() {
43
41
  const approveArr = [];
44
- const tokens = this.args[0][3];
45
- tokens.forEach(token => approveArr.push({asset: token, owner: this.args[0][1], specialApproveLabel: 'balancer'}));
46
-
42
+ const tokens = this.args[3];
43
+ tokens.forEach(token => approveArr.push({asset: token, owner: this.args[1], specialApproveLabel: 'balancer'}));
44
+
47
45
  return approveArr;
48
46
  }
49
47
  }
@@ -19,36 +19,34 @@ class BalancerV2WithdrawAction extends Action {
19
19
  'BalancerV2Withdraw',
20
20
  getAddr('BalancerV2Withdraw'),
21
21
  [
22
- [
23
- "bytes32",
24
- "address",
25
- "address",
26
- "uint256",
27
- "address[]",
28
- "uint256[]",
29
- "bytes",
30
- ],
22
+ "bytes32",
23
+ "address",
24
+ "address",
25
+ "uint256",
26
+ "address[]",
27
+ "uint256[]",
28
+ "bytes",
31
29
  ],
32
- [[poolId, from, to, lpTokenAmount, tokens, minAmountsOut, userData]]
30
+ [poolId, from, to, lpTokenAmount, tokens, minAmountsOut, userData]
33
31
  );
34
32
 
35
33
  this.from = from;
36
34
 
37
35
  this.mappableArgs = [
38
- this.args[0][1],
39
- this.args[0][2],
40
- this.args[0][3],
36
+ this.args[1],
37
+ this.args[2],
38
+ this.args[3],
41
39
  ];
42
40
 
43
- for (let i = 0; i < this.args[0][5].length; i++){
44
- this.mappableArgs.push(this.args[0][5][i]);
41
+ for (let i = 0; i < this.args[5].length; i++){
42
+ this.mappableArgs.push(this.args[5][i]);
45
43
  }
46
44
  }
47
45
 
48
46
  async getAssetsToApprove() {
49
47
  const approveArr = [];
50
- const token = this.args[0][0].slice(0,42);
51
- approveArr.push({asset: token, owner: this.args[0][1], specialApproveLabel: 'balancer'});
48
+ const token = this.args[0].slice(0,42);
49
+ approveArr.push({asset: token, owner: this.args[1], specialApproveLabel: 'balancer'});
52
50
  return approveArr;
53
51
  }
54
52
  }
@@ -6,10 +6,10 @@ class AutomationV2Unsub extends Action {
6
6
  super(
7
7
  'AutomationV2Unsub',
8
8
  getAddr('AutomationV2Unsub'),
9
- [["uint256", "uint256"]],
10
- [[cdpId, protocol]]
9
+ ["uint256", "uint256"],
10
+ [cdpId, protocol]
11
11
  );
12
12
  }
13
13
  }
14
14
 
15
- module.exports = AutomationV2Unsub;
15
+ module.exports = AutomationV2Unsub;
@@ -9,10 +9,8 @@ class ChangeProxyOwnerAction extends Action {
9
9
  * @param newOwner {Address} Address of new owner
10
10
  */
11
11
  constructor(newOwner) {
12
- super("ChangeProxyOwner", getAddr("ChangeProxyOwner"), [["address"]], [[...arguments]]);
13
-
14
- this.mappableArgs = [this.args[0][0]];
15
- }
12
+ super("ChangeProxyOwner", getAddr("ChangeProxyOwner"), ["address"], [...arguments]);
13
+ }
16
14
  }
17
15
 
18
16
  module.exports = ChangeProxyOwnerAction;
@@ -11,17 +11,17 @@ class GasFeeAction extends Action {
11
11
  constructor(gasStart, feeToken, availableAmount, dfsFeeDivider = 2000) {
12
12
  super("GasFeeTaker",
13
13
  getAddr("GasFeeTaker"),
14
- [["uint256", "address", "uint256", "uint256"]],
15
- [[gasStart, feeToken, availableAmount, dfsFeeDivider]],
14
+ ["uint256", "address", "uint256", "uint256"],
15
+ [gasStart, feeToken, availableAmount, dfsFeeDivider],
16
16
  );
17
17
 
18
18
  this.mappableArgs = [
19
- this.args[0][1],
20
- this.args[0][2],
21
- this.args[0][3],
19
+ this.args[1],
20
+ this.args[2],
21
+ this.args[3],
22
22
  ];
23
23
  }
24
24
 
25
25
  }
26
26
 
27
- module.exports = GasFeeAction;
27
+ module.exports = GasFeeAction;