@defisaver/sdk 1.2.16 → 1.2.17
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/LiquityV2TargetRatioCheckAction.d.ts +15 -0
- package/esm/src/actions/checkers/LiquityV2TargetRatioCheckAction.js +22 -0
- package/esm/src/actions/checkers/index.d.ts +2 -0
- package/esm/src/actions/checkers/index.js +2 -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/addresses.d.ts +53 -1
- package/esm/src/addresses.js +15 -0
- package/esm/src/index.d.ts +212 -4
- 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/LiquityV2QuotePriceTrigger.d.ts +8 -0
- package/esm/src/triggers/LiquityV2QuotePriceTrigger.js +10 -0
- package/esm/src/triggers/LiquityV2RatioTrigger.d.ts +8 -0
- package/esm/src/triggers/LiquityV2RatioTrigger.js +10 -0
- package/esm/src/triggers/index.d.ts +3 -0
- package/esm/src/triggers/index.js +3 -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/LiquityV2TargetRatioCheckAction.ts +30 -0
- package/src/actions/checkers/index.ts +3 -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/addresses.ts +17 -0
- package/src/triggers/ClosePriceTrigger.ts +19 -0
- package/src/triggers/LiquityRatioTrigger.ts +1 -1
- package/src/triggers/LiquityV2QuotePriceTrigger.ts +17 -0
- package/src/triggers/LiquityV2RatioTrigger.ts +17 -0
- package/src/triggers/index.ts +3 -0
- package/test/actions/basic/SendTokensAndUnwrapAction.js +73 -0
- package/umd/index.js +1314 -569
|
@@ -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';
|
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: '0x6CEdC0317A9236CdFD800e6a6F41074f01d8229F',
|
|
181
|
+
LiquityV2Close: '0xBD97F8fCfdb03ca29F0C9baCA7Cb09c5A51E4adE',
|
|
182
|
+
LiquityV2Supply: '0x89403Bc80FDb1adbcf4Ea7b6acFB26197E47F2AA',
|
|
183
|
+
LiquityV2Withdraw: '0xDcBd59b7095edC5fd29063873Ec5d62F8BB18E9A',
|
|
184
|
+
LiquityV2Borrow: '0x092afc8AB25C6d5A2cE8CeAc4801fd8B1eFa5759',
|
|
185
|
+
LiquityV2Payback: '0x2B51c21a1af1316Af89f0493b2FF5C5D34D4626f',
|
|
186
|
+
LiquityV2Claim: '0x1b5a0c2573A1692bB183cC5d6f506e108c0599FC',
|
|
187
|
+
LiquityV2Adjust: '0x6063CaD05DBf1c15f643C0F483bc5ce749501d3C',
|
|
188
|
+
LiquityV2AdjustInterestRate: '0x685f0237D8b85B2018278E975a481b0650dE0b54',
|
|
189
|
+
LiquityV2SPDeposit: '0x1556711572a53c89912AE185f3a6Dba9FF365Bf3',
|
|
190
|
+
LiquityV2SPWithdraw: '0x237eaB8D7f9bBeaF8D27dB9797EB835e4062B8C2',
|
|
191
|
+
LiquityV2SPClaimColl: '0x3f783de20C3095bcB999AEA999aF4DF184b6630f',
|
|
192
|
+
LiquityV2AdjustZombieTrove: '0xDaB6aA000B0EBAa653A2715cb3847976bf614272',
|
|
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',
|
|
@@ -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 LiquityV2QuotePriceTrigger extends Action {
|
|
9
|
+
constructor(market: EthAddress, price:uint256, state:uint8) {
|
|
10
|
+
super(
|
|
11
|
+
'LiquityV2QuotePriceTrigger',
|
|
12
|
+
getAddr('Empty'),
|
|
13
|
+
['address', 'uint256', 'uint8'],
|
|
14
|
+
[market, price, state],
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -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
|
@@ -20,3 +20,6 @@ export * from './CurveUsdCollRatioTrigger';
|
|
|
20
20
|
export * from './CurveUsdHealthRatioTrigger';
|
|
21
21
|
export * from './MorphoBlueRatioTrigger';
|
|
22
22
|
export * from './OffchainPriceTrigger';
|
|
23
|
+
export * from './LiquityV2RatioTrigger';
|
|
24
|
+
export * from './ClosePriceTrigger';
|
|
25
|
+
export * from './LiquityV2QuotePriceTrigger';
|
|
@@ -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
|
+
})
|