@defisaver/sdk 1.0.22 → 1.0.23-dev

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.
Files changed (41) hide show
  1. package/esm/src/Action.js +2 -1
  2. package/esm/src/actions/basic/ApproveTokenAction.d.ts +14 -0
  3. package/esm/src/actions/basic/ApproveTokenAction.js +22 -0
  4. package/esm/src/actions/basic/LSVSellAction.d.ts +23 -0
  5. package/esm/src/actions/basic/LSVSellAction.js +61 -0
  6. package/esm/src/actions/basic/index.d.ts +2 -0
  7. package/esm/src/actions/basic/index.js +2 -0
  8. package/esm/src/actions/index.d.ts +2 -1
  9. package/esm/src/actions/index.js +2 -1
  10. package/esm/src/actions/lsv/LSVBorrowAction.d.ts +14 -0
  11. package/esm/src/actions/lsv/LSVBorrowAction.js +16 -0
  12. package/esm/src/actions/lsv/LSVPaybackAction.d.ts +13 -0
  13. package/esm/src/actions/lsv/LSVPaybackAction.js +15 -0
  14. package/esm/src/actions/lsv/LSVSupplyAction.d.ts +15 -0
  15. package/esm/src/actions/lsv/LSVSupplyAction.js +17 -0
  16. package/esm/src/actions/lsv/LSVWithdrawAction.d.ts +15 -0
  17. package/esm/src/actions/lsv/LSVWithdrawAction.js +17 -0
  18. package/esm/src/actions/lsv/index.d.ts +4 -0
  19. package/esm/src/actions/lsv/index.js +4 -0
  20. package/esm/src/actions/morpho/aaveV3/MorphoAaveV3SetManagerAction.d.ts +14 -0
  21. package/esm/src/actions/morpho/aaveV3/MorphoAaveV3SetManagerAction.js +20 -0
  22. package/esm/src/actions/morpho/index.d.ts +1 -0
  23. package/esm/src/actions/morpho/index.js +1 -0
  24. package/esm/src/addresses.d.ts +21 -0
  25. package/esm/src/addresses.js +8 -0
  26. package/esm/src/index.d.ts +84 -0
  27. package/package.json +1 -1
  28. package/src/Action.ts +2 -1
  29. package/src/actions/basic/ApproveTokenAction.ts +29 -0
  30. package/src/actions/basic/LSVSellAction.ts +61 -0
  31. package/src/actions/basic/index.ts +2 -0
  32. package/src/actions/index.ts +2 -0
  33. package/src/actions/lsv/LSVBorrowAction.ts +18 -0
  34. package/src/actions/lsv/LSVPaybackAction.ts +17 -0
  35. package/src/actions/lsv/LSVSupplyAction.ts +19 -0
  36. package/src/actions/lsv/LSVWithdrawAction.ts +19 -0
  37. package/src/actions/lsv/index.ts +4 -0
  38. package/src/actions/morpho/aaveV3/MorphoAaveV3SetManagerAction.ts +28 -0
  39. package/src/actions/morpho/index.ts +1 -0
  40. package/src/addresses.ts +9 -0
  41. package/umd/index.js +1059 -772
package/esm/src/Action.js CHANGED
@@ -108,7 +108,8 @@ export class Action {
108
108
  return [AbiCoder.encodeParameter(_paramType, _arg)];
109
109
  }
110
110
  encodeForL2DsProxyCall() {
111
- return this._encodeForCall()[0];
111
+ const executeActionDirectAbi = (ActionAbi.find(({ name }) => name === 'executeActionDirect'));
112
+ return AbiCoder.encodeFunctionCall(executeActionDirectAbi, this._encodeForCall());
112
113
  }
113
114
  encodeForL2Recipe() {
114
115
  return this._encodeForCall()[0];
@@ -0,0 +1,14 @@
1
+ import { Action } from '../../Action';
2
+ import { EthAddress, uint256 } from '../../types';
3
+ /**
4
+ *
5
+ * @category BasicActions
6
+ */
7
+ export declare class ApproveTokenAction extends Action {
8
+ /**
9
+ * @param token Token address
10
+ * @param spender
11
+ * @param amount Transfer amount (-1 for whole Recipe (DsProxy) balance)
12
+ */
13
+ constructor(token: EthAddress, spender: EthAddress, amount: uint256);
14
+ }
@@ -0,0 +1,22 @@
1
+ import { Action } from '../../Action';
2
+ import { requireAddress } from '../../utils/general';
3
+ import { getAddr } from '../../addresses';
4
+ /**
5
+ *
6
+ * @category BasicActions
7
+ */
8
+ export class ApproveTokenAction extends Action {
9
+ /**
10
+ * @param token Token address
11
+ * @param spender
12
+ * @param amount Transfer amount (-1 for whole Recipe (DsProxy) balance)
13
+ */
14
+ constructor(token, spender, amount) {
15
+ requireAddress(spender);
16
+ super('ApproveToken', getAddr('ApproveToken'), [
17
+ 'address',
18
+ 'address',
19
+ 'uint',
20
+ ], [token, spender, amount]);
21
+ }
22
+ }
@@ -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
+ }
@@ -16,3 +16,5 @@ 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';
@@ -16,3 +16,5 @@ 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';
@@ -23,4 +23,5 @@ import * as chickenBonds from './chickenBonds';
23
23
  import * as compoundV3 from './compoundV3';
24
24
  import * as morpho from './morpho';
25
25
  import * as bprotocol from './bprotocol';
26
- export { aave, maker, compound, basic, flashloan, uniswap, reflexer, dydx, uniswapV3, checkers, liquity, yearn, lido, insta, balancer, curve, guni, mstable, rari, aaveV3, convex, chickenBonds, compoundV3, morpho, bprotocol, };
26
+ import * as lsv from './lsv';
27
+ export { aave, maker, compound, basic, flashloan, uniswap, reflexer, dydx, uniswapV3, checkers, liquity, yearn, lido, insta, balancer, curve, guni, mstable, rari, aaveV3, convex, chickenBonds, compoundV3, morpho, bprotocol, lsv, };
@@ -23,4 +23,5 @@ import * as chickenBonds from './chickenBonds';
23
23
  import * as compoundV3 from './compoundV3';
24
24
  import * as morpho from './morpho';
25
25
  import * as bprotocol from './bprotocol';
26
- export { aave, maker, compound, basic, flashloan, uniswap, reflexer, dydx, uniswapV3, checkers, liquity, yearn, lido, insta, balancer, curve, guni, mstable, rari, aaveV3, convex, chickenBonds, compoundV3, morpho, bprotocol, };
26
+ import * as lsv from './lsv';
27
+ export { aave, maker, compound, basic, flashloan, uniswap, reflexer, dydx, uniswapV3, checkers, liquity, yearn, lido, insta, balancer, curve, guni, mstable, rari, aaveV3, convex, chickenBonds, compoundV3, morpho, bprotocol, lsv, };
@@ -0,0 +1,14 @@
1
+ import { Action } from '../../Action';
2
+ import { uint256, uint8 } from '../../types';
3
+ /**
4
+ *
5
+ *
6
+ * @category LSV
7
+ */
8
+ export declare class LSVBorrowAction extends Action {
9
+ /**
10
+ * @param protocol
11
+ * @param amount
12
+ */
13
+ constructor(protocol: uint8, amount: uint256);
14
+ }
@@ -0,0 +1,16 @@
1
+ import { Action } from '../../Action';
2
+ import { getAddr } from '../../addresses';
3
+ /**
4
+ *
5
+ *
6
+ * @category LSV
7
+ */
8
+ export class LSVBorrowAction extends Action {
9
+ /**
10
+ * @param protocol
11
+ * @param amount
12
+ */
13
+ constructor(protocol, amount) {
14
+ super('LSVBorrow', getAddr('LSVBorrow'), ['uint8', 'uint256'], [protocol, amount]);
15
+ }
16
+ }
@@ -0,0 +1,13 @@
1
+ import { Action } from '../../Action';
2
+ import { uint8, uint256 } from '../../types';
3
+ /**
4
+ *
5
+ * @category LSV
6
+ */
7
+ export declare class LSVPaybackAction extends Action {
8
+ /**
9
+ * @param protocol
10
+ * @param amount
11
+ */
12
+ constructor(protocol: uint8, amount: uint256);
13
+ }
@@ -0,0 +1,15 @@
1
+ import { Action } from '../../Action';
2
+ import { getAddr } from '../../addresses';
3
+ /**
4
+ *
5
+ * @category LSV
6
+ */
7
+ export class LSVPaybackAction extends Action {
8
+ /**
9
+ * @param protocol
10
+ * @param amount
11
+ */
12
+ constructor(protocol, amount) {
13
+ super('LSVPayback', getAddr('LSVPayback'), ['uint8', 'uint256'], [protocol, amount]);
14
+ }
15
+ }
@@ -0,0 +1,15 @@
1
+ import { Action } from '../../Action';
2
+ import { EthAddress, uint256, uint8 } from '../../types';
3
+ /**
4
+ *
5
+ *
6
+ * @category LSV
7
+ */
8
+ export declare class LSVSupplyAction extends Action {
9
+ /**
10
+ * @param protocol
11
+ * @param token
12
+ * @param amount
13
+ */
14
+ constructor(protocol: uint8, token: EthAddress, amount: uint256);
15
+ }
@@ -0,0 +1,17 @@
1
+ import { Action } from '../../Action';
2
+ import { getAddr } from '../../addresses';
3
+ /**
4
+ *
5
+ *
6
+ * @category LSV
7
+ */
8
+ export class LSVSupplyAction extends Action {
9
+ /**
10
+ * @param protocol
11
+ * @param token
12
+ * @param amount
13
+ */
14
+ constructor(protocol, token, amount) {
15
+ super('LSVSupply', getAddr('LSVSupply'), ['uint8', 'address', 'uint256'], [protocol, token, amount]);
16
+ }
17
+ }
@@ -0,0 +1,15 @@
1
+ import { Action } from '../../Action';
2
+ import { EthAddress, uint256, uint8 } from '../../types';
3
+ /**
4
+ *
5
+ * @category LSV
6
+ */
7
+ export declare class LSVWithdrawAction extends Action {
8
+ /**
9
+ * @param protocol
10
+ * @param token
11
+ * @param amount
12
+ * @param isPositionClosing
13
+ */
14
+ constructor(protocol: uint8, token: EthAddress, amount: uint256, isPositionClosing: boolean);
15
+ }
@@ -0,0 +1,17 @@
1
+ import { Action } from '../../Action';
2
+ import { getAddr } from '../../addresses';
3
+ /**
4
+ *
5
+ * @category LSV
6
+ */
7
+ export class LSVWithdrawAction extends Action {
8
+ /**
9
+ * @param protocol
10
+ * @param token
11
+ * @param amount
12
+ * @param isPositionClosing
13
+ */
14
+ constructor(protocol, token, amount, isPositionClosing) {
15
+ super('LSVWithdraw', getAddr('LSVWithdraw'), ['uint8', 'address', 'uint256', 'bool'], [protocol, token, amount, isPositionClosing]);
16
+ }
17
+ }
@@ -0,0 +1,4 @@
1
+ export * from './LSVPaybackAction';
2
+ export * from './LSVWithdrawAction';
3
+ export * from './LSVSupplyAction';
4
+ export * from './LSVBorrowAction';
@@ -0,0 +1,4 @@
1
+ export * from './LSVPaybackAction';
2
+ export * from './LSVWithdrawAction';
3
+ export * from './LSVSupplyAction';
4
+ export * from './LSVBorrowAction';
@@ -0,0 +1,14 @@
1
+ import { Action } from '../../../Action';
2
+ import { EthAddress, uint256 } from '../../../types';
3
+ /**
4
+ *
5
+ * @category MorphoAaveV3
6
+ */
7
+ export declare class MorphoAaveV3SetManagerAction extends Action {
8
+ /**
9
+ * @param emodeId
10
+ * @param manager
11
+ * @param isAllowed
12
+ */
13
+ constructor(emodeId: uint256, manager: EthAddress, isAllowed: boolean);
14
+ }
@@ -0,0 +1,20 @@
1
+ import { Action } from '../../../Action';
2
+ import { getAddr } from '../../../addresses';
3
+ /**
4
+ *
5
+ * @category MorphoAaveV3
6
+ */
7
+ export class MorphoAaveV3SetManagerAction extends Action {
8
+ /**
9
+ * @param emodeId
10
+ * @param manager
11
+ * @param isAllowed
12
+ */
13
+ constructor(emodeId, manager, isAllowed) {
14
+ super('MorphoAaveV3SetManager', getAddr('MorphoAaveV3SetManager'), [
15
+ 'uint256',
16
+ 'address',
17
+ 'bool',
18
+ ], [emodeId, manager, isAllowed]);
19
+ }
20
+ }
@@ -7,3 +7,4 @@ export * from './aaveV3/MorphoAaveV3SupplyAction';
7
7
  export * from './aaveV3/MorphoAaveV3WithdrawAction';
8
8
  export * from './aaveV3/MorphoAaveV3BorrowAction';
9
9
  export * from './aaveV3/MorphoAaveV3PaybackAction';
10
+ export * from './aaveV3/MorphoAaveV3SetManagerAction';
@@ -7,3 +7,4 @@ export * from './aaveV3/MorphoAaveV3SupplyAction';
7
7
  export * from './aaveV3/MorphoAaveV3WithdrawAction';
8
8
  export * from './aaveV3/MorphoAaveV3BorrowAction';
9
9
  export * from './aaveV3/MorphoAaveV3PaybackAction';
10
+ export * from './aaveV3/MorphoAaveV3SetManagerAction';
@@ -15,6 +15,7 @@ export declare const actionAddresses: {
15
15
  UpdateSub: string;
16
16
  TransferNFT: string;
17
17
  CreateSub: string;
18
+ ApproveToken: string;
18
19
  DFSSell: string;
19
20
  McdGenerate: string;
20
21
  McdGive: string;
@@ -49,6 +50,11 @@ export declare const actionAddresses: {
49
50
  AaveV3Borrow: string;
50
51
  AaveV3ATokenPayback: string;
51
52
  AaveV3View: string;
53
+ LSVWithdraw: string;
54
+ LSVBorrow: string;
55
+ LSVSupply: string;
56
+ LSVPayback: string;
57
+ LSVSell: string;
52
58
  MorphoAaveV2Borrow: string;
53
59
  MorphoAaveV2Payback: string;
54
60
  MorphoAaveV2Supply: string;
@@ -58,6 +64,7 @@ export declare const actionAddresses: {
58
64
  MorphoAaveV3Payback: string;
59
65
  MorphoAaveV3Supply: string;
60
66
  MorphoAaveV3Withdraw: string;
67
+ MorphoAaveV3SetManager: string;
61
68
  CompBorrow: string;
62
69
  CompClaim: string;
63
70
  CompPayback: string;
@@ -181,6 +188,7 @@ export declare const actionAddresses: {
181
188
  UpdateSub?: undefined;
182
189
  TransferNFT?: undefined;
183
190
  CreateSub?: undefined;
191
+ ApproveToken?: undefined;
184
192
  McdGenerate?: undefined;
185
193
  McdGive?: undefined;
186
194
  McdMerge?: undefined;
@@ -205,6 +213,11 @@ export declare const actionAddresses: {
205
213
  AaveWithdraw?: undefined;
206
214
  AaveCollateralSwitch?: undefined;
207
215
  AaveV3View?: undefined;
216
+ LSVWithdraw?: undefined;
217
+ LSVBorrow?: undefined;
218
+ LSVSupply?: undefined;
219
+ LSVPayback?: undefined;
220
+ LSVSell?: undefined;
208
221
  MorphoAaveV2Borrow?: undefined;
209
222
  MorphoAaveV2Payback?: undefined;
210
223
  MorphoAaveV2Supply?: undefined;
@@ -214,6 +227,7 @@ export declare const actionAddresses: {
214
227
  MorphoAaveV3Payback?: undefined;
215
228
  MorphoAaveV3Supply?: undefined;
216
229
  MorphoAaveV3Withdraw?: undefined;
230
+ MorphoAaveV3SetManager?: undefined;
217
231
  CompBorrow?: undefined;
218
232
  CompClaim?: undefined;
219
233
  CompPayback?: undefined;
@@ -323,6 +337,7 @@ export declare const actionAddresses: {
323
337
  UpdateSub?: undefined;
324
338
  TransferNFT?: undefined;
325
339
  CreateSub?: undefined;
340
+ ApproveToken?: undefined;
326
341
  McdGenerate?: undefined;
327
342
  McdGive?: undefined;
328
343
  McdMerge?: undefined;
@@ -348,6 +363,11 @@ export declare const actionAddresses: {
348
363
  AaveCollateralSwitch?: undefined;
349
364
  AaveV3ClaimRewards?: undefined;
350
365
  AaveV3View?: undefined;
366
+ LSVWithdraw?: undefined;
367
+ LSVBorrow?: undefined;
368
+ LSVSupply?: undefined;
369
+ LSVPayback?: undefined;
370
+ LSVSell?: undefined;
351
371
  MorphoAaveV2Borrow?: undefined;
352
372
  MorphoAaveV2Payback?: undefined;
353
373
  MorphoAaveV2Supply?: undefined;
@@ -357,6 +377,7 @@ export declare const actionAddresses: {
357
377
  MorphoAaveV3Payback?: undefined;
358
378
  MorphoAaveV3Supply?: undefined;
359
379
  MorphoAaveV3Withdraw?: undefined;
380
+ MorphoAaveV3SetManager?: undefined;
360
381
  CompBorrow?: undefined;
361
382
  CompClaim?: undefined;
362
383
  CompPayback?: undefined;
@@ -16,6 +16,7 @@ export const actionAddresses = {
16
16
  UpdateSub: '0xF6Cb8f7e61a64075ec8FAC3f298745605E543233',
17
17
  TransferNFT: '0x861e893E1796F81248e75F06C0b09Abdc8fe2f6F',
18
18
  CreateSub: '0x7308e88BB21B934478E75bB6A2143b8cfDFf2961',
19
+ ApproveToken: '0x0000000000000000000000000000000000000000',
19
20
  // exchange
20
21
  DFSSell: '0x951D7B421f45FF0e4A8ddE0288aE3f9C2C69b784',
21
22
  // maker
@@ -56,6 +57,12 @@ export const actionAddresses = {
56
57
  AaveV3Borrow: '0x7079ba1Bd00EeFCD2a260BbD6D088230505e3858',
57
58
  AaveV3ATokenPayback: '0xDe5c012cd1878D86E91309593764895a3adb380E',
58
59
  AaveV3View: '0x9ECB0645b357fDD7B92789B91595160862Bd45d0',
60
+ // LSV action
61
+ LSVWithdraw: '0x0000000000000000000000000000000000000000',
62
+ LSVBorrow: '0x0000000000000000000000000000000000000000',
63
+ LSVSupply: '0x0000000000000000000000000000000000000000',
64
+ LSVPayback: '0x0000000000000000000000000000000000000000',
65
+ LSVSell: '0x0000000000000000000000000000000000000000',
59
66
  // morpho aave v2
60
67
  MorphoAaveV2Borrow: '0xa85C3E41Bf9F75a381927e1Aa9b00f77C4631109',
61
68
  MorphoAaveV2Payback: '0x5dd0E0835acbb08aa4A4599d70fB2d93969fa7b7',
@@ -67,6 +74,7 @@ export const actionAddresses = {
67
74
  MorphoAaveV3Payback: '0x36b8b968c81D97cBfAa642e206b634A6f378d287',
68
75
  MorphoAaveV3Supply: '0x51fA8FBc6F0aDEfe2FBA06104FCA39f5beD69291',
69
76
  MorphoAaveV3Withdraw: '0xdc3e74C4cD577275296ceFE36A3D082223AfF206',
77
+ MorphoAaveV3SetManager: '0x0000000000000000000000000000000000000000',
70
78
  // compound
71
79
  CompBorrow: '0x8495579BF6Ae848f7E59686536F834f1d2CCd79C',
72
80
  CompClaim: '0x81F488cF7A0128A9DB5e7207042cCAB1CB0ac902',