@defisaver/sdk 0.2.12 → 0.2.13

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 (131) 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 -6
  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/aaveV3/AaveV3ATokenPaybackAction.js +13 -13
  12. package/src/actions/aaveV3/AaveV3BorrowAction.js +16 -16
  13. package/src/actions/aaveV3/AaveV3ClaimRewardsAction.js +8 -8
  14. package/src/actions/aaveV3/AaveV3CollateralSwitchAction.js +9 -9
  15. package/src/actions/aaveV3/AaveV3PaybackAction.js +16 -16
  16. package/src/actions/aaveV3/AaveV3SetEModeAction.js +7 -7
  17. package/src/actions/aaveV3/AaveV3SupplyAction.js +17 -17
  18. package/src/actions/aaveV3/AaveV3SwapBorrowRateModeAction.js +8 -8
  19. package/src/actions/aaveV3/AaveV3WithdrawAction.js +11 -11
  20. package/src/actions/balancer/BalancerV2ClaimAction.js +10 -12
  21. package/src/actions/balancer/BalancerV2SupplyAction.js +14 -16
  22. package/src/actions/balancer/BalancerV2WithdrawAction.js +15 -17
  23. package/src/actions/basic/AutomationV2Unsub.js +3 -3
  24. package/src/actions/basic/ChangeProxyOwnerAction.js +2 -4
  25. package/src/actions/basic/GasFeeAction.js +6 -6
  26. package/src/actions/basic/PullTokenAction.js +3 -9
  27. package/src/actions/basic/SellAction.js +5 -6
  28. package/src/actions/basic/SendTokenAction.js +3 -9
  29. package/src/actions/basic/SendTokenAndUnwrapAction.js +30 -0
  30. package/src/actions/basic/SubInputsAction.js +3 -8
  31. package/src/actions/basic/SumInputsAction.js +3 -8
  32. package/src/actions/basic/ToggleSubAction.js +19 -0
  33. package/src/actions/basic/TokenBalanceAction.js +3 -3
  34. package/src/actions/basic/UnwrapEthAction.js +3 -8
  35. package/src/actions/basic/UpdateSubAction.js +19 -0
  36. package/src/actions/basic/WrapEthAction.js +5 -8
  37. package/src/actions/basic/index.js +6 -0
  38. package/src/actions/checkers/MakerRatioCheckAction.js +5 -5
  39. package/src/actions/compound/CompoundBorrowAction.js +1 -7
  40. package/src/actions/compound/CompoundClaimAction.js +3 -3
  41. package/src/actions/compound/CompoundCollateralSwitchAction.js +2 -4
  42. package/src/actions/compound/CompoundGetDebtAction.js +3 -3
  43. package/src/actions/compound/CompoundPaybackAction.js +1 -7
  44. package/src/actions/compound/CompoundSupplyAction.js +4 -4
  45. package/src/actions/compound/CompoundWithdrawAction.js +1 -7
  46. package/src/actions/convex/ConvexClaimAction.js +60 -0
  47. package/src/actions/convex/ConvexDepositAction.js +67 -0
  48. package/src/actions/convex/ConvexWithdrawAction.js +65 -0
  49. package/src/actions/convex/index.js +9 -0
  50. package/src/actions/curve/CurveClaimFeesAction.js +4 -4
  51. package/src/actions/curve/CurveDepositAction.js +7 -7
  52. package/src/actions/curve/CurveGaugeDepositAction.js +6 -6
  53. package/src/actions/curve/CurveGaugeWithdrawAction.js +4 -4
  54. package/src/actions/curve/CurveMintCrvAction.js +3 -3
  55. package/src/actions/curve/CurveStethPoolDepositAction.js +9 -9
  56. package/src/actions/curve/CurveStethPoolWithdrawAction.js +11 -9
  57. package/src/actions/curve/CurveSwapAction.js +15 -15
  58. package/src/actions/curve/CurveWithdrawAction.js +7 -7
  59. package/src/actions/dydx/DyDxWithdrawAction.js +1 -7
  60. package/src/actions/flashloan/AaveV2FlashLoanAction.js +2 -2
  61. package/src/actions/flashloan/AaveV3FlashLoanAction.js +2 -2
  62. package/src/actions/flashloan/BalancerFlashLoanAction.js +2 -2
  63. package/src/actions/flashloan/DyDxFlashLoanAction.js +5 -1
  64. package/src/actions/flashloan/MakerFlashLoanAction.js +2 -2
  65. package/src/actions/guni/GUniDeposit.js +9 -9
  66. package/src/actions/guni/GUniWithdraw.js +5 -5
  67. package/src/actions/index.js +2 -0
  68. package/src/actions/insta/InstPullTokensAction.js +4 -4
  69. package/src/actions/lido/LidoStakeAction.js +2 -7
  70. package/src/actions/lido/LidoUnwrapAction.js +2 -7
  71. package/src/actions/lido/LidoWrapAction.js +7 -7
  72. package/src/actions/liquity/LiquityBorrowAction.js +5 -5
  73. package/src/actions/liquity/LiquityClaimAction.js +3 -3
  74. package/src/actions/liquity/LiquityCloseAction.js +4 -4
  75. package/src/actions/liquity/LiquityEthGainToTroveAction.js +3 -3
  76. package/src/actions/liquity/LiquityOpenAction.js +8 -8
  77. package/src/actions/liquity/LiquityPaybackAction.js +5 -5
  78. package/src/actions/liquity/LiquityRedeemAction.js +7 -7
  79. package/src/actions/liquity/LiquitySPDepositAction.js +7 -7
  80. package/src/actions/liquity/LiquitySPWithdrawAction.js +6 -6
  81. package/src/actions/liquity/LiquityStakeAction.js +7 -7
  82. package/src/actions/liquity/LiquitySupplyAction.js +5 -5
  83. package/src/actions/liquity/LiquityUnstakeAction.js +6 -6
  84. package/src/actions/liquity/LiquityWithdrawAction.js +4 -4
  85. package/src/actions/maker/MakerClaimAction.js +4 -4
  86. package/src/actions/maker/MakerGenerateAction.js +1 -8
  87. package/src/actions/maker/MakerGiveAction.js +4 -4
  88. package/src/actions/maker/MakerMergeAction.js +1 -7
  89. package/src/actions/maker/MakerOpenVaultAction.js +1 -6
  90. package/src/actions/maker/MakerPaybackAction.js +2 -9
  91. package/src/actions/maker/MakerRatioAction.js +1 -5
  92. package/src/actions/maker/MakerSupplyAction.js +1 -9
  93. package/src/actions/maker/MakerWithdrawAction.js +1 -9
  94. package/src/actions/mstable/MStableClaimAction.js +4 -4
  95. package/src/actions/mstable/MStableDepositAction.js +16 -16
  96. package/src/actions/mstable/MStableWithdrawAction.js +15 -15
  97. package/src/actions/rari/RariDepositAction.js +5 -5
  98. package/src/actions/rari/RariWithdrawAction.js +6 -6
  99. package/src/actions/reflexer/ReflexerGenerateAction.js +1 -7
  100. package/src/actions/reflexer/ReflexerNativeUniV2SaviourDepositAction.js +5 -5
  101. package/src/actions/reflexer/ReflexerNativeUniV2SaviourGetReservesAction.js +3 -8
  102. package/src/actions/reflexer/ReflexerNativeUniV2SaviourWithdrawAction.js +4 -9
  103. package/src/actions/reflexer/ReflexerOpenSafeAction.js +1 -5
  104. package/src/actions/reflexer/ReflexerPaybackAction.js +1 -7
  105. package/src/actions/reflexer/ReflexerSupplyAction.js +1 -8
  106. package/src/actions/reflexer/ReflexerWithdrawAction.js +1 -8
  107. package/src/actions/uniswap/UniswapSupplyAction.js +20 -22
  108. package/src/actions/uniswap/UniswapWithdrawAction.js +16 -18
  109. package/src/actions/uniswapV3/UniswapV3CollectAction.js +7 -9
  110. package/src/actions/uniswapV3/UniswapV3CreatePoolAction.js +20 -22
  111. package/src/actions/uniswapV3/UniswapV3MintAction.js +19 -21
  112. package/src/actions/uniswapV3/UniswapV3SupplyAction.js +17 -19
  113. package/src/actions/uniswapV3/UniswapV3WithdrawAction.js +12 -14
  114. package/src/actions/yearn/YearnSupplyAction.js +6 -6
  115. package/src/actions/yearn/YearnWithdrawAction.js +6 -6
  116. package/src/addresses.js +19 -12
  117. package/src/triggers/ChainLinkPriceTrigger.js +2 -2
  118. package/src/triggers/CompoundRatioTrigger.js +1 -1
  119. package/src/triggers/GasPriceTrigger.js +1 -1
  120. package/src/triggers/LiquityRatioTrigger.js +2 -2
  121. package/src/triggers/MakerRatioTrigger.js +1 -5
  122. package/src/triggers/ReflexerRatioTrigger.js +1 -1
  123. package/src/triggers/TimestampTrigger.js +1 -1
  124. package/src/triggers/UniV3CurrentTickTrigger.js +1 -1
  125. package/src/utils/convex-utils.js +20 -0
  126. package/src/utils/convexPoolInfo.json +1039 -0
  127. package/src/utils/index.js +2 -0
  128. package/test/Action.js +2 -1
  129. package/test/Strategy.js +44 -0
  130. package/test/accessLists/access-lists.js +1 -2
  131. 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.12",
3
+ "version": "0.2.13",
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.18",
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
@@ -108,12 +108,9 @@ class Action {
108
108
  * @private
109
109
  */
110
110
  _encodeForCall() {
111
- return this.args.map((arg, i) => {
112
- let paramType = this.paramTypes[i];
113
- let _arg = this._replaceWithPlaceholders(arg, paramType);
114
- let _paramType = this._formatType(paramType);
115
- return AbiCoder.encodeParameter(_paramType, _arg);
116
- });
111
+ let _arg = this._replaceWithPlaceholders(this.args, this.paramTypes);
112
+ let _paramType = this._formatType(this.paramTypes);
113
+ return [AbiCoder.encodeParameter(_paramType, _arg)];
117
114
  }
118
115
 
119
116
  encodeForL2DsProxyCall() {
@@ -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,39 +17,39 @@ class AaveV3ATokenPaybackAction extends ActionWithL2 {
17
17
  */
18
18
  constructor(useDefaultMarket, market, amount, from, rateMode, aTokenAddr, assetId) {
19
19
  super('AaveV3ATokenPayback', getAddr('AaveV3ATokenPayback'),
20
- [['uint256','address','uint8','uint16', 'bool', 'address']],
21
- [[amount, from, rateMode, assetId, useDefaultMarket, market]]
20
+ ['uint256','address','uint8','uint16', 'bool', 'address'],
21
+ [amount, from, rateMode, assetId, useDefaultMarket, market]
22
22
  );
23
23
 
24
24
  this.mappableArgs = [
25
- this.args[0][0],
26
- this.args[0][1],
27
- this.args[0][5],
25
+ this.args[0],
26
+ this.args[1],
27
+ this.args[5],
28
28
  ];
29
29
  this.addressForApproval = aTokenAddr;
30
30
  }
31
31
 
32
32
  async getAssetsToApprove() {
33
33
  const asset = getAssetInfoByAddress(this.addressForApproval);
34
- if (asset.symbol !== 'ETH') return [{asset: this.addressForApproval, owner: this.args[0][2]}];
34
+ if (asset.symbol !== 'ETH') return [{asset: this.addressForApproval, owner: this.args[2]}];
35
35
  return [];
36
36
  }
37
37
  encodeInputs() {
38
38
  // executeActionDirectL2
39
39
  let encodedInput = "0x2895f3aa";
40
40
  // amount
41
- encodedInput = encodedInput.concat(this.numberToBytes32(this.args[0][0]));
41
+ encodedInput = encodedInput.concat(this.numberToBytes32(this.args[0]));
42
42
  // from
43
- encodedInput = encodedInput.concat(this.addressToBytes20(this.args[0][1]));
43
+ encodedInput = encodedInput.concat(this.addressToBytes20(this.args[1]));
44
44
  // rateMode
45
- encodedInput = encodedInput.concat(this.numberToBytes1(this.args[0][2]));
45
+ encodedInput = encodedInput.concat(this.numberToBytes1(this.args[2]));
46
46
  // assetId
47
- encodedInput = encodedInput.concat(this.numberToBytes2(this.args[0][3]));
47
+ encodedInput = encodedInput.concat(this.numberToBytes2(this.args[3]));
48
48
  // useDefaultMarket
49
- encodedInput = encodedInput.concat(this.boolToBytes1(this.args[0][4]))
50
- if (!this.args[0][4]){
49
+ encodedInput = encodedInput.concat(this.boolToBytes1(this.args[4]))
50
+ if (!this.args[4]){
51
51
  // market
52
- encodedInput = encodedInput.concat(this.addressToBytes20(this.args[0][5]));
52
+ encodedInput = encodedInput.concat(this.addressToBytes20(this.args[5]));
53
53
  }
54
54
  return encodedInput;
55
55
  }
@@ -17,15 +17,15 @@ class AaveV3BorrowAction extends ActionWithL2 {
17
17
  */
18
18
  constructor(useDefaultMarket, market, amount, to, rateMode, assetId, useOnBehalf , onBehalf = getAddr('Empty')) {
19
19
  super('AaveV3Borrow', getAddr('AaveV3Borrow'),
20
- [['uint256','address','uint8','uint16','bool','bool','address','address']],
21
- [[amount, to, rateMode, assetId, useDefaultMarket, useOnBehalf, market, onBehalf]]
20
+ ['uint256','address','uint8','uint16','bool','bool','address','address'],
21
+ [amount, to, rateMode, assetId, useDefaultMarket, useOnBehalf, market, onBehalf]
22
22
  );
23
23
 
24
24
  this.mappableArgs = [
25
- this.args[0][0],
26
- this.args[0][1],
27
- this.args[0][6],
28
- this.args[0][7],
25
+ this.args[0],
26
+ this.args[1],
27
+ this.args[6],
28
+ this.args[7],
29
29
  ];
30
30
  }
31
31
 
@@ -33,24 +33,24 @@ class AaveV3BorrowAction extends ActionWithL2 {
33
33
  // executeActionDirectL2
34
34
  let encodedInput = "0x2895f3aa";
35
35
  // amount
36
- encodedInput = encodedInput.concat(this.numberToBytes32(this.args[0][0]));
36
+ encodedInput = encodedInput.concat(this.numberToBytes32(this.args[0]));
37
37
  // to
38
- encodedInput = encodedInput.concat(this.addressToBytes20(this.args[0][1]));
38
+ encodedInput = encodedInput.concat(this.addressToBytes20(this.args[1]));
39
39
  // rateMode
40
- encodedInput = encodedInput.concat(this.numberToBytes1(this.args[0][2]));
40
+ encodedInput = encodedInput.concat(this.numberToBytes1(this.args[2]));
41
41
  // assetId
42
- encodedInput = encodedInput.concat(this.numberToBytes2(this.args[0][3]));
42
+ encodedInput = encodedInput.concat(this.numberToBytes2(this.args[3]));
43
43
  // useDefaultMarket
44
- encodedInput = encodedInput.concat(this.boolToBytes1(this.args[0][4]))
44
+ encodedInput = encodedInput.concat(this.boolToBytes1(this.args[4]))
45
45
  // useOnBehalf
46
- encodedInput = encodedInput.concat(this.boolToBytes1(this.args[0][5]));
47
- if (!this.args[0][4]) {
46
+ encodedInput = encodedInput.concat(this.boolToBytes1(this.args[5]));
47
+ if (!this.args[4]) {
48
48
  // market
49
- encodedInput = encodedInput.concat(this.addressToBytes20(this.args[0][6]));
49
+ encodedInput = encodedInput.concat(this.addressToBytes20(this.args[6]));
50
50
  }
51
- if (this.args[0][5]) {
51
+ if (this.args[5]) {
52
52
  // onBehalf
53
- encodedInput = encodedInput.concat(this.addressToBytes20(this.args[0][7]));
53
+ encodedInput = encodedInput.concat(this.addressToBytes20(this.args[7]));
54
54
  }
55
55
  return encodedInput;
56
56
  }
@@ -16,26 +16,26 @@ class AaveV3ClaimRewardsAction extends ActionWithL2 {
16
16
  super(
17
17
  'AaveV3ClaimRewards',
18
18
  getAddr('AaveV3ClaimRewards'),
19
- [['uint8', 'uint256', 'address', 'address', 'address[]']],
20
- [[assetsLength, amount, to, reward, assets]],
19
+ ['uint8', 'uint256', 'address', 'address', 'address[]'],
20
+ [assetsLength, amount, to, reward, assets],
21
21
  );
22
22
  }
23
23
  encodeInputs() {
24
24
  // executeActionDirectL2
25
25
  let encodedInput = "0x2895f3aa";
26
26
  // assetsLength
27
- encodedInput = encodedInput.concat(this.numberToBytes1(this.args[0][0]));
27
+ encodedInput = encodedInput.concat(this.numberToBytes1(this.args[0]));
28
28
  // amount
29
- encodedInput = encodedInput.concat(this.numberToBytes32(this.args[0][1]));
29
+ encodedInput = encodedInput.concat(this.numberToBytes32(this.args[1]));
30
30
  // to
31
- encodedInput = encodedInput.concat(this.addressToBytes20(this.args[0][2]));
31
+ encodedInput = encodedInput.concat(this.addressToBytes20(this.args[2]));
32
32
  // reward
33
- encodedInput = encodedInput.concat(this.addressToBytes20(this.args[0][3]));
33
+ encodedInput = encodedInput.concat(this.addressToBytes20(this.args[3]));
34
34
  // assets
35
- const arrayLength = this.args[0][0];
35
+ const arrayLength = this.args[0];
36
36
  for (let i = 0; i < arrayLength; i++){
37
37
  // assets[i]
38
- encodedInput = encodedInput.concat(this.addressToBytes20(this.args[0][4][i]))
38
+ encodedInput = encodedInput.concat(this.addressToBytes20(this.args[4][i]))
39
39
  }
40
40
 
41
41
  return encodedInput;
@@ -16,27 +16,27 @@ class AaveV3CollateralSwitchAction extends ActionWithL2 {
16
16
  super(
17
17
  'AaveV3CollateralSwitch',
18
18
  getAddr('AaveV3CollateralSwitch'),
19
- [['uint8','bool', 'uint16[]', 'bool[]','address']],
20
- [[arrayLength, useDefaultMarket, assetIds, useAsCollateral, market]],
19
+ ['uint8','bool', 'uint16[]', 'bool[]','address'],
20
+ [arrayLength, useDefaultMarket, assetIds, useAsCollateral, market],
21
21
  );
22
22
  }
23
23
  encodeInputs() {
24
24
  // executeActionDirectL2
25
25
  let encodedInput = "0x2895f3aa";
26
26
  // arrayLength
27
- encodedInput = encodedInput.concat(this.numberToBytes1(this.args[0][0]));
27
+ encodedInput = encodedInput.concat(this.numberToBytes1(this.args[0]));
28
28
  // useDefaultMarket
29
- encodedInput = encodedInput.concat(this.boolToBytes1(this.args[0][1]));
30
- const arrayLength = this.args[0][0];
29
+ encodedInput = encodedInput.concat(this.boolToBytes1(this.args[1]));
30
+ const arrayLength = this.args[0];
31
31
  for (let i = 0; i < arrayLength; i++){
32
32
  // assetIds[i]
33
- encodedInput = encodedInput.concat(this.numberToBytes2(this.args[0][2][i]));
33
+ encodedInput = encodedInput.concat(this.numberToBytes2(this.args[2][i]));
34
34
  // useAsCollateral[i]
35
- encodedInput = encodedInput.concat(this.boolToBytes1(this.args[0][3][i]));
35
+ encodedInput = encodedInput.concat(this.boolToBytes1(this.args[3][i]));
36
36
  }
37
- if (!this.args[0][1]){
37
+ if (!this.args[1]){
38
38
  // market
39
- encodedInput = encodedInput.concat(this.addressToBytes20(this.args[0][4]));
39
+ encodedInput = encodedInput.concat(this.addressToBytes20(this.args[4]));
40
40
  }
41
41
  return encodedInput;
42
42
  }