@defisaver/sdk 0.3.18 → 0.3.19
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/package.json +1 -1
- package/src/ActionWithL2.js +8 -1
- package/src/actions/flashloan/AaveV3FlashLoanAction.js +1 -1
- package/src/actions/flashloan/EulerFlashLoanAction.js +24 -0
- package/src/actions/flashloan/EulerFlashLoanPaybackAction.js +16 -0
- package/src/actions/flashloan/index.js +5 -0
- package/src/actions/uniswapV3/UniswapV3CollectAction.js +3 -3
- package/src/actions/uniswapV3/UniswapV3CreatePoolAction.js +5 -4
- package/src/actions/uniswapV3/UniswapV3MintAction.js +5 -4
- package/src/actions/uniswapV3/UniswapV3SupplyAction.js +5 -4
- package/src/actions/uniswapV3/UniswapV3WithdrawAction.js +3 -3
- package/src/addresses.js +31 -2
- package/src/triggers/TrailingStopTrigger.js +11 -0
- package/src/triggers/index.js +2 -0
package/package.json
CHANGED
package/src/ActionWithL2.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
const Action = require('./Action');
|
|
2
2
|
const Dec = require('decimal.js');
|
|
3
|
+
const AbiCoder = require('web3-eth-abi');
|
|
4
|
+
const ActionAbi = require('./abis/Action.json');
|
|
3
5
|
|
|
4
6
|
class ActionWithL2 extends Action {
|
|
5
7
|
/**
|
|
@@ -10,7 +12,12 @@ class ActionWithL2 extends Action {
|
|
|
10
12
|
|
|
11
13
|
encodeForL2Recipe() { return `0x${this.encodeInputs().slice(10)}`; } // cut the method id
|
|
12
14
|
|
|
13
|
-
encodeInputs() {
|
|
15
|
+
encodeInputs() {
|
|
16
|
+
let _arg = this._replaceWithPlaceholders(this.args, this.paramTypes);
|
|
17
|
+
let _paramType = this._formatType(this.paramTypes);
|
|
18
|
+
const executeActionDirectAbi = ActionAbi.find(({ name }) => name === 'executeActionDirect');
|
|
19
|
+
return AbiCoder.encodeFunctionCall(executeActionDirectAbi, [AbiCoder.encodeParameter(_paramType, _arg)]);
|
|
20
|
+
}
|
|
14
21
|
|
|
15
22
|
addressToBytes20(address) { return address.slice(2); }
|
|
16
23
|
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
const Action = require("../../Action");
|
|
2
|
+
const { getAddr } = require('../../addresses.js');
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Gets a flashloan from Euler using their low-level one token only flashloan option
|
|
6
|
+
*/
|
|
7
|
+
class EulerFlashLoanAction extends Action {
|
|
8
|
+
/**
|
|
9
|
+
* @param tokenAddr {EthAddress}
|
|
10
|
+
* @param amount {string}
|
|
11
|
+
* @param flParamGetterAddr {EthAddress}
|
|
12
|
+
* @param flParamGetterData {bytes}
|
|
13
|
+
*/
|
|
14
|
+
constructor(tokenAddr, amount, flParamGetterAddr = getAddr('Empty'), flParamGetterData= []) {
|
|
15
|
+
super(
|
|
16
|
+
'FLEuler',
|
|
17
|
+
getAddr('FLEuler'),
|
|
18
|
+
['address[]','uint256[]', 'uint256[]', 'address', 'address', 'bytes', 'bytes'],
|
|
19
|
+
[[tokenAddr], [amount], [], getAddr('Empty'), flParamGetterAddr, flParamGetterData, []]
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
module.exports = EulerFlashLoanAction;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const SendTokenAction = require("../basic/SendTokenAction");
|
|
2
|
+
const { getAddr } = require('../../addresses.js');
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Pays back a flashloan from Euler
|
|
6
|
+
*/
|
|
7
|
+
class EulerFlashLoanPaybackAction extends SendTokenAction {
|
|
8
|
+
/**
|
|
9
|
+
* @param loanAmount {string}
|
|
10
|
+
*/
|
|
11
|
+
constructor(loanAmount, tokenAddr) {
|
|
12
|
+
super(tokenAddr, getAddr('FLEuler'), loanAmount);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
module.exports = EulerFlashLoanPaybackAction;
|
|
@@ -9,6 +9,9 @@ const MakerFlashLoanPaybackAction = require('./MakerFlashLoanPaybackAction');
|
|
|
9
9
|
const BalancerFlashLoanAction = require('./BalancerFlashLoanAction');
|
|
10
10
|
const BalancerFlashLoanPaybackAction = require('./BalancerFlashLoanPaybackAction');
|
|
11
11
|
|
|
12
|
+
const EulerFlashLoanAction = require('./EulerFlashLoanAction');
|
|
13
|
+
const EulerFlashLoanPaybackAction = require('./EulerFlashLoanPaybackAction')
|
|
14
|
+
|
|
12
15
|
module.exports = {
|
|
13
16
|
DyDxFlashLoanAction,
|
|
14
17
|
DyDxFlashLoanPaybackAction,
|
|
@@ -20,4 +23,6 @@ module.exports = {
|
|
|
20
23
|
MakerFlashLoanPaybackAction,
|
|
21
24
|
BalancerFlashLoanAction,
|
|
22
25
|
BalancerFlashLoanPaybackAction,
|
|
26
|
+
EulerFlashLoanPaybackAction,
|
|
27
|
+
EulerFlashLoanAction,
|
|
23
28
|
};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
const
|
|
2
|
-
const {getAddr} = require('../../addresses.js');
|
|
1
|
+
const ActionWithL2 = require('../../ActionWithL2');
|
|
2
|
+
const { getAddr } = require('../../addresses.js');
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Collects fees earned by user on position identified by tokenId
|
|
6
6
|
*/
|
|
7
|
-
class UniswapV3CollectAction extends
|
|
7
|
+
class UniswapV3CollectAction extends ActionWithL2 {
|
|
8
8
|
/**
|
|
9
9
|
* @param {string} tokenId
|
|
10
10
|
* @param {EthAddress} recipient
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
const
|
|
2
|
-
|
|
3
|
-
const
|
|
1
|
+
const { getAssetInfoByAddress } = require('@defisaver/tokens');
|
|
2
|
+
|
|
3
|
+
const ActionWithL2 = require('../../ActionWithL2');
|
|
4
|
+
const { getAddr } = require('../../addresses.js');
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* Create a uniswap v3 pool
|
|
7
8
|
*/
|
|
8
|
-
class UniswapV3CreatePoolAction extends
|
|
9
|
+
class UniswapV3CreatePoolAction extends ActionWithL2 {
|
|
9
10
|
/**
|
|
10
11
|
* @param {EthAddress} token0
|
|
11
12
|
* @param {EthAddress} token1
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
const
|
|
2
|
-
|
|
3
|
-
const
|
|
1
|
+
const { getAssetInfoByAddress } = require('@defisaver/tokens');
|
|
2
|
+
|
|
3
|
+
const ActionWithL2 = require('../../ActionWithL2');
|
|
4
|
+
const { getAddr } = require('../../addresses.js');
|
|
4
5
|
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Creates a new Uniswap v3 LP supply position
|
|
8
9
|
*/
|
|
9
|
-
class UniswapV3MintAction extends
|
|
10
|
+
class UniswapV3MintAction extends ActionWithL2 {
|
|
10
11
|
/**
|
|
11
12
|
* @param {EthAddress} token0
|
|
12
13
|
* @param {EthAddress} token1
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
const {getAssetInfoByAddress} = require(
|
|
2
|
-
|
|
3
|
-
const
|
|
1
|
+
const { getAssetInfoByAddress } = require('@defisaver/tokens');
|
|
2
|
+
|
|
3
|
+
const ActionWithL2 = require('../../ActionWithL2');
|
|
4
|
+
const { getAddr } = require('../../addresses.js');
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* Supplies a pair of tokens to an existing Uniswap v3 position identified by tokenId
|
|
7
8
|
*/
|
|
8
|
-
class UniswapV3SupplyAction extends
|
|
9
|
+
class UniswapV3SupplyAction extends ActionWithL2 {
|
|
9
10
|
/**
|
|
10
11
|
* @param {string} tokenId
|
|
11
12
|
* @param {string} amount0Desired
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
const
|
|
2
|
-
const {getAddr} = require('../../addresses.js');
|
|
1
|
+
const ActionWithL2 = require('../../ActionWithL2');
|
|
2
|
+
const { getAddr } = require('../../addresses.js');
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Burns liquidity, and returns underlying tokens to recipient
|
|
6
6
|
*/
|
|
7
|
-
class UniswapV3WithdrawAction extends
|
|
7
|
+
class UniswapV3WithdrawAction extends ActionWithL2 {
|
|
8
8
|
/**
|
|
9
9
|
* @param {string} tokenId
|
|
10
10
|
* @param {string} liquidity
|
package/src/addresses.js
CHANGED
|
@@ -132,6 +132,11 @@ const actionAddresses = {
|
|
|
132
132
|
CurveDeposit: '0x160225c24300bD9fAA03Bc007D5e72bDbbcA9257',
|
|
133
133
|
CurveWithdraw: '0xA2A6D75417807ebAf8364613018D697f88021771',
|
|
134
134
|
|
|
135
|
+
// Euler
|
|
136
|
+
FLEuler: '0xaf591afeCbAa4026Be377AA3cF02dA366f18DE07',
|
|
137
|
+
|
|
138
|
+
TrailingStopTrigger: '0x0000000000000000000000000000000000000000',
|
|
139
|
+
|
|
135
140
|
// Convex
|
|
136
141
|
ConvexDeposit: '0x3Ecc4F1FD5aA09D2E13Ec9ebFdF102063d66F458',
|
|
137
142
|
ConvexWithdraw: '0x2B2c235F9e27A121947c34A39d447bD4C585aA15',
|
|
@@ -156,6 +161,7 @@ const actionAddresses = {
|
|
|
156
161
|
PullToken: '0x392579E020a688068422A925c85f28bFD12a7EBB',
|
|
157
162
|
SendTokenAndUnwrap: '0x8000174366066923D554cb466e190258A6FF3b1f',
|
|
158
163
|
ToggleSub: '0x988C5C24AE6348404196267e19962f36961CAc29',
|
|
164
|
+
TokenBalance: '0xC6FF5b01f7c7b35b6e093fF70D2332B361C5Be5A',
|
|
159
165
|
|
|
160
166
|
|
|
161
167
|
// aave v3
|
|
@@ -169,11 +175,20 @@ const actionAddresses = {
|
|
|
169
175
|
AaveV3Withdraw: '0xf19d045f6cFc04A5Ee5E0e8837b565b9f276e3F7',
|
|
170
176
|
AaveV3ClaimRewards: '0xBE8e8cea67085F869C1C0040fD52F9F3115E962e',
|
|
171
177
|
|
|
178
|
+
// flashloan
|
|
172
179
|
FLAaveV3: '0x352D4a1622f2DC34c738F542934372855f219F05',
|
|
180
|
+
FLBalancer: '0x79d6bf536b8DD65909a3174C87eA6395310d5c41',
|
|
173
181
|
|
|
174
182
|
AaveV3RatioTrigger: '0xB76e3f7694589D0f34ba43b17AD0D15350Ab5f85',
|
|
175
183
|
GasFeeTakerL2: '0xB3dB299622A9DB0E944ccda2Ef899d6fF365B082',
|
|
176
184
|
AaveV3RatioCheck: '0x7A36779a7b5F1128B28932604057d5b63361297c',
|
|
185
|
+
|
|
186
|
+
// uniswap V3
|
|
187
|
+
UniCollectV3: '0xad1D55a73D6d8b2218a4aD599c88d9550fb54cd7',
|
|
188
|
+
UniMintV3: '0x7548E3923A9f9e4e182C939CC78FA30050414D12',
|
|
189
|
+
UniSupplyV3: '0x533aDec68Eed581F4a7F202493Eaf4Df77b89EC0',
|
|
190
|
+
UniWithdrawV3: '0xE920235ED2d52EcF6157BBAFedfB5bbbcF7c5825',
|
|
191
|
+
UniCreatePoolV3: '0xAF45d1380d89dB7260DC2684158c5dfA4E147d3e',
|
|
177
192
|
},
|
|
178
193
|
[NETWORKS.arbitrum.chainId]: {
|
|
179
194
|
DFSSell: '0x77c02Bb7CbBb2F896c5Ea14e1b60D65f81e552db',
|
|
@@ -185,7 +200,7 @@ const actionAddresses = {
|
|
|
185
200
|
PullToken: '0xD8B3769f74bd9F196C3416a42a91E786948898e6',
|
|
186
201
|
SendTokenAndUnwrap: '0x0fb867A5Ee1CA9426D3dAb95e613Be166218b977',
|
|
187
202
|
ToggleSub: '0x71015226EADFd4aC887fB56556F64338e352439b',
|
|
188
|
-
|
|
203
|
+
TokenBalance: '0x483B903E702F60698Dd8124558C6199922737f1F',
|
|
189
204
|
|
|
190
205
|
// aave v3
|
|
191
206
|
AaveV3ATokenPayback: '0x261906e5E0D0D38D9cBb5c10dB9c4031aabdf8C1',
|
|
@@ -197,15 +212,25 @@ const actionAddresses = {
|
|
|
197
212
|
AaveV3SwapBorrowRateMode: '0x738042389A8d6B0F6D6ab009c42dfF84ebB737C0',
|
|
198
213
|
AaveV3Withdraw: '0xbf492F869DdB1A18BB4F41b6c3059D9f882Fe7ff',
|
|
199
214
|
|
|
215
|
+
// flashloan
|
|
200
216
|
FLAaveV3: '0x3Cc0d5DAE1B94e294152C3150aA732b97af603E1',
|
|
217
|
+
FLBalancer: '0xdb28fE77709D88badC86868B27937428C3F48E73',
|
|
218
|
+
|
|
201
219
|
GasFeeTakerL2: '0x2F64f73B222B4978CAfd0295c0fa106cE5f34996',
|
|
202
220
|
AaveV3RatioCheck: '0x4a5c2cbCFB921b596Dec049389899CC8Eb4678ED',
|
|
221
|
+
|
|
222
|
+
// uniswap V3
|
|
223
|
+
UniCollectV3: '0xd521cbEfE58440d1C31FD0baF41fdfE18D028704',
|
|
224
|
+
UniMintV3: '0x7AC778fB7CaB7D368f37d6E7CE3c293077969331',
|
|
225
|
+
UniSupplyV3: '0x55675C6041A33EE9BDd796Edaa0f098AC7F3534f',
|
|
226
|
+
UniWithdrawV3: '0xa004c22eFd0CD87847DE83Ce9ab92af5382c2efe',
|
|
227
|
+
UniCreatePoolV3: '0x334Ab3C12a4c0315566fd9308880Dad71F838Dc5',
|
|
203
228
|
}
|
|
204
229
|
};
|
|
205
230
|
|
|
206
231
|
const otherAddresses = {
|
|
207
232
|
[NETWORKS.ethereum.chainId]: {
|
|
208
|
-
RecipeExecutor: '
|
|
233
|
+
RecipeExecutor: '0x1D6DEdb49AF91A11B5C5F34954FD3E8cC4f03A86',
|
|
209
234
|
DFSRegistry: '0x287778F121F134C66212FB16c9b53eC991D32f5b',
|
|
210
235
|
DFSProxyRegistry: '0x29474FdaC7142f9aB7773B8e38264FA15E3805ed',
|
|
211
236
|
ProxyRegistry: '0x4678f0a6958e4D2Bc4F1BAF7Bc52E8F3564f3fE4',
|
|
@@ -230,6 +255,8 @@ const otherAddresses = {
|
|
|
230
255
|
AdminVault: '0x136b1bEAfff362530F98f10E3D8C38f3a3F3d38C',
|
|
231
256
|
DefisaverLogger: '0xFc2f1355296ab7dd98a1260E3Ff5E906999d4Acb',
|
|
232
257
|
Empty: '0x0000000000000000000000000000000000000000',
|
|
258
|
+
|
|
259
|
+
UniswapV3PositionManager : '0xC36442b4a4522E871399CD717aBDD847Ab11FE88',
|
|
233
260
|
},
|
|
234
261
|
[NETWORKS.arbitrum.chainId]: {
|
|
235
262
|
RecipeExecutor: '0xe775c59e5662597bcE8aB4432C06380709554883',
|
|
@@ -240,6 +267,8 @@ const otherAddresses = {
|
|
|
240
267
|
AdminVault: '0xd47D8D97cAd12A866900eEc6Cde1962529F25351',
|
|
241
268
|
DefisaverLogger: '0xE6f9A5C850dbcD12bc64f40d692F537250aDEC38',
|
|
242
269
|
Empty: '0x0000000000000000000000000000000000000000',
|
|
270
|
+
|
|
271
|
+
UniswapV3PositionManager: '0xC36442b4a4522E871399CD717aBDD847Ab11FE88',
|
|
243
272
|
},
|
|
244
273
|
};
|
|
245
274
|
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
const Action = require("../Action");
|
|
2
|
+
const { getAddr } = require("../addresses.js");
|
|
3
|
+
|
|
4
|
+
class TrailingStopTrigger extends Action {
|
|
5
|
+
constructor(tokenAddr, percentage, roundId) {
|
|
6
|
+
super("TrailingStopTrigger", getAddr("TrailingStopTrigger"), ["address", "uint256", "uint80"], [...arguments]);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
module.exports = TrailingStopTrigger;
|
package/src/triggers/index.js
CHANGED
|
@@ -7,6 +7,7 @@ const CompoundRatioTrigger = require('./CompoundRatioTrigger');
|
|
|
7
7
|
const ReflexerRatioTrigger = require('./ReflexerRatioTrigger');
|
|
8
8
|
const LiquityRatioTrigger = require('./LiquityRatioTrigger');
|
|
9
9
|
const AaveV3RatioTrigger = require('./AaveV3RatioTrigger');
|
|
10
|
+
const TrailingStopTrigger = require('./TrailingStopTrigger');
|
|
10
11
|
|
|
11
12
|
module.exports = {
|
|
12
13
|
MakerRatioTrigger,
|
|
@@ -18,4 +19,5 @@ module.exports = {
|
|
|
18
19
|
ReflexerRatioTrigger,
|
|
19
20
|
LiquityRatioTrigger,
|
|
20
21
|
AaveV3RatioTrigger,
|
|
22
|
+
TrailingStopTrigger,
|
|
21
23
|
}
|