@defisaver/sdk 1.2.7-dev-liquity-v2 → 1.2.7-dev-3-liquity-v2
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/esm/src/actions/basic/SendTokensAction.d.ts +1 -1
- package/esm/src/actions/basic/SendTokensAction.js +1 -1
- package/esm/src/actions/basic/SendTokensAndUnwrapAction.d.ts +15 -0
- package/esm/src/actions/basic/SendTokensAndUnwrapAction.js +31 -0
- package/esm/src/actions/basic/index.d.ts +1 -0
- package/esm/src/actions/basic/index.js +1 -0
- package/esm/src/actions/checkers/AaveV3OpenRatioCheckAction.d.ts +16 -0
- package/esm/src/actions/checkers/AaveV3OpenRatioCheckAction.js +22 -0
- package/esm/src/actions/checkers/LiquityV2RatioCheckAction.js +1 -1
- package/esm/src/actions/checkers/index.d.ts +1 -0
- package/esm/src/actions/checkers/index.js +1 -0
- package/esm/src/actions/eulerV2/EulerV2BorrowAction.d.ts +16 -0
- package/esm/src/actions/eulerV2/EulerV2BorrowAction.js +24 -0
- package/esm/src/actions/eulerV2/EulerV2CollateralSwitchAction.d.ts +15 -0
- package/esm/src/actions/eulerV2/EulerV2CollateralSwitchAction.js +22 -0
- package/esm/src/actions/eulerV2/EulerV2PaybackAction.d.ts +22 -0
- package/esm/src/actions/eulerV2/EulerV2PaybackAction.js +40 -0
- package/esm/src/actions/eulerV2/EulerV2PaybackWithSharesAction.d.ts +16 -0
- package/esm/src/actions/eulerV2/EulerV2PaybackWithSharesAction.js +24 -0
- package/esm/src/actions/eulerV2/EulerV2PullDebtAction.d.ts +16 -0
- package/esm/src/actions/eulerV2/EulerV2PullDebtAction.js +24 -0
- package/esm/src/actions/eulerV2/EulerV2ReorderCollateralsAction.d.ts +14 -0
- package/esm/src/actions/eulerV2/EulerV2ReorderCollateralsAction.js +20 -0
- package/esm/src/actions/eulerV2/EulerV2SupplyAction.d.ts +23 -0
- package/esm/src/actions/eulerV2/EulerV2SupplyAction.js +42 -0
- package/esm/src/actions/eulerV2/EulerV2WithdrawAction.d.ts +16 -0
- package/esm/src/actions/eulerV2/EulerV2WithdrawAction.js +24 -0
- package/esm/src/actions/eulerV2/index.d.ts +8 -0
- package/esm/src/actions/eulerV2/index.js +8 -0
- package/esm/src/actions/index.d.ts +2 -1
- package/esm/src/actions/index.js +2 -1
- package/esm/src/addresses.d.ts +24 -0
- package/esm/src/addresses.js +19 -12
- package/esm/src/index.d.ts +96 -0
- package/esm/src/triggers/LiquityRatioTrigger.js +1 -1
- package/esm/src/triggers/LiquityV2RatioTrigger.js +1 -1
- package/esm/src/triggers/ShouldClosePriceTrigger.d.ts +10 -0
- package/esm/src/triggers/ShouldClosePriceTrigger.js +12 -0
- package/esm/src/triggers/index.d.ts +1 -0
- package/esm/src/triggers/index.js +1 -0
- package/package.json +1 -1
- package/src/actions/basic/SendTokensAction.ts +1 -1
- package/src/actions/basic/SendTokensAndUnwrapAction.ts +38 -0
- package/src/actions/basic/index.ts +2 -1
- package/src/actions/checkers/AaveV3OpenRatioCheckAction.ts +30 -0
- package/src/actions/checkers/LiquityV2RatioCheckAction.ts +1 -1
- package/src/actions/checkers/index.ts +2 -1
- package/src/actions/eulerV2/EulerV2BorrowAction.ts +37 -0
- package/src/actions/eulerV2/EulerV2CollateralSwitchAction.ts +34 -0
- package/src/actions/eulerV2/EulerV2PaybackAction.ts +47 -0
- package/src/actions/eulerV2/EulerV2PaybackWithSharesAction.ts +37 -0
- package/src/actions/eulerV2/EulerV2PullDebtAction.ts +37 -0
- package/src/actions/eulerV2/EulerV2ReorderCollateralsAction.ts +31 -0
- package/src/actions/eulerV2/EulerV2SupplyAction.ts +49 -0
- package/src/actions/eulerV2/EulerV2WithdrawAction.ts +37 -0
- package/src/actions/eulerV2/index.ts +8 -0
- package/src/actions/index.ts +2 -0
- package/src/addresses.ts +20 -12
- package/src/triggers/LiquityRatioTrigger.ts +1 -1
- package/src/triggers/LiquityV2RatioTrigger.ts +1 -1
- package/src/triggers/ShouldClosePriceTrigger.ts +19 -0
- package/src/triggers/index.ts +1 -0
- package/test/actions/basic/SendTokensAndUnwrapAction.js +73 -0
- package/test/actions/checkers/AaveV3OpenRatioCheckAction.js +22 -0
- package/test/actions/eulerV2/EulerV2BorrowAction.js +31 -0
- package/test/actions/eulerV2/EulerV2CollateralSwitchAction.js +28 -0
- package/test/actions/eulerV2/EulerV2PaybackAction.js +39 -0
- package/test/actions/eulerV2/EulerV2SupplyAction.js +42 -0
- package/test/actions/eulerV2/EulerV2WithdrawAction.js +31 -0
- package/umd/index.js +980 -566
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { Action } from '../../Action';
|
|
2
|
+
import { getAddr } from '../../addresses';
|
|
3
|
+
import { EthAddress, uint256 } from '../../types';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* EulerV2SupplyAction - Supply assets to a Euler vault and gets eTokens vault shares
|
|
7
|
+
*
|
|
8
|
+
* @category EulerV2
|
|
9
|
+
*/
|
|
10
|
+
export class EulerV2SupplyAction extends Action {
|
|
11
|
+
tokenForApproval: EthAddress;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @param vault The address of the supply vault
|
|
15
|
+
* @param tokenAddress Underlying token address
|
|
16
|
+
* @param account The address of the Euler account, defaults to user's wallet
|
|
17
|
+
* @param from The address from which to pull tokens to be supplied
|
|
18
|
+
* @param amount The amount of assets to supply
|
|
19
|
+
* @param enableAsColl Whether to enable supply vault as collateral
|
|
20
|
+
*/
|
|
21
|
+
constructor(
|
|
22
|
+
vault:EthAddress,
|
|
23
|
+
tokenAddress:EthAddress,
|
|
24
|
+
account:EthAddress,
|
|
25
|
+
from:EthAddress,
|
|
26
|
+
amount:uint256,
|
|
27
|
+
enableAsColl:boolean,
|
|
28
|
+
) {
|
|
29
|
+
super(
|
|
30
|
+
'EulerV2Supply',
|
|
31
|
+
getAddr('EulerV2Supply'),
|
|
32
|
+
['address', 'address', 'address', 'uint256', 'bool'],
|
|
33
|
+
[vault, account, from, amount, enableAsColl],
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
this.mappableArgs = [
|
|
37
|
+
this.args[0],
|
|
38
|
+
this.args[1],
|
|
39
|
+
this.args[2],
|
|
40
|
+
this.args[3],
|
|
41
|
+
this.args[4],
|
|
42
|
+
];
|
|
43
|
+
this.tokenForApproval = tokenAddress;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
async getAssetsToApprove() {
|
|
47
|
+
return [{ asset: this.tokenForApproval, owner: this.args[2] }];
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Action } from '../../Action';
|
|
2
|
+
import { getAddr } from '../../addresses';
|
|
3
|
+
import { EthAddress, uint256 } from '../../types';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* EulerV2WithdrawAction - Withdraws assets from Euler vault
|
|
7
|
+
*
|
|
8
|
+
* @category EulerV2
|
|
9
|
+
*/
|
|
10
|
+
export class EulerV2WithdrawAction extends Action {
|
|
11
|
+
/**
|
|
12
|
+
* @param vault The address of the Euler vault
|
|
13
|
+
* @param account The address of the Euler account, defaults to user's wallet
|
|
14
|
+
* @param receiver The address to receive the withdrawn assets
|
|
15
|
+
* @param amount The amount of assets to withdraw (uint256.max for max withdrawal)
|
|
16
|
+
*/
|
|
17
|
+
constructor(
|
|
18
|
+
vault:EthAddress,
|
|
19
|
+
account:EthAddress,
|
|
20
|
+
receiver:EthAddress,
|
|
21
|
+
amount:uint256,
|
|
22
|
+
) {
|
|
23
|
+
super(
|
|
24
|
+
'EulerV2Withdraw',
|
|
25
|
+
getAddr('EulerV2Withdraw'),
|
|
26
|
+
['address', 'address', 'address', 'uint256'],
|
|
27
|
+
[vault, account, receiver, amount],
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
this.mappableArgs = [
|
|
31
|
+
this.args[0],
|
|
32
|
+
this.args[1],
|
|
33
|
+
this.args[2],
|
|
34
|
+
this.args[3],
|
|
35
|
+
];
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from './EulerV2SupplyAction';
|
|
2
|
+
export * from './EulerV2WithdrawAction';
|
|
3
|
+
export * from './EulerV2BorrowAction';
|
|
4
|
+
export * from './EulerV2PaybackAction';
|
|
5
|
+
export * from './EulerV2PaybackWithSharesAction';
|
|
6
|
+
export * from './EulerV2PullDebtAction';
|
|
7
|
+
export * from './EulerV2ReorderCollateralsAction';
|
|
8
|
+
export * from './EulerV2CollateralSwitchAction';
|
package/src/actions/index.ts
CHANGED
|
@@ -29,6 +29,7 @@ import * as spark from './spark';
|
|
|
29
29
|
import * as morphoblue from './morpho-blue';
|
|
30
30
|
import * as llamalend from './llamalend';
|
|
31
31
|
import * as merkl from './merkl';
|
|
32
|
+
import * as eulerV2 from './eulerV2';
|
|
32
33
|
import * as sky from './sky';
|
|
33
34
|
import * as liquityV2 from './liquityV2';
|
|
34
35
|
|
|
@@ -64,6 +65,7 @@ export {
|
|
|
64
65
|
morphoblue,
|
|
65
66
|
llamalend,
|
|
66
67
|
merkl,
|
|
68
|
+
eulerV2,
|
|
67
69
|
sky,
|
|
68
70
|
liquityV2,
|
|
69
71
|
};
|
package/src/addresses.ts
CHANGED
|
@@ -174,18 +174,18 @@ export const actionAddresses = {
|
|
|
174
174
|
LiquityAdjust: '0x0A398f6B97677192A5d5e7Ea8A937383FFf9304c',
|
|
175
175
|
|
|
176
176
|
// liquity v2
|
|
177
|
-
LiquityV2Open: '
|
|
178
|
-
LiquityV2Close: '
|
|
179
|
-
LiquityV2Supply: '
|
|
180
|
-
LiquityV2Withdraw: '
|
|
181
|
-
LiquityV2Borrow: '
|
|
182
|
-
LiquityV2Payback: '
|
|
183
|
-
LiquityV2Claim: '
|
|
184
|
-
LiquityV2Adjust: '
|
|
185
|
-
LiquityV2AdjustInterestRate: '
|
|
186
|
-
LiquityV2SPDeposit: '
|
|
187
|
-
LiquityV2SPWithdraw: '
|
|
188
|
-
LiquityV2SPClaimColl: '
|
|
177
|
+
LiquityV2Open: '0x7DC97868B4b2Fd31c1002E9bfFe9a4aF2b534c06',
|
|
178
|
+
LiquityV2Close: '0x2EA69De9d5913959A8A89E4c0773Ce0c98Eefe2C',
|
|
179
|
+
LiquityV2Supply: '0x8Fd1872a2936FF90C83088f47deE582f106297C1',
|
|
180
|
+
LiquityV2Withdraw: '0x544e1a68A2CC8C5d2aE5493CdE472293a89f27A1',
|
|
181
|
+
LiquityV2Borrow: '0xDDCcE054Ea32dc857A2D7Cf87E55310Feb2DD86c',
|
|
182
|
+
LiquityV2Payback: '0x3f7e7C1E239ea2bb74990D915f1C318f86CbC6BE',
|
|
183
|
+
LiquityV2Claim: '0xA32FDa33e344a48dB9098C702a25E2341f96CF8b',
|
|
184
|
+
LiquityV2Adjust: '0xE093C5fbb251CbE6331A7D6db59153b3b32C6940',
|
|
185
|
+
LiquityV2AdjustInterestRate: '0x73Aa73142Ed0FE25929f6Ea1Cb34586bB938Cc53',
|
|
186
|
+
LiquityV2SPDeposit: '0x2aEEC1D33dD9D5fBEfC2A210Cf6B853D7B740EBF',
|
|
187
|
+
LiquityV2SPWithdraw: '0xaA2620B0Bcb07818CC6C4C33B2b5e45AEc290C36',
|
|
188
|
+
LiquityV2SPClaimColl: '0x8b946Be515f106930E82E50A31093c8e76C11034',
|
|
189
189
|
|
|
190
190
|
// b.protocol
|
|
191
191
|
BprotocolLiquitySPDeposit: '0x5A0436c7559e37da8cD24B0f66C155a0a2fd6309',
|
|
@@ -297,6 +297,14 @@ export const actionAddresses = {
|
|
|
297
297
|
LlamaLendLevCreate: '0x534b704a62385cfe5EEB8d9605419743d4fe105E',
|
|
298
298
|
LlamaLendSelfLiquidateWithColl: '0xA99DD1D91141cA63C423DB763dE75078336803B2',
|
|
299
299
|
|
|
300
|
+
// eulerV2
|
|
301
|
+
EulerV2Supply: '0xa067787D086841437D112e0C847dDB3e5D95173f',
|
|
302
|
+
EulerV2Withdraw: '0x5bf1a54fe1e65B134E7920e53A5eB0D14b9e6aD1',
|
|
303
|
+
EulerV2Borrow: '0x38d66ecD38b7800D8FD0Bc29489c2306170a9Ede',
|
|
304
|
+
EulerV2Payback: '0x738b1df6b6962D8795Bda5bc5EFCd8b0B8c74d01',
|
|
305
|
+
EulerV2CollateralSwitch: '0x38950b50Fb38aC19D06e8CE5AAE632D6dF1EEb1a',
|
|
306
|
+
EulerV2View: '0x8932E46Ecf96b5Fe033F5e27Ab6dC755Cb668967',
|
|
307
|
+
|
|
300
308
|
MerklClaim: '0xE88036F3F0D7e216D63726356cA2bC334e305fe5',
|
|
301
309
|
},
|
|
302
310
|
[NETWORKS.optimism.chainId]: {
|
|
@@ -9,7 +9,7 @@ export class LiquityV2RatioTrigger extends Action {
|
|
|
9
9
|
constructor(market: EthAddress, troveId: uint256, ratio:uint256, state:uint8) {
|
|
10
10
|
super(
|
|
11
11
|
'LiquityV2RatioTrigger',
|
|
12
|
-
getAddr('
|
|
12
|
+
getAddr('Empty'),
|
|
13
13
|
['address', 'uint256', 'uint256', 'uint8'],
|
|
14
14
|
[market, troveId, ratio, state],
|
|
15
15
|
);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Action } from '../Action';
|
|
2
|
+
import { getAddr } from '../addresses';
|
|
3
|
+
import { EthAddress, uint256 } from '../types';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
*
|
|
7
|
+
*
|
|
8
|
+
* @category Triggers
|
|
9
|
+
*/
|
|
10
|
+
export class ShouldClosePriceTrigger extends Action {
|
|
11
|
+
constructor(token:EthAddress, lowerPrice:uint256, upperPrice:uint256) {
|
|
12
|
+
super(
|
|
13
|
+
'ShouldClosePriceTrigger',
|
|
14
|
+
getAddr('Empty'),
|
|
15
|
+
['address', 'uint256', 'uint256'],
|
|
16
|
+
[token, lowerPrice, upperPrice],
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
}
|
package/src/triggers/index.ts
CHANGED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
const dfs = require('../../../src');
|
|
2
|
+
const {assetAmountInWei} = require("@defisaver/tokens");
|
|
3
|
+
const {getAssetInfo} = require("@defisaver/tokens");
|
|
4
|
+
const {encodeForDsProxyCall, encodeForRecipe} = require('../../_actionUtils');
|
|
5
|
+
const {assert} = require('chai');
|
|
6
|
+
|
|
7
|
+
describe('Action: SendTokensAndUnwrap', () => {
|
|
8
|
+
let action;
|
|
9
|
+
context('Transfer DAI/USDC', () => {
|
|
10
|
+
const tokens = [getAssetInfo('DAI').address, getAssetInfo('USDC').address];
|
|
11
|
+
const amounts = [assetAmountInWei(1, 'DAI'), assetAmountInWei(1, 'USDC')];
|
|
12
|
+
const receivers = ['0x0a80C3C540eEF99811f4579fa7b1A0617294e06f', '0xf0e1a5f7445211E47faa6D267Fc5A214884557aa'];
|
|
13
|
+
it('constructor', () => {
|
|
14
|
+
action = new dfs.actions.basic.SendTokensAndUnwrapAction(
|
|
15
|
+
tokens,
|
|
16
|
+
receivers,
|
|
17
|
+
amounts
|
|
18
|
+
);
|
|
19
|
+
assert.equal(action.mappableArgs[0], getAssetInfo('DAI').address);
|
|
20
|
+
assert.equal(action.mappableArgs[1], getAssetInfo('USDC').address);
|
|
21
|
+
assert.equal(action.mappableArgs[2], receivers[0]);
|
|
22
|
+
assert.equal(action.mappableArgs[3], receivers[1]);
|
|
23
|
+
assert.equal(action.mappableArgs[4], assetAmountInWei(1, 'DAI'));
|
|
24
|
+
assert.equal(action.mappableArgs[5], assetAmountInWei(1, 'USDC'));
|
|
25
|
+
})
|
|
26
|
+
it('encodeForDsProxyCall', () => encodeForDsProxyCall(action));
|
|
27
|
+
it('encodeForRecipe', () => encodeForRecipe(action));
|
|
28
|
+
it('getEthValue', async () => {
|
|
29
|
+
const ethValue = await action.getEthValue();
|
|
30
|
+
assert.equal(ethValue, '0');
|
|
31
|
+
})
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
context('Transfer DAI/WETH', () => {
|
|
35
|
+
const tokens = [
|
|
36
|
+
getAssetInfo('DAI').address,
|
|
37
|
+
getAssetInfo('WETH').address,
|
|
38
|
+
getAssetInfo('WETH').address
|
|
39
|
+
];
|
|
40
|
+
const amounts = [
|
|
41
|
+
assetAmountInWei(1, 'DAI'),
|
|
42
|
+
assetAmountInWei(1, 'WETH'),
|
|
43
|
+
assetAmountInWei(100, 'WETH'),
|
|
44
|
+
];
|
|
45
|
+
const receivers = [
|
|
46
|
+
'0x0a80C3C540eEF99811f4579fa7b1A0617294e06f',
|
|
47
|
+
'0xf0e1a5f7445211E47faa6D267Fc5A214884557aa',
|
|
48
|
+
'0x0a80C3C540eEF99811f4579fa7b1A0617294e06f'
|
|
49
|
+
];
|
|
50
|
+
it('constructor', () => {
|
|
51
|
+
action = new dfs.actions.basic.SendTokensAndUnwrapAction(
|
|
52
|
+
tokens,
|
|
53
|
+
receivers,
|
|
54
|
+
amounts
|
|
55
|
+
);
|
|
56
|
+
action.mappableArgs[0] = getAssetInfo('DAI').address;
|
|
57
|
+
action.mappableArgs[1] = getAssetInfo('WETH').address;
|
|
58
|
+
action.mappableArgs[2] = getAssetInfo('WETH').address;
|
|
59
|
+
action.mappableArgs[3] = receivers[0];
|
|
60
|
+
action.mappableArgs[4] = receivers[1];
|
|
61
|
+
action.mappableArgs[5] = receivers[2];
|
|
62
|
+
action.mappableArgs[6] = assetAmountInWei(1, 'DAI');
|
|
63
|
+
action.mappableArgs[7] = assetAmountInWei(1, 'WETH');
|
|
64
|
+
action.mappableArgs[8] = assetAmountInWei(100, 'WETH');
|
|
65
|
+
})
|
|
66
|
+
it('encodeForDsProxyCall', () => encodeForDsProxyCall(action));
|
|
67
|
+
it('encodeForRecipe', () => encodeForRecipe(action));
|
|
68
|
+
it('getEthValue', async () => {
|
|
69
|
+
const ethValue = await action.getEthValue();
|
|
70
|
+
assert.equal(ethValue, '0');
|
|
71
|
+
})
|
|
72
|
+
})
|
|
73
|
+
})
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
|
|
2
|
+
const dfs = require('../../../src');
|
|
3
|
+
const {encodeForDsProxyCall, encodeForRecipe} = require('../../_actionUtils');
|
|
4
|
+
const {assert} = require('chai');
|
|
5
|
+
|
|
6
|
+
describe('Action: AaveV3OpenRatioCheckAction', () => {
|
|
7
|
+
let action;
|
|
8
|
+
context('AaveV3OpenRatioCheckAction', () => {
|
|
9
|
+
it('constructor', () => {
|
|
10
|
+
const targetRatio = '150'
|
|
11
|
+
const market = '0x24a42fD28C976A61Df5D00D0599C34c4f90748c8';
|
|
12
|
+
action = new dfs.actions.checkers.AaveV3OpenRatioCheckAction(
|
|
13
|
+
targetRatio,
|
|
14
|
+
market
|
|
15
|
+
);
|
|
16
|
+
assert.equal(action.args[0], targetRatio);
|
|
17
|
+
assert.equal(action.args[1], market);
|
|
18
|
+
})
|
|
19
|
+
it('encodeForDsProxyCall', () => encodeForDsProxyCall(action));
|
|
20
|
+
it('encodeForRecipe', () => encodeForRecipe(action));
|
|
21
|
+
})
|
|
22
|
+
})
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
const dfs = require('../../../src');
|
|
2
|
+
const {encodeForDsProxyCall, encodeForRecipe} = require('../../_actionUtils');
|
|
3
|
+
const {assert} = require('chai');
|
|
4
|
+
|
|
5
|
+
describe('Action: EulerV2BorrowAction', () => {
|
|
6
|
+
let action;
|
|
7
|
+
context('Borrow 100 USDC', () => {
|
|
8
|
+
it('constructor', () => {
|
|
9
|
+
const usdcVault = '0x797DD80692c3b2dAdabCe8e30C07fDE5307D48a9';
|
|
10
|
+
const account = '0x968Cc941aD9074EE687E0423a33E6f2D33d7c327';
|
|
11
|
+
const receiver = '0x80788de454ad3681d357dc7FcB13c72333f684a7';
|
|
12
|
+
const amount = 100;
|
|
13
|
+
action = new dfs.actions.eulerV2.EulerV2BorrowAction(
|
|
14
|
+
usdcVault,
|
|
15
|
+
account,
|
|
16
|
+
receiver,
|
|
17
|
+
amount
|
|
18
|
+
);
|
|
19
|
+
assert.equal(action.args[0], usdcVault);
|
|
20
|
+
assert.equal(action.args[1], account);
|
|
21
|
+
assert.equal(action.args[2], receiver);
|
|
22
|
+
assert.equal(action.args[3], amount);
|
|
23
|
+
})
|
|
24
|
+
it('encodeForDsProxyCall', () => encodeForDsProxyCall(action));
|
|
25
|
+
it('encodeForRecipe', () => encodeForRecipe(action));
|
|
26
|
+
it('getEthValue', async () => {
|
|
27
|
+
const ethValue = await action.getEthValue();
|
|
28
|
+
assert.equal(ethValue, '0');
|
|
29
|
+
})
|
|
30
|
+
})
|
|
31
|
+
})
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
const dfs = require('../../../src');
|
|
2
|
+
const {encodeForDsProxyCall, encodeForRecipe} = require('../../_actionUtils');
|
|
3
|
+
const {assert} = require('chai');
|
|
4
|
+
|
|
5
|
+
describe('Action: EulerV2CollateralSwitchAction', () => {
|
|
6
|
+
let action;
|
|
7
|
+
context('Enable collateral', () => {
|
|
8
|
+
it('constructor', () => {
|
|
9
|
+
const usdcVault = '0x797DD80692c3b2dAdabCe8e30C07fDE5307D48a9';
|
|
10
|
+
const account = '0x968Cc941aD9074EE687E0423a33E6f2D33d7c327';
|
|
11
|
+
const enableAsCollateral = true;
|
|
12
|
+
action = new dfs.actions.eulerV2.EulerV2CollateralSwitchAction(
|
|
13
|
+
usdcVault,
|
|
14
|
+
account,
|
|
15
|
+
enableAsCollateral
|
|
16
|
+
);
|
|
17
|
+
assert.equal(action.args[0], usdcVault);
|
|
18
|
+
assert.equal(action.args[1], account);
|
|
19
|
+
assert.equal(action.args[2], enableAsCollateral);
|
|
20
|
+
})
|
|
21
|
+
it('encodeForDsProxyCall', () => encodeForDsProxyCall(action));
|
|
22
|
+
it('encodeForRecipe', () => encodeForRecipe(action));
|
|
23
|
+
it('getEthValue', async () => {
|
|
24
|
+
const ethValue = await action.getEthValue();
|
|
25
|
+
assert.equal(ethValue, '0');
|
|
26
|
+
})
|
|
27
|
+
})
|
|
28
|
+
})
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
const dfs = require('../../../src');
|
|
2
|
+
const {getAssetInfo} = require("@defisaver/tokens");
|
|
3
|
+
const {encodeForDsProxyCall, encodeForRecipe} = require('../../_actionUtils');
|
|
4
|
+
const {assert} = require('chai');
|
|
5
|
+
|
|
6
|
+
describe('Action: EulerV2PaybackAction', () => {
|
|
7
|
+
let action;
|
|
8
|
+
const from = '0x80788de454ad3681d357dc7FcB13c72333f684a7';
|
|
9
|
+
context('Payback 100 USDC', () => {
|
|
10
|
+
it('constructor', () => {
|
|
11
|
+
const usdcVault = '0x797DD80692c3b2dAdabCe8e30C07fDE5307D48a9';
|
|
12
|
+
const account = '0x968Cc941aD9074EE687E0423a33E6f2D33d7c327';
|
|
13
|
+
const amount = 100;
|
|
14
|
+
action = new dfs.actions.eulerV2.EulerV2PaybackAction(
|
|
15
|
+
usdcVault,
|
|
16
|
+
getAssetInfo('USDC').address,
|
|
17
|
+
account,
|
|
18
|
+
from,
|
|
19
|
+
amount,
|
|
20
|
+
);
|
|
21
|
+
assert.equal(action.args[0], usdcVault);
|
|
22
|
+
assert.equal(action.args[1], account);
|
|
23
|
+
assert.equal(action.args[2], from);
|
|
24
|
+
assert.equal(action.args[3], amount);
|
|
25
|
+
})
|
|
26
|
+
it('encodeForDsProxyCall', () => encodeForDsProxyCall(action));
|
|
27
|
+
it('encodeForRecipe', () => encodeForRecipe(action));
|
|
28
|
+
it('getEthValue', async () => {
|
|
29
|
+
const ethValue = await action.getEthValue();
|
|
30
|
+
assert.equal(ethValue, '0');
|
|
31
|
+
})
|
|
32
|
+
it('getAssetsToApprove', async () => {
|
|
33
|
+
const assetOwnerPairs = await action.getAssetsToApprove();
|
|
34
|
+
assert.lengthOf(assetOwnerPairs, 1);
|
|
35
|
+
assert.equal(assetOwnerPairs[0].asset, getAssetInfo('USDC').address);
|
|
36
|
+
assert.equal(assetOwnerPairs[0].owner, from);
|
|
37
|
+
})
|
|
38
|
+
})
|
|
39
|
+
})
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
const dfs = require('../../../src');
|
|
2
|
+
const {getAssetInfo} = require("@defisaver/tokens");
|
|
3
|
+
const {encodeForDsProxyCall, encodeForRecipe} = require('../../_actionUtils');
|
|
4
|
+
const {assert} = require('chai');
|
|
5
|
+
|
|
6
|
+
describe('Action: EulerV2SupplyAction', () => {
|
|
7
|
+
let action;
|
|
8
|
+
const from = '0x80788de454ad3681d357dc7FcB13c72333f684a7';
|
|
9
|
+
context('Supply 100 USDC', () => {
|
|
10
|
+
it('constructor', () => {
|
|
11
|
+
const usdcVault = '0x797DD80692c3b2dAdabCe8e30C07fDE5307D48a9';
|
|
12
|
+
const account = '0x968Cc941aD9074EE687E0423a33E6f2D33d7c327';
|
|
13
|
+
const amount = 100;
|
|
14
|
+
const enableAsCollateral = true;
|
|
15
|
+
action = new dfs.actions.eulerV2.EulerV2SupplyAction(
|
|
16
|
+
usdcVault,
|
|
17
|
+
getAssetInfo('USDC').address,
|
|
18
|
+
account,
|
|
19
|
+
from,
|
|
20
|
+
amount,
|
|
21
|
+
enableAsCollateral
|
|
22
|
+
);
|
|
23
|
+
assert.equal(action.args[0], usdcVault);
|
|
24
|
+
assert.equal(action.args[1], account);
|
|
25
|
+
assert.equal(action.args[2], from);
|
|
26
|
+
assert.equal(action.args[3], amount);
|
|
27
|
+
assert.equal(action.args[4], enableAsCollateral);
|
|
28
|
+
})
|
|
29
|
+
it('encodeForDsProxyCall', () => encodeForDsProxyCall(action));
|
|
30
|
+
it('encodeForRecipe', () => encodeForRecipe(action));
|
|
31
|
+
it('getEthValue', async () => {
|
|
32
|
+
const ethValue = await action.getEthValue();
|
|
33
|
+
assert.equal(ethValue, '0');
|
|
34
|
+
})
|
|
35
|
+
it('getAssetsToApprove', async () => {
|
|
36
|
+
const assetOwnerPairs = await action.getAssetsToApprove();
|
|
37
|
+
assert.lengthOf(assetOwnerPairs, 1);
|
|
38
|
+
assert.equal(assetOwnerPairs[0].asset, getAssetInfo('USDC').address);
|
|
39
|
+
assert.equal(assetOwnerPairs[0].owner, from);
|
|
40
|
+
})
|
|
41
|
+
})
|
|
42
|
+
})
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
const dfs = require('../../../src');
|
|
2
|
+
const {encodeForDsProxyCall, encodeForRecipe} = require('../../_actionUtils');
|
|
3
|
+
const {assert} = require('chai');
|
|
4
|
+
|
|
5
|
+
describe('Action: EulerV2WithdrawAction', () => {
|
|
6
|
+
let action;
|
|
7
|
+
context('Withdraw 100 USDC', () => {
|
|
8
|
+
it('constructor', () => {
|
|
9
|
+
const usdcVault = '0x797DD80692c3b2dAdabCe8e30C07fDE5307D48a9';
|
|
10
|
+
const account = '0x968Cc941aD9074EE687E0423a33E6f2D33d7c327';
|
|
11
|
+
const receiver = '0x80788de454ad3681d357dc7FcB13c72333f684a7';
|
|
12
|
+
const amount = 100;
|
|
13
|
+
action = new dfs.actions.eulerV2.EulerV2WithdrawAction(
|
|
14
|
+
usdcVault,
|
|
15
|
+
account,
|
|
16
|
+
receiver,
|
|
17
|
+
amount
|
|
18
|
+
);
|
|
19
|
+
assert.equal(action.args[0], usdcVault);
|
|
20
|
+
assert.equal(action.args[1], account);
|
|
21
|
+
assert.equal(action.args[2], receiver);
|
|
22
|
+
assert.equal(action.args[3], amount);
|
|
23
|
+
})
|
|
24
|
+
it('encodeForDsProxyCall', () => encodeForDsProxyCall(action));
|
|
25
|
+
it('encodeForRecipe', () => encodeForRecipe(action));
|
|
26
|
+
it('getEthValue', async () => {
|
|
27
|
+
const ethValue = await action.getEthValue();
|
|
28
|
+
assert.equal(ethValue, '0');
|
|
29
|
+
})
|
|
30
|
+
})
|
|
31
|
+
})
|