@defisaver/sdk 1.0.4 → 1.0.6

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 (44) hide show
  1. package/esm/src/Action.d.ts +1 -0
  2. package/esm/src/Action.js +16 -2
  3. package/esm/src/actions/basic/CreateSubAction.d.ts +13 -0
  4. package/esm/src/actions/basic/CreateSubAction.js +18 -0
  5. package/esm/src/actions/basic/UpdateSubAction.js +6 -0
  6. package/esm/src/actions/basic/index.d.ts +1 -0
  7. package/esm/src/actions/basic/index.js +1 -0
  8. package/esm/src/actions/chickenBonds/CBCreateRebondSubAction.d.ts +13 -0
  9. package/esm/src/actions/chickenBonds/CBCreateRebondSubAction.js +18 -0
  10. package/esm/src/actions/chickenBonds/CBUpdateRebondSubAction.d.ts +14 -0
  11. package/esm/src/actions/chickenBonds/CBUpdateRebondSubAction.js +16 -0
  12. package/esm/src/actions/chickenBonds/FetchBondIdAction.d.ts +15 -0
  13. package/esm/src/actions/chickenBonds/FetchBondIdAction.js +21 -0
  14. package/esm/src/actions/chickenBonds/index.d.ts +3 -0
  15. package/esm/src/actions/chickenBonds/index.js +3 -0
  16. package/esm/src/actions/curve/CurveDepositAction.js +1 -1
  17. package/esm/src/actions/curve/CurveWithdrawAction.d.ts +10 -9
  18. package/esm/src/actions/curve/CurveWithdrawAction.js +11 -10
  19. package/esm/src/addresses.d.ts +12 -0
  20. package/esm/src/addresses.js +9 -5
  21. package/esm/src/index.d.ts +48 -0
  22. package/esm/src/triggers/CBRebondTrigger.d.ts +10 -0
  23. package/esm/src/triggers/CBRebondTrigger.js +12 -0
  24. package/esm/src/triggers/index.d.ts +1 -0
  25. package/esm/src/triggers/index.js +1 -0
  26. package/esm/src/utils/curve-utils.d.ts +1 -1
  27. package/esm/src/utils/curve-utils.js +1 -1
  28. package/package-lock.json +8845 -0
  29. package/package.json +5 -3
  30. package/src/Action.ts +17 -2
  31. package/src/actions/basic/CreateSubAction.ts +23 -0
  32. package/src/actions/basic/UpdateSubAction.ts +8 -1
  33. package/src/actions/basic/index.ts +2 -1
  34. package/src/actions/chickenBonds/CBCreateRebondSubAction.ts +20 -0
  35. package/src/actions/chickenBonds/CBUpdateRebondSubAction.ts +18 -0
  36. package/src/actions/chickenBonds/FetchBondIdAction.ts +23 -0
  37. package/src/actions/chickenBonds/index.ts +5 -1
  38. package/src/actions/curve/CurveDepositAction.ts +2 -2
  39. package/src/actions/curve/CurveWithdrawAction.ts +21 -19
  40. package/src/addresses.ts +9 -6
  41. package/src/triggers/CBRebondTrigger.ts +14 -0
  42. package/src/triggers/index.ts +1 -0
  43. package/src/utils/curve-utils.ts +2 -1
  44. package/umd/index.js +486 -312
@@ -28,6 +28,7 @@ export declare class Action {
28
28
  *
29
29
  */
30
30
  _getArgumentMapping(): Args;
31
+ _parseParamType(paramType: string | ParamTypes, arg: Args): string | any[];
31
32
  /**
32
33
  *
33
34
  */
package/esm/src/Action.js CHANGED
@@ -61,12 +61,26 @@ export class Action {
61
61
  return 0;
62
62
  });
63
63
  }
64
+ _parseParamType(paramType, arg) {
65
+ if (typeof (paramType) === 'string') {
66
+ if (paramType.startsWith('(')) {
67
+ let _paramType = paramType.replace('(', '');
68
+ _paramType = _paramType.replace(')', '');
69
+ return _paramType.split(',');
70
+ }
71
+ if (paramType.endsWith('[]')) {
72
+ return Array.from(Array(arg.length).fill(paramType.replace('[]', '')));
73
+ }
74
+ }
75
+ return paramType;
76
+ }
64
77
  /**
65
78
  *
66
79
  */
67
80
  _replaceWithPlaceholders(arg, paramType) {
81
+ const paramTypeParsed = this._parseParamType(paramType, arg);
68
82
  if (Array.isArray(arg))
69
- return arg.map((_arg, i) => this._replaceWithPlaceholders(_arg, paramType[i]));
83
+ return arg.map((_arg, i) => this._replaceWithPlaceholders(_arg, paramTypeParsed[i]));
70
84
  if (typeof (paramType) === 'string') {
71
85
  if (new RegExp(/\$\d+/).test(arg))
72
86
  return __classPrivateFieldGet(this, _Action_instances, "m", _Action__getPlaceholderForType).call(this, paramType);
@@ -186,7 +200,7 @@ _Action_instances = new WeakSet(), _Action__getArgumentMappingWithSlots = functi
186
200
  // TODO handle arrays?
187
201
  // eslint-disable-next-line
188
202
  if (type.startsWith('bytes'))
189
- return `0x${'0'.repeat(parseInt(type.substr(5)))}`;
203
+ return `0x${'0'.repeat(parseInt(type.substr(5)) * 2)}`;
190
204
  if (type === 'address')
191
205
  return `0x${'0'.repeat(40)}`;
192
206
  if (type === 'string')
@@ -0,0 +1,13 @@
1
+ import { Action } from '../../Action';
2
+ import { bytes, bytes32, uint64 } from '../../types';
3
+ /**
4
+ * Action for creating a sub
5
+ *
6
+ * @category BasicActions
7
+ */
8
+ export declare class CreateSubAction extends Action {
9
+ /**
10
+ * @param sub object that contains new sub information
11
+ */
12
+ constructor(sub: [uint64, boolean, bytes[], bytes32[]]);
13
+ }
@@ -0,0 +1,18 @@
1
+ import { Action } from '../../Action';
2
+ import { getAddr } from '../../addresses';
3
+ /**
4
+ * Action for creating a sub
5
+ *
6
+ * @category BasicActions
7
+ */
8
+ export class CreateSubAction extends Action {
9
+ /**
10
+ * @param sub object that contains new sub information
11
+ */
12
+ constructor(sub) {
13
+ super('CreateSub', getAddr('CreateSub'), ['(uint64,bool,bytes[],bytes32[])'], [sub]);
14
+ for (let i = 0; i < this.args[0][3].length; i++) {
15
+ this.mappableArgs.push(this.args[0][3][i]);
16
+ }
17
+ }
18
+ }
@@ -12,5 +12,11 @@ export class UpdateSubAction extends Action {
12
12
  */
13
13
  constructor(subId, sub) {
14
14
  super('UpdateSub', getAddr('UpdateSub'), ['uint256', '(uint64,bool,bytes[],bytes32[])'], [subId, sub]);
15
+ this.mappableArgs = [
16
+ this.args[0],
17
+ ];
18
+ for (let i = 0; i < this.args[1][3].length; i++) {
19
+ this.mappableArgs.push(this.args[1][3][i]);
20
+ }
15
21
  }
16
22
  }
@@ -14,3 +14,4 @@ export * from './UpdateSubAction';
14
14
  export * from './ToggleSubAction';
15
15
  export * from './GasFeeActionL2';
16
16
  export * from './TransferNFTAction';
17
+ export * from './CreateSubAction';
@@ -14,3 +14,4 @@ export * from './UpdateSubAction';
14
14
  export * from './ToggleSubAction';
15
15
  export * from './GasFeeActionL2';
16
16
  export * from './TransferNFTAction';
17
+ export * from './CreateSubAction';
@@ -0,0 +1,13 @@
1
+ import { Action } from '../../Action';
2
+ import { uint256 } from '../../types';
3
+ /**
4
+ * CBCreateRebondSubAction - Subscribes to CB Rebond Strategy
5
+ *
6
+ * @category ChickenBonds
7
+ */
8
+ export declare class CBCreateRebondSubAction extends Action {
9
+ /**
10
+ * @param bondId {string} Id of the bond in the strategy
11
+ */
12
+ constructor(bondId: uint256);
13
+ }
@@ -0,0 +1,18 @@
1
+ import { Action } from '../../Action';
2
+ import { getAddr } from '../../addresses';
3
+ /**
4
+ * CBCreateRebondSubAction - Subscribes to CB Rebond Strategy
5
+ *
6
+ * @category ChickenBonds
7
+ */
8
+ export class CBCreateRebondSubAction extends Action {
9
+ /**
10
+ * @param bondId {string} Id of the bond in the strategy
11
+ */
12
+ constructor(bondId) {
13
+ super('CBCreateRebondSub', getAddr('CBCreateRebondSub'), ['uint256'], [bondId]);
14
+ this.mappableArgs = [
15
+ this.args[0],
16
+ ];
17
+ }
18
+ }
@@ -0,0 +1,14 @@
1
+ import { Action } from '../../Action';
2
+ import { uint256 } from '../../types';
3
+ /**
4
+ * CBUpdateRebondSubAction - Updates rebond strategy subscription
5
+ *
6
+ * @category ChickenBonds
7
+ */
8
+ export declare class CBUpdateRebondSubAction extends Action {
9
+ /**
10
+ * @param subId {string} Id of the subscription to update
11
+ * @param bondId {string} Id of the bond in the strategy
12
+ */
13
+ constructor(subId: uint256, bondId: uint256);
14
+ }
@@ -0,0 +1,16 @@
1
+ import { Action } from '../../Action';
2
+ import { getAddr } from '../../addresses';
3
+ /**
4
+ * CBUpdateRebondSubAction - Updates rebond strategy subscription
5
+ *
6
+ * @category ChickenBonds
7
+ */
8
+ export class CBUpdateRebondSubAction extends Action {
9
+ /**
10
+ * @param subId {string} Id of the subscription to update
11
+ * @param bondId {string} Id of the bond in the strategy
12
+ */
13
+ constructor(subId, bondId) {
14
+ super('CBUpdateRebondSub', getAddr('CBUpdateRebondSub'), ['uint256', 'uint256'], [subId, bondId]);
15
+ }
16
+ }
@@ -0,0 +1,15 @@
1
+ import { Action } from '../../Action';
2
+ import { uint256 } from '../../types';
3
+ /**
4
+ * FetchBondIdAction - action that retrieves CB BondId from a hashed strategy
5
+ *
6
+ * @category ChickenBonds
7
+ */
8
+ export declare class FetchBondIdAction extends Action {
9
+ /**
10
+ * @param paybackSourceId
11
+ * @param sourceType
12
+ * @param cbRebondBondId
13
+ */
14
+ constructor(paybackSourceId: uint256, sourceType: uint256, cbRebondBondId: uint256);
15
+ }
@@ -0,0 +1,21 @@
1
+ import { Action } from '../../Action';
2
+ import { getAddr } from '../../addresses';
3
+ /**
4
+ * FetchBondIdAction - action that retrieves CB BondId from a hashed strategy
5
+ *
6
+ * @category ChickenBonds
7
+ */
8
+ export class FetchBondIdAction extends Action {
9
+ /**
10
+ * @param paybackSourceId
11
+ * @param sourceType
12
+ * @param cbRebondBondId
13
+ */
14
+ constructor(paybackSourceId, sourceType, cbRebondBondId) {
15
+ super('FetchBondId', getAddr('FetchBondId'), ['uint256', 'uint256', 'uint256'], [paybackSourceId, sourceType, cbRebondBondId]);
16
+ this.mappableArgs = [
17
+ this.args[0],
18
+ this.args[1],
19
+ ];
20
+ }
21
+ }
@@ -2,3 +2,6 @@ export * from './CBCreateAction';
2
2
  export * from './CBChickenInAction';
3
3
  export * from './CBChickenOutAction';
4
4
  export * from './CBRedeemAction';
5
+ export * from './CBUpdateRebondSubAction';
6
+ export * from './FetchBondIdAction';
7
+ export * from './CBCreateRebondSubAction';
@@ -2,3 +2,6 @@ export * from './CBCreateAction';
2
2
  export * from './CBChickenInAction';
3
3
  export * from './CBChickenOutAction';
4
4
  export * from './CBRedeemAction';
5
+ export * from './CBUpdateRebondSubAction';
6
+ export * from './FetchBondIdAction';
7
+ export * from './CBCreateRebondSubAction';
@@ -54,7 +54,7 @@ export class CurveDepositAction extends Action {
54
54
  receiver,
55
55
  depositTarget,
56
56
  minMintAmount,
57
- makeFlags(depositTargetType, explicitUnderlying, 0),
57
+ makeFlags(depositTargetType, explicitUnderlying, 0, 0),
58
58
  amounts,
59
59
  ]);
60
60
  this.tokensForApproval = tokensForApproval;
@@ -6,15 +6,16 @@ import { EthAddress, uint256 } from '../../types';
6
6
  export declare class CurveWithdrawAction extends Action {
7
7
  lpToken: EthAddress;
8
8
  /**
9
- * @param sender
10
- * @param receiver
11
- * @param poolAddr
12
- * @param burnAmount
13
- * @param useUnderlying
14
- * @param withdrawExact
15
- * @param minAmounts
16
- */
17
- constructor(sender: EthAddress, receiver: EthAddress, poolAddr: EthAddress, burnAmount: uint256, useUnderlying: boolean, withdrawExact: boolean, minAmounts?: Array<uint256>);
9
+ * @param sender
10
+ * @param receiver
11
+ * @param poolAddr
12
+ * @param burnAmount
13
+ * @param useUnderlying
14
+ * @param withdrawExact
15
+ * @param minAmounts
16
+ * @param removeOneCoin
17
+ */
18
+ constructor(sender: EthAddress, receiver: EthAddress, poolAddr: EthAddress, burnAmount: uint256, useUnderlying: boolean, withdrawExact: boolean, removeOneCoin: boolean, minAmounts?: Array<uint256>);
18
19
  getAssetsToApprove(): Promise<{
19
20
  asset: string;
20
21
  owner: any;
@@ -16,15 +16,16 @@ import { poolInfo, makeFlags } from '../../utils/curve-utils';
16
16
  */
17
17
  export class CurveWithdrawAction extends Action {
18
18
  /**
19
- * @param sender
20
- * @param receiver
21
- * @param poolAddr
22
- * @param burnAmount
23
- * @param useUnderlying
24
- * @param withdrawExact
25
- * @param minAmounts
26
- */
27
- constructor(sender, receiver, poolAddr, burnAmount, useUnderlying, withdrawExact, minAmounts = []) {
19
+ * @param sender
20
+ * @param receiver
21
+ * @param poolAddr
22
+ * @param burnAmount
23
+ * @param useUnderlying
24
+ * @param withdrawExact
25
+ * @param minAmounts
26
+ * @param removeOneCoin
27
+ */
28
+ constructor(sender, receiver, poolAddr, burnAmount, useUnderlying, withdrawExact, removeOneCoin, minAmounts = []) {
28
29
  requireAddress(sender);
29
30
  requireAddress(receiver);
30
31
  let depositTarget;
@@ -51,7 +52,7 @@ export class CurveWithdrawAction extends Action {
51
52
  receiver,
52
53
  depositTarget,
53
54
  burnAmount,
54
- makeFlags(depositTargetType, explicitUnderlying, withdrawExact),
55
+ makeFlags(depositTargetType, explicitUnderlying, withdrawExact, removeOneCoin),
55
56
  minAmounts,
56
57
  ]);
57
58
  this.lpToken = pool.lpToken;
@@ -14,6 +14,7 @@ export declare const actionAddresses: {
14
14
  ToggleSub: string;
15
15
  UpdateSub: string;
16
16
  TransferNFT: string;
17
+ CreateSub: string;
17
18
  DFSSell: string;
18
19
  McdGenerate: string;
19
20
  McdGive: string;
@@ -93,6 +94,8 @@ export declare const actionAddresses: {
93
94
  CurveWithdraw: string;
94
95
  FLEuler: string;
95
96
  TrailingStopTrigger: string;
97
+ CBRebondTrigger: string;
98
+ CBUpdateRebondSub: string;
96
99
  ConvexDeposit: string;
97
100
  ConvexWithdraw: string;
98
101
  ConvexClaim: string;
@@ -100,6 +103,7 @@ export declare const actionAddresses: {
100
103
  CBRedeem: string;
101
104
  CBChickenIn: string;
102
105
  CBChickenOut: string;
106
+ CBCreateRebondSub: string;
103
107
  CompV3Allow: string;
104
108
  CompV3Borrow: string;
105
109
  CompV3Claim: string;
@@ -155,6 +159,7 @@ export declare const actionAddresses: {
155
159
  AutomationV2Unsub?: undefined;
156
160
  UpdateSub?: undefined;
157
161
  TransferNFT?: undefined;
162
+ CreateSub?: undefined;
158
163
  McdGenerate?: undefined;
159
164
  McdGive?: undefined;
160
165
  McdMerge?: undefined;
@@ -226,6 +231,8 @@ export declare const actionAddresses: {
226
231
  CurveWithdraw?: undefined;
227
232
  FLEuler?: undefined;
228
233
  TrailingStopTrigger?: undefined;
234
+ CBRebondTrigger?: undefined;
235
+ CBUpdateRebondSub?: undefined;
229
236
  ConvexDeposit?: undefined;
230
237
  ConvexWithdraw?: undefined;
231
238
  ConvexClaim?: undefined;
@@ -233,6 +240,7 @@ export declare const actionAddresses: {
233
240
  CBRedeem?: undefined;
234
241
  CBChickenIn?: undefined;
235
242
  CBChickenOut?: undefined;
243
+ CBCreateRebondSub?: undefined;
236
244
  CompV3Allow?: undefined;
237
245
  CompV3Borrow?: undefined;
238
246
  CompV3Claim?: undefined;
@@ -273,6 +281,7 @@ export declare const actionAddresses: {
273
281
  AutomationV2Unsub?: undefined;
274
282
  UpdateSub?: undefined;
275
283
  TransferNFT?: undefined;
284
+ CreateSub?: undefined;
276
285
  McdGenerate?: undefined;
277
286
  McdGive?: undefined;
278
287
  McdMerge?: undefined;
@@ -344,6 +353,8 @@ export declare const actionAddresses: {
344
353
  CurveWithdraw?: undefined;
345
354
  FLEuler?: undefined;
346
355
  TrailingStopTrigger?: undefined;
356
+ CBRebondTrigger?: undefined;
357
+ CBUpdateRebondSub?: undefined;
347
358
  ConvexDeposit?: undefined;
348
359
  ConvexWithdraw?: undefined;
349
360
  ConvexClaim?: undefined;
@@ -351,6 +362,7 @@ export declare const actionAddresses: {
351
362
  CBRedeem?: undefined;
352
363
  CBChickenIn?: undefined;
353
364
  CBChickenOut?: undefined;
365
+ CBCreateRebondSub?: undefined;
354
366
  CompV3Allow?: undefined;
355
367
  CompV3Borrow?: undefined;
356
368
  CompV3Claim?: undefined;
@@ -13,10 +13,11 @@ export const actionAddresses = {
13
13
  AutomationV2Unsub: '0xe35Fb12fE9796847751076aCf5ee7d124108612C',
14
14
  SendTokenAndUnwrap: '0xeecd376026335261c89faD40D89625391b1eFF6a',
15
15
  ToggleSub: '0x9A78E9d6538cfDbA0242Ca5eC46771E6132E8085',
16
- UpdateSub: '0x94D707f411B852082a5ce49C3f47c49c7757761f',
16
+ UpdateSub: '0x92e93a50F75dF380f0A34327Ce7243E43B74303c',
17
17
  TransferNFT: '0x861e893E1796F81248e75F06C0b09Abdc8fe2f6F',
18
+ CreateSub: '0x6C94C856361aB12165120a3A9A936c41Af238121',
18
19
  // exchange
19
- DFSSell: '0xB744474Bdd7226736ACa4Ba87593e32d8315e5c9',
20
+ DFSSell: '0x951D7B421f45FF0e4A8ddE0288aE3f9C2C69b784',
20
21
  // maker
21
22
  McdGenerate: '0xCb50a91C0f12f439b8bf11E9474B9c1ED62Bf7a3',
22
23
  McdGive: '0xf9556A87BF424834FDe7De0547b58E36Cb42EF01',
@@ -109,10 +110,12 @@ export const actionAddresses = {
109
110
  CurveStethPoolDeposit: '0x5Ae5870dC0C780e9eb68bE7a223eCd7F3BDad12B',
110
111
  CurveStethPoolWithdraw: '0x4089731d843Ce52699Fe64F68556aBbD95D70D00',
111
112
  CurveDeposit: '0x160225c24300bD9fAA03Bc007D5e72bDbbcA9257',
112
- CurveWithdraw: '0xA2A6D75417807ebAf8364613018D697f88021771',
113
+ CurveWithdraw: '0xb6Be5c486dD65c2cb18A388671b348E62307F0B3',
113
114
  // Euler
114
115
  FLEuler: '0x66DC6444CdC099153f89332e0d4C87af5C966A75',
115
116
  TrailingStopTrigger: '0x0000000000000000000000000000000000000000',
117
+ CBRebondTrigger: '0x6Bb48580977e2aBfD6c70B522204EFbe828a9428',
118
+ CBUpdateRebondSub: '0x2709Fd59a27F35997dFf618E3C68ABA1c9e91465',
116
119
  // Convex
117
120
  ConvexDeposit: '0x3Ecc4F1FD5aA09D2E13Ec9ebFdF102063d66F458',
118
121
  ConvexWithdraw: '0x2B2c235F9e27A121947c34A39d447bD4C585aA15',
@@ -122,6 +125,7 @@ export const actionAddresses = {
122
125
  CBRedeem: '0xdD06754cA5367B03af7014AB359332eD82D988d1',
123
126
  CBChickenIn: '0x1E990AF6dCf9E9f8a0b2fc76f3BC032A34fFfD14',
124
127
  CBChickenOut: '0x3d2f2d88749BB387abD07A2408b68D2Bf2D4be3f',
128
+ CBCreateRebondSub: '0x31Ebd23C00f3266ae84531025C91c030347CBCAA',
125
129
  // CompV3
126
130
  CompV3Allow: '0xC4a80f22bf56E0dFa2CB378561B934F41E14bc9f',
127
131
  CompV3Borrow: '0x11e7b984299a771C92CD42A87358a32791A75CEA',
@@ -132,7 +136,7 @@ export const actionAddresses = {
132
136
  CompV3Withdraw: '0x0b0F21EDE32DE4243D9145a899E97FC2366Aec46',
133
137
  },
134
138
  [NETWORKS.optimism.chainId]: {
135
- DFSSell: '0xBA0f6039b95CC0A02B5fc983eCf0FC4437BaacC7',
139
+ DFSSell: '0xC6c601fcAa870efd26C624F8c65fbc54cBe533b1',
136
140
  // basic
137
141
  WrapEth: '0x6D735db054AC4a1F10f96b99f8550E9eefbC2AC5',
138
142
  UnwrapEth: '0x1Fa75B00A05C2EbBd0EDF253a63c209966337A0d',
@@ -166,7 +170,7 @@ export const actionAddresses = {
166
170
  UniCreatePoolV3: '0xAF45d1380d89dB7260DC2684158c5dfA4E147d3e',
167
171
  },
168
172
  [NETWORKS.arbitrum.chainId]: {
169
- DFSSell: '0x77c02Bb7CbBb2F896c5Ea14e1b60D65f81e552db',
173
+ DFSSell: '0x9109F34AB28D369cF894aF45C50E976B8E312a82',
170
174
  // basic
171
175
  WrapEth: '0x35136b25bFA7CCC8f5b94E3181a16B61c06980F0',
172
176
  UnwrapEth: '0x2B69d494536098700910D167902D1d397dcA2B61',