@gearbox-protocol/sdk 3.0.0-next.12 → 3.0.0-next.14

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.
@@ -54,7 +54,6 @@ export declare class CreditAccountData {
54
54
  readonly schedultedWithdrawals: Array<ScheduledWithdrawal>;
55
55
  constructor(payload: CreditAccountDataPayload);
56
56
  setDeleteInProgress(d: boolean): void;
57
- balancesSorted(prices: Record<string, bigint>, tokens: Record<string, TokenData>): Array<Asset>;
58
57
  static sortBalances(balances: Record<string, bigint>, prices: Record<string, bigint>, tokens: Record<string, TokenData>): Array<[string, bigint]>;
59
58
  static tokensAbcComparator(t1?: TokenData, t2?: TokenData): 1 | -1;
60
59
  static amountAbcComparator(t1: bigint, t2: bigint): 1 | -1;
@@ -105,9 +105,6 @@ class CreditAccountData {
105
105
  setDeleteInProgress(d) {
106
106
  this.isDeleting = d;
107
107
  }
108
- balancesSorted(prices, tokens) {
109
- return CreditAccountData.sortBalances(this.balances, prices, tokens).map(([token, balance]) => ({ token, balance }));
110
- }
111
108
  static sortBalances(balances, prices, tokens) {
112
109
  return Object.entries(balances).sort(([addr1, amount1], [addr2, amount2]) => {
113
110
  const addr1Lc = addr1.toLowerCase();
@@ -13,7 +13,7 @@ export declare class CreditManagerData {
13
13
  readonly isPaused: boolean;
14
14
  readonly forbiddenTokenMask: bigint;
15
15
  readonly maxEnabledTokensLength: number;
16
- readonly description: string;
16
+ readonly name: string;
17
17
  readonly borrowRate: number;
18
18
  readonly minDebt: bigint;
19
19
  readonly maxDebt: bigint;
@@ -16,7 +16,7 @@ class CreditManagerData {
16
16
  isPaused;
17
17
  forbiddenTokenMask; // V2 only: mask which forbids some particular tokens
18
18
  maxEnabledTokensLength;
19
- description;
19
+ name;
20
20
  borrowRate;
21
21
  minDebt;
22
22
  maxDebt;
@@ -46,7 +46,7 @@ class CreditManagerData {
46
46
  this.isPaused = payload.isPaused;
47
47
  this.forbiddenTokenMask = (0, sdk_gov_1.toBigInt)(payload.forbiddenTokenMask);
48
48
  this.maxEnabledTokensLength = payload.maxEnabledTokensLength;
49
- this.description = payload.description;
49
+ this.name = payload.name;
50
50
  this.borrowRate = Number(((0, sdk_gov_1.toBigInt)(payload.baseBorrowRate) *
51
51
  ((0, sdk_gov_1.toBigInt)(payload.feeInterest) + sdk_gov_1.PERCENTAGE_FACTOR) *
52
52
  sdk_gov_1.PERCENTAGE_DECIMALS) /
@@ -77,11 +77,12 @@ class PoolData {
77
77
  ];
78
78
  }));
79
79
  this.zappers = Object.fromEntries(payload.zappers.map(z => {
80
- const tokenFrom = z.tokenFrom.toLowerCase();
80
+ const tokenIn = z.tokenIn.toLowerCase();
81
81
  return [
82
- tokenFrom,
82
+ tokenIn,
83
83
  {
84
- tokenFrom,
84
+ tokenIn,
85
+ tokenOut: z.tokenOut.toLowerCase(),
85
86
  zapper: z.zapper.toLowerCase(),
86
87
  },
87
88
  ];
@@ -1,7 +1,8 @@
1
1
  import { SupportedContract } from "@gearbox-protocol/sdk-gov";
2
+ import { Asset } from "./assets";
2
3
  import { EVMTx, EVMTxProps } from "./eventOrTx";
3
4
  export interface TxSerialized {
4
- type: "TxAddLiquidity" | "TxRemoveLiquidity" | "TxSwap" | "TxAddCollateral" | "TxIncreaseBorrowAmount" | "TxDecreaseBorrowAmount" | "TxOpenAccount" | "TxRepayAccount" | "TxCloseAccount" | "TxApprove" | "TxOpenMultitokenAccount" | "TxClaimReward" | "TxClaimNFT" | "TxClaimGearRewards" | "TxEnableTokens";
5
+ type: "TxAddLiquidity" | "TxRemoveLiquidity" | "TxSwap" | "TxAddCollateral" | "TxIncreaseBorrowAmount" | "TxDecreaseBorrowAmount" | "TxOpenAccount" | "TxRepayAccount" | "TxCloseAccount" | "TxApprove" | "TxOpenMultitokenAccount" | "TxClaimReward" | "TxClaimNFT" | "TxClaimGearRewards" | "TxEnableTokens" | "TxUpdateQuota";
5
6
  content: string;
6
7
  }
7
8
  export declare class TxSerializer {
@@ -190,4 +191,17 @@ export declare class TxEnableTokens extends EVMTx {
190
191
  toString(): string;
191
192
  serialize(): TxSerialized;
192
193
  }
194
+ interface TxUpdateQuotaProps extends EVMTxProps {
195
+ updatedQuotas: Array<Asset>;
196
+ underlyingToken: string;
197
+ creditManager: string;
198
+ }
199
+ export declare class TxUpdateQuota extends EVMTx {
200
+ readonly updatedQuotas: Array<Asset>;
201
+ readonly underlyingToken: string;
202
+ readonly creditManager: string;
203
+ constructor(opts: TxUpdateQuotaProps);
204
+ toString(): string;
205
+ serialize(): TxSerialized;
206
+ }
193
207
  export {};
@@ -1,9 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TxEnableTokens = exports.TxApprove = exports.TxCloseAccount = exports.TxRepayAccount = exports.TxClaimGearRewards = exports.TxClaimNFT = exports.TxClaimReward = exports.TxOpenMultitokenAccount = exports.TxOpenAccount = exports.TxDecreaseBorrowAmount = exports.TxIncreaseBorrowAmount = exports.TxAddCollateral = exports.TXSwap = exports.TxRemoveLiquidity = exports.TxAddLiquidity = exports.TxSerializer = void 0;
3
+ exports.TxUpdateQuota = exports.TxEnableTokens = exports.TxApprove = exports.TxCloseAccount = exports.TxRepayAccount = exports.TxClaimGearRewards = exports.TxClaimNFT = exports.TxClaimReward = exports.TxOpenMultitokenAccount = exports.TxOpenAccount = exports.TxDecreaseBorrowAmount = exports.TxIncreaseBorrowAmount = exports.TxAddCollateral = exports.TXSwap = exports.TxRemoveLiquidity = exports.TxAddLiquidity = exports.TxSerializer = void 0;
4
4
  const sdk_gov_1 = require("@gearbox-protocol/sdk-gov");
5
5
  const contractsRegister_1 = require("../contracts/contractsRegister");
6
6
  const formatter_1 = require("../utils/formatter");
7
+ const math_1 = require("../utils/math");
7
8
  const eventOrTx_1 = require("./eventOrTx");
8
9
  class TxSerializer {
9
10
  static serialize(items) {
@@ -43,6 +44,8 @@ class TxSerializer {
43
44
  return new TxClaimGearRewards(params);
44
45
  case "TxEnableTokens":
45
46
  return new TxEnableTokens(params);
47
+ case "TxUpdateQuota":
48
+ return new TxUpdateQuota(params);
46
49
  default:
47
50
  throw new Error(`Unknown transaction for parsing: ${e.type}`);
48
51
  }
@@ -470,3 +473,36 @@ class TxEnableTokens extends eventOrTx_1.EVMTx {
470
473
  }
471
474
  }
472
475
  exports.TxEnableTokens = TxEnableTokens;
476
+ class TxUpdateQuota extends eventOrTx_1.EVMTx {
477
+ updatedQuotas;
478
+ underlyingToken;
479
+ creditManager;
480
+ constructor(opts) {
481
+ super({
482
+ block: opts.block,
483
+ txHash: opts.txHash,
484
+ txStatus: opts.txStatus,
485
+ timestamp: opts.timestamp,
486
+ });
487
+ this.updatedQuotas = opts.updatedQuotas;
488
+ this.creditManager = opts.creditManager;
489
+ this.underlyingToken = opts.underlyingToken;
490
+ }
491
+ toString() {
492
+ const [, underlyingDecimals] = (0, sdk_gov_1.extractTokenData)(this.underlyingToken);
493
+ const quota = this.updatedQuotas.map(({ token, balance }) => {
494
+ const [tokenSymbol] = (0, sdk_gov_1.extractTokenData)(token);
495
+ const sign = balance < 0 ? "-" : "";
496
+ const amountString = (0, formatter_1.formatBN)(math_1.BigIntMath.abs(balance), underlyingDecimals || 18);
497
+ return `${tokenSymbol} by ${sign}${amountString}`;
498
+ });
499
+ return `Credit account ${(0, contractsRegister_1.getContractName)(this.creditManager)} quota updated: ${quota.join("; ")}`;
500
+ }
501
+ serialize() {
502
+ return {
503
+ type: "TxEnableTokens",
504
+ content: JSON.stringify(this),
505
+ };
506
+ }
507
+ }
508
+ exports.TxUpdateQuota = TxUpdateQuota;
@@ -208,7 +208,7 @@ export type LinearModelStructOutput = [
208
208
  };
209
209
  export type CreditManagerDataStruct = {
210
210
  addr: PromiseOrValue<string>;
211
- description: PromiseOrValue<string>;
211
+ name: PromiseOrValue<string>;
212
212
  cfVersion: PromiseOrValue<BigNumberish>;
213
213
  creditFacade: PromiseOrValue<string>;
214
214
  creditConfigurator: PromiseOrValue<string>;
@@ -267,7 +267,7 @@ export type CreditManagerDataStructOutput = [
267
267
  boolean
268
268
  ] & {
269
269
  addr: string;
270
- description: string;
270
+ name: string;
271
271
  cfVersion: BigNumber;
272
272
  creditFacade: string;
273
273
  creditConfigurator: string;
@@ -313,12 +313,14 @@ export type CreditManagerDebtParamsStructOutput = [
313
313
  availableToBorrow: BigNumber;
314
314
  };
315
315
  export type ZapperInfoStruct = {
316
- tokenFrom: PromiseOrValue<string>;
317
316
  zapper: PromiseOrValue<string>;
317
+ tokenIn: PromiseOrValue<string>;
318
+ tokenOut: PromiseOrValue<string>;
318
319
  };
319
- export type ZapperInfoStructOutput = [string, string] & {
320
- tokenFrom: string;
320
+ export type ZapperInfoStructOutput = [string, string, string] & {
321
321
  zapper: string;
322
+ tokenIn: string;
323
+ tokenOut: string;
322
324
  };
323
325
  export type PoolDataStruct = {
324
326
  addr: PromiseOrValue<string>;
@@ -216,7 +216,7 @@ export type LinearModelStructOutput = [
216
216
  };
217
217
  export type CreditManagerDataStruct = {
218
218
  addr: PromiseOrValue<string>;
219
- description: PromiseOrValue<string>;
219
+ name: PromiseOrValue<string>;
220
220
  cfVersion: PromiseOrValue<BigNumberish>;
221
221
  creditFacade: PromiseOrValue<string>;
222
222
  creditConfigurator: PromiseOrValue<string>;
@@ -275,7 +275,7 @@ export type CreditManagerDataStructOutput = [
275
275
  boolean
276
276
  ] & {
277
277
  addr: string;
278
- description: string;
278
+ name: string;
279
279
  cfVersion: BigNumber;
280
280
  creditFacade: string;
281
281
  creditConfigurator: string;
@@ -321,12 +321,14 @@ export type CreditManagerDebtParamsStructOutput = [
321
321
  availableToBorrow: BigNumber;
322
322
  };
323
323
  export type ZapperInfoStruct = {
324
- tokenFrom: PromiseOrValue<string>;
325
324
  zapper: PromiseOrValue<string>;
325
+ tokenIn: PromiseOrValue<string>;
326
+ tokenOut: PromiseOrValue<string>;
326
327
  };
327
- export type ZapperInfoStructOutput = [string, string] & {
328
- tokenFrom: string;
328
+ export type ZapperInfoStructOutput = [string, string, string] & {
329
329
  zapper: string;
330
+ tokenIn: string;
331
+ tokenOut: string;
330
332
  };
331
333
  export type PoolDataStruct = {
332
334
  addr: PromiseOrValue<string>;
@@ -392,7 +392,7 @@ export declare class IDataCompressorV2_10__factory {
392
392
  readonly type: "address";
393
393
  }, {
394
394
  readonly internalType: "string";
395
- readonly name: "description";
395
+ readonly name: "name";
396
396
  readonly type: "string";
397
397
  }, {
398
398
  readonly internalType: "uint256";
@@ -586,7 +586,7 @@ export declare class IDataCompressorV2_10__factory {
586
586
  readonly type: "address";
587
587
  }, {
588
588
  readonly internalType: "string";
589
- readonly name: "description";
589
+ readonly name: "name";
590
590
  readonly type: "string";
591
591
  }, {
592
592
  readonly internalType: "uint256";
@@ -915,11 +915,15 @@ export declare class IDataCompressorV2_10__factory {
915
915
  }, {
916
916
  readonly components: readonly [{
917
917
  readonly internalType: "address";
918
- readonly name: "tokenFrom";
918
+ readonly name: "zapper";
919
919
  readonly type: "address";
920
920
  }, {
921
921
  readonly internalType: "address";
922
- readonly name: "zapper";
922
+ readonly name: "tokenIn";
923
+ readonly type: "address";
924
+ }, {
925
+ readonly internalType: "address";
926
+ readonly name: "tokenOut";
923
927
  readonly type: "address";
924
928
  }];
925
929
  readonly internalType: "struct ZapperInfo[]";
@@ -1118,11 +1122,15 @@ export declare class IDataCompressorV2_10__factory {
1118
1122
  }, {
1119
1123
  readonly components: readonly [{
1120
1124
  readonly internalType: "address";
1121
- readonly name: "tokenFrom";
1125
+ readonly name: "zapper";
1122
1126
  readonly type: "address";
1123
1127
  }, {
1124
1128
  readonly internalType: "address";
1125
- readonly name: "zapper";
1129
+ readonly name: "tokenIn";
1130
+ readonly type: "address";
1131
+ }, {
1132
+ readonly internalType: "address";
1133
+ readonly name: "tokenOut";
1126
1134
  readonly type: "address";
1127
1135
  }];
1128
1136
  readonly internalType: "struct ZapperInfo[]";
@@ -504,7 +504,7 @@ const _abi = [
504
504
  },
505
505
  {
506
506
  internalType: "string",
507
- name: "description",
507
+ name: "name",
508
508
  type: "string",
509
509
  },
510
510
  {
@@ -750,7 +750,7 @@ const _abi = [
750
750
  },
751
751
  {
752
752
  internalType: "string",
753
- name: "description",
753
+ name: "name",
754
754
  type: "string",
755
755
  },
756
756
  {
@@ -1168,12 +1168,17 @@ const _abi = [
1168
1168
  components: [
1169
1169
  {
1170
1170
  internalType: "address",
1171
- name: "tokenFrom",
1171
+ name: "zapper",
1172
1172
  type: "address",
1173
1173
  },
1174
1174
  {
1175
1175
  internalType: "address",
1176
- name: "zapper",
1176
+ name: "tokenIn",
1177
+ type: "address",
1178
+ },
1179
+ {
1180
+ internalType: "address",
1181
+ name: "tokenOut",
1177
1182
  type: "address",
1178
1183
  },
1179
1184
  ],
@@ -1426,12 +1431,17 @@ const _abi = [
1426
1431
  components: [
1427
1432
  {
1428
1433
  internalType: "address",
1429
- name: "tokenFrom",
1434
+ name: "zapper",
1430
1435
  type: "address",
1431
1436
  },
1432
1437
  {
1433
1438
  internalType: "address",
1434
- name: "zapper",
1439
+ name: "tokenIn",
1440
+ type: "address",
1441
+ },
1442
+ {
1443
+ internalType: "address",
1444
+ name: "tokenOut",
1435
1445
  type: "address",
1436
1446
  },
1437
1447
  ],
@@ -586,7 +586,7 @@ export declare class IDataCompressorV3_00__factory {
586
586
  readonly type: "address";
587
587
  }, {
588
588
  readonly internalType: "string";
589
- readonly name: "description";
589
+ readonly name: "name";
590
590
  readonly type: "string";
591
591
  }, {
592
592
  readonly internalType: "uint256";
@@ -780,7 +780,7 @@ export declare class IDataCompressorV3_00__factory {
780
780
  readonly type: "address";
781
781
  }, {
782
782
  readonly internalType: "string";
783
- readonly name: "description";
783
+ readonly name: "name";
784
784
  readonly type: "string";
785
785
  }, {
786
786
  readonly internalType: "uint256";
@@ -1109,11 +1109,15 @@ export declare class IDataCompressorV3_00__factory {
1109
1109
  }, {
1110
1110
  readonly components: readonly [{
1111
1111
  readonly internalType: "address";
1112
- readonly name: "tokenFrom";
1112
+ readonly name: "zapper";
1113
1113
  readonly type: "address";
1114
1114
  }, {
1115
1115
  readonly internalType: "address";
1116
- readonly name: "zapper";
1116
+ readonly name: "tokenIn";
1117
+ readonly type: "address";
1118
+ }, {
1119
+ readonly internalType: "address";
1120
+ readonly name: "tokenOut";
1117
1121
  readonly type: "address";
1118
1122
  }];
1119
1123
  readonly internalType: "struct ZapperInfo[]";
@@ -1312,11 +1316,15 @@ export declare class IDataCompressorV3_00__factory {
1312
1316
  }, {
1313
1317
  readonly components: readonly [{
1314
1318
  readonly internalType: "address";
1315
- readonly name: "tokenFrom";
1319
+ readonly name: "zapper";
1316
1320
  readonly type: "address";
1317
1321
  }, {
1318
1322
  readonly internalType: "address";
1319
- readonly name: "zapper";
1323
+ readonly name: "tokenIn";
1324
+ readonly type: "address";
1325
+ }, {
1326
+ readonly internalType: "address";
1327
+ readonly name: "tokenOut";
1320
1328
  readonly type: "address";
1321
1329
  }];
1322
1330
  readonly internalType: "struct ZapperInfo[]";
@@ -751,7 +751,7 @@ const _abi = [
751
751
  },
752
752
  {
753
753
  internalType: "string",
754
- name: "description",
754
+ name: "name",
755
755
  type: "string",
756
756
  },
757
757
  {
@@ -997,7 +997,7 @@ const _abi = [
997
997
  },
998
998
  {
999
999
  internalType: "string",
1000
- name: "description",
1000
+ name: "name",
1001
1001
  type: "string",
1002
1002
  },
1003
1003
  {
@@ -1415,12 +1415,17 @@ const _abi = [
1415
1415
  components: [
1416
1416
  {
1417
1417
  internalType: "address",
1418
- name: "tokenFrom",
1418
+ name: "zapper",
1419
1419
  type: "address",
1420
1420
  },
1421
1421
  {
1422
1422
  internalType: "address",
1423
- name: "zapper",
1423
+ name: "tokenIn",
1424
+ type: "address",
1425
+ },
1426
+ {
1427
+ internalType: "address",
1428
+ name: "tokenOut",
1424
1429
  type: "address",
1425
1430
  },
1426
1431
  ],
@@ -1673,12 +1678,17 @@ const _abi = [
1673
1678
  components: [
1674
1679
  {
1675
1680
  internalType: "address",
1676
- name: "tokenFrom",
1681
+ name: "zapper",
1677
1682
  type: "address",
1678
1683
  },
1679
1684
  {
1680
1685
  internalType: "address",
1681
- name: "zapper",
1686
+ name: "tokenIn",
1687
+ type: "address",
1688
+ },
1689
+ {
1690
+ internalType: "address",
1691
+ name: "tokenOut",
1682
1692
  type: "address",
1683
1693
  },
1684
1694
  ],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gearbox-protocol/sdk",
3
- "version": "3.0.0-next.12",
3
+ "version": "3.0.0-next.14",
4
4
  "description": "Gearbox SDK",
5
5
  "main": "./lib/index.js",
6
6
  "types": "./lib/index.d.ts",
@@ -41,11 +41,11 @@
41
41
  "@commitlint/cli": "^17.6.3",
42
42
  "@commitlint/config-conventional": "^17.0.3",
43
43
  "@gearbox-protocol/core-v2": "1.19.0-base.15",
44
- "@gearbox-protocol/core-v3": "^1.40.0",
44
+ "@gearbox-protocol/core-v3": "^1.40.2",
45
45
  "@gearbox-protocol/eslint-config": "^1.4.1",
46
46
  "@gearbox-protocol/integrations-v3": "^1.17.0",
47
47
  "@gearbox-protocol/oracles-v3": "^1.7.6",
48
- "@gearbox-protocol/periphery-v3": "^1.2.6",
48
+ "@gearbox-protocol/periphery-v3": "^1.2.11",
49
49
  "@gearbox-protocol/prettier-config": "^1.4.1",
50
50
  "@openzeppelin/contracts": "^4.9.3",
51
51
  "@typechain/ethers-v5": "^10.1.0",