@defisaver/sdk 0.3.6 → 0.3.7
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/actions/aaveV3/AaveV3ATokenPaybackAction.js +1 -1
- package/src/actions/aaveV3/AaveV3BorrowAction.js +20 -10
- package/src/actions/aaveV3/AaveV3PaybackAction.js +25 -11
- package/src/actions/aaveV3/AaveV3SupplyAction.js +25 -11
- package/src/actions/aaveV3/AaveV3WithdrawAction.js +16 -7
package/package.json
CHANGED
|
@@ -31,7 +31,7 @@ class AaveV3ATokenPaybackAction extends ActionWithL2 {
|
|
|
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[
|
|
34
|
+
if (asset.symbol !== 'ETH') return [{asset: this.addressForApproval, owner: this.args[1]}];
|
|
35
35
|
return [];
|
|
36
36
|
}
|
|
37
37
|
encodeInputs() {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const ActionWithL2 = require("../../ActionWithL2");
|
|
2
2
|
const { getAddr } = require('../../addresses.js');
|
|
3
|
+
const { CONFIG } = require('../../config');
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* AaveV3BorrowAction - Borrow a token from AaveV3
|
|
@@ -21,16 +22,25 @@ class AaveV3BorrowAction extends ActionWithL2 {
|
|
|
21
22
|
[amount, to, rateMode, assetId, useDefaultMarket, useOnBehalf, market, onBehalf]
|
|
22
23
|
);
|
|
23
24
|
|
|
24
|
-
|
|
25
|
-
this.
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
25
|
+
if (CONFIG.chainId === 10) {
|
|
26
|
+
this.mappableArgs = [
|
|
27
|
+
this.args[0],
|
|
28
|
+
this.args[1],
|
|
29
|
+
this.args[2],
|
|
30
|
+
this.args[3],
|
|
31
|
+
this.args[4],
|
|
32
|
+
this.args[5],
|
|
33
|
+
this.args[6],
|
|
34
|
+
this.args[7],
|
|
35
|
+
];
|
|
36
|
+
} else {
|
|
37
|
+
this.mappableArgs = [
|
|
38
|
+
this.args[0],
|
|
39
|
+
this.args[1],
|
|
40
|
+
this.args[6],
|
|
41
|
+
this.args[7],
|
|
42
|
+
];
|
|
43
|
+
}
|
|
34
44
|
}
|
|
35
45
|
|
|
36
46
|
encodeInputs() {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const ActionWithL2 = require("../../ActionWithL2");
|
|
2
2
|
const { getAssetInfoByAddress } = require("@defisaver/tokens");
|
|
3
3
|
const { getAddr } = require('../../addresses.js');
|
|
4
|
+
const { CONFIG } = require('../../config');
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* AaveV3PaybackAction - Payback debt on Aave using underlying token
|
|
@@ -23,22 +24,35 @@ class AaveV3PaybackAction extends ActionWithL2 {
|
|
|
23
24
|
[amount, from, rateMode, assetId, useOnDefaultMarket, useOnBehalf, market, onBehalf]
|
|
24
25
|
);
|
|
25
26
|
|
|
26
|
-
|
|
27
|
-
this.
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
27
|
+
if (CONFIG.chainId === 10) {
|
|
28
|
+
this.mappableArgs = [
|
|
29
|
+
this.args[0],
|
|
30
|
+
this.args[1],
|
|
31
|
+
this.args[2],
|
|
32
|
+
this.args[3],
|
|
33
|
+
this.args[4],
|
|
34
|
+
this.args[5],
|
|
35
|
+
this.args[6],
|
|
36
|
+
this.args[7],
|
|
37
|
+
];
|
|
38
|
+
} else {
|
|
39
|
+
this.mappableArgs = [
|
|
40
|
+
this.args[0],
|
|
41
|
+
this.args[1],
|
|
42
|
+
this.args[6],
|
|
43
|
+
this.args[7],
|
|
44
|
+
];
|
|
45
|
+
}
|
|
36
46
|
this.tokenForApproval = tokenAddr;
|
|
37
47
|
}
|
|
38
48
|
|
|
39
49
|
async getAssetsToApprove() {
|
|
40
50
|
const asset = getAssetInfoByAddress(this.tokenForApproval);
|
|
41
|
-
if (
|
|
51
|
+
if (CONFIG.chainId === 10) {
|
|
52
|
+
if (asset.symbol !== 'ETH') return [{asset: this.tokenForApproval, owner: this.args[1]}];
|
|
53
|
+
} else {
|
|
54
|
+
if (asset.symbol !== 'ETH') return [{asset: this.tokenForApproval, owner: this.args[3]}];
|
|
55
|
+
}
|
|
42
56
|
return [];
|
|
43
57
|
}
|
|
44
58
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const ActionWithL2 = require("../../ActionWithL2");
|
|
2
2
|
const { getAssetInfoByAddress } = require("@defisaver/tokens");
|
|
3
3
|
const { getAddr } = require('../../addresses.js');
|
|
4
|
+
const { CONFIG } = require('../../config');
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* AaveV3SupplyAction - Supply token to an aave position on Aave V3
|
|
@@ -24,22 +25,35 @@ class AaveV3SupplyAction extends ActionWithL2 {
|
|
|
24
25
|
[amount, from, assetId, enableAsColl, useDefaultMarket, useOnBehalf, market, onBehalf]
|
|
25
26
|
);
|
|
26
27
|
|
|
27
|
-
|
|
28
|
-
this.
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
28
|
+
if (CONFIG.chainId === 10) {
|
|
29
|
+
this.mappableArgs = [
|
|
30
|
+
this.args[0],
|
|
31
|
+
this.args[1],
|
|
32
|
+
this.args[2],
|
|
33
|
+
this.args[3],
|
|
34
|
+
this.args[4],
|
|
35
|
+
this.args[5],
|
|
36
|
+
this.args[6],
|
|
37
|
+
this.args[7],
|
|
38
|
+
];
|
|
39
|
+
} else {
|
|
40
|
+
this.mappableArgs = [
|
|
41
|
+
this.args[0],
|
|
42
|
+
this.args[1],
|
|
43
|
+
this.args[6],
|
|
44
|
+
this.args[7],
|
|
45
|
+
];
|
|
46
|
+
}
|
|
37
47
|
this.tokenForApproval = tokenAddress;
|
|
38
48
|
}
|
|
39
49
|
|
|
40
50
|
async getAssetsToApprove() {
|
|
41
51
|
const asset = getAssetInfoByAddress(this.tokenForApproval);
|
|
42
|
-
if (
|
|
52
|
+
if (CONFIG.chainId === 10) {
|
|
53
|
+
if (asset.symbol !== 'ETH') return [{asset: this.tokenForApproval, owner: this.args[1]}];
|
|
54
|
+
} else {
|
|
55
|
+
if (asset.symbol !== 'ETH') return [{asset: this.tokenForApproval, owner: this.args[2]}];
|
|
56
|
+
}
|
|
43
57
|
return [];
|
|
44
58
|
}
|
|
45
59
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const ActionWithL2 = require("../../ActionWithL2");
|
|
2
2
|
const { getAddr } = require('../../addresses.js');
|
|
3
|
+
const { CONFIG } = require('../../config');
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* AaveV3WithdrawAction - Withdraw a previously supplied token from a position in AaveV3
|
|
@@ -18,13 +19,21 @@ class AaveV3WithdrawAction extends ActionWithL2 {
|
|
|
18
19
|
[assetId, useDefaultMarket, amount, to, market]
|
|
19
20
|
);
|
|
20
21
|
|
|
21
|
-
|
|
22
|
-
this.
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
22
|
+
if (CONFIG.chainId === 10) {
|
|
23
|
+
this.mappableArgs = [
|
|
24
|
+
this.args[0],
|
|
25
|
+
this.args[1],
|
|
26
|
+
this.args[2],
|
|
27
|
+
this.args[3],
|
|
28
|
+
this.args[4],
|
|
29
|
+
];
|
|
30
|
+
} else {
|
|
31
|
+
this.mappableArgs = [
|
|
32
|
+
this.args[2],
|
|
33
|
+
this.args[3],
|
|
34
|
+
this.args[4],
|
|
35
|
+
];
|
|
36
|
+
}
|
|
28
37
|
}
|
|
29
38
|
encodeInputs() {
|
|
30
39
|
// executeActionDirectL2
|