@defisaver/sdk 1.0.1 → 1.0.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/.babelrc +3 -0
- package/.eslintrc.js +100 -0
- package/package.json +8 -3
- package/src/Action.ts +47 -42
- package/src/ActionWithL2.ts +6 -6
- package/src/DfsWeb3.ts +20 -25
- package/src/Recipe.ts +18 -16
- package/src/Strategy.ts +10 -8
- package/src/actions/aave/AaveBorrowAction.ts +4 -4
- package/src/actions/aave/AaveClaimStkAaveAction.ts +5 -5
- package/src/actions/aave/AaveCollateralSwitchAction.ts +7 -7
- package/src/actions/aave/AavePaybackAction.ts +6 -6
- package/src/actions/aave/AaveSupplyAction.ts +7 -7
- package/src/actions/aave/AaveWithdrawAction.ts +6 -6
- package/src/actions/aaveV3/AaveV3ATokenPaybackAction.ts +13 -11
- package/src/actions/aaveV3/AaveV3BorrowAction.ts +11 -9
- package/src/actions/aaveV3/AaveV3ClaimRewardsAction.ts +7 -6
- package/src/actions/aaveV3/AaveV3CollateralSwitchAction.ts +8 -7
- package/src/actions/aaveV3/AaveV3PaybackAction.ts +20 -19
- package/src/actions/aaveV3/AaveV3SetEModeAction.ts +6 -6
- package/src/actions/aaveV3/AaveV3SupplyAction.ts +17 -18
- package/src/actions/aaveV3/AaveV3SwapBorrowRateModeAction.ts +10 -9
- package/src/actions/aaveV3/AaveV3WithdrawAction.ts +14 -13
- package/src/actions/balancer/BalancerV2ClaimAction.ts +14 -15
- package/src/actions/balancer/BalancerV2SupplyAction.ts +16 -14
- package/src/actions/balancer/BalancerV2WithdrawAction.ts +16 -14
- package/src/actions/balancer/index.ts +3 -3
- package/src/actions/basic/AutomationV2Unsub.ts +6 -6
- package/src/actions/basic/ChangeProxyOwnerAction.ts +5 -5
- package/src/actions/basic/GasFeeAction.ts +6 -7
- package/src/actions/basic/GasFeeActionL2.ts +6 -6
- package/src/actions/basic/PullTokenAction.ts +11 -11
- package/src/actions/basic/SellAction.ts +11 -12
- package/src/actions/basic/SendTokenAction.ts +8 -8
- package/src/actions/basic/SendTokenAndUnwrapAction.ts +8 -8
- package/src/actions/basic/SubInputsAction.ts +6 -6
- package/src/actions/basic/SumInputsAction.ts +6 -6
- package/src/actions/basic/ToggleSubAction.ts +5 -7
- package/src/actions/basic/TokenBalanceAction.ts +5 -5
- package/src/actions/basic/TransferNFTAction.ts +8 -8
- package/src/actions/basic/UnwrapEthAction.ts +11 -10
- package/src/actions/basic/UpdateSubAction.ts +8 -8
- package/src/actions/basic/WrapEthAction.ts +6 -6
- package/src/actions/checkers/AaveV3RatioCheckAction.ts +5 -5
- package/src/actions/checkers/CompoundV3RatioCheckAction.ts +6 -6
- package/src/actions/checkers/MakerRatioCheckAction.ts +5 -5
- package/src/actions/chickenBonds/CBChickenInAction.ts +6 -6
- package/src/actions/chickenBonds/CBChickenOutAction.ts +7 -7
- package/src/actions/chickenBonds/CBCreateAction.ts +6 -6
- package/src/actions/chickenBonds/CBRedeemAction.ts +6 -7
- package/src/actions/compound/CompoundBorrowAction.ts +5 -5
- package/src/actions/compound/CompoundClaimAction.ts +6 -6
- package/src/actions/compound/CompoundCollateralSwitchAction.ts +4 -4
- package/src/actions/compound/CompoundGetDebtAction.ts +5 -5
- package/src/actions/compound/CompoundPaybackAction.ts +8 -9
- package/src/actions/compound/CompoundSupplyAction.ts +8 -9
- package/src/actions/compound/CompoundWithdrawAction.ts +5 -5
- package/src/actions/compoundV3/CompoundV3AllowAction.ts +16 -16
- package/src/actions/compoundV3/CompoundV3BorrowAction.ts +17 -17
- package/src/actions/compoundV3/CompoundV3ClaimAction.ts +9 -9
- package/src/actions/compoundV3/CompoundV3PaybackAction.ts +32 -33
- package/src/actions/compoundV3/CompoundV3SupplyAction.ts +24 -25
- package/src/actions/compoundV3/CompoundV3TransferAction.ts +25 -25
- package/src/actions/compoundV3/CompoundV3WithdrawAction.ts +9 -9
- package/src/actions/compoundV3/index.ts +1 -1
- package/src/actions/convex/ConvexClaimAction.ts +51 -52
- package/src/actions/convex/ConvexDepositAction.ts +58 -59
- package/src/actions/convex/ConvexWithdrawAction.ts +55 -56
- package/src/actions/curve/CurveClaimFeesAction.ts +18 -19
- package/src/actions/curve/CurveDepositAction.ts +61 -62
- package/src/actions/curve/CurveGaugeDepositAction.ts +20 -21
- package/src/actions/curve/CurveGaugeWithdrawAction.ts +15 -16
- package/src/actions/curve/CurveMintCrvAction.ts +14 -15
- package/src/actions/curve/CurveStethPoolDepositAction.ts +27 -27
- package/src/actions/curve/CurveStethPoolWithdrawAction.ts +26 -26
- package/src/actions/curve/CurveSwapAction.ts +20 -21
- package/src/actions/curve/CurveWithdrawAction.ts +56 -57
- package/src/actions/dydx/DyDxWithdrawAction.ts +6 -6
- package/src/actions/flashloan/AaveV2FlashLoanAction.ts +6 -6
- package/src/actions/flashloan/AaveV2FlashLoanPaybackAction.ts +5 -5
- package/src/actions/flashloan/AaveV3FlashLoanAction.ts +6 -6
- package/src/actions/flashloan/AaveV3FlashLoanPaybackAction.ts +5 -5
- package/src/actions/flashloan/BalancerFlashLoanAction.ts +6 -6
- package/src/actions/flashloan/BalancerFlashLoanPaybackAction.ts +8 -8
- package/src/actions/flashloan/DyDxFlashLoanAction.ts +7 -7
- package/src/actions/flashloan/DyDxFlashLoanPaybackAction.ts +5 -5
- package/src/actions/flashloan/EulerFlashLoanAction.ts +6 -6
- package/src/actions/flashloan/EulerFlashLoanPaybackAction.ts +6 -5
- package/src/actions/flashloan/FLAction.ts +51 -0
- package/src/actions/flashloan/MakerFlashLoanAction.ts +6 -6
- package/src/actions/flashloan/MakerFlashLoanPaybackAction.ts +4 -4
- package/src/actions/flashloan/index.ts +3 -2
- package/src/actions/guni/GUniDeposit.ts +15 -15
- package/src/actions/guni/GUniWithdraw.ts +11 -11
- package/src/actions/index.ts +24 -24
- package/src/actions/insta/InstPullTokensAction.ts +9 -9
- package/src/actions/lido/LidoStakeAction.ts +7 -7
- package/src/actions/lido/LidoUnwrapAction.ts +6 -6
- package/src/actions/lido/LidoWrapAction.ts +9 -10
- package/src/actions/liquity/LiquityBorrowAction.ts +19 -17
- package/src/actions/liquity/LiquityClaimAction.ts +14 -14
- package/src/actions/liquity/LiquityClaimSPRewardsAction.ts +9 -9
- package/src/actions/liquity/LiquityClaimStakingRewardsAction.ts +9 -9
- package/src/actions/liquity/LiquityCloseAction.ts +19 -19
- package/src/actions/liquity/LiquityEthGainToTroveAction.ts +19 -17
- package/src/actions/liquity/LiquityOpenAction.ts +25 -23
- package/src/actions/liquity/LiquityPaybackAction.ts +21 -19
- package/src/actions/liquity/LiquityRedeemAction.ts +42 -37
- package/src/actions/liquity/LiquitySPDepositAction.ts +22 -22
- package/src/actions/liquity/LiquitySPWithdrawAction.ts +19 -19
- package/src/actions/liquity/LiquityStakeAction.ts +22 -22
- package/src/actions/liquity/LiquitySupplyAction.ts +21 -19
- package/src/actions/liquity/LiquityUnstakeAction.ts +19 -19
- package/src/actions/liquity/LiquityWithdrawAction.ts +18 -16
- package/src/actions/maker/MakerClaimAction.ts +8 -8
- package/src/actions/maker/MakerGenerateAction.ts +5 -5
- package/src/actions/maker/MakerGiveAction.ts +6 -6
- package/src/actions/maker/MakerMergeAction.ts +4 -4
- package/src/actions/maker/MakerOpenVaultAction.ts +4 -4
- package/src/actions/maker/MakerPaybackAction.ts +6 -6
- package/src/actions/maker/MakerRatioAction.ts +3 -3
- package/src/actions/maker/MakerSupplyAction.ts +6 -6
- package/src/actions/maker/MakerWithdrawAction.ts +5 -5
- package/src/actions/mstable/MStableClaimAction.ts +23 -23
- package/src/actions/mstable/MStableDepositAction.ts +60 -60
- package/src/actions/mstable/MStableWithdrawAction.ts +59 -59
- package/src/actions/rari/RariDepositAction.ts +4 -4
- package/src/actions/rari/RariWithdrawAction.ts +4 -4
- package/src/actions/reflexer/ReflexerGenerateAction.ts +6 -6
- package/src/actions/reflexer/ReflexerNativeUniV2SaviourDepositAction.ts +10 -11
- package/src/actions/reflexer/ReflexerNativeUniV2SaviourGetReservesAction.ts +7 -7
- package/src/actions/reflexer/ReflexerNativeUniV2SaviourWithdrawAction.ts +8 -8
- package/src/actions/reflexer/ReflexerOpenSafeAction.ts +3 -3
- package/src/actions/reflexer/ReflexerPaybackAction.ts +6 -6
- package/src/actions/reflexer/ReflexerSupplyAction.ts +6 -6
- package/src/actions/reflexer/ReflexerWithdrawAction.ts +5 -5
- package/src/actions/uniswap/UniswapSupplyAction.ts +18 -18
- package/src/actions/uniswap/UniswapWithdrawAction.ts +16 -16
- package/src/actions/uniswapV3/UniswapV3CollectAction.ts +9 -10
- package/src/actions/uniswapV3/UniswapV3CreatePoolAction.ts +22 -20
- package/src/actions/uniswapV3/UniswapV3MintAction.ts +21 -19
- package/src/actions/uniswapV3/UniswapV3SupplyAction.ts +15 -15
- package/src/actions/uniswapV3/UniswapV3WithdrawAction.ts +14 -15
- package/src/actions/yearn/YearnSupplyAction.ts +7 -7
- package/src/actions/yearn/YearnWithdrawAction.ts +7 -7
- package/src/addresses.ts +10 -7
- package/src/config.ts +6 -6
- package/src/index.ts +30 -15
- package/src/triggers/AaveV3RatioTrigger.ts +6 -7
- package/src/triggers/ChainLinkPriceTrigger.ts +6 -8
- package/src/triggers/CompV3RatioTrigger.ts +6 -7
- package/src/triggers/CompoundRatioTrigger.ts +6 -7
- package/src/triggers/GasPriceTrigger.ts +6 -7
- package/src/triggers/LiquityRatioTrigger.ts +9 -10
- package/src/triggers/MakerRatioTrigger.ts +6 -7
- package/src/triggers/ReflexerRatioTrigger.ts +6 -7
- package/src/triggers/TimestampTrigger.ts +6 -7
- package/src/triggers/TrailingStopTrigger.ts +6 -7
- package/src/triggers/UniV3CurrentTickTrigger.ts +6 -6
- package/src/types.ts +9 -7
- package/src/utils/convex-utils.ts +9 -9
- package/src/utils/curve-utils.ts +11 -8
- package/src/utils/general.ts +4 -5
- package/src/utils/index.ts +7 -5
- package/src/utils/mstableAssetPairs.ts +6 -6
- package/src/utils/uniswapLP.ts +14 -16
- package/src/utils/uniswapV3LP.ts +5 -4
- package/src/utils/zeroExExchange.ts +9 -8
- package/.eslintrc +0 -14
- package/src/triggers/CompV3Trigger.ts +0 -15
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
import { getAssetInfo } from '@defisaver/tokens';
|
|
2
|
-
import {Action}
|
|
2
|
+
import { Action } from '../../Action';
|
|
3
3
|
import { requireAddress } from '../../utils/general';
|
|
4
4
|
import { getAddr } from '../../addresses';
|
|
5
5
|
import { poolInfo, makeFlags } from '../../utils/curve-utils';
|
|
6
|
-
import {EthAddress,uint256} from '../../types';
|
|
6
|
+
import { EthAddress, uint256 } from '../../types';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* @category Curve
|
|
10
10
|
*/
|
|
11
11
|
export class CurveDepositAction extends Action {
|
|
12
|
+
tokensForApproval:Array<EthAddress>;
|
|
12
13
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
/**
|
|
14
|
+
/**
|
|
16
15
|
* @param sender
|
|
17
16
|
* @param receiver
|
|
18
17
|
* @param poolAddr
|
|
@@ -20,66 +19,66 @@ export class CurveDepositAction extends Action {
|
|
|
20
19
|
* @param useUnderlying
|
|
21
20
|
* @param amounts
|
|
22
21
|
*/
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
22
|
+
constructor(
|
|
23
|
+
sender:EthAddress,
|
|
24
|
+
receiver:EthAddress,
|
|
25
|
+
poolAddr:EthAddress,
|
|
26
|
+
minMintAmount:uint256,
|
|
27
|
+
useUnderlying:boolean,
|
|
28
|
+
amounts:Array<uint256> = [],
|
|
29
|
+
) {
|
|
30
|
+
requireAddress(sender);
|
|
31
|
+
requireAddress(receiver);
|
|
33
32
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
33
|
+
let depositTarget;
|
|
34
|
+
let depositTargetType = 0;
|
|
35
|
+
let explicitUnderlying = false;
|
|
36
|
+
let tokensForApproval;
|
|
38
37
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
38
|
+
const pool = poolInfo.find((e) => e.swapAddr.toLowerCase() === poolAddr.toLowerCase())!;
|
|
39
|
+
if (useUnderlying) {
|
|
40
|
+
if (pool.depositContract) {
|
|
41
|
+
depositTarget = pool.depositContract;
|
|
42
|
+
depositTargetType = pool.zapType + 1;
|
|
43
|
+
} else {
|
|
44
|
+
depositTarget = pool.swapAddr;
|
|
45
|
+
explicitUnderlying = pool.underlyingFlag!;
|
|
46
|
+
if (!explicitUnderlying) throw Error('pool has no underlying deposit mechanism');
|
|
47
|
+
}
|
|
48
|
+
tokensForApproval = pool.underlyingCoins;
|
|
49
|
+
} else {
|
|
50
|
+
depositTarget = pool.swapAddr;
|
|
51
|
+
tokensForApproval = pool.coins;
|
|
52
|
+
}
|
|
54
53
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
54
|
+
super('CurveDeposit',
|
|
55
|
+
getAddr('CurveDeposit'),
|
|
56
|
+
['address', 'address', 'address', 'uint256', 'uint8', 'uint256[]'],
|
|
57
|
+
[
|
|
58
|
+
sender,
|
|
59
|
+
receiver,
|
|
60
|
+
depositTarget,
|
|
61
|
+
minMintAmount,
|
|
62
|
+
makeFlags(depositTargetType, explicitUnderlying, 0),
|
|
63
|
+
amounts,
|
|
64
|
+
],
|
|
65
|
+
);
|
|
66
|
+
this.tokensForApproval = tokensForApproval;
|
|
68
67
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
68
|
+
this.mappableArgs = [
|
|
69
|
+
this.args[0],
|
|
70
|
+
this.args[1],
|
|
71
|
+
this.args[2],
|
|
72
|
+
this.args[3],
|
|
73
|
+
this.args[4],
|
|
74
|
+
...this.args[5],
|
|
75
|
+
];
|
|
76
|
+
}
|
|
78
77
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
78
|
+
async getAssetsToApprove() {
|
|
79
|
+
return this.tokensForApproval.map((e) => Object({
|
|
80
|
+
asset: e.toLowerCase() !== getAssetInfo('ETH').address.toLowerCase() ? e : getAssetInfo('WETH').address,
|
|
81
|
+
owner: this.args[0],
|
|
82
|
+
}));
|
|
83
|
+
}
|
|
85
84
|
}
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import {Action}
|
|
1
|
+
import { Action } from '../../Action';
|
|
2
2
|
import { requireAddress } from '../../utils/general';
|
|
3
3
|
import { getAddr } from '../../addresses';
|
|
4
|
-
import {EthAddress,uint256} from '../../types';
|
|
4
|
+
import { EthAddress, uint256 } from '../../types';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* @category Curve
|
|
8
8
|
*/
|
|
9
9
|
export class CurveGaugeDepositAction extends Action {
|
|
10
|
-
|
|
11
|
-
/**
|
|
10
|
+
/**
|
|
12
11
|
*
|
|
13
12
|
* @param gaugeAddr
|
|
14
13
|
* @param lpToken
|
|
@@ -16,23 +15,23 @@ export class CurveGaugeDepositAction extends Action {
|
|
|
16
15
|
* @param onBehalfOf
|
|
17
16
|
* @param amount
|
|
18
17
|
*/
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
18
|
+
constructor(gaugeAddr:EthAddress, lpToken:EthAddress, sender:EthAddress, onBehalfOf:EthAddress, amount:uint256) {
|
|
19
|
+
requireAddress(sender);
|
|
20
|
+
requireAddress(onBehalfOf);
|
|
21
|
+
super('CurveGaugeDeposit',
|
|
22
|
+
getAddr('CurveGaugeDeposit'),
|
|
23
|
+
['address', 'address', 'address', 'address', 'uint256'],
|
|
24
|
+
[gaugeAddr, lpToken, sender, onBehalfOf, amount],
|
|
25
|
+
);
|
|
27
26
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
27
|
+
this.mappableArgs = [
|
|
28
|
+
this.args[2],
|
|
29
|
+
this.args[3],
|
|
30
|
+
this.args[4],
|
|
31
|
+
];
|
|
32
|
+
}
|
|
34
33
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
async getAssetsToApprove() {
|
|
35
|
+
return [{ asset: this.args[1], owner: this.args[2] }];
|
|
36
|
+
}
|
|
38
37
|
}
|
|
@@ -1,30 +1,29 @@
|
|
|
1
|
-
import {Action}
|
|
1
|
+
import { Action } from '../../Action';
|
|
2
2
|
import { requireAddress } from '../../utils/general';
|
|
3
3
|
import { getAddr } from '../../addresses';
|
|
4
|
-
import {EthAddress,uint256} from '../../types';
|
|
4
|
+
import { EthAddress, uint256 } from '../../types';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* @category Curve
|
|
8
8
|
*/
|
|
9
9
|
export class CurveGaugeWithdrawAction extends Action {
|
|
10
|
-
|
|
11
|
-
/**
|
|
10
|
+
/**
|
|
12
11
|
* @param gaugeAddr
|
|
13
12
|
* @param lpToken
|
|
14
13
|
* @param receiver
|
|
15
14
|
* @param amount
|
|
16
15
|
*/
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
16
|
+
constructor(gaugeAddr:EthAddress, lpToken:EthAddress, receiver:EthAddress, amount:uint256) {
|
|
17
|
+
requireAddress(receiver);
|
|
18
|
+
super('CurveGaugeWithdraw',
|
|
19
|
+
getAddr('CurveGaugeWithdraw'),
|
|
20
|
+
['address', 'address', 'address', 'uint256'],
|
|
21
|
+
[gaugeAddr, lpToken, receiver, amount],
|
|
22
|
+
);
|
|
24
23
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
24
|
+
this.mappableArgs = [
|
|
25
|
+
this.args[2],
|
|
26
|
+
this.args[3],
|
|
27
|
+
];
|
|
28
|
+
}
|
|
30
29
|
}
|
|
@@ -1,27 +1,26 @@
|
|
|
1
|
-
import {Action}
|
|
1
|
+
import { Action } from '../../Action';
|
|
2
2
|
import { requireAddress } from '../../utils/general';
|
|
3
3
|
import { getAddr } from '../../addresses';
|
|
4
|
-
import {EthAddress} from '../../types';
|
|
4
|
+
import { EthAddress } from '../../types';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* @category Curve
|
|
8
8
|
*/
|
|
9
9
|
export class CurveMintCrvAction extends Action {
|
|
10
|
-
|
|
11
|
-
/**
|
|
10
|
+
/**
|
|
12
11
|
* @param gaugeAddrs
|
|
13
12
|
* @param receiver
|
|
14
13
|
*/
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
14
|
+
constructor(gaugeAddrs:EthAddress[8], receiver:EthAddress) {
|
|
15
|
+
requireAddress(receiver);
|
|
16
|
+
super('CurveMintCrv',
|
|
17
|
+
getAddr('CurveMintCrv'),
|
|
18
|
+
['address[8]', 'address'],
|
|
19
|
+
[gaugeAddrs, receiver],
|
|
20
|
+
);
|
|
22
21
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
22
|
+
this.mappableArgs = [
|
|
23
|
+
this.args[8],
|
|
24
|
+
];
|
|
25
|
+
}
|
|
27
26
|
}
|
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
import {Action}
|
|
1
|
+
import { Action } from '../../Action';
|
|
2
2
|
import { requireAddress } from '../../utils/general';
|
|
3
3
|
import { getAddr } from '../../addresses';
|
|
4
|
-
import {EthAddress,uint256} from '../../types';
|
|
4
|
+
import { EthAddress, uint256 } from '../../types';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* CurveStethPoolDepositAction - Deposits tokens into curve steth pool
|
|
8
|
-
*
|
|
8
|
+
*
|
|
9
9
|
* @category Curve
|
|
10
10
|
*/
|
|
11
11
|
export class CurveStethPoolDepositAction extends Action {
|
|
12
|
-
|
|
13
|
-
* @param from
|
|
14
|
-
* @param to
|
|
12
|
+
/**
|
|
13
|
+
* @param from
|
|
14
|
+
* @param to
|
|
15
15
|
* @param amounts
|
|
16
16
|
* @param minMintAmount
|
|
17
17
|
*/
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
18
|
+
constructor(
|
|
19
|
+
from:EthAddress,
|
|
20
|
+
to:EthAddress,
|
|
21
|
+
amounts:uint256[2],
|
|
22
|
+
minMintAmount:uint256,
|
|
23
|
+
) {
|
|
24
|
+
requireAddress(to);
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
26
|
+
super(
|
|
27
|
+
'CurveStethPoolDeposit',
|
|
28
|
+
getAddr('CurveStethPoolDeposit'),
|
|
29
|
+
['address', 'address', 'uint256[2]', 'uint256'],
|
|
30
|
+
[from, to, amounts, minMintAmount],
|
|
31
|
+
);
|
|
32
32
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
33
|
+
this.mappableArgs = [
|
|
34
|
+
this.args[0],
|
|
35
|
+
this.args[1],
|
|
36
|
+
this.args[2][0],
|
|
37
|
+
this.args[2][1],
|
|
38
|
+
this.args[3],
|
|
39
|
+
];
|
|
40
|
+
}
|
|
41
41
|
}
|
|
@@ -1,43 +1,43 @@
|
|
|
1
|
-
import {Action}
|
|
1
|
+
import { Action } from '../../Action';
|
|
2
2
|
import { requireAddress } from '../../utils/general';
|
|
3
3
|
import { getAddr } from '../../addresses';
|
|
4
|
-
import {EthAddress,uint256} from '../../types';
|
|
4
|
+
import { EthAddress, uint256 } from '../../types';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* CurveStethPoolWithdrawAction - Withdraws tokens from curve steth pool
|
|
8
|
-
*
|
|
8
|
+
*
|
|
9
9
|
* @category Curve
|
|
10
10
|
*/
|
|
11
11
|
export class CurveStethPoolWithdrawAction extends Action {
|
|
12
|
-
|
|
12
|
+
/**
|
|
13
13
|
* @param from
|
|
14
14
|
* @param to
|
|
15
15
|
* @param amounts
|
|
16
16
|
* @param maxBurnAmount
|
|
17
17
|
* @param returnValue
|
|
18
18
|
*/
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
19
|
+
constructor(
|
|
20
|
+
from:EthAddress,
|
|
21
|
+
to:EthAddress,
|
|
22
|
+
amounts:uint256[2],
|
|
23
|
+
maxBurnAmount:uint256,
|
|
24
|
+
returnValue:uint256,
|
|
25
|
+
) {
|
|
26
|
+
requireAddress(to);
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
28
|
+
super(
|
|
29
|
+
'CurveStethPoolWithdraw',
|
|
30
|
+
getAddr('CurveStethPoolWithdraw'),
|
|
31
|
+
['address', 'address', 'uint256[2]', 'uint256', 'uint256'],
|
|
32
|
+
[from, to, amounts, maxBurnAmount, returnValue],
|
|
33
|
+
);
|
|
34
34
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
35
|
+
this.mappableArgs = [
|
|
36
|
+
this.args[0],
|
|
37
|
+
this.args[1],
|
|
38
|
+
this.args[2][0],
|
|
39
|
+
this.args[2][1],
|
|
40
|
+
this.args[3],
|
|
41
|
+
];
|
|
42
|
+
}
|
|
43
43
|
}
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import {Action}
|
|
1
|
+
import { Action } from '../../Action';
|
|
2
2
|
import { requireAddress } from '../../utils/general';
|
|
3
3
|
import { getAddr } from '../../addresses';
|
|
4
|
-
import {EthAddress,uint256} from '../../types';
|
|
4
|
+
import { EthAddress, uint256 } from '../../types';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* @category Curve
|
|
8
8
|
*/
|
|
9
9
|
export class CurveSwapAction extends Action {
|
|
10
|
-
|
|
11
|
-
/**
|
|
10
|
+
/**
|
|
12
11
|
*
|
|
13
12
|
* @param sender
|
|
14
13
|
* @param receiver
|
|
@@ -18,23 +17,23 @@ export class CurveSwapAction extends Action {
|
|
|
18
17
|
* @param amount
|
|
19
18
|
* @param expected
|
|
20
19
|
*/
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
20
|
+
constructor(sender:EthAddress, receiver:EthAddress, pool:EthAddress, tokenA:EthAddress, tokenB:EthAddress, amount:uint256, expected:uint256) {
|
|
21
|
+
requireAddress(sender);
|
|
22
|
+
requireAddress(receiver);
|
|
23
|
+
super('CurveSwap',
|
|
24
|
+
getAddr('CurveSwap'),
|
|
25
|
+
['address', 'address', 'address', 'address', 'address', 'uint256', 'uint256'],
|
|
26
|
+
[sender, receiver, pool, tokenA, tokenB, amount, expected]);
|
|
28
27
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
28
|
+
this.mappableArgs = [
|
|
29
|
+
this.args[0],
|
|
30
|
+
this.args[1],
|
|
31
|
+
this.args[5],
|
|
32
|
+
this.args[6],
|
|
33
|
+
];
|
|
34
|
+
}
|
|
36
35
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
async getAssetsToApprove() {
|
|
37
|
+
return [{ asset: this.args[3], owner: this.args[0] }];
|
|
38
|
+
}
|
|
40
39
|
}
|
|
@@ -1,18 +1,17 @@
|
|
|
1
|
-
import {Action}
|
|
1
|
+
import { Action } from '../../Action';
|
|
2
2
|
import { requireAddress } from '../../utils/general';
|
|
3
3
|
import { getAddr } from '../../addresses';
|
|
4
4
|
import { poolInfo, makeFlags } from '../../utils/curve-utils';
|
|
5
|
-
import {EthAddress,uint256} from '../../types';
|
|
5
|
+
import { EthAddress, uint256 } from '../../types';
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* @category Curve
|
|
10
10
|
*/
|
|
11
11
|
export class CurveWithdrawAction extends Action {
|
|
12
|
+
lpToken:EthAddress;
|
|
12
13
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
/**
|
|
14
|
+
/**
|
|
16
15
|
* @param sender
|
|
17
16
|
* @param receiver
|
|
18
17
|
* @param poolAddr
|
|
@@ -21,61 +20,61 @@ export class CurveWithdrawAction extends Action {
|
|
|
21
20
|
* @param withdrawExact
|
|
22
21
|
* @param minAmounts
|
|
23
22
|
*/
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
23
|
+
constructor(
|
|
24
|
+
sender:EthAddress,
|
|
25
|
+
receiver:EthAddress,
|
|
26
|
+
poolAddr:EthAddress,
|
|
27
|
+
burnAmount:uint256,
|
|
28
|
+
useUnderlying:boolean,
|
|
29
|
+
withdrawExact:boolean,
|
|
30
|
+
minAmounts:Array<uint256> = [],
|
|
31
|
+
) {
|
|
32
|
+
requireAddress(sender);
|
|
33
|
+
requireAddress(receiver);
|
|
35
34
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
35
|
+
let depositTarget;
|
|
36
|
+
let depositTargetType = 0;
|
|
37
|
+
let explicitUnderlying = false;
|
|
39
38
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
39
|
+
const pool = poolInfo.find((e:any) => e.swapAddr.toLowerCase() === poolAddr.toLowerCase())!;
|
|
40
|
+
if (useUnderlying) {
|
|
41
|
+
if (pool.depositContract) {
|
|
42
|
+
depositTarget = pool.depositContract;
|
|
43
|
+
depositTargetType = pool.zapType + 1;
|
|
44
|
+
} else {
|
|
45
|
+
depositTarget = pool.swapAddr;
|
|
46
|
+
explicitUnderlying = pool.underlyingFlag!;
|
|
47
|
+
if (!explicitUnderlying) throw Error('pool has no underlying deposit mechanism');
|
|
48
|
+
}
|
|
49
|
+
} else {
|
|
50
|
+
depositTarget = pool.swapAddr;
|
|
51
|
+
}
|
|
53
52
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
53
|
+
super('CurveWithdraw',
|
|
54
|
+
getAddr('CurveWithdraw'),
|
|
55
|
+
['address', 'address', 'address', 'uint256', 'uint8', 'uint256[]'],
|
|
56
|
+
[
|
|
57
|
+
sender,
|
|
58
|
+
receiver,
|
|
59
|
+
depositTarget,
|
|
60
|
+
burnAmount,
|
|
61
|
+
makeFlags(depositTargetType, explicitUnderlying, withdrawExact),
|
|
62
|
+
minAmounts,
|
|
63
|
+
],
|
|
64
|
+
);
|
|
65
|
+
this.lpToken = pool.lpToken;
|
|
67
66
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
67
|
+
this.mappableArgs = [
|
|
68
|
+
this.args[0],
|
|
69
|
+
this.args[1],
|
|
70
|
+
this.args[2],
|
|
71
|
+
this.args[3],
|
|
72
|
+
this.args[4],
|
|
73
|
+
...this.args[5],
|
|
74
|
+
];
|
|
75
|
+
}
|
|
77
76
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
77
|
+
async getAssetsToApprove() {
|
|
78
|
+
return [{ asset: this.lpToken, owner: this.args[0] }];
|
|
79
|
+
}
|
|
81
80
|
}
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import {Action}
|
|
2
|
-
import { requireAddress } from
|
|
1
|
+
import { Action } from '../../Action';
|
|
2
|
+
import { requireAddress } from '../../utils/general';
|
|
3
3
|
import { getAddr } from '../../addresses';
|
|
4
|
-
import {EthAddress,uint256} from '../../types';
|
|
4
|
+
import { EthAddress, uint256 } from '../../types';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* DyDxWithdrawAction - Withdraw token from an DyDx position
|
|
8
|
-
*
|
|
8
|
+
*
|
|
9
9
|
* @category DyDx
|
|
10
10
|
*/
|
|
11
11
|
export class DyDxWithdrawAction extends Action {
|
|
12
12
|
/**
|
|
13
13
|
* @param tokenAddr
|
|
14
|
-
* @param amount
|
|
14
|
+
* @param amount
|
|
15
15
|
* @param to Tokens will be withdrawn to this address
|
|
16
16
|
*/
|
|
17
17
|
constructor(tokenAddr:EthAddress, amount:uint256, to:EthAddress) {
|
|
18
18
|
requireAddress(to);
|
|
19
|
-
super('DyDxWithdraw', getAddr('DyDxWithdraw'), ['address','uint256','address'], [tokenAddr, amount, to]);
|
|
19
|
+
super('DyDxWithdraw', getAddr('DyDxWithdraw'), ['address', 'uint256', 'address'], [tokenAddr, amount, to]);
|
|
20
20
|
}
|
|
21
21
|
}
|