@defisaver/sdk 1.0.61 → 1.0.63-dev-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/Action.d.ts +2 -2
- package/esm/src/actions/aave/AaveBorrowAction.js +8 -0
- package/esm/src/actions/basic/ApproveTokenAction.js +5 -0
- package/esm/src/actions/basic/ExecuteSafeTxAction.d.ts +23 -0
- package/esm/src/actions/basic/ExecuteSafeTxAction.js +60 -0
- package/esm/src/actions/basic/LSVSellAction.d.ts +23 -0
- package/esm/src/actions/basic/LSVSellAction.js +61 -0
- package/esm/src/actions/basic/LimitSellAction.d.ts +24 -0
- package/esm/src/actions/basic/LimitSellAction.js +63 -0
- package/esm/src/actions/basic/RemoveTokenApprovalAction.d.ts +15 -0
- package/esm/src/actions/basic/RemoveTokenApprovalAction.js +42 -0
- package/esm/src/actions/basic/index.d.ts +5 -1
- package/esm/src/actions/basic/index.js +5 -1
- package/esm/src/actions/checkers/AaveV2RatioCheckAction.d.ts +14 -0
- package/esm/src/actions/checkers/AaveV2RatioCheckAction.js +20 -0
- package/esm/src/actions/checkers/CompoundV2RatioCheckAction.d.ts +14 -0
- package/esm/src/actions/checkers/CompoundV2RatioCheckAction.js +20 -0
- package/esm/src/actions/checkers/CurveUsdCollRatioCheck.d.ts +15 -0
- package/esm/src/actions/checkers/CurveUsdCollRatioCheck.js +22 -0
- package/esm/src/actions/checkers/index.d.ts +4 -1
- package/esm/src/actions/checkers/index.js +4 -1
- package/esm/src/actions/curveusd/CurveUsdGetDebtAction.d.ts +8 -0
- package/esm/src/actions/curveusd/CurveUsdGetDebtAction.js +13 -0
- package/esm/src/actions/curveusd/index.d.ts +1 -0
- package/esm/src/actions/curveusd/index.js +1 -0
- package/esm/src/actions/flashloan/AaveV3FlashLoanCarryDebtAction.d.ts +18 -0
- package/esm/src/actions/flashloan/AaveV3FlashLoanCarryDebtAction.js +28 -0
- package/esm/src/actions/flashloan/FLAction.js +3 -0
- package/esm/src/actions/flashloan/MorphoBlueFlashLoanAction.d.ts +16 -0
- package/esm/src/actions/flashloan/MorphoBlueFlashLoanAction.js +18 -0
- package/esm/src/actions/flashloan/MorphoBlueFlashLoanPaybackAction.d.ts +14 -0
- package/esm/src/actions/flashloan/MorphoBlueFlashLoanPaybackAction.js +16 -0
- package/esm/src/actions/flashloan/index.d.ts +3 -0
- package/esm/src/actions/flashloan/index.js +3 -0
- package/esm/src/actions/index.d.ts +3 -1
- package/esm/src/actions/index.js +3 -1
- package/esm/src/actions/lsv/LSVBorrowAction.d.ts +14 -0
- package/esm/src/actions/lsv/LSVBorrowAction.js +19 -0
- package/esm/src/actions/lsv/LSVPaybackAction.d.ts +13 -0
- package/esm/src/actions/lsv/LSVPaybackAction.js +18 -0
- package/esm/src/actions/lsv/LSVSupplyAction.d.ts +15 -0
- package/esm/src/actions/lsv/LSVSupplyAction.js +21 -0
- package/esm/src/actions/lsv/LSVWithdrawAction.d.ts +15 -0
- package/esm/src/actions/lsv/LSVWithdrawAction.js +21 -0
- package/esm/src/actions/lsv/index.d.ts +4 -0
- package/esm/src/actions/lsv/index.js +4 -0
- package/esm/src/actions/maker/MakerGiveAction.d.ts +1 -2
- package/esm/src/actions/maker/MakerGiveAction.js +2 -3
- package/esm/src/actions/morpho/aaveV3/MorphoAaveV3SetManagerAction.d.ts +14 -0
- package/esm/src/actions/morpho/aaveV3/MorphoAaveV3SetManagerAction.js +24 -0
- package/esm/src/actions/morpho/index.d.ts +1 -0
- package/esm/src/actions/morpho/index.js +1 -0
- package/esm/src/actions/morpho-blue/MorphoBlueBorrowAction.d.ts +21 -0
- package/esm/src/actions/morpho-blue/MorphoBlueBorrowAction.js +46 -0
- package/esm/src/actions/morpho-blue/MorphoBluePaybackAction.d.ts +24 -0
- package/esm/src/actions/morpho-blue/MorphoBluePaybackAction.js +46 -0
- package/esm/src/actions/morpho-blue/MorphoBlueSetAuthAction.d.ts +12 -0
- package/esm/src/actions/morpho-blue/MorphoBlueSetAuthAction.js +18 -0
- package/esm/src/actions/morpho-blue/MorphoBlueSetAuthWithSigAction.d.ts +12 -0
- package/esm/src/actions/morpho-blue/MorphoBlueSetAuthWithSigAction.js +21 -0
- package/esm/src/actions/morpho-blue/MorphoBlueSupplyAction.d.ts +24 -0
- package/esm/src/actions/morpho-blue/MorphoBlueSupplyAction.js +46 -0
- package/esm/src/actions/morpho-blue/MorphoBlueSupplyCollateralAction.d.ts +24 -0
- package/esm/src/actions/morpho-blue/MorphoBlueSupplyCollateralAction.js +46 -0
- package/esm/src/actions/morpho-blue/MorphoBlueWithdrawAction.d.ts +21 -0
- package/esm/src/actions/morpho-blue/MorphoBlueWithdrawAction.js +46 -0
- package/esm/src/actions/morpho-blue/MorphoBlueWithdrawCollateralAction.d.ts +21 -0
- package/esm/src/actions/morpho-blue/MorphoBlueWithdrawCollateralAction.js +46 -0
- package/esm/src/actions/morpho-blue/index.d.ts +8 -0
- package/esm/src/actions/morpho-blue/index.js +8 -0
- package/esm/src/addresses.d.ts +79 -3
- package/esm/src/addresses.js +24 -3
- package/esm/src/index.d.ts +316 -12
- package/esm/src/triggers/AaveV2RatioTrigger.d.ts +10 -0
- package/esm/src/triggers/AaveV2RatioTrigger.js +12 -0
- package/esm/src/triggers/CurveUsdCollRatioTrigger.d.ts +10 -0
- package/esm/src/triggers/CurveUsdCollRatioTrigger.js +12 -0
- package/esm/src/triggers/OffchainPriceTrigger.d.ts +10 -0
- package/esm/src/triggers/OffchainPriceTrigger.js +12 -0
- package/esm/src/triggers/index.d.ts +3 -0
- package/esm/src/triggers/index.js +3 -0
- package/esm/src/types.d.ts +20 -20
- package/esm/src/utils/curveusd-utils.d.ts +10 -0
- package/esm/src/utils/curveusd-utils.js +7 -3
- package/package.json +1 -1
- package/src/actions/aave/AaveBorrowAction.ts +9 -0
- package/src/actions/basic/ApproveTokenAction.ts +5 -0
- package/src/actions/basic/ExecuteSafeTxAction.ts +85 -0
- package/src/actions/basic/LSVSellAction.ts +61 -0
- package/src/actions/basic/LimitSellAction.ts +63 -0
- package/src/actions/basic/RemoveTokenApprovalAction.ts +39 -0
- package/src/actions/basic/index.ts +5 -1
- package/src/actions/checkers/AaveV2RatioCheckAction.ts +23 -0
- package/src/actions/checkers/CompoundV2RatioCheckAction.ts +23 -0
- package/src/actions/checkers/CurveUsdCollRatioCheck.ts +25 -0
- package/src/actions/checkers/index.ts +4 -1
- package/src/actions/curveusd/CurveUsdGetDebtAction.ts +21 -0
- package/src/actions/curveusd/index.ts +2 -1
- package/src/actions/flashloan/AaveV3FlashLoanCarryDebtAction.ts +35 -0
- package/src/actions/flashloan/FLAction.ts +3 -0
- package/src/actions/flashloan/MorphoBlueFlashLoanAction.ts +25 -0
- package/src/actions/flashloan/MorphoBlueFlashLoanPaybackAction.ts +18 -0
- package/src/actions/flashloan/index.ts +4 -1
- package/src/actions/index.ts +4 -0
- package/src/actions/lsv/LSVBorrowAction.ts +21 -0
- package/src/actions/lsv/LSVPaybackAction.ts +20 -0
- package/src/actions/lsv/LSVSupplyAction.ts +23 -0
- package/src/actions/lsv/LSVWithdrawAction.ts +23 -0
- package/src/actions/lsv/index.ts +4 -0
- package/src/actions/maker/MakerGiveAction.ts +2 -3
- package/src/actions/morpho/aaveV3/MorphoAaveV3SetManagerAction.ts +32 -0
- package/src/actions/morpho/index.ts +1 -0
- package/src/actions/morpho-blue/MorphoBlueBorrowAction.ts +54 -0
- package/src/actions/morpho-blue/MorphoBluePaybackAction.ts +54 -0
- package/src/actions/morpho-blue/MorphoBlueSetAuthAction.ts +25 -0
- package/src/actions/morpho-blue/MorphoBlueSetAuthWithSigAction.ts +39 -0
- package/src/actions/morpho-blue/MorphoBlueSupplyAction.ts +54 -0
- package/src/actions/morpho-blue/MorphoBlueSupplyCollateralAction.ts +54 -0
- package/src/actions/morpho-blue/MorphoBlueWithdrawAction.ts +54 -0
- package/src/actions/morpho-blue/MorphoBlueWithdrawCollateralAction.ts +54 -0
- package/src/actions/morpho-blue/index.ts +8 -0
- package/src/addresses.ts +26 -3
- package/src/triggers/AaveV2RatioTrigger.ts +14 -0
- package/src/triggers/CurveUsdCollRatioTrigger.ts +14 -0
- package/src/triggers/OffchainPriceTrigger.ts +14 -0
- package/src/triggers/index.ts +4 -0
- package/src/utils/basic-utils.ts +1 -1
- package/src/utils/curveusd-utils.ts +7 -3
- package/umd/index.js +1627 -584
- package/yarn-error.log +0 -3976
package/esm/src/Action.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AccessListItem, EthAddress } from './types';
|
|
2
|
-
type ParamTypes = Array<string | Array<any>>;
|
|
3
|
-
type Args = Array<any>;
|
|
2
|
+
declare type ParamTypes = Array<string | Array<any>>;
|
|
3
|
+
declare type Args = Array<any>;
|
|
4
4
|
/**
|
|
5
5
|
* Single action that can be executed directly, or combined into a set (ie. supply a vault)
|
|
6
6
|
*
|
|
@@ -18,5 +18,13 @@ export class AaveBorrowAction extends Action {
|
|
|
18
18
|
constructor(market, tokenAddr, amount, rateMode, to, onBehalf = getAddr('Empty')) {
|
|
19
19
|
requireAddress(to);
|
|
20
20
|
super('AaveBorrow', getAddr('AaveBorrow'), ['address', 'address', 'uint256', 'uint256', 'address', 'address'], [market, tokenAddr, amount, rateMode, to, onBehalf]);
|
|
21
|
+
this.mappableArgs = [
|
|
22
|
+
this.args[0],
|
|
23
|
+
this.args[1],
|
|
24
|
+
this.args[2],
|
|
25
|
+
this.args[3],
|
|
26
|
+
this.args[4],
|
|
27
|
+
this.args[5],
|
|
28
|
+
];
|
|
21
29
|
}
|
|
22
30
|
}
|
|
@@ -28,6 +28,11 @@ export class ApproveTokenAction extends Action {
|
|
|
28
28
|
'address',
|
|
29
29
|
'uint',
|
|
30
30
|
], [token, spender, amount]);
|
|
31
|
+
this.mappableArgs = [
|
|
32
|
+
this.args[0],
|
|
33
|
+
this.args[1],
|
|
34
|
+
this.args[2],
|
|
35
|
+
];
|
|
31
36
|
}
|
|
32
37
|
getAssetsToApprove() {
|
|
33
38
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Action } from '../../Action';
|
|
2
|
+
import { EthAddress, bytes, uint256, uint8 } from '../../types';
|
|
3
|
+
/**
|
|
4
|
+
* ExecuteSafeTxAction - Execute Safe transaction
|
|
5
|
+
*
|
|
6
|
+
* @category BasicActions
|
|
7
|
+
*/
|
|
8
|
+
export declare class ExecuteSafeTxAction extends Action {
|
|
9
|
+
/**
|
|
10
|
+
* @param safe Address of the Safe wallet
|
|
11
|
+
* @param to Destination address of Safe transaction
|
|
12
|
+
* @param value Ether value of Safe transaction
|
|
13
|
+
* @param data Data payload of Safe transaction
|
|
14
|
+
* @param operation Operation type of Safe transaction. 0 = call, 1 = delegateCall
|
|
15
|
+
* @param safeTxGas Gas that should be used for the Safe transaction
|
|
16
|
+
* @param baseGas Gas costs that are independent of the transaction execution(e.g. base transaction fee, signature check, payment of the refund)
|
|
17
|
+
* @param gasPrice Gas price that should be used for the payment calculation
|
|
18
|
+
* @param gasToken Token address (or 0 if ETH) that is used for the payment
|
|
19
|
+
* @param refundReceiver Address of receiver of gas payment (or 0 if tx.origin
|
|
20
|
+
* @param signatures Packed signature data ({bytes32 r}{bytes32 s}{uint8 v})
|
|
21
|
+
*/
|
|
22
|
+
constructor(safe: EthAddress, to: EthAddress, value: uint256, data: bytes, operation: uint8, safeTxGas: uint256, baseGas: uint256, gasPrice: uint256, gasToken: EthAddress, refundReceiver: EthAddress, signatures: bytes);
|
|
23
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { Action } from '../../Action';
|
|
2
|
+
import { getAddr } from '../../addresses';
|
|
3
|
+
/**
|
|
4
|
+
* ExecuteSafeTxAction - Execute Safe transaction
|
|
5
|
+
*
|
|
6
|
+
* @category BasicActions
|
|
7
|
+
*/
|
|
8
|
+
export class ExecuteSafeTxAction extends Action {
|
|
9
|
+
/**
|
|
10
|
+
* @param safe Address of the Safe wallet
|
|
11
|
+
* @param to Destination address of Safe transaction
|
|
12
|
+
* @param value Ether value of Safe transaction
|
|
13
|
+
* @param data Data payload of Safe transaction
|
|
14
|
+
* @param operation Operation type of Safe transaction. 0 = call, 1 = delegateCall
|
|
15
|
+
* @param safeTxGas Gas that should be used for the Safe transaction
|
|
16
|
+
* @param baseGas Gas costs that are independent of the transaction execution(e.g. base transaction fee, signature check, payment of the refund)
|
|
17
|
+
* @param gasPrice Gas price that should be used for the payment calculation
|
|
18
|
+
* @param gasToken Token address (or 0 if ETH) that is used for the payment
|
|
19
|
+
* @param refundReceiver Address of receiver of gas payment (or 0 if tx.origin
|
|
20
|
+
* @param signatures Packed signature data ({bytes32 r}{bytes32 s}{uint8 v})
|
|
21
|
+
*/
|
|
22
|
+
constructor(safe, to, value, data, operation, safeTxGas, baseGas, gasPrice, gasToken, refundReceiver, signatures) {
|
|
23
|
+
super('ExecuteSafeTx', getAddr('ExecuteSafeTx'), [
|
|
24
|
+
'address',
|
|
25
|
+
'address',
|
|
26
|
+
'uint256',
|
|
27
|
+
'bytes',
|
|
28
|
+
'uint8',
|
|
29
|
+
'uint256',
|
|
30
|
+
'uint256',
|
|
31
|
+
'uint256',
|
|
32
|
+
'address',
|
|
33
|
+
'address',
|
|
34
|
+
'bytes',
|
|
35
|
+
], [
|
|
36
|
+
safe,
|
|
37
|
+
to,
|
|
38
|
+
value,
|
|
39
|
+
data,
|
|
40
|
+
operation,
|
|
41
|
+
safeTxGas,
|
|
42
|
+
baseGas,
|
|
43
|
+
gasPrice,
|
|
44
|
+
gasToken,
|
|
45
|
+
refundReceiver,
|
|
46
|
+
signatures,
|
|
47
|
+
]);
|
|
48
|
+
this.mappableArgs = [
|
|
49
|
+
this.args[0],
|
|
50
|
+
this.args[1],
|
|
51
|
+
this.args[2],
|
|
52
|
+
this.args[4],
|
|
53
|
+
this.args[5],
|
|
54
|
+
this.args[6],
|
|
55
|
+
this.args[7],
|
|
56
|
+
this.args[8],
|
|
57
|
+
this.args[9],
|
|
58
|
+
];
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ActionWithL2 } from '../../ActionWithL2';
|
|
2
|
+
import { EthAddress } from '../../types';
|
|
3
|
+
/**
|
|
4
|
+
* Sells token on DeFi Saver exchange aggregator without fee
|
|
5
|
+
*
|
|
6
|
+
* @category BasicActions
|
|
7
|
+
*/
|
|
8
|
+
export declare class LSVSellAction extends ActionWithL2 {
|
|
9
|
+
protocolFee: string;
|
|
10
|
+
/**
|
|
11
|
+
* @param exchangeOrder Standard DFS Exchange data
|
|
12
|
+
* @param from Order sender
|
|
13
|
+
* @param to Order recipient
|
|
14
|
+
* @param protocolFee 0x fee (amount of ETH in Wei)
|
|
15
|
+
*/
|
|
16
|
+
constructor(exchangeOrder: Array<any>, from: EthAddress, to: EthAddress, protocolFee?: string);
|
|
17
|
+
encodeInputs(): string;
|
|
18
|
+
getAssetsToApprove(): Promise<{
|
|
19
|
+
asset: any;
|
|
20
|
+
owner: any;
|
|
21
|
+
}[]>;
|
|
22
|
+
getEthValue(): Promise<string>;
|
|
23
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import AbiCoder from 'web3-eth-abi';
|
|
11
|
+
import { getAssetInfoByAddress } from '@defisaver/tokens';
|
|
12
|
+
import ActionAbi from '../../abis/Action.json';
|
|
13
|
+
import { ActionWithL2 } from '../../ActionWithL2';
|
|
14
|
+
import { requireAddress } from '../../utils/general';
|
|
15
|
+
import { getAddr } from '../../addresses';
|
|
16
|
+
/**
|
|
17
|
+
* Sells token on DeFi Saver exchange aggregator without fee
|
|
18
|
+
*
|
|
19
|
+
* @category BasicActions
|
|
20
|
+
*/
|
|
21
|
+
export class LSVSellAction extends ActionWithL2 {
|
|
22
|
+
/**
|
|
23
|
+
* @param exchangeOrder Standard DFS Exchange data
|
|
24
|
+
* @param from Order sender
|
|
25
|
+
* @param to Order recipient
|
|
26
|
+
* @param protocolFee 0x fee (amount of ETH in Wei)
|
|
27
|
+
*/
|
|
28
|
+
constructor(exchangeOrder, from, to, protocolFee = '0') {
|
|
29
|
+
requireAddress(to);
|
|
30
|
+
super('LSVSell', getAddr('LSVSell'), [
|
|
31
|
+
['address', 'address', 'uint256', 'uint256', 'uint256', 'uint256', 'address', 'address', 'bytes', ['address', 'address', 'address', 'uint256', 'uint256', 'bytes']],
|
|
32
|
+
'address',
|
|
33
|
+
'address',
|
|
34
|
+
], [exchangeOrder, from, to]);
|
|
35
|
+
this.protocolFee = protocolFee;
|
|
36
|
+
this.mappableArgs = [
|
|
37
|
+
this.args[0][0],
|
|
38
|
+
this.args[0][1],
|
|
39
|
+
this.args[0][2],
|
|
40
|
+
this.args[1],
|
|
41
|
+
this.args[2],
|
|
42
|
+
];
|
|
43
|
+
}
|
|
44
|
+
encodeInputs() {
|
|
45
|
+
const executeActionDirectAbi = (ActionAbi.find(({ name }) => name === 'executeActionDirect'));
|
|
46
|
+
return AbiCoder.encodeFunctionCall(executeActionDirectAbi, this._encodeForCall());
|
|
47
|
+
}
|
|
48
|
+
getAssetsToApprove() {
|
|
49
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
50
|
+
const asset = getAssetInfoByAddress(this.args[0][0]);
|
|
51
|
+
if (asset.symbol !== 'ETH')
|
|
52
|
+
return [{ asset: this.args[0][0], owner: this.args[1] }];
|
|
53
|
+
return [];
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
getEthValue() {
|
|
57
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
58
|
+
return this.protocolFee || '0';
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ActionWithL2 } from '../../ActionWithL2';
|
|
2
|
+
import { EthAddress, uint256 } from '../../types';
|
|
3
|
+
/**
|
|
4
|
+
* Limit sell action used as part of the LimitSell Strategy
|
|
5
|
+
*
|
|
6
|
+
* @category BasicActions
|
|
7
|
+
*/
|
|
8
|
+
export declare class LimitSellAction extends ActionWithL2 {
|
|
9
|
+
protocolFee: string;
|
|
10
|
+
/**
|
|
11
|
+
* @param exchangeOrder Standard DFS Exchange data
|
|
12
|
+
* @param from Order sender
|
|
13
|
+
* @param to Order recipient
|
|
14
|
+
* @param gasUsed Amount of gas spent as part of the strategy
|
|
15
|
+
* @param protocolFee 0x fee (amount of ETH in Wei)
|
|
16
|
+
*/
|
|
17
|
+
constructor(exchangeOrder: Array<any>, from: EthAddress, to: EthAddress, gasUsed: uint256, protocolFee?: string);
|
|
18
|
+
encodeInputs(): string;
|
|
19
|
+
getAssetsToApprove(): Promise<{
|
|
20
|
+
asset: any;
|
|
21
|
+
owner: any;
|
|
22
|
+
}[]>;
|
|
23
|
+
getEthValue(): Promise<string>;
|
|
24
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import AbiCoder from 'web3-eth-abi';
|
|
11
|
+
import { getAssetInfoByAddress } from '@defisaver/tokens';
|
|
12
|
+
import ActionAbi from '../../abis/Action.json';
|
|
13
|
+
import { ActionWithL2 } from '../../ActionWithL2';
|
|
14
|
+
import { requireAddress } from '../../utils/general';
|
|
15
|
+
import { getAddr } from '../../addresses';
|
|
16
|
+
/**
|
|
17
|
+
* Limit sell action used as part of the LimitSell Strategy
|
|
18
|
+
*
|
|
19
|
+
* @category BasicActions
|
|
20
|
+
*/
|
|
21
|
+
export class LimitSellAction extends ActionWithL2 {
|
|
22
|
+
/**
|
|
23
|
+
* @param exchangeOrder Standard DFS Exchange data
|
|
24
|
+
* @param from Order sender
|
|
25
|
+
* @param to Order recipient
|
|
26
|
+
* @param gasUsed Amount of gas spent as part of the strategy
|
|
27
|
+
* @param protocolFee 0x fee (amount of ETH in Wei)
|
|
28
|
+
*/
|
|
29
|
+
constructor(exchangeOrder, from, to, gasUsed, protocolFee = '0') {
|
|
30
|
+
requireAddress(to);
|
|
31
|
+
super('LimitSell', getAddr('LimitSell'), [
|
|
32
|
+
['address', 'address', 'uint256', 'uint256', 'uint256', 'uint256', 'address', 'address', 'bytes', ['address', 'address', 'address', 'uint256', 'uint256', 'bytes']],
|
|
33
|
+
'address',
|
|
34
|
+
'address',
|
|
35
|
+
'uint256',
|
|
36
|
+
], [exchangeOrder, from, to, gasUsed]);
|
|
37
|
+
this.protocolFee = protocolFee;
|
|
38
|
+
this.mappableArgs = [
|
|
39
|
+
this.args[0][0],
|
|
40
|
+
this.args[0][1],
|
|
41
|
+
this.args[0][2],
|
|
42
|
+
this.args[1],
|
|
43
|
+
this.args[2],
|
|
44
|
+
];
|
|
45
|
+
}
|
|
46
|
+
encodeInputs() {
|
|
47
|
+
const executeActionDirectAbi = (ActionAbi.find(({ name }) => name === 'executeActionDirect'));
|
|
48
|
+
return AbiCoder.encodeFunctionCall(executeActionDirectAbi, this._encodeForCall());
|
|
49
|
+
}
|
|
50
|
+
getAssetsToApprove() {
|
|
51
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
52
|
+
const asset = getAssetInfoByAddress(this.args[0][0]);
|
|
53
|
+
if (asset.symbol !== 'ETH')
|
|
54
|
+
return [{ asset: this.args[0][0], owner: this.args[1] }];
|
|
55
|
+
return [];
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
getEthValue() {
|
|
59
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
60
|
+
return this.protocolFee || '0';
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Action } from '../../Action';
|
|
2
|
+
import { EthAddress } from '../../types';
|
|
3
|
+
/**
|
|
4
|
+
* Remove approval for a spender to pull tokens from user wallet
|
|
5
|
+
*
|
|
6
|
+
* @category BasicActions
|
|
7
|
+
*/
|
|
8
|
+
export declare class RemoveTokenApprovalAction extends Action {
|
|
9
|
+
/**
|
|
10
|
+
* @param token Token address
|
|
11
|
+
* @param spender Spender address
|
|
12
|
+
*/
|
|
13
|
+
constructor(token: EthAddress, spender: EthAddress);
|
|
14
|
+
getAssetsToApprove(): Promise<never[]>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { requireAddress } from '../../utils/general';
|
|
11
|
+
import { Action } from '../../Action';
|
|
12
|
+
import { getAddr } from '../../addresses';
|
|
13
|
+
/**
|
|
14
|
+
* Remove approval for a spender to pull tokens from user wallet
|
|
15
|
+
*
|
|
16
|
+
* @category BasicActions
|
|
17
|
+
*/
|
|
18
|
+
export class RemoveTokenApprovalAction extends Action {
|
|
19
|
+
/**
|
|
20
|
+
* @param token Token address
|
|
21
|
+
* @param spender Spender address
|
|
22
|
+
*/
|
|
23
|
+
constructor(token, spender) {
|
|
24
|
+
requireAddress(spender);
|
|
25
|
+
super('RemoveTokenApproval', getAddr('RemoveTokenApproval'), [
|
|
26
|
+
'address',
|
|
27
|
+
'address',
|
|
28
|
+
], [
|
|
29
|
+
token,
|
|
30
|
+
spender,
|
|
31
|
+
]);
|
|
32
|
+
this.mappableArgs = [
|
|
33
|
+
this.args[0],
|
|
34
|
+
this.args[1],
|
|
35
|
+
];
|
|
36
|
+
}
|
|
37
|
+
getAssetsToApprove() {
|
|
38
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
39
|
+
return [];
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -16,10 +16,14 @@ export * from './GasFeeActionL2';
|
|
|
16
16
|
export * from './TransferNFTAction';
|
|
17
17
|
export * from './SendTokensAction';
|
|
18
18
|
export * from './CreateSubAction';
|
|
19
|
+
export * from './LSVSellAction';
|
|
20
|
+
export * from './ApproveTokenAction';
|
|
19
21
|
export * from './SDaiWrapAction';
|
|
20
22
|
export * from './SDaiUnwrapAction';
|
|
21
23
|
export * from './TokenizedVaultAdapterDepositAction';
|
|
22
24
|
export * from './TokenizedVaultAdapterMintAction';
|
|
23
25
|
export * from './TokenizedVaultAdapterRedeemAction';
|
|
24
26
|
export * from './TokenizedVaultAdapterWithdrawAction';
|
|
25
|
-
export * from './
|
|
27
|
+
export * from './LimitSellAction';
|
|
28
|
+
export * from './ExecuteSafeTxAction';
|
|
29
|
+
export * from './RemoveTokenApprovalAction';
|
|
@@ -16,10 +16,14 @@ export * from './GasFeeActionL2';
|
|
|
16
16
|
export * from './TransferNFTAction';
|
|
17
17
|
export * from './SendTokensAction';
|
|
18
18
|
export * from './CreateSubAction';
|
|
19
|
+
export * from './LSVSellAction';
|
|
20
|
+
export * from './ApproveTokenAction';
|
|
19
21
|
export * from './SDaiWrapAction';
|
|
20
22
|
export * from './SDaiUnwrapAction';
|
|
21
23
|
export * from './TokenizedVaultAdapterDepositAction';
|
|
22
24
|
export * from './TokenizedVaultAdapterMintAction';
|
|
23
25
|
export * from './TokenizedVaultAdapterRedeemAction';
|
|
24
26
|
export * from './TokenizedVaultAdapterWithdrawAction';
|
|
25
|
-
export * from './
|
|
27
|
+
export * from './LimitSellAction';
|
|
28
|
+
export * from './ExecuteSafeTxAction';
|
|
29
|
+
export * from './RemoveTokenApprovalAction';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Action } from '../../Action';
|
|
2
|
+
import { uint8, uint256 } from '../../types';
|
|
3
|
+
/**
|
|
4
|
+
* AaveV2RatioCheckAction - Checks aave 2 ratio for users proxy position and reverts if faulty
|
|
5
|
+
*
|
|
6
|
+
* @category Checkers
|
|
7
|
+
*/
|
|
8
|
+
export declare class AaveV2RatioCheckAction extends Action {
|
|
9
|
+
/**
|
|
10
|
+
* @param ratioState If it should lower/higher
|
|
11
|
+
* @param targetRatio The ratio user want to be at
|
|
12
|
+
*/
|
|
13
|
+
constructor(ratioState: uint8, targetRatio: uint256);
|
|
14
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Action } from '../../Action';
|
|
2
|
+
import { getAddr } from '../../addresses';
|
|
3
|
+
/**
|
|
4
|
+
* AaveV2RatioCheckAction - Checks aave 2 ratio for users proxy position and reverts if faulty
|
|
5
|
+
*
|
|
6
|
+
* @category Checkers
|
|
7
|
+
*/
|
|
8
|
+
export class AaveV2RatioCheckAction extends Action {
|
|
9
|
+
/**
|
|
10
|
+
* @param ratioState If it should lower/higher
|
|
11
|
+
* @param targetRatio The ratio user want to be at
|
|
12
|
+
*/
|
|
13
|
+
constructor(ratioState, targetRatio) {
|
|
14
|
+
super('AaveV2RatioCheck', getAddr('AaveV2RatioCheck'), ['uint8', 'uint256'], [ratioState, targetRatio]);
|
|
15
|
+
this.mappableArgs = [
|
|
16
|
+
this.args[0],
|
|
17
|
+
this.args[1],
|
|
18
|
+
];
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Action } from '../../Action';
|
|
2
|
+
import { uint8, uint256 } from '../../types';
|
|
3
|
+
/**
|
|
4
|
+
* CompoundV2RatioCheckAction - Checks comp V2 ratio for user position and reverts if faulty
|
|
5
|
+
*
|
|
6
|
+
* @category Checkers
|
|
7
|
+
*/
|
|
8
|
+
export declare class CompoundV2RatioCheckAction extends Action {
|
|
9
|
+
/**
|
|
10
|
+
* @param ratioState If it should lower/higher
|
|
11
|
+
* @param targetRatio The ratio user want to be at
|
|
12
|
+
*/
|
|
13
|
+
constructor(ratioState: uint8, targetRatio: uint256);
|
|
14
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Action } from '../../Action';
|
|
2
|
+
import { getAddr } from '../../addresses';
|
|
3
|
+
/**
|
|
4
|
+
* CompoundV2RatioCheckAction - Checks comp V2 ratio for user position and reverts if faulty
|
|
5
|
+
*
|
|
6
|
+
* @category Checkers
|
|
7
|
+
*/
|
|
8
|
+
export class CompoundV2RatioCheckAction extends Action {
|
|
9
|
+
/**
|
|
10
|
+
* @param ratioState If it should lower/higher
|
|
11
|
+
* @param targetRatio The ratio user want to be at
|
|
12
|
+
*/
|
|
13
|
+
constructor(ratioState, targetRatio) {
|
|
14
|
+
super('CompV2RatioCheck', getAddr('CompV2RatioCheck'), ['uint8', 'uint256'], [ratioState, targetRatio]);
|
|
15
|
+
this.mappableArgs = [
|
|
16
|
+
this.args[0],
|
|
17
|
+
this.args[1],
|
|
18
|
+
];
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Action } from '../../Action';
|
|
2
|
+
import { uint8, uint256, EthAddress } from '../../types';
|
|
3
|
+
/**
|
|
4
|
+
* CurveUsdCollRatioCheck - Checks curveusd coll ratio for user position and reverts if faulty
|
|
5
|
+
*
|
|
6
|
+
* @category Checkers
|
|
7
|
+
*/
|
|
8
|
+
export declare class CurveUsdCollRatioCheck extends Action {
|
|
9
|
+
/**
|
|
10
|
+
* @param ratioState If it should lower/higher
|
|
11
|
+
* @param targetRatio The ratio user want to be at
|
|
12
|
+
* @param controllerAddr
|
|
13
|
+
*/
|
|
14
|
+
constructor(ratioState: uint8, targetRatio: uint256, controllerAddr: EthAddress);
|
|
15
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Action } from '../../Action';
|
|
2
|
+
import { getAddr } from '../../addresses';
|
|
3
|
+
/**
|
|
4
|
+
* CurveUsdCollRatioCheck - Checks curveusd coll ratio for user position and reverts if faulty
|
|
5
|
+
*
|
|
6
|
+
* @category Checkers
|
|
7
|
+
*/
|
|
8
|
+
export class CurveUsdCollRatioCheck extends Action {
|
|
9
|
+
/**
|
|
10
|
+
* @param ratioState If it should lower/higher
|
|
11
|
+
* @param targetRatio The ratio user want to be at
|
|
12
|
+
* @param controllerAddr
|
|
13
|
+
*/
|
|
14
|
+
constructor(ratioState, targetRatio, controllerAddr) {
|
|
15
|
+
super('CurveUsdCollRatioCheck', getAddr('CurveUsdCollRatioCheck'), ['uint8', 'uint256', 'address'], [ratioState, targetRatio, controllerAddr]);
|
|
16
|
+
this.mappableArgs = [
|
|
17
|
+
this.args[0],
|
|
18
|
+
this.args[1],
|
|
19
|
+
this.args[2],
|
|
20
|
+
];
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
export * from './MakerRatioCheckAction';
|
|
2
2
|
export * from './AaveV3RatioCheckAction';
|
|
3
3
|
export * from './CompoundV3RatioCheckAction';
|
|
4
|
-
export * from './MorphoAaveV2RatioCheckAction';
|
|
5
4
|
export * from './LiquityRatioCheckAction';
|
|
5
|
+
export * from './AaveV2RatioCheckAction';
|
|
6
|
+
export * from './CompoundV2RatioCheckAction';
|
|
7
|
+
export * from './MorphoAaveV2RatioCheckAction';
|
|
6
8
|
export * from './SparkRatioCheckAction';
|
|
7
9
|
export * from './LiquityRatioIncreaseCheckAction';
|
|
10
|
+
export * from './CurveUsdCollRatioCheck';
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
export * from './MakerRatioCheckAction';
|
|
2
2
|
export * from './AaveV3RatioCheckAction';
|
|
3
3
|
export * from './CompoundV3RatioCheckAction';
|
|
4
|
-
export * from './MorphoAaveV2RatioCheckAction';
|
|
5
4
|
export * from './LiquityRatioCheckAction';
|
|
5
|
+
export * from './AaveV2RatioCheckAction';
|
|
6
|
+
export * from './CompoundV2RatioCheckAction';
|
|
7
|
+
export * from './MorphoAaveV2RatioCheckAction';
|
|
6
8
|
export * from './SparkRatioCheckAction';
|
|
7
9
|
export * from './LiquityRatioIncreaseCheckAction';
|
|
10
|
+
export * from './CurveUsdCollRatioCheck';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Action } from '../../Action';
|
|
2
|
+
import { getAddr } from '../../addresses';
|
|
3
|
+
/**
|
|
4
|
+
* @category CurveUsd
|
|
5
|
+
*/
|
|
6
|
+
export class CurveUsdGetDebtAction extends Action {
|
|
7
|
+
constructor(controllerAddr, debtor) {
|
|
8
|
+
super('CurveUsdGetDebt', getAddr('CurveUsdGetDebt'), [
|
|
9
|
+
'address',
|
|
10
|
+
'address',
|
|
11
|
+
], [controllerAddr, debtor]);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ActionWithL2 } from '../../ActionWithL2';
|
|
2
|
+
import { EthAddress, uint256, bytes } from '../../types';
|
|
3
|
+
/**
|
|
4
|
+
* Gets a flashloan from Aave v3 and opens a debt position instead of repaying
|
|
5
|
+
*
|
|
6
|
+
* @category Flashloans
|
|
7
|
+
*/
|
|
8
|
+
export declare class AaveV3FlashLoanCarryDebtAction extends ActionWithL2 {
|
|
9
|
+
/**
|
|
10
|
+
* @param loanAmounts
|
|
11
|
+
* @param tokens
|
|
12
|
+
* @param modes
|
|
13
|
+
* @param loanPayer
|
|
14
|
+
* @param flParamGetterAddr
|
|
15
|
+
* @param flParamGetterData
|
|
16
|
+
*/
|
|
17
|
+
constructor(tokens: Array<EthAddress>, loanAmounts: Array<uint256>, modes: Array<uint256>, loanPayer: EthAddress, flParamGetterAddr?: EthAddress, flParamGetterData?: bytes);
|
|
18
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { ActionWithL2 } from '../../ActionWithL2';
|
|
2
|
+
import { getAddr } from '../../addresses';
|
|
3
|
+
/**
|
|
4
|
+
* Gets a flashloan from Aave v3 and opens a debt position instead of repaying
|
|
5
|
+
*
|
|
6
|
+
* @category Flashloans
|
|
7
|
+
*/
|
|
8
|
+
export class AaveV3FlashLoanCarryDebtAction extends ActionWithL2 {
|
|
9
|
+
/**
|
|
10
|
+
* @param loanAmounts
|
|
11
|
+
* @param tokens
|
|
12
|
+
* @param modes
|
|
13
|
+
* @param loanPayer
|
|
14
|
+
* @param flParamGetterAddr
|
|
15
|
+
* @param flParamGetterData
|
|
16
|
+
*/
|
|
17
|
+
constructor(tokens, loanAmounts, modes, loanPayer, flParamGetterAddr = getAddr('Empty'), flParamGetterData = []) {
|
|
18
|
+
super('FLAaveV3CarryDebt', getAddr('FLAaveV3CarryDebt'), ['address[]', 'uint256[]', 'uint256[]', 'address', 'address', 'bytes', 'bytes'], [tokens, loanAmounts, modes, loanPayer, flParamGetterAddr, flParamGetterData, []]);
|
|
19
|
+
if (tokens.length !== modes.length || tokens.length !== loanAmounts.length) {
|
|
20
|
+
throw new Error('Arrays must be of the same length');
|
|
21
|
+
}
|
|
22
|
+
modes.forEach((mode) => {
|
|
23
|
+
if (mode.toString() !== '1' && mode.toString() !== '2') {
|
|
24
|
+
throw new Error('Invalid borrow mode set');
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -50,5 +50,8 @@ _FLAction_instances = new WeakSet(), _FLAction_handleArgs = function _FLAction_h
|
|
|
50
50
|
if (specificFLAction.constructor.name === 'SparkFlashLoanAction') {
|
|
51
51
|
argsToReturn[5] = [7];
|
|
52
52
|
}
|
|
53
|
+
if (specificFLAction.constructor.name === 'MorphoBlueFlashLoanAction') {
|
|
54
|
+
argsToReturn[5] = [8];
|
|
55
|
+
}
|
|
53
56
|
return argsToReturn;
|
|
54
57
|
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Action } from '../../Action';
|
|
2
|
+
import { EthAddress, uint256, bytes } from '../../types';
|
|
3
|
+
/**
|
|
4
|
+
* Gets a flashloan from MorphoBlue
|
|
5
|
+
*
|
|
6
|
+
* @category Flashloans
|
|
7
|
+
*/
|
|
8
|
+
export declare class MorphoBlueFlashLoanAction extends Action {
|
|
9
|
+
/**
|
|
10
|
+
* @param token
|
|
11
|
+
* @param amount
|
|
12
|
+
* @param flParamGetterAddr
|
|
13
|
+
* @param flParamGetterData
|
|
14
|
+
*/
|
|
15
|
+
constructor(token: EthAddress, amount: uint256, flParamGetterAddr?: EthAddress, flParamGetterData?: bytes);
|
|
16
|
+
}
|