@defisaver/sdk 0.1.23 → 0.2.2
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/ACTIONS.md +20 -311
- package/AccessLists/DyDxAccessLists.js +0 -4
- package/AccessLists/InstaAccessLists.js +0 -8
- package/AccessLists/UtilsAccessLists.js +0 -5
- package/DEV.md +0 -7
- package/index.js +4 -0
- package/package.json +1 -1
- package/src/Action.js +38 -12
- package/src/Recipe.js +5 -4
- package/src/Strategy.js +63 -0
- package/src/abis/Action.json +157 -11
- package/src/abis/Recipe.json +92 -47
- package/src/actions/aave/AaveClaimStkAaveAction.js +5 -5
- package/src/actions/aave/AaveCollateralSwitchAction.js +4 -5
- package/src/actions/aave/AaveSupplyAction.js +8 -0
- package/src/actions/balancer/BalancerV2ClaimAction.js +10 -12
- package/src/actions/balancer/BalancerV2SupplyAction.js +14 -16
- package/src/actions/balancer/BalancerV2WithdrawAction.js +15 -17
- package/src/actions/basic/AutomationV2Unsub.js +3 -3
- package/src/actions/basic/ChangeProxyOwnerAction.js +2 -4
- package/src/actions/basic/GasFeeAction.js +27 -0
- package/src/actions/basic/SendTokenAndUnwrapAction.js +30 -0
- package/src/actions/basic/SubInputsAction.js +3 -8
- package/src/actions/basic/TokenBalanceAction.js +3 -3
- package/src/actions/basic/UpdateSubAction.js +19 -0
- package/src/actions/basic/index.js +6 -2
- package/src/actions/checkers/MakerRatioCheckAction.js +29 -0
- package/src/actions/checkers/index.js +5 -0
- package/src/actions/compound/CompoundClaimAction.js +5 -0
- package/src/actions/compound/CompoundCollateralSwitchAction.js +2 -4
- package/src/actions/compound/CompoundGetDebtAction.js +3 -3
- package/src/actions/compound/CompoundSupplyAction.js +6 -0
- package/src/actions/curve/CurveClaimFeesAction.js +4 -4
- package/src/actions/curve/CurveDepositAction.js +7 -7
- package/src/actions/curve/CurveGaugeDepositAction.js +6 -6
- package/src/actions/curve/CurveGaugeWithdrawAction.js +4 -4
- package/src/actions/curve/CurveMintCrvAction.js +3 -3
- package/src/actions/curve/CurveStethPoolDepositAction.js +9 -9
- package/src/actions/curve/CurveStethPoolWithdrawAction.js +9 -11
- package/src/actions/curve/CurveSwapAction.js +15 -15
- package/src/actions/curve/CurveWithdrawAction.js +7 -7
- package/src/actions/dydx/index.js +0 -2
- package/src/actions/flashloan/AaveV2FlashLoanAction.js +2 -2
- package/src/actions/flashloan/BalancerFlashLoanAction.js +2 -2
- package/src/actions/flashloan/DyDxFlashLoanAction.js +5 -1
- package/src/actions/flashloan/MakerFlashLoanAction.js +2 -2
- package/src/actions/guni/GUniDeposit.js +9 -9
- package/src/actions/guni/GUniWithdraw.js +5 -5
- package/src/actions/index.js +2 -0
- package/src/actions/insta/InstPullTokensAction.js +4 -4
- package/src/actions/insta/index.js +0 -2
- package/src/actions/lido/LidoStakeAction.js +2 -7
- package/src/actions/lido/LidoUnwrapAction.js +2 -7
- package/src/actions/lido/LidoWrapAction.js +7 -7
- package/src/actions/liquity/LiquityBorrowAction.js +5 -5
- package/src/actions/liquity/LiquityClaimAction.js +4 -0
- package/src/actions/liquity/LiquityCloseAction.js +5 -0
- package/src/actions/liquity/LiquityEthGainToTroveAction.js +3 -3
- package/src/actions/liquity/LiquityOpenAction.js +8 -8
- package/src/actions/liquity/LiquityPaybackAction.js +5 -5
- package/src/actions/liquity/LiquityRedeemAction.js +7 -7
- package/src/actions/liquity/LiquitySPDepositAction.js +7 -7
- package/src/actions/liquity/LiquitySPWithdrawAction.js +6 -6
- package/src/actions/liquity/LiquityStakeAction.js +7 -7
- package/src/actions/liquity/LiquitySupplyAction.js +5 -5
- package/src/actions/liquity/LiquityUnstakeAction.js +6 -6
- package/src/actions/liquity/LiquityWithdrawAction.js +4 -4
- package/src/actions/maker/MakerClaimAction.js +4 -4
- package/src/actions/maker/MakerGiveAction.js +6 -0
- package/src/actions/maker/MakerPaybackAction.js +2 -8
- package/src/actions/maker/MakerRatioAction.js +16 -0
- package/src/actions/maker/MakerWithdrawAction.js +1 -1
- package/src/actions/maker/index.js +2 -0
- package/src/actions/mstable/MStableClaimAction.js +4 -4
- package/src/actions/mstable/MStableDepositAction.js +18 -18
- package/src/actions/mstable/MStableWithdrawAction.js +17 -17
- package/src/actions/rari/RariDepositAction.js +5 -5
- package/src/actions/rari/RariWithdrawAction.js +6 -6
- package/src/actions/reflexer/ReflexerNativeUniV2SaviourDepositAction.js +5 -5
- package/src/actions/reflexer/ReflexerNativeUniV2SaviourGetReservesAction.js +3 -8
- package/src/actions/reflexer/ReflexerNativeUniV2SaviourWithdrawAction.js +4 -9
- package/src/actions/uniswap/UniswapSupplyAction.js +20 -22
- package/src/actions/uniswap/UniswapWithdrawAction.js +16 -18
- package/src/actions/uniswapV3/UniswapV3CollectAction.js +7 -9
- package/src/actions/uniswapV3/UniswapV3CreatePoolAction.js +20 -22
- package/src/actions/uniswapV3/UniswapV3MintAction.js +19 -21
- package/src/actions/uniswapV3/UniswapV3SupplyAction.js +17 -19
- package/src/actions/uniswapV3/UniswapV3WithdrawAction.js +12 -14
- package/src/actions/yearn/YearnSupplyAction.js +6 -6
- package/src/actions/yearn/YearnWithdrawAction.js +6 -6
- package/src/addresses.js +90 -90
- package/src/triggers/ChainLinkPriceTrigger.js +12 -0
- package/src/triggers/CompoundRatioTrigger.js +11 -0
- package/src/triggers/GasPriceTrigger.js +11 -0
- package/src/triggers/LiquityRatioTrigger.js +16 -0
- package/src/triggers/MakerRatioTrigger.js +11 -0
- package/src/triggers/ReflexerRatioTrigger.js +11 -0
- package/src/triggers/TimestampTrigger.js +11 -0
- package/src/triggers/UniV3CurrentTickTrigger.js +12 -0
- package/src/triggers/index.js +19 -0
- package/src/utils/general.js +2 -0
- package/src/utils/zeroExExchange.js +2 -40
- package/test/Action.js +2 -1
- package/test/accessLists/MockAccessLists.json +0 -72
- package/test/accessLists/Recipe.js +3 -3
- package/test/accessLists/access-lists.js +1 -2
- package/test/actions/insta/InstPullTokensAction.js +2 -2
- package/test/actions/maker/MakerPaybackAction.js +2 -2
- package/test/utils/zeroExExchange.js +0 -8
- package/src/actions/basic/BuyAction.js +0 -53
- package/src/actions/dydx/DyDxSupplyAction.js +0 -25
- package/src/actions/insta/ClaimInstMakerAction.js +0 -21
- package/test/actions/basic/BuyAction.js +0 -100
- package/test/actions/dydx/DyDxSupplyAction.js +0 -78
- package/test/actions/insta/ClaimInstMakerAction.js +0 -46
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
const Action = require("../../Action");
|
|
2
|
-
const {requireAddress} = require("../../utils/general");
|
|
3
|
-
const {getAssetInfoByAddress} = require("@defisaver/tokens");
|
|
4
|
-
const {getAddr} = require('../../addresses.js');
|
|
5
|
-
const Dec = require('decimal.js');
|
|
6
|
-
const {parsePriceFromContract} = require('../../utils/general');
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Buys an exact amount of dest token on DeFi Saver exchange aggregator
|
|
10
|
-
*/
|
|
11
|
-
class BuyAction extends Action {
|
|
12
|
-
/**
|
|
13
|
-
* @param exchangeOrder {Array} Standard DFS Exchange data
|
|
14
|
-
* @param from {string} Order sender
|
|
15
|
-
* @param to {string} Order recipient
|
|
16
|
-
* @param protocolFee {string} 0x fee (amount of ETH in Wei)
|
|
17
|
-
*/
|
|
18
|
-
constructor(exchangeOrder, from, to, protocolFee) {
|
|
19
|
-
requireAddress(to);
|
|
20
|
-
super(
|
|
21
|
-
'DFSBuy',
|
|
22
|
-
getAddr('DFSBuy'),
|
|
23
|
-
[
|
|
24
|
-
["address","address","uint256","uint256","uint256","uint256","address","address","bytes",["address","address","address","uint256","uint256","bytes"]],
|
|
25
|
-
"address",
|
|
26
|
-
"address",
|
|
27
|
-
],
|
|
28
|
-
[exchangeOrder, from, to]
|
|
29
|
-
);
|
|
30
|
-
|
|
31
|
-
this.protocolFee = protocolFee;
|
|
32
|
-
|
|
33
|
-
this.mappableArgs = [
|
|
34
|
-
this.args[0][0],
|
|
35
|
-
this.args[0][1],
|
|
36
|
-
this.args[0][3],
|
|
37
|
-
this.args[1],
|
|
38
|
-
this.args[2],
|
|
39
|
-
];
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
async getAssetsToApprove() {
|
|
43
|
-
const asset = getAssetInfoByAddress(this.args[0][0]);
|
|
44
|
-
if (asset.symbol !== 'ETH') return [{asset: this.args[0][0], owner: this.args[1]}];
|
|
45
|
-
return [];
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
async getEthValue() {
|
|
49
|
-
return this.protocolFee || '0';
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
module.exports = BuyAction;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
const Action = require("../../Action");
|
|
2
|
-
const {getAssetInfoByAddress} = require("@defisaver/tokens");
|
|
3
|
-
const { getAddr } = require('../../addresses.js');
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* DyDxSupplyAction - Supply token to an DyDx position
|
|
7
|
-
*/
|
|
8
|
-
class DyDxSupplyAction extends Action {
|
|
9
|
-
/**
|
|
10
|
-
* @param tokenAddr {EthAddress}
|
|
11
|
-
* @param amount {string}
|
|
12
|
-
* @param from {EthAddress} Tokens will be supplied from this address
|
|
13
|
-
*/
|
|
14
|
-
constructor(tokenAddr, amount, from) {
|
|
15
|
-
super('DyDxSupply', getAddr('DyDxSupply'), ['address','uint256','address'], [tokenAddr, amount, from]);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
async getAssetsToApprove() {
|
|
19
|
-
const asset = getAssetInfoByAddress(this.args[0]);
|
|
20
|
-
if (asset.symbol !== 'ETH') return [{asset: this.args[0], owner: this.args[2], specialApproveLabel: 'dydx'}];
|
|
21
|
-
return [];
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
module.exports = DyDxSupplyAction;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
const Action = require("../../Action");
|
|
2
|
-
const { getAssetInfoByAddress, getAssetInfo } = require("@defisaver/tokens");
|
|
3
|
-
const { getAddr } = require("../../addresses.js");
|
|
4
|
-
|
|
5
|
-
class ClaimInstMakerAction extends Action {
|
|
6
|
-
constructor(index, vaultId, rewardAmount, networthAmount, merkleProof, owner, to) {
|
|
7
|
-
super(
|
|
8
|
-
"ClaimInstMaker",
|
|
9
|
-
getAddr("ClaimInstMaker"),
|
|
10
|
-
[["uint256", "uint256", "uint256", "uint256", "bytes32[]", "address", "address"]],
|
|
11
|
-
[[index, vaultId, rewardAmount, networthAmount, merkleProof,owner, to]]
|
|
12
|
-
);
|
|
13
|
-
this.mappableArgs = [];
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
async getAssetsToApprove() {
|
|
17
|
-
return [];
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
module.exports = ClaimInstMakerAction;
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
const dfs = require('../../../index.js');
|
|
2
|
-
const {assetAmountInEth} = require("@defisaver/tokens");
|
|
3
|
-
const {assetAmountInWei} = require("@defisaver/tokens");
|
|
4
|
-
const {getAssetInfo} = require("@defisaver/tokens");
|
|
5
|
-
const {encodeForDsProxyCall, encodeForRecipe} = require('../../_actionUtils');
|
|
6
|
-
const {assert} = require('chai');
|
|
7
|
-
|
|
8
|
-
describe('Action: Buy', () => {
|
|
9
|
-
let action;
|
|
10
|
-
|
|
11
|
-
context('Without param mappings', () => {
|
|
12
|
-
it('constructor', () => {
|
|
13
|
-
action = new dfs.actions.basic.BuyAction(
|
|
14
|
-
[getAssetInfo('DAI').address, '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', 0, 1000000000000, 0, 0, '0x0000000000000000000000000000000000000000', '0x6403BD92589F825FfeF6b62177FCe9149947cb9f', '0x000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000020000000000000000000000006b175474e89094c44da98b954eedeac495271d0f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', ['0x0000000000000000000000000000000000000000','0x0000000000000000000000000000000000000000', '0x0000000000000000000000000000000000000000', 0, 0, []]],
|
|
15
|
-
'0x0a80C3C540eEF99811f4579fa7b1A0617294e06f',
|
|
16
|
-
'0x0a80C3C540eEF99811f4579fa7b1A0617294e06f'
|
|
17
|
-
);
|
|
18
|
-
})
|
|
19
|
-
it('encodeForDsProxyCall', () => encodeForDsProxyCall(action));
|
|
20
|
-
it('encodeForRecipe', () => encodeForRecipe(action));
|
|
21
|
-
it('getAssetsToApprove', async () => {
|
|
22
|
-
const assetOwnerPairs = await action.getAssetsToApprove();
|
|
23
|
-
assert.lengthOf(assetOwnerPairs, 1);
|
|
24
|
-
assert.equal(assetOwnerPairs[0].asset, getAssetInfo('DAI').address);
|
|
25
|
-
assert.equal(assetOwnerPairs[0].owner, '0x0a80C3C540eEF99811f4579fa7b1A0617294e06f');
|
|
26
|
-
})
|
|
27
|
-
it('getEthValue', async () => {
|
|
28
|
-
const ethValue = await action.getEthValue();
|
|
29
|
-
assert.equal(ethValue, '0');
|
|
30
|
-
})
|
|
31
|
-
})
|
|
32
|
-
|
|
33
|
-
context('With param mappings inside tuple', () => {
|
|
34
|
-
it('constructor', () => {
|
|
35
|
-
action = new dfs.actions.basic.BuyAction(
|
|
36
|
-
['0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', 0, '$1', 0, 0, '0x0000000000000000000000000000000000000000', '0x6403BD92589F825FfeF6b62177FCe9149947cb9f', '0x000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000020000000000000000000000006b175474e89094c44da98b954eedeac495271d0f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', ['0x0000000000000000000000000000000000000000','0x0000000000000000000000000000000000000000', '0x0000000000000000000000000000000000000000', 0, 0, []]],
|
|
37
|
-
'0x0a80C3C540eEF99811f4579fa7b1A0617294e06f',
|
|
38
|
-
'0x0a80C3C540eEF99811f4579fa7b1A0617294e06f'
|
|
39
|
-
);
|
|
40
|
-
})
|
|
41
|
-
it('encodeForDsProxyCall', () => encodeForDsProxyCall(action));
|
|
42
|
-
it('encodeForRecipe', () => encodeForRecipe(action));
|
|
43
|
-
})
|
|
44
|
-
|
|
45
|
-
context('Buy DAI with ETH', () => {
|
|
46
|
-
it('constructor', () => {
|
|
47
|
-
action = new dfs.actions.basic.BuyAction(
|
|
48
|
-
[getAssetInfo('WETH').address, getAssetInfo('DAI').address, '0', assetAmountInWei('1000', 'DAI'), '1813717262792943307400', 0, '0x0000000000000000000000000000000000000000', '0x0000000000000000000000000000000000000000', '0x', ['0x0c4e16899f2059F4e41ddB164317414a5c0d2988','0xdef1c0ded9bec7f1a1670819833240f027b25eff', '0xdef1c0ded9bec7f1a1670819833240f027b25eff', '1813717262792943307400', '0', '0x415565b0000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000006b175474e89094c44da98b954eedeac495271d0fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00000000000000000000000000000000000000000000021e19e0c9bab240000000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000003a0000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000001000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000006b175474e89094c44da98b954eedeac495271d0f000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000002c000000000000000000000000000000000000000000000000000000000000002c000000000000000000000000000000000000000000000000000000000000002a000000000000000000000000000000000000000000000021e19e0c9bab2400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000004c84061358b7eca100000000000000000000000000000000000000000000021e19e0c9bab2400000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000d9e1ce17f2641f24ae83637ab66a2cca9c378b9f00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000002000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000006b175474e89094c44da98b954eedeac495271d0f000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000003000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000006b175474e89094c44da98b954eedeac495271d0f000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee0000000000000000000000000000000000000000000000000000000000000000869584cd000000000000000000000000322d58b9e75a6918f7e7849aee0ff09369977e0800000000000000000000000000000000000000000000007ef75d3d7d6048be6e']],
|
|
49
|
-
'0x0a80C3C540eEF99811f4579fa7b1A0617294e06f',
|
|
50
|
-
'0x0a80C3C540eEF99811f4579fa7b1A0617294e06f'
|
|
51
|
-
);
|
|
52
|
-
})
|
|
53
|
-
it('encodeForDsProxyCall', () => encodeForDsProxyCall(action));
|
|
54
|
-
it('encodeForRecipe', () => encodeForRecipe(action));
|
|
55
|
-
it('getAssetsToApprove', async () => {
|
|
56
|
-
const assetOwnerPairs = await action.getAssetsToApprove();
|
|
57
|
-
assert.lengthOf(assetOwnerPairs, 1);
|
|
58
|
-
assert.equal(assetOwnerPairs[0].asset, getAssetInfo('WETH').address);
|
|
59
|
-
assert.equal(assetOwnerPairs[0].owner, '0x0a80C3C540eEF99811f4579fa7b1A0617294e06f');
|
|
60
|
-
})
|
|
61
|
-
it('getEthValue', async () => {
|
|
62
|
-
const ethValue = await action.getEthValue();
|
|
63
|
-
assert.isAtLeast(+assetAmountInEth(ethValue, 'WETH'), 0);
|
|
64
|
-
})
|
|
65
|
-
})
|
|
66
|
-
|
|
67
|
-
context('Buy DAI with USDC', () => {
|
|
68
|
-
it('constructor', () => {
|
|
69
|
-
action = new dfs.actions.basic.BuyAction(
|
|
70
|
-
[getAssetInfo('USDC').address, getAssetInfo('DAI').address, 0, assetAmountInWei('1000', 'DAI'), 0, 0, '0x0000000000000000000000000000000000000000', '0x6403BD92589F825FfeF6b62177FCe9149947cb9f', '0x000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000020000000000000000000000006b175474e89094c44da98b954eedeac495271d0f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', ['0x0000000000000000000000000000000000000000','0x0000000000000000000000000000000000000000', '0x0000000000000000000000000000000000000000', 0, 0, []]],
|
|
71
|
-
'0x0a80C3C540eEF99811f4579fa7b1A0617294e06f',
|
|
72
|
-
'0x0a80C3C540eEF99811f4579fa7b1A0617294e06f'
|
|
73
|
-
);
|
|
74
|
-
})
|
|
75
|
-
it('encodeForDsProxyCall', () => encodeForDsProxyCall(action));
|
|
76
|
-
it('encodeForRecipe', () => encodeForRecipe(action));
|
|
77
|
-
it('getAssetsToApprove', async () => {
|
|
78
|
-
const assetOwnerPairs = await action.getAssetsToApprove();
|
|
79
|
-
assert.lengthOf(assetOwnerPairs, 1);
|
|
80
|
-
assert.equal(assetOwnerPairs[0].asset, getAssetInfo('USDC').address);
|
|
81
|
-
assert.equal(assetOwnerPairs[0].owner, '0x0a80C3C540eEF99811f4579fa7b1A0617294e06f');
|
|
82
|
-
})
|
|
83
|
-
it('getEthValue', async () => {
|
|
84
|
-
const ethValue = await action.getEthValue();
|
|
85
|
-
assert.isAtLeast(+assetAmountInEth(ethValue, 'WETH'), 0);
|
|
86
|
-
})
|
|
87
|
-
})
|
|
88
|
-
|
|
89
|
-
context('Buy and send to invalid address', () => {
|
|
90
|
-
it('constructor throws', () => {
|
|
91
|
-
assert.throws(() => {
|
|
92
|
-
action = new dfs.actions.basic.BuyAction(
|
|
93
|
-
[getAssetInfo('USDC').address, getAssetInfo('DAI').address, 0, assetAmountInWei('1000', 'DAI'), 0, 0, '0x0000000000000000000000000000000000000000', '0x6403BD92589F825FfeF6b62177FCe9149947cb9f', '0x000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000020000000000000000000000006b175474e89094c44da98b954eedeac495271d0f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', ['0x0000000000000000000000000000000000000000','0x0000000000000000000000000000000000000000', '0x0000000000000000000000000000000000000000', 0, 0, []]],
|
|
94
|
-
'0x0a80C3C540eEF99811f4579fa7b1A0617294e06f',
|
|
95
|
-
'0x0000000000000000000000000000000000000000'
|
|
96
|
-
);
|
|
97
|
-
});
|
|
98
|
-
});
|
|
99
|
-
})
|
|
100
|
-
})
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
const dfs = require('../../../index.js');
|
|
2
|
-
const {assetAmountInWei, getAssetInfo, assetAmountInEth} = require("@defisaver/tokens");
|
|
3
|
-
const {encodeForDsProxyCall, encodeForRecipe} = require('../../_actionUtils');
|
|
4
|
-
const {assert} = require('chai');
|
|
5
|
-
const { getAddr } = require('../../../src/addresses.js');
|
|
6
|
-
|
|
7
|
-
describe('Action: DyDxSupplyAction', () => {
|
|
8
|
-
let action;
|
|
9
|
-
|
|
10
|
-
const testAcc = '0x0a80C3C540eEF99811f4579fa7b1A0617294e06f';
|
|
11
|
-
|
|
12
|
-
context('Supply 1 ETH', () => {
|
|
13
|
-
it('constructor', () => {
|
|
14
|
-
action = new dfs.actions.dydx.DyDxSupplyAction(
|
|
15
|
-
getAssetInfo('WETH').address,
|
|
16
|
-
assetAmountInWei(1, 'WETH'),
|
|
17
|
-
testAcc,
|
|
18
|
-
);
|
|
19
|
-
})
|
|
20
|
-
it('encodeForDsProxyCall', () => encodeForDsProxyCall(action));
|
|
21
|
-
it('encodeForRecipe', () => encodeForRecipe(action));
|
|
22
|
-
it('getAssetsToApprove', async () => {
|
|
23
|
-
const assetOwnerPairs = await action.getAssetsToApprove();
|
|
24
|
-
assert.lengthOf(assetOwnerPairs, 1);
|
|
25
|
-
assert.equal(assetOwnerPairs[0].asset, getAssetInfo('WETH').address);
|
|
26
|
-
assert.equal(assetOwnerPairs[0].owner, testAcc);
|
|
27
|
-
})
|
|
28
|
-
it('getEthValue', async () => {
|
|
29
|
-
const ethValue = await action.getEthValue();
|
|
30
|
-
assert.equal(assetAmountInEth(ethValue), '0');
|
|
31
|
-
})
|
|
32
|
-
})
|
|
33
|
-
|
|
34
|
-
context('Supply 1 ETH on behalf of', () => {
|
|
35
|
-
it('constructor', () => {
|
|
36
|
-
action = new dfs.actions.dydx.DyDxSupplyAction(
|
|
37
|
-
getAssetInfo('WETH').address,
|
|
38
|
-
assetAmountInWei(1, 'WETH'),
|
|
39
|
-
testAcc,
|
|
40
|
-
);
|
|
41
|
-
})
|
|
42
|
-
it('encodeForDsProxyCall', () => encodeForDsProxyCall(action));
|
|
43
|
-
it('encodeForRecipe', () => encodeForRecipe(action));
|
|
44
|
-
it('getAssetsToApprove', async () => {
|
|
45
|
-
const assetOwnerPairs = await action.getAssetsToApprove();
|
|
46
|
-
assert.lengthOf(assetOwnerPairs, 1);
|
|
47
|
-
assert.equal(assetOwnerPairs[0].asset, getAssetInfo('WETH').address);
|
|
48
|
-
assert.equal(assetOwnerPairs[0].owner, testAcc);
|
|
49
|
-
|
|
50
|
-
})
|
|
51
|
-
it('getEthValue', async () => {
|
|
52
|
-
const ethValue = await action.getEthValue();
|
|
53
|
-
assert.equal(assetAmountInEth(ethValue), '0');
|
|
54
|
-
})
|
|
55
|
-
})
|
|
56
|
-
|
|
57
|
-
context('Supply 1 WBTC', () => {
|
|
58
|
-
it('constructor', () => {
|
|
59
|
-
action = new dfs.actions.dydx.DyDxSupplyAction(
|
|
60
|
-
getAssetInfo('WBTC').address,
|
|
61
|
-
assetAmountInWei(1, 'WBTC'),
|
|
62
|
-
testAcc,
|
|
63
|
-
);
|
|
64
|
-
})
|
|
65
|
-
it('encodeForDsProxyCall', () => encodeForDsProxyCall(action));
|
|
66
|
-
it('encodeForRecipe', () => encodeForRecipe(action));
|
|
67
|
-
it('getAssetsToApprove', async () => {
|
|
68
|
-
const assetOwnerPairs = await action.getAssetsToApprove();
|
|
69
|
-
assert.lengthOf(assetOwnerPairs, 1);
|
|
70
|
-
assert.equal(assetOwnerPairs[0].asset, getAssetInfo('WBTC').address);
|
|
71
|
-
assert.equal(assetOwnerPairs[0].owner, testAcc);
|
|
72
|
-
})
|
|
73
|
-
it('getEthValue', async () => {
|
|
74
|
-
const ethValue = await action.getEthValue();
|
|
75
|
-
assert.equal(ethValue, '0');
|
|
76
|
-
})
|
|
77
|
-
})
|
|
78
|
-
})
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
const dfs = require('../../../index.js');
|
|
2
|
-
const {encodeForDsProxyCall, encodeForRecipe} = require('../../_actionUtils');
|
|
3
|
-
const {assert} = require('chai');
|
|
4
|
-
|
|
5
|
-
describe('Action: ClaimInstMakerAction', () => {
|
|
6
|
-
let action;
|
|
7
|
-
|
|
8
|
-
const testAcc = '0x0a80C3C540eEF99811f4579fa7b1A0617294e06f';
|
|
9
|
-
const merkleProof = [
|
|
10
|
-
'0xadf6648083080d45a44d25d400e399d3cc49189e7b6f497714d3dd0eabfa85f5',
|
|
11
|
-
'0x75498e5089efb5104ee04ebf124d0498ddc9103fbcf231f40c951315e85a8bc6',
|
|
12
|
-
'0x2b94d73cab41590303d19a99dae53ed96975cd945bea914861fa8d9e835ee092',
|
|
13
|
-
'0xce3aeed6316ab0db40b4d286050b8c154c68772a562cd46755f218f7e4ba273a',
|
|
14
|
-
'0x131f93fd7e53c15f7709fb6d1ceff03f9174b47b9567500073fe70c384eeffb1',
|
|
15
|
-
'0xbe8fcca3868516767e82e3ee7024f6d7db4142a3d61580d5c5c3ca83c2e879a4',
|
|
16
|
-
'0xdfdaad234615b6a3301d429cb65ac9355c1ace3d8eb11254ed2205741b713f19',
|
|
17
|
-
'0x3b38004520945b4299cc3767238c1fcbfc80311ffccfe807b8d6018e0a1689f3',
|
|
18
|
-
'0xdafb15b74e2ba8567c06a8f39929d395cb62f21397077d49abfdb9bbbc4503bc',
|
|
19
|
-
'0x01187ca02739e5b2be74b31bdec427cba63e0aed2ec18e76537834350efef60e',
|
|
20
|
-
'0xb603aea54f299c68b184e36174748b3b6dbb7205e4049a1e35a9391cea34f161',
|
|
21
|
-
'0xfa80a2920bb437f7db718d3bc0b1247687d5b2cae710f3dc2b315c6edf734305',
|
|
22
|
-
'0xbc145c0be2d3bf27857248519709740701a787a9c3f685534ac0cac578bfe90c',
|
|
23
|
-
];
|
|
24
|
-
|
|
25
|
-
context('Claim INST tokens for Maker vault', () => {
|
|
26
|
-
it('constructor', () => {
|
|
27
|
-
action = new dfs.actions.insta.ClaimInstMakerAction(
|
|
28
|
-
'3570',
|
|
29
|
-
'22178',
|
|
30
|
-
'35152894943847522649',
|
|
31
|
-
'5926144717204641000000',
|
|
32
|
-
merkleProof,
|
|
33
|
-
testAcc,
|
|
34
|
-
testAcc,
|
|
35
|
-
);
|
|
36
|
-
})
|
|
37
|
-
it('encodeForDsProxyCall', () => encodeForDsProxyCall(action));
|
|
38
|
-
it('encodeForRecipe', () => encodeForRecipe(action));
|
|
39
|
-
it('getAssetsToApprove', async () => {
|
|
40
|
-
const assetOwnerPairs = await action.getAssetsToApprove();
|
|
41
|
-
assert.lengthOf(assetOwnerPairs, 0);
|
|
42
|
-
})
|
|
43
|
-
})
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
})
|