@gearbox-protocol/deploy-tools 5.16.8 → 5.16.10

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 +1278 -552
  2. package/package.json +2 -2
package/dist/index.mjs CHANGED
@@ -87486,13 +87486,13 @@ var require_tokenType = __commonJS({
87486
87486
  TokenType3[TokenType3["ZIRCUIT_STAKED_TOKEN"] = 18] = "ZIRCUIT_STAKED_TOKEN";
87487
87487
  TokenType3[TokenType3["STAKING_REWARDS_PHANTOM_TOKEN"] = 19] = "STAKING_REWARDS_PHANTOM_TOKEN";
87488
87488
  })(TokenType2 || (exports2.TokenType = TokenType2 = {}));
87489
- var PhantomTokenType2;
87490
- (function(PhantomTokenType3) {
87491
- PhantomTokenType3[PhantomTokenType3["NO_TOKEN"] = 0] = "NO_TOKEN";
87492
- PhantomTokenType3[PhantomTokenType3["CONVEX_PHANTOM_TOKEN"] = 1] = "CONVEX_PHANTOM_TOKEN";
87493
- PhantomTokenType3[PhantomTokenType3["ZIRCUIT_PHANTOM_TOKEN"] = 2] = "ZIRCUIT_PHANTOM_TOKEN";
87494
- PhantomTokenType3[PhantomTokenType3["STAKING_REWARDS_PHANTOM_TOKEN"] = 3] = "STAKING_REWARDS_PHANTOM_TOKEN";
87495
- })(PhantomTokenType2 || (exports2.PhantomTokenType = PhantomTokenType2 = {}));
87489
+ var PhantomTokenType;
87490
+ (function(PhantomTokenType2) {
87491
+ PhantomTokenType2[PhantomTokenType2["NO_TOKEN"] = 0] = "NO_TOKEN";
87492
+ PhantomTokenType2[PhantomTokenType2["CONVEX_PHANTOM_TOKEN"] = 1] = "CONVEX_PHANTOM_TOKEN";
87493
+ PhantomTokenType2[PhantomTokenType2["ZIRCUIT_PHANTOM_TOKEN"] = 2] = "ZIRCUIT_PHANTOM_TOKEN";
87494
+ PhantomTokenType2[PhantomTokenType2["STAKING_REWARDS_PHANTOM_TOKEN"] = 3] = "STAKING_REWARDS_PHANTOM_TOKEN";
87495
+ })(PhantomTokenType || (exports2.PhantomTokenType = PhantomTokenType = {}));
87496
87496
  }
87497
87497
  });
87498
87498
 
@@ -353023,8 +353023,7 @@ var ADDRESS_PROVIDER = {
353023
353023
  };
353024
353024
 
353025
353025
  // ../../node_modules/@gearbox-protocol/sdk/dist/esm/sdk/constants/bot-permissions.js
353026
- var BotPermissions;
353027
- (function(BotPermissions2) {
353026
+ var BotPermissions = /* @__PURE__ */ ((BotPermissions2) => {
353028
353027
  BotPermissions2[BotPermissions2["ADD_COLLATERAL"] = 1] = "ADD_COLLATERAL";
353029
353028
  BotPermissions2[BotPermissions2["INCREASE_DEBT"] = 2] = "INCREASE_DEBT";
353030
353029
  BotPermissions2[BotPermissions2["DECREASE_DEBT"] = 4] = "DECREASE_DEBT";
@@ -353036,7 +353035,8 @@ var BotPermissions;
353036
353035
  BotPermissions2[BotPermissions2["EXTERNAL_CALLS"] = 65536] = "EXTERNAL_CALLS";
353037
353036
  BotPermissions2[BotPermissions2["ALL_CREDIT_FACADE_CALLS"] = 255] = "ALL_CREDIT_FACADE_CALLS";
353038
353037
  BotPermissions2[BotPermissions2["ALLS"] = 65791] = "ALLS";
353039
- })(BotPermissions || (BotPermissions = {}));
353038
+ return BotPermissions2;
353039
+ })(BotPermissions || {});
353040
353040
  function botPermissionsToString(value) {
353041
353041
  let result = "";
353042
353042
  for (let i = 0; i < 16; i++) {
@@ -353051,7 +353051,9 @@ function botPermissionsToString(value) {
353051
353051
  }
353052
353052
 
353053
353053
  // ../../node_modules/@gearbox-protocol/sdk/dist/esm/sdk/constants/math.js
353054
- var MAX_INT = BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
353054
+ var MAX_INT = BigInt(
353055
+ "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
353056
+ );
353055
353057
  var MIN_INT96 = -39614081257132168796771975168n;
353056
353058
  var MAX_UINT256 = 115792089237316195423570985008687907853269984665640564039457584007913129639935n;
353057
353059
  var RAY_DECIMALS_POW = 27;
@@ -353135,7 +353137,9 @@ var AddressMap = class {
353135
353137
  }
353136
353138
  const key = getAddress(address);
353137
353139
  if (this.#map.has(key)) {
353138
- throw new Error(`address ${address} already exists in ${this.#name ?? "map"}`);
353140
+ throw new Error(
353141
+ `address ${address} already exists in ${this.#name ?? "map"}`
353142
+ );
353139
353143
  }
353140
353144
  this.#map.set(key, value);
353141
353145
  }
@@ -354197,7 +354201,10 @@ function formatBn4dig(num2, precision = 2) {
354197
354201
  const completed = "0".repeat(6 - numStr.length) + numStr;
354198
354202
  return `0.${completed.slice(0, precision)}`;
354199
354203
  }
354200
- return `${numStr.slice(0, numStr.length - 6)}.${numStr.slice(numStr.length - 6, numStr.length - 6 + precision)}`;
354204
+ return `${numStr.slice(0, numStr.length - 6)}.${numStr.slice(
354205
+ numStr.length - 6,
354206
+ numStr.length - 6 + precision
354207
+ )}`;
354201
354208
  }
354202
354209
  function fmtBinaryMask(mask) {
354203
354210
  return mask.toString(2).padStart(64, "0");
@@ -354577,7 +354584,9 @@ var BaseContract = class extends SDKConstruct {
354577
354584
  abi: this.abi,
354578
354585
  data: calldata
354579
354586
  });
354580
- const abiItem = this.abi.find((abiItem2) => abiItem2.name === decoded.functionName && abiItem2.type === "function");
354587
+ const abiItem = this.abi.find(
354588
+ (abiItem2) => abiItem2.name === decoded.functionName && abiItem2.type === "function"
354589
+ );
354581
354590
  if (!abiItem) {
354582
354591
  return `Unknown function: ${decoded.functionName}`;
354583
354592
  }
@@ -354592,7 +354601,9 @@ var BaseContract = class extends SDKConstruct {
354592
354601
  return `${abiItem.inputs[i].name}: ${abiItem.inputs[i].type === "address" ? this.addressLabels.get(value) : abiItem.inputs[i].type.startsWith("tuple") ? json_stringify(value) : value}`;
354593
354602
  });
354594
354603
  } else {
354595
- paramsHuman = Object.entries(decoded.args || {}).map(([key, value]) => `${key}: ${value}`);
354604
+ paramsHuman = Object.entries(decoded.args || {}).map(
354605
+ ([key, value]) => `${key}: ${value}`
354606
+ );
354596
354607
  }
354597
354608
  return `${this.name}.${decoded.functionName}({${paramsHuman.join(", ")}})`;
354598
354609
  }
@@ -354612,19 +354623,25 @@ var BaseContract = class extends SDKConstruct {
354612
354623
  return void 0;
354613
354624
  }
354614
354625
  async getVersion() {
354615
- this.version = Number(await this.sdk.provider.publicClient.readContract({
354616
- abi: iVersionAbi,
354617
- functionName: "version",
354618
- address: this.address
354619
- }));
354626
+ this.version = Number(
354627
+ await this.sdk.provider.publicClient.readContract({
354628
+ abi: iVersionAbi,
354629
+ functionName: "version",
354630
+ address: this.address
354631
+ })
354632
+ );
354620
354633
  return this.version;
354621
354634
  }
354622
354635
  createRawTx(parameters) {
354623
354636
  const { description: argsDescription } = parameters;
354624
- const tx = createRawTx(this.address, {
354625
- ...parameters,
354626
- abi: this.abi
354627
- }, argsDescription);
354637
+ const tx = createRawTx(
354638
+ this.address,
354639
+ {
354640
+ ...parameters,
354641
+ abi: this.abi
354642
+ },
354643
+ argsDescription
354644
+ );
354628
354645
  tx.description = argsDescription || this.parseFunctionData(tx.callData);
354629
354646
  return tx;
354630
354647
  }
@@ -354668,12 +354685,12 @@ var TokensMeta = class extends AddressMap {
354668
354685
  };
354669
354686
 
354670
354687
  // ../../node_modules/@gearbox-protocol/sdk/dist/esm/sdk/base/types.js
354671
- var VotingContractStatus;
354672
- (function(VotingContractStatus2) {
354688
+ var VotingContractStatus = /* @__PURE__ */ ((VotingContractStatus2) => {
354673
354689
  VotingContractStatus2[VotingContractStatus2["NOT_ALLOWED"] = 0] = "NOT_ALLOWED";
354674
354690
  VotingContractStatus2[VotingContractStatus2["ALLOWED"] = 1] = "ALLOWED";
354675
354691
  VotingContractStatus2[VotingContractStatus2["UNVOTE_ONLY"] = 2] = "UNVOTE_ONLY";
354676
- })(VotingContractStatus || (VotingContractStatus = {}));
354692
+ return VotingContractStatus2;
354693
+ })(VotingContractStatus || {});
354677
354694
 
354678
354695
  // ../../node_modules/@gearbox-protocol/sdk/dist/esm/sdk/market/adapters/PlaceholderAdapterContracts.js
354679
354696
  var PlaceholderAdapterContract = class extends PlaceholderContract {
@@ -354691,14 +354708,20 @@ function createAdapter(sdk, args) {
354691
354708
  try {
354692
354709
  const adapter = plugin.createContract(sdk, args);
354693
354710
  if (adapter) {
354694
- sdk.logger?.info(` ${adapterType} v${args.baseParams.version} created using plugin ${plugin.name}`);
354711
+ sdk.logger?.info(
354712
+ ` ${adapterType} v${args.baseParams.version} created using plugin ${plugin.name}`
354713
+ );
354695
354714
  return adapter;
354696
354715
  }
354697
354716
  } catch (e) {
354698
- sdk.logger?.warn(`plugin ${plugin.name} error while trying to create ${adapterType} v${args.baseParams.version}: ${e}`);
354717
+ sdk.logger?.warn(
354718
+ `plugin ${plugin.name} error while trying to create ${adapterType} v${args.baseParams.version}: ${e}`
354719
+ );
354699
354720
  }
354700
354721
  }
354701
- sdk.logger?.warn(`no class found for ${adapterType} v${args.baseParams.version}, falling back to placeholder`);
354722
+ sdk.logger?.warn(
354723
+ `no class found for ${adapterType} v${args.baseParams.version}, falling back to placeholder`
354724
+ );
354702
354725
  return new PlaceholderAdapterContract(sdk, args);
354703
354726
  }
354704
354727
 
@@ -354808,7 +354831,13 @@ var CreditConfiguratorV300Contract = class extends BaseContract {
354808
354831
  return [`${expirationDate}`];
354809
354832
  }
354810
354833
  case "setFees": {
354811
- const [feeInterest, feeLiquidation, liquidationPremium, feeLiquidationExpired, liquidationPremiumExpired] = params.args;
354834
+ const [
354835
+ feeInterest,
354836
+ feeLiquidation,
354837
+ liquidationPremium,
354838
+ feeLiquidationExpired,
354839
+ liquidationPremiumExpired
354840
+ ] = params.args;
354812
354841
  return [
354813
354842
  percentFmt(feeInterest),
354814
354843
  percentFmt(feeLiquidation),
@@ -359523,7 +359552,12 @@ var CreditConfiguratorV310Contract = class extends BaseContract {
359523
359552
  return [`${expirationDate}`];
359524
359553
  }
359525
359554
  case "setFees": {
359526
- const [feeLiquidation, liquidationPremium, feeLiquidationExpired, liquidationPremiumExpired] = params.args;
359555
+ const [
359556
+ feeLiquidation,
359557
+ liquidationPremium,
359558
+ feeLiquidationExpired,
359559
+ liquidationPremiumExpired
359560
+ ] = params.args;
359527
359561
  return [
359528
359562
  percentFmt(feeLiquidation),
359529
359563
  percentFmt(liquidationPremium),
@@ -359847,7 +359881,10 @@ var CreditManagerV300Contract = class extends BaseContract {
359847
359881
  abi: abi7
359848
359882
  });
359849
359883
  Object.assign(this, rest);
359850
- this.liquidationThresholds = new AddressMap(collateralTokens.map((ct) => [ct.token, ct.liquidationThreshold]), "liquidationThresholds");
359884
+ this.liquidationThresholds = new AddressMap(
359885
+ collateralTokens.map((ct) => [ct.token, ct.liquidationThreshold]),
359886
+ "liquidationThresholds"
359887
+ );
359851
359888
  this.adapters = new AddressMap(void 0, "adapters");
359852
359889
  for (const adapterData of adapters) {
359853
359890
  try {
@@ -359869,21 +359906,28 @@ var CreditManagerV300Contract = class extends BaseContract {
359869
359906
  creditFacade: this.labelAddress(this.creditFacade),
359870
359907
  creditConfigurator: this.labelAddress(this.creditConfigurator),
359871
359908
  maxEnabledTokens: this.maxEnabledTokens,
359872
- collateralTokens: Object.fromEntries(this.liquidationThresholds.entries().map(([k, v]) => [
359873
- this.labelAddress(k),
359874
- percentFmt(v, raw)
359875
- ])),
359909
+ collateralTokens: Object.fromEntries(
359910
+ this.liquidationThresholds.entries().map(([k, v]) => [
359911
+ this.labelAddress(k),
359912
+ percentFmt(v, raw)
359913
+ ])
359914
+ ),
359876
359915
  feeInterest: percentFmt(this.feeInterest, raw),
359877
359916
  feeLiquidation: percentFmt(this.feeLiquidation, raw),
359878
359917
  liquidationDiscount: percentFmt(this.liquidationDiscount, raw),
359879
359918
  feeLiquidationExpired: percentFmt(this.feeLiquidationExpired, raw),
359880
- liquidationDiscountExpired: percentFmt(this.liquidationDiscountExpired, raw),
359919
+ liquidationDiscountExpired: percentFmt(
359920
+ this.liquidationDiscountExpired,
359921
+ raw
359922
+ ),
359881
359923
  quotedTokensMask: fmtBinaryMask(0n),
359882
359924
  // TODO: ?
359883
- contractsToAdapters: Object.fromEntries(this.adapters.entries().map(([k, v]) => [
359884
- this.labelAddress(k),
359885
- this.labelAddress(v.address)
359886
- ])),
359925
+ contractsToAdapters: Object.fromEntries(
359926
+ this.adapters.entries().map(([k, v]) => [
359927
+ this.labelAddress(k),
359928
+ this.labelAddress(v.address)
359929
+ ])
359930
+ ),
359887
359931
  creditAccounts: []
359888
359932
  // TODO: ?
359889
359933
  };
@@ -359919,7 +359963,10 @@ var CreditManagerV310Contract = class extends BaseContract {
359919
359963
  abi: abi8
359920
359964
  });
359921
359965
  Object.assign(this, rest);
359922
- this.liquidationThresholds = new AddressMap(collateralTokens.map((ct) => [ct.token, ct.liquidationThreshold]), "liquidationThresholds");
359966
+ this.liquidationThresholds = new AddressMap(
359967
+ collateralTokens.map((ct) => [ct.token, ct.liquidationThreshold]),
359968
+ "liquidationThresholds"
359969
+ );
359923
359970
  this.adapters = new AddressMap(void 0, "adapters");
359924
359971
  for (const adapterData of adapters) {
359925
359972
  try {
@@ -359941,21 +359988,28 @@ var CreditManagerV310Contract = class extends BaseContract {
359941
359988
  creditFacade: this.labelAddress(this.creditFacade),
359942
359989
  creditConfigurator: this.labelAddress(this.creditConfigurator),
359943
359990
  maxEnabledTokens: this.maxEnabledTokens,
359944
- collateralTokens: Object.fromEntries(this.liquidationThresholds.entries().map(([k, v]) => [
359945
- this.labelAddress(k),
359946
- percentFmt(v, raw)
359947
- ])),
359991
+ collateralTokens: Object.fromEntries(
359992
+ this.liquidationThresholds.entries().map(([k, v]) => [
359993
+ this.labelAddress(k),
359994
+ percentFmt(v, raw)
359995
+ ])
359996
+ ),
359948
359997
  feeInterest: percentFmt(this.feeInterest, raw),
359949
359998
  feeLiquidation: percentFmt(this.feeLiquidation, raw),
359950
359999
  liquidationDiscount: percentFmt(this.liquidationDiscount, raw),
359951
360000
  feeLiquidationExpired: percentFmt(this.feeLiquidationExpired, raw),
359952
- liquidationDiscountExpired: percentFmt(this.liquidationDiscountExpired, raw),
360001
+ liquidationDiscountExpired: percentFmt(
360002
+ this.liquidationDiscountExpired,
360003
+ raw
360004
+ ),
359953
360005
  quotedTokensMask: fmtBinaryMask(0n),
359954
360006
  // TODO: ?
359955
- contractsToAdapters: Object.fromEntries(this.adapters.entries().map(([k, v]) => [
359956
- this.labelAddress(k),
359957
- this.labelAddress(v.address)
359958
- ])),
360007
+ contractsToAdapters: Object.fromEntries(
360008
+ this.adapters.entries().map(([k, v]) => [
360009
+ this.labelAddress(k),
360010
+ this.labelAddress(v.address)
360011
+ ])
360012
+ ),
359959
360013
  creditAccounts: []
359960
360014
  // TODO: ?
359961
360015
  };
@@ -360574,7 +360628,11 @@ async function detectNetwork(client) {
360574
360628
  // ../../node_modules/@gearbox-protocol/sdk/dist/esm/sdk/utils/viem/sendRawTx.js
360575
360629
  async function sendRawTx(client, params) {
360576
360630
  const { account, tx } = params;
360577
- return getAction(client, sendTransaction, "sendTransaction")({
360631
+ return getAction(
360632
+ client,
360633
+ sendTransaction,
360634
+ "sendTransaction"
360635
+ )({
360578
360636
  // @ts-expect-error
360579
360637
  account,
360580
360638
  data: tx.callData,
@@ -360585,13 +360643,24 @@ async function sendRawTx(client, params) {
360585
360643
 
360586
360644
  // ../../node_modules/@gearbox-protocol/sdk/dist/esm/sdk/utils/viem/simulateMulticall.js
360587
360645
  async function simulateMulticall(client, parameters) {
360588
- const { account, allowFailure = true, batchSize: batchSize_, blockNumber, blockTag, gas, multicallAddress: multicallAddress_, stateOverride } = parameters;
360646
+ const {
360647
+ account,
360648
+ allowFailure = true,
360649
+ batchSize: batchSize_,
360650
+ blockNumber,
360651
+ blockTag,
360652
+ gas,
360653
+ multicallAddress: multicallAddress_,
360654
+ stateOverride
360655
+ } = parameters;
360589
360656
  const contracts2 = parameters.contracts;
360590
360657
  const batchSize = batchSize_ ?? (typeof client.batch?.multicall === "object" && client.batch.multicall.batchSize || 1024);
360591
360658
  let multicallAddress = multicallAddress_;
360592
360659
  if (!multicallAddress) {
360593
360660
  if (!client.chain)
360594
- throw new Error("client chain not configured. multicallAddress is required.");
360661
+ throw new Error(
360662
+ "client chain not configured. multicallAddress is required."
360663
+ );
360595
360664
  multicallAddress = getChainContractAddress({
360596
360665
  blockNumber,
360597
360666
  chain: client.chain,
@@ -360632,8 +360701,7 @@ async function simulateMulticall(client, parameters) {
360632
360701
  docsPath: "/docs/contract/multicall",
360633
360702
  functionName
360634
360703
  });
360635
- if (!allowFailure)
360636
- throw error;
360704
+ if (!allowFailure) throw error;
360637
360705
  chunkedCalls[currentChunk] = [
360638
360706
  ...chunkedCalls[currentChunk],
360639
360707
  {
@@ -360644,18 +360712,26 @@ async function simulateMulticall(client, parameters) {
360644
360712
  ];
360645
360713
  }
360646
360714
  }
360647
- const aggregate3Results = await Promise.allSettled(chunkedCalls.map((calls) => getAction(client, simulateContract, "simulateContract")({
360648
- account,
360649
- abi: multicall3Abi,
360650
- address: multicallAddress,
360651
- args: [calls],
360652
- blockNumber,
360653
- blockTag,
360654
- // does not infer well that either blockNumber or blockTag must be present
360655
- functionName: "aggregate3",
360656
- stateOverride,
360657
- gas
360658
- })));
360715
+ const aggregate3Results = await Promise.allSettled(
360716
+ chunkedCalls.map(
360717
+ (calls) => getAction(
360718
+ client,
360719
+ simulateContract,
360720
+ "simulateContract"
360721
+ )({
360722
+ account,
360723
+ abi: multicall3Abi,
360724
+ address: multicallAddress,
360725
+ args: [calls],
360726
+ blockNumber,
360727
+ blockTag,
360728
+ // does not infer well that either blockNumber or blockTag must be present
360729
+ functionName: "aggregate3",
360730
+ stateOverride,
360731
+ gas
360732
+ })
360733
+ )
360734
+ );
360659
360735
  const results = [];
360660
360736
  for (let i = 0; i < aggregate3Results.length; i++) {
360661
360737
  const result = aggregate3Results[i];
@@ -360678,10 +360754,8 @@ async function simulateMulticall(client, parameters) {
360678
360754
  const { callData } = chunkedCalls[i][j];
360679
360755
  const { abi: abi23, address, functionName, args } = contracts2[results.length];
360680
360756
  try {
360681
- if (callData === "0x")
360682
- throw new AbiDecodingZeroDataError();
360683
- if (!success)
360684
- throw new RawContractError({ data: returnData });
360757
+ if (callData === "0x") throw new AbiDecodingZeroDataError();
360758
+ if (!success) throw new RawContractError({ data: returnData });
360685
360759
  const result2 = decodeFunctionResult({
360686
360760
  abi: abi23,
360687
360761
  args,
@@ -360697,8 +360771,7 @@ async function simulateMulticall(client, parameters) {
360697
360771
  docsPath: "/docs/contract/multicall",
360698
360772
  functionName
360699
360773
  });
360700
- if (!allowFailure)
360701
- throw error;
360774
+ if (!allowFailure) throw error;
360702
360775
  results.push({ error, result: void 0, status: "failure" });
360703
360776
  }
360704
360777
  }
@@ -360726,7 +360799,10 @@ var MarketConfiguratorContract = class extends BaseContract {
360726
360799
  abi: this.abi,
360727
360800
  functionName: "curatorName"
360728
360801
  });
360729
- this.sdk.provider.addressLabels.set(this.address, "Market configurator " + this.#curatorName);
360802
+ this.sdk.provider.addressLabels.set(
360803
+ this.address,
360804
+ "Market configurator " + this.#curatorName
360805
+ );
360730
360806
  }
360731
360807
  async getPeripheryContract(contract) {
360732
360808
  const resp = await this.sdk.provider.publicClient.readContract({
@@ -360755,8 +360831,7 @@ var MarketConfiguratorContract = class extends BaseContract {
360755
360831
  };
360756
360832
 
360757
360833
  // ../../node_modules/@gearbox-protocol/sdk/dist/esm/sdk/sdk-gov-legacy/contracts/adapters.js
360758
- var AdapterInterface;
360759
- (function(AdapterInterface2) {
360834
+ var AdapterInterface = /* @__PURE__ */ ((AdapterInterface2) => {
360760
360835
  AdapterInterface2[AdapterInterface2["ABSTRACT"] = 0] = "ABSTRACT";
360761
360836
  AdapterInterface2[AdapterInterface2["UNISWAP_V2_ROUTER"] = 1] = "UNISWAP_V2_ROUTER";
360762
360837
  AdapterInterface2[AdapterInterface2["UNISWAP_V3_ROUTER"] = 2] = "UNISWAP_V3_ROUTER";
@@ -360794,7 +360869,8 @@ var AdapterInterface;
360794
360869
  AdapterInterface2[AdapterInterface2["STAKING_REWARDS"] = 34] = "STAKING_REWARDS";
360795
360870
  AdapterInterface2[AdapterInterface2["EQUALIZER_ROUTER"] = 35] = "EQUALIZER_ROUTER";
360796
360871
  AdapterInterface2[AdapterInterface2["BALANCER_V3_ROUTER"] = 36] = "BALANCER_V3_ROUTER";
360797
- })(AdapterInterface || (AdapterInterface = {}));
360872
+ return AdapterInterface2;
360873
+ })(AdapterInterface || {});
360798
360874
 
360799
360875
  // ../../node_modules/@gearbox-protocol/sdk/dist/esm/sdk/sdk-gov-legacy/contracts/contracts.js
360800
360876
  var contractParams = {
@@ -361170,8 +361246,7 @@ var contractParams = {
361170
361246
  };
361171
361247
 
361172
361248
  // ../../node_modules/@gearbox-protocol/sdk/dist/esm/sdk/sdk-gov-legacy/oracles/PriceFeedType.js
361173
- var PriceFeedType;
361174
- (function(PriceFeedType2) {
361249
+ var PriceFeedType = /* @__PURE__ */ ((PriceFeedType2) => {
361175
361250
  PriceFeedType2[PriceFeedType2["CHAINLINK_ORACLE"] = 0] = "CHAINLINK_ORACLE";
361176
361251
  PriceFeedType2[PriceFeedType2["YEARN_ORACLE"] = 1] = "YEARN_ORACLE";
361177
361252
  PriceFeedType2[PriceFeedType2["CURVE_2LP_ORACLE"] = 2] = "CURVE_2LP_ORACLE";
@@ -361194,11 +361269,11 @@ var PriceFeedType;
361194
361269
  PriceFeedType2[PriceFeedType2["PYTH_ORACLE"] = 19] = "PYTH_ORACLE";
361195
361270
  PriceFeedType2[PriceFeedType2["MELLOW_LRT_ORACLE"] = 20] = "MELLOW_LRT_ORACLE";
361196
361271
  PriceFeedType2[PriceFeedType2["PENDLE_PT_TWAP_ORACLE"] = 21] = "PENDLE_PT_TWAP_ORACLE";
361197
- })(PriceFeedType || (PriceFeedType = {}));
361272
+ return PriceFeedType2;
361273
+ })(PriceFeedType || {});
361198
361274
 
361199
361275
  // ../../node_modules/@gearbox-protocol/sdk/dist/esm/sdk/sdk-gov-legacy/tokens/tokenType.js
361200
- var TokenType;
361201
- (function(TokenType2) {
361276
+ var TokenType = /* @__PURE__ */ ((TokenType2) => {
361202
361277
  TokenType2[TokenType2["NO_TOKEN"] = 0] = "NO_TOKEN";
361203
361278
  TokenType2[TokenType2["NORMAL_TOKEN"] = 1] = "NORMAL_TOKEN";
361204
361279
  TokenType2[TokenType2["CURVE_LP_TOKEN"] = 2] = "CURVE_LP_TOKEN";
@@ -361219,14 +361294,8 @@ var TokenType;
361219
361294
  TokenType2[TokenType2["CONVEX_L2_STAKED_TOKEN"] = 17] = "CONVEX_L2_STAKED_TOKEN";
361220
361295
  TokenType2[TokenType2["ZIRCUIT_STAKED_TOKEN"] = 18] = "ZIRCUIT_STAKED_TOKEN";
361221
361296
  TokenType2[TokenType2["STAKING_REWARDS_PHANTOM_TOKEN"] = 19] = "STAKING_REWARDS_PHANTOM_TOKEN";
361222
- })(TokenType || (TokenType = {}));
361223
- var PhantomTokenType;
361224
- (function(PhantomTokenType2) {
361225
- PhantomTokenType2[PhantomTokenType2["NO_TOKEN"] = 0] = "NO_TOKEN";
361226
- PhantomTokenType2[PhantomTokenType2["CONVEX_PHANTOM_TOKEN"] = 1] = "CONVEX_PHANTOM_TOKEN";
361227
- PhantomTokenType2[PhantomTokenType2["ZIRCUIT_PHANTOM_TOKEN"] = 2] = "ZIRCUIT_PHANTOM_TOKEN";
361228
- PhantomTokenType2[PhantomTokenType2["STAKING_REWARDS_PHANTOM_TOKEN"] = 3] = "STAKING_REWARDS_PHANTOM_TOKEN";
361229
- })(PhantomTokenType || (PhantomTokenType = {}));
361297
+ return TokenType2;
361298
+ })(TokenType || {});
361230
361299
 
361231
361300
  // ../../node_modules/@gearbox-protocol/sdk/dist/esm/sdk/sdk-gov-legacy/tokens/aave.js
361232
361301
  var aaveV2Tokens = {
@@ -363678,7 +363747,9 @@ var zircuitStakedPhantomTokens = {
363678
363747
  var zircuitTokens = {
363679
363748
  ...zircuitStakedPhantomTokens
363680
363749
  };
363681
- var zircuitStakedTokenByToken = Object.values(zircuitStakedPhantomTokens).reduce((acc, value) => {
363750
+ var zircuitStakedTokenByToken = Object.values(
363751
+ zircuitStakedPhantomTokens
363752
+ ).reduce((acc, value) => {
363682
363753
  acc[value.underlying] = value.symbol;
363683
363754
  return acc;
363684
363755
  }, {});
@@ -365613,26 +365684,40 @@ var tickerInfoTokensByNetwork = {
365613
365684
  ]
365614
365685
  }
365615
365686
  };
365616
- var tickerTokensByNetwork = Object.fromEntries(Object.entries(tickerInfoTokensByNetwork).map(([network, data]) => {
365617
- if (Object.values(data).length === 0)
365618
- return [network, {}];
365619
- const addrs = {};
365620
- Object.values(data).forEach((d) => d.forEach((val) => {
365621
- if (Object.keys(addrs).includes(val.symbol)) {
365622
- if (!addrs[val.symbol]?.includes(val.address)) {
365623
- addrs[val.symbol]?.push(val.address);
365624
- }
365625
- } else {
365626
- addrs[val.symbol] = [val.address];
365627
- }
365628
- }));
365629
- return [network, addrs];
365630
- }));
365631
- var tokenSymbolByAddress = Object.entries(tokenDataByNetwork).reduce((acc, [, tokens]) => ({
365632
- ...acc,
365633
- ...Object.fromEntries(Object.entries(tokens).map(([k, v]) => [v.toLowerCase(), k]).filter((k) => !!k))
365634
- }), {});
365635
- var tickerSymbolByAddress = Object.fromEntries(Object.values(tickerTokensByNetwork).map((en) => Object.entries(en).map(([symbol, addresses]) => addresses.map((addr) => [addr.toLowerCase(), symbol])).flat()).flat());
365687
+ var tickerTokensByNetwork = Object.fromEntries(
365688
+ Object.entries(tickerInfoTokensByNetwork).map(([network, data]) => {
365689
+ if (Object.values(data).length === 0) return [network, {}];
365690
+ const addrs = {};
365691
+ Object.values(data).forEach(
365692
+ (d) => d.forEach((val) => {
365693
+ if (Object.keys(addrs).includes(val.symbol)) {
365694
+ if (!addrs[val.symbol]?.includes(val.address)) {
365695
+ addrs[val.symbol]?.push(val.address);
365696
+ }
365697
+ } else {
365698
+ addrs[val.symbol] = [val.address];
365699
+ }
365700
+ })
365701
+ );
365702
+ return [network, addrs];
365703
+ })
365704
+ );
365705
+ var tokenSymbolByAddress = Object.entries(tokenDataByNetwork).reduce(
365706
+ (acc, [, tokens]) => ({
365707
+ ...acc,
365708
+ ...Object.fromEntries(
365709
+ Object.entries(tokens).map(([k, v]) => [v.toLowerCase(), k]).filter((k) => !!k)
365710
+ )
365711
+ }),
365712
+ {}
365713
+ );
365714
+ var tickerSymbolByAddress = Object.fromEntries(
365715
+ Object.values(tickerTokensByNetwork).map(
365716
+ (en) => Object.entries(en).map(
365717
+ ([symbol, addresses]) => addresses.map((addr) => [addr.toLowerCase(), symbol])
365718
+ ).flat()
365719
+ ).flat()
365720
+ );
365636
365721
  function getTokenSymbol(address) {
365637
365722
  return tokenSymbolByAddress[address.toLowerCase()];
365638
365723
  }
@@ -365641,8 +365726,7 @@ function getTokenSymbolOrTicker(address) {
365641
365726
  }
365642
365727
  function getDecimals(token) {
365643
365728
  let dec = decimals[token];
365644
- if (dec)
365645
- return dec;
365729
+ if (dec) return dec;
365646
365730
  dec = decimals[tokenSymbolByAddress[token.toLowerCase()]];
365647
365731
  if (!dec) {
365648
365732
  throw new Error(`Decimals for ${token} not found`);
@@ -370209,7 +370293,13 @@ var AbstractPriceFeedContract = class extends BaseContract {
370209
370293
  this.#updatable = args.updatable;
370210
370294
  this.#skipCheck = args.skipCheck;
370211
370295
  if (args.underlyingFeeds && args.underlyingStalenessPeriods) {
370212
- this.#underlyingPriceFeeds = args.underlyingFeeds.map((address, i) => new PriceFeedRef(this.sdk, address, args.underlyingStalenessPeriods[i]));
370296
+ this.#underlyingPriceFeeds = args.underlyingFeeds.map(
370297
+ (address, i) => new PriceFeedRef(
370298
+ this.sdk,
370299
+ address,
370300
+ args.underlyingStalenessPeriods[i]
370301
+ )
370302
+ );
370213
370303
  }
370214
370304
  }
370215
370305
  get loaded() {
@@ -370268,7 +370358,9 @@ var AbstractPriceFeedContract = class extends BaseContract {
370268
370358
  return lastRoundData[1];
370269
370359
  }
370270
370360
  updatableDependencies() {
370271
- const underlying = this.underlyingPriceFeeds.flatMap((f) => f.priceFeed.updatableDependencies());
370361
+ const underlying = this.underlyingPriceFeeds.flatMap(
370362
+ (f) => f.priceFeed.updatableDependencies()
370363
+ );
370272
370364
  return this.updatable ? [this, ...underlying] : underlying;
370273
370365
  }
370274
370366
  };
@@ -370283,17 +370375,20 @@ var AbstractLPPriceFeedContract = class _AbstractLPPriceFeedContract extends Abs
370283
370375
  constructor(sdk, args) {
370284
370376
  super(sdk, { ...args, decimals: 8 });
370285
370377
  this.hasLowerBoundCap = true;
370286
- const decoder = decodeAbiParameters([
370287
- { type: "address", name: "lpToken" },
370288
- { type: "address", name: "lpContract" },
370289
- { type: "uint256", name: "lowerBound" },
370290
- { type: "uint256", name: "upperBound" },
370291
- // { type: "bool", name: "updateBoundsAllowed" },
370292
- // { type: "uint40", name: "lastBoundsUpdate" },
370293
- { type: "int256", name: "aggregatePrice" },
370294
- { type: "uint256", name: "lPExchangeRate" },
370295
- { type: "uint256", name: "scale" }
370296
- ], hexToBytes(args.baseParams.serializedParams));
370378
+ const decoder = decodeAbiParameters(
370379
+ [
370380
+ { type: "address", name: "lpToken" },
370381
+ { type: "address", name: "lpContract" },
370382
+ { type: "uint256", name: "lowerBound" },
370383
+ { type: "uint256", name: "upperBound" },
370384
+ // { type: "bool", name: "updateBoundsAllowed" },
370385
+ // { type: "uint40", name: "lastBoundsUpdate" },
370386
+ { type: "int256", name: "aggregatePrice" },
370387
+ { type: "uint256", name: "lPExchangeRate" },
370388
+ { type: "uint256", name: "scale" }
370389
+ ],
370390
+ hexToBytes(args.baseParams.serializedParams)
370391
+ );
370297
370392
  this.lpToken = decoder[0];
370298
370393
  this.lpContract = decoder[1];
370299
370394
  this.lowerBound = decoder[2];
@@ -370302,7 +370397,9 @@ var AbstractLPPriceFeedContract = class _AbstractLPPriceFeedContract extends Abs
370302
370397
  async getLowerBound() {
370303
370398
  const value = await this.getValue();
370304
370399
  const lowerBound = _AbstractLPPriceFeedContract.toLowerBound(value);
370305
- this.logger?.debug(`Lowerbound for ${this.labelAddress(this.address)}: ${lowerBound}`);
370400
+ this.logger?.debug(
370401
+ `Lowerbound for ${this.labelAddress(this.address)}: ${lowerBound}`
370402
+ );
370306
370403
  return lowerBound;
370307
370404
  }
370308
370405
  static toLowerBound(value) {
@@ -370343,12 +370440,15 @@ var BalancerWeightedPriceFeedContract = class extends AbstractLPPriceFeedContrac
370343
370440
  poolId;
370344
370441
  weights;
370345
370442
  constructor(sdk, args) {
370346
- const decoded = decodeAbiParameters([
370347
- { type: "bytes", name: "superParams" },
370348
- { type: "address", name: "vault" },
370349
- { type: "bytes32", name: "poolId" },
370350
- { type: "uint256[8]", name: "weights" }
370351
- ], hexToBytes(args.baseParams.serializedParams));
370443
+ const decoded = decodeAbiParameters(
370444
+ [
370445
+ { type: "bytes", name: "superParams" },
370446
+ { type: "address", name: "vault" },
370447
+ { type: "bytes32", name: "poolId" },
370448
+ { type: "uint256[8]", name: "weights" }
370449
+ ],
370450
+ hexToBytes(args.baseParams.serializedParams)
370451
+ );
370352
370452
  super(sdk, {
370353
370453
  ...args,
370354
370454
  baseParams: {
@@ -370385,10 +370485,13 @@ var BoundedPriceFeedContract = class extends AbstractPriceFeedContract {
370385
370485
  upperBound;
370386
370486
  constructor(sdk, args) {
370387
370487
  super(sdk, { ...args, name: "BoundedPriceFeed", abi: boundedPriceFeedAbi });
370388
- const decoder = decodeAbiParameters([
370389
- { type: "int256" }
370390
- // upperBound
370391
- ], args.baseParams.serializedParams);
370488
+ const decoder = decodeAbiParameters(
370489
+ [
370490
+ { type: "int256" }
370491
+ // upperBound
370492
+ ],
370493
+ args.baseParams.serializedParams
370494
+ );
370392
370495
  this.upperBound = decoder[0];
370393
370496
  }
370394
370497
  stateHuman(raw = true) {
@@ -370541,14 +370644,17 @@ var PendleTWAPPTPriceFeed = class extends AbstractPriceFeedContract {
370541
370644
  name: "PendleTWAPPTPriceFeed",
370542
370645
  abi: abi10
370543
370646
  });
370544
- const decoded = decodeAbiParameters([
370545
- { type: "address", name: "market" },
370546
- { type: "address", name: "sy" },
370547
- { type: "address", name: "yt" },
370548
- { type: "uint256", name: "expiry" },
370549
- { type: "uint32", name: "twapWindow" },
370550
- { type: "bool", name: "priceToSy" }
370551
- ], args.baseParams.serializedParams);
370647
+ const decoded = decodeAbiParameters(
370648
+ [
370649
+ { type: "address", name: "market" },
370650
+ { type: "address", name: "sy" },
370651
+ { type: "address", name: "yt" },
370652
+ { type: "uint256", name: "expiry" },
370653
+ { type: "uint32", name: "twapWindow" },
370654
+ { type: "bool", name: "priceToSy" }
370655
+ ],
370656
+ args.baseParams.serializedParams
370657
+ );
370552
370658
  this.market = decoded[0];
370553
370659
  this.sy = decoded[1];
370554
370660
  this.yt = decoded[2];
@@ -370595,38 +370701,41 @@ var RedstonePriceFeedContract = class extends AbstractPriceFeedContract {
370595
370701
  name: `RedstonePriceFeed`,
370596
370702
  abi: redstonePriceFeedAbi
370597
370703
  });
370598
- const decoder = decodeAbiParameters([
370599
- { type: "address" },
370600
- // [0]: pf.token(),
370601
- { type: "bytes32" },
370602
- // [1]: pf.dataFeedId(),
370603
- { type: "address" },
370604
- // [2]: pf.signerAddress0(),
370605
- { type: "address" },
370606
- // [3]: pf.signerAddress1(),
370607
- { type: "address" },
370608
- // [4]: pf.signerAddress2(),
370609
- { type: "address" },
370610
- // [5]: pf.signerAddress3(),
370611
- { type: "address" },
370612
- // [6]: pf.signerAddress4(),
370613
- { type: "address" },
370614
- // [7]: pf.signerAddress5()
370615
- { type: "address" },
370616
- // [8]: pf.signerAddress6(),
370617
- { type: "address" },
370618
- // [9]: pf.signerAddress7(),
370619
- { type: "address" },
370620
- // [10]: pf.signerAddress8(),
370621
- { type: "address" },
370622
- // [11]: pf.signerAddress9(),
370623
- { type: "uint8" },
370624
- // [12]: pf.getUniqueSignersThreshold()
370625
- { type: "uint128" },
370626
- // [13]: pf.lastPrice(),
370627
- { type: "uint40" }
370628
- // [14]: pf.lastPayloadTimestamp()
370629
- ], args.baseParams.serializedParams);
370704
+ const decoder = decodeAbiParameters(
370705
+ [
370706
+ { type: "address" },
370707
+ // [0]: pf.token(),
370708
+ { type: "bytes32" },
370709
+ // [1]: pf.dataFeedId(),
370710
+ { type: "address" },
370711
+ // [2]: pf.signerAddress0(),
370712
+ { type: "address" },
370713
+ // [3]: pf.signerAddress1(),
370714
+ { type: "address" },
370715
+ // [4]: pf.signerAddress2(),
370716
+ { type: "address" },
370717
+ // [5]: pf.signerAddress3(),
370718
+ { type: "address" },
370719
+ // [6]: pf.signerAddress4(),
370720
+ { type: "address" },
370721
+ // [7]: pf.signerAddress5()
370722
+ { type: "address" },
370723
+ // [8]: pf.signerAddress6(),
370724
+ { type: "address" },
370725
+ // [9]: pf.signerAddress7(),
370726
+ { type: "address" },
370727
+ // [10]: pf.signerAddress8(),
370728
+ { type: "address" },
370729
+ // [11]: pf.signerAddress9(),
370730
+ { type: "uint8" },
370731
+ // [12]: pf.getUniqueSignersThreshold()
370732
+ { type: "uint128" },
370733
+ // [13]: pf.lastPrice(),
370734
+ { type: "uint40" }
370735
+ // [14]: pf.lastPayloadTimestamp()
370736
+ ],
370737
+ args.baseParams.serializedParams
370738
+ );
370630
370739
  this.dataId = bytesToString(toBytes(decoder[1])).replaceAll("\0", "");
370631
370740
  this.signers = decoder.slice(2, 11);
370632
370741
  this.signersThreshold = Number(decoder[12]);
@@ -370669,7 +370778,10 @@ var RedstoneUpdater = class extends SDKConstruct {
370669
370778
  this.#gateways = gateways;
370670
370779
  }
370671
370780
  async getUpdateTxs(feeds, logContext = {}) {
370672
- this.#logger?.debug(logContext, `generating update transactions for ${feeds.length} redstone price feeds`);
370781
+ this.#logger?.debug(
370782
+ logContext,
370783
+ `generating update transactions for ${feeds.length} redstone price feeds`
370784
+ );
370673
370785
  const groupedFeeds = {};
370674
370786
  const priceFeeds = /* @__PURE__ */ new Map();
370675
370787
  for (const feed of feeds) {
@@ -370684,7 +370796,11 @@ var RedstoneUpdater = class extends SDKConstruct {
370684
370796
  for (const [key, group] of Object.entries(groupedFeeds)) {
370685
370797
  const [dataServiceId, signersStr] = key.split(":");
370686
370798
  const uniqueSignersCount = parseInt(signersStr, 10);
370687
- const payloads = await this.#getPayloads(dataServiceId, group, uniqueSignersCount);
370799
+ const payloads = await this.#getPayloads(
370800
+ dataServiceId,
370801
+ group,
370802
+ uniqueSignersCount
370803
+ );
370688
370804
  for (const { dataFeedId, data, timestamp } of payloads) {
370689
370805
  const priceFeed = priceFeeds.get(dataFeedId);
370690
370806
  if (!priceFeed) {
@@ -370701,7 +370817,10 @@ var RedstoneUpdater = class extends SDKConstruct {
370701
370817
  });
370702
370818
  }
370703
370819
  }
370704
- this.#logger?.debug(logContext, `generated ${results.length} update transactions for redstone price feeds`);
370820
+ this.#logger?.debug(
370821
+ logContext,
370822
+ `generated ${results.length} update transactions for redstone price feeds`
370823
+ );
370705
370824
  return results;
370706
370825
  }
370707
370826
  /**
@@ -370713,11 +370832,18 @@ var RedstoneUpdater = class extends SDKConstruct {
370713
370832
  * @returns
370714
370833
  */
370715
370834
  async #getPayloads(dataServiceId, dataFeedsIds, uniqueSignersCount) {
370716
- this.#logger?.debug(`getting redstone payloads for ${dataFeedsIds.size} data feeds in ${dataServiceId} with ${uniqueSignersCount} signers: ${Array.from(dataFeedsIds).join(", ")}`);
370835
+ this.#logger?.debug(
370836
+ `getting redstone payloads for ${dataFeedsIds.size} data feeds in ${dataServiceId} with ${uniqueSignersCount} signers: ${Array.from(dataFeedsIds).join(", ")}`
370837
+ );
370717
370838
  const fromCache = [];
370718
370839
  const uncached = [];
370719
370840
  for (const dataFeedId of dataFeedsIds) {
370720
- const key = cacheKey2(dataServiceId, dataFeedId, uniqueSignersCount, this.#historicalTimestampMs);
370841
+ const key = cacheKey2(
370842
+ dataServiceId,
370843
+ dataFeedId,
370844
+ uniqueSignersCount,
370845
+ this.#historicalTimestampMs
370846
+ );
370721
370847
  const cached = this.#cache.get(key);
370722
370848
  if (this.#historicalTimestampMs && !!cached) {
370723
370849
  fromCache.push(cached);
@@ -370725,14 +370851,25 @@ var RedstoneUpdater = class extends SDKConstruct {
370725
370851
  uncached.push(dataFeedId);
370726
370852
  }
370727
370853
  }
370728
- const fromRedstone = await this.#fetchPayloads(dataServiceId, new Set(uncached), uniqueSignersCount);
370854
+ const fromRedstone = await this.#fetchPayloads(
370855
+ dataServiceId,
370856
+ new Set(uncached),
370857
+ uniqueSignersCount
370858
+ );
370729
370859
  if (this.#historicalTimestampMs) {
370730
370860
  for (const resp of fromRedstone) {
370731
- const key = cacheKey2(dataServiceId, resp.dataFeedId, uniqueSignersCount, this.#historicalTimestampMs);
370861
+ const key = cacheKey2(
370862
+ dataServiceId,
370863
+ resp.dataFeedId,
370864
+ uniqueSignersCount,
370865
+ this.#historicalTimestampMs
370866
+ );
370732
370867
  this.#cache.set(key, resp);
370733
370868
  }
370734
370869
  }
370735
- this.#logger?.debug(`got ${fromRedstone.length} new redstone updates and ${fromCache.length} from cache`);
370870
+ this.#logger?.debug(
370871
+ `got ${fromRedstone.length} new redstone updates and ${fromCache.length} from cache`
370872
+ );
370736
370873
  return [...fromCache, ...fromRedstone];
370737
370874
  }
370738
370875
  /**
@@ -370749,7 +370886,9 @@ var RedstoneUpdater = class extends SDKConstruct {
370749
370886
  }
370750
370887
  const dataPackagesIds = Array.from(dataFeedsIds);
370751
370888
  const tsStr = this.#historicalTimestampMs ? ` with historical timestamp ${this.#historicalTimestampMs}` : "";
370752
- this.#logger?.debug(`fetching redstone payloads for ${dataFeedsIds.size} data feeds in ${dataServiceId} with ${uniqueSignersCount} signers: ${dataPackagesIds.join(", ")}${tsStr}`);
370889
+ this.#logger?.debug(
370890
+ `fetching redstone payloads for ${dataFeedsIds.size} data feeds in ${dataServiceId} with ${uniqueSignersCount} signers: ${dataPackagesIds.join(", ")}${tsStr}`
370891
+ );
370753
370892
  const wrapper = new import_evm_connector.DataServiceWrapper({
370754
370893
  dataServiceId,
370755
370894
  dataPackagesIds,
@@ -370757,7 +370896,10 @@ var RedstoneUpdater = class extends SDKConstruct {
370757
370896
  historicalTimestamp: this.#historicalTimestampMs,
370758
370897
  urls: this.#gateways
370759
370898
  });
370760
- const dataPayload = await retry(() => wrapper.prepareRedstonePayload(true), { attempts: 5, interval: this.#historicalTimestampMs ? 30500 : 250 });
370899
+ const dataPayload = await retry(
370900
+ () => wrapper.prepareRedstonePayload(true),
370901
+ { attempts: 5, interval: this.#historicalTimestampMs ? 30500 : 250 }
370902
+ );
370761
370903
  const parsed = import_protocol.RedstonePayload.parse(toBytes(`0x${dataPayload}`));
370762
370904
  const packagesByDataFeedId = groupDataPackages(parsed.signedDataPackages);
370763
370905
  return dataPackagesIds.map((dataFeedId) => {
@@ -370766,9 +370908,15 @@ var RedstoneUpdater = class extends SDKConstruct {
370766
370908
  throw new Error(`cannot find data packages for ${dataFeedId}`);
370767
370909
  }
370768
370910
  if (signedDataPackages.length !== uniqueSignersCount) {
370769
- throw new Error(`got ${signedDataPackages.length} data packages for ${dataFeedId}, but expected ${uniqueSignersCount}`);
370911
+ throw new Error(
370912
+ `got ${signedDataPackages.length} data packages for ${dataFeedId}, but expected ${uniqueSignersCount}`
370913
+ );
370770
370914
  }
370771
- return getCalldataWithTimestamp(dataFeedId, signedDataPackages, wrapper.getUnsignedMetadata());
370915
+ return getCalldataWithTimestamp(
370916
+ dataFeedId,
370917
+ signedDataPackages,
370918
+ wrapper.getUnsignedMetadata()
370919
+ );
370772
370920
  });
370773
370921
  }
370774
370922
  };
@@ -370782,7 +370930,9 @@ function groupDataPackages(signedDataPackages) {
370782
370930
  const dataFeedId0 = dataPoints[0].dataFeedId;
370783
370931
  for (const dp of dataPoints) {
370784
370932
  if (dp.dataFeedId !== dataFeedId0) {
370785
- throw new Error(`data package contains data points with different dataFeedIds: ${dp.dataFeedId} and ${dataFeedId0}`);
370933
+ throw new Error(
370934
+ `data package contains data points with different dataFeedIds: ${dp.dataFeedId} and ${dataFeedId0}`
370935
+ );
370786
370936
  }
370787
370937
  }
370788
370938
  if (!packagesByDataFeedId[dataFeedId0]) {
@@ -370809,7 +370959,10 @@ function getCalldataWithTimestamp(dataFeedId, packages, unsignedMetadata) {
370809
370959
  }
370810
370960
  return {
370811
370961
  dataFeedId,
370812
- data: encodeAbiParameters([{ type: "uint256" }, { type: "bytes" }], [BigInt(timestamp), `0x${payload}`]),
370962
+ data: encodeAbiParameters(
370963
+ [{ type: "uint256" }, { type: "bytes" }],
370964
+ [BigInt(timestamp), `0x${payload}`]
370965
+ ),
370813
370966
  timestamp
370814
370967
  };
370815
370968
  }
@@ -370905,7 +371058,10 @@ var PriceFeedRegister = class extends SDKConstruct {
370905
371058
  * This can later be used to load price feed updates
370906
371059
  */
370907
371060
  async preloadUpdatablePriceFeeds(marketConfigurators, pools) {
370908
- const feedsData = await this.#loadUpdatablePriceFeeds(marketConfigurators, pools);
371061
+ const feedsData = await this.#loadUpdatablePriceFeeds(
371062
+ marketConfigurators,
371063
+ pools
371064
+ );
370909
371065
  for (const data of feedsData) {
370910
371066
  const feed = this.create({ baseParams: data });
370911
371067
  this.#feeds.upsert(feed.address, feed);
@@ -370918,23 +371074,29 @@ var PriceFeedRegister = class extends SDKConstruct {
370918
371074
  * @returns
370919
371075
  */
370920
371076
  async getUpdatePriceFeedsTx(marketConfigurators, pools) {
370921
- const feedsData = await this.#loadUpdatablePriceFeeds(marketConfigurators, pools);
371077
+ const feedsData = await this.#loadUpdatablePriceFeeds(
371078
+ marketConfigurators,
371079
+ pools
371080
+ );
370922
371081
  const feeds = feedsData.map((data) => this.create({ baseParams: data }));
370923
371082
  const updates = await this.#generatePriceFeedsUpdateTxs(feeds);
370924
- return createRawTx(getChainContractAddress({
370925
- chain: this.sdk.provider.chain,
370926
- contract: "multicall3"
370927
- }), {
370928
- abi: multicall3Abi,
370929
- functionName: "aggregate3",
370930
- args: [
370931
- updates.txs.map((tx) => ({
370932
- target: tx.to,
370933
- allowFailure: false,
370934
- callData: tx.callData
370935
- }))
370936
- ]
370937
- });
371083
+ return createRawTx(
371084
+ getChainContractAddress({
371085
+ chain: this.sdk.provider.chain,
371086
+ contract: "multicall3"
371087
+ }),
371088
+ {
371089
+ abi: multicall3Abi,
371090
+ functionName: "aggregate3",
371091
+ args: [
371092
+ updates.txs.map((tx) => ({
371093
+ target: tx.to,
371094
+ allowFailure: false,
371095
+ callData: tx.callData
371096
+ }))
371097
+ ]
371098
+ }
371099
+ );
370938
371100
  }
370939
371101
  async #generatePriceFeedsUpdateTxs(updateables, logContext = {}) {
370940
371102
  const txs = [];
@@ -370946,7 +371108,10 @@ var PriceFeedRegister = class extends SDKConstruct {
370946
371108
  }
370947
371109
  let maxTimestamp = 0;
370948
371110
  if (redstonePFs.length > 0) {
370949
- const redstoneUpdates = await this.redstoneUpdater.getUpdateTxs(redstonePFs, logContext);
371111
+ const redstoneUpdates = await this.redstoneUpdater.getUpdateTxs(
371112
+ redstonePFs,
371113
+ logContext
371114
+ );
370950
371115
  for (const { tx, timestamp } of redstoneUpdates) {
370951
371116
  if (timestamp > maxTimestamp) {
370952
371117
  maxTimestamp = timestamp;
@@ -370955,16 +371120,25 @@ var PriceFeedRegister = class extends SDKConstruct {
370955
371120
  }
370956
371121
  }
370957
371122
  const result = { txs, timestamp: maxTimestamp };
370958
- this.logger?.debug(logContext, `generated ${txs.length} price feed update transactions, timestamp: ${maxTimestamp}`);
371123
+ this.logger?.debug(
371124
+ logContext,
371125
+ `generated ${txs.length} price feed update transactions, timestamp: ${maxTimestamp}`
371126
+ );
370959
371127
  if (txs.length) {
370960
371128
  await this.#hooks.triggerHooks("updatesGenerated", result);
370961
371129
  }
370962
371130
  return result;
370963
371131
  }
370964
371132
  async #loadUpdatablePriceFeeds(marketConfigurators, pools) {
370965
- const marketCompressorAddress = this.sdk.addressProvider.getAddress(AP_MARKET_COMPRESSOR, 310);
371133
+ const marketCompressorAddress = this.sdk.addressProvider.getAddress(
371134
+ AP_MARKET_COMPRESSOR,
371135
+ 310
371136
+ );
370966
371137
  const configurators = marketConfigurators ?? this.sdk.marketRegister.marketConfigurators.map((mc) => mc.address);
370967
- this.logger?.debug({ configurators, pools }, "calling getUpdatablePriceFeeds");
371138
+ this.logger?.debug(
371139
+ { configurators, pools },
371140
+ "calling getUpdatablePriceFeeds"
371141
+ );
370968
371142
  const result = await this.provider.publicClient.readContract({
370969
371143
  address: marketCompressorAddress,
370970
371144
  abi: iMarketCompressorAbi,
@@ -370984,7 +371158,9 @@ var PriceFeedRegister = class extends SDKConstruct {
370984
371158
  return result;
370985
371159
  }
370986
371160
  create(data) {
370987
- const contractType = bytes32ToString(data.baseParams.contractType);
371161
+ const contractType = bytes32ToString(
371162
+ data.baseParams.contractType
371163
+ );
370988
371164
  switch (contractType) {
370989
371165
  case "PRICE_FEED::EXTERNAL":
370990
371166
  return new ChainlinkPriceFeedContract(this.sdk, data);
@@ -371046,11 +371222,17 @@ var PriceOracleBaseContract = class extends BaseContract {
371046
371222
  /**
371047
371223
  * Mapping Token => [PriceFeed Address, stalenessPeriod]
371048
371224
  */
371049
- mainPriceFeeds = new AddressMap(void 0, "mainPriceFeeds");
371225
+ mainPriceFeeds = new AddressMap(
371226
+ void 0,
371227
+ "mainPriceFeeds"
371228
+ );
371050
371229
  /**
371051
371230
  * Mapping Token => [PriceFeed Address, stalenessPeriod]
371052
371231
  */
371053
- reservePriceFeeds = new AddressMap(void 0, "reservePriceFeeds");
371232
+ reservePriceFeeds = new AddressMap(
371233
+ void 0,
371234
+ "reservePriceFeeds"
371235
+ );
371054
371236
  /**
371055
371237
  * Mapping Token => Price in underlying
371056
371238
  */
@@ -371058,7 +371240,10 @@ var PriceOracleBaseContract = class extends BaseContract {
371058
371240
  /**
371059
371241
  * Mapping Token => Price in underlying
371060
371242
  */
371061
- reservePrices = new AddressMap(void 0, "reservePrices");
371243
+ reservePrices = new AddressMap(
371244
+ void 0,
371245
+ "reservePrices"
371246
+ );
371062
371247
  #priceFeedTree = [];
371063
371248
  constructor(sdk, args, data, underlying) {
371064
371249
  super(sdk, args);
@@ -371110,7 +371295,9 @@ var PriceOracleBaseContract = class extends BaseContract {
371110
371295
  const { to: priceFeed, callData, description } = tx;
371111
371296
  const [token, reserve] = this.findTokenForPriceFeed(priceFeed);
371112
371297
  if (!token) {
371113
- this.logger?.debug(`skipping onDemandPriceUpdate ${description}): token not found for price feed ${priceFeed} in oracle ${this.address}`);
371298
+ this.logger?.debug(
371299
+ `skipping onDemandPriceUpdate ${description}): token not found for price feed ${priceFeed} in oracle ${this.address}`
371300
+ );
371114
371301
  continue;
371115
371302
  }
371116
371303
  const { args } = decodeFunctionData({
@@ -371125,7 +371312,9 @@ var PriceOracleBaseContract = class extends BaseContract {
371125
371312
  data
371126
371313
  });
371127
371314
  }
371128
- this.logger?.debug(`got ${result.length} onDemandPriceUpdates from ${txs.length} txs`);
371315
+ this.logger?.debug(
371316
+ `got ${result.length} onDemandPriceUpdates from ${txs.length} txs`
371317
+ );
371129
371318
  return result;
371130
371319
  }
371131
371320
  /**
@@ -371134,7 +371323,9 @@ var PriceOracleBaseContract = class extends BaseContract {
371134
371323
  * @returns
371135
371324
  */
371136
371325
  usesPriceFeed(priceFeed) {
371137
- return this.#priceFeedTree.some((node) => node.baseParams.addr.toLowerCase() === priceFeed.toLowerCase());
371326
+ return this.#priceFeedTree.some(
371327
+ (node) => node.baseParams.addr.toLowerCase() === priceFeed.toLowerCase()
371328
+ );
371138
371329
  }
371139
371330
  /**
371140
371331
  * Tries to convert amount of token into underlying of current market
@@ -371185,16 +371376,22 @@ var PriceOracleBaseContract = class extends BaseContract {
371185
371376
  syncStateMulticall() {
371186
371377
  const args = [this.address];
371187
371378
  if (this.version === 300) {
371188
- args.push(Array.from(/* @__PURE__ */ new Set([
371189
- this.underlying,
371190
- ...this.mainPriceFeeds.keys(),
371191
- ...this.reservePriceFeeds.keys()
371192
- ])));
371379
+ args.push(
371380
+ Array.from(
371381
+ /* @__PURE__ */ new Set([
371382
+ this.underlying,
371383
+ ...this.mainPriceFeeds.keys(),
371384
+ ...this.reservePriceFeeds.keys()
371385
+ ])
371386
+ )
371387
+ );
371193
371388
  }
371194
371389
  return {
371195
371390
  call: {
371196
371391
  abi: iPriceFeedCompressorAbi,
371197
- address: this.sdk.addressProvider.getLatestVersion(AP_PRICE_FEED_COMPRESSOR),
371392
+ address: this.sdk.addressProvider.getLatestVersion(
371393
+ AP_PRICE_FEED_COMPRESSOR
371394
+ ),
371198
371395
  functionName: "getPriceFeeds",
371199
371396
  args
371200
371397
  },
@@ -371215,26 +371412,34 @@ var PriceOracleBaseContract = class extends BaseContract {
371215
371412
  entries.forEach((entry) => {
371216
371413
  const { token, priceFeed, reserve, stalenessPeriod } = entry;
371217
371414
  const ref = new PriceFeedRef(this.sdk, priceFeed, stalenessPeriod);
371218
- const node = this.#priceFeedTree.find((n) => n.baseParams.addr === priceFeed);
371415
+ const node = this.#priceFeedTree.find(
371416
+ (n) => n.baseParams.addr === priceFeed
371417
+ );
371219
371418
  const price = node?.answer?.price;
371220
371419
  if (reserve) {
371221
371420
  this.reservePriceFeeds.upsert(token, ref);
371222
371421
  if (price) {
371223
371422
  this.reservePrices.upsert(token, price);
371224
371423
  } else {
371225
- this.logger?.warn(`answer not found for reserve price feed ${this.labelAddress(priceFeed)}, success: ${node?.answer?.success}`);
371424
+ this.logger?.warn(
371425
+ `answer not found for reserve price feed ${this.labelAddress(priceFeed)}, success: ${node?.answer?.success}`
371426
+ );
371226
371427
  }
371227
371428
  } else {
371228
371429
  this.mainPriceFeeds.upsert(token, ref);
371229
371430
  if (price) {
371230
371431
  this.mainPrices.upsert(token, price);
371231
371432
  } else {
371232
- this.logger?.warn(`answer not found for main price feed ${this.labelAddress(priceFeed)}, success: ${node?.answer?.success}`);
371433
+ this.logger?.warn(
371434
+ `answer not found for main price feed ${this.labelAddress(priceFeed)}, success: ${node?.answer?.success}`
371435
+ );
371233
371436
  }
371234
371437
  }
371235
371438
  this.#labelPriceFeed(priceFeed, reserve ? "Reserve" : "Main", token);
371236
371439
  });
371237
- this.logger?.debug(`Got ${this.mainPriceFeeds.size} main and ${this.reservePriceFeeds.size} reserve price feeds`);
371440
+ this.logger?.debug(
371441
+ `Got ${this.mainPriceFeeds.size} main and ${this.reservePriceFeeds.size} reserve price feeds`
371442
+ );
371238
371443
  }
371239
371444
  #labelPriceFeed(address, usage, token) {
371240
371445
  this.sdk.provider.addressLabels.set(address, (oldLabel) => {
@@ -371271,8 +371476,12 @@ var PriceOracleBaseContract = class extends BaseContract {
371271
371476
  stateHuman(raw = true) {
371272
371477
  return {
371273
371478
  ...super.stateHuman(raw),
371274
- mainPriceFeeds: Object.fromEntries(this.mainPriceFeeds.entries().map(([token, v]) => [this.labelAddress(token), v.stateHuman(raw)])),
371275
- reservePriceFeeds: Object.fromEntries(this.reservePriceFeeds.entries().map(([token, v]) => [this.labelAddress(token), v.stateHuman(raw)]))
371479
+ mainPriceFeeds: Object.fromEntries(
371480
+ this.mainPriceFeeds.entries().map(([token, v]) => [this.labelAddress(token), v.stateHuman(raw)])
371481
+ ),
371482
+ reservePriceFeeds: Object.fromEntries(
371483
+ this.reservePriceFeeds.entries().map(([token, v]) => [this.labelAddress(token), v.stateHuman(raw)])
371484
+ )
371276
371485
  };
371277
371486
  }
371278
371487
  get priceFeedTree() {
@@ -371284,11 +371493,16 @@ var PriceOracleBaseContract = class extends BaseContract {
371284
371493
  var abi11 = [...iPriceOracleV300Abi, ...iPausableAbi];
371285
371494
  var PriceOracleV300Contract = class extends PriceOracleBaseContract {
371286
371495
  constructor(sdk, data, underlying) {
371287
- super(sdk, {
371288
- ...data.baseParams,
371289
- name: "PriceOracleV3",
371290
- abi: abi11
371291
- }, data, underlying);
371496
+ super(
371497
+ sdk,
371498
+ {
371499
+ ...data.baseParams,
371500
+ name: "PriceOracleV3",
371501
+ abi: abi11
371502
+ },
371503
+ data,
371504
+ underlying
371505
+ );
371292
371506
  }
371293
371507
  processLog(log2) {
371294
371508
  switch (log2.eventName) {
@@ -371307,10 +371521,16 @@ var PriceOracleV300Contract = class extends PriceOracleBaseContract {
371307
371521
  if (token) {
371308
371522
  return [token, reserve];
371309
371523
  }
371310
- const tickers = Object.values(tickerInfoTokensByNetwork[this.sdk.provider.networkType]).flat();
371311
- const ticker = tickers.find((t) => t.priceFeed.toLowerCase() === priceFeed.toLowerCase());
371524
+ const tickers = Object.values(
371525
+ tickerInfoTokensByNetwork[this.sdk.provider.networkType]
371526
+ ).flat();
371527
+ const ticker = tickers.find(
371528
+ (t) => t.priceFeed.toLowerCase() === priceFeed.toLowerCase()
371529
+ );
371312
371530
  if (ticker) {
371313
- this.logger?.debug(`will use ticker ${ticker.symbol} (${ticker.address}) for price feed ${priceFeed}`);
371531
+ this.logger?.debug(
371532
+ `will use ticker ${ticker.symbol} (${ticker.address}) for price feed ${priceFeed}`
371533
+ );
371314
371534
  return [ticker.address, false];
371315
371535
  }
371316
371536
  return [void 0, false];
@@ -371321,11 +371541,16 @@ var PriceOracleV300Contract = class extends PriceOracleBaseContract {
371321
371541
  var abi12 = iPriceOracleV310Abi;
371322
371542
  var PriceOracleV310Contract = class extends PriceOracleBaseContract {
371323
371543
  constructor(sdk, data, underlying) {
371324
- super(sdk, {
371325
- ...data.baseParams,
371326
- name: "PriceOracleV3",
371327
- abi: abi12
371328
- }, data, underlying);
371544
+ super(
371545
+ sdk,
371546
+ {
371547
+ ...data.baseParams,
371548
+ name: "PriceOracleV3",
371549
+ abi: abi12
371550
+ },
371551
+ data,
371552
+ underlying
371553
+ );
371329
371554
  }
371330
371555
  processLog(log2) {
371331
371556
  switch (log2.eventName) {
@@ -371361,22 +371586,25 @@ var GaugeContract = class extends BaseContract {
371361
371586
  name: `Gauge(${pool.name})`,
371362
371587
  abi: iGaugeV300Abi
371363
371588
  });
371364
- const [_voter, epochLastUpdate, epochFrozen, gaugeTokens, gaugeParams] = decodeAbiParameters([
371365
- { name: "voter", type: "address" },
371366
- { name: "epochLastUpdate", type: "uint16" },
371367
- { name: "epochFrozen", type: "bool" },
371368
- { name: "tokens", type: "address[]" },
371369
- {
371370
- name: "quotaParams",
371371
- type: "tuple[]",
371372
- components: [
371373
- { name: "minRate", type: "uint16" },
371374
- { name: "maxRate", type: "uint16" },
371375
- { name: "totalVotesLpSide", type: "uint96" },
371376
- { name: "totalVotesCaSide", type: "uint96" }
371377
- ]
371378
- }
371379
- ], gauge.baseParams.serializedParams);
371589
+ const [_voter, epochLastUpdate, epochFrozen, gaugeTokens, gaugeParams] = decodeAbiParameters(
371590
+ [
371591
+ { name: "voter", type: "address" },
371592
+ { name: "epochLastUpdate", type: "uint16" },
371593
+ { name: "epochFrozen", type: "bool" },
371594
+ { name: "tokens", type: "address[]" },
371595
+ {
371596
+ name: "quotaParams",
371597
+ type: "tuple[]",
371598
+ components: [
371599
+ { name: "minRate", type: "uint16" },
371600
+ { name: "maxRate", type: "uint16" },
371601
+ { name: "totalVotesLpSide", type: "uint96" },
371602
+ { name: "totalVotesCaSide", type: "uint96" }
371603
+ ]
371604
+ }
371605
+ ],
371606
+ gauge.baseParams.serializedParams
371607
+ );
371380
371608
  this.epochFrozen = epochFrozen;
371381
371609
  this.epochLastUpdate = epochLastUpdate;
371382
371610
  this.rates = new AddressMap(gauge.rates.map((r) => [r.token, r.rate]));
@@ -371410,16 +371638,19 @@ var GaugeContract = class extends BaseContract {
371410
371638
  ...super.stateHuman(raw),
371411
371639
  epochLastUpdate: Number(this.epochLastUpdate),
371412
371640
  epochFrozen: this.epochFrozen,
371413
- quotaParams: this.quotaParams.entries().reduce((acc, [address, params]) => ({
371414
- ...acc,
371415
- [this.labelAddress(address)]: {
371416
- minRate: percentFmt(params.minRate, raw),
371417
- maxRate: percentFmt(params.maxRate, raw),
371418
- totalVotesLpSide: params.totalVotesLpSide / WAD,
371419
- totalVotesCaSide: params.totalVotesCaSide / WAD,
371420
- rate: percentFmt(params.rate, raw)
371421
- }
371422
- }), {})
371641
+ quotaParams: this.quotaParams.entries().reduce(
371642
+ (acc, [address, params]) => ({
371643
+ ...acc,
371644
+ [this.labelAddress(address)]: {
371645
+ minRate: percentFmt(params.minRate, raw),
371646
+ maxRate: percentFmt(params.maxRate, raw),
371647
+ totalVotesLpSide: params.totalVotesLpSide / WAD,
371648
+ totalVotesCaSide: params.totalVotesCaSide / WAD,
371649
+ rate: percentFmt(params.rate, raw)
371650
+ }
371651
+ }),
371652
+ {}
371653
+ )
371423
371654
  };
371424
371655
  }
371425
371656
  };
@@ -371440,15 +371671,26 @@ var LinearInterestRateModelContract = class extends BaseContract {
371440
371671
  name: "LinearInterestRateModel",
371441
371672
  abi: abi13
371442
371673
  });
371443
- const [U1, U2, Rbase, Rslope1, Rslope2, Rslope3, isBorrowingMoreU2Forbidden] = decodeAbiParameters([
371444
- { type: "uint16", name: "U1" },
371445
- { type: "uint16", name: "U2" },
371446
- { type: "uint16", name: "Rbase" },
371447
- { type: "uint16", name: "Rslope1" },
371448
- { type: "uint16", name: "Rslope2" },
371449
- { type: "uint16", name: "Rslope3" },
371450
- { type: "bool", name: "isBorrowingMoreU2Forbidden" }
371451
- ], params.baseParams.serializedParams);
371674
+ const [
371675
+ U1,
371676
+ U2,
371677
+ Rbase,
371678
+ Rslope1,
371679
+ Rslope2,
371680
+ Rslope3,
371681
+ isBorrowingMoreU2Forbidden
371682
+ ] = decodeAbiParameters(
371683
+ [
371684
+ { type: "uint16", name: "U1" },
371685
+ { type: "uint16", name: "U2" },
371686
+ { type: "uint16", name: "Rbase" },
371687
+ { type: "uint16", name: "Rslope1" },
371688
+ { type: "uint16", name: "Rslope2" },
371689
+ { type: "uint16", name: "Rslope3" },
371690
+ { type: "bool", name: "isBorrowingMoreU2Forbidden" }
371691
+ ],
371692
+ params.baseParams.serializedParams
371693
+ );
371452
371694
  this.U1 = U1;
371453
371695
  this.U2 = U2;
371454
371696
  this.Rbase = Rbase;
@@ -371483,23 +371725,34 @@ var PoolQuotaKeeperV300Contract = class extends BaseContract {
371483
371725
  abi: abi14
371484
371726
  });
371485
371727
  this.decimals = pool.decimals;
371486
- this.quotas = new AddressMap(pqk.quotas.map((q) => {
371487
- return [q.token, q];
371488
- }), "quotas");
371728
+ this.quotas = new AddressMap(
371729
+ pqk.quotas.map((q) => {
371730
+ return [q.token, q];
371731
+ }),
371732
+ "quotas"
371733
+ );
371489
371734
  }
371490
371735
  stateHuman(raw = true) {
371491
371736
  return {
371492
371737
  ...super.stateHuman(raw),
371493
- quotas: this.quotas.entries().reduce((acc, [address, params]) => ({
371494
- ...acc,
371495
- [this.labelAddress(address)]: {
371496
- rate: percentFmt(params.rate, raw),
371497
- quotaIncreaseFee: percentFmt(params.quotaIncreaseFee, raw),
371498
- totalQuoted: formatBNvalue(params.totalQuoted, this.decimals, 2, raw),
371499
- limit: formatBNvalue(params.limit, this.decimals, 2, raw),
371500
- isActive: params.isActive
371501
- }
371502
- }), {})
371738
+ quotas: this.quotas.entries().reduce(
371739
+ (acc, [address, params]) => ({
371740
+ ...acc,
371741
+ [this.labelAddress(address)]: {
371742
+ rate: percentFmt(params.rate, raw),
371743
+ quotaIncreaseFee: percentFmt(params.quotaIncreaseFee, raw),
371744
+ totalQuoted: formatBNvalue(
371745
+ params.totalQuoted,
371746
+ this.decimals,
371747
+ 2,
371748
+ raw
371749
+ ),
371750
+ limit: formatBNvalue(params.limit, this.decimals, 2, raw),
371751
+ isActive: params.isActive
371752
+ }
371753
+ }),
371754
+ {}
371755
+ )
371503
371756
  };
371504
371757
  }
371505
371758
  processLog(log2) {
@@ -371521,7 +371774,9 @@ var PoolQuotaKeeperV300Contract = class extends BaseContract {
371521
371774
  function createInterestRateModel(sdk, data) {
371522
371775
  const { addr, contractType } = data.baseParams;
371523
371776
  if (sdk.interestRateModels.has(addr)) {
371524
- return sdk.interestRateModels.mustGet(addr);
371777
+ return sdk.interestRateModels.mustGet(
371778
+ addr
371779
+ );
371525
371780
  } else {
371526
371781
  const modelType = bytes32ToString(contractType);
371527
371782
  switch (modelType) {
@@ -371549,7 +371804,9 @@ var PoolV300Contract = class extends BaseContract {
371549
371804
  abi: abi15
371550
371805
  });
371551
371806
  Object.assign(this, rest);
371552
- this.creditManagerDebtParams = new AddressMap(creditManagerDebtParams.map((p) => [p.creditManager, p]));
371807
+ this.creditManagerDebtParams = new AddressMap(
371808
+ creditManagerDebtParams.map((p) => [p.creditManager, p])
371809
+ );
371553
371810
  sdk.tokensMeta.upsert(data.baseParams.addr, {
371554
371811
  addr: data.baseParams.addr,
371555
371812
  decimals: data.decimals,
@@ -371564,18 +371821,35 @@ var PoolV300Contract = class extends BaseContract {
371564
371821
  symbol: this.symbol,
371565
371822
  name: this.name,
371566
371823
  decimals: this.decimals,
371567
- availableLiquidity: formatBNvalue(this.availableLiquidity, this.decimals, 2, raw),
371568
- expectedLiquidity: formatBNvalue(this.expectedLiquidity, this.decimals, 2, raw),
371824
+ availableLiquidity: formatBNvalue(
371825
+ this.availableLiquidity,
371826
+ this.decimals,
371827
+ 2,
371828
+ raw
371829
+ ),
371830
+ expectedLiquidity: formatBNvalue(
371831
+ this.expectedLiquidity,
371832
+ this.decimals,
371833
+ 2,
371834
+ raw
371835
+ ),
371569
371836
  totalBorrowed: formatBNvalue(this.totalBorrowed, this.decimals, 2, raw),
371570
371837
  totalDebtLimit: formatBNvalue(this.totalDebtLimit, this.decimals, 2, raw),
371571
- creditManagerDebtParams: Object.fromEntries(this.creditManagerDebtParams.values().map(({ creditManager, borrowed, limit, available }) => [
371572
- this.labelAddress(creditManager),
371573
- {
371574
- borrowed: formatBNvalue(borrowed, this.decimals, 2, raw),
371575
- limit: formatBNvalue(limit, this.decimals, 2, raw),
371576
- availableToBorrow: formatBNvalue(available, this.decimals, 2, raw)
371577
- }
371578
- ])),
371838
+ creditManagerDebtParams: Object.fromEntries(
371839
+ this.creditManagerDebtParams.values().map(({ creditManager, borrowed, limit, available }) => [
371840
+ this.labelAddress(creditManager),
371841
+ {
371842
+ borrowed: formatBNvalue(borrowed, this.decimals, 2, raw),
371843
+ limit: formatBNvalue(limit, this.decimals, 2, raw),
371844
+ availableToBorrow: formatBNvalue(
371845
+ available,
371846
+ this.decimals,
371847
+ 2,
371848
+ raw
371849
+ )
371850
+ }
371851
+ ])
371852
+ ),
371579
371853
  totalSupply: formatBNvalue(this.totalSupply, this.decimals, 2, raw),
371580
371854
  supplyRate: `${formatBNvalue(this.supplyRate, 25, 2, raw)}%`,
371581
371855
  baseInterestIndex: `${formatBNvalue(this.totalSupply, 25, 2, raw)}%`,
@@ -371636,7 +371910,9 @@ var PoolV310Contract = class extends BaseContract {
371636
371910
  abi: abi16
371637
371911
  });
371638
371912
  Object.assign(this, rest);
371639
- this.creditManagerDebtParams = new AddressMap(creditManagerDebtParams.map((p) => [p.creditManager, p]));
371913
+ this.creditManagerDebtParams = new AddressMap(
371914
+ creditManagerDebtParams.map((p) => [p.creditManager, p])
371915
+ );
371640
371916
  sdk.tokensMeta.upsert(data.baseParams.addr, {
371641
371917
  addr: data.baseParams.addr,
371642
371918
  decimals: data.decimals,
@@ -371651,18 +371927,35 @@ var PoolV310Contract = class extends BaseContract {
371651
371927
  symbol: this.symbol,
371652
371928
  name: this.name,
371653
371929
  decimals: this.decimals,
371654
- availableLiquidity: formatBNvalue(this.availableLiquidity, this.decimals, 2, raw),
371655
- expectedLiquidity: formatBNvalue(this.expectedLiquidity, this.decimals, 2, raw),
371930
+ availableLiquidity: formatBNvalue(
371931
+ this.availableLiquidity,
371932
+ this.decimals,
371933
+ 2,
371934
+ raw
371935
+ ),
371936
+ expectedLiquidity: formatBNvalue(
371937
+ this.expectedLiquidity,
371938
+ this.decimals,
371939
+ 2,
371940
+ raw
371941
+ ),
371656
371942
  totalBorrowed: formatBNvalue(this.totalBorrowed, this.decimals, 2, raw),
371657
371943
  totalDebtLimit: formatBNvalue(this.totalDebtLimit, this.decimals, 2, raw),
371658
- creditManagerDebtParams: Object.fromEntries(this.creditManagerDebtParams.values().map(({ creditManager, borrowed, limit, available }) => [
371659
- this.labelAddress(creditManager),
371660
- {
371661
- borrowed: formatBNvalue(borrowed, this.decimals, 2, raw),
371662
- limit: formatBNvalue(limit, this.decimals, 2, raw),
371663
- availableToBorrow: formatBNvalue(available, this.decimals, 2, raw)
371664
- }
371665
- ])),
371944
+ creditManagerDebtParams: Object.fromEntries(
371945
+ this.creditManagerDebtParams.values().map(({ creditManager, borrowed, limit, available }) => [
371946
+ this.labelAddress(creditManager),
371947
+ {
371948
+ borrowed: formatBNvalue(borrowed, this.decimals, 2, raw),
371949
+ limit: formatBNvalue(limit, this.decimals, 2, raw),
371950
+ availableToBorrow: formatBNvalue(
371951
+ available,
371952
+ this.decimals,
371953
+ 2,
371954
+ raw
371955
+ )
371956
+ }
371957
+ ])
371958
+ ),
371666
371959
  totalSupply: formatBNvalue(this.totalSupply, this.decimals, 2, raw),
371667
371960
  supplyRate: `${formatBNvalue(this.supplyRate, 25, 2, raw)}%`,
371668
371961
  baseInterestIndex: `${formatBNvalue(this.totalSupply, 25, 2, raw)}%`,
@@ -371735,23 +372028,34 @@ var PoolQuotaKeeperV310Contract = class extends BaseContract {
371735
372028
  abi: abi17
371736
372029
  });
371737
372030
  this.decimals = pool.decimals;
371738
- this.quotas = new AddressMap(pqk.quotas.map((q) => {
371739
- return [q.token, q];
371740
- }), "quotas");
372031
+ this.quotas = new AddressMap(
372032
+ pqk.quotas.map((q) => {
372033
+ return [q.token, q];
372034
+ }),
372035
+ "quotas"
372036
+ );
371741
372037
  }
371742
372038
  stateHuman(raw = true) {
371743
372039
  return {
371744
372040
  ...super.stateHuman(raw),
371745
- quotas: this.quotas.entries().reduce((acc, [address, params]) => ({
371746
- ...acc,
371747
- [this.labelAddress(address)]: {
371748
- rate: percentFmt(params.rate, raw),
371749
- quotaIncreaseFee: percentFmt(params.quotaIncreaseFee, raw),
371750
- totalQuoted: formatBNvalue(params.totalQuoted, this.decimals, 2, raw),
371751
- limit: formatBNvalue(params.limit, this.decimals, 2, raw),
371752
- isActive: params.isActive
371753
- }
371754
- }), {})
372041
+ quotas: this.quotas.entries().reduce(
372042
+ (acc, [address, params]) => ({
372043
+ ...acc,
372044
+ [this.labelAddress(address)]: {
372045
+ rate: percentFmt(params.rate, raw),
372046
+ quotaIncreaseFee: percentFmt(params.quotaIncreaseFee, raw),
372047
+ totalQuoted: formatBNvalue(
372048
+ params.totalQuoted,
372049
+ this.decimals,
372050
+ 2,
372051
+ raw
372052
+ ),
372053
+ limit: formatBNvalue(params.limit, this.decimals, 2, raw),
372054
+ isActive: params.isActive
372055
+ }
372056
+ }),
372057
+ {}
372058
+ )
371755
372059
  };
371756
372060
  }
371757
372061
  processLog(log2) {
@@ -371792,11 +372096,14 @@ var TumblerContract = class extends BaseContract {
371792
372096
  name: `Tumbler(${pool.name})`,
371793
372097
  abi: abi18
371794
372098
  });
371795
- const [epochLength, tokens_, rates_] = decodeAbiParameters([
371796
- { name: "epochLength", type: "uint256" },
371797
- { name: "tokens", type: "address[]" },
371798
- { name: "rates", type: "uint16[]" }
371799
- ], tumbler.baseParams.serializedParams);
372099
+ const [epochLength, tokens_, rates_] = decodeAbiParameters(
372100
+ [
372101
+ { name: "epochLength", type: "uint256" },
372102
+ { name: "tokens", type: "address[]" },
372103
+ { name: "rates", type: "uint16[]" }
372104
+ ],
372105
+ tumbler.baseParams.serializedParams
372106
+ );
371800
372107
  this.epochLength = epochLength;
371801
372108
  this.rates = new AddressMap(tokens_.map((t, i) => [t, rates_[i]]));
371802
372109
  }
@@ -371812,17 +372119,22 @@ var TumblerContract = class extends BaseContract {
371812
372119
  return {
371813
372120
  ...super.stateHuman(raw),
371814
372121
  epochLength: formatDuration2(Number(this.epochLength), raw),
371815
- rates: this.rates.entries().reduce((acc, [token, rate]) => ({
371816
- ...acc,
371817
- [this.labelAddress(token)]: percentFmt(rate, raw)
371818
- }), {})
372122
+ rates: this.rates.entries().reduce(
372123
+ (acc, [token, rate]) => ({
372124
+ ...acc,
372125
+ [this.labelAddress(token)]: percentFmt(rate, raw)
372126
+ }),
372127
+ {}
372128
+ )
371819
372129
  };
371820
372130
  }
371821
372131
  };
371822
372132
 
371823
372133
  // ../../node_modules/@gearbox-protocol/sdk/dist/esm/sdk/market/pool/createRateKeeper.js
371824
372134
  function createRateKeeper(sdk, pool, data) {
371825
- const rateKeeperType = bytes32ToString(data.baseParams.contractType);
372135
+ const rateKeeperType = bytes32ToString(
372136
+ data.baseParams.contractType
372137
+ );
371826
372138
  switch (rateKeeperType) {
371827
372139
  case "RATE_KEEPER::GAUGE":
371828
372140
  return new GaugeContract(sdk, pool, data);
@@ -371844,19 +372156,26 @@ var PoolSuite = class extends SDKConstruct {
371844
372156
  this.pool = createPool(sdk, data.pool);
371845
372157
  this.pqk = createPoolQuotaKeeper(sdk, data.pool, data.poolQuotaKeeper);
371846
372158
  this.rateKeeper = createRateKeeper(sdk, data.pool, data.rateKeeper);
371847
- this.interestRateModel = createInterestRateModel(sdk, data.interestRateModel);
372159
+ this.interestRateModel = createInterestRateModel(
372160
+ sdk,
372161
+ data.interestRateModel
372162
+ );
371848
372163
  }
371849
372164
  get gauge() {
371850
372165
  if (this.rateKeeper instanceof GaugeContract) {
371851
372166
  return this.rateKeeper;
371852
372167
  }
371853
- throw new Error("Rate keeper is not a gauge, but a " + this.rateKeeper.contractType);
372168
+ throw new Error(
372169
+ "Rate keeper is not a gauge, but a " + this.rateKeeper.contractType
372170
+ );
371854
372171
  }
371855
372172
  get linearModel() {
371856
372173
  if (this.interestRateModel instanceof LinearInterestRateModelContract) {
371857
372174
  return this.interestRateModel;
371858
372175
  }
371859
- throw new Error(`Interest rate model is not a linear model, but a ${this.interestRateModel.contractType}`);
372176
+ throw new Error(
372177
+ `Interest rate model is not a linear model, but a ${this.interestRateModel.contractType}`
372178
+ );
371860
372179
  }
371861
372180
  get underlying() {
371862
372181
  return this.pool.underlying;
@@ -371888,9 +372207,14 @@ var MarketSuite = class extends SDKConstruct {
371888
372207
  constructor(sdk, marketData) {
371889
372208
  super(sdk);
371890
372209
  this.state = marketData;
371891
- let configurator = sdk.contracts.get(marketData.configurator);
372210
+ let configurator = sdk.contracts.get(
372211
+ marketData.configurator
372212
+ );
371892
372213
  if (!configurator) {
371893
- configurator = new MarketConfiguratorContract(sdk, marketData.configurator);
372214
+ configurator = new MarketConfiguratorContract(
372215
+ sdk,
372216
+ marketData.configurator
372217
+ );
371894
372218
  }
371895
372219
  this.configurator = configurator;
371896
372220
  this.acl = marketData.acl;
@@ -371902,7 +372226,11 @@ var MarketSuite = class extends SDKConstruct {
371902
372226
  for (let i = 0; i < marketData.creditManagers.length; i++) {
371903
372227
  this.creditManagers.push(new CreditSuite(sdk, marketData, i));
371904
372228
  }
371905
- this.priceOracle = createPriceOracle(sdk, marketData.priceOracleData, marketData.pool.underlying);
372229
+ this.priceOracle = createPriceOracle(
372230
+ sdk,
372231
+ marketData.priceOracleData,
372232
+ marketData.pool.underlying
372233
+ );
371906
372234
  }
371907
372235
  get dirty() {
371908
372236
  return this.configurator.dirty || this.pool.dirty || this.priceOracle.dirty || this.creditManagers.some((cm) => cm.dirty);
@@ -371914,8 +372242,12 @@ var MarketSuite = class extends SDKConstruct {
371914
372242
  creditManagers: this.creditManagers.map((cm) => cm.stateHuman(raw)),
371915
372243
  priceOracle: this.priceOracle.stateHuman(raw),
371916
372244
  pausableAdmins: this.state.pausableAdmins.map((a) => this.labelAddress(a)),
371917
- unpausableAdmins: this.state.unpausableAdmins.map((a) => this.labelAddress(a)),
371918
- emergencyLiquidators: this.state.emergencyLiquidators.map((a) => this.labelAddress(a))
372245
+ unpausableAdmins: this.state.unpausableAdmins.map(
372246
+ (a) => this.labelAddress(a)
372247
+ ),
372248
+ emergencyLiquidators: this.state.emergencyLiquidators.map(
372249
+ (a) => this.labelAddress(a)
372250
+ )
371919
372251
  };
371920
372252
  }
371921
372253
  };
@@ -371933,18 +372265,26 @@ var MarketRegister = class extends SDKConstruct {
371933
372265
  super(sdk);
371934
372266
  this.#logger = childLogger("MarketRegister", sdk.logger);
371935
372267
  for (const data of markets ?? []) {
371936
- this.#markets.upsert(data.pool.baseParams.addr, new MarketSuite(this.sdk, data));
372268
+ this.#markets.upsert(
372269
+ data.pool.baseParams.addr,
372270
+ new MarketSuite(this.sdk, data)
372271
+ );
371937
372272
  }
371938
372273
  }
371939
372274
  async loadMarkets(marketConfigurators, ignoreUpdateablePrices) {
371940
372275
  if (!marketConfigurators.length) {
371941
- this.#logger?.warn("no market configurators provided, skipping loadMarkets");
372276
+ this.#logger?.warn(
372277
+ "no market configurators provided, skipping loadMarkets"
372278
+ );
371942
372279
  return;
371943
372280
  }
371944
372281
  await this.#loadMarkets(marketConfigurators, [], ignoreUpdateablePrices);
371945
372282
  }
371946
372283
  async loadZappers() {
371947
- const pcAddr = this.sdk.addressProvider.getAddress(AP_PERIPHERY_COMPRESSOR, 310);
372284
+ const pcAddr = this.sdk.addressProvider.getAddress(
372285
+ AP_PERIPHERY_COMPRESSOR,
372286
+ 310
372287
+ );
371948
372288
  this.#logger?.debug(`loading zappers with periphery compressor ${pcAddr}`);
371949
372289
  const resp = await this.provider.publicClient.multicall({
371950
372290
  contracts: this.markets.map((m) => ({
@@ -371961,9 +372301,14 @@ var MarketRegister = class extends SDKConstruct {
371961
372301
  const pool = this.markets[i].pool.pool.address;
371962
372302
  if (status === "success") {
371963
372303
  const list = result;
371964
- this.#zappers.upsert(pool, list.map((z2) => ({ ...z2, pool })));
372304
+ this.#zappers.upsert(
372305
+ pool,
372306
+ list.map((z2) => ({ ...z2, pool }))
372307
+ );
371965
372308
  } else {
371966
- this.#logger?.error(`failed to load zapper for market configurator ${this.labelAddress(marketConfigurator)} and pool ${this.labelAddress(pool)}: ${error}`);
372309
+ this.#logger?.error(
372310
+ `failed to load zapper for market configurator ${this.labelAddress(marketConfigurator)} and pool ${this.labelAddress(pool)}: ${error}`
372311
+ );
371967
372312
  }
371968
372313
  }
371969
372314
  const zappersTokens = this.#zappers.values().flatMap((l) => l.flatMap((z2) => [z2.tokenIn, z2.tokenOut]));
@@ -371988,14 +372333,23 @@ var MarketRegister = class extends SDKConstruct {
371988
372333
  pools,
371989
372334
  underlying: ADDRESS_0X0
371990
372335
  };
371991
- const marketCompressorAddress = this.sdk.addressProvider.getAddress(AP_MARKET_COMPRESSOR, 310);
372336
+ const marketCompressorAddress = this.sdk.addressProvider.getAddress(
372337
+ AP_MARKET_COMPRESSOR,
372338
+ 310
372339
+ );
371992
372340
  let txs = [];
371993
372341
  if (!ignoreUpdateablePrices) {
371994
- await this.sdk.priceFeeds.preloadUpdatablePriceFeeds(configurators, pools);
372342
+ await this.sdk.priceFeeds.preloadUpdatablePriceFeeds(
372343
+ configurators,
372344
+ pools
372345
+ );
371995
372346
  const updates = await this.sdk.priceFeeds.generatePriceFeedsUpdateTxs();
371996
372347
  txs = updates.txs;
371997
372348
  }
371998
- this.#logger?.debug({ configurators, pools }, `calling getMarkets with ${txs.length} price updates`);
372349
+ this.#logger?.debug(
372350
+ { configurators, pools },
372351
+ `calling getMarkets with ${txs.length} price updates`
372352
+ );
371999
372353
  let markets = [];
372000
372354
  if (txs.length) {
372001
372355
  const resp = await simulateMulticall(this.provider.publicClient, {
@@ -372024,7 +372378,10 @@ var MarketRegister = class extends SDKConstruct {
372024
372378
  });
372025
372379
  }
372026
372380
  for (const data of markets) {
372027
- this.#markets.upsert(data.pool.baseParams.addr, new MarketSuite(this.sdk, data));
372381
+ this.#markets.upsert(
372382
+ data.pool.baseParams.addr,
372383
+ new MarketSuite(this.sdk, data)
372384
+ );
372028
372385
  }
372029
372386
  this.#logger?.info(`loaded ${markets.length} markets`);
372030
372387
  }
@@ -372061,13 +372418,15 @@ var MarketRegister = class extends SDKConstruct {
372061
372418
  stateHuman(raw = true) {
372062
372419
  return {
372063
372420
  markets: this.markets.map((market) => market.stateHuman(raw)),
372064
- zappers: this.zappers.values().flatMap((l) => l.flatMap((z2) => ({
372065
- address: z2.baseParams.addr,
372066
- contractType: z2.baseParams.contractType,
372067
- version: Number(z2.baseParams.version),
372068
- tokenIn: this.labelAddress(z2.tokenIn.addr),
372069
- tokenOut: this.labelAddress(z2.tokenOut.addr)
372070
- })))
372421
+ zappers: this.zappers.values().flatMap(
372422
+ (l) => l.flatMap((z2) => ({
372423
+ address: z2.baseParams.addr,
372424
+ contractType: z2.baseParams.contractType,
372425
+ version: Number(z2.baseParams.version),
372426
+ tokenIn: this.labelAddress(z2.tokenIn.addr),
372427
+ tokenOut: this.labelAddress(z2.tokenOut.addr)
372428
+ }))
372429
+ )
372071
372430
  };
372072
372431
  }
372073
372432
  get pools() {
@@ -372096,7 +372455,11 @@ var MarketRegister = class extends SDKConstruct {
372096
372455
  }
372097
372456
  findByCreditManager(creditManager) {
372098
372457
  const addr = creditManager.toLowerCase();
372099
- const market = this.markets.find((m) => m.creditManagers.some((cm) => cm.creditManager.address.toLowerCase() === addr));
372458
+ const market = this.markets.find(
372459
+ (m) => m.creditManagers.some(
372460
+ (cm) => cm.creditManager.address.toLowerCase() === addr
372461
+ )
372462
+ );
372100
372463
  if (!market) {
372101
372464
  throw new Error(`cannot find market for credit manager ${creditManager}`);
372102
372465
  }
@@ -372132,11 +372495,14 @@ var MarketRegister = class extends SDKConstruct {
372132
372495
  async tvl() {
372133
372496
  const creditManagers = this.creditManagers;
372134
372497
  const tvls = await Promise.all(creditManagers.map((cm) => cm.tvl()));
372135
- return tvls.reduce((acc, curr) => {
372136
- acc.tvl += curr.tvl;
372137
- acc.tvlUSD += curr.tvlUSD;
372138
- return acc;
372139
- }, { tvl: 0n, tvlUSD: 0n });
372498
+ return tvls.reduce(
372499
+ (acc, curr) => {
372500
+ acc.tvl += curr.tvl;
372501
+ acc.tvlUSD += curr.tvlUSD;
372502
+ return acc;
372503
+ },
372504
+ { tvl: 0n, tvlUSD: 0n }
372505
+ );
372140
372506
  }
372141
372507
  };
372142
372508
 
@@ -372540,7 +372906,10 @@ var PathOptionFactory = class _PathOptionFactory {
372540
372906
  };
372541
372907
  });
372542
372908
  const initPO = [...curveInitPO, ...balancerInitPO];
372543
- const totalLoops = initPO.reduce((acc, item) => acc * item.totalOptions, 1);
372909
+ const totalLoops = initPO.reduce(
372910
+ (acc, item) => acc * item.totalOptions,
372911
+ 1
372912
+ );
372544
372913
  const result = [];
372545
372914
  let currentPo = [...initPO];
372546
372915
  for (let i = 0; i < totalLoops; i++) {
@@ -372557,7 +372926,9 @@ var PathOptionFactory = class _PathOptionFactory {
372557
372926
  const nonZeroBalances = balances.filter((b) => b.balance > 1n);
372558
372927
  const curvePools = nonZeroBalances.map((b) => getTokenSymbol(b.token)).filter((symbol) => isCurveLPToken(symbol));
372559
372928
  const yearnCurveTokens = Object.entries(yearnTokens).filter(([, data]) => isCurveLPToken(data.underlying)).map(([token]) => token);
372560
- const curvePoolsFromYearn = nonZeroBalances.map((b) => getTokenSymbol(b.token)).filter((symbol) => yearnCurveTokens.includes(symbol)).map((symbol) => yearnTokens[symbol].underlying);
372929
+ const curvePoolsFromYearn = nonZeroBalances.map((b) => getTokenSymbol(b.token)).filter((symbol) => yearnCurveTokens.includes(symbol)).map(
372930
+ (symbol) => yearnTokens[symbol].underlying
372931
+ );
372561
372932
  const convexCurveTokens = Object.entries(convexTokens).filter(([, data]) => isCurveLPToken(data.underlying)).map(([token]) => token);
372562
372933
  const curvePoolsFromConvex = nonZeroBalances.map((b) => getTokenSymbol(b.token)).filter((symbol) => convexCurveTokens.includes(symbol)).map((symbol) => convexTokens[symbol].underlying);
372563
372934
  const curveSet = /* @__PURE__ */ new Set([
@@ -372568,10 +372939,14 @@ var PathOptionFactory = class _PathOptionFactory {
372568
372939
  return Array.from(curveSet.values());
372569
372940
  }
372570
372941
  static getBalancerPools(balances) {
372571
- const nonZeroBalances = Object.entries(balances).filter(([, balance]) => balance.balance > 1);
372942
+ const nonZeroBalances = Object.entries(balances).filter(
372943
+ ([, balance]) => balance.balance > 1
372944
+ );
372572
372945
  const balancerPools = nonZeroBalances.map(([token]) => getTokenSymbol(token)).filter((symbol) => isBalancerLPToken(symbol));
372573
372946
  const balancerAuraTokens = Object.entries(auraTokens).filter(([, data]) => isBalancerLPToken(data.underlying)).map(([token]) => token);
372574
- const balancerTokensFromAura = nonZeroBalances.map(([token]) => getTokenSymbol(token)).filter((symbol) => balancerAuraTokens.includes(symbol)).map((symbol) => auraTokens[symbol].underlying);
372947
+ const balancerTokensFromAura = nonZeroBalances.map(([token]) => getTokenSymbol(token)).filter((symbol) => balancerAuraTokens.includes(symbol)).map(
372948
+ (symbol) => auraTokens[symbol].underlying
372949
+ );
372575
372950
  const balancerSet = /* @__PURE__ */ new Set([...balancerPools, ...balancerTokensFromAura]);
372576
372951
  return Array.from(balancerSet.values());
372577
372952
  }
@@ -372581,8 +372956,7 @@ var PathOptionFactory = class _PathOptionFactory {
372581
372956
  const po = { ...newPath[i] };
372582
372957
  po.option++;
372583
372958
  newPath[i] = po;
372584
- if (po.option < po.totalOptions)
372585
- return newPath;
372959
+ if (po.option < po.totalOptions) return newPath;
372586
372960
  po.option = 0;
372587
372961
  }
372588
372962
  throw new Error("Path options overflow");
@@ -372631,7 +373005,16 @@ var RouterV3Contract = class extends BaseContract {
372631
373005
  * @param slippage
372632
373006
  * @returns
372633
373007
  */
372634
- async findAllSwaps({ creditAccount: ca, creditManager: cm, swapOperation, tokenIn, tokenOut, amount, leftoverAmount, slippage }) {
373008
+ async findAllSwaps({
373009
+ creditAccount: ca,
373010
+ creditManager: cm,
373011
+ swapOperation,
373012
+ tokenIn,
373013
+ tokenOut,
373014
+ amount,
373015
+ leftoverAmount,
373016
+ slippage
373017
+ }) {
372635
373018
  const connectors2 = this.getAvailableConnectors(cm.collateralTokens);
372636
373019
  const swapTask = {
372637
373020
  swapOperation: SWAP_OPERATIONS[swapOperation],
@@ -372642,9 +373025,12 @@ var RouterV3Contract = class extends BaseContract {
372642
373025
  amount,
372643
373026
  leftoverAmount
372644
373027
  };
372645
- const { result } = await this.contract.simulate.findAllSwaps([swapTask, BigInt(slippage)], {
372646
- gas: GAS_PER_BLOCK
372647
- });
373028
+ const { result } = await this.contract.simulate.findAllSwaps(
373029
+ [swapTask, BigInt(slippage)],
373030
+ {
373031
+ gas: GAS_PER_BLOCK
373032
+ }
373033
+ );
372648
373034
  const unique = {};
372649
373035
  result.forEach((r) => {
372650
373036
  const key = `${r.minAmount.toString()}${r.calls.map((c) => `${c.target.toLowerCase()}${c.callData}`).join("-")}`;
@@ -372667,19 +373053,31 @@ var RouterV3Contract = class extends BaseContract {
372667
373053
  * @returns
372668
373054
  */
372669
373055
  async findOneTokenPath(props) {
372670
- const { creditAccount, creditManager, tokenIn, tokenOut, amount, slippage } = props;
372671
- const connectors2 = this.getAvailableConnectors(creditManager.collateralTokens);
372672
- const isPTOverrideRedeem = PT_IN[tokenIn.toLowerCase()] && OUT[tokenOut.toLowerCase()];
372673
- const { result } = await (isPTOverrideRedeem ? this.overridePTRedeem(props) : this.contract.simulate.findOneTokenPath([
373056
+ const {
373057
+ creditAccount,
373058
+ creditManager,
372674
373059
  tokenIn,
372675
- amount,
372676
373060
  tokenOut,
372677
- creditAccount.creditAccount,
372678
- connectors2,
372679
- BigInt(slippage)
372680
- ], {
372681
- gas: GAS_PER_BLOCK
372682
- }));
373061
+ amount,
373062
+ slippage
373063
+ } = props;
373064
+ const connectors2 = this.getAvailableConnectors(
373065
+ creditManager.collateralTokens
373066
+ );
373067
+ const isPTOverrideRedeem = PT_IN[tokenIn.toLowerCase()] && OUT[tokenOut.toLowerCase()];
373068
+ const { result } = await (isPTOverrideRedeem ? this.overridePTRedeem(props) : this.contract.simulate.findOneTokenPath(
373069
+ [
373070
+ tokenIn,
373071
+ amount,
373072
+ tokenOut,
373073
+ creditAccount.creditAccount,
373074
+ connectors2,
373075
+ BigInt(slippage)
373076
+ ],
373077
+ {
373078
+ gas: GAS_PER_BLOCK
373079
+ }
373080
+ ));
372683
373081
  return {
372684
373082
  amount: result.amount,
372685
373083
  minAmount: result.minAmount,
@@ -372687,7 +373085,14 @@ var RouterV3Contract = class extends BaseContract {
372687
373085
  };
372688
373086
  }
372689
373087
  // TODO: remove me when new router will be added
372690
- async overridePTRedeem({ creditAccount, creditManager, tokenIn, tokenOut, amount, slippage }) {
373088
+ async overridePTRedeem({
373089
+ creditAccount,
373090
+ creditManager,
373091
+ tokenIn,
373092
+ tokenOut,
373093
+ amount,
373094
+ slippage
373095
+ }) {
372691
373096
  const pendleSwapperAddress = await this.contract.read.componentAddressById([
372692
373097
  37
372693
373098
  ]);
@@ -372758,7 +373163,13 @@ var RouterV3Contract = class extends BaseContract {
372758
373163
  * @param slippage Slippage in PERCENTAGE_FORMAT (100% = 10_000) per operation
372759
373164
  * @returns PathFinderOpenStrategyResult which
372760
373165
  */
372761
- async findOpenStrategyPath({ creditManager: cm, expectedBalances, leftoverBalances, target, slippage }) {
373166
+ async findOpenStrategyPath({
373167
+ creditManager: cm,
373168
+ expectedBalances,
373169
+ leftoverBalances,
373170
+ target,
373171
+ slippage
373172
+ }) {
372762
373173
  const [expectedMap, leftoverMap] = [
372763
373174
  balancesMap(expectedBalances),
372764
373175
  balancesMap(leftoverBalances)
@@ -372772,10 +373183,17 @@ var RouterV3Contract = class extends BaseContract {
372772
373183
  balance: leftoverMap.get(token) ?? 0n
372773
373184
  }));
372774
373185
  const connectors2 = this.getAvailableConnectors(cm.collateralTokens);
372775
- const { result: [outBalances, result] } = await this.contract.simulate.findOpenStrategyPath([cm.address, input, leftover, target, connectors2, BigInt(slippage)], {
372776
- gas: GAS_PER_BLOCK
372777
- });
372778
- const balancesAfter = Object.fromEntries(outBalances.map((b) => [b.token.toLowerCase(), b.balance]));
373186
+ const {
373187
+ result: [outBalances, result]
373188
+ } = await this.contract.simulate.findOpenStrategyPath(
373189
+ [cm.address, input, leftover, target, connectors2, BigInt(slippage)],
373190
+ {
373191
+ gas: GAS_PER_BLOCK
373192
+ }
373193
+ );
373194
+ const balancesAfter = Object.fromEntries(
373195
+ outBalances.map((b) => [b.token.toLowerCase(), b.balance])
373196
+ );
372779
373197
  return {
372780
373198
  balances: {
372781
373199
  ...balancesAfter,
@@ -372800,11 +373218,20 @@ var RouterV3Contract = class extends BaseContract {
372800
373218
  * - underlyingBalance - total balance of underlying token
372801
373219
  * - calls - list of calls which should be done to swap & unwrap everything to underlying token
372802
373220
  */
372803
- async findBestClosePath({ creditAccount: ca, creditManager: cm, slippage, balances }) {
372804
- const { pathOptions, expected, leftover, connectors: connectors2 } = this.getFindClosePathInput(ca, cm, balances ? {
372805
- expectedBalances: assetsMap(balances.expectedBalances),
372806
- leftoverBalances: assetsMap(balances.leftoverBalances)
372807
- } : void 0);
373221
+ async findBestClosePath({
373222
+ creditAccount: ca,
373223
+ creditManager: cm,
373224
+ slippage,
373225
+ balances
373226
+ }) {
373227
+ const { pathOptions, expected, leftover, connectors: connectors2 } = this.getFindClosePathInput(
373228
+ ca,
373229
+ cm,
373230
+ balances ? {
373231
+ expectedBalances: assetsMap(balances.expectedBalances),
373232
+ leftoverBalances: assetsMap(balances.leftoverBalances)
373233
+ } : void 0
373234
+ );
372808
373235
  await this.#hooks.triggerHooks("foundPathOptions", {
372809
373236
  creditAccount: ca.creditAccount,
372810
373237
  pathOptions,
@@ -372814,18 +373241,21 @@ var RouterV3Contract = class extends BaseContract {
372814
373241
  });
372815
373242
  let results = [];
372816
373243
  for (const po of pathOptions) {
372817
- const { result: result2 } = await this.contract.simulate.findBestClosePath([
372818
- ca.creditAccount,
372819
- expected,
372820
- leftover,
372821
- connectors2,
372822
- BigInt(slippage),
372823
- po,
372824
- BigInt(LOOPS_PER_TX),
372825
- false
372826
- ], {
372827
- gas: GAS_PER_BLOCK
372828
- });
373244
+ const { result: result2 } = await this.contract.simulate.findBestClosePath(
373245
+ [
373246
+ ca.creditAccount,
373247
+ expected,
373248
+ leftover,
373249
+ connectors2,
373250
+ BigInt(slippage),
373251
+ po,
373252
+ BigInt(LOOPS_PER_TX),
373253
+ false
373254
+ ],
373255
+ {
373256
+ gas: GAS_PER_BLOCK
373257
+ }
373258
+ );
372829
373259
  results.push({
372830
373260
  ...result2,
372831
373261
  calls: [...result2.calls]
@@ -372857,7 +373287,11 @@ var RouterV3Contract = class extends BaseContract {
372857
373287
  getFindClosePathInput(ca, cm, balances) {
372858
373288
  const b = balances || this.getDefaultExpectedAndLeftover(ca);
372859
373289
  const { leftoverBalances, expectedBalances } = b;
372860
- const pathOptions = PathOptionFactory.generatePathOptions(ca.tokens, this.provider.networkType, LOOPS_PER_TX);
373290
+ const pathOptions = PathOptionFactory.generatePathOptions(
373291
+ ca.tokens,
373292
+ this.provider.networkType,
373293
+ LOOPS_PER_TX
373294
+ );
372861
373295
  const expected = cm.collateralTokens.map((token) => {
372862
373296
  const actual = expectedBalances.get(token)?.balance || 0n;
372863
373297
  return {
@@ -372888,7 +373322,9 @@ var RouterV3Contract = class extends BaseContract {
372888
373322
  return { expectedBalances, leftoverBalances };
372889
373323
  }
372890
373324
  getAvailableConnectors(collateralTokens) {
372891
- return collateralTokens.filter((t) => this.#connectors.includes(t.toLowerCase()));
373325
+ return collateralTokens.filter(
373326
+ (t) => this.#connectors.includes(t.toLowerCase())
373327
+ );
372892
373328
  }
372893
373329
  };
372894
373330
  function compareRouterResults(a, b) {
@@ -373155,7 +373591,9 @@ var CreditAccountsService = class extends SDKConstruct {
373155
373591
  #logger;
373156
373592
  constructor(sdk, options) {
373157
373593
  super(sdk);
373158
- this.#compressor = sdk.addressProvider.getLatestVersion(AP_CREDIT_ACCOUNT_COMPRESSOR);
373594
+ this.#compressor = sdk.addressProvider.getLatestVersion(
373595
+ AP_CREDIT_ACCOUNT_COMPRESSOR
373596
+ );
373159
373597
  this.#batchSize = options?.batchSize;
373160
373598
  this.#logger = childLogger("CreditAccountsService", sdk.logger);
373161
373599
  }
@@ -373241,13 +373679,17 @@ var CreditAccountsService = class extends SDKConstruct {
373241
373679
  for (const reverting of [false, true]) {
373242
373680
  let offset = 0n;
373243
373681
  do {
373244
- const [accounts, newOffset] = await this.#getCreditAccounts(this.#batchSize ? [
373245
- arg0,
373246
- { ...caFilter, reverting },
373247
- offset,
373248
- BigInt(this.#batchSize)
373249
- // limit
373250
- ] : [arg0, { ...caFilter, reverting }, offset], priceUpdateTxs, options);
373682
+ const [accounts, newOffset] = await this.#getCreditAccounts(
373683
+ this.#batchSize ? [
373684
+ arg0,
373685
+ { ...caFilter, reverting },
373686
+ offset,
373687
+ BigInt(this.#batchSize)
373688
+ // limit
373689
+ ] : [arg0, { ...caFilter, reverting }, offset],
373690
+ priceUpdateTxs,
373691
+ options
373692
+ );
373251
373693
  allCAs.push(...accounts);
373252
373694
  offset = newOffset;
373253
373695
  } while (offset !== 0n);
@@ -373295,7 +373737,9 @@ var CreditAccountsService = class extends SDKConstruct {
373295
373737
  async getConnectedBots(accountsToCheck) {
373296
373738
  const resp = await this.provider.publicClient.multicall({
373297
373739
  contracts: accountsToCheck.map((o) => {
373298
- const pool = this.sdk.marketRegister.findByCreditManager(o.creditManager);
373740
+ const pool = this.sdk.marketRegister.findByCreditManager(
373741
+ o.creditManager
373742
+ );
373299
373743
  return {
373300
373744
  abi: iPeripheryCompressorAbi,
373301
373745
  address: this.peripheryCompressor,
@@ -373321,9 +373765,17 @@ var CreditAccountsService = class extends SDKConstruct {
373321
373765
  creditManager: cm.creditManager,
373322
373766
  slippage
373323
373767
  });
373324
- const priceUpdates = await this.getPriceUpdatesForFacade(account.creditManager, account, void 0);
373768
+ const priceUpdates = await this.getPriceUpdatesForFacade(
373769
+ account.creditManager,
373770
+ account,
373771
+ void 0
373772
+ );
373325
373773
  const calls = [...priceUpdates, ...routerCloseResult.calls];
373326
- const tx = cm.creditFacade.liquidateCreditAccount(account.creditAccount, to, calls);
373774
+ const tx = cm.creditFacade.liquidateCreditAccount(
373775
+ account.creditAccount,
373776
+ to,
373777
+ calls
373778
+ );
373327
373779
  return { tx, calls, routerCloseResult, creditFacade: cm.creditFacade };
373328
373780
  }
373329
373781
  /**
@@ -373336,7 +373788,14 @@ var CreditAccountsService = class extends SDKConstruct {
373336
373788
  * @param closePath
373337
373789
  * @returns
373338
373790
  */
373339
- async closeCreditAccount({ operation, assetsToWithdraw, creditAccount: ca, to, slippage = 50n, closePath }) {
373791
+ async closeCreditAccount({
373792
+ operation,
373793
+ assetsToWithdraw,
373794
+ creditAccount: ca,
373795
+ to,
373796
+ slippage = 50n,
373797
+ closePath
373798
+ }) {
373340
373799
  const cm = this.sdk.marketRegister.findCreditManager(ca.creditManager);
373341
373800
  const routerCloseResult = closePath || await this.sdk.router.findBestClosePath({
373342
373801
  creditAccount: ca,
@@ -373348,7 +373807,9 @@ var CreditAccountsService = class extends SDKConstruct {
373348
373807
  ...this.#prepareDisableQuotas(ca),
373349
373808
  ...this.#prepareDecreaseDebt(ca),
373350
373809
  ...this.#prepareDisableTokens(ca),
373351
- ...assetsToWithdraw.map((t) => this.#prepareWithdrawToken(ca.creditFacade, t, MAX_UINT256, to))
373810
+ ...assetsToWithdraw.map(
373811
+ (t) => this.#prepareWithdrawToken(ca.creditFacade, t, MAX_UINT256, to)
373812
+ )
373352
373813
  ];
373353
373814
  const tx = operation === "close" ? cm.creditFacade.closeCreditAccount(ca.creditAccount, calls) : cm.creditFacade.multicall(ca.creditAccount, calls);
373354
373815
  return { tx, calls, routerCloseResult, creditFacade: cm.creditFacade };
@@ -373364,7 +373825,14 @@ var CreditAccountsService = class extends SDKConstruct {
373364
373825
  * @param permits
373365
373826
  * @returns
373366
373827
  */
373367
- async repayCreditAccount({ operation, collateralAssets, assetsToWithdraw, creditAccount: ca, permits, to }) {
373828
+ async repayCreditAccount({
373829
+ operation,
373830
+ collateralAssets,
373831
+ assetsToWithdraw,
373832
+ creditAccount: ca,
373833
+ permits,
373834
+ to
373835
+ }) {
373368
373836
  const cm = this.sdk.marketRegister.findCreditManager(ca.creditManager);
373369
373837
  const addCollateral = collateralAssets.filter((a) => a.balance > 0);
373370
373838
  const calls = [
@@ -373373,7 +373841,9 @@ var CreditAccountsService = class extends SDKConstruct {
373373
373841
  ...this.#prepareDecreaseDebt(ca),
373374
373842
  ...this.#prepareDisableTokens(ca),
373375
373843
  // TODO: probably needs a better way to handle reward tokens
373376
- ...assetsToWithdraw.map((t) => this.#prepareWithdrawToken(ca.creditFacade, t, MAX_UINT256, to))
373844
+ ...assetsToWithdraw.map(
373845
+ (t) => this.#prepareWithdrawToken(ca.creditFacade, t, MAX_UINT256, to)
373846
+ )
373377
373847
  ];
373378
373848
  const tx = operation === "close" ? cm.creditFacade.closeCreditAccount(ca.creditAccount, calls) : cm.creditFacade.multicall(ca.creditAccount, calls);
373379
373849
  return { tx, calls, creditFacade: cm.creditFacade };
@@ -373387,22 +373857,44 @@ var CreditAccountsService = class extends SDKConstruct {
373387
373857
  * @param slippage
373388
373858
  * @returns
373389
373859
  */
373390
- async repayAndLiquidateCreditAccount({ collateralAssets, assetsToWithdraw, creditAccount: ca, permits, to }) {
373860
+ async repayAndLiquidateCreditAccount({
373861
+ collateralAssets,
373862
+ assetsToWithdraw,
373863
+ creditAccount: ca,
373864
+ permits,
373865
+ to
373866
+ }) {
373391
373867
  const cm = this.sdk.marketRegister.findCreditManager(ca.creditManager);
373392
- const priceUpdates = await this.getPriceUpdatesForFacade(ca.creditManager, ca, void 0);
373868
+ const priceUpdates = await this.getPriceUpdatesForFacade(
373869
+ ca.creditManager,
373870
+ ca,
373871
+ void 0
373872
+ );
373393
373873
  const addCollateral = collateralAssets.filter((a) => a.balance > 0);
373394
373874
  const calls = [
373395
373875
  ...priceUpdates,
373396
373876
  ...this.#prepareAddCollateral(ca.creditFacade, addCollateral, permits),
373397
- ...assetsToWithdraw.map((t) => this.#prepareWithdrawToken(ca.creditFacade, t, MAX_UINT256, to))
373877
+ ...assetsToWithdraw.map(
373878
+ (t) => this.#prepareWithdrawToken(ca.creditFacade, t, MAX_UINT256, to)
373879
+ )
373398
373880
  ];
373399
- const tx = cm.creditFacade.liquidateCreditAccount(ca.creditAccount, to, calls);
373881
+ const tx = cm.creditFacade.liquidateCreditAccount(
373882
+ ca.creditAccount,
373883
+ to,
373884
+ calls
373885
+ );
373400
373886
  return { tx, calls, creditFacade: cm.creditFacade };
373401
373887
  }
373402
373888
  async updateQuotas(props) {
373403
373889
  const { creditAccount } = props;
373404
- const cm = this.sdk.marketRegister.findCreditManager(creditAccount.creditManager);
373405
- const priceUpdates = await this.getPriceUpdatesForFacade(creditAccount.creditManager, creditAccount, void 0);
373890
+ const cm = this.sdk.marketRegister.findCreditManager(
373891
+ creditAccount.creditManager
373892
+ );
373893
+ const priceUpdates = await this.getPriceUpdatesForFacade(
373894
+ creditAccount.creditManager,
373895
+ creditAccount,
373896
+ void 0
373897
+ );
373406
373898
  const calls = [
373407
373899
  ...priceUpdates,
373408
373900
  ...this.#prepareUpdateQuotas(props.creditAccount.creditFacade, props)
@@ -373415,25 +373907,44 @@ var CreditAccountsService = class extends SDKConstruct {
373415
373907
  }
373416
373908
  async addCollateral(props) {
373417
373909
  const { creditAccount, asset, permit, ethAmount } = props;
373418
- const cm = this.sdk.marketRegister.findCreditManager(creditAccount.creditManager);
373419
- const priceUpdatesCalls = await this.getPriceUpdatesForFacade(creditAccount.creditManager, creditAccount, props.averageQuota);
373910
+ const cm = this.sdk.marketRegister.findCreditManager(
373911
+ creditAccount.creditManager
373912
+ );
373913
+ const priceUpdatesCalls = await this.getPriceUpdatesForFacade(
373914
+ creditAccount.creditManager,
373915
+ creditAccount,
373916
+ props.averageQuota
373917
+ );
373420
373918
  const calls = [
373421
373919
  ...priceUpdatesCalls,
373422
- ...this.#prepareAddCollateral(creditAccount.creditFacade, [asset], permit ? { [asset.token]: permit } : {}),
373920
+ ...this.#prepareAddCollateral(
373921
+ creditAccount.creditFacade,
373922
+ [asset],
373923
+ permit ? { [asset.token]: permit } : {}
373924
+ ),
373423
373925
  ...this.#prepareUpdateQuotas(creditAccount.creditFacade, props)
373424
373926
  ];
373425
373927
  const tx = cm.creditFacade.multicall(creditAccount.creditAccount, calls);
373426
373928
  tx.value = ethAmount.toString(10);
373427
373929
  return { tx, calls, creditFacade: cm.creditFacade };
373428
373930
  }
373429
- async changeDebt({ creditAccount, amount }) {
373931
+ async changeDebt({
373932
+ creditAccount,
373933
+ amount
373934
+ }) {
373430
373935
  if (amount === 0n) {
373431
373936
  throw new Error("debt increase or decrease must be non-zero");
373432
373937
  }
373433
373938
  const isDecrease = amount < 0n;
373434
373939
  const change = isDecrease ? -amount : amount;
373435
- const cm = this.sdk.marketRegister.findCreditManager(creditAccount.creditManager);
373436
- const priceUpdatesCalls = await this.getPriceUpdatesForFacade(creditAccount.creditManager, creditAccount, void 0);
373940
+ const cm = this.sdk.marketRegister.findCreditManager(
373941
+ creditAccount.creditManager
373942
+ );
373943
+ const priceUpdatesCalls = await this.getPriceUpdatesForFacade(
373944
+ creditAccount.creditManager,
373945
+ creditAccount,
373946
+ void 0
373947
+ );
373437
373948
  const underlyingEnabled = (creditAccount.enabledTokensMask & 1n) === 1n;
373438
373949
  const shouldEnable = !isDecrease && !underlyingEnabled;
373439
373950
  const calls = [
@@ -373448,11 +373959,24 @@ var CreditAccountsService = class extends SDKConstruct {
373448
373959
  }
373449
373960
  async withdrawCollateral(props) {
373450
373961
  const { creditAccount, assetsToWithdraw, to } = props;
373451
- const cm = this.sdk.marketRegister.findCreditManager(creditAccount.creditManager);
373452
- const priceUpdatesCalls = await this.getPriceUpdatesForFacade(creditAccount.creditManager, creditAccount, void 0);
373962
+ const cm = this.sdk.marketRegister.findCreditManager(
373963
+ creditAccount.creditManager
373964
+ );
373965
+ const priceUpdatesCalls = await this.getPriceUpdatesForFacade(
373966
+ creditAccount.creditManager,
373967
+ creditAccount,
373968
+ void 0
373969
+ );
373453
373970
  const calls = [
373454
373971
  ...priceUpdatesCalls,
373455
- ...assetsToWithdraw.map((a) => this.#prepareWithdrawToken(creditAccount.creditFacade, a.token, a.balance, to)),
373972
+ ...assetsToWithdraw.map(
373973
+ (a) => this.#prepareWithdrawToken(
373974
+ creditAccount.creditFacade,
373975
+ a.token,
373976
+ a.balance,
373977
+ to
373978
+ )
373979
+ ),
373456
373980
  ...this.#prepareUpdateQuotas(creditAccount.creditFacade, props)
373457
373981
  ];
373458
373982
  const tx = cm.creditFacade.multicall(creditAccount.creditAccount, calls);
@@ -373460,10 +373984,15 @@ var CreditAccountsService = class extends SDKConstruct {
373460
373984
  }
373461
373985
  async executeSwap(props) {
373462
373986
  const { creditAccount, calls: swapCalls } = props;
373463
- if (swapCalls.length === 0)
373464
- throw new Error("No path to execute");
373465
- const cm = this.sdk.marketRegister.findCreditManager(creditAccount.creditManager);
373466
- const priceUpdatesCalls = await this.getPriceUpdatesForFacade(creditAccount.creditManager, creditAccount, props.averageQuota);
373987
+ if (swapCalls.length === 0) throw new Error("No path to execute");
373988
+ const cm = this.sdk.marketRegister.findCreditManager(
373989
+ creditAccount.creditManager
373990
+ );
373991
+ const priceUpdatesCalls = await this.getPriceUpdatesForFacade(
373992
+ creditAccount.creditManager,
373993
+ creditAccount,
373994
+ props.averageQuota
373995
+ );
373467
373996
  const calls = [
373468
373997
  ...priceUpdatesCalls,
373469
373998
  ...swapCalls,
@@ -373474,24 +374003,43 @@ var CreditAccountsService = class extends SDKConstruct {
373474
374003
  }
373475
374004
  async claimFarmRewards(props) {
373476
374005
  const { tokensToDisable, calls: claimCalls, creditAccount: ca } = props;
373477
- if (claimCalls.length === 0)
373478
- throw new Error("No path to execute");
374006
+ if (claimCalls.length === 0) throw new Error("No path to execute");
373479
374007
  const cm = this.sdk.marketRegister.findCreditManager(ca.creditManager);
373480
- const priceUpdatesCalls = await this.getPriceUpdatesForFacade(ca.creditManager, ca, props.averageQuota);
374008
+ const priceUpdatesCalls = await this.getPriceUpdatesForFacade(
374009
+ ca.creditManager,
374010
+ ca,
374011
+ props.averageQuota
374012
+ );
373481
374013
  const calls = [
373482
374014
  ...priceUpdatesCalls,
373483
374015
  ...claimCalls,
373484
- ...tokensToDisable.map((a) => this.#prepareDisableToken(ca.creditFacade, a.token)),
374016
+ ...tokensToDisable.map(
374017
+ (a) => this.#prepareDisableToken(ca.creditFacade, a.token)
374018
+ ),
373485
374019
  ...this.#prepareUpdateQuotas(ca.creditFacade, props)
373486
374020
  ];
373487
374021
  const tx = cm.creditFacade.multicall(ca.creditAccount, calls);
373488
374022
  return { tx, calls, creditFacade: cm.creditFacade };
373489
374023
  }
373490
374024
  async openCA(props) {
373491
- const { ethAmount, creditManager, collateral, permits, debt, withdrawDebt, referralCode, to, calls: openPathCalls } = props;
374025
+ const {
374026
+ ethAmount,
374027
+ creditManager,
374028
+ collateral,
374029
+ permits,
374030
+ debt,
374031
+ withdrawDebt,
374032
+ referralCode,
374033
+ to,
374034
+ calls: openPathCalls
374035
+ } = props;
373492
374036
  const cmSuite = this.sdk.marketRegister.findCreditManager(creditManager);
373493
374037
  const cm = cmSuite.creditManager;
373494
- const priceUpdatesCalls = await this.getPriceUpdatesForFacade(cm.address, void 0, props.averageQuota);
374038
+ const priceUpdatesCalls = await this.getPriceUpdatesForFacade(
374039
+ cm.address,
374040
+ void 0,
374041
+ props.averageQuota
374042
+ );
373495
374043
  const calls = [
373496
374044
  ...priceUpdatesCalls,
373497
374045
  this.#prepareIncreaseDebt(cm.creditFacade, debt),
@@ -373550,7 +374098,9 @@ var CreditAccountsService = class extends SDKConstruct {
373550
374098
  const tokensByPool = /* @__PURE__ */ new Map();
373551
374099
  const oracleByPool = /* @__PURE__ */ new Map();
373552
374100
  for (const acc of accounts) {
373553
- const market = this.sdk.marketRegister.findByCreditManager(acc.creditManager);
374101
+ const market = this.sdk.marketRegister.findByCreditManager(
374102
+ acc.creditManager
374103
+ );
373554
374104
  const pool = market.pool.pool.address;
373555
374105
  oracleByPool.set(pool, market.priceOracle);
373556
374106
  for (const t of acc.tokens) {
@@ -373597,13 +374147,11 @@ var CreditAccountsService = class extends SDKConstruct {
373597
374147
  const balance = balanceAsset?.balance || 0n;
373598
374148
  const mask = balanceAsset?.mask || 0n;
373599
374149
  const isEnabled = (mask & creditAccount.enabledTokensMask) !== 0n;
373600
- if (balance > 10n && isEnabled)
373601
- insertToken(pool, t);
374150
+ if (balance > 10n && isEnabled) insertToken(pool, t);
373602
374151
  } else if (quotaRecord) {
373603
374152
  const quotaAsset = quotaRecord.get(t);
373604
374153
  const quotaBalance = quotaAsset?.balance || 0n;
373605
- if (quotaBalance > 0)
373606
- insertToken(pool, t);
374154
+ if (quotaBalance > 0) insertToken(pool, t);
373607
374155
  }
373608
374156
  }
373609
374157
  const priceFeeds = [];
@@ -373611,8 +374159,14 @@ var CreditAccountsService = class extends SDKConstruct {
373611
374159
  const tokens = Array.from(tokensByPool.get(pool2) ?? []);
373612
374160
  priceFeeds.push(...oracle.priceFeedsForTokens(tokens));
373613
374161
  }
373614
- this.#logger?.debug({ account: creditAccount?.creditAccount, manager: cm.name }, `generating price feed updates for ${priceFeeds.length} price feeds`);
373615
- return this.sdk.priceFeeds.generatePriceFeedsUpdateTxs(priceFeeds, creditAccount ? { account: creditAccount.creditAccount } : void 0);
374162
+ this.#logger?.debug(
374163
+ { account: creditAccount?.creditAccount, manager: cm.name },
374164
+ `generating price feed updates for ${priceFeeds.length} price feeds`
374165
+ );
374166
+ return this.sdk.priceFeeds.generatePriceFeedsUpdateTxs(
374167
+ priceFeeds,
374168
+ creditAccount ? { account: creditAccount.creditAccount } : void 0
374169
+ );
373616
374170
  }
373617
374171
  /**
373618
374172
  * Returns account price updates in a non-encoded format
@@ -373622,8 +374176,15 @@ var CreditAccountsService = class extends SDKConstruct {
373622
374176
  async getOnDemandPriceUpdates(creditManager, creditAccount, desiredQuotas) {
373623
374177
  const market = this.sdk.marketRegister.findByCreditManager(creditManager);
373624
374178
  const cm = this.sdk.marketRegister.findCreditManager(creditManager);
373625
- const update = await this.getUpdateForAccount(creditManager, creditAccount, desiredQuotas);
373626
- this.#logger?.debug({ account: creditAccount?.creditAccount, manager: cm.name }, `getting on demand price updates from ${update.txs.length} txs`);
374179
+ const update = await this.getUpdateForAccount(
374180
+ creditManager,
374181
+ creditAccount,
374182
+ desiredQuotas
374183
+ );
374184
+ this.#logger?.debug(
374185
+ { account: creditAccount?.creditAccount, manager: cm.name },
374186
+ `getting on demand price updates from ${update.txs.length} txs`
374187
+ );
373627
374188
  return market.priceOracle.onDemandPriceUpdates(update);
373628
374189
  }
373629
374190
  /**
@@ -373633,7 +374194,11 @@ var CreditAccountsService = class extends SDKConstruct {
373633
374194
  */
373634
374195
  async getPriceUpdatesForFacade(creditManager, creditAccount, desiredQuotas) {
373635
374196
  const cm = this.sdk.marketRegister.findCreditManager(creditManager);
373636
- const updates = await this.getOnDemandPriceUpdates(creditManager, creditAccount, desiredQuotas);
374197
+ const updates = await this.getOnDemandPriceUpdates(
374198
+ creditManager,
374199
+ creditAccount,
374200
+ desiredQuotas
374201
+ );
373637
374202
  return cm.creditFacade.encodeOnDemandPriceUpdates(updates);
373638
374203
  }
373639
374204
  #prepareDisableQuotas(ca) {
@@ -373813,7 +374378,9 @@ var AbstractAddressProviderContract = class extends BaseContract {
373813
374378
  if (!this.#latest[contract]) {
373814
374379
  throw new Error(`Latest version for ${contract} not found`);
373815
374380
  }
373816
- this.logger?.debug(`Latest version found for ${contract} : ${this.#latest[contract]}`);
374381
+ this.logger?.debug(
374382
+ `Latest version found for ${contract} : ${this.#latest[contract]}`
374383
+ );
373817
374384
  return this.getAddress(contract, this.#latest[contract]);
373818
374385
  }
373819
374386
  get state() {
@@ -373838,15 +374405,18 @@ var AbstractAddressProviderContract = class extends BaseContract {
373838
374405
  address: this.sdk.provider.addressLabels.get(address)
373839
374406
  };
373840
374407
  });
373841
- }).reduce((acc, vals) => {
373842
- for (const val of vals) {
373843
- if (!acc[val.key]) {
373844
- acc[val.key] = {};
374408
+ }).reduce(
374409
+ (acc, vals) => {
374410
+ for (const val of vals) {
374411
+ if (!acc[val.key]) {
374412
+ acc[val.key] = {};
374413
+ }
374414
+ acc[val.key][val.version] = val.address;
373845
374415
  }
373846
- acc[val.key][val.version] = val.address;
373847
- }
373848
- return acc;
373849
- }, {})
374416
+ return acc;
374417
+ },
374418
+ {}
374419
+ )
373850
374420
  };
373851
374421
  }
373852
374422
  };
@@ -373855,12 +374425,16 @@ var AbstractAddressProviderContract = class extends BaseContract {
373855
374425
  var abi19 = iAddressProviderV310Abi;
373856
374426
  var AddressProviderContractV3_1 = class extends AbstractAddressProviderContract {
373857
374427
  constructor(sdk, address, addresses = {}) {
373858
- super(sdk, {
373859
- addr: address,
373860
- name: "AddressProviderV3_1",
373861
- abi: abi19,
373862
- version: 310
373863
- }, addresses);
374428
+ super(
374429
+ sdk,
374430
+ {
374431
+ addr: address,
374432
+ name: "AddressProviderV3_1",
374433
+ abi: abi19,
374434
+ version: 310
374435
+ },
374436
+ addresses
374437
+ );
373864
374438
  }
373865
374439
  parseFunctionParams(params) {
373866
374440
  switch (params.functionName) {
@@ -373907,12 +374481,16 @@ var AddressProviderContractV3_1 = class extends AbstractAddressProviderContract
373907
374481
  var abi20 = iAddressProviderV300Abi;
373908
374482
  var AddressProviderContractV3 = class extends AbstractAddressProviderContract {
373909
374483
  constructor(sdk, address, addresses = {}) {
373910
- super(sdk, {
373911
- addr: address,
373912
- name: "AddressProviderV3",
373913
- abi: abi20,
373914
- version: 300
373915
- }, addresses);
374484
+ super(
374485
+ sdk,
374486
+ {
374487
+ addr: address,
374488
+ name: "AddressProviderV3",
374489
+ abi: abi20,
374490
+ version: 300
374491
+ },
374492
+ addresses
374493
+ );
373916
374494
  }
373917
374495
  parseFunctionParams(params) {
373918
374496
  switch (params.functionName) {
@@ -373937,7 +374515,11 @@ var AddressProviderContractV3 = class extends AbstractAddressProviderContract {
373937
374515
  logs: [log2]
373938
374516
  })[0];
373939
374517
  const { key, version: version4 } = args;
373940
- this.setInternalAddress(key, log2.args.value, Number(version4));
374518
+ this.setInternalAddress(
374519
+ key,
374520
+ log2.args.value,
374521
+ Number(version4)
374522
+ );
373941
374523
  break;
373942
374524
  }
373943
374525
  default:
@@ -373954,7 +374536,11 @@ var AddressProviderContractV3 = class extends AbstractAddressProviderContract {
373954
374536
  strict: true
373955
374537
  });
373956
374538
  for (const event of events) {
373957
- this.setInternalAddress(event.args.key, event.args.value, Number(event.args.version));
374539
+ this.setInternalAddress(
374540
+ event.args.key,
374541
+ event.args.value,
374542
+ Number(event.args.version)
374543
+ );
373958
374544
  }
373959
374545
  }
373960
374546
  };
@@ -373973,9 +374559,17 @@ async function getAddressProvider(sdk, address, options) {
373973
374559
  }
373974
374560
  switch (v) {
373975
374561
  case 300:
373976
- return new AddressProviderContractV3(sdk, addr, options?.state?.addresses);
374562
+ return new AddressProviderContractV3(
374563
+ sdk,
374564
+ addr,
374565
+ options?.state?.addresses
374566
+ );
373977
374567
  case 310:
373978
- return new AddressProviderContractV3_1(sdk, addr, options?.state?.addresses);
374568
+ return new AddressProviderContractV3_1(
374569
+ sdk,
374570
+ addr,
374571
+ options?.state?.addresses
374572
+ );
373979
374573
  default:
373980
374574
  throw new Error(`Unsupported address provider version: ${v}`);
373981
374575
  }
@@ -374028,7 +374622,11 @@ var BotListContract = class extends BaseContract {
374028
374622
  }
374029
374623
  break;
374030
374624
  case "SetBotSpecialPermissions":
374031
- this.logger?.debug(`Bot ${log2.args.bot} has been given permissions ${botPermissionsToString(log2.args.permissions)} for credit manager ${log2.args.creditManager}`);
374625
+ this.logger?.debug(
374626
+ `Bot ${log2.args.bot} has been given permissions ${botPermissionsToString(
374627
+ log2.args.permissions
374628
+ )} for credit manager ${log2.args.creditManager}`
374629
+ );
374032
374630
  break;
374033
374631
  default:
374034
374632
  this.logger?.warn(`Unknown event: ${log2.eventName}`);
@@ -374037,7 +374635,9 @@ var BotListContract = class extends BaseContract {
374037
374635
  }
374038
374636
  get approvedCreditManagers() {
374039
374637
  if (!this.#approvedCreditManagers) {
374040
- throw new Error("BotListContract state needs to be synced to load approvedCreditManagers");
374638
+ throw new Error(
374639
+ "BotListContract state needs to be synced to load approvedCreditManagers"
374640
+ );
374041
374641
  }
374042
374642
  return this.#approvedCreditManagers;
374043
374643
  }
@@ -374133,7 +374733,10 @@ var GearboxSDK = class _GearboxSDK {
374133
374733
  /**
374134
374734
  * All contracts known to sdk
374135
374735
  */
374136
- contracts = new AddressMap(void 0, "contracts");
374736
+ contracts = new AddressMap(
374737
+ void 0,
374738
+ "contracts"
374739
+ );
374137
374740
  /**
374138
374741
  * Token metadata such as symbol and decimals
374139
374742
  */
@@ -374141,7 +374744,14 @@ var GearboxSDK = class _GearboxSDK {
374141
374744
  addHook = this.#hooks.addHook.bind(this.#hooks);
374142
374745
  removeHook = this.#hooks.removeHook.bind(this.#hooks);
374143
374746
  static async attach(options) {
374144
- const { logger: logger2, plugins, blockNumber, redstoneHistoricTimestamp, ignoreUpdateablePrices, marketConfigurators } = options;
374747
+ const {
374748
+ logger: logger2,
374749
+ plugins,
374750
+ blockNumber,
374751
+ redstoneHistoricTimestamp,
374752
+ ignoreUpdateablePrices,
374753
+ marketConfigurators
374754
+ } = options;
374145
374755
  let { networkType, addressProvider, chainId } = options;
374146
374756
  const attachClient = createPublicClient({
374147
374757
  transport: createTransport2(options)
@@ -374160,7 +374770,10 @@ var GearboxSDK = class _GearboxSDK {
374160
374770
  chainId,
374161
374771
  networkType
374162
374772
  });
374163
- logger2?.debug({ networkType, chainId, addressProvider, marketConfigurators }, "attaching gearbox sdk");
374773
+ logger2?.debug(
374774
+ { networkType, chainId, addressProvider, marketConfigurators },
374775
+ "attaching gearbox sdk"
374776
+ );
374164
374777
  return new _GearboxSDK({
374165
374778
  provider,
374166
374779
  logger: logger2,
@@ -374180,11 +374793,20 @@ var GearboxSDK = class _GearboxSDK {
374180
374793
  this.plugins = options.plugins ?? [];
374181
374794
  }
374182
374795
  async #attach(opts) {
374183
- const { addressProvider, blockNumber, redstoneHistoricTimestamp, redstoneGateways, ignoreUpdateablePrices, marketConfigurators } = opts;
374796
+ const {
374797
+ addressProvider,
374798
+ blockNumber,
374799
+ redstoneHistoricTimestamp,
374800
+ redstoneGateways,
374801
+ ignoreUpdateablePrices,
374802
+ marketConfigurators
374803
+ } = opts;
374184
374804
  const time = Date.now();
374185
- const block = await this.provider.publicClient.getBlock(blockNumber ? { blockNumber: BigInt(blockNumber) } : {
374186
- blockTag: "latest"
374187
- });
374805
+ const block = await this.provider.publicClient.getBlock(
374806
+ blockNumber ? { blockNumber: BigInt(blockNumber) } : {
374807
+ blockTag: "latest"
374808
+ }
374809
+ );
374188
374810
  this.#currentBlock = block.number;
374189
374811
  this.#timestamp = block.timestamp;
374190
374812
  if (redstoneHistoricTimestamp) {
@@ -374193,21 +374815,38 @@ var GearboxSDK = class _GearboxSDK {
374193
374815
  if (redstoneGateways?.length) {
374194
374816
  this.priceFeeds.redstoneUpdater.gateways = redstoneGateways;
374195
374817
  }
374196
- this.logger?.info({
374197
- addressProvider,
374198
- blockNumber: block.number,
374199
- timestamp: block.timestamp
374200
- }, "attaching");
374818
+ this.logger?.info(
374819
+ {
374820
+ addressProvider,
374821
+ blockNumber: block.number,
374822
+ timestamp: block.timestamp
374823
+ },
374824
+ "attaching"
374825
+ );
374201
374826
  this.#addressProvider = await getAddressProvider(this, addressProvider);
374202
- this.logger?.debug(`address provider version: ${this.#addressProvider.version}`);
374827
+ this.logger?.debug(
374828
+ `address provider version: ${this.#addressProvider.version}`
374829
+ );
374203
374830
  await this.#addressProvider.syncState(this.currentBlock);
374204
- const botListAddress = this.#addressProvider.getAddress(AP_BOT_LIST, NO_VERSION);
374831
+ const botListAddress = this.#addressProvider.getAddress(
374832
+ AP_BOT_LIST,
374833
+ NO_VERSION
374834
+ );
374205
374835
  this.#botListContract = new BotListContract(this, botListAddress);
374206
374836
  this.#gear = this.#addressProvider.getAddress(AP_GEAR_TOKEN, NO_VERSION);
374207
- const gearStakingAddress = this.#addressProvider.getAddress(AP_GEAR_STAKING, NO_VERSION);
374208
- this.#gearStakingContract = new GearStakingContract(this, gearStakingAddress);
374837
+ const gearStakingAddress = this.#addressProvider.getAddress(
374838
+ AP_GEAR_STAKING,
374839
+ NO_VERSION
374840
+ );
374841
+ this.#gearStakingContract = new GearStakingContract(
374842
+ this,
374843
+ gearStakingAddress
374844
+ );
374209
374845
  this.#marketRegister = new MarketRegister(this);
374210
- await this.#marketRegister.loadMarkets(marketConfigurators, ignoreUpdateablePrices);
374846
+ await this.#marketRegister.loadMarkets(
374847
+ marketConfigurators,
374848
+ ignoreUpdateablePrices
374849
+ );
374211
374850
  try {
374212
374851
  const router = this.#addressProvider.getLatestVersion(AP_ROUTER);
374213
374852
  this.#router = new RouterV3Contract(this, router);
@@ -374234,7 +374873,9 @@ var GearboxSDK = class _GearboxSDK {
374234
374873
  * @returns
374235
374874
  */
374236
374875
  parseMultiCall(calls) {
374237
- return calls.map((call2) => this.parseFunctionData(call2.target, call2.callData));
374876
+ return calls.map(
374877
+ (call2) => this.parseFunctionData(call2.target, call2.callData)
374878
+ );
374238
374879
  }
374239
374880
  /**
374240
374881
  * Return args, function, type and address name from contract call
@@ -374257,7 +374898,9 @@ var GearboxSDK = class _GearboxSDK {
374257
374898
  * @returns
374258
374899
  */
374259
374900
  parseMultiCallToObject(calls) {
374260
- return calls.map((call2) => this.parseFunctionDataToObject(call2.target, call2.callData));
374901
+ return calls.map(
374902
+ (call2) => this.parseFunctionDataToObject(call2.target, call2.callData)
374903
+ );
374261
374904
  }
374262
374905
  stateHuman(raw = true) {
374263
374906
  return {
@@ -399390,14 +400033,19 @@ var iDegenNftv2Abi2 = parseAbi([
399390
400033
  ]);
399391
400034
 
399392
400035
  // ../../node_modules/@gearbox-protocol/sdk/dist/esm/dev/createAnvilClient.js
399393
- function createAnvilClient({ chain, transport }) {
399394
- return createTestClient({
399395
- chain,
399396
- mode: "anvil",
399397
- transport,
399398
- cacheTime: 0,
399399
- pollingInterval: 50
399400
- }).extend(publicActions).extend(walletActions).extend((client) => ({
400036
+ function createAnvilClient({
400037
+ chain,
400038
+ transport
400039
+ }) {
400040
+ return createTestClient(
400041
+ {
400042
+ chain,
400043
+ mode: "anvil",
400044
+ transport,
400045
+ cacheTime: 0,
400046
+ pollingInterval: 50
400047
+ }
400048
+ ).extend(publicActions).extend(walletActions).extend((client) => ({
399401
400049
  anvilNodeInfo: () => anvilNodeInfo(client),
399402
400050
  isAnvil: () => isAnvil(client),
399403
400051
  evmMineDetailed: (timestamp) => evmMineDetailed(client, timestamp)
@@ -399503,7 +400151,12 @@ var AccountOpener = class extends SDKConstruct {
399503
400151
  return results;
399504
400152
  }
399505
400153
  async #openAccount(input, index2, total) {
399506
- const { creditManager, collateral, leverage = DEFAULT_LEVERAGE, slippage = 50 } = input;
400154
+ const {
400155
+ creditManager,
400156
+ collateral,
400157
+ leverage = DEFAULT_LEVERAGE,
400158
+ slippage = 50
400159
+ } = input;
399507
400160
  const borrower = await this.#getBorrower();
399508
400161
  const cm = this.sdk.marketRegister.findCreditManager(creditManager);
399509
400162
  const symbol = this.sdk.tokensMeta.symbol(collateral);
@@ -399536,8 +400189,18 @@ var AccountOpener = class extends SDKConstruct {
399536
400189
  });
399537
400190
  logger2?.debug(strategy, "found open strategy");
399538
400191
  const debt = minDebt * BigInt(leverage - 1);
399539
- const averageQuota = this.#getCollateralQuota(cm, collateral, strategy.amount, debt);
399540
- const minQuota = this.#getCollateralQuota(cm, collateral, strategy.minAmount, debt);
400192
+ const averageQuota = this.#getCollateralQuota(
400193
+ cm,
400194
+ collateral,
400195
+ strategy.amount,
400196
+ debt
400197
+ );
400198
+ const minQuota = this.#getCollateralQuota(
400199
+ cm,
400200
+ collateral,
400201
+ strategy.minAmount,
400202
+ debt
400203
+ );
399541
400204
  logger2?.debug({ averageQuota, minQuota }, "calculated quotas");
399542
400205
  const { tx, calls } = await this.#service.openCA({
399543
400206
  creditManager: cm.creditManager.address,
@@ -399553,7 +400216,9 @@ var AccountOpener = class extends SDKConstruct {
399553
400216
  });
399554
400217
  for (let i = 0; i < calls.length; i++) {
399555
400218
  const call2 = calls[i];
399556
- logger2?.debug(`call #${i + 1}: ${this.sdk.parseFunctionData(call2.target, call2.callData)}`);
400219
+ logger2?.debug(
400220
+ `call #${i + 1}: ${this.sdk.parseFunctionData(call2.target, call2.callData)}`
400221
+ );
399557
400222
  }
399558
400223
  logger2?.debug("prepared open account transaction");
399559
400224
  let hash2;
@@ -399589,8 +400254,12 @@ var AccountOpener = class extends SDKConstruct {
399589
400254
  let account;
399590
400255
  if (logs.length > 0) {
399591
400256
  try {
399592
- logger2?.debug(`getting credit account data for ${logs[0].args.creditAccount}`);
399593
- account = await this.#service.getCreditAccountData(logs[0].args.creditAccount);
400257
+ logger2?.debug(
400258
+ `getting credit account data for ${logs[0].args.creditAccount}`
400259
+ );
400260
+ account = await this.#service.getCreditAccountData(
400261
+ logs[0].args.creditAccount
400262
+ );
399594
400263
  } catch (e) {
399595
400264
  logger2?.error(`failed to get credit account data: ${e}`);
399596
400265
  }
@@ -399627,14 +400296,18 @@ var AccountOpener = class extends SDKConstruct {
399627
400296
  pool.availableLiquidity,
399628
400297
  diff
399629
400298
  ].map((v) => this.sdk.tokensMeta.formatBN(pool.underlying, v));
399630
- this.#logger?.debug(`Pool ${this.labelAddress(pool.address)} has ${availableS} liquidity, needs ${diffS} more for the minimum of ${minS} ${this.sdk.tokensMeta.symbol(pool.underlying)}`);
400299
+ this.#logger?.debug(
400300
+ `Pool ${this.labelAddress(pool.address)} has ${availableS} liquidity, needs ${diffS} more for the minimum of ${minS} ${this.sdk.tokensMeta.symbol(pool.underlying)}`
400301
+ );
399631
400302
  if (diff > 0n) {
399632
400303
  deposits.push([pool, diff]);
399633
400304
  totalUSD += market.priceOracle.convertToUSD(pool.underlying, diff);
399634
400305
  }
399635
400306
  }
399636
400307
  totalUSD = totalUSD * 105n / 100n;
399637
- this.#logger?.debug(`total USD to claim from faucet: ${formatBN(totalUSD, 8)}`);
400308
+ this.#logger?.debug(
400309
+ `total USD to claim from faucet: ${formatBN(totalUSD, 8)}`
400310
+ );
399638
400311
  const depositor = await this.#createAccount();
399639
400312
  this.#logger?.debug(`created depositor ${depositor.address}`);
399640
400313
  await this.#claimFromFaucet(depositor, totalUSD);
@@ -399657,7 +400330,9 @@ var AccountOpener = class extends SDKConstruct {
399657
400330
  functionName: "balanceOf",
399658
400331
  args: [depositor.address]
399659
400332
  });
399660
- this.#logger?.debug(`depositor balance in underlying: ${this.sdk.tokensMeta.formatBN(pool.underlying, allowance)}`);
400333
+ this.#logger?.debug(
400334
+ `depositor balance in underlying: ${this.sdk.tokensMeta.formatBN(pool.underlying, allowance)}`
400335
+ );
399661
400336
  let hash2 = await this.#anvil.writeContract({
399662
400337
  account: depositor,
399663
400338
  address: underlying,
@@ -399668,9 +400343,13 @@ var AccountOpener = class extends SDKConstruct {
399668
400343
  });
399669
400344
  let receipt = await this.#anvil.waitForTransactionReceipt({ hash: hash2 });
399670
400345
  if (receipt.status === "reverted") {
399671
- throw new Error(`tx ${hash2} that approves underlying from depositor for pool ${poolName} reverted`);
400346
+ throw new Error(
400347
+ `tx ${hash2} that approves underlying from depositor for pool ${poolName} reverted`
400348
+ );
399672
400349
  }
399673
- this.#logger?.debug(`depositor approved underlying for pool ${poolName}: ${hash2}`);
400350
+ this.#logger?.debug(
400351
+ `depositor approved underlying for pool ${poolName}: ${hash2}`
400352
+ );
399674
400353
  hash2 = await this.#anvil.writeContract({
399675
400354
  account: depositor,
399676
400355
  address,
@@ -399697,8 +400376,12 @@ var AccountOpener = class extends SDKConstruct {
399697
400376
  let claimUSD = 0n;
399698
400377
  let degenNFTS = {};
399699
400378
  for (const target of targets) {
399700
- const cm = this.sdk.marketRegister.findCreditManager(target.creditManager);
399701
- const market = this.sdk.marketRegister.findByCreditManager(target.creditManager);
400379
+ const cm = this.sdk.marketRegister.findCreditManager(
400380
+ target.creditManager
400381
+ );
400382
+ const market = this.sdk.marketRegister.findByCreditManager(
400383
+ target.creditManager
400384
+ );
399702
400385
  const { minDebt, degenNFT } = cm.creditFacade;
399703
400386
  claimUSD += market.priceOracle.convertToUSD(cm.underlying, minDebt);
399704
400387
  if (isAddress(degenNFT) && degenNFT !== ADDRESS_0X0) {
@@ -399738,16 +400421,20 @@ var AccountOpener = class extends SDKConstruct {
399738
400421
  hash: hash2
399739
400422
  });
399740
400423
  if (receipt.status === "reverted") {
399741
- throw new Error(`account ${usr} failed to claimed equivalent of ${amnt} USD from faucet, tx: ${hash2}`);
400424
+ throw new Error(
400425
+ `account ${usr} failed to claimed equivalent of ${amnt} USD from faucet, tx: ${hash2}`
400426
+ );
399742
400427
  }
399743
- this.#logger?.debug(`account ${usr} claimed equivalent of ${amnt} USD from faucet, tx: ${hash2}`);
400428
+ this.#logger?.debug(
400429
+ `account ${usr} claimed equivalent of ${amnt} USD from faucet, tx: ${hash2}`
400430
+ );
399744
400431
  }
399745
400432
  async #approve(token, cm) {
399746
400433
  const borrower = await this.#getBorrower();
399747
400434
  const symbol = this.#service.sdk.tokensMeta.symbol(token);
399748
400435
  try {
399749
400436
  if (symbol === "USDT") {
399750
- const hash3 = await this.#anvil.writeContract({
400437
+ const hash22 = await this.#anvil.writeContract({
399751
400438
  account: borrower,
399752
400439
  address: token,
399753
400440
  abi: ierc20Abi,
@@ -399756,7 +400443,7 @@ var AccountOpener = class extends SDKConstruct {
399756
400443
  chain: this.#anvil.chain
399757
400444
  });
399758
400445
  await this.#anvil.waitForTransactionReceipt({
399759
- hash: hash3
400446
+ hash: hash22
399760
400447
  });
399761
400448
  }
399762
400449
  const hash2 = await this.#anvil.writeContract({
@@ -399771,12 +400458,18 @@ var AccountOpener = class extends SDKConstruct {
399771
400458
  hash: hash2
399772
400459
  });
399773
400460
  if (receipt.status === "reverted") {
399774
- this.#logger?.error(`failed to allowed credit manager ${cm.creditManager.name} to spend ${symbol} (${token}), tx reverted: ${hash2}`);
400461
+ this.#logger?.error(
400462
+ `failed to allowed credit manager ${cm.creditManager.name} to spend ${symbol} (${token}), tx reverted: ${hash2}`
400463
+ );
399775
400464
  } else {
399776
- this.#logger?.debug(`allowed credit manager ${cm.creditManager.name} to spend ${symbol} (${token}), tx: ${hash2}`);
400465
+ this.#logger?.debug(
400466
+ `allowed credit manager ${cm.creditManager.name} to spend ${symbol} (${token}), tx: ${hash2}`
400467
+ );
399777
400468
  }
399778
400469
  } catch (e) {
399779
- this.#logger?.error(`failed to allowed credit manager ${cm.creditManager.name} to spend ${symbol} (${token}): ${e}`);
400470
+ this.#logger?.error(
400471
+ `failed to allowed credit manager ${cm.creditManager.name} to spend ${symbol} (${token}): ${e}`
400472
+ );
399780
400473
  }
399781
400474
  }
399782
400475
  async #mintDegenNft(degenNFT, to, amount) {
@@ -399812,11 +400505,17 @@ var AccountOpener = class extends SDKConstruct {
399812
400505
  hash: hash2
399813
400506
  });
399814
400507
  if (receipt.status === "reverted") {
399815
- this.#logger?.error(`failed to mint ${amount} degenNFT ${degenNFT} to borrower ${to}, tx reverted: ${hash2}`);
400508
+ this.#logger?.error(
400509
+ `failed to mint ${amount} degenNFT ${degenNFT} to borrower ${to}, tx reverted: ${hash2}`
400510
+ );
399816
400511
  }
399817
- this.#logger?.debug(`minted ${amount} degenNFT ${degenNFT} to borrower ${to}, tx: ${hash2}`);
400512
+ this.#logger?.debug(
400513
+ `minted ${amount} degenNFT ${degenNFT} to borrower ${to}, tx: ${hash2}`
400514
+ );
399818
400515
  } catch (e) {
399819
- this.#logger?.error(`failed to mint ${amount} degenNFT ${degenNFT} to borrower ${to}: ${e}`);
400516
+ this.#logger?.error(
400517
+ `failed to mint ${amount} degenNFT ${degenNFT} to borrower ${to}: ${e}`
400518
+ );
399820
400519
  } finally {
399821
400520
  await this.#anvil.stopImpersonatingAccount({ address: minter });
399822
400521
  }
@@ -399837,17 +400536,24 @@ var AccountOpener = class extends SDKConstruct {
399837
400536
  return acc;
399838
400537
  }
399839
400538
  #getCollateralQuota(cm, collateral, amount, debt) {
399840
- const { underlying, creditManager: { liquidationThresholds } } = cm;
400539
+ const {
400540
+ underlying,
400541
+ creditManager: { liquidationThresholds }
400542
+ } = cm;
399841
400543
  const inUnderlying = collateral.toLowerCase() === underlying.toLowerCase();
399842
400544
  if (inUnderlying) {
399843
400545
  return [];
399844
400546
  }
399845
400547
  const collateralLT = BigInt(liquidationThresholds.mustGet(collateral));
399846
- const market = this.sdk.marketRegister.findByCreditManager(cm.creditManager.address);
400548
+ const market = this.sdk.marketRegister.findByCreditManager(
400549
+ cm.creditManager.address
400550
+ );
399847
400551
  const quotaInfo = market.pool.pqk.quotas.mustGet(collateral);
399848
400552
  const availableQuota = quotaInfo.limit - quotaInfo.totalQuoted;
399849
400553
  if (availableQuota <= 0n) {
399850
- throw new Error(`quota exceeded for asset ${this.labelAddress(collateral)} in ${cm.name}`);
400554
+ throw new Error(
400555
+ `quota exceeded for asset ${this.labelAddress(collateral)} in ${cm.name}`
400556
+ );
399851
400557
  }
399852
400558
  const desiredQuota = this.#calcQuota(amount, debt, collateralLT);
399853
400559
  return [
@@ -399874,8 +400580,18 @@ var SDKExample = class {
399874
400580
  this.#logger = logger2;
399875
400581
  }
399876
400582
  async run(opts) {
399877
- const { addressProvider: ap, addressProviderJson, marketConfigurators, anvilUrl = "http://127.0.0.1:8545", outFile } = opts;
399878
- const addressProvider = await this.#readConfigAddress("addressProvider", ap, addressProviderJson);
400583
+ const {
400584
+ addressProvider: ap,
400585
+ addressProviderJson,
400586
+ marketConfigurators,
400587
+ anvilUrl = "http://127.0.0.1:8545",
400588
+ outFile
400589
+ } = opts;
400590
+ const addressProvider = await this.#readConfigAddress(
400591
+ "addressProvider",
400592
+ ap,
400593
+ addressProviderJson
400594
+ );
399879
400595
  this.#sdk = await GearboxSDK.attach({
399880
400596
  rpcURLs: [anvilUrl],
399881
400597
  timeout: 48e4,
@@ -399890,11 +400606,19 @@ var SDKExample = class {
399890
400606
  } catch (e) {
399891
400607
  this.#logger?.error(`failed to load zappers: ${e}`);
399892
400608
  }
399893
- await Promise.allSettled(this.#sdk.marketRegister.marketConfigurators.map((m) => m.loadCuratorName()));
400609
+ await Promise.allSettled(
400610
+ this.#sdk.marketRegister.marketConfigurators.map(
400611
+ (m) => m.loadCuratorName()
400612
+ )
400613
+ );
399894
400614
  this.#logger?.info("loaded curator names");
399895
400615
  if (outFile) {
399896
400616
  try {
399897
- await writeFile2(outFile, json_stringify(this.#sdk.stateHuman()), "utf-8");
400617
+ await writeFile2(
400618
+ outFile,
400619
+ json_stringify(this.#sdk.stateHuman()),
400620
+ "utf-8"
400621
+ );
399898
400622
  } catch (e) {
399899
400623
  this.#logger?.error(`failed to write to ${outFile}: ${e}`);
399900
400624
  }
@@ -400039,7 +400763,9 @@ async function setLTZero(anvil, cm, logger2) {
400039
400763
  address: cm.creditConfigurator,
400040
400764
  value: parseEther("100")
400041
400765
  });
400042
- logger2?.debug(`[${cm.name}] impresonating creditConfigurator ${cm.creditConfigurator}`);
400766
+ logger2?.debug(
400767
+ `[${cm.name}] impresonating creditConfigurator ${cm.creditConfigurator}`
400768
+ );
400043
400769
  logger2?.debug(`[${cm.name}] setting liquidation threshold`);
400044
400770
  hash2 = await anvil.writeContract({
400045
400771
  chain: anvil.chain,
@@ -406766,7 +407492,7 @@ function getRenderer(opts) {
406766
407492
  var package_default = {
406767
407493
  name: "@gearbox-protocol/deploy-tools",
406768
407494
  description: "Gearbox deploy tools",
406769
- version: "5.16.8",
407495
+ version: "5.16.10",
406770
407496
  homepage: "https://gearbox.fi",
406771
407497
  keywords: [
406772
407498
  "gearbox"
@@ -406809,7 +407535,7 @@ var package_default = {
406809
407535
  "@gearbox-protocol/deploy-tools-node": "0.0.0",
406810
407536
  "@gearbox-protocol/deploy-tools-shared": "0.0.0",
406811
407537
  "@gearbox-protocol/deploy-tools-types": "0.0.0",
406812
- "@gearbox-protocol/sdk": "3.0.0-vfourabi.8",
407538
+ "@gearbox-protocol/sdk": "3.0.0-vfour.269",
406813
407539
  "@gearbox-protocol/sdk-gov": "^2.36.5",
406814
407540
  "@types/lodash-es": "^4.17.12",
406815
407541
  "@types/node": "^22.13.5",