@defisaver/sdk 1.3.28 → 1.3.29

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 (29) hide show
  1. package/esm/src/Action.js +23 -5
  2. package/esm/src/actions/index.d.ts +2 -1
  3. package/esm/src/actions/index.js +2 -1
  4. package/esm/src/actions/midnight/MidnightBorrowFromOrdersAction.d.ts +18 -0
  5. package/esm/src/actions/midnight/MidnightBorrowFromOrdersAction.js +28 -0
  6. package/esm/src/actions/midnight/MidnightPaybackDirectAction.d.ts +16 -0
  7. package/esm/src/actions/midnight/MidnightPaybackDirectAction.js +24 -0
  8. package/esm/src/actions/midnight/MidnightPaybackFromOrdersAction.d.ts +18 -0
  9. package/esm/src/actions/midnight/MidnightPaybackFromOrdersAction.js +28 -0
  10. package/esm/src/actions/midnight/MidnightSupplyCollateralAction.d.ts +17 -0
  11. package/esm/src/actions/midnight/MidnightSupplyCollateralAction.js +26 -0
  12. package/esm/src/actions/midnight/MidnightWithdrawCollateralAction.d.ts +17 -0
  13. package/esm/src/actions/midnight/MidnightWithdrawCollateralAction.js +26 -0
  14. package/esm/src/actions/midnight/index.d.ts +5 -0
  15. package/esm/src/actions/midnight/index.js +5 -0
  16. package/esm/src/addresses.d.ts +36 -0
  17. package/esm/src/addresses.js +6 -0
  18. package/esm/src/index.d.ts +144 -0
  19. package/package.json +1 -1
  20. package/src/Action.ts +21 -5
  21. package/src/actions/index.ts +2 -0
  22. package/src/actions/midnight/MidnightBorrowFromOrdersAction.ts +44 -0
  23. package/src/actions/midnight/MidnightPaybackDirectAction.ts +36 -0
  24. package/src/actions/midnight/MidnightPaybackFromOrdersAction.ts +44 -0
  25. package/src/actions/midnight/MidnightSupplyCollateralAction.ts +39 -0
  26. package/src/actions/midnight/MidnightWithdrawCollateralAction.ts +39 -0
  27. package/src/actions/midnight/index.ts +5 -0
  28. package/src/addresses.ts +7 -0
  29. package/umd/index.js +298 -91
package/esm/src/Action.js CHANGED
@@ -63,14 +63,32 @@ export class Action {
63
63
  }
64
64
  _parseParamType(paramType, arg) {
65
65
  if (typeof (paramType) === 'string') {
66
- if (paramType.startsWith('(')) {
67
- let _paramType = paramType.replace('(', '');
68
- _paramType = _paramType.replace(')', '');
69
- return _paramType.split(',');
70
- }
71
66
  if (paramType.endsWith('[]')) {
72
67
  return Array.from(Array(arg.length).fill(paramType.replace('[]', '')));
73
68
  }
69
+ if (paramType.startsWith('(') || paramType.startsWith('tuple(')) {
70
+ const tupleStart = paramType.indexOf('(');
71
+ const tupleEnd = paramType.lastIndexOf(')');
72
+ const tupleContents = paramType.slice(tupleStart + 1, tupleEnd);
73
+ const tupleTypes = [];
74
+ let currentType = '';
75
+ let nestingDepth = 0;
76
+ for (const character of tupleContents) {
77
+ if (character === ',' && nestingDepth === 0) {
78
+ tupleTypes.push(currentType);
79
+ currentType = '';
80
+ }
81
+ else {
82
+ currentType += character;
83
+ if (character === '(')
84
+ nestingDepth += 1;
85
+ if (character === ')')
86
+ nestingDepth -= 1;
87
+ }
88
+ }
89
+ tupleTypes.push(currentType);
90
+ return tupleTypes;
91
+ }
74
92
  }
75
93
  return paramType;
76
94
  }
@@ -40,4 +40,5 @@ import * as fluid from './fluid';
40
40
  import * as pendle from './pendle';
41
41
  import * as umbrella from './umbrella';
42
42
  import * as aaveV4 from './aavev4';
43
- 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, spark, curveusd, morphoblue, summerfi, llamalend, merkl, eulerV2, sky, liquityV2, stkgho, renzo, etherfi, fluid, pendle, umbrella, aaveV4, };
43
+ import * as midnight from './midnight';
44
+ 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, spark, curveusd, morphoblue, summerfi, llamalend, merkl, eulerV2, sky, liquityV2, stkgho, renzo, etherfi, fluid, pendle, umbrella, aaveV4, midnight, };
@@ -40,4 +40,5 @@ import * as fluid from './fluid';
40
40
  import * as pendle from './pendle';
41
41
  import * as umbrella from './umbrella';
42
42
  import * as aaveV4 from './aavev4';
43
- 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, spark, curveusd, morphoblue, summerfi, llamalend, merkl, eulerV2, sky, liquityV2, stkgho, renzo, etherfi, fluid, pendle, umbrella, aaveV4, };
43
+ import * as midnight from './midnight';
44
+ 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, spark, curveusd, morphoblue, summerfi, llamalend, merkl, eulerV2, sky, liquityV2, stkgho, renzo, etherfi, fluid, pendle, umbrella, aaveV4, midnight, };
@@ -0,0 +1,18 @@
1
+ import { Action } from '../../Action';
2
+ import { EthAddress, bytes32, uint256 } from '../../types';
3
+ /**
4
+ * MidnightBorrowFromOrdersAction - Borrow from one or more Midnight offers.
5
+ *
6
+ * @category MidnightBorrowFromOrders
7
+ */
8
+ export declare class MidnightBorrowFromOrdersAction extends Action {
9
+ /**
10
+ * @param marketId Market id.
11
+ * @param onBehalf Address to borrow tokens on behalf of. Defaults to the user's wallet if not provided.
12
+ * @param to Address to send the borrowed tokens to.
13
+ * @param amount Amount of tokens to borrow.
14
+ * @param maxUnits Maximum number of units to take from the orders (slippage protection).
15
+ * @param offerFills Array of offer fills to borrow from.
16
+ */
17
+ constructor(marketId: bytes32, onBehalf: EthAddress, to: EthAddress, amount: uint256, maxUnits: uint256, offerFills: Array<any>);
18
+ }
@@ -0,0 +1,28 @@
1
+ import { Action } from '../../Action';
2
+ import { getAddr } from '../../addresses';
3
+ const offerFillsParamType = 'tuple(tuple(tuple(uint256,address,address,tuple(address,uint256,uint256,address)[],uint256,uint256,address,address),bool,address,uint256,uint256,uint256,bytes32,address,bytes,address,address,bool,uint128,uint128,uint256),bytes,uint256)[]';
4
+ /**
5
+ * MidnightBorrowFromOrdersAction - Borrow from one or more Midnight offers.
6
+ *
7
+ * @category MidnightBorrowFromOrders
8
+ */
9
+ export class MidnightBorrowFromOrdersAction extends Action {
10
+ /**
11
+ * @param marketId Market id.
12
+ * @param onBehalf Address to borrow tokens on behalf of. Defaults to the user's wallet if not provided.
13
+ * @param to Address to send the borrowed tokens to.
14
+ * @param amount Amount of tokens to borrow.
15
+ * @param maxUnits Maximum number of units to take from the orders (slippage protection).
16
+ * @param offerFills Array of offer fills to borrow from.
17
+ */
18
+ constructor(marketId, onBehalf, to, amount, maxUnits, offerFills) {
19
+ super('MidnightBorrowFromOrders', getAddr('MidnightBorrowFromOrders'), ['bytes32', 'address', 'address', 'uint256', 'uint256', offerFillsParamType], [marketId, onBehalf, to, amount, maxUnits, offerFills]);
20
+ this.mappableArgs = [
21
+ this.args[0],
22
+ this.args[1],
23
+ this.args[2],
24
+ this.args[3],
25
+ this.args[4],
26
+ ];
27
+ }
28
+ }
@@ -0,0 +1,16 @@
1
+ import { Action } from '../../Action';
2
+ import { EthAddress, bytes32, uint256 } from '../../types';
3
+ /**
4
+ * MidnightPaybackDirectAction - Payback a debt directly to the Midnight protocol.
5
+ *
6
+ * @category MidnightPaybackDirect
7
+ */
8
+ export declare class MidnightPaybackDirectAction extends Action {
9
+ /**
10
+ * @param marketId Market id.
11
+ * @param onBehalf Address to payback tokens on behalf of.
12
+ * @param from Address from which to pull the payback tokens.
13
+ * @param amount Amount of tokens to payback. Send type(uint).max to payback whole amount.
14
+ */
15
+ constructor(marketId: bytes32, onBehalf: EthAddress, from: EthAddress, amount: uint256);
16
+ }
@@ -0,0 +1,24 @@
1
+ import { Action } from '../../Action';
2
+ import { getAddr } from '../../addresses';
3
+ /**
4
+ * MidnightPaybackDirectAction - Payback a debt directly to the Midnight protocol.
5
+ *
6
+ * @category MidnightPaybackDirect
7
+ */
8
+ export class MidnightPaybackDirectAction extends Action {
9
+ /**
10
+ * @param marketId Market id.
11
+ * @param onBehalf Address to payback tokens on behalf of.
12
+ * @param from Address from which to pull the payback tokens.
13
+ * @param amount Amount of tokens to payback. Send type(uint).max to payback whole amount.
14
+ */
15
+ constructor(marketId, onBehalf, from, amount) {
16
+ super('MidnightPaybackDirect', getAddr('MidnightPaybackDirect'), ['bytes32', 'address', 'address', 'uint256'], [marketId, onBehalf, from, amount]);
17
+ this.mappableArgs = [
18
+ this.args[0],
19
+ this.args[1],
20
+ this.args[2],
21
+ this.args[3],
22
+ ];
23
+ }
24
+ }
@@ -0,0 +1,18 @@
1
+ import { Action } from '../../Action';
2
+ import { EthAddress, bytes32, uint256 } from '../../types';
3
+ /**
4
+ * MidnightPaybackFromOrdersAction - Pay back debt through one or more Midnight offers.
5
+ *
6
+ * @category MidnightPaybackFromOrders
7
+ */
8
+ export declare class MidnightPaybackFromOrdersAction extends Action {
9
+ /**
10
+ * @param marketId Market id.
11
+ * @param onBehalf Address whose debt is repaid. Defaults to the user's wallet if not provided.
12
+ * @param from Address from which to pull the payback tokens.
13
+ * @param amount Amount of tokens to spend. Send type(uint).max to pay back the whole debt.
14
+ * @param minUnits Minimum number of debt units to repay (slippage protection).
15
+ * @param offerFills Array of offer fills to pay back from.
16
+ */
17
+ constructor(marketId: bytes32, onBehalf: EthAddress, from: EthAddress, amount: uint256, minUnits: uint256, offerFills: Array<any>);
18
+ }
@@ -0,0 +1,28 @@
1
+ import { Action } from '../../Action';
2
+ import { getAddr } from '../../addresses';
3
+ const offerFillsParamType = 'tuple(tuple(tuple(uint256,address,address,tuple(address,uint256,uint256,address)[],uint256,uint256,address,address),bool,address,uint256,uint256,uint256,bytes32,address,bytes,address,address,bool,uint128,uint128,uint256),bytes,uint256)[]';
4
+ /**
5
+ * MidnightPaybackFromOrdersAction - Pay back debt through one or more Midnight offers.
6
+ *
7
+ * @category MidnightPaybackFromOrders
8
+ */
9
+ export class MidnightPaybackFromOrdersAction extends Action {
10
+ /**
11
+ * @param marketId Market id.
12
+ * @param onBehalf Address whose debt is repaid. Defaults to the user's wallet if not provided.
13
+ * @param from Address from which to pull the payback tokens.
14
+ * @param amount Amount of tokens to spend. Send type(uint).max to pay back the whole debt.
15
+ * @param minUnits Minimum number of debt units to repay (slippage protection).
16
+ * @param offerFills Array of offer fills to pay back from.
17
+ */
18
+ constructor(marketId, onBehalf, from, amount, minUnits, offerFills) {
19
+ super('MidnightPaybackFromOrders', getAddr('MidnightPaybackFromOrders'), ['bytes32', 'address', 'address', 'uint256', 'uint256', offerFillsParamType], [marketId, onBehalf, from, amount, minUnits, offerFills]);
20
+ this.mappableArgs = [
21
+ this.args[0],
22
+ this.args[1],
23
+ this.args[2],
24
+ this.args[3],
25
+ this.args[4],
26
+ ];
27
+ }
28
+ }
@@ -0,0 +1,17 @@
1
+ import { Action } from '../../Action';
2
+ import { EthAddress, bytes32, uint256 } from '../../types';
3
+ /**
4
+ * MidnightSupplyCollateralAction
5
+ *
6
+ * @category MidnightSupplyCollateral
7
+ */
8
+ export declare class MidnightSupplyCollateralAction extends Action {
9
+ /**
10
+ * @param marketId Market id.
11
+ * @param onBehalf Address to supply tokens on behalf of.
12
+ * @param from Address from which to pull collateral asset.
13
+ * @param amount Amount of tokens to supply.
14
+ * @param collateralIndex Collateral index (0-based).
15
+ */
16
+ constructor(marketId: bytes32, onBehalf: EthAddress, from: EthAddress, amount: uint256, collateralIndex: uint256);
17
+ }
@@ -0,0 +1,26 @@
1
+ import { Action } from '../../Action';
2
+ import { getAddr } from '../../addresses';
3
+ /**
4
+ * MidnightSupplyCollateralAction
5
+ *
6
+ * @category MidnightSupplyCollateral
7
+ */
8
+ export class MidnightSupplyCollateralAction extends Action {
9
+ /**
10
+ * @param marketId Market id.
11
+ * @param onBehalf Address to supply tokens on behalf of.
12
+ * @param from Address from which to pull collateral asset.
13
+ * @param amount Amount of tokens to supply.
14
+ * @param collateralIndex Collateral index (0-based).
15
+ */
16
+ constructor(marketId, onBehalf, from, amount, collateralIndex) {
17
+ super('MidnightSupplyCollateral', getAddr('MidnightSupplyCollateral'), ['bytes32', 'address', 'address', 'uint256', 'uint256'], [marketId, onBehalf, from, amount, collateralIndex]);
18
+ this.mappableArgs = [
19
+ this.args[0],
20
+ this.args[1],
21
+ this.args[2],
22
+ this.args[3],
23
+ this.args[4],
24
+ ];
25
+ }
26
+ }
@@ -0,0 +1,17 @@
1
+ import { Action } from '../../Action';
2
+ import { EthAddress, bytes32, uint256 } from '../../types';
3
+ /**
4
+ * MidnightWithdrawCollateralAction
5
+ *
6
+ * @category MidnightWithdrawCollateral
7
+ */
8
+ export declare class MidnightWithdrawCollateralAction extends Action {
9
+ /**
10
+ * @param marketId Market id.
11
+ * @param onBehalf Address to withdraw tokens on behalf of.
12
+ * @param to Address that will receive the withdrawn tokens.
13
+ * @param amount Amount of tokens to withdraw. Send type(uint).max to withdraw whole amount.
14
+ * @param collateralIndex Collateral index (0-based).
15
+ */
16
+ constructor(marketId: bytes32, onBehalf: EthAddress, to: EthAddress, amount: uint256, collateralIndex: uint256);
17
+ }
@@ -0,0 +1,26 @@
1
+ import { Action } from '../../Action';
2
+ import { getAddr } from '../../addresses';
3
+ /**
4
+ * MidnightWithdrawCollateralAction
5
+ *
6
+ * @category MidnightWithdrawCollateral
7
+ */
8
+ export class MidnightWithdrawCollateralAction extends Action {
9
+ /**
10
+ * @param marketId Market id.
11
+ * @param onBehalf Address to withdraw tokens on behalf of.
12
+ * @param to Address that will receive the withdrawn tokens.
13
+ * @param amount Amount of tokens to withdraw. Send type(uint).max to withdraw whole amount.
14
+ * @param collateralIndex Collateral index (0-based).
15
+ */
16
+ constructor(marketId, onBehalf, to, amount, collateralIndex) {
17
+ super('MidnightWithdrawCollateral', getAddr('MidnightWithdrawCollateral'), ['bytes32', 'address', 'address', 'uint256', 'uint256'], [marketId, onBehalf, to, amount, collateralIndex]);
18
+ this.mappableArgs = [
19
+ this.args[0],
20
+ this.args[1],
21
+ this.args[2],
22
+ this.args[3],
23
+ this.args[4],
24
+ ];
25
+ }
26
+ }
@@ -0,0 +1,5 @@
1
+ export * from './MidnightSupplyCollateralAction';
2
+ export * from './MidnightWithdrawCollateralAction';
3
+ export * from './MidnightPaybackDirectAction';
4
+ export * from './MidnightBorrowFromOrdersAction';
5
+ export * from './MidnightPaybackFromOrdersAction';
@@ -0,0 +1,5 @@
1
+ export * from './MidnightSupplyCollateralAction';
2
+ export * from './MidnightWithdrawCollateralAction';
3
+ export * from './MidnightPaybackDirectAction';
4
+ export * from './MidnightBorrowFromOrdersAction';
5
+ export * from './MidnightPaybackFromOrdersAction';
@@ -294,6 +294,12 @@ export declare const actionAddresses: {
294
294
  GasFeeTakerL2?: undefined;
295
295
  AaveV3RatioCheck?: undefined;
296
296
  MorphoBlueView?: undefined;
297
+ MidnightPaybackDirect?: undefined;
298
+ MidnightBorrowFromOrders?: undefined;
299
+ MidnightPaybackFromOrders?: undefined;
300
+ MidnightSupplyCollateral?: undefined;
301
+ MidnightWithdrawCollateral?: undefined;
302
+ MidnightView?: undefined;
297
303
  } | {
298
304
  DFSSell: string;
299
305
  DFSSellNoFee: string;
@@ -588,6 +594,12 @@ export declare const actionAddresses: {
588
594
  AaveV4DelegateBorrowWithSig?: undefined;
589
595
  AaveV4DelegateSetUsingAsCollateralWithSig?: undefined;
590
596
  MorphoBlueView?: undefined;
597
+ MidnightPaybackDirect?: undefined;
598
+ MidnightBorrowFromOrders?: undefined;
599
+ MidnightPaybackFromOrders?: undefined;
600
+ MidnightSupplyCollateral?: undefined;
601
+ MidnightWithdrawCollateral?: undefined;
602
+ MidnightView?: undefined;
591
603
  } | {
592
604
  DFSSell: string;
593
605
  DFSSellNoFee: string;
@@ -882,6 +894,12 @@ export declare const actionAddresses: {
882
894
  AaveV4DelegateBorrowWithSig?: undefined;
883
895
  AaveV4DelegateSetUsingAsCollateralWithSig?: undefined;
884
896
  AaveV3RatioTrigger?: undefined;
897
+ MidnightPaybackDirect?: undefined;
898
+ MidnightBorrowFromOrders?: undefined;
899
+ MidnightPaybackFromOrders?: undefined;
900
+ MidnightSupplyCollateral?: undefined;
901
+ MidnightWithdrawCollateral?: undefined;
902
+ MidnightView?: undefined;
885
903
  } | {
886
904
  DFSSell: string;
887
905
  DFSSellNoFee: string;
@@ -955,6 +973,12 @@ export declare const actionAddresses: {
955
973
  SFApproveTokens: string;
956
974
  SummerfiUnsub: string;
957
975
  SummerfiUnsubV2: string;
976
+ MidnightPaybackDirect: string;
977
+ MidnightBorrowFromOrders: string;
978
+ MidnightPaybackFromOrders: string;
979
+ MidnightSupplyCollateral: string;
980
+ MidnightWithdrawCollateral: string;
981
+ MidnightView: string;
958
982
  AutomationV2Unsub?: undefined;
959
983
  SendTokenAndUnwrap?: undefined;
960
984
  SDaiWrap?: undefined;
@@ -1470,6 +1494,12 @@ export declare const actionAddresses: {
1470
1494
  GasFeeTakerL2?: undefined;
1471
1495
  AaveV3RatioCheck?: undefined;
1472
1496
  MorphoBlueView?: undefined;
1497
+ MidnightPaybackDirect?: undefined;
1498
+ MidnightBorrowFromOrders?: undefined;
1499
+ MidnightPaybackFromOrders?: undefined;
1500
+ MidnightSupplyCollateral?: undefined;
1501
+ MidnightWithdrawCollateral?: undefined;
1502
+ MidnightView?: undefined;
1473
1503
  } | {
1474
1504
  DFSSell: string;
1475
1505
  DFSSellNoFee: string;
@@ -1764,6 +1794,12 @@ export declare const actionAddresses: {
1764
1794
  GasFeeTakerL2?: undefined;
1765
1795
  AaveV3RatioCheck?: undefined;
1766
1796
  MorphoBlueView?: undefined;
1797
+ MidnightPaybackDirect?: undefined;
1798
+ MidnightBorrowFromOrders?: undefined;
1799
+ MidnightPaybackFromOrders?: undefined;
1800
+ MidnightSupplyCollateral?: undefined;
1801
+ MidnightWithdrawCollateral?: undefined;
1802
+ MidnightView?: undefined;
1767
1803
  };
1768
1804
  };
1769
1805
  export declare const otherAddresses: {
@@ -576,6 +576,12 @@ export const actionAddresses = {
576
576
  SFApproveTokens: '0x03EDC9A683f37BFB7516FF234223fFb6E38D5eb9',
577
577
  SummerfiUnsub: '0x0000000000000000000000000000000000000000',
578
578
  SummerfiUnsubV2: '0x60587B8Fe62Fc149d285a611822263206b4138da',
579
+ MidnightPaybackDirect: '0xC1B049A038f9E9811dc1Ad1D335369844d4268D9',
580
+ MidnightBorrowFromOrders: '0x82F9dd7eA821463178A2c7bC4047057Bd338E5e5',
581
+ MidnightPaybackFromOrders: '0x4B0c242195B1C941A2e7a871Bfa242c40dbf032F',
582
+ MidnightSupplyCollateral: '0xC83C7Ca37203FC30636EDcd3Ef127194542504c5',
583
+ MidnightWithdrawCollateral: '0x4fA4DA5fDD813279409B4Bf0Bde5Fe9ca8006A9C',
584
+ MidnightView: '0x3aa272f329E8B562A3bA56Bb6979a44D23A28839',
579
585
  },
580
586
  [NETWORKS.linea.chainId]: {
581
587
  // Basic