@gearbox-protocol/sdk 3.0.0-vfour.61 → 3.0.0-vfour.63

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.
@@ -19097,6 +19097,12 @@ var ADDRESS_PROVIDER = {
19097
19097
  Optimism: "0x3761ca4BFAcFCFFc1B8034e69F19116dD6756726",
19098
19098
  Base: NOT_DEPLOYED
19099
19099
  };
19100
+ var ADDRESS_PROVIDER_BLOCK = {
19101
+ Mainnet: 18433056n,
19102
+ Arbitrum: 184650310n,
19103
+ Optimism: 118410666n,
19104
+ Base: 0n
19105
+ };
19100
19106
 
19101
19107
  // src/sdk/constants/bot-permissions.ts
19102
19108
  var BotPermissions = /* @__PURE__ */ ((BotPermissions2) => {
@@ -22486,9 +22492,11 @@ var AddressProviderContractV3_1 = class extends BaseContract {
22486
22492
 
22487
22493
  // src/sdk/core/BotListV3Contract.ts
22488
22494
  var BotListContract = class extends BaseContract {
22489
- approvedCreditManagers = /* @__PURE__ */ new Set();
22495
+ #approvedCreditManagers;
22496
+ #currentBlock;
22490
22497
  constructor(sdk, address) {
22491
22498
  super(sdk, { addr: address, name: "BotListV3", abi: botListV3Abi });
22499
+ this.#currentBlock = ADDRESS_PROVIDER_BLOCK[sdk.provider.networkType];
22492
22500
  }
22493
22501
  parseFunctionParams(params) {
22494
22502
  switch (params.functionName) {
@@ -22508,14 +22516,15 @@ var BotListContract = class extends BaseContract {
22508
22516
  return void 0;
22509
22517
  }
22510
22518
  }
22511
- async fetchState(toBlock) {
22519
+ async syncState(toBlock) {
22512
22520
  const logs = await this.provider.publicClient.getContractEvents({
22513
22521
  address: this.address,
22514
22522
  abi: this.abi,
22515
- fromBlock: 0n,
22523
+ fromBlock: this.#currentBlock,
22516
22524
  toBlock
22517
22525
  });
22518
22526
  logs.forEach((e) => this.processLog(e));
22527
+ this.#currentBlock = toBlock;
22519
22528
  }
22520
22529
  processLog(log) {
22521
22530
  switch (log.eventName) {
@@ -22538,6 +22547,14 @@ var BotListContract = class extends BaseContract {
22538
22547
  break;
22539
22548
  }
22540
22549
  }
22550
+ get approvedCreditManagers() {
22551
+ if (!this.#approvedCreditManagers) {
22552
+ throw new Error(
22553
+ "BotListContract state needs to be synced to load approvedCreditManagers"
22554
+ );
22555
+ }
22556
+ return this.#approvedCreditManagers;
22557
+ }
22541
22558
  stateHuman(raw = true) {
22542
22559
  return super.stateHuman(raw);
22543
22560
  }
@@ -22898,6 +22915,7 @@ function assetsMap(assets) {
22898
22915
 
22899
22916
  // src/sdk/GearboxSDK.ts
22900
22917
  var GearboxSDK = class _GearboxSDK {
22918
+ #hooks = new Hooks();
22901
22919
  // Represents chain object
22902
22920
  #provider;
22903
22921
  // Block which was use for data query
@@ -22931,6 +22949,8 @@ var GearboxSDK = class _GearboxSDK {
22931
22949
  * Token metadata such as symbol and decimals
22932
22950
  */
22933
22951
  tokensMeta = new TokensMeta();
22952
+ addHook = this.#hooks.addHook.bind(this.#hooks);
22953
+ removeHook = this.#hooks.removeHook.bind(this.#hooks);
22934
22954
  static async attach(options) {
22935
22955
  const { logger, riskCurators, blockNumber } = options;
22936
22956
  let { networkType, addressProvider, chainId } = options;
@@ -22982,7 +23002,6 @@ var GearboxSDK = class _GearboxSDK {
22982
23002
  await this.#addressProvider.fetchState(this.currentBlock);
22983
23003
  const botListAddress = this.#addressProvider.getAddress(AP_BOT_LIST, 300);
22984
23004
  this.#botListContract = new BotListContract(this, botListAddress);
22985
- await this.#botListContract.fetchState(this.currentBlock);
22986
23005
  this.#gear = this.#addressProvider.getAddress(AP_GEAR_TOKEN);
22987
23006
  const gearStakingAddress = this.#addressProvider.getAddress(
22988
23007
  AP_GEAR_STAKING,
@@ -23083,6 +23102,7 @@ var GearboxSDK = class _GearboxSDK {
23083
23102
  await this.marketRegister.syncState();
23084
23103
  this.#currentBlock = blockNumber;
23085
23104
  this.#timestamp = timestamp;
23105
+ await this.#hooks.triggerHooks("syncState");
23086
23106
  this.#syncing = false;
23087
23107
  this.logger?.debug(`synced state to block ${blockNumber}`);
23088
23108
  }
@@ -23141,6 +23161,7 @@ var GearboxSDK = class _GearboxSDK {
23141
23161
 
23142
23162
  exports.ADDRESS_0X0 = ADDRESS_0X0;
23143
23163
  exports.ADDRESS_PROVIDER = ADDRESS_PROVIDER;
23164
+ exports.ADDRESS_PROVIDER_BLOCK = ADDRESS_PROVIDER_BLOCK;
23144
23165
  exports.AP_ACCOUNT_FACTORY = AP_ACCOUNT_FACTORY;
23145
23166
  exports.AP_ACL = AP_ACL;
23146
23167
  exports.AP_ADAPTER_COMPRESSOR = AP_ADAPTER_COMPRESSOR;
@@ -24433,11 +24433,12 @@ declare class AddressProviderContractV3_1 extends BaseContract<abi$3> {
24433
24433
 
24434
24434
  type abi$2 = typeof botListV3Abi;
24435
24435
  declare class BotListContract extends BaseContract<abi$2> {
24436
- approvedCreditManagers: Set<Address>;
24436
+ #private;
24437
24437
  constructor(sdk: GearboxSDK, address: Address);
24438
24438
  parseFunctionParams(params: DecodeFunctionDataReturnType<abi$2>): Array<string> | undefined;
24439
- fetchState(toBlock: bigint): Promise<void>;
24439
+ syncState(toBlock: bigint): Promise<void>;
24440
24440
  processLog(log: Log<bigint, number, false, undefined, undefined, abi$2, ContractEventName<abi$2>>): void;
24441
+ get approvedCreditManagers(): Set<Address>;
24441
24442
  stateHuman(raw?: boolean): BotListStateHuman;
24442
24443
  }
24443
24444
 
@@ -24632,6 +24633,9 @@ interface SyncStateOptions {
24632
24633
  blockNumber: bigint;
24633
24634
  timestamp: bigint;
24634
24635
  }
24636
+ type SDKHooks = {
24637
+ syncState: [];
24638
+ };
24635
24639
  declare class GearboxSDK {
24636
24640
  #private;
24637
24641
  readonly logger?: ILogger;
@@ -24652,6 +24656,8 @@ declare class GearboxSDK {
24652
24656
  * Token metadata such as symbol and decimals
24653
24657
  */
24654
24658
  readonly tokensMeta: TokensMeta;
24659
+ addHook: <K extends "syncState">(hookName: K, fn: (...args: SDKHooks[K]) => void | Promise<void>) => void;
24660
+ removeHook: <K extends "syncState">(hookName: K, fn: (...args: SDKHooks[K]) => void | Promise<void>) => void;
24655
24661
  static attach(options: SDKOptions & Partial<NetworkOptions> & ConnectionOptions & TransportOptions): Promise<GearboxSDK>;
24656
24662
  private constructor();
24657
24663
  /**
@@ -24861,6 +24867,10 @@ declare const AP_DELEVERAGE_BOT_PEGGED = "DELEVERAGE_BOT_PEGGED";
24861
24867
  declare const AP_DELEVERAGE_BOT_LV = "DELEVERAGE_BOT_LV";
24862
24868
  declare const AP_DELEVERAGE_BOT_HV = "DELEVERAGE_BOT_HV";
24863
24869
  declare const ADDRESS_PROVIDER: Record<NetworkType, Address>;
24870
+ /**
24871
+ * Block number when address provider was deployed
24872
+ */
24873
+ declare const ADDRESS_PROVIDER_BLOCK: Record<NetworkType, bigint>;
24864
24874
 
24865
24875
  /**
24866
24876
  * Address 0x0000000000000000000000000000000000000000
@@ -24933,4 +24943,4 @@ type MulticallErrorType = GetChainContractAddressErrorType | ReadContractErrorTy
24933
24943
  */
24934
24944
  declare function simulateMulticall<const contracts extends readonly unknown[], chain extends Chain | undefined, allowFailure extends boolean = true>(client: Client<Transport, chain>, parameters: MulticallParameters<contracts, allowFailure>): Promise<MulticallReturnType<contracts, allowFailure>>;
24935
24945
 
24936
- export { ADDRESS_0X0, ADDRESS_PROVIDER, AP_ACCOUNT_FACTORY, AP_ACL, AP_ADAPTER_COMPRESSOR, AP_BOT_LIST, AP_CONTRACTS_REGISTER, AP_CONTROLLER_TIMELOCK, AP_CREDIT_ACCOUNT_COMPRESSOR, AP_DATA_COMPRESSOR, AP_DEGEN_DISTRIBUTOR, AP_DEGEN_NFT, AP_DELEVERAGE_BOT_HV, AP_DELEVERAGE_BOT_LV, AP_DELEVERAGE_BOT_PEGGED, AP_GEAR_STAKING, AP_GEAR_TOKEN, AP_INFLATION_ATTACK_BLOCKER, AP_INSOLVENCY_CHECKER, AP_MARKET_COMPRESSOR, AP_MARKET_CONFIGURATOR, AP_MULTI_PAUSE, AP_PARTIAL_LIQUIDATION_BOT, AP_PRICE_FEED_COMPRESSOR, AP_PRICE_ORACLE, AP_ROUTER, AP_TREASURY, AP_WETH_GATEWAY, AP_WETH_TOKEN, AP_ZAPPER_REGISTER, AP_ZERO_PRICE_FEED, AbstractPriceFeedContract, type AdapterContractType, type AdapterData, AddressLabeller, AddressMap, AddressProviderContractV3_1, type AddressProviderV3StateHuman, type Asset, type AssetPriceFeedStateHuman, BalancerStablePriceFeedContract, BalancerV2VaultAdapterContract, BalancerWeightedPriceFeedContract, BaseContract, type BaseContractOptions, type BaseContractStateHuman, type BaseParams, type BasePriceFeedStateHuman, BotListContract, type BotListStateHuman, BotPermissions, type BoundedOracleStateHuman, BoundedPriceFeedContract, CamelotV3AdapterContract, ChainlinkPriceFeedContract, CompositePriceFeedContract, type ConnectionOptions, type ContractMethod, ConvexV1BaseRewardPoolAdapterContract, ConvexV1BoosterAdapterContract, type CoreStateHuman, type CreditAccountData, type CreditAccountFilter, CreditAccountsService, CreditConfiguratorContract, type CreditConfiguratorState, type CreditConfiguratorStateHuman, type CreditFacadeState, type CreditFacadeStateHuman, CreditFacadeV300Contract, CreditFacadeV310Contract, CreditFactory, type CreditFactoryStateHuman, CreditManagerContract, type CreditManagerData, type CreditManagerDebtParams, type CreditManagerDebtParamsHuman, type CreditManagerState, type CreditManagerStateHuman, Curve2AssetsAdapterContract, Curve3AssetsAdapterContract, Curve4AssetsAdapterContract, CurveCryptoPriceFeedContract, type CurvePoolStruct, CurveStablePriceFeedContract, CurveUSDPriceFeedContract, CurveV1AdapterStETHContract, CurveV1AdapterStableNGContract, ERC4626AdapterContract, Erc4626PriceFeedContract, type EtherscanURLParam, type FindClosePathInput, GaugeContract, type GaugeParams, type GaugeParamsHuman, type GaugeStateHuman, GearStakingContract, type GearStakingV3StateHuman, GearboxSDK, type GearboxStateHuman, type IAdapterContract, type IBaseContract, type ILPPriceFeedContract, type ILogger, type IPriceFeedContract, LinearModelContract, type LinearModelStateHuman, type LogFn, MAX_UINT16, MAX_UINT256, MIN_INT96, type MarketData, MarketFactory, MarketRegister, type MarketStateHuman, MellowLRTPriceFeedContract, type MultiCall, type MulticallErrorType, type MulticallParameters, type MulticallReturnType, NOT_DEPLOYED, NO_VERSION, type NetworkOptions, type NetworkType, type OnDemandPriceUpdate, type OpenStrategyResult, PERCENTAGE_DECIMALS, PERCENTAGE_FACTOR, PRICE_DECIMALS, PRICE_DECIMALS_POW, type PathOption, type PathOptionSerie, PoolContract, type PoolData, PoolFactory, type PoolFactoryStateHuman, PoolQuotaKeeperContract, type PoolQuotaKeeperData, type PoolQuotaKeeperStateHuman, type PoolStateHuman, type PriceFeedConstructorArgs, type PriceFeedContractType, type PriceFeedMapEntry, PriceFeedRef, PriceFeedRegister, type PriceFeedRegisterHooks, type PriceFeedStateHuman, type PriceFeedTreeNode, type PriceFeedUsageType, PriceOracleContract, type PriceOracleData, type PriceOracleV3StateHuman, Provider, type QuotaParamsHuman, type QuotaState, RAY, RAY_DECIMALS_POW, type RateKeeperData, type RawTx, RedstonePriceFeedContract, type RedstonePriceFeedStateHuman, type RouterCloseResult, type RouterHooks, type RouterResult, RouterV3Contract, SDKConstruct, type SDKOptions, SUPPORTED_CHAINS, type SwapOperation, type SwapTask, type SyncStateOptions, TIMELOCK, type TVL, type TokenMetaData, TokensMeta, type TransportOptions, USDC, UniswapV2AdapterContract, UniswapV3AdapterContract, type UpdatePriceFeedsResult, VelodromeV2RouterAdapterContract, VotingContractStatus, WAD, WAD_DECIMALS_POW, WstETHPriceFeedContract, WstETHV1AdapterContract, YearnPriceFeedContract, YearnV2RouterAdapterContract, ZeroPriceFeedContract, botPermissionsToString, bytes32ToString, chains, childLogger, createAdapter, createRawTx, createTransport, detectNetwork, etherscanUrl, filterDust, fmtBinaryMask, formatBN, formatBNvalue, formatBn4dig, formatDuration, formatNumberToString_, halfRAY, json_parse, json_stringify, numberWithCommas, percentFmt, rawTxToMulticallPriceUpdate, simulateMulticall, toHumanFormat };
24946
+ export { ADDRESS_0X0, ADDRESS_PROVIDER, ADDRESS_PROVIDER_BLOCK, AP_ACCOUNT_FACTORY, AP_ACL, AP_ADAPTER_COMPRESSOR, AP_BOT_LIST, AP_CONTRACTS_REGISTER, AP_CONTROLLER_TIMELOCK, AP_CREDIT_ACCOUNT_COMPRESSOR, AP_DATA_COMPRESSOR, AP_DEGEN_DISTRIBUTOR, AP_DEGEN_NFT, AP_DELEVERAGE_BOT_HV, AP_DELEVERAGE_BOT_LV, AP_DELEVERAGE_BOT_PEGGED, AP_GEAR_STAKING, AP_GEAR_TOKEN, AP_INFLATION_ATTACK_BLOCKER, AP_INSOLVENCY_CHECKER, AP_MARKET_COMPRESSOR, AP_MARKET_CONFIGURATOR, AP_MULTI_PAUSE, AP_PARTIAL_LIQUIDATION_BOT, AP_PRICE_FEED_COMPRESSOR, AP_PRICE_ORACLE, AP_ROUTER, AP_TREASURY, AP_WETH_GATEWAY, AP_WETH_TOKEN, AP_ZAPPER_REGISTER, AP_ZERO_PRICE_FEED, AbstractPriceFeedContract, type AdapterContractType, type AdapterData, AddressLabeller, AddressMap, AddressProviderContractV3_1, type AddressProviderV3StateHuman, type Asset, type AssetPriceFeedStateHuman, BalancerStablePriceFeedContract, BalancerV2VaultAdapterContract, BalancerWeightedPriceFeedContract, BaseContract, type BaseContractOptions, type BaseContractStateHuman, type BaseParams, type BasePriceFeedStateHuman, BotListContract, type BotListStateHuman, BotPermissions, type BoundedOracleStateHuman, BoundedPriceFeedContract, CamelotV3AdapterContract, ChainlinkPriceFeedContract, CompositePriceFeedContract, type ConnectionOptions, type ContractMethod, ConvexV1BaseRewardPoolAdapterContract, ConvexV1BoosterAdapterContract, type CoreStateHuman, type CreditAccountData, type CreditAccountFilter, CreditAccountsService, CreditConfiguratorContract, type CreditConfiguratorState, type CreditConfiguratorStateHuman, type CreditFacadeState, type CreditFacadeStateHuman, CreditFacadeV300Contract, CreditFacadeV310Contract, CreditFactory, type CreditFactoryStateHuman, CreditManagerContract, type CreditManagerData, type CreditManagerDebtParams, type CreditManagerDebtParamsHuman, type CreditManagerState, type CreditManagerStateHuman, Curve2AssetsAdapterContract, Curve3AssetsAdapterContract, Curve4AssetsAdapterContract, CurveCryptoPriceFeedContract, type CurvePoolStruct, CurveStablePriceFeedContract, CurveUSDPriceFeedContract, CurveV1AdapterStETHContract, CurveV1AdapterStableNGContract, ERC4626AdapterContract, Erc4626PriceFeedContract, type EtherscanURLParam, type FindClosePathInput, GaugeContract, type GaugeParams, type GaugeParamsHuman, type GaugeStateHuman, GearStakingContract, type GearStakingV3StateHuman, GearboxSDK, type GearboxStateHuman, type IAdapterContract, type IBaseContract, type ILPPriceFeedContract, type ILogger, type IPriceFeedContract, LinearModelContract, type LinearModelStateHuman, type LogFn, MAX_UINT16, MAX_UINT256, MIN_INT96, type MarketData, MarketFactory, MarketRegister, type MarketStateHuman, MellowLRTPriceFeedContract, type MultiCall, type MulticallErrorType, type MulticallParameters, type MulticallReturnType, NOT_DEPLOYED, NO_VERSION, type NetworkOptions, type NetworkType, type OnDemandPriceUpdate, type OpenStrategyResult, PERCENTAGE_DECIMALS, PERCENTAGE_FACTOR, PRICE_DECIMALS, PRICE_DECIMALS_POW, type PathOption, type PathOptionSerie, PoolContract, type PoolData, PoolFactory, type PoolFactoryStateHuman, PoolQuotaKeeperContract, type PoolQuotaKeeperData, type PoolQuotaKeeperStateHuman, type PoolStateHuman, type PriceFeedConstructorArgs, type PriceFeedContractType, type PriceFeedMapEntry, PriceFeedRef, PriceFeedRegister, type PriceFeedRegisterHooks, type PriceFeedStateHuman, type PriceFeedTreeNode, type PriceFeedUsageType, PriceOracleContract, type PriceOracleData, type PriceOracleV3StateHuman, Provider, type QuotaParamsHuman, type QuotaState, RAY, RAY_DECIMALS_POW, type RateKeeperData, type RawTx, RedstonePriceFeedContract, type RedstonePriceFeedStateHuman, type RouterCloseResult, type RouterHooks, type RouterResult, RouterV3Contract, SDKConstruct, type SDKHooks, type SDKOptions, SUPPORTED_CHAINS, type SwapOperation, type SwapTask, type SyncStateOptions, TIMELOCK, type TVL, type TokenMetaData, TokensMeta, type TransportOptions, USDC, UniswapV2AdapterContract, UniswapV3AdapterContract, type UpdatePriceFeedsResult, VelodromeV2RouterAdapterContract, VotingContractStatus, WAD, WAD_DECIMALS_POW, WstETHPriceFeedContract, WstETHV1AdapterContract, YearnPriceFeedContract, YearnV2RouterAdapterContract, ZeroPriceFeedContract, botPermissionsToString, bytes32ToString, chains, childLogger, createAdapter, createRawTx, createTransport, detectNetwork, etherscanUrl, filterDust, fmtBinaryMask, formatBN, formatBNvalue, formatBn4dig, formatDuration, formatNumberToString_, halfRAY, json_parse, json_stringify, numberWithCommas, percentFmt, rawTxToMulticallPriceUpdate, simulateMulticall, toHumanFormat };
@@ -24433,11 +24433,12 @@ declare class AddressProviderContractV3_1 extends BaseContract<abi$3> {
24433
24433
 
24434
24434
  type abi$2 = typeof botListV3Abi;
24435
24435
  declare class BotListContract extends BaseContract<abi$2> {
24436
- approvedCreditManagers: Set<Address>;
24436
+ #private;
24437
24437
  constructor(sdk: GearboxSDK, address: Address);
24438
24438
  parseFunctionParams(params: DecodeFunctionDataReturnType<abi$2>): Array<string> | undefined;
24439
- fetchState(toBlock: bigint): Promise<void>;
24439
+ syncState(toBlock: bigint): Promise<void>;
24440
24440
  processLog(log: Log<bigint, number, false, undefined, undefined, abi$2, ContractEventName<abi$2>>): void;
24441
+ get approvedCreditManagers(): Set<Address>;
24441
24442
  stateHuman(raw?: boolean): BotListStateHuman;
24442
24443
  }
24443
24444
 
@@ -24632,6 +24633,9 @@ interface SyncStateOptions {
24632
24633
  blockNumber: bigint;
24633
24634
  timestamp: bigint;
24634
24635
  }
24636
+ type SDKHooks = {
24637
+ syncState: [];
24638
+ };
24635
24639
  declare class GearboxSDK {
24636
24640
  #private;
24637
24641
  readonly logger?: ILogger;
@@ -24652,6 +24656,8 @@ declare class GearboxSDK {
24652
24656
  * Token metadata such as symbol and decimals
24653
24657
  */
24654
24658
  readonly tokensMeta: TokensMeta;
24659
+ addHook: <K extends "syncState">(hookName: K, fn: (...args: SDKHooks[K]) => void | Promise<void>) => void;
24660
+ removeHook: <K extends "syncState">(hookName: K, fn: (...args: SDKHooks[K]) => void | Promise<void>) => void;
24655
24661
  static attach(options: SDKOptions & Partial<NetworkOptions> & ConnectionOptions & TransportOptions): Promise<GearboxSDK>;
24656
24662
  private constructor();
24657
24663
  /**
@@ -24861,6 +24867,10 @@ declare const AP_DELEVERAGE_BOT_PEGGED = "DELEVERAGE_BOT_PEGGED";
24861
24867
  declare const AP_DELEVERAGE_BOT_LV = "DELEVERAGE_BOT_LV";
24862
24868
  declare const AP_DELEVERAGE_BOT_HV = "DELEVERAGE_BOT_HV";
24863
24869
  declare const ADDRESS_PROVIDER: Record<NetworkType, Address>;
24870
+ /**
24871
+ * Block number when address provider was deployed
24872
+ */
24873
+ declare const ADDRESS_PROVIDER_BLOCK: Record<NetworkType, bigint>;
24864
24874
 
24865
24875
  /**
24866
24876
  * Address 0x0000000000000000000000000000000000000000
@@ -24933,4 +24943,4 @@ type MulticallErrorType = GetChainContractAddressErrorType | ReadContractErrorTy
24933
24943
  */
24934
24944
  declare function simulateMulticall<const contracts extends readonly unknown[], chain extends Chain | undefined, allowFailure extends boolean = true>(client: Client<Transport, chain>, parameters: MulticallParameters<contracts, allowFailure>): Promise<MulticallReturnType<contracts, allowFailure>>;
24935
24945
 
24936
- export { ADDRESS_0X0, ADDRESS_PROVIDER, AP_ACCOUNT_FACTORY, AP_ACL, AP_ADAPTER_COMPRESSOR, AP_BOT_LIST, AP_CONTRACTS_REGISTER, AP_CONTROLLER_TIMELOCK, AP_CREDIT_ACCOUNT_COMPRESSOR, AP_DATA_COMPRESSOR, AP_DEGEN_DISTRIBUTOR, AP_DEGEN_NFT, AP_DELEVERAGE_BOT_HV, AP_DELEVERAGE_BOT_LV, AP_DELEVERAGE_BOT_PEGGED, AP_GEAR_STAKING, AP_GEAR_TOKEN, AP_INFLATION_ATTACK_BLOCKER, AP_INSOLVENCY_CHECKER, AP_MARKET_COMPRESSOR, AP_MARKET_CONFIGURATOR, AP_MULTI_PAUSE, AP_PARTIAL_LIQUIDATION_BOT, AP_PRICE_FEED_COMPRESSOR, AP_PRICE_ORACLE, AP_ROUTER, AP_TREASURY, AP_WETH_GATEWAY, AP_WETH_TOKEN, AP_ZAPPER_REGISTER, AP_ZERO_PRICE_FEED, AbstractPriceFeedContract, type AdapterContractType, type AdapterData, AddressLabeller, AddressMap, AddressProviderContractV3_1, type AddressProviderV3StateHuman, type Asset, type AssetPriceFeedStateHuman, BalancerStablePriceFeedContract, BalancerV2VaultAdapterContract, BalancerWeightedPriceFeedContract, BaseContract, type BaseContractOptions, type BaseContractStateHuman, type BaseParams, type BasePriceFeedStateHuman, BotListContract, type BotListStateHuman, BotPermissions, type BoundedOracleStateHuman, BoundedPriceFeedContract, CamelotV3AdapterContract, ChainlinkPriceFeedContract, CompositePriceFeedContract, type ConnectionOptions, type ContractMethod, ConvexV1BaseRewardPoolAdapterContract, ConvexV1BoosterAdapterContract, type CoreStateHuman, type CreditAccountData, type CreditAccountFilter, CreditAccountsService, CreditConfiguratorContract, type CreditConfiguratorState, type CreditConfiguratorStateHuman, type CreditFacadeState, type CreditFacadeStateHuman, CreditFacadeV300Contract, CreditFacadeV310Contract, CreditFactory, type CreditFactoryStateHuman, CreditManagerContract, type CreditManagerData, type CreditManagerDebtParams, type CreditManagerDebtParamsHuman, type CreditManagerState, type CreditManagerStateHuman, Curve2AssetsAdapterContract, Curve3AssetsAdapterContract, Curve4AssetsAdapterContract, CurveCryptoPriceFeedContract, type CurvePoolStruct, CurveStablePriceFeedContract, CurveUSDPriceFeedContract, CurveV1AdapterStETHContract, CurveV1AdapterStableNGContract, ERC4626AdapterContract, Erc4626PriceFeedContract, type EtherscanURLParam, type FindClosePathInput, GaugeContract, type GaugeParams, type GaugeParamsHuman, type GaugeStateHuman, GearStakingContract, type GearStakingV3StateHuman, GearboxSDK, type GearboxStateHuman, type IAdapterContract, type IBaseContract, type ILPPriceFeedContract, type ILogger, type IPriceFeedContract, LinearModelContract, type LinearModelStateHuman, type LogFn, MAX_UINT16, MAX_UINT256, MIN_INT96, type MarketData, MarketFactory, MarketRegister, type MarketStateHuman, MellowLRTPriceFeedContract, type MultiCall, type MulticallErrorType, type MulticallParameters, type MulticallReturnType, NOT_DEPLOYED, NO_VERSION, type NetworkOptions, type NetworkType, type OnDemandPriceUpdate, type OpenStrategyResult, PERCENTAGE_DECIMALS, PERCENTAGE_FACTOR, PRICE_DECIMALS, PRICE_DECIMALS_POW, type PathOption, type PathOptionSerie, PoolContract, type PoolData, PoolFactory, type PoolFactoryStateHuman, PoolQuotaKeeperContract, type PoolQuotaKeeperData, type PoolQuotaKeeperStateHuman, type PoolStateHuman, type PriceFeedConstructorArgs, type PriceFeedContractType, type PriceFeedMapEntry, PriceFeedRef, PriceFeedRegister, type PriceFeedRegisterHooks, type PriceFeedStateHuman, type PriceFeedTreeNode, type PriceFeedUsageType, PriceOracleContract, type PriceOracleData, type PriceOracleV3StateHuman, Provider, type QuotaParamsHuman, type QuotaState, RAY, RAY_DECIMALS_POW, type RateKeeperData, type RawTx, RedstonePriceFeedContract, type RedstonePriceFeedStateHuman, type RouterCloseResult, type RouterHooks, type RouterResult, RouterV3Contract, SDKConstruct, type SDKOptions, SUPPORTED_CHAINS, type SwapOperation, type SwapTask, type SyncStateOptions, TIMELOCK, type TVL, type TokenMetaData, TokensMeta, type TransportOptions, USDC, UniswapV2AdapterContract, UniswapV3AdapterContract, type UpdatePriceFeedsResult, VelodromeV2RouterAdapterContract, VotingContractStatus, WAD, WAD_DECIMALS_POW, WstETHPriceFeedContract, WstETHV1AdapterContract, YearnPriceFeedContract, YearnV2RouterAdapterContract, ZeroPriceFeedContract, botPermissionsToString, bytes32ToString, chains, childLogger, createAdapter, createRawTx, createTransport, detectNetwork, etherscanUrl, filterDust, fmtBinaryMask, formatBN, formatBNvalue, formatBn4dig, formatDuration, formatNumberToString_, halfRAY, json_parse, json_stringify, numberWithCommas, percentFmt, rawTxToMulticallPriceUpdate, simulateMulticall, toHumanFormat };
24946
+ export { ADDRESS_0X0, ADDRESS_PROVIDER, ADDRESS_PROVIDER_BLOCK, AP_ACCOUNT_FACTORY, AP_ACL, AP_ADAPTER_COMPRESSOR, AP_BOT_LIST, AP_CONTRACTS_REGISTER, AP_CONTROLLER_TIMELOCK, AP_CREDIT_ACCOUNT_COMPRESSOR, AP_DATA_COMPRESSOR, AP_DEGEN_DISTRIBUTOR, AP_DEGEN_NFT, AP_DELEVERAGE_BOT_HV, AP_DELEVERAGE_BOT_LV, AP_DELEVERAGE_BOT_PEGGED, AP_GEAR_STAKING, AP_GEAR_TOKEN, AP_INFLATION_ATTACK_BLOCKER, AP_INSOLVENCY_CHECKER, AP_MARKET_COMPRESSOR, AP_MARKET_CONFIGURATOR, AP_MULTI_PAUSE, AP_PARTIAL_LIQUIDATION_BOT, AP_PRICE_FEED_COMPRESSOR, AP_PRICE_ORACLE, AP_ROUTER, AP_TREASURY, AP_WETH_GATEWAY, AP_WETH_TOKEN, AP_ZAPPER_REGISTER, AP_ZERO_PRICE_FEED, AbstractPriceFeedContract, type AdapterContractType, type AdapterData, AddressLabeller, AddressMap, AddressProviderContractV3_1, type AddressProviderV3StateHuman, type Asset, type AssetPriceFeedStateHuman, BalancerStablePriceFeedContract, BalancerV2VaultAdapterContract, BalancerWeightedPriceFeedContract, BaseContract, type BaseContractOptions, type BaseContractStateHuman, type BaseParams, type BasePriceFeedStateHuman, BotListContract, type BotListStateHuman, BotPermissions, type BoundedOracleStateHuman, BoundedPriceFeedContract, CamelotV3AdapterContract, ChainlinkPriceFeedContract, CompositePriceFeedContract, type ConnectionOptions, type ContractMethod, ConvexV1BaseRewardPoolAdapterContract, ConvexV1BoosterAdapterContract, type CoreStateHuman, type CreditAccountData, type CreditAccountFilter, CreditAccountsService, CreditConfiguratorContract, type CreditConfiguratorState, type CreditConfiguratorStateHuman, type CreditFacadeState, type CreditFacadeStateHuman, CreditFacadeV300Contract, CreditFacadeV310Contract, CreditFactory, type CreditFactoryStateHuman, CreditManagerContract, type CreditManagerData, type CreditManagerDebtParams, type CreditManagerDebtParamsHuman, type CreditManagerState, type CreditManagerStateHuman, Curve2AssetsAdapterContract, Curve3AssetsAdapterContract, Curve4AssetsAdapterContract, CurveCryptoPriceFeedContract, type CurvePoolStruct, CurveStablePriceFeedContract, CurveUSDPriceFeedContract, CurveV1AdapterStETHContract, CurveV1AdapterStableNGContract, ERC4626AdapterContract, Erc4626PriceFeedContract, type EtherscanURLParam, type FindClosePathInput, GaugeContract, type GaugeParams, type GaugeParamsHuman, type GaugeStateHuman, GearStakingContract, type GearStakingV3StateHuman, GearboxSDK, type GearboxStateHuman, type IAdapterContract, type IBaseContract, type ILPPriceFeedContract, type ILogger, type IPriceFeedContract, LinearModelContract, type LinearModelStateHuman, type LogFn, MAX_UINT16, MAX_UINT256, MIN_INT96, type MarketData, MarketFactory, MarketRegister, type MarketStateHuman, MellowLRTPriceFeedContract, type MultiCall, type MulticallErrorType, type MulticallParameters, type MulticallReturnType, NOT_DEPLOYED, NO_VERSION, type NetworkOptions, type NetworkType, type OnDemandPriceUpdate, type OpenStrategyResult, PERCENTAGE_DECIMALS, PERCENTAGE_FACTOR, PRICE_DECIMALS, PRICE_DECIMALS_POW, type PathOption, type PathOptionSerie, PoolContract, type PoolData, PoolFactory, type PoolFactoryStateHuman, PoolQuotaKeeperContract, type PoolQuotaKeeperData, type PoolQuotaKeeperStateHuman, type PoolStateHuman, type PriceFeedConstructorArgs, type PriceFeedContractType, type PriceFeedMapEntry, PriceFeedRef, PriceFeedRegister, type PriceFeedRegisterHooks, type PriceFeedStateHuman, type PriceFeedTreeNode, type PriceFeedUsageType, PriceOracleContract, type PriceOracleData, type PriceOracleV3StateHuman, Provider, type QuotaParamsHuman, type QuotaState, RAY, RAY_DECIMALS_POW, type RateKeeperData, type RawTx, RedstonePriceFeedContract, type RedstonePriceFeedStateHuman, type RouterCloseResult, type RouterHooks, type RouterResult, RouterV3Contract, SDKConstruct, type SDKHooks, type SDKOptions, SUPPORTED_CHAINS, type SwapOperation, type SwapTask, type SyncStateOptions, TIMELOCK, type TVL, type TokenMetaData, TokensMeta, type TransportOptions, USDC, UniswapV2AdapterContract, UniswapV3AdapterContract, type UpdatePriceFeedsResult, VelodromeV2RouterAdapterContract, VotingContractStatus, WAD, WAD_DECIMALS_POW, WstETHPriceFeedContract, WstETHV1AdapterContract, YearnPriceFeedContract, YearnV2RouterAdapterContract, ZeroPriceFeedContract, botPermissionsToString, bytes32ToString, chains, childLogger, createAdapter, createRawTx, createTransport, detectNetwork, etherscanUrl, filterDust, fmtBinaryMask, formatBN, formatBNvalue, formatBn4dig, formatDuration, formatNumberToString_, halfRAY, json_parse, json_stringify, numberWithCommas, percentFmt, rawTxToMulticallPriceUpdate, simulateMulticall, toHumanFormat };
@@ -19095,6 +19095,12 @@ var ADDRESS_PROVIDER = {
19095
19095
  Optimism: "0x3761ca4BFAcFCFFc1B8034e69F19116dD6756726",
19096
19096
  Base: NOT_DEPLOYED
19097
19097
  };
19098
+ var ADDRESS_PROVIDER_BLOCK = {
19099
+ Mainnet: 18433056n,
19100
+ Arbitrum: 184650310n,
19101
+ Optimism: 118410666n,
19102
+ Base: 0n
19103
+ };
19098
19104
 
19099
19105
  // src/sdk/constants/bot-permissions.ts
19100
19106
  var BotPermissions = /* @__PURE__ */ ((BotPermissions2) => {
@@ -22484,9 +22490,11 @@ var AddressProviderContractV3_1 = class extends BaseContract {
22484
22490
 
22485
22491
  // src/sdk/core/BotListV3Contract.ts
22486
22492
  var BotListContract = class extends BaseContract {
22487
- approvedCreditManagers = /* @__PURE__ */ new Set();
22493
+ #approvedCreditManagers;
22494
+ #currentBlock;
22488
22495
  constructor(sdk, address) {
22489
22496
  super(sdk, { addr: address, name: "BotListV3", abi: botListV3Abi });
22497
+ this.#currentBlock = ADDRESS_PROVIDER_BLOCK[sdk.provider.networkType];
22490
22498
  }
22491
22499
  parseFunctionParams(params) {
22492
22500
  switch (params.functionName) {
@@ -22506,14 +22514,15 @@ var BotListContract = class extends BaseContract {
22506
22514
  return void 0;
22507
22515
  }
22508
22516
  }
22509
- async fetchState(toBlock) {
22517
+ async syncState(toBlock) {
22510
22518
  const logs = await this.provider.publicClient.getContractEvents({
22511
22519
  address: this.address,
22512
22520
  abi: this.abi,
22513
- fromBlock: 0n,
22521
+ fromBlock: this.#currentBlock,
22514
22522
  toBlock
22515
22523
  });
22516
22524
  logs.forEach((e) => this.processLog(e));
22525
+ this.#currentBlock = toBlock;
22517
22526
  }
22518
22527
  processLog(log) {
22519
22528
  switch (log.eventName) {
@@ -22536,6 +22545,14 @@ var BotListContract = class extends BaseContract {
22536
22545
  break;
22537
22546
  }
22538
22547
  }
22548
+ get approvedCreditManagers() {
22549
+ if (!this.#approvedCreditManagers) {
22550
+ throw new Error(
22551
+ "BotListContract state needs to be synced to load approvedCreditManagers"
22552
+ );
22553
+ }
22554
+ return this.#approvedCreditManagers;
22555
+ }
22539
22556
  stateHuman(raw = true) {
22540
22557
  return super.stateHuman(raw);
22541
22558
  }
@@ -22896,6 +22913,7 @@ function assetsMap(assets) {
22896
22913
 
22897
22914
  // src/sdk/GearboxSDK.ts
22898
22915
  var GearboxSDK = class _GearboxSDK {
22916
+ #hooks = new Hooks();
22899
22917
  // Represents chain object
22900
22918
  #provider;
22901
22919
  // Block which was use for data query
@@ -22929,6 +22947,8 @@ var GearboxSDK = class _GearboxSDK {
22929
22947
  * Token metadata such as symbol and decimals
22930
22948
  */
22931
22949
  tokensMeta = new TokensMeta();
22950
+ addHook = this.#hooks.addHook.bind(this.#hooks);
22951
+ removeHook = this.#hooks.removeHook.bind(this.#hooks);
22932
22952
  static async attach(options) {
22933
22953
  const { logger, riskCurators, blockNumber } = options;
22934
22954
  let { networkType, addressProvider, chainId } = options;
@@ -22980,7 +23000,6 @@ var GearboxSDK = class _GearboxSDK {
22980
23000
  await this.#addressProvider.fetchState(this.currentBlock);
22981
23001
  const botListAddress = this.#addressProvider.getAddress(AP_BOT_LIST, 300);
22982
23002
  this.#botListContract = new BotListContract(this, botListAddress);
22983
- await this.#botListContract.fetchState(this.currentBlock);
22984
23003
  this.#gear = this.#addressProvider.getAddress(AP_GEAR_TOKEN);
22985
23004
  const gearStakingAddress = this.#addressProvider.getAddress(
22986
23005
  AP_GEAR_STAKING,
@@ -23081,6 +23100,7 @@ var GearboxSDK = class _GearboxSDK {
23081
23100
  await this.marketRegister.syncState();
23082
23101
  this.#currentBlock = blockNumber;
23083
23102
  this.#timestamp = timestamp;
23103
+ await this.#hooks.triggerHooks("syncState");
23084
23104
  this.#syncing = false;
23085
23105
  this.logger?.debug(`synced state to block ${blockNumber}`);
23086
23106
  }
@@ -23137,4 +23157,4 @@ var GearboxSDK = class _GearboxSDK {
23137
23157
  }
23138
23158
  };
23139
23159
 
23140
- export { ADDRESS_0X0, ADDRESS_PROVIDER, AP_ACCOUNT_FACTORY, AP_ACL, AP_ADAPTER_COMPRESSOR, AP_BOT_LIST, AP_CONTRACTS_REGISTER, AP_CONTROLLER_TIMELOCK, AP_CREDIT_ACCOUNT_COMPRESSOR, AP_DATA_COMPRESSOR, AP_DEGEN_DISTRIBUTOR, AP_DEGEN_NFT, AP_DELEVERAGE_BOT_HV, AP_DELEVERAGE_BOT_LV, AP_DELEVERAGE_BOT_PEGGED, AP_GEAR_STAKING, AP_GEAR_TOKEN, AP_INFLATION_ATTACK_BLOCKER, AP_INSOLVENCY_CHECKER, AP_MARKET_COMPRESSOR, AP_MARKET_CONFIGURATOR, AP_MULTI_PAUSE, AP_PARTIAL_LIQUIDATION_BOT, AP_PRICE_FEED_COMPRESSOR, AP_PRICE_ORACLE, AP_ROUTER, AP_TREASURY, AP_WETH_GATEWAY, AP_WETH_TOKEN, AP_ZAPPER_REGISTER, AP_ZERO_PRICE_FEED, AbstractPriceFeedContract, AddressLabeller, AddressMap, AddressProviderContractV3_1, BalancerStablePriceFeedContract, BalancerV2VaultAdapterContract, BalancerWeightedPriceFeedContract, BaseContract, BotListContract, BotPermissions, BoundedPriceFeedContract, CamelotV3AdapterContract, ChainlinkPriceFeedContract, CompositePriceFeedContract, ConvexV1BaseRewardPoolAdapterContract, ConvexV1BoosterAdapterContract, CreditAccountsService, CreditConfiguratorContract, CreditFacadeV300Contract, CreditFacadeV310Contract, CreditFactory, CreditManagerContract, Curve2AssetsAdapterContract, Curve3AssetsAdapterContract, Curve4AssetsAdapterContract, CurveCryptoPriceFeedContract, CurveStablePriceFeedContract, CurveUSDPriceFeedContract, CurveV1AdapterStETHContract, CurveV1AdapterStableNGContract, ERC4626AdapterContract, Erc4626PriceFeedContract, GaugeContract, GearStakingContract, GearboxSDK, LinearModelContract, MAX_UINT16, MAX_UINT256, MIN_INT96, MarketFactory, MarketRegister, MellowLRTPriceFeedContract, NOT_DEPLOYED, NO_VERSION, PERCENTAGE_DECIMALS, PERCENTAGE_FACTOR, PRICE_DECIMALS, PRICE_DECIMALS_POW, PoolContract, PoolFactory, PoolQuotaKeeperContract, PriceFeedRef, PriceFeedRegister, PriceOracleContract, Provider, RAY, RAY_DECIMALS_POW, RedstonePriceFeedContract, RouterV3Contract, SDKConstruct, SUPPORTED_CHAINS, TIMELOCK, TokensMeta, USDC, UniswapV2AdapterContract, UniswapV3AdapterContract, VelodromeV2RouterAdapterContract, VotingContractStatus, WAD, WAD_DECIMALS_POW, WstETHPriceFeedContract, WstETHV1AdapterContract, YearnPriceFeedContract, YearnV2RouterAdapterContract, ZeroPriceFeedContract, botPermissionsToString, bytes32ToString, chains, childLogger, createAdapter, createRawTx, createTransport, detectNetwork, etherscanUrl, filterDust, fmtBinaryMask, formatBN, formatBNvalue, formatBn4dig, formatDuration, formatNumberToString_, halfRAY, json_parse, json_stringify, numberWithCommas, percentFmt, rawTxToMulticallPriceUpdate, simulateMulticall, toHumanFormat };
23160
+ export { ADDRESS_0X0, ADDRESS_PROVIDER, ADDRESS_PROVIDER_BLOCK, AP_ACCOUNT_FACTORY, AP_ACL, AP_ADAPTER_COMPRESSOR, AP_BOT_LIST, AP_CONTRACTS_REGISTER, AP_CONTROLLER_TIMELOCK, AP_CREDIT_ACCOUNT_COMPRESSOR, AP_DATA_COMPRESSOR, AP_DEGEN_DISTRIBUTOR, AP_DEGEN_NFT, AP_DELEVERAGE_BOT_HV, AP_DELEVERAGE_BOT_LV, AP_DELEVERAGE_BOT_PEGGED, AP_GEAR_STAKING, AP_GEAR_TOKEN, AP_INFLATION_ATTACK_BLOCKER, AP_INSOLVENCY_CHECKER, AP_MARKET_COMPRESSOR, AP_MARKET_CONFIGURATOR, AP_MULTI_PAUSE, AP_PARTIAL_LIQUIDATION_BOT, AP_PRICE_FEED_COMPRESSOR, AP_PRICE_ORACLE, AP_ROUTER, AP_TREASURY, AP_WETH_GATEWAY, AP_WETH_TOKEN, AP_ZAPPER_REGISTER, AP_ZERO_PRICE_FEED, AbstractPriceFeedContract, AddressLabeller, AddressMap, AddressProviderContractV3_1, BalancerStablePriceFeedContract, BalancerV2VaultAdapterContract, BalancerWeightedPriceFeedContract, BaseContract, BotListContract, BotPermissions, BoundedPriceFeedContract, CamelotV3AdapterContract, ChainlinkPriceFeedContract, CompositePriceFeedContract, ConvexV1BaseRewardPoolAdapterContract, ConvexV1BoosterAdapterContract, CreditAccountsService, CreditConfiguratorContract, CreditFacadeV300Contract, CreditFacadeV310Contract, CreditFactory, CreditManagerContract, Curve2AssetsAdapterContract, Curve3AssetsAdapterContract, Curve4AssetsAdapterContract, CurveCryptoPriceFeedContract, CurveStablePriceFeedContract, CurveUSDPriceFeedContract, CurveV1AdapterStETHContract, CurveV1AdapterStableNGContract, ERC4626AdapterContract, Erc4626PriceFeedContract, GaugeContract, GearStakingContract, GearboxSDK, LinearModelContract, MAX_UINT16, MAX_UINT256, MIN_INT96, MarketFactory, MarketRegister, MellowLRTPriceFeedContract, NOT_DEPLOYED, NO_VERSION, PERCENTAGE_DECIMALS, PERCENTAGE_FACTOR, PRICE_DECIMALS, PRICE_DECIMALS_POW, PoolContract, PoolFactory, PoolQuotaKeeperContract, PriceFeedRef, PriceFeedRegister, PriceOracleContract, Provider, RAY, RAY_DECIMALS_POW, RedstonePriceFeedContract, RouterV3Contract, SDKConstruct, SUPPORTED_CHAINS, TIMELOCK, TokensMeta, USDC, UniswapV2AdapterContract, UniswapV3AdapterContract, VelodromeV2RouterAdapterContract, VotingContractStatus, WAD, WAD_DECIMALS_POW, WstETHPriceFeedContract, WstETHV1AdapterContract, YearnPriceFeedContract, YearnV2RouterAdapterContract, ZeroPriceFeedContract, botPermissionsToString, bytes32ToString, chains, childLogger, createAdapter, createRawTx, createTransport, detectNetwork, etherscanUrl, filterDust, fmtBinaryMask, formatBN, formatBNvalue, formatBn4dig, formatDuration, formatNumberToString_, halfRAY, json_parse, json_stringify, numberWithCommas, percentFmt, rawTxToMulticallPriceUpdate, simulateMulticall, toHumanFormat };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gearbox-protocol/sdk",
3
- "version": "3.0.0-vfour.61",
3
+ "version": "3.0.0-vfour.63",
4
4
  "description": "Gearbox SDK",
5
5
  "license": "MIT",
6
6
  "main": "./dist/cjs/sdk/index.cjs",