@gearbox-protocol/deploy-tools 5.28.9 → 5.28.11

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 (2) hide show
  1. package/dist/index.mjs +63 -29
  2. package/package.json +3 -3
package/dist/index.mjs CHANGED
@@ -4276,7 +4276,7 @@ var init_size = __esm({
4276
4276
  var version2;
4277
4277
  var init_version2 = __esm({
4278
4278
  "../../node_modules/viem/_esm/errors/version.js"() {
4279
- version2 = "2.28.1";
4279
+ version2 = "2.28.3";
4280
4280
  }
4281
4281
  });
4282
4282
 
@@ -161405,7 +161405,7 @@ var require_version28 = __commonJS({
161405
161405
  "use strict";
161406
161406
  Object.defineProperty(exports2, "__esModule", { value: true });
161407
161407
  exports2.version = void 0;
161408
- exports2.version = "2.28.1";
161408
+ exports2.version = "2.28.3";
161409
161409
  }
161410
161410
  });
161411
161411
 
@@ -173934,7 +173934,7 @@ var require_sendTransaction = __commonJS({
173934
173934
  var sendRawTransaction_js_1 = require_sendRawTransaction();
173935
173935
  var supportsWalletNamespace2 = new lru_js_1.LruMap(128);
173936
173936
  async function sendTransaction2(client, parameters) {
173937
- const { account: account_ = client.account, chain = client.chain, accessList, authorizationList, blobs, data, gas, gasPrice, maxFeePerBlobGas, maxFeePerGas, maxPriorityFeePerGas, nonce, value, ...rest } = parameters;
173937
+ const { account: account_ = client.account, chain = client.chain, accessList, authorizationList, blobs, data, gas, gasPrice, maxFeePerBlobGas, maxFeePerGas, maxPriorityFeePerGas, nonce, type, value, ...rest } = parameters;
173938
173938
  if (typeof account_ === "undefined")
173939
173939
  throw new account_js_1.AccountNotFoundError({
173940
173940
  docsPath: "/docs/actions/wallet/sendTransaction"
@@ -173981,6 +173981,7 @@ var require_sendTransaction = __commonJS({
173981
173981
  maxPriorityFeePerGas,
173982
173982
  nonce,
173983
173983
  to,
173984
+ type,
173984
173985
  value
173985
173986
  });
173986
173987
  const isWalletNamespaceSupported = supportsWalletNamespace2.get(client.uid);
@@ -174029,6 +174030,7 @@ var require_sendTransaction = __commonJS({
174029
174030
  nonce,
174030
174031
  nonceManager: account.nonceManager,
174031
174032
  parameters: [...prepareTransactionRequest_js_1.defaultParameters, "sidecars"],
174033
+ type,
174032
174034
  value,
174033
174035
  ...rest,
174034
174036
  to
@@ -189347,12 +189349,14 @@ var require_getCapabilities = __commonJS({
189347
189349
  Object.defineProperty(exports2, "__esModule", { value: true });
189348
189350
  exports2.getCapabilities = getCapabilities2;
189349
189351
  var parseAccount_js_1 = require_parseAccount();
189352
+ var toHex_js_1 = require_toHex();
189350
189353
  async function getCapabilities2(client, parameters = {}) {
189351
189354
  const { account = client.account, chainId } = parameters;
189352
189355
  const account_ = account ? (0, parseAccount_js_1.parseAccount)(account) : void 0;
189356
+ const params = chainId ? [account_?.address, [(0, toHex_js_1.numberToHex)(chainId)]] : [account_?.address];
189353
189357
  const capabilities_raw = await client.request({
189354
189358
  method: "wallet_getCapabilities",
189355
- params: [account_?.address]
189359
+ params
189356
189360
  });
189357
189361
  const capabilities = {};
189358
189362
  for (const [key, value] of Object.entries(capabilities_raw))
@@ -189744,7 +189748,7 @@ var require_wallet3 = __commonJS({
189744
189748
  deployContract: (args) => (0, deployContract_js_1.deployContract)(client, args),
189745
189749
  getAddresses: () => (0, getAddresses_js_1.getAddresses)(client),
189746
189750
  getCallsStatus: (args) => (0, getCallsStatus_js_1.getCallsStatus)(client, args),
189747
- getCapabilities: () => (0, getCapabilities_js_1.getCapabilities)(client),
189751
+ getCapabilities: (args) => (0, getCapabilities_js_1.getCapabilities)(client, args),
189748
189752
  getChainId: () => (0, getChainId_js_1.getChainId)(client),
189749
189753
  getPermissions: () => (0, getPermissions_js_1.getPermissions)(client),
189750
189754
  prepareAuthorization: (args) => (0, prepareAuthorization_js_1.prepareAuthorization)(client, args),
@@ -219683,7 +219687,7 @@ var require_fraxtal = __commonJS({
219683
219687
  ...chainConfig_js_1.chainConfig,
219684
219688
  id: 252,
219685
219689
  name: "Fraxtal",
219686
- nativeCurrency: { name: "Frax Ether", symbol: "frxETH", decimals: 18 },
219690
+ nativeCurrency: { name: "Frax", symbol: "FRAX", decimals: 18 },
219687
219691
  rpcUrls: {
219688
219692
  default: {
219689
219693
  http: ["https://rpc.frax.com"]
@@ -219737,7 +219741,7 @@ var require_fraxtalTestnet = __commonJS({
219737
219741
  ...chainConfig_js_1.chainConfig,
219738
219742
  id: 2522,
219739
219743
  name: "Fraxtal Testnet",
219740
- nativeCurrency: { name: "Frax Ether", symbol: "frxETH", decimals: 18 },
219744
+ nativeCurrency: { name: "Frax", symbol: "FRAX", decimals: 18 },
219741
219745
  rpcUrls: {
219742
219746
  default: {
219743
219747
  http: ["https://rpc.testnet.frax.com"]
@@ -358006,7 +358010,7 @@ async function sendRawTransaction(client, { serializedTransaction }) {
358006
358010
  // ../../node_modules/viem/_esm/actions/wallet/sendTransaction.js
358007
358011
  var supportsWalletNamespace = new LruMap(128);
358008
358012
  async function sendTransaction(client, parameters) {
358009
- const { account: account_ = client.account, chain = client.chain, accessList, authorizationList, blobs, data, gas, gasPrice, maxFeePerBlobGas, maxFeePerGas, maxPriorityFeePerGas, nonce, value, ...rest } = parameters;
358013
+ const { account: account_ = client.account, chain = client.chain, accessList, authorizationList, blobs, data, gas, gasPrice, maxFeePerBlobGas, maxFeePerGas, maxPriorityFeePerGas, nonce, type, value, ...rest } = parameters;
358010
358014
  if (typeof account_ === "undefined")
358011
358015
  throw new AccountNotFoundError({
358012
358016
  docsPath: "/docs/actions/wallet/sendTransaction"
@@ -358054,6 +358058,7 @@ async function sendTransaction(client, parameters) {
358054
358058
  maxPriorityFeePerGas,
358055
358059
  nonce,
358056
358060
  to,
358061
+ type,
358057
358062
  value
358058
358063
  });
358059
358064
  const isWalletNamespaceSupported = supportsWalletNamespace.get(client.uid);
@@ -358102,6 +358107,7 @@ async function sendTransaction(client, parameters) {
358102
358107
  nonce,
358103
358108
  nonceManager: account.nonceManager,
358104
358109
  parameters: [...defaultParameters, "sidecars"],
358110
+ type,
358105
358111
  value,
358106
358112
  ...rest,
358107
358113
  to
@@ -364022,12 +364028,14 @@ async function getAddresses(client) {
364022
364028
 
364023
364029
  // ../../node_modules/viem/_esm/actions/wallet/getCapabilities.js
364024
364030
  init_parseAccount();
364031
+ init_toHex();
364025
364032
  async function getCapabilities(client, parameters = {}) {
364026
364033
  const { account = client.account, chainId } = parameters;
364027
364034
  const account_ = account ? parseAccount(account) : void 0;
364035
+ const params = chainId ? [account_?.address, [numberToHex(chainId)]] : [account_?.address];
364028
364036
  const capabilities_raw = await client.request({
364029
364037
  method: "wallet_getCapabilities",
364030
- params: [account_?.address]
364038
+ params
364031
364039
  });
364032
364040
  const capabilities = {};
364033
364041
  for (const [key, value] of Object.entries(capabilities_raw))
@@ -364290,7 +364298,7 @@ function walletActions(client) {
364290
364298
  deployContract: (args) => deployContract(client, args),
364291
364299
  getAddresses: () => getAddresses(client),
364292
364300
  getCallsStatus: (args) => getCallsStatus(client, args),
364293
- getCapabilities: () => getCapabilities(client),
364301
+ getCapabilities: (args) => getCapabilities(client, args),
364294
364302
  getChainId: () => getChainId(client),
364295
364303
  getPermissions: () => getPermissions(client),
364296
364304
  prepareAuthorization: (args) => prepareAuthorization(client, args),
@@ -381601,7 +381609,7 @@ var chains = {
381601
381609
  "0x5BCF14d8470e1a6110916371aacC8E1C947A7D9d": "Chaos Labs"
381602
381610
  },
381603
381611
  testMarketConfigurators: {
381604
- "0x537F5F2032e75Fa586E48ad635DF6f79c06205b9": "Chaos Labs"
381612
+ "0x19037a281025b83fa37e3264b77af523ff87a3a4": "Chaos Labs"
381605
381613
  },
381606
381614
  isPublic: false,
381607
381615
  wellKnownToken: {
@@ -428937,7 +428945,6 @@ async function evmMineDetailed(client, timestamp) {
428937
428945
  }
428938
428946
 
428939
428947
  // ../../node_modules/@gearbox-protocol/sdk/dist/esm/dev/AccountOpener.js
428940
- var DEFAULT_LEVERAGE = 4;
428941
428948
  var AccountOpener = class extends SDKConstruct {
428942
428949
  #service;
428943
428950
  #anvil;
@@ -429074,12 +429081,7 @@ var AccountOpener = class extends SDKConstruct {
429074
429081
  };
429075
429082
  }
429076
429083
  async prepareOpen(input) {
429077
- const {
429078
- creditManager,
429079
- target,
429080
- leverage = DEFAULT_LEVERAGE,
429081
- slippage = 50
429082
- } = input;
429084
+ const { creditManager, target, slippage = 50 } = input;
429083
429085
  const borrower = await this.#getBorrower();
429084
429086
  const cm = this.sdk.marketRegister.findCreditManager(creditManager);
429085
429087
  const symbol = this.sdk.tokensMeta.symbol(target);
@@ -429087,6 +429089,8 @@ var AccountOpener = class extends SDKConstruct {
429087
429089
  creditManager: cm.name,
429088
429090
  target: symbol
429089
429091
  });
429092
+ const leverage = this.#getLeverage(input);
429093
+ logger2?.debug(`using leverage ${leverage}`);
429090
429094
  const { minDebt, underlying } = cm.creditFacade;
429091
429095
  const expectedBalances = [];
429092
429096
  const leftoverBalances = [];
@@ -429094,7 +429098,7 @@ var AccountOpener = class extends SDKConstruct {
429094
429098
  const token = t;
429095
429099
  expectedBalances.push({
429096
429100
  token,
429097
- balance: token === underlying ? BigInt(leverage) * minDebt : 1n
429101
+ balance: token === underlying ? BigInt(leverage) * minDebt / PERCENTAGE_FACTOR : 1n
429098
429102
  });
429099
429103
  leftoverBalances.push({
429100
429104
  token,
@@ -429110,18 +429114,20 @@ var AccountOpener = class extends SDKConstruct {
429110
429114
  target
429111
429115
  });
429112
429116
  logger2?.debug(strategy, "found open strategy");
429113
- const debt = minDebt * BigInt(leverage - 1);
429117
+ const debt = minDebt * (leverage - PERCENTAGE_FACTOR) / PERCENTAGE_FACTOR;
429114
429118
  const averageQuota = this.#getCollateralQuota(
429115
429119
  cm,
429116
429120
  target,
429117
429121
  strategy.amount,
429118
- debt
429122
+ debt,
429123
+ logger2
429119
429124
  );
429120
429125
  const minQuota = this.#getCollateralQuota(
429121
429126
  cm,
429122
429127
  target,
429123
429128
  strategy.minAmount,
429124
- debt
429129
+ debt,
429130
+ logger2
429125
429131
  );
429126
429132
  logger2?.debug({ averageQuota, minQuota }, "calculated quotas");
429127
429133
  const { tx, calls } = await this.#service.openCA({
@@ -429153,10 +429159,11 @@ var AccountOpener = class extends SDKConstruct {
429153
429159
  async #depositIntoPools(targets) {
429154
429160
  this.#logger?.debug("checking and topping up pools if necessary");
429155
429161
  const minAvailableByPool = {};
429156
- for (const { leverage = DEFAULT_LEVERAGE, creditManager } of targets) {
429157
- const cm = this.sdk.marketRegister.findCreditManager(creditManager);
429162
+ for (const t of targets) {
429163
+ const leverage = this.#getLeverage(t);
429164
+ const cm = this.sdk.marketRegister.findCreditManager(t.creditManager);
429158
429165
  const { minDebt } = cm.creditFacade;
429159
- minAvailableByPool[cm.pool] = (minAvailableByPool[cm.pool] ?? 0n) + minDebt * BigInt(leverage - 1) * this.#poolDepositMultiplier / PERCENTAGE_FACTOR;
429166
+ minAvailableByPool[cm.pool] = (minAvailableByPool[cm.pool] ?? 0n) + minDebt * (leverage - PERCENTAGE_FACTOR) / PERCENTAGE_FACTOR * this.#poolDepositMultiplier / PERCENTAGE_FACTOR;
429160
429167
  }
429161
429168
  let totalUSD = 0n;
429162
429169
  let deposits = [];
@@ -429412,7 +429419,7 @@ var AccountOpener = class extends SDKConstruct {
429412
429419
  });
429413
429420
  return acc;
429414
429421
  }
429415
- #getCollateralQuota(cm, collateral, amount, debt) {
429422
+ #getCollateralQuota(cm, collateral, amount, debt, logger2) {
429416
429423
  const {
429417
429424
  underlying,
429418
429425
  creditManager: { liquidationThresholds }
@@ -429433,6 +429440,19 @@ var AccountOpener = class extends SDKConstruct {
429433
429440
  );
429434
429441
  }
429435
429442
  const desiredQuota = this.#calcQuota(amount, debt, collateralLT);
429443
+ logger2?.debug(
429444
+ {
429445
+ desiredQuota: this.sdk.tokensMeta.formatBN(underlying, desiredQuota),
429446
+ availableQuota: this.sdk.tokensMeta.formatBN(
429447
+ underlying,
429448
+ availableQuota
429449
+ ),
429450
+ amount: this.sdk.tokensMeta.formatBN(underlying, amount),
429451
+ debt: this.sdk.tokensMeta.formatBN(underlying, debt),
429452
+ lt: Number(collateralLT)
429453
+ },
429454
+ "calculated quota"
429455
+ );
429436
429456
  return [
429437
429457
  {
429438
429458
  token: collateral,
@@ -429446,6 +429466,20 @@ var AccountOpener = class extends SDKConstruct {
429446
429466
  quota = quota * (PERCENTAGE_FACTOR + 500n) / PERCENTAGE_FACTOR;
429447
429467
  return quota / PERCENTAGE_FACTOR * PERCENTAGE_FACTOR;
429448
429468
  }
429469
+ /**
429470
+ * Returns leverage in percentage factor format
429471
+ * @param param0
429472
+ * @returns
429473
+ */
429474
+ #getLeverage({ creditManager, target, leverage }) {
429475
+ if (leverage) {
429476
+ return BigInt(leverage) * PERCENTAGE_FACTOR;
429477
+ }
429478
+ const cm = this.sdk.marketRegister.findCreditManager(creditManager);
429479
+ const lt = BigInt(cm.creditManager.liquidationThresholds.mustGet(target));
429480
+ const d = 50n;
429481
+ return PERCENTAGE_FACTOR * (1n + (lt - d) / (PERCENTAGE_FACTOR - lt));
429482
+ }
429449
429483
  get faucet() {
429450
429484
  if (!this.#faucet) {
429451
429485
  throw new Error("faucet not found");
@@ -436780,7 +436814,7 @@ function getRenderer(opts) {
436780
436814
  var package_default = {
436781
436815
  name: "@gearbox-protocol/deploy-tools",
436782
436816
  description: "Gearbox deploy tools",
436783
- version: "5.28.9",
436817
+ version: "5.28.11",
436784
436818
  homepage: "https://gearbox.fi",
436785
436819
  keywords: [
436786
436820
  "gearbox"
@@ -436823,7 +436857,7 @@ var package_default = {
436823
436857
  "@gearbox-protocol/deploy-tools-node": "0.0.0",
436824
436858
  "@gearbox-protocol/deploy-tools-shared": "0.0.0",
436825
436859
  "@gearbox-protocol/deploy-tools-types": "0.0.0",
436826
- "@gearbox-protocol/sdk": "^4.1.3",
436860
+ "@gearbox-protocol/sdk": "^4.1.6",
436827
436861
  "@gearbox-protocol/sdk-gov": "^2.37.0",
436828
436862
  "@types/lodash-es": "^4.17.12",
436829
436863
  "@types/node": "^22.14.1",
@@ -436845,7 +436879,7 @@ var package_default = {
436845
436879
  "react-dom": "^19.1.0",
436846
436880
  table: "^6.9.0",
436847
436881
  tsx: "^4.19.4",
436848
- viem: "^2.28.1",
436882
+ viem: "^2.28.3",
436849
436883
  yaml: "^2.7.1",
436850
436884
  zod: "^3.24.3"
436851
436885
  },
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@gearbox-protocol/deploy-tools",
3
3
  "description": "Gearbox deploy tools",
4
- "version": "5.28.9",
4
+ "version": "5.28.11",
5
5
  "homepage": "https://gearbox.fi",
6
6
  "keywords": [
7
7
  "gearbox"
@@ -44,7 +44,7 @@
44
44
  "@gearbox-protocol/deploy-tools-node": "0.0.0",
45
45
  "@gearbox-protocol/deploy-tools-shared": "0.0.0",
46
46
  "@gearbox-protocol/deploy-tools-types": "0.0.0",
47
- "@gearbox-protocol/sdk": "^4.1.3",
47
+ "@gearbox-protocol/sdk": "^4.1.6",
48
48
  "@gearbox-protocol/sdk-gov": "^2.37.0",
49
49
  "@types/lodash-es": "^4.17.12",
50
50
  "@types/node": "^22.14.1",
@@ -66,7 +66,7 @@
66
66
  "react-dom": "^19.1.0",
67
67
  "table": "^6.9.0",
68
68
  "tsx": "^4.19.4",
69
- "viem": "^2.28.1",
69
+ "viem": "^2.28.3",
70
70
  "yaml": "^2.7.1",
71
71
  "zod": "^3.24.3"
72
72
  },