@gearbox-protocol/sdk 3.0.0-next.156 → 3.0.0-next.158

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.
@@ -10,7 +10,7 @@ interface PoolEvent {
10
10
  readonly poolName?: string;
11
11
  }
12
12
  export interface TxSerialized {
13
- type: "TxAddLiquidity" | "TxRemoveLiquidity" | "TxSwap" | "TxAddCollateral" | "TxIncreaseBorrowAmount" | "TxDecreaseBorrowAmount" | "TxOpenAccount" | "TxRepayAccount" | "TxCloseAccount" | "TxApprove" | "TxOpenMultitokenAccount" | "TxClaimReward" | "TxClaimNFT" | "TxClaimGearRewards" | "TxEnableTokens" | "TxUpdateQuota" | "TxGaugeStake" | "TxGaugeUnstake" | "TxGaugeClaim" | "TxGaugeVote" | "TxWithdrawCollateral";
13
+ type: "TxAddLiquidity" | "TxRemoveLiquidity" | "TxSwap" | "TxAddCollateral" | "TxIncreaseBorrowAmount" | "TxDecreaseBorrowAmount" | "TxOpenAccount" | "TxRepayAccount" | "TxCloseAccount" | "TxApprove" | "TxOpenMultitokenAccount" | "TxClaimReward" | "TxClaimNFT" | "TxClaimRewards" | "TxEnableTokens" | "TxUpdateQuota" | "TxGaugeStake" | "TxGaugeUnstake" | "TxGaugeClaim" | "TxGaugeVote" | "TxWithdrawCollateral";
14
14
  content: string;
15
15
  }
16
16
  export declare class TxSerializer {
@@ -162,14 +162,14 @@ export declare class TxClaimNFT extends EVMTx {
162
162
  toString(): string;
163
163
  serialize(): TxSerialized;
164
164
  }
165
- interface TxClaimGearRewardsProps extends EVMTxProps {
165
+ interface TxClaimRewardsProps extends EVMTxProps {
166
166
  token: string;
167
167
  amount: bigint;
168
168
  }
169
- export declare class TxClaimGearRewards extends EVMTx {
169
+ export declare class TxClaimRewards extends EVMTx {
170
170
  readonly token: string;
171
171
  readonly amount: bigint;
172
- constructor(opts: TxClaimGearRewardsProps);
172
+ constructor(opts: TxClaimRewardsProps);
173
173
  toString(): string;
174
174
  serialize(): TxSerialized;
175
175
  }
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TxWithdrawCollateral = exports.TxGaugeVote = exports.TxGaugeClaim = exports.TxGaugeUnstake = exports.TxGaugeStake = 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;
3
+ exports.TxWithdrawCollateral = exports.TxGaugeVote = exports.TxGaugeClaim = exports.TxGaugeUnstake = exports.TxGaugeStake = exports.TxUpdateQuota = exports.TxEnableTokens = exports.TxApprove = exports.TxCloseAccount = exports.TxRepayAccount = exports.TxClaimRewards = 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 math_1 = require("../utils/math");
@@ -39,8 +39,8 @@ class TxSerializer {
39
39
  return new TxClaimReward(params);
40
40
  case "TxClaimNFT":
41
41
  return new TxClaimNFT(params);
42
- case "TxClaimGearRewards":
43
- return new TxClaimGearRewards(params);
42
+ case "TxClaimRewards":
43
+ return new TxClaimRewards(params);
44
44
  case "TxEnableTokens":
45
45
  return new TxEnableTokens(params);
46
46
  case "TxUpdateQuota":
@@ -313,7 +313,7 @@ class TxClaimNFT extends eventOrTx_1.EVMTx {
313
313
  }
314
314
  }
315
315
  exports.TxClaimNFT = TxClaimNFT;
316
- class TxClaimGearRewards extends eventOrTx_1.EVMTx {
316
+ class TxClaimRewards extends eventOrTx_1.EVMTx {
317
317
  token;
318
318
  amount;
319
319
  constructor(opts) {
@@ -323,16 +323,16 @@ class TxClaimGearRewards extends eventOrTx_1.EVMTx {
323
323
  }
324
324
  toString() {
325
325
  const [symbol, decimals] = (0, sdk_gov_1.extractTokenData)(this.token);
326
- return `GEAR Rewards claimed: ${(0, sdk_gov_1.formatBN)(this.amount, decimals || 18)} ${symbol} `;
326
+ return `Rewards claimed: ${(0, sdk_gov_1.formatBN)(this.amount, decimals || 18)} ${symbol} `;
327
327
  }
328
328
  serialize() {
329
329
  return {
330
- type: "TxClaimGearRewards",
330
+ type: "TxClaimRewards",
331
331
  content: JSON.stringify(this),
332
332
  };
333
333
  }
334
334
  }
335
- exports.TxClaimGearRewards = TxClaimGearRewards;
335
+ exports.TxClaimRewards = TxClaimRewards;
336
336
  class TxRepayAccount extends eventOrTx_1.EVMTx {
337
337
  creditManager;
338
338
  creditManagerName;
@@ -8,9 +8,8 @@ export interface PathOption {
8
8
  export type PathOptionSerie = Array<PathOption>;
9
9
  export type BalanceInterface = Pick<CaTokenBalance, "balance">;
10
10
  export declare class PathOptionFactory {
11
- static generatePathOptions(balances: Record<string, BalanceInterface>, loopsInTx: number): Array<PathOptionSerie>;
11
+ static generatePathOptions(balances: Record<string, BalanceInterface>, loopsInTx: number, network: NetworkType): Array<PathOptionSerie>;
12
12
  static getCurvePools(balances: Record<string, BalanceInterface>): Array<CurveLPToken>;
13
13
  static getBalancerPools(balances: Record<string, BalanceInterface>): Array<BalancerLPToken>;
14
14
  static next(path: PathOptionSerie): PathOptionSerie;
15
- static detectNetwork(underlying: string): NetworkType;
16
15
  }
@@ -4,10 +4,9 @@ exports.PathOptionFactory = void 0;
4
4
  const sdk_gov_1 = require("@gearbox-protocol/sdk-gov");
5
5
  const aura_1 = require("@gearbox-protocol/sdk-gov/lib/tokens/aura");
6
6
  class PathOptionFactory {
7
- static generatePathOptions(balances, loopsInTx) {
7
+ static generatePathOptions(balances, loopsInTx, network) {
8
8
  const curvePools = PathOptionFactory.getCurvePools(balances);
9
9
  const balancerPools = PathOptionFactory.getBalancerPools(balances);
10
- const network = PathOptionFactory.detectNetwork(Object.keys(balances)[0]);
11
10
  const curveInitPO = curvePools.map(symbol => {
12
11
  return {
13
12
  target: sdk_gov_1.tokenDataByNetwork[network][symbol],
@@ -90,10 +89,5 @@ class PathOptionFactory {
90
89
  }
91
90
  throw new Error("Path options overflow");
92
91
  }
93
- static detectNetwork(underlying) {
94
- return sdk_gov_1.tokenDataByNetwork.Mainnet[sdk_gov_1.tokenSymbolByAddress[underlying.toLowerCase()]].toLowerCase() === underlying.toLowerCase()
95
- ? "Mainnet"
96
- : "Arbitrum";
97
- }
98
92
  }
99
93
  exports.PathOptionFactory = PathOptionFactory;
@@ -63,7 +63,7 @@ describe("PathOptionFactory test", () => {
63
63
  [sdk_gov_1.tokenDataByNetwork.Mainnet.FRAX3CRV]: { balance: 200n },
64
64
  [sdk_gov_1.tokenDataByNetwork.Mainnet["50OHM_50DAI"]]: { balance: 200n },
65
65
  };
66
- const result = pathOptions_1.PathOptionFactory.generatePathOptions(balances, 4);
66
+ const result = pathOptions_1.PathOptionFactory.generatePathOptions(balances, 4, "Mainnet");
67
67
  const expected = [
68
68
  {
69
69
  target: sdk_gov_1.tokenDataByNetwork.Mainnet["3Crv"],
@@ -135,7 +135,4 @@ describe("PathOptionFactory test", () => {
135
135
  expectedCurvePools = ["3Crv", "steCRV"];
136
136
  (0, chai_1.expect)(pathOptions_1.PathOptionFactory.getCurvePools(balances)).to.be.eql(expectedCurvePools);
137
137
  });
138
- it("detectNetwork works correctly", () => {
139
- (0, chai_1.expect)(pathOptions_1.PathOptionFactory.detectNetwork(sdk_gov_1.tokenDataByNetwork.Mainnet["1INCH"])).to.be.eq("Mainnet");
140
- });
141
138
  });
@@ -28,6 +28,7 @@ interface FindBestClosePathProps {
28
28
  leftoverBalances: Record<string, Asset>;
29
29
  slippage: number;
30
30
  noConcurrency?: boolean;
31
+ network: NetworkType;
31
32
  }
32
33
  interface FindOpenStrategyPathProps {
33
34
  creditManager: CreditManagerData;
@@ -64,7 +65,7 @@ export declare class PathFinder {
64
65
  * - underlyingBalance - total balance of underlying token
65
66
  * - calls - list of calls which should be done to swap & unwrap everything to underlying token
66
67
  */
67
- findBestClosePath({ creditAccount, creditManager: cm, expectedBalances, leftoverBalances, slippage, noConcurrency, }: FindBestClosePathProps): Promise<PathFinderCloseResult>;
68
+ findBestClosePath({ creditAccount, creditManager: cm, expectedBalances, leftoverBalances, slippage, noConcurrency, network, }: FindBestClosePathProps): Promise<PathFinderCloseResult>;
68
69
  static compare(r1: PathFinderResult, r2: PathFinderResult): PathFinderResult;
69
70
  getAvailableConnectors(availableList: Record<string, bigint> | Record<string, true>): string[];
70
71
  static getAvailableConnectors(availableList: Record<string, bigint> | Record<string, true>, connectors: string[]): string[];
@@ -105,9 +105,9 @@ class PathFinder {
105
105
  * - underlyingBalance - total balance of underlying token
106
106
  * - calls - list of calls which should be done to swap & unwrap everything to underlying token
107
107
  */
108
- async findBestClosePath({ creditAccount, creditManager: cm, expectedBalances, leftoverBalances, slippage, noConcurrency = false, }) {
108
+ async findBestClosePath({ creditAccount, creditManager: cm, expectedBalances, leftoverBalances, slippage, noConcurrency = false, network, }) {
109
109
  const loopsPerTx = Math.floor(GAS_PER_BLOCK / MAX_GAS_PER_ROUTE);
110
- const pathOptions = pathOptions_1.PathOptionFactory.generatePathOptions(creditAccount.allBalances, loopsPerTx);
110
+ const pathOptions = pathOptions_1.PathOptionFactory.generatePathOptions(creditAccount.allBalances, loopsPerTx, network);
111
111
  const expected = cm.collateralTokens.map(token => {
112
112
  // When we pass expected balances explicitly, we need to mimic router behaviour by filtering out leftover tokens
113
113
  // for example, we can have stETH balance of 2, because 1 transforms to 2 because of rebasing
@@ -39,7 +39,7 @@ export declare class PathFinderV1 {
39
39
  * - underlyingBalance - total balance of underlying token
40
40
  * - calls - list of calls which should be done to swap & unwrap everything to underlying token
41
41
  */
42
- findBestClosePath(creditAccount: CreditAccountData, slippage: number, noConcurency?: boolean): Promise<PathFinderV1CloseResult>;
42
+ findBestClosePath(creditAccount: CreditAccountData, slippage: number, noConcurency: boolean | undefined, network: NetworkType): Promise<PathFinderV1CloseResult>;
43
43
  static compare(r1: CloseResult, r2: CloseResult, gasPriceRAY: bigint): CloseResult;
44
44
  getAvailableConnectors(availableList: Record<string, bigint> | Record<string, true>): string[];
45
45
  static getAvailableConnectors(availableList: Record<string, bigint> | Record<string, true>, connectors: string[]): string[];
@@ -107,9 +107,9 @@ class PathFinderV1 {
107
107
  * - underlyingBalance - total balance of underlying token
108
108
  * - calls - list of calls which should be done to swap & unwrap everything to underlying token
109
109
  */
110
- async findBestClosePath(creditAccount, slippage, noConcurency = false) {
110
+ async findBestClosePath(creditAccount, slippage, noConcurency = false, network) {
111
111
  const loopsPerTx = Math.floor(GAS_PER_BLOCK / MAX_GAS_PER_ROUTE);
112
- const pathOptions = pathOptions_1.PathOptionFactory.generatePathOptions(creditAccount.allBalances, loopsPerTx);
112
+ const pathOptions = pathOptions_1.PathOptionFactory.generatePathOptions(creditAccount.allBalances, loopsPerTx, network);
113
113
  const connectors = this.getAvailableConnectors(creditAccount.balances);
114
114
  let results = [];
115
115
  if (noConcurency) {
@@ -7,7 +7,10 @@ const ALIASES = {
7
7
  };
8
8
  const NETWROK_DEPENDENT_ALIASES = {
9
9
  Mainnet: {},
10
- Optimism: {},
10
+ Optimism: {
11
+ dUSDCV3: "dUSDC.eV3",
12
+ sdUSDCV3: "sdUSDC.eV3",
13
+ },
11
14
  Arbitrum: {
12
15
  dUSDCV3: "dUSDC.eV3",
13
16
  sdUSDCV3: "sdUSDC.eV3",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gearbox-protocol/sdk",
3
- "version": "3.0.0-next.156",
3
+ "version": "3.0.0-next.158",
4
4
  "description": "Gearbox SDK",
5
5
  "main": "./lib/index.js",
6
6
  "types": "./lib/index.d.ts",