@gearbox-protocol/sdk 3.0.0-vfour.17 → 3.0.0-vfour.18
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.
- package/dist/cjs/sdk/index.cjs +41 -7
- package/dist/cjs/sdk/index.d.ts +43 -27
- package/dist/esm/sdk/index.d.mts +43 -27
- package/dist/esm/sdk/index.mjs +41 -7
- package/package.json +2 -3
package/dist/cjs/sdk/index.cjs
CHANGED
|
@@ -5,7 +5,6 @@ var utils = require('viem/utils');
|
|
|
5
5
|
var dateFns = require('date-fns');
|
|
6
6
|
var chains$1 = require('viem/chains');
|
|
7
7
|
var actions = require('viem/actions');
|
|
8
|
-
var eventemitter3 = require('eventemitter3');
|
|
9
8
|
var evmConnector = require('@redstone-finance/evm-connector');
|
|
10
9
|
var redstoneProtocol = require('redstone-protocol');
|
|
11
10
|
var sdkGov = require('@gearbox-protocol/sdk-gov');
|
|
@@ -14540,6 +14539,31 @@ var MellowLRTPriceFeedContract = class extends AbstractLPPriceFeedContract {
|
|
|
14540
14539
|
return stack.totalValue * BigInt(1e18) / stack.totalSupply;
|
|
14541
14540
|
}
|
|
14542
14541
|
};
|
|
14542
|
+
|
|
14543
|
+
// src/sdk/utils/internal/Hooks.ts
|
|
14544
|
+
var Hooks = class {
|
|
14545
|
+
#reg = {};
|
|
14546
|
+
addHook(hookName, fn) {
|
|
14547
|
+
if (!this.#reg[hookName]) {
|
|
14548
|
+
this.#reg[hookName] = [];
|
|
14549
|
+
}
|
|
14550
|
+
this.#reg[hookName].push(fn);
|
|
14551
|
+
}
|
|
14552
|
+
removeHook(hookName, fn) {
|
|
14553
|
+
if (!this.#reg[hookName]) {
|
|
14554
|
+
return;
|
|
14555
|
+
}
|
|
14556
|
+
this.#reg[hookName] = this.#reg[hookName]?.filter((hookFn) => hookFn !== fn) ?? [];
|
|
14557
|
+
}
|
|
14558
|
+
async triggerHooks(hookName, ...args) {
|
|
14559
|
+
if (!this.#reg[hookName]) {
|
|
14560
|
+
return;
|
|
14561
|
+
}
|
|
14562
|
+
for (const fn of this.#reg[hookName]) {
|
|
14563
|
+
await fn(...args);
|
|
14564
|
+
}
|
|
14565
|
+
}
|
|
14566
|
+
};
|
|
14543
14567
|
var RedstonePriceFeedContract = class extends AbstractPriceFeedContract {
|
|
14544
14568
|
decimals = 8;
|
|
14545
14569
|
dataServiceId;
|
|
@@ -14890,6 +14914,7 @@ var ZeroPriceFeedContract = class extends AbstractPriceFeedContract {
|
|
|
14890
14914
|
// src/sdk/market/pricefeeds/PriceFeedsRegister.ts
|
|
14891
14915
|
var PriceFeedRegister = class extends SDKConstruct {
|
|
14892
14916
|
logger;
|
|
14917
|
+
#hooks = new Hooks();
|
|
14893
14918
|
#feeds = new AddressMap();
|
|
14894
14919
|
#redstoneUpdater;
|
|
14895
14920
|
// public readonly zeroPriceFeed: ZeroPriceFeedContract;
|
|
@@ -14898,6 +14923,8 @@ var PriceFeedRegister = class extends SDKConstruct {
|
|
|
14898
14923
|
this.logger = childLogger("PriceFeedRegister", sdk.logger);
|
|
14899
14924
|
this.#redstoneUpdater = new RedstoneUpdater(sdk);
|
|
14900
14925
|
}
|
|
14926
|
+
addHook = this.#hooks.addHook.bind(this);
|
|
14927
|
+
removeHook = this.#hooks.removeHook.bind(this);
|
|
14901
14928
|
/**
|
|
14902
14929
|
* Returns RawTxs to update price feeds
|
|
14903
14930
|
* @param priceFeeds top-level price feeds, actual updatable price feeds will be derived. If not provided will use all price feeds that are attached
|
|
@@ -14927,7 +14954,9 @@ var PriceFeedRegister = class extends SDKConstruct {
|
|
|
14927
14954
|
txs.push(tx);
|
|
14928
14955
|
}
|
|
14929
14956
|
}
|
|
14930
|
-
|
|
14957
|
+
const result = { txs, timestamp: maxTimestamp };
|
|
14958
|
+
await this.#hooks.triggerHooks("updatesGenerated", result);
|
|
14959
|
+
return result;
|
|
14931
14960
|
}
|
|
14932
14961
|
get(address) {
|
|
14933
14962
|
return this.#feeds.get(address);
|
|
@@ -15055,7 +15084,7 @@ var PriceOracleContract = class extends BaseContract {
|
|
|
15055
15084
|
* Generates updates for all updateable price feeds in this oracle (including dependencies)
|
|
15056
15085
|
* @returns
|
|
15057
15086
|
*/
|
|
15058
|
-
async
|
|
15087
|
+
async updatePriceFeeds() {
|
|
15059
15088
|
const updatables = [];
|
|
15060
15089
|
for (const node of this.#priceFeedTree) {
|
|
15061
15090
|
if (node.updatable) {
|
|
@@ -15451,6 +15480,7 @@ var SWAP_OPERATIONS = {
|
|
|
15451
15480
|
};
|
|
15452
15481
|
var RouterV3Contract = class extends BaseContract {
|
|
15453
15482
|
#connectors;
|
|
15483
|
+
#hooks = new Hooks();
|
|
15454
15484
|
constructor(sdk, address) {
|
|
15455
15485
|
super(sdk, {
|
|
15456
15486
|
addr: address,
|
|
@@ -15459,6 +15489,8 @@ var RouterV3Contract = class extends BaseContract {
|
|
|
15459
15489
|
});
|
|
15460
15490
|
this.#connectors = sdkGov.getConnectors(sdk.provider.networkType);
|
|
15461
15491
|
}
|
|
15492
|
+
addHook = this.#hooks.addHook.bind(this);
|
|
15493
|
+
removeHook = this.#hooks.removeHook.bind(this);
|
|
15462
15494
|
/**
|
|
15463
15495
|
* Finds all available swaps for NORMAL tokens
|
|
15464
15496
|
* @param ca
|
|
@@ -15592,7 +15624,10 @@ var RouterV3Contract = class extends BaseContract {
|
|
|
15592
15624
|
*/
|
|
15593
15625
|
async findBestClosePath(ca, cm, slippage) {
|
|
15594
15626
|
const { pathOptions, expected, leftover, connectors } = this.getFindClosePathInput(ca, cm);
|
|
15595
|
-
this.
|
|
15627
|
+
await this.#hooks.triggerHooks("foundPathOptions", {
|
|
15628
|
+
creditAccount: ca.creditAccount,
|
|
15629
|
+
pathOptions
|
|
15630
|
+
});
|
|
15596
15631
|
let results = [];
|
|
15597
15632
|
for (const po of pathOptions) {
|
|
15598
15633
|
const { result: result2 } = await this.contract.simulate.findBestClosePath(
|
|
@@ -15627,7 +15662,7 @@ var RouterV3Contract = class extends BaseContract {
|
|
|
15627
15662
|
})),
|
|
15628
15663
|
underlyingBalance: underlyingBalance + bestResult.minAmount
|
|
15629
15664
|
};
|
|
15630
|
-
this.
|
|
15665
|
+
await this.#hooks.triggerHooks("foundBestClosePath", {
|
|
15631
15666
|
creditAccount: ca.creditAccount,
|
|
15632
15667
|
...result
|
|
15633
15668
|
});
|
|
@@ -15687,7 +15722,7 @@ function assetsMap(assets) {
|
|
|
15687
15722
|
}
|
|
15688
15723
|
|
|
15689
15724
|
// src/sdk/GearboxSDK.ts
|
|
15690
|
-
var GearboxSDK = class _GearboxSDK
|
|
15725
|
+
var GearboxSDK = class _GearboxSDK {
|
|
15691
15726
|
// Represents chain object
|
|
15692
15727
|
#provider;
|
|
15693
15728
|
// Block which was use for data query
|
|
@@ -15750,7 +15785,6 @@ var GearboxSDK = class _GearboxSDK extends eventemitter3.EventEmitter {
|
|
|
15750
15785
|
}).#attach(addressProvider, riskCurators);
|
|
15751
15786
|
}
|
|
15752
15787
|
constructor(options) {
|
|
15753
|
-
super();
|
|
15754
15788
|
this.#provider = options.provider;
|
|
15755
15789
|
this.logger = options.logger;
|
|
15756
15790
|
this.priceFeeds = new PriceFeedRegister(this);
|
package/dist/cjs/sdk/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Address, Chain, PublicClient, Transport, Hex, Abi, DecodeFunctionDataReturnType, Log, ContractFunctionName, EncodeFunctionDataParameters, TransactionReceipt, GetContractReturnType, Client, Prettify, TestActions, WalletClient, TestRpcSchema, Block, ContractFunctionParameters, CallParameters, MulticallContracts, Narrow, AbiStateMutability, MulticallResults, GetChainContractAddressErrorType, ReadContractErrorType, GetContractErrorReturnType, EncodeFunctionDataErrorType, DecodeFunctionResultErrorType } from 'viem';
|
|
2
|
-
import { EventEmitter } from 'eventemitter3';
|
|
3
2
|
import { RouterComponentRegister, TokenTypeToResolver } from '@gearbox-protocol/sdk-gov';
|
|
4
3
|
import { AbiParametersToPrimitiveTypes, ExtractAbiFunction } from 'abitype';
|
|
5
4
|
|
|
@@ -14867,15 +14866,28 @@ declare class MellowLRTPriceFeedContract extends AbstractLPPriceFeedContract<abi
|
|
|
14867
14866
|
getValue(): Promise<bigint>;
|
|
14868
14867
|
}
|
|
14869
14868
|
|
|
14869
|
+
interface IHooks<HookMap extends Record<string, any[]>> {
|
|
14870
|
+
addHook: <K extends keyof HookMap>(hookName: K, fn: (...args: HookMap[K]) => void | Promise<void>) => void;
|
|
14871
|
+
removeHook: <K extends keyof HookMap>(hookName: K, fn: (...args: HookMap[K]) => void | Promise<void>) => void;
|
|
14872
|
+
}
|
|
14873
|
+
|
|
14874
|
+
type PriceFeedRegisterHooks = {
|
|
14875
|
+
/**
|
|
14876
|
+
* Emitted when transactions to update price feeds have been generated, but before they're used anywhere
|
|
14877
|
+
*/
|
|
14878
|
+
updatesGenerated: [UpdatePriceFeedsResult];
|
|
14879
|
+
};
|
|
14870
14880
|
/**
|
|
14871
14881
|
* PriceFeedRegister acts as a chain-level cache to avoid creating multiple contract instances.
|
|
14872
14882
|
* It's reused by PriceFeedFactory belonging to different markets
|
|
14873
14883
|
*
|
|
14874
14884
|
**/
|
|
14875
|
-
declare class PriceFeedRegister extends SDKConstruct {
|
|
14885
|
+
declare class PriceFeedRegister extends SDKConstruct implements IHooks<PriceFeedRegisterHooks> {
|
|
14876
14886
|
#private;
|
|
14877
14887
|
readonly logger?: ILogger;
|
|
14878
14888
|
constructor(sdk: GearboxSDK);
|
|
14889
|
+
addHook: <K extends "updatesGenerated">(hookName: K, fn: (...args: PriceFeedRegisterHooks[K]) => void | Promise<void>) => void;
|
|
14890
|
+
removeHook: <K extends "updatesGenerated">(hookName: K, fn: (...args: PriceFeedRegisterHooks[K]) => void | Promise<void>) => void;
|
|
14879
14891
|
/**
|
|
14880
14892
|
* Returns RawTxs to update price feeds
|
|
14881
14893
|
* @param priceFeeds top-level price feeds, actual updatable price feeds will be derived. If not provided will use all price feeds that are attached
|
|
@@ -16869,7 +16881,7 @@ declare class PriceOracleContract extends BaseContract<abi$1> {
|
|
|
16869
16881
|
* Generates updates for all updateable price feeds in this oracle (including dependencies)
|
|
16870
16882
|
* @returns
|
|
16871
16883
|
*/
|
|
16872
|
-
|
|
16884
|
+
updatePriceFeeds(): Promise<UpdatePriceFeedsResult>;
|
|
16873
16885
|
/**
|
|
16874
16886
|
* Converts previously obtained price updates into CreditFacade multicall entries
|
|
16875
16887
|
* @param creditFacade
|
|
@@ -16968,6 +16980,29 @@ interface FindClosePathInput {
|
|
|
16968
16980
|
leftover: Asset[];
|
|
16969
16981
|
connectors: Address[];
|
|
16970
16982
|
}
|
|
16983
|
+
type RouterHooks = {
|
|
16984
|
+
/**
|
|
16985
|
+
* Internal router event
|
|
16986
|
+
*/
|
|
16987
|
+
foundPathOptions: [
|
|
16988
|
+
{
|
|
16989
|
+
creditAccount: Address;
|
|
16990
|
+
pathOptions: PathOptionSerie[];
|
|
16991
|
+
}
|
|
16992
|
+
];
|
|
16993
|
+
/**
|
|
16994
|
+
* Internal router event
|
|
16995
|
+
*/
|
|
16996
|
+
foundBestClosePath: [
|
|
16997
|
+
{
|
|
16998
|
+
creditAccount: Address;
|
|
16999
|
+
amount: bigint;
|
|
17000
|
+
minAmount: bigint;
|
|
17001
|
+
calls: MultiCall[];
|
|
17002
|
+
underlyingBalance: bigint;
|
|
17003
|
+
}
|
|
17004
|
+
];
|
|
17005
|
+
};
|
|
16971
17006
|
/**
|
|
16972
17007
|
* Slice of credit manager data required for router operations
|
|
16973
17008
|
*/
|
|
@@ -16975,9 +17010,11 @@ interface CreditManagerSlice {
|
|
|
16975
17010
|
address: Address;
|
|
16976
17011
|
collateralTokens: Address[];
|
|
16977
17012
|
}
|
|
16978
|
-
declare class RouterV3Contract extends BaseContract<abi> {
|
|
17013
|
+
declare class RouterV3Contract extends BaseContract<abi> implements IHooks<RouterHooks> {
|
|
16979
17014
|
#private;
|
|
16980
17015
|
constructor(sdk: GearboxSDK, address: Address);
|
|
17016
|
+
addHook: <K extends keyof RouterHooks>(hookName: K, fn: (...args: RouterHooks[K]) => void | Promise<void>) => void;
|
|
17017
|
+
removeHook: <K extends keyof RouterHooks>(hookName: K, fn: (...args: RouterHooks[K]) => void | Promise<void>) => void;
|
|
16981
17018
|
/**
|
|
16982
17019
|
* Finds all available swaps for NORMAL tokens
|
|
16983
17020
|
* @param ca
|
|
@@ -17035,27 +17072,6 @@ declare class RouterV3Contract extends BaseContract<abi> {
|
|
|
17035
17072
|
getAvailableConnectors(collateralTokens: Address[]): Address[];
|
|
17036
17073
|
}
|
|
17037
17074
|
|
|
17038
|
-
interface SDKEventsMap {
|
|
17039
|
-
/**
|
|
17040
|
-
* Emitted by router
|
|
17041
|
-
*/
|
|
17042
|
-
foundPathOptions: [{
|
|
17043
|
-
pathOptions: PathOptionSerie[];
|
|
17044
|
-
}];
|
|
17045
|
-
/**
|
|
17046
|
-
* Emitted by router
|
|
17047
|
-
*/
|
|
17048
|
-
foundBestClosePath: [
|
|
17049
|
-
{
|
|
17050
|
-
creditAccount: Address;
|
|
17051
|
-
amount: bigint;
|
|
17052
|
-
minAmount: bigint;
|
|
17053
|
-
calls: MultiCall[];
|
|
17054
|
-
underlyingBalance: bigint;
|
|
17055
|
-
}
|
|
17056
|
-
];
|
|
17057
|
-
}
|
|
17058
|
-
|
|
17059
17075
|
interface SDKAttachOptions {
|
|
17060
17076
|
/**
|
|
17061
17077
|
* Account address for contract write simulations
|
|
@@ -17090,7 +17106,7 @@ interface SDKAttachOptions {
|
|
|
17090
17106
|
*/
|
|
17091
17107
|
logger?: ILogger;
|
|
17092
17108
|
}
|
|
17093
|
-
declare class GearboxSDK
|
|
17109
|
+
declare class GearboxSDK {
|
|
17094
17110
|
#private;
|
|
17095
17111
|
readonly logger?: ILogger;
|
|
17096
17112
|
/**
|
|
@@ -17407,4 +17423,4 @@ type MulticallErrorType = GetChainContractAddressErrorType | ReadContractErrorTy
|
|
|
17407
17423
|
*/
|
|
17408
17424
|
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>>;
|
|
17409
17425
|
|
|
17410
|
-
export { type ACLState, type ACLStateHuman, ADDRESS_0X0, ADDRESS_PROVIDER, AP_ACCOUNT_FACTORY, AP_ACL, 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_MULTI_PAUSE, AP_PARTIAL_LIQUIDATION_BOT, AP_PRICE_ORACLE, AP_ROUTER, AP_TREASURY, AP_WETH_GATEWAY, AP_WETH_TOKEN, AP_ZAPPER_REGISTER, AP_ZERO_PRICE_FEED, AbstractPriceFeedContract, type AccountFactoryStateHuman, AddressLabeller, AddressMap, AddressProviderContractV3_1, type AddressProviderV3State, type AddressProviderV3StateHuman, type AnvilActions, type AnvilClient, type AnvilClientConfig, type Asset, type AssetPriceFeedState, type AssetPriceFeedStateHuman, BalancerStablePriceFeedContract, BalancerWeightedPriceFeedContract, BaseContract, type BaseContractOptions, type BaseContractState, type BaseContractStateHuman, type BasePriceFeedState, type BasePriceFeedStateHuman, BotListContract, type BotListState, type BotListStateHuman, BotPermissions, type BoundedOracleState, type BoundedOracleStateHuman, BoundedPriceFeedContract, ChainlinkPriceFeedContract, CompositePriceFeedContract, type ContractMethod, type ContractsRegisterState, type ContractsRegisterStateHuman, type ControllerTimelockV3State, type ControllerTimelockV3StateHuman, type CoreState, type CoreStateHuman, type CreditAccountData, type CreditAccountFilter, CreditAccountsService, CreditConfiguratorContract, type CreditConfiguratorState, type CreditConfiguratorStateHuman, CreditFacadeContract, type CreditFacadeState, type CreditFacadeStateHuman, CreditFactory, type CreditFactoryState, type CreditFactoryStateHuman, CreditManagerContract, type CreditManagerData, type CreditManagerDebtParams, type CreditManagerDebtParamsHuman, type CreditManagerDebtParamsStruct, type CreditManagerState, type CreditManagerStateHuman, CurveCryptoPriceFeedContract, type CurvePoolStruct, CurveStablePriceFeedContract, CurveUSDPriceFeedContract, type DataCompressorV3State, type DegenDistributorState, type DegenDistributorStateHuman, type DegenNFT2State, type DegenNFT2StateHuman, Erc4626PriceFeedContract, type EtherscanURLParam, type FindClosePathInput, GaugeContract, type GaugeParams, type GaugeParamsHuman, type GaugeState, type GaugeStateHuman, GearStakingContract, type GearStakingV3State, type GearStakingV3StateHuman, GearboxSDK, type GearboxState, type GearboxStateHuman, type ILPPriceFeedContract, type ILogger, type IPriceFeedContract, LinearModelContract, type LinearModelState, type LinearModelStateHuman, type LogFn, MAX_UINT256, MIN_INT96, type MarketData, MarketFactory, MarketRegister, type MarketState, type MarketStateHuman, MellowLRTPriceFeedContract, type MultiCall, type MultiPauseState, type MulticallErrorType, type MulticallParameters, type MulticallReturnType, NOT_DEPLOYED, NO_VERSION, type NetworkType, type OnDemandPriceUpdate, type OpenStrategyResult, PERCENTAGE_DECIMALS, PERCENTAGE_FACTOR, PRICE_DECIMALS, PRICE_DECIMALS_POW, type PathOption, type PathOptionSerie, type PeripheryState, type PeripheryStateHuman, type PolicyStruct, type PolicyStructHuman, PoolContract, type PoolData, PoolFactory, type PoolFactoryState, type PoolFactoryStateHuman, PoolQuotaKeeperContract, type PoolQuotaKeeperData, type PoolQuotaKeeperState, type PoolQuotaKeeperStateHuman, type PoolState, type PoolStateHuman, type PriceFactoryStateHuman, type PriceFeedConstructorArgs, type PriceFeedContractType, type PriceFeedMapEntry, PriceFeedRef, PriceFeedRegister, type PriceFeedState, type PriceFeedStateHuman, type PriceFeedTreeNode, type PriceFeedUsageType, PriceOracleContract, type PriceOracleData, type PriceOracleState, type PriceOracleV3State, type PriceOracleV3StateHuman, Provider, type ProviderOptions, type QuotaParams, type QuotaParamsHuman, RAY, RAY_DECIMALS_POW, type RateKeeperData, type RawTx, type ReadContractOptions, RedstonePriceFeedContract, type RedstonePriceFeedState, type RedstonePriceFeedStateHuman, type RouterCloseResult, type RouterComponentRegisterHuman, type RouterResult, type RouterState, type RouterStateHuman, RouterV3Contract, type RouterV3ContractState, type RouterV3ContractStateHuman, type SDKAttachOptions, SDKConstruct,
|
|
17426
|
+
export { type ACLState, type ACLStateHuman, ADDRESS_0X0, ADDRESS_PROVIDER, AP_ACCOUNT_FACTORY, AP_ACL, 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_MULTI_PAUSE, AP_PARTIAL_LIQUIDATION_BOT, AP_PRICE_ORACLE, AP_ROUTER, AP_TREASURY, AP_WETH_GATEWAY, AP_WETH_TOKEN, AP_ZAPPER_REGISTER, AP_ZERO_PRICE_FEED, AbstractPriceFeedContract, type AccountFactoryStateHuman, AddressLabeller, AddressMap, AddressProviderContractV3_1, type AddressProviderV3State, type AddressProviderV3StateHuman, type AnvilActions, type AnvilClient, type AnvilClientConfig, type Asset, type AssetPriceFeedState, type AssetPriceFeedStateHuman, BalancerStablePriceFeedContract, BalancerWeightedPriceFeedContract, BaseContract, type BaseContractOptions, type BaseContractState, type BaseContractStateHuman, type BasePriceFeedState, type BasePriceFeedStateHuman, BotListContract, type BotListState, type BotListStateHuman, BotPermissions, type BoundedOracleState, type BoundedOracleStateHuman, BoundedPriceFeedContract, ChainlinkPriceFeedContract, CompositePriceFeedContract, type ContractMethod, type ContractsRegisterState, type ContractsRegisterStateHuman, type ControllerTimelockV3State, type ControllerTimelockV3StateHuman, type CoreState, type CoreStateHuman, type CreditAccountData, type CreditAccountFilter, CreditAccountsService, CreditConfiguratorContract, type CreditConfiguratorState, type CreditConfiguratorStateHuman, CreditFacadeContract, type CreditFacadeState, type CreditFacadeStateHuman, CreditFactory, type CreditFactoryState, type CreditFactoryStateHuman, CreditManagerContract, type CreditManagerData, type CreditManagerDebtParams, type CreditManagerDebtParamsHuman, type CreditManagerDebtParamsStruct, type CreditManagerState, type CreditManagerStateHuman, CurveCryptoPriceFeedContract, type CurvePoolStruct, CurveStablePriceFeedContract, CurveUSDPriceFeedContract, type DataCompressorV3State, type DegenDistributorState, type DegenDistributorStateHuman, type DegenNFT2State, type DegenNFT2StateHuman, Erc4626PriceFeedContract, type EtherscanURLParam, type FindClosePathInput, GaugeContract, type GaugeParams, type GaugeParamsHuman, type GaugeState, type GaugeStateHuman, GearStakingContract, type GearStakingV3State, type GearStakingV3StateHuman, GearboxSDK, type GearboxState, type GearboxStateHuman, type ILPPriceFeedContract, type ILogger, type IPriceFeedContract, LinearModelContract, type LinearModelState, type LinearModelStateHuman, type LogFn, MAX_UINT256, MIN_INT96, type MarketData, MarketFactory, MarketRegister, type MarketState, type MarketStateHuman, MellowLRTPriceFeedContract, type MultiCall, type MultiPauseState, type MulticallErrorType, type MulticallParameters, type MulticallReturnType, NOT_DEPLOYED, NO_VERSION, type NetworkType, type OnDemandPriceUpdate, type OpenStrategyResult, PERCENTAGE_DECIMALS, PERCENTAGE_FACTOR, PRICE_DECIMALS, PRICE_DECIMALS_POW, type PathOption, type PathOptionSerie, type PeripheryState, type PeripheryStateHuman, type PolicyStruct, type PolicyStructHuman, PoolContract, type PoolData, PoolFactory, type PoolFactoryState, type PoolFactoryStateHuman, PoolQuotaKeeperContract, type PoolQuotaKeeperData, type PoolQuotaKeeperState, type PoolQuotaKeeperStateHuman, type PoolState, type PoolStateHuman, type PriceFactoryStateHuman, type PriceFeedConstructorArgs, type PriceFeedContractType, type PriceFeedMapEntry, PriceFeedRef, PriceFeedRegister, type PriceFeedRegisterHooks, type PriceFeedState, type PriceFeedStateHuman, type PriceFeedTreeNode, type PriceFeedUsageType, PriceOracleContract, type PriceOracleData, type PriceOracleState, type PriceOracleV3State, type PriceOracleV3StateHuman, Provider, type ProviderOptions, type QuotaParams, type QuotaParamsHuman, RAY, RAY_DECIMALS_POW, type RateKeeperData, type RawTx, type ReadContractOptions, RedstonePriceFeedContract, type RedstonePriceFeedState, type RedstonePriceFeedStateHuman, type RouterCloseResult, type RouterComponentRegisterHuman, type RouterHooks, type RouterResult, type RouterState, type RouterStateHuman, RouterV3Contract, type RouterV3ContractState, type RouterV3ContractStateHuman, type SDKAttachOptions, SDKConstruct, SUPPORTED_CHAINS, type SwapOperation, type SwapTask, TIMELOCK, type TVL, type TokenMetaData, type TokenTypeToResolverHuman, USDC, type UpdatePriceFeedsResult, VotingContractStatus, WAD, WAD_DECIMALS_POW, WstETHPriceFeedContract, YearnPriceFeedContract, type ZapperInfo, type ZapperInfoHuman, type ZapperRegisterState, type ZapperRegisterStateHuman, ZeroPriceFeedContract, botPermissionsToString, bytes32ToString, chains, childLogger, convertBaseContractState, convertCoreStateToHuman, convertCreditFactoryStateToHuman, convertGaugeStateToHuman, convertGearboxStateToHuman, convertGearboxStateToHumanLA, convertLinearModelStateToHuman, convertPeripheryStateToHuman, convertPoolFactoryStateToHuman, convertPoolQuotaKeeperStateToHuman, convertPoolStateToHuman, convertPriceFeedStateToHuman, convertPriceOracleStateToHuman, convertRouterStateToHuman, convertRouterV3StateToHuman, convertZapperRegisterStateToHuman, createAnvilClient, createRawTx, detectNetwork, etherscanUrl, filterDust, fmtBinaryMask, formatBN, formatBNvalue, formatBn4dig, formatDuration, formatNumberToString_, halfRAY, isAnvil, json_parse, json_stringify, numberWithCommas, percentFmt, simulateMulticall, toHumanFormat };
|
package/dist/esm/sdk/index.d.mts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Address, Chain, PublicClient, Transport, Hex, Abi, DecodeFunctionDataReturnType, Log, ContractFunctionName, EncodeFunctionDataParameters, TransactionReceipt, GetContractReturnType, Client, Prettify, TestActions, WalletClient, TestRpcSchema, Block, ContractFunctionParameters, CallParameters, MulticallContracts, Narrow, AbiStateMutability, MulticallResults, GetChainContractAddressErrorType, ReadContractErrorType, GetContractErrorReturnType, EncodeFunctionDataErrorType, DecodeFunctionResultErrorType } from 'viem';
|
|
2
|
-
import { EventEmitter } from 'eventemitter3';
|
|
3
2
|
import { RouterComponentRegister, TokenTypeToResolver } from '@gearbox-protocol/sdk-gov';
|
|
4
3
|
import { AbiParametersToPrimitiveTypes, ExtractAbiFunction } from 'abitype';
|
|
5
4
|
|
|
@@ -14867,15 +14866,28 @@ declare class MellowLRTPriceFeedContract extends AbstractLPPriceFeedContract<abi
|
|
|
14867
14866
|
getValue(): Promise<bigint>;
|
|
14868
14867
|
}
|
|
14869
14868
|
|
|
14869
|
+
interface IHooks<HookMap extends Record<string, any[]>> {
|
|
14870
|
+
addHook: <K extends keyof HookMap>(hookName: K, fn: (...args: HookMap[K]) => void | Promise<void>) => void;
|
|
14871
|
+
removeHook: <K extends keyof HookMap>(hookName: K, fn: (...args: HookMap[K]) => void | Promise<void>) => void;
|
|
14872
|
+
}
|
|
14873
|
+
|
|
14874
|
+
type PriceFeedRegisterHooks = {
|
|
14875
|
+
/**
|
|
14876
|
+
* Emitted when transactions to update price feeds have been generated, but before they're used anywhere
|
|
14877
|
+
*/
|
|
14878
|
+
updatesGenerated: [UpdatePriceFeedsResult];
|
|
14879
|
+
};
|
|
14870
14880
|
/**
|
|
14871
14881
|
* PriceFeedRegister acts as a chain-level cache to avoid creating multiple contract instances.
|
|
14872
14882
|
* It's reused by PriceFeedFactory belonging to different markets
|
|
14873
14883
|
*
|
|
14874
14884
|
**/
|
|
14875
|
-
declare class PriceFeedRegister extends SDKConstruct {
|
|
14885
|
+
declare class PriceFeedRegister extends SDKConstruct implements IHooks<PriceFeedRegisterHooks> {
|
|
14876
14886
|
#private;
|
|
14877
14887
|
readonly logger?: ILogger;
|
|
14878
14888
|
constructor(sdk: GearboxSDK);
|
|
14889
|
+
addHook: <K extends "updatesGenerated">(hookName: K, fn: (...args: PriceFeedRegisterHooks[K]) => void | Promise<void>) => void;
|
|
14890
|
+
removeHook: <K extends "updatesGenerated">(hookName: K, fn: (...args: PriceFeedRegisterHooks[K]) => void | Promise<void>) => void;
|
|
14879
14891
|
/**
|
|
14880
14892
|
* Returns RawTxs to update price feeds
|
|
14881
14893
|
* @param priceFeeds top-level price feeds, actual updatable price feeds will be derived. If not provided will use all price feeds that are attached
|
|
@@ -16869,7 +16881,7 @@ declare class PriceOracleContract extends BaseContract<abi$1> {
|
|
|
16869
16881
|
* Generates updates for all updateable price feeds in this oracle (including dependencies)
|
|
16870
16882
|
* @returns
|
|
16871
16883
|
*/
|
|
16872
|
-
|
|
16884
|
+
updatePriceFeeds(): Promise<UpdatePriceFeedsResult>;
|
|
16873
16885
|
/**
|
|
16874
16886
|
* Converts previously obtained price updates into CreditFacade multicall entries
|
|
16875
16887
|
* @param creditFacade
|
|
@@ -16968,6 +16980,29 @@ interface FindClosePathInput {
|
|
|
16968
16980
|
leftover: Asset[];
|
|
16969
16981
|
connectors: Address[];
|
|
16970
16982
|
}
|
|
16983
|
+
type RouterHooks = {
|
|
16984
|
+
/**
|
|
16985
|
+
* Internal router event
|
|
16986
|
+
*/
|
|
16987
|
+
foundPathOptions: [
|
|
16988
|
+
{
|
|
16989
|
+
creditAccount: Address;
|
|
16990
|
+
pathOptions: PathOptionSerie[];
|
|
16991
|
+
}
|
|
16992
|
+
];
|
|
16993
|
+
/**
|
|
16994
|
+
* Internal router event
|
|
16995
|
+
*/
|
|
16996
|
+
foundBestClosePath: [
|
|
16997
|
+
{
|
|
16998
|
+
creditAccount: Address;
|
|
16999
|
+
amount: bigint;
|
|
17000
|
+
minAmount: bigint;
|
|
17001
|
+
calls: MultiCall[];
|
|
17002
|
+
underlyingBalance: bigint;
|
|
17003
|
+
}
|
|
17004
|
+
];
|
|
17005
|
+
};
|
|
16971
17006
|
/**
|
|
16972
17007
|
* Slice of credit manager data required for router operations
|
|
16973
17008
|
*/
|
|
@@ -16975,9 +17010,11 @@ interface CreditManagerSlice {
|
|
|
16975
17010
|
address: Address;
|
|
16976
17011
|
collateralTokens: Address[];
|
|
16977
17012
|
}
|
|
16978
|
-
declare class RouterV3Contract extends BaseContract<abi> {
|
|
17013
|
+
declare class RouterV3Contract extends BaseContract<abi> implements IHooks<RouterHooks> {
|
|
16979
17014
|
#private;
|
|
16980
17015
|
constructor(sdk: GearboxSDK, address: Address);
|
|
17016
|
+
addHook: <K extends keyof RouterHooks>(hookName: K, fn: (...args: RouterHooks[K]) => void | Promise<void>) => void;
|
|
17017
|
+
removeHook: <K extends keyof RouterHooks>(hookName: K, fn: (...args: RouterHooks[K]) => void | Promise<void>) => void;
|
|
16981
17018
|
/**
|
|
16982
17019
|
* Finds all available swaps for NORMAL tokens
|
|
16983
17020
|
* @param ca
|
|
@@ -17035,27 +17072,6 @@ declare class RouterV3Contract extends BaseContract<abi> {
|
|
|
17035
17072
|
getAvailableConnectors(collateralTokens: Address[]): Address[];
|
|
17036
17073
|
}
|
|
17037
17074
|
|
|
17038
|
-
interface SDKEventsMap {
|
|
17039
|
-
/**
|
|
17040
|
-
* Emitted by router
|
|
17041
|
-
*/
|
|
17042
|
-
foundPathOptions: [{
|
|
17043
|
-
pathOptions: PathOptionSerie[];
|
|
17044
|
-
}];
|
|
17045
|
-
/**
|
|
17046
|
-
* Emitted by router
|
|
17047
|
-
*/
|
|
17048
|
-
foundBestClosePath: [
|
|
17049
|
-
{
|
|
17050
|
-
creditAccount: Address;
|
|
17051
|
-
amount: bigint;
|
|
17052
|
-
minAmount: bigint;
|
|
17053
|
-
calls: MultiCall[];
|
|
17054
|
-
underlyingBalance: bigint;
|
|
17055
|
-
}
|
|
17056
|
-
];
|
|
17057
|
-
}
|
|
17058
|
-
|
|
17059
17075
|
interface SDKAttachOptions {
|
|
17060
17076
|
/**
|
|
17061
17077
|
* Account address for contract write simulations
|
|
@@ -17090,7 +17106,7 @@ interface SDKAttachOptions {
|
|
|
17090
17106
|
*/
|
|
17091
17107
|
logger?: ILogger;
|
|
17092
17108
|
}
|
|
17093
|
-
declare class GearboxSDK
|
|
17109
|
+
declare class GearboxSDK {
|
|
17094
17110
|
#private;
|
|
17095
17111
|
readonly logger?: ILogger;
|
|
17096
17112
|
/**
|
|
@@ -17407,4 +17423,4 @@ type MulticallErrorType = GetChainContractAddressErrorType | ReadContractErrorTy
|
|
|
17407
17423
|
*/
|
|
17408
17424
|
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>>;
|
|
17409
17425
|
|
|
17410
|
-
export { type ACLState, type ACLStateHuman, ADDRESS_0X0, ADDRESS_PROVIDER, AP_ACCOUNT_FACTORY, AP_ACL, 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_MULTI_PAUSE, AP_PARTIAL_LIQUIDATION_BOT, AP_PRICE_ORACLE, AP_ROUTER, AP_TREASURY, AP_WETH_GATEWAY, AP_WETH_TOKEN, AP_ZAPPER_REGISTER, AP_ZERO_PRICE_FEED, AbstractPriceFeedContract, type AccountFactoryStateHuman, AddressLabeller, AddressMap, AddressProviderContractV3_1, type AddressProviderV3State, type AddressProviderV3StateHuman, type AnvilActions, type AnvilClient, type AnvilClientConfig, type Asset, type AssetPriceFeedState, type AssetPriceFeedStateHuman, BalancerStablePriceFeedContract, BalancerWeightedPriceFeedContract, BaseContract, type BaseContractOptions, type BaseContractState, type BaseContractStateHuman, type BasePriceFeedState, type BasePriceFeedStateHuman, BotListContract, type BotListState, type BotListStateHuman, BotPermissions, type BoundedOracleState, type BoundedOracleStateHuman, BoundedPriceFeedContract, ChainlinkPriceFeedContract, CompositePriceFeedContract, type ContractMethod, type ContractsRegisterState, type ContractsRegisterStateHuman, type ControllerTimelockV3State, type ControllerTimelockV3StateHuman, type CoreState, type CoreStateHuman, type CreditAccountData, type CreditAccountFilter, CreditAccountsService, CreditConfiguratorContract, type CreditConfiguratorState, type CreditConfiguratorStateHuman, CreditFacadeContract, type CreditFacadeState, type CreditFacadeStateHuman, CreditFactory, type CreditFactoryState, type CreditFactoryStateHuman, CreditManagerContract, type CreditManagerData, type CreditManagerDebtParams, type CreditManagerDebtParamsHuman, type CreditManagerDebtParamsStruct, type CreditManagerState, type CreditManagerStateHuman, CurveCryptoPriceFeedContract, type CurvePoolStruct, CurveStablePriceFeedContract, CurveUSDPriceFeedContract, type DataCompressorV3State, type DegenDistributorState, type DegenDistributorStateHuman, type DegenNFT2State, type DegenNFT2StateHuman, Erc4626PriceFeedContract, type EtherscanURLParam, type FindClosePathInput, GaugeContract, type GaugeParams, type GaugeParamsHuman, type GaugeState, type GaugeStateHuman, GearStakingContract, type GearStakingV3State, type GearStakingV3StateHuman, GearboxSDK, type GearboxState, type GearboxStateHuman, type ILPPriceFeedContract, type ILogger, type IPriceFeedContract, LinearModelContract, type LinearModelState, type LinearModelStateHuman, type LogFn, MAX_UINT256, MIN_INT96, type MarketData, MarketFactory, MarketRegister, type MarketState, type MarketStateHuman, MellowLRTPriceFeedContract, type MultiCall, type MultiPauseState, type MulticallErrorType, type MulticallParameters, type MulticallReturnType, NOT_DEPLOYED, NO_VERSION, type NetworkType, type OnDemandPriceUpdate, type OpenStrategyResult, PERCENTAGE_DECIMALS, PERCENTAGE_FACTOR, PRICE_DECIMALS, PRICE_DECIMALS_POW, type PathOption, type PathOptionSerie, type PeripheryState, type PeripheryStateHuman, type PolicyStruct, type PolicyStructHuman, PoolContract, type PoolData, PoolFactory, type PoolFactoryState, type PoolFactoryStateHuman, PoolQuotaKeeperContract, type PoolQuotaKeeperData, type PoolQuotaKeeperState, type PoolQuotaKeeperStateHuman, type PoolState, type PoolStateHuman, type PriceFactoryStateHuman, type PriceFeedConstructorArgs, type PriceFeedContractType, type PriceFeedMapEntry, PriceFeedRef, PriceFeedRegister, type PriceFeedState, type PriceFeedStateHuman, type PriceFeedTreeNode, type PriceFeedUsageType, PriceOracleContract, type PriceOracleData, type PriceOracleState, type PriceOracleV3State, type PriceOracleV3StateHuman, Provider, type ProviderOptions, type QuotaParams, type QuotaParamsHuman, RAY, RAY_DECIMALS_POW, type RateKeeperData, type RawTx, type ReadContractOptions, RedstonePriceFeedContract, type RedstonePriceFeedState, type RedstonePriceFeedStateHuman, type RouterCloseResult, type RouterComponentRegisterHuman, type RouterResult, type RouterState, type RouterStateHuman, RouterV3Contract, type RouterV3ContractState, type RouterV3ContractStateHuman, type SDKAttachOptions, SDKConstruct,
|
|
17426
|
+
export { type ACLState, type ACLStateHuman, ADDRESS_0X0, ADDRESS_PROVIDER, AP_ACCOUNT_FACTORY, AP_ACL, 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_MULTI_PAUSE, AP_PARTIAL_LIQUIDATION_BOT, AP_PRICE_ORACLE, AP_ROUTER, AP_TREASURY, AP_WETH_GATEWAY, AP_WETH_TOKEN, AP_ZAPPER_REGISTER, AP_ZERO_PRICE_FEED, AbstractPriceFeedContract, type AccountFactoryStateHuman, AddressLabeller, AddressMap, AddressProviderContractV3_1, type AddressProviderV3State, type AddressProviderV3StateHuman, type AnvilActions, type AnvilClient, type AnvilClientConfig, type Asset, type AssetPriceFeedState, type AssetPriceFeedStateHuman, BalancerStablePriceFeedContract, BalancerWeightedPriceFeedContract, BaseContract, type BaseContractOptions, type BaseContractState, type BaseContractStateHuman, type BasePriceFeedState, type BasePriceFeedStateHuman, BotListContract, type BotListState, type BotListStateHuman, BotPermissions, type BoundedOracleState, type BoundedOracleStateHuman, BoundedPriceFeedContract, ChainlinkPriceFeedContract, CompositePriceFeedContract, type ContractMethod, type ContractsRegisterState, type ContractsRegisterStateHuman, type ControllerTimelockV3State, type ControllerTimelockV3StateHuman, type CoreState, type CoreStateHuman, type CreditAccountData, type CreditAccountFilter, CreditAccountsService, CreditConfiguratorContract, type CreditConfiguratorState, type CreditConfiguratorStateHuman, CreditFacadeContract, type CreditFacadeState, type CreditFacadeStateHuman, CreditFactory, type CreditFactoryState, type CreditFactoryStateHuman, CreditManagerContract, type CreditManagerData, type CreditManagerDebtParams, type CreditManagerDebtParamsHuman, type CreditManagerDebtParamsStruct, type CreditManagerState, type CreditManagerStateHuman, CurveCryptoPriceFeedContract, type CurvePoolStruct, CurveStablePriceFeedContract, CurveUSDPriceFeedContract, type DataCompressorV3State, type DegenDistributorState, type DegenDistributorStateHuman, type DegenNFT2State, type DegenNFT2StateHuman, Erc4626PriceFeedContract, type EtherscanURLParam, type FindClosePathInput, GaugeContract, type GaugeParams, type GaugeParamsHuman, type GaugeState, type GaugeStateHuman, GearStakingContract, type GearStakingV3State, type GearStakingV3StateHuman, GearboxSDK, type GearboxState, type GearboxStateHuman, type ILPPriceFeedContract, type ILogger, type IPriceFeedContract, LinearModelContract, type LinearModelState, type LinearModelStateHuman, type LogFn, MAX_UINT256, MIN_INT96, type MarketData, MarketFactory, MarketRegister, type MarketState, type MarketStateHuman, MellowLRTPriceFeedContract, type MultiCall, type MultiPauseState, type MulticallErrorType, type MulticallParameters, type MulticallReturnType, NOT_DEPLOYED, NO_VERSION, type NetworkType, type OnDemandPriceUpdate, type OpenStrategyResult, PERCENTAGE_DECIMALS, PERCENTAGE_FACTOR, PRICE_DECIMALS, PRICE_DECIMALS_POW, type PathOption, type PathOptionSerie, type PeripheryState, type PeripheryStateHuman, type PolicyStruct, type PolicyStructHuman, PoolContract, type PoolData, PoolFactory, type PoolFactoryState, type PoolFactoryStateHuman, PoolQuotaKeeperContract, type PoolQuotaKeeperData, type PoolQuotaKeeperState, type PoolQuotaKeeperStateHuman, type PoolState, type PoolStateHuman, type PriceFactoryStateHuman, type PriceFeedConstructorArgs, type PriceFeedContractType, type PriceFeedMapEntry, PriceFeedRef, PriceFeedRegister, type PriceFeedRegisterHooks, type PriceFeedState, type PriceFeedStateHuman, type PriceFeedTreeNode, type PriceFeedUsageType, PriceOracleContract, type PriceOracleData, type PriceOracleState, type PriceOracleV3State, type PriceOracleV3StateHuman, Provider, type ProviderOptions, type QuotaParams, type QuotaParamsHuman, RAY, RAY_DECIMALS_POW, type RateKeeperData, type RawTx, type ReadContractOptions, RedstonePriceFeedContract, type RedstonePriceFeedState, type RedstonePriceFeedStateHuman, type RouterCloseResult, type RouterComponentRegisterHuman, type RouterHooks, type RouterResult, type RouterState, type RouterStateHuman, RouterV3Contract, type RouterV3ContractState, type RouterV3ContractStateHuman, type SDKAttachOptions, SDKConstruct, SUPPORTED_CHAINS, type SwapOperation, type SwapTask, TIMELOCK, type TVL, type TokenMetaData, type TokenTypeToResolverHuman, USDC, type UpdatePriceFeedsResult, VotingContractStatus, WAD, WAD_DECIMALS_POW, WstETHPriceFeedContract, YearnPriceFeedContract, type ZapperInfo, type ZapperInfoHuman, type ZapperRegisterState, type ZapperRegisterStateHuman, ZeroPriceFeedContract, botPermissionsToString, bytes32ToString, chains, childLogger, convertBaseContractState, convertCoreStateToHuman, convertCreditFactoryStateToHuman, convertGaugeStateToHuman, convertGearboxStateToHuman, convertGearboxStateToHumanLA, convertLinearModelStateToHuman, convertPeripheryStateToHuman, convertPoolFactoryStateToHuman, convertPoolQuotaKeeperStateToHuman, convertPoolStateToHuman, convertPriceFeedStateToHuman, convertPriceOracleStateToHuman, convertRouterStateToHuman, convertRouterV3StateToHuman, convertZapperRegisterStateToHuman, createAnvilClient, createRawTx, detectNetwork, etherscanUrl, filterDust, fmtBinaryMask, formatBN, formatBNvalue, formatBn4dig, formatDuration, formatNumberToString_, halfRAY, isAnvil, json_parse, json_stringify, numberWithCommas, percentFmt, simulateMulticall, toHumanFormat };
|
package/dist/esm/sdk/index.mjs
CHANGED
|
@@ -3,7 +3,6 @@ import { formatAbiItem, getAction } from 'viem/utils';
|
|
|
3
3
|
import { intervalToDuration, formatDuration as formatDuration$1 } from 'date-fns';
|
|
4
4
|
import { mainnet, arbitrum, optimism, base } from 'viem/chains';
|
|
5
5
|
import { simulateContract } from 'viem/actions';
|
|
6
|
-
import { EventEmitter } from 'eventemitter3';
|
|
7
6
|
import { DataServiceWrapper } from '@redstone-finance/evm-connector';
|
|
8
7
|
import { RedstonePayload } from 'redstone-protocol';
|
|
9
8
|
import { getConnectors, decimals, getTokenSymbol, RouterComponent, TokenType, tokenDataByNetwork, contractParams, curveTokens, balancerLpTokens, isCurveLPToken, yearnTokens, convexTokens, isBalancerLPToken } from '@gearbox-protocol/sdk-gov';
|
|
@@ -14538,6 +14537,31 @@ var MellowLRTPriceFeedContract = class extends AbstractLPPriceFeedContract {
|
|
|
14538
14537
|
return stack.totalValue * BigInt(1e18) / stack.totalSupply;
|
|
14539
14538
|
}
|
|
14540
14539
|
};
|
|
14540
|
+
|
|
14541
|
+
// src/sdk/utils/internal/Hooks.ts
|
|
14542
|
+
var Hooks = class {
|
|
14543
|
+
#reg = {};
|
|
14544
|
+
addHook(hookName, fn) {
|
|
14545
|
+
if (!this.#reg[hookName]) {
|
|
14546
|
+
this.#reg[hookName] = [];
|
|
14547
|
+
}
|
|
14548
|
+
this.#reg[hookName].push(fn);
|
|
14549
|
+
}
|
|
14550
|
+
removeHook(hookName, fn) {
|
|
14551
|
+
if (!this.#reg[hookName]) {
|
|
14552
|
+
return;
|
|
14553
|
+
}
|
|
14554
|
+
this.#reg[hookName] = this.#reg[hookName]?.filter((hookFn) => hookFn !== fn) ?? [];
|
|
14555
|
+
}
|
|
14556
|
+
async triggerHooks(hookName, ...args) {
|
|
14557
|
+
if (!this.#reg[hookName]) {
|
|
14558
|
+
return;
|
|
14559
|
+
}
|
|
14560
|
+
for (const fn of this.#reg[hookName]) {
|
|
14561
|
+
await fn(...args);
|
|
14562
|
+
}
|
|
14563
|
+
}
|
|
14564
|
+
};
|
|
14541
14565
|
var RedstonePriceFeedContract = class extends AbstractPriceFeedContract {
|
|
14542
14566
|
decimals = 8;
|
|
14543
14567
|
dataServiceId;
|
|
@@ -14888,6 +14912,7 @@ var ZeroPriceFeedContract = class extends AbstractPriceFeedContract {
|
|
|
14888
14912
|
// src/sdk/market/pricefeeds/PriceFeedsRegister.ts
|
|
14889
14913
|
var PriceFeedRegister = class extends SDKConstruct {
|
|
14890
14914
|
logger;
|
|
14915
|
+
#hooks = new Hooks();
|
|
14891
14916
|
#feeds = new AddressMap();
|
|
14892
14917
|
#redstoneUpdater;
|
|
14893
14918
|
// public readonly zeroPriceFeed: ZeroPriceFeedContract;
|
|
@@ -14896,6 +14921,8 @@ var PriceFeedRegister = class extends SDKConstruct {
|
|
|
14896
14921
|
this.logger = childLogger("PriceFeedRegister", sdk.logger);
|
|
14897
14922
|
this.#redstoneUpdater = new RedstoneUpdater(sdk);
|
|
14898
14923
|
}
|
|
14924
|
+
addHook = this.#hooks.addHook.bind(this);
|
|
14925
|
+
removeHook = this.#hooks.removeHook.bind(this);
|
|
14899
14926
|
/**
|
|
14900
14927
|
* Returns RawTxs to update price feeds
|
|
14901
14928
|
* @param priceFeeds top-level price feeds, actual updatable price feeds will be derived. If not provided will use all price feeds that are attached
|
|
@@ -14925,7 +14952,9 @@ var PriceFeedRegister = class extends SDKConstruct {
|
|
|
14925
14952
|
txs.push(tx);
|
|
14926
14953
|
}
|
|
14927
14954
|
}
|
|
14928
|
-
|
|
14955
|
+
const result = { txs, timestamp: maxTimestamp };
|
|
14956
|
+
await this.#hooks.triggerHooks("updatesGenerated", result);
|
|
14957
|
+
return result;
|
|
14929
14958
|
}
|
|
14930
14959
|
get(address) {
|
|
14931
14960
|
return this.#feeds.get(address);
|
|
@@ -15053,7 +15082,7 @@ var PriceOracleContract = class extends BaseContract {
|
|
|
15053
15082
|
* Generates updates for all updateable price feeds in this oracle (including dependencies)
|
|
15054
15083
|
* @returns
|
|
15055
15084
|
*/
|
|
15056
|
-
async
|
|
15085
|
+
async updatePriceFeeds() {
|
|
15057
15086
|
const updatables = [];
|
|
15058
15087
|
for (const node of this.#priceFeedTree) {
|
|
15059
15088
|
if (node.updatable) {
|
|
@@ -15449,6 +15478,7 @@ var SWAP_OPERATIONS = {
|
|
|
15449
15478
|
};
|
|
15450
15479
|
var RouterV3Contract = class extends BaseContract {
|
|
15451
15480
|
#connectors;
|
|
15481
|
+
#hooks = new Hooks();
|
|
15452
15482
|
constructor(sdk, address) {
|
|
15453
15483
|
super(sdk, {
|
|
15454
15484
|
addr: address,
|
|
@@ -15457,6 +15487,8 @@ var RouterV3Contract = class extends BaseContract {
|
|
|
15457
15487
|
});
|
|
15458
15488
|
this.#connectors = getConnectors(sdk.provider.networkType);
|
|
15459
15489
|
}
|
|
15490
|
+
addHook = this.#hooks.addHook.bind(this);
|
|
15491
|
+
removeHook = this.#hooks.removeHook.bind(this);
|
|
15460
15492
|
/**
|
|
15461
15493
|
* Finds all available swaps for NORMAL tokens
|
|
15462
15494
|
* @param ca
|
|
@@ -15590,7 +15622,10 @@ var RouterV3Contract = class extends BaseContract {
|
|
|
15590
15622
|
*/
|
|
15591
15623
|
async findBestClosePath(ca, cm, slippage) {
|
|
15592
15624
|
const { pathOptions, expected, leftover, connectors } = this.getFindClosePathInput(ca, cm);
|
|
15593
|
-
this.
|
|
15625
|
+
await this.#hooks.triggerHooks("foundPathOptions", {
|
|
15626
|
+
creditAccount: ca.creditAccount,
|
|
15627
|
+
pathOptions
|
|
15628
|
+
});
|
|
15594
15629
|
let results = [];
|
|
15595
15630
|
for (const po of pathOptions) {
|
|
15596
15631
|
const { result: result2 } = await this.contract.simulate.findBestClosePath(
|
|
@@ -15625,7 +15660,7 @@ var RouterV3Contract = class extends BaseContract {
|
|
|
15625
15660
|
})),
|
|
15626
15661
|
underlyingBalance: underlyingBalance + bestResult.minAmount
|
|
15627
15662
|
};
|
|
15628
|
-
this.
|
|
15663
|
+
await this.#hooks.triggerHooks("foundBestClosePath", {
|
|
15629
15664
|
creditAccount: ca.creditAccount,
|
|
15630
15665
|
...result
|
|
15631
15666
|
});
|
|
@@ -15685,7 +15720,7 @@ function assetsMap(assets) {
|
|
|
15685
15720
|
}
|
|
15686
15721
|
|
|
15687
15722
|
// src/sdk/GearboxSDK.ts
|
|
15688
|
-
var GearboxSDK = class _GearboxSDK
|
|
15723
|
+
var GearboxSDK = class _GearboxSDK {
|
|
15689
15724
|
// Represents chain object
|
|
15690
15725
|
#provider;
|
|
15691
15726
|
// Block which was use for data query
|
|
@@ -15748,7 +15783,6 @@ var GearboxSDK = class _GearboxSDK extends EventEmitter {
|
|
|
15748
15783
|
}).#attach(addressProvider, riskCurators);
|
|
15749
15784
|
}
|
|
15750
15785
|
constructor(options) {
|
|
15751
|
-
super();
|
|
15752
15786
|
this.#provider = options.provider;
|
|
15753
15787
|
this.logger = options.logger;
|
|
15754
15788
|
this.priceFeeds = new PriceFeedRegister(this);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gearbox-protocol/sdk",
|
|
3
|
-
"version": "3.0.0-vfour.
|
|
3
|
+
"version": "3.0.0-vfour.18",
|
|
4
4
|
"description": "Gearbox SDK",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -46,9 +46,8 @@
|
|
|
46
46
|
"@redstone-finance/evm-connector": "^0.6.2",
|
|
47
47
|
"abitype": "^1.0.6",
|
|
48
48
|
"date-fns": "^4.1.0",
|
|
49
|
-
"eventemitter3": "^5.0.1",
|
|
50
49
|
"redstone-protocol": "^1.0.5",
|
|
51
|
-
"viem": "
|
|
50
|
+
"viem": ">=2.21.0 <3.0.0"
|
|
52
51
|
},
|
|
53
52
|
"devDependencies": {
|
|
54
53
|
"@commitlint/cli": "^19.5.0",
|