@defisaver/sdk 1.2.15-dev-allocator-2 → 1.2.16-dev-liquity-v2-1
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/LiquityV2RatioCheckAction.d.ts +16 -0
- package/esm/src/actions/checkers/LiquityV2RatioCheckAction.js +24 -0
- package/esm/src/actions/checkers/index.d.ts +1 -0
- package/esm/src/actions/checkers/index.js +1 -0
- package/esm/src/actions/index.d.ts +2 -1
- package/esm/src/actions/index.js +2 -1
- package/esm/src/actions/liquityV2/LiquityV2AdjustAction.d.ts +21 -0
- package/esm/src/actions/liquityV2/LiquityV2AdjustAction.js +54 -0
- package/esm/src/actions/liquityV2/LiquityV2AdjustInterestRateAction.d.ts +18 -0
- package/esm/src/actions/liquityV2/LiquityV2AdjustInterestRateAction.js +42 -0
- package/esm/src/actions/liquityV2/LiquityV2AdjustZombieTroveAction.d.ts +23 -0
- package/esm/src/actions/liquityV2/LiquityV2AdjustZombieTroveAction.js +62 -0
- package/esm/src/actions/liquityV2/LiquityV2BorrowAction.d.ts +17 -0
- package/esm/src/actions/liquityV2/LiquityV2BorrowAction.js +38 -0
- package/esm/src/actions/liquityV2/LiquityV2ClaimAction.d.ts +14 -0
- package/esm/src/actions/liquityV2/LiquityV2ClaimAction.js +26 -0
- package/esm/src/actions/liquityV2/LiquityV2CloseAction.d.ts +20 -0
- package/esm/src/actions/liquityV2/LiquityV2CloseAction.js +49 -0
- package/esm/src/actions/liquityV2/LiquityV2OpenAction.d.ts +29 -0
- package/esm/src/actions/liquityV2/LiquityV2OpenAction.js +86 -0
- package/esm/src/actions/liquityV2/LiquityV2PaybackAction.d.ts +20 -0
- package/esm/src/actions/liquityV2/LiquityV2PaybackAction.js +49 -0
- package/esm/src/actions/liquityV2/LiquityV2SPClaimCollAction.d.ts +14 -0
- package/esm/src/actions/liquityV2/LiquityV2SPClaimCollAction.js +26 -0
- package/esm/src/actions/liquityV2/LiquityV2SPDepositAction.d.ts +22 -0
- package/esm/src/actions/liquityV2/LiquityV2SPDepositAction.js +57 -0
- package/esm/src/actions/liquityV2/LiquityV2SPWithdrawAction.d.ts +17 -0
- package/esm/src/actions/liquityV2/LiquityV2SPWithdrawAction.js +38 -0
- package/esm/src/actions/liquityV2/LiquityV2SupplyAction.d.ts +22 -0
- package/esm/src/actions/liquityV2/LiquityV2SupplyAction.js +50 -0
- package/esm/src/actions/liquityV2/LiquityV2WithdrawAction.d.ts +16 -0
- package/esm/src/actions/liquityV2/LiquityV2WithdrawAction.js +34 -0
- package/esm/src/actions/liquityV2/index.d.ts +13 -0
- package/esm/src/actions/liquityV2/index.js +13 -0
- package/esm/src/actions/morpho-blue/MorphoBlueReallocateLiquidityAction.js +1 -1
- package/esm/src/addresses.d.ts +54 -2
- package/esm/src/addresses.js +16 -0
- package/esm/src/index.d.ts +216 -8
- package/esm/src/triggers/ClosePriceTrigger.d.ts +10 -0
- package/esm/src/triggers/ClosePriceTrigger.js +12 -0
- package/esm/src/triggers/LiquityRatioTrigger.js +1 -1
- package/esm/src/triggers/LiquityV2RatioTrigger.d.ts +8 -0
- package/esm/src/triggers/LiquityV2RatioTrigger.js +10 -0
- package/esm/src/triggers/index.d.ts +2 -0
- package/esm/src/triggers/index.js +2 -0
- package/package.json +2 -2
- 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/LiquityV2RatioCheckAction.ts +32 -0
- package/src/actions/checkers/index.ts +2 -1
- package/src/actions/index.ts +2 -0
- package/src/actions/liquityV2/LiquityV2AdjustAction.ts +73 -0
- package/src/actions/liquityV2/LiquityV2AdjustInterestRateAction.ts +57 -0
- package/src/actions/liquityV2/LiquityV2AdjustZombieTroveAction.ts +82 -0
- package/src/actions/liquityV2/LiquityV2BorrowAction.ts +52 -0
- package/src/actions/liquityV2/LiquityV2ClaimAction.ts +37 -0
- package/src/actions/liquityV2/LiquityV2CloseAction.ts +53 -0
- package/src/actions/liquityV2/LiquityV2OpenAction.ts +101 -0
- package/src/actions/liquityV2/LiquityV2PaybackAction.ts +52 -0
- package/src/actions/liquityV2/LiquityV2SPClaimCollAction.ts +37 -0
- package/src/actions/liquityV2/LiquityV2SPDepositAction.ts +62 -0
- package/src/actions/liquityV2/LiquityV2SPWithdrawAction.ts +52 -0
- package/src/actions/liquityV2/LiquityV2SupplyAction.ts +57 -0
- package/src/actions/liquityV2/LiquityV2WithdrawAction.ts +47 -0
- package/src/actions/liquityV2/index.ts +13 -0
- package/src/actions/morpho-blue/MorphoBlueReallocateLiquidityAction.ts +1 -1
- package/src/addresses.ts +18 -0
- package/src/triggers/ClosePriceTrigger.ts +19 -0
- package/src/triggers/LiquityRatioTrigger.ts +1 -1
- package/src/triggers/LiquityV2RatioTrigger.ts +17 -0
- package/src/triggers/index.ts +2 -0
- package/test/actions/basic/SendTokensAndUnwrapAction.js +73 -0
- package/umd/index.js +1261 -571
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { Action } from '../../Action';
|
|
2
|
+
import { getAddr } from '../../addresses';
|
|
3
|
+
import { EthAddress, uint256 } from '../../types';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* LiquityV2SupplyAction - Supplies collateral to a trove
|
|
7
|
+
*
|
|
8
|
+
* @category LiquityV2
|
|
9
|
+
*/
|
|
10
|
+
export class LiquityV2SupplyAction extends Action {
|
|
11
|
+
tokenForApproval: EthAddress;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @param market liquity address registry for the market
|
|
15
|
+
* @param from address from which to take the collateral
|
|
16
|
+
* @param collToken address of the collateral token
|
|
17
|
+
* @param troveId id of the trove to supply collateral to
|
|
18
|
+
* @param amount collateral amount to supply
|
|
19
|
+
*/
|
|
20
|
+
constructor(
|
|
21
|
+
market: EthAddress,
|
|
22
|
+
from: EthAddress,
|
|
23
|
+
collToken: EthAddress,
|
|
24
|
+
troveId: uint256,
|
|
25
|
+
amount: uint256,
|
|
26
|
+
) {
|
|
27
|
+
super(
|
|
28
|
+
'LiquityV2Supply',
|
|
29
|
+
getAddr('LiquityV2Supply'),
|
|
30
|
+
[
|
|
31
|
+
'address',
|
|
32
|
+
'address',
|
|
33
|
+
'uint256',
|
|
34
|
+
'uint256',
|
|
35
|
+
],
|
|
36
|
+
[
|
|
37
|
+
market,
|
|
38
|
+
from,
|
|
39
|
+
troveId,
|
|
40
|
+
amount,
|
|
41
|
+
],
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
this.mappableArgs = [
|
|
45
|
+
this.args[0],
|
|
46
|
+
this.args[1],
|
|
47
|
+
this.args[2],
|
|
48
|
+
this.args[3],
|
|
49
|
+
];
|
|
50
|
+
|
|
51
|
+
this.tokenForApproval = collToken;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
async getAssetsToApprove() {
|
|
55
|
+
return [{ asset: this.tokenForApproval, owner: this.args[1] }];
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { Action } from '../../Action';
|
|
2
|
+
import { getAddr } from '../../addresses';
|
|
3
|
+
import { EthAddress, uint256 } from '../../types';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* LiquityV2WithdrawAction - Withdraws collateral from a trove
|
|
7
|
+
*
|
|
8
|
+
* @category LiquityV2
|
|
9
|
+
*/
|
|
10
|
+
export class LiquityV2WithdrawAction extends Action {
|
|
11
|
+
/**
|
|
12
|
+
* @param market liquity address registry for the market
|
|
13
|
+
* @param to address to which to send the withdrawn collateral
|
|
14
|
+
* @param troveId id of the trove to withdraw from
|
|
15
|
+
* @param amount collateral amount to withdraw
|
|
16
|
+
*/
|
|
17
|
+
constructor(
|
|
18
|
+
market: EthAddress,
|
|
19
|
+
to: EthAddress,
|
|
20
|
+
troveId: uint256,
|
|
21
|
+
amount: uint256,
|
|
22
|
+
) {
|
|
23
|
+
super(
|
|
24
|
+
'LiquityV2Withdraw',
|
|
25
|
+
getAddr('LiquityV2Withdraw'),
|
|
26
|
+
[
|
|
27
|
+
'address',
|
|
28
|
+
'address',
|
|
29
|
+
'uint256',
|
|
30
|
+
'uint256',
|
|
31
|
+
],
|
|
32
|
+
[
|
|
33
|
+
market,
|
|
34
|
+
to,
|
|
35
|
+
troveId,
|
|
36
|
+
amount,
|
|
37
|
+
],
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
this.mappableArgs = [
|
|
41
|
+
this.args[0],
|
|
42
|
+
this.args[1],
|
|
43
|
+
this.args[2],
|
|
44
|
+
this.args[3],
|
|
45
|
+
];
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export * from './LiquityV2OpenAction';
|
|
2
|
+
export * from './LiquityV2CloseAction';
|
|
3
|
+
export * from './LiquityV2BorrowAction';
|
|
4
|
+
export * from './LiquityV2PaybackAction';
|
|
5
|
+
export * from './LiquityV2SupplyAction';
|
|
6
|
+
export * from './LiquityV2WithdrawAction';
|
|
7
|
+
export * from './LiquityV2SPDepositAction';
|
|
8
|
+
export * from './LiquityV2SPWithdrawAction';
|
|
9
|
+
export * from './LiquityV2SPClaimCollAction';
|
|
10
|
+
export * from './LiquityV2AdjustAction';
|
|
11
|
+
export * from './LiquityV2ClaimAction';
|
|
12
|
+
export * from './LiquityV2AdjustInterestRateAction';
|
|
13
|
+
export * from './LiquityV2AdjustZombieTroveAction';
|
|
@@ -28,7 +28,7 @@ export class MorphoBlueReallocateLiquidityAction extends Action {
|
|
|
28
28
|
) {
|
|
29
29
|
super(
|
|
30
30
|
'MorphoBlueReallocateLiquidity',
|
|
31
|
-
getAddr('
|
|
31
|
+
getAddr('MorphoBlueReallocateLiquidity'),
|
|
32
32
|
[
|
|
33
33
|
['address', 'address', 'address', 'address', 'uint256'], // MarketParams
|
|
34
34
|
'address[]', // vaults
|
package/src/addresses.ts
CHANGED
|
@@ -176,6 +176,21 @@ export const actionAddresses = {
|
|
|
176
176
|
LiquityRedeem: '0x20B78854658011394C931EF2BF3cEEA2Fe62E7f0',
|
|
177
177
|
LiquityAdjust: '0x0A398f6B97677192A5d5e7Ea8A937383FFf9304c',
|
|
178
178
|
|
|
179
|
+
// liquity v2
|
|
180
|
+
LiquityV2Open: '0x270A0C7eBd1C0a98FdA613782b51419300AB6322',
|
|
181
|
+
LiquityV2Close: '0xC6C627c63389D8bB7913b55CD62fa451703AD1E1',
|
|
182
|
+
LiquityV2Supply: '0x6e31Dd331571209043c8CF997f86b4291F648537',
|
|
183
|
+
LiquityV2Withdraw: '0x561013c605A17f5dC5b738C8a3fF9c5F33DbC3d8',
|
|
184
|
+
LiquityV2Borrow: '0x26C39FE05466dBA72A98d095d019dC5e067F6b28',
|
|
185
|
+
LiquityV2Payback: '0x3B1D0bD618fF8F8c51B11CD676c3384CB2A36C64',
|
|
186
|
+
LiquityV2Claim: '0xb3d3dFf3d68539F6a1bb51e56B7dC8d515aE8978',
|
|
187
|
+
LiquityV2Adjust: '0x57d6228b5EfC44174701704629A0F3EEa2c25E7f',
|
|
188
|
+
LiquityV2AdjustInterestRate: '0x3EFf4EEC06bd75941025fb751407A5de5F456bC6',
|
|
189
|
+
LiquityV2SPDeposit: '0x1e533364fE613AaD64B8D46F7A096Ae0c722239D',
|
|
190
|
+
LiquityV2SPWithdraw: '0xb080DC160415Ffe1a4b80d75b0Be92EE38a0b426',
|
|
191
|
+
LiquityV2SPClaimColl: '0xD50B0295C69e3F77BE7d99e7BdeAc442F37b373b',
|
|
192
|
+
LiquityV2AdjustZombieTrove: '0x457d4969d73FfCb656AF9002703EB4B33504dEFF',
|
|
193
|
+
|
|
179
194
|
// b.protocol
|
|
180
195
|
BprotocolLiquitySPDeposit: '0x5A0436c7559e37da8cD24B0f66C155a0a2fd6309',
|
|
181
196
|
BprotocolLiquitySPWithdraw: '0x20Ece7CB4463bB1DbA4C4fA800E321A05dfB028B',
|
|
@@ -457,6 +472,8 @@ export const actionAddresses = {
|
|
|
457
472
|
UpdateSub: '0x1601c6ABCDE6e6d8Ad96628AFe20d47908127Aea',
|
|
458
473
|
MerklClaim: '0xa2c6cd875c52bf5c27516fae3b6ba9241790908a',
|
|
459
474
|
|
|
475
|
+
GasFeeTakerL2: '0xAEe02caf404332c40Fd7FF8d5c25F91f7c1641d0',
|
|
476
|
+
|
|
460
477
|
// Flashloan
|
|
461
478
|
FLAaveV3: '0x79Eb9cEe432Cd3e7b09A9eFdB21A733A6d7b4c3A',
|
|
462
479
|
FLBalancer: '0x862E533198C9656B75bB6A5dDF0953F7ED5E8507',
|
|
@@ -496,6 +513,7 @@ export const actionAddresses = {
|
|
|
496
513
|
MorphoBlueSetAuth: '0xb565630c6ddd1fae169c453667f5aa52ef4e2e39',
|
|
497
514
|
MorphoBlueSetAuthWithSig: '0x80be65342f6172a6cd0b6a2653e8a887e3f46cab',
|
|
498
515
|
MorphoBlueView: '0xdbcacf59c5063da8b15481f88e7d70e13c92f2a1',
|
|
516
|
+
MorphoBlueReallocateLiquidity: '0x5Ea7F30E40F6A25BE2aD23A6FC1C31A6c95F3dc8',
|
|
499
517
|
},
|
|
500
518
|
};
|
|
501
519
|
|
|
@@ -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 ClosePriceTrigger extends Action {
|
|
11
|
+
constructor(token:EthAddress, lowerPrice:uint256, upperPrice:uint256) {
|
|
12
|
+
super(
|
|
13
|
+
'ClosePriceTrigger',
|
|
14
|
+
getAddr('Empty'),
|
|
15
|
+
['address', 'uint256', 'uint256'],
|
|
16
|
+
[token, lowerPrice, upperPrice],
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Action } from '../Action';
|
|
2
|
+
import { getAddr } from '../addresses';
|
|
3
|
+
import { EthAddress, uint256, uint8 } from '../types';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @category Triggers
|
|
7
|
+
*/
|
|
8
|
+
export class LiquityV2RatioTrigger extends Action {
|
|
9
|
+
constructor(market: EthAddress, troveId: uint256, ratio:uint256, state:uint8) {
|
|
10
|
+
super(
|
|
11
|
+
'LiquityV2RatioTrigger',
|
|
12
|
+
getAddr('Empty'),
|
|
13
|
+
['address', 'uint256', 'uint256', 'uint8'],
|
|
14
|
+
[market, troveId, ratio, state],
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
}
|
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
|
+
})
|