@gearbox-protocol/sdk 0.0.52 → 0.0.55

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.
@@ -22,9 +22,12 @@ export enum TradeType {
22
22
  YearnDeposit,
23
23
  YearnWithdraw,
24
24
  LidoStake,
25
- ConvexDeposit,
25
+ ConvexDepositLP,
26
26
  ConvexStake,
27
- ConvexDepositAndStake
27
+ ConvexDepositLPAndStake,
28
+ ConvexWithdrawLP,
29
+ ConvexWithdraw,
30
+ ConvexWithdrawAndUnwrap
28
31
  }
29
32
 
30
33
  export type TradeAction =
@@ -67,8 +70,8 @@ export type TradeAction =
67
70
  tokenOut: NormalToken;
68
71
  }
69
72
  | {
70
- type: TradeType.ConvexDeposit;
71
- contract: ConvexPoolContract;
73
+ type: TradeType.ConvexDepositLP;
74
+ contract: "CONVEX_BOOSTER";
72
75
  tokenOut: ConvexLPToken;
73
76
  }
74
77
  | {
@@ -77,7 +80,22 @@ export type TradeAction =
77
80
  tokenOut: ConvexStakedPhantomToken;
78
81
  }
79
82
  | {
80
- type: TradeType.ConvexDepositAndStake;
81
- contract: ConvexPoolContract;
83
+ type: TradeType.ConvexDepositLPAndStake;
84
+ contract: "CONVEX_BOOSTER";
82
85
  tokenOut: ConvexStakedPhantomToken;
86
+ }
87
+ | {
88
+ type: TradeType.ConvexWithdrawLP;
89
+ contract: "CONVEX_BOOSTER";
90
+ tokenOut: CurveLPToken;
91
+ }
92
+ | {
93
+ type: TradeType.ConvexWithdraw;
94
+ contract: ConvexPoolContract;
95
+ tokenOut: ConvexLPToken;
96
+ }
97
+ | {
98
+ type: TradeType.ConvexWithdrawAndUnwrap;
99
+ contract: ConvexPoolContract;
100
+ tokenOut: CurveLPToken;
83
101
  };
@@ -77,7 +77,7 @@ export class TxAddLiquidity extends EVMTx {
77
77
  }
78
78
 
79
79
  toString(tokenData: Record<string, TokenData>): string {
80
- const token = tokenData[this.underlyingToken];
80
+ const token = tokenData[this.underlyingToken.toLowerCase()];
81
81
  return `${getContractName(this.pool)}: Deposit ${formatBN(
82
82
  this.amount,
83
83
  token?.decimals || 18
@@ -115,7 +115,7 @@ export class TxRemoveLiquidity extends EVMTx {
115
115
  }
116
116
 
117
117
  toString(tokenData: Record<string, TokenData>): string {
118
- const dtoken = tokenData[this.dieselToken];
118
+ const dtoken = tokenData[this.dieselToken.toLowerCase()];
119
119
  return `${getContractName(this.pool)}: Withdraw ${formatBN(
120
120
  this.amount,
121
121
  dtoken?.decimals || 18
@@ -165,11 +165,11 @@ export class TXSwap extends EVMTx {
165
165
  }
166
166
 
167
167
  toString(tokenData: Record<string, TokenData>): string {
168
- const tokenFrom = tokenData[this.tokenFrom];
168
+ const tokenFrom = tokenData[this.tokenFrom.toLowerCase()];
169
169
 
170
170
  let toPart = "";
171
171
  if (this.tokenTo && this.amountTo) {
172
- const tokenTo = tokenData[this.tokenTo];
172
+ const tokenTo = tokenData[this.tokenTo.toLowerCase()];
173
173
  toPart = ` ⇒ ${formatBN(this.amountTo, tokenTo?.decimals || 18)} ${
174
174
  tokenTo?.symbol || ""
175
175
  }`;
@@ -213,7 +213,7 @@ export class TxAddCollateral extends EVMTx {
213
213
  }
214
214
 
215
215
  toString(tokenData: Record<string, TokenData>): string {
216
- const addedToken = tokenData[this.addedToken];
216
+ const addedToken = tokenData[this.addedToken.toLowerCase()];
217
217
  return `Credit account ${getContractName(
218
218
  this.creditManager
219
219
  )}: Added ${formatBN(this.amount, addedToken.decimals)} ${
@@ -252,7 +252,7 @@ export class TxIncreaseBorrowAmount extends EVMTx {
252
252
  }
253
253
 
254
254
  toString(tokenData: Record<string, TokenData>): string {
255
- const token = tokenData[this.underlyingToken];
255
+ const token = tokenData[this.underlyingToken.toLowerCase()];
256
256
  return `Credit account ${getContractName(
257
257
  this.creditManager
258
258
  )}: Borrowed amount was increased for ${formatBN(
@@ -295,7 +295,7 @@ export class TxOpenAccount extends EVMTx {
295
295
  }
296
296
 
297
297
  toString(tokenData: Record<string, TokenData>): string {
298
- const token = tokenData[this.underlyingToken];
298
+ const token = tokenData[this.underlyingToken.toLowerCase()];
299
299
  return `Credit account ${getContractName(
300
300
  this.creditManager
301
301
  )}: opening ${formatBN(this.amount, token?.decimals || 18)} ${
@@ -333,7 +333,7 @@ export class TxRepayAccount extends EVMTx {
333
333
  this.creditManager = opts.creditManager;
334
334
  }
335
335
 
336
- toString(_tokenData: Record<string, TokenData>): string {
336
+ toString(_: Record<string, TokenData>): string {
337
337
  return `Credit account ${getContractName(
338
338
  this.creditManager
339
339
  )}: Repaying account`;
@@ -363,7 +363,7 @@ export class TxCloseAccount extends EVMTx {
363
363
  this.creditManager = opts.creditManager;
364
364
  }
365
365
 
366
- toString(_tokenData: Record<string, TokenData>): string {
366
+ toString(_: Record<string, TokenData>): string {
367
367
  return `Credit account ${getContractName(
368
368
  this.creditManager
369
369
  )}: Closing account`;
@@ -394,7 +394,7 @@ export class TxApprove extends EVMTx {
394
394
  }
395
395
 
396
396
  toString(tokenData: Record<string, TokenData>): string {
397
- const token = tokenData[this.token];
397
+ const token = tokenData[this.token.toLowerCase()];
398
398
  return `Approve ${token?.symbol}`;
399
399
  }
400
400
 
package/src/index.ts CHANGED
@@ -6,6 +6,7 @@ export * from "./core/contracts";
6
6
  export * from "./core/events";
7
7
  export * from "./core/errors";
8
8
  export * from "./core/pool";
9
+ export * from "./core/protocols";
9
10
  export * from "./core/priceFeeds";
10
11
  export * from "./core/operations";
11
12
  export * from "./core/oracles";
@@ -43,3 +44,4 @@ export { MultiCallContract } from "./utils/multicall";
43
44
  export { callRepeater } from "./utils/repeater";
44
45
  export { getContractName } from "./core/contractsRegister";
45
46
  export { AdapterInterface } from "./core/adapters";
47
+ export { objectEntries, swapKeyValue, keyToLowercase } from "./utils/mappers";
@@ -0,0 +1,23 @@
1
+ type SupportedValue = string | number;
2
+
3
+ const objectEntries = <K extends SupportedValue, T>(
4
+ o: Record<K, T>
5
+ ): Array<[K, T]> => Object.entries(o) as Array<[K, T]>;
6
+
7
+ const swapKeyValue = <K extends SupportedValue, T extends SupportedValue>(
8
+ o: Record<K, T>
9
+ ): Record<T, K> =>
10
+ objectEntries(o).reduce((sum, [key, value]) => {
11
+ return { ...sum, [value]: key };
12
+ }, {} as Record<T, K>);
13
+
14
+ const keyToLowercase = <K extends SupportedValue, T extends SupportedValue>(
15
+ o: Record<K, T>
16
+ ): Record<K, T> =>
17
+ objectEntries(o).reduce((sum, [key, value]) => {
18
+ const keyTransformed = typeof key === "string" ? key.toLowerCase() : key;
19
+ return { ...sum, [keyTransformed]: value };
20
+ }, {} as Record<K, T>);
21
+
22
+ export type { SupportedValue };
23
+ export { objectEntries, swapKeyValue, keyToLowercase };