@defisaver/sdk 1.0.64 → 1.0.66-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/actions/basic/ExecuteSafeTxAction.d.ts +23 -0
- package/esm/src/actions/basic/ExecuteSafeTxAction.js +60 -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 +3 -0
- package/esm/src/actions/basic/index.js +3 -0
- package/esm/src/actions/checkers/index.d.ts +0 -1
- package/esm/src/actions/checkers/index.js +0 -1
- package/esm/src/actions/maker/MakerGiveAction.d.ts +1 -2
- package/esm/src/actions/maker/MakerGiveAction.js +2 -3
- package/esm/src/addresses.d.ts +3 -3
- package/esm/src/addresses.js +3 -6
- package/esm/src/index.d.ts +12 -12
- package/esm/src/triggers/OffchainPriceTrigger.d.ts +10 -0
- package/esm/src/triggers/OffchainPriceTrigger.js +12 -0
- package/esm/src/triggers/index.d.ts +1 -1
- package/esm/src/triggers/index.js +1 -1
- package/package.json +1 -1
- package/src/actions/basic/ExecuteSafeTxAction.ts +85 -0
- package/src/actions/basic/LimitSellAction.ts +63 -0
- package/src/actions/basic/RemoveTokenApprovalAction.ts +39 -0
- package/src/actions/basic/WrapEthAction.ts +4 -3
- package/src/actions/basic/index.ts +3 -0
- package/src/actions/maker/MakerGiveAction.ts +2 -3
- package/src/addresses.ts +3 -3
- package/src/triggers/OffchainPriceTrigger.ts +14 -0
- package/src/triggers/index.ts +2 -0
- package/umd/index.js +631 -514
- package/esm/src/actions/checkers/MorphoBlueRatioCheckAction.d.ts +0 -20
- package/esm/src/actions/checkers/MorphoBlueRatioCheckAction.js +0 -32
- package/esm/src/triggers/MorphoBlueRatioTrigger.d.ts +0 -10
- package/esm/src/triggers/MorphoBlueRatioTrigger.js +0 -12
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { Action } from '../../Action';
|
|
2
|
+
import { getAddr } from '../../addresses';
|
|
3
|
+
import {
|
|
4
|
+
EthAddress,
|
|
5
|
+
bytes,
|
|
6
|
+
uint256,
|
|
7
|
+
uint8,
|
|
8
|
+
} from '../../types';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* ExecuteSafeTxAction - Execute Safe transaction
|
|
12
|
+
*
|
|
13
|
+
* @category BasicActions
|
|
14
|
+
*/
|
|
15
|
+
export class ExecuteSafeTxAction extends Action {
|
|
16
|
+
/**
|
|
17
|
+
* @param safe Address of the Safe wallet
|
|
18
|
+
* @param to Destination address of Safe transaction
|
|
19
|
+
* @param value Ether value of Safe transaction
|
|
20
|
+
* @param data Data payload of Safe transaction
|
|
21
|
+
* @param operation Operation type of Safe transaction. 0 = call, 1 = delegateCall
|
|
22
|
+
* @param safeTxGas Gas that should be used for the Safe transaction
|
|
23
|
+
* @param baseGas Gas costs that are independent of the transaction execution(e.g. base transaction fee, signature check, payment of the refund)
|
|
24
|
+
* @param gasPrice Gas price that should be used for the payment calculation
|
|
25
|
+
* @param gasToken Token address (or 0 if ETH) that is used for the payment
|
|
26
|
+
* @param refundReceiver Address of receiver of gas payment (or 0 if tx.origin
|
|
27
|
+
* @param signatures Packed signature data ({bytes32 r}{bytes32 s}{uint8 v})
|
|
28
|
+
*/
|
|
29
|
+
constructor(
|
|
30
|
+
safe: EthAddress,
|
|
31
|
+
to: EthAddress,
|
|
32
|
+
value: uint256,
|
|
33
|
+
data: bytes,
|
|
34
|
+
operation: uint8,
|
|
35
|
+
safeTxGas: uint256,
|
|
36
|
+
baseGas: uint256,
|
|
37
|
+
gasPrice: uint256,
|
|
38
|
+
gasToken: EthAddress,
|
|
39
|
+
refundReceiver: EthAddress,
|
|
40
|
+
signatures: bytes,
|
|
41
|
+
) {
|
|
42
|
+
super(
|
|
43
|
+
'ExecuteSafeTx',
|
|
44
|
+
getAddr('ExecuteSafeTx'),
|
|
45
|
+
[
|
|
46
|
+
'address',
|
|
47
|
+
'address',
|
|
48
|
+
'uint256',
|
|
49
|
+
'bytes',
|
|
50
|
+
'uint8',
|
|
51
|
+
'uint256',
|
|
52
|
+
'uint256',
|
|
53
|
+
'uint256',
|
|
54
|
+
'address',
|
|
55
|
+
'address',
|
|
56
|
+
'bytes',
|
|
57
|
+
],
|
|
58
|
+
[
|
|
59
|
+
safe,
|
|
60
|
+
to,
|
|
61
|
+
value,
|
|
62
|
+
data,
|
|
63
|
+
operation,
|
|
64
|
+
safeTxGas,
|
|
65
|
+
baseGas,
|
|
66
|
+
gasPrice,
|
|
67
|
+
gasToken,
|
|
68
|
+
refundReceiver,
|
|
69
|
+
signatures,
|
|
70
|
+
],
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
this.mappableArgs = [
|
|
74
|
+
this.args[0],
|
|
75
|
+
this.args[1],
|
|
76
|
+
this.args[2],
|
|
77
|
+
this.args[4],
|
|
78
|
+
this.args[5],
|
|
79
|
+
this.args[6],
|
|
80
|
+
this.args[7],
|
|
81
|
+
this.args[8],
|
|
82
|
+
this.args[9],
|
|
83
|
+
];
|
|
84
|
+
}
|
|
85
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import AbiCoder from 'web3-eth-abi';
|
|
2
|
+
import { getAssetInfoByAddress } from '@defisaver/tokens';
|
|
3
|
+
import ActionAbi from '../../abis/Action.json';
|
|
4
|
+
import { ActionWithL2 } from '../../ActionWithL2';
|
|
5
|
+
import { requireAddress } from '../../utils/general';
|
|
6
|
+
import { getAddr } from '../../addresses';
|
|
7
|
+
import { EthAddress, uint256 } from '../../types';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Limit sell action used as part of the LimitSell Strategy
|
|
11
|
+
*
|
|
12
|
+
* @category BasicActions
|
|
13
|
+
*/
|
|
14
|
+
export class LimitSellAction extends ActionWithL2 {
|
|
15
|
+
protocolFee:string;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @param exchangeOrder Standard DFS Exchange data
|
|
19
|
+
* @param from Order sender
|
|
20
|
+
* @param to Order recipient
|
|
21
|
+
* @param gasUsed Amount of gas spent as part of the strategy
|
|
22
|
+
* @param protocolFee 0x fee (amount of ETH in Wei)
|
|
23
|
+
*/
|
|
24
|
+
constructor(exchangeOrder:Array<any>, from:EthAddress, to:EthAddress, gasUsed: uint256, protocolFee = '0') {
|
|
25
|
+
requireAddress(to);
|
|
26
|
+
super(
|
|
27
|
+
'LimitSell',
|
|
28
|
+
getAddr('LimitSell'),
|
|
29
|
+
[
|
|
30
|
+
['address', 'address', 'uint256', 'uint256', 'uint256', 'uint256', 'address', 'address', 'bytes', ['address', 'address', 'address', 'uint256', 'uint256', 'bytes']],
|
|
31
|
+
'address',
|
|
32
|
+
'address',
|
|
33
|
+
'uint256',
|
|
34
|
+
],
|
|
35
|
+
[exchangeOrder, from, to, gasUsed],
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
this.protocolFee = protocolFee;
|
|
39
|
+
|
|
40
|
+
this.mappableArgs = [
|
|
41
|
+
this.args[0][0],
|
|
42
|
+
this.args[0][1],
|
|
43
|
+
this.args[0][2],
|
|
44
|
+
this.args[1],
|
|
45
|
+
this.args[2],
|
|
46
|
+
];
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
encodeInputs() {
|
|
50
|
+
const executeActionDirectAbi: any = (ActionAbi.find(({ name }) => name === 'executeActionDirect'))!;
|
|
51
|
+
return AbiCoder.encodeFunctionCall(executeActionDirectAbi, this._encodeForCall());
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
async getAssetsToApprove() {
|
|
55
|
+
const asset = getAssetInfoByAddress(this.args[0][0]);
|
|
56
|
+
if (asset.symbol !== 'ETH') return [{ asset: this.args[0][0], owner: this.args[1] }];
|
|
57
|
+
return [];
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
async getEthValue() {
|
|
61
|
+
return this.protocolFee || '0';
|
|
62
|
+
}
|
|
63
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { requireAddress } from '../../utils/general';
|
|
2
|
+
import { Action } from '../../Action';
|
|
3
|
+
import { getAddr } from '../../addresses';
|
|
4
|
+
import { EthAddress, uint256 } from '../../types';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Remove approval for a spender to pull tokens from user wallet
|
|
8
|
+
*
|
|
9
|
+
* @category BasicActions
|
|
10
|
+
*/
|
|
11
|
+
export class RemoveTokenApprovalAction extends Action {
|
|
12
|
+
/**
|
|
13
|
+
* @param token Token address
|
|
14
|
+
* @param spender Spender address
|
|
15
|
+
*/
|
|
16
|
+
constructor(token:EthAddress, spender:EthAddress) {
|
|
17
|
+
requireAddress(spender);
|
|
18
|
+
super(
|
|
19
|
+
'RemoveTokenApproval',
|
|
20
|
+
getAddr('RemoveTokenApproval'),
|
|
21
|
+
[
|
|
22
|
+
'address',
|
|
23
|
+
'address',
|
|
24
|
+
],
|
|
25
|
+
[
|
|
26
|
+
token,
|
|
27
|
+
spender,
|
|
28
|
+
],
|
|
29
|
+
);
|
|
30
|
+
this.mappableArgs = [
|
|
31
|
+
this.args[0],
|
|
32
|
+
this.args[1],
|
|
33
|
+
];
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
async getAssetsToApprove() {
|
|
37
|
+
return [];
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -10,13 +10,14 @@ import { uint256 } from '../../types';
|
|
|
10
10
|
export class WrapEthAction extends ActionWithL2 {
|
|
11
11
|
/**
|
|
12
12
|
* @param amount Wrap amount
|
|
13
|
+
* @param includeEthInTx If true, the transaction will include the ETH value in the transaction
|
|
13
14
|
*/
|
|
14
|
-
constructor(amount:uint256) {
|
|
15
|
-
super('WrapEth', getAddr('WrapEth'), ['uint256'], [amount]);
|
|
15
|
+
constructor(amount:uint256, includeEthInTx = true) {
|
|
16
|
+
super('WrapEth', getAddr('WrapEth'), ['uint256', 'bool'], [amount, includeEthInTx]);
|
|
16
17
|
}
|
|
17
18
|
|
|
18
19
|
async getEthValue() {
|
|
19
|
-
return this.args[0];
|
|
20
|
+
return this.args[1] ? this.args[0] : 0;
|
|
20
21
|
}
|
|
21
22
|
|
|
22
23
|
encodeInputs() {
|
|
@@ -24,3 +24,6 @@ export * from './TokenizedVaultAdapterDepositAction';
|
|
|
24
24
|
export * from './TokenizedVaultAdapterMintAction';
|
|
25
25
|
export * from './TokenizedVaultAdapterRedeemAction';
|
|
26
26
|
export * from './TokenizedVaultAdapterWithdrawAction';
|
|
27
|
+
export * from './LimitSellAction';
|
|
28
|
+
export * from './ExecuteSafeTxAction';
|
|
29
|
+
export * from './RemoveTokenApprovalAction';
|
|
@@ -12,12 +12,11 @@ export class MakerGiveAction extends Action {
|
|
|
12
12
|
/**
|
|
13
13
|
* @param vaultId
|
|
14
14
|
* @param newOwner
|
|
15
|
-
* @param createProxy
|
|
16
15
|
* @param mcdManager
|
|
17
16
|
*/
|
|
18
|
-
constructor(vaultId:uint256, newOwner:EthAddress,
|
|
17
|
+
constructor(vaultId:uint256, newOwner:EthAddress, mcdManager:EthAddress = getAddr('McdCdpManager')) {
|
|
19
18
|
requireAddress(newOwner);
|
|
20
|
-
super('McdGive', getAddr('McdGive'), ['uint256', 'address', '
|
|
19
|
+
super('McdGive', getAddr('McdGive'), ['uint256', 'address', 'address'], [vaultId, newOwner, mcdManager]);
|
|
21
20
|
|
|
22
21
|
this.mappableArgs = [
|
|
23
22
|
this.args[0],
|
package/src/addresses.ts
CHANGED
|
@@ -24,7 +24,7 @@ export const actionAddresses = {
|
|
|
24
24
|
TokenizedVaultAdapter: '0x3944364Ce3a273D269707484F3a676fCa17E08b8',
|
|
25
25
|
|
|
26
26
|
// exchange
|
|
27
|
-
DFSSell: '
|
|
27
|
+
DFSSell: '0x561013c605A17f5dC5b738C8a3fF9c5F33DbC3d8',
|
|
28
28
|
|
|
29
29
|
// maker
|
|
30
30
|
McdGenerate: '0xCb50a91C0f12f439b8bf11E9474B9c1ED62Bf7a3',
|
|
@@ -122,7 +122,7 @@ export const actionAddresses = {
|
|
|
122
122
|
FLMaker: '0x672DE08e36A1698fD5e9E34045F81558dB4c1AFE',
|
|
123
123
|
FLBalancer: '0x540a83E36E5E6Aa916A6c591934d800e17115048',
|
|
124
124
|
FLSpark: '0xe9Fe5a0f5e4B370Ae60d837da58744666D5C06F7',
|
|
125
|
-
FLAction: '
|
|
125
|
+
FLAction: '0x2b10B000292745099Deb15304A247c0816bd8b73',
|
|
126
126
|
FLUniV3: '0x9CAdAC8Be718572F82B672b950c53F0b58483A35',
|
|
127
127
|
FLGho: '0xbb67b81dD080a406227A38965d0393f396ddECBc',
|
|
128
128
|
FLMorphoBlue: '0x6206C96EAc5EAC546861438A9f953B6BEa50EBAB',
|
|
@@ -392,7 +392,7 @@ export const actionAddresses = {
|
|
|
392
392
|
|
|
393
393
|
export const otherAddresses = {
|
|
394
394
|
[NETWORKS.ethereum.chainId]: {
|
|
395
|
-
RecipeExecutor: '
|
|
395
|
+
RecipeExecutor: '0x10B748Dc504C2515Bb6A9e23CB2F686090b6c584',
|
|
396
396
|
DFSRegistry: '0x287778F121F134C66212FB16c9b53eC991D32f5b',
|
|
397
397
|
DFSProxyRegistry: '0x29474FdaC7142f9aB7773B8e38264FA15E3805ed',
|
|
398
398
|
ProxyRegistry: '0x4678f0a6958e4D2Bc4F1BAF7Bc52E8F3564f3fE4',
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Action } from '../Action';
|
|
2
|
+
import { getAddr } from '../addresses';
|
|
3
|
+
import { uint256, uint8 } from '../types';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
*
|
|
7
|
+
*
|
|
8
|
+
* @category Triggers
|
|
9
|
+
*/
|
|
10
|
+
export class OffchainPriceTrigger extends Action {
|
|
11
|
+
constructor(limitPrice:uint256, limitType: uint8) {
|
|
12
|
+
super('OffchainPriceTrigger', getAddr('OffchainPriceTrigger'), ['uint256', 'uint8'], [limitPrice, limitType]);
|
|
13
|
+
}
|
|
14
|
+
}
|
package/src/triggers/index.ts
CHANGED