@gearbox-protocol/sdk 9.17.0 → 10.0.0
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/dev/AccountOpener.js +2 -5
- package/dist/cjs/dev/createAnvilClient.js +16 -13
- package/dist/cjs/dev/migrateFaucet.js +3 -6
- package/dist/cjs/plugins/accounts-counter/AccountsCounterPlugin.js +1 -1
- package/dist/cjs/plugins/degen-distributors/DegenDistributorsPlugin.js +1 -1
- package/dist/cjs/plugins/pools-history/Pools7DAgoPlugin.js +2 -2
- package/dist/cjs/plugins/zappers/ZappersPlugin.js +2 -2
- package/dist/cjs/sdk/GearboxSDK.js +70 -39
- package/dist/cjs/sdk/accountMigration/AbstractMigrateCreditAccountsService.js +1 -1
- package/dist/cjs/sdk/accounts/AbstractCreditAccountsService.js +1 -1
- package/dist/cjs/sdk/accounts/CreditAccountsServiceV300.js +1 -1
- package/dist/cjs/sdk/base/BaseContract.js +6 -9
- package/dist/cjs/sdk/base/SDKConstruct.js +4 -7
- package/dist/cjs/sdk/chain/chains.js +1 -1
- package/dist/cjs/sdk/chain/index.js +1 -3
- package/dist/cjs/sdk/core/BotListV3Contract.js +5 -5
- package/dist/cjs/sdk/core/GearStakingV3Contract.js +1 -1
- package/dist/cjs/sdk/core/address-provider/AbstractAddressProviderContract.js +1 -1
- package/dist/cjs/sdk/core/address-provider/AddressProviderV300Contract.js +2 -2
- package/dist/cjs/sdk/core/address-provider/createAddressProvider.js +1 -1
- package/dist/cjs/sdk/gauges/GaugeStakingService.js +1 -1
- package/dist/cjs/sdk/market/MarketConfiguratorContract.js +3 -3
- package/dist/cjs/sdk/market/MarketRegister.js +20 -26
- package/dist/cjs/sdk/market/MarketSuite.js +1 -1
- package/dist/cjs/sdk/market/credit/CreditConfiguratorV300Contract.js +2 -2
- package/dist/cjs/sdk/market/credit/CreditConfiguratorV310Contract.js +2 -2
- package/dist/cjs/sdk/market/oracle/PriceOracleBaseContract.js +1 -1
- package/dist/cjs/sdk/market/oracle/PriceOracleV300Contract.js +1 -1
- package/dist/cjs/sdk/market/pricefeeds/AbstractLPPriceFeed.js +1 -1
- package/dist/cjs/sdk/market/pricefeeds/BalancerStablePriceFeed.js +1 -1
- package/dist/cjs/sdk/market/pricefeeds/BalancerWeightedPriceFeed.js +1 -1
- package/dist/cjs/sdk/market/pricefeeds/CurveCryptoPriceFeed.js +1 -1
- package/dist/cjs/sdk/market/pricefeeds/CurveStablePriceFeed.js +1 -1
- package/dist/cjs/sdk/market/pricefeeds/CurveUSDPriceFeed.js +1 -1
- package/dist/cjs/sdk/market/pricefeeds/Erc4626PriceFeed.js +2 -2
- package/dist/cjs/sdk/market/pricefeeds/MellowLRTPriceFeed.js +1 -1
- package/dist/cjs/sdk/market/pricefeeds/PriceFeedsRegister.js +2 -2
- package/dist/cjs/sdk/market/pricefeeds/WstETHPriceFeed.js +1 -1
- package/dist/cjs/sdk/market/pricefeeds/YearnPriceFeed.js +1 -1
- package/dist/cjs/sdk/plugins/BasePlugin.js +3 -6
- package/dist/cjs/sdk/plugins/V300StalenessPeriodPlugin.js +1 -1
- package/dist/cjs/sdk/router/RouterV300Contract.js +4 -4
- package/dist/esm/dev/AccountOpener.js +3 -6
- package/dist/esm/dev/createAnvilClient.js +21 -14
- package/dist/esm/dev/migrateFaucet.js +4 -7
- package/dist/esm/plugins/accounts-counter/AccountsCounterPlugin.js +1 -1
- package/dist/esm/plugins/degen-distributors/DegenDistributorsPlugin.js +1 -1
- package/dist/esm/plugins/pools-history/Pools7DAgoPlugin.js +2 -2
- package/dist/esm/plugins/zappers/ZappersPlugin.js +2 -2
- package/dist/esm/sdk/GearboxSDK.js +78 -46
- package/dist/esm/sdk/accountMigration/AbstractMigrateCreditAccountsService.js +1 -1
- package/dist/esm/sdk/accounts/AbstractCreditAccountsService.js +1 -1
- package/dist/esm/sdk/accounts/CreditAccountsServiceV300.js +1 -1
- package/dist/esm/sdk/base/BaseContract.js +6 -9
- package/dist/esm/sdk/base/SDKConstruct.js +4 -7
- package/dist/esm/sdk/chain/chains.js +1 -1
- package/dist/esm/sdk/chain/index.js +0 -1
- package/dist/esm/sdk/core/BotListV3Contract.js +5 -5
- package/dist/esm/sdk/core/GearStakingV3Contract.js +1 -1
- package/dist/esm/sdk/core/address-provider/AbstractAddressProviderContract.js +1 -1
- package/dist/esm/sdk/core/address-provider/AddressProviderV300Contract.js +2 -2
- package/dist/esm/sdk/core/address-provider/createAddressProvider.js +1 -1
- package/dist/esm/sdk/gauges/GaugeStakingService.js +1 -1
- package/dist/esm/sdk/market/MarketConfiguratorContract.js +3 -3
- package/dist/esm/sdk/market/MarketRegister.js +20 -26
- package/dist/esm/sdk/market/MarketSuite.js +1 -1
- package/dist/esm/sdk/market/credit/CreditConfiguratorV300Contract.js +2 -2
- package/dist/esm/sdk/market/credit/CreditConfiguratorV310Contract.js +2 -2
- package/dist/esm/sdk/market/oracle/PriceOracleBaseContract.js +1 -1
- package/dist/esm/sdk/market/oracle/PriceOracleV300Contract.js +1 -1
- package/dist/esm/sdk/market/pricefeeds/AbstractLPPriceFeed.js +1 -1
- package/dist/esm/sdk/market/pricefeeds/BalancerStablePriceFeed.js +1 -1
- package/dist/esm/sdk/market/pricefeeds/BalancerWeightedPriceFeed.js +1 -1
- package/dist/esm/sdk/market/pricefeeds/CurveCryptoPriceFeed.js +1 -1
- package/dist/esm/sdk/market/pricefeeds/CurveStablePriceFeed.js +1 -1
- package/dist/esm/sdk/market/pricefeeds/CurveUSDPriceFeed.js +1 -1
- package/dist/esm/sdk/market/pricefeeds/Erc4626PriceFeed.js +2 -2
- package/dist/esm/sdk/market/pricefeeds/MellowLRTPriceFeed.js +1 -1
- package/dist/esm/sdk/market/pricefeeds/PriceFeedsRegister.js +2 -2
- package/dist/esm/sdk/market/pricefeeds/WstETHPriceFeed.js +1 -1
- package/dist/esm/sdk/market/pricefeeds/YearnPriceFeed.js +1 -1
- package/dist/esm/sdk/plugins/BasePlugin.js +3 -6
- package/dist/esm/sdk/plugins/V300StalenessPeriodPlugin.js +1 -1
- package/dist/esm/sdk/router/RouterV300Contract.js +4 -4
- package/dist/types/dev/createAnvilClient.d.ts +1 -0
- package/dist/types/sdk/GearboxSDK.d.ts +51 -6
- package/dist/types/sdk/base/BaseContract.d.ts +0 -2
- package/dist/types/sdk/base/SDKConstruct.d.ts +2 -3
- package/dist/types/sdk/chain/index.d.ts +0 -1
- package/dist/types/sdk/plugins/BasePlugin.d.ts +1 -2
- package/package.json +1 -1
- package/dist/cjs/sdk/chain/Provider.js +0 -86
- package/dist/esm/sdk/chain/Provider.js +0 -61
- package/dist/types/sdk/chain/Provider.d.ts +0 -51
|
@@ -11,12 +11,12 @@ class Erc4626PriceFeedContract extends AbstractLPPriceFeedContract {
|
|
|
11
11
|
});
|
|
12
12
|
}
|
|
13
13
|
async getValue() {
|
|
14
|
-
const decimals = await this.sdk.
|
|
14
|
+
const decimals = await this.sdk.client.readContract({
|
|
15
15
|
abi: ierc20Abi,
|
|
16
16
|
address: this.lpContract,
|
|
17
17
|
functionName: "decimals"
|
|
18
18
|
});
|
|
19
|
-
const price = await this.sdk.
|
|
19
|
+
const price = await this.sdk.client.readContract({
|
|
20
20
|
abi: erc4626Abi,
|
|
21
21
|
address: this.lpContract,
|
|
22
22
|
functionName: "convertToAssets",
|
|
@@ -9,7 +9,7 @@ class MellowLRTPriceFeedContract extends AbstractLPPriceFeedContract {
|
|
|
9
9
|
});
|
|
10
10
|
}
|
|
11
11
|
async getValue() {
|
|
12
|
-
const stack = await this.sdk.
|
|
12
|
+
const stack = await this.sdk.client.readContract({
|
|
13
13
|
abi: iMellowVaultAbi,
|
|
14
14
|
address: this.lpContract,
|
|
15
15
|
functionName: "calculateStack"
|
|
@@ -157,7 +157,7 @@ class PriceFeedRegister extends SDKConstruct {
|
|
|
157
157
|
VERSION_RANGE_310
|
|
158
158
|
);
|
|
159
159
|
const blockParam = block ?? { blockNumber: this.sdk.currentBlock };
|
|
160
|
-
const result = await this.
|
|
160
|
+
const result = await this.client.readContract({
|
|
161
161
|
address: priceFeedCompressorAddress,
|
|
162
162
|
abi: priceFeedCompressorAbi,
|
|
163
163
|
functionName: "loadPriceFeedTree",
|
|
@@ -214,7 +214,7 @@ class PriceFeedRegister extends SDKConstruct {
|
|
|
214
214
|
{ configurators, pools },
|
|
215
215
|
`calling getUpdatablePriceFeeds in block ${this.sdk.currentBlock}`
|
|
216
216
|
);
|
|
217
|
-
const result = await this.
|
|
217
|
+
const result = await this.client.readContract({
|
|
218
218
|
address: priceFeedCompressorAddress,
|
|
219
219
|
abi: priceFeedCompressorAbi,
|
|
220
220
|
functionName: "getUpdatablePriceFeeds",
|
|
@@ -9,7 +9,7 @@ class WstETHPriceFeedContract extends AbstractLPPriceFeedContract {
|
|
|
9
9
|
});
|
|
10
10
|
}
|
|
11
11
|
async getValue() {
|
|
12
|
-
return await this.sdk.
|
|
12
|
+
return await this.sdk.client.readContract({
|
|
13
13
|
abi: iwstEthAbi,
|
|
14
14
|
address: this.lpContract,
|
|
15
15
|
functionName: "stEthPerToken"
|
|
@@ -9,7 +9,7 @@ class YearnPriceFeedContract extends AbstractLPPriceFeedContract {
|
|
|
9
9
|
});
|
|
10
10
|
}
|
|
11
11
|
async getValue() {
|
|
12
|
-
return await this.sdk.
|
|
12
|
+
return await this.sdk.client.readContract({
|
|
13
13
|
abi: iyVaultAbi,
|
|
14
14
|
address: this.lpContract,
|
|
15
15
|
functionName: "pricePerShare"
|
|
@@ -27,17 +27,14 @@ class BasePlugin {
|
|
|
27
27
|
async syncState() {
|
|
28
28
|
await this.load(false);
|
|
29
29
|
}
|
|
30
|
-
get provider() {
|
|
31
|
-
return this.sdk.provider;
|
|
32
|
-
}
|
|
33
30
|
get network() {
|
|
34
|
-
return this.
|
|
31
|
+
return this.sdk.networkType;
|
|
35
32
|
}
|
|
36
33
|
get client() {
|
|
37
|
-
return this.
|
|
34
|
+
return this.sdk.client;
|
|
38
35
|
}
|
|
39
36
|
labelAddress(address) {
|
|
40
|
-
return this.
|
|
37
|
+
return this.sdk.labelAddress(address);
|
|
41
38
|
}
|
|
42
39
|
}
|
|
43
40
|
export {
|
|
@@ -11,7 +11,7 @@ class V300StalenessPeriodPlugin extends BasePlugin {
|
|
|
11
11
|
#events = [];
|
|
12
12
|
set sdk(sdk) {
|
|
13
13
|
super.sdk = sdk;
|
|
14
|
-
this.#syncedTo = (sdk.
|
|
14
|
+
this.#syncedTo = (sdk.chain.firstBlock ?? 1n) - 1n;
|
|
15
15
|
}
|
|
16
16
|
get sdk() {
|
|
17
17
|
return super.sdk;
|
|
@@ -39,7 +39,7 @@ class RouterV300Contract extends AbstractRouterContract {
|
|
|
39
39
|
abi: iRouterV300Abi,
|
|
40
40
|
version
|
|
41
41
|
});
|
|
42
|
-
this.#connectors = getConnectors(sdk.
|
|
42
|
+
this.#connectors = getConnectors(sdk.networkType);
|
|
43
43
|
}
|
|
44
44
|
/**
|
|
45
45
|
* Implements {@link IRouterContract.findAllSwaps}
|
|
@@ -267,7 +267,7 @@ class RouterV300Contract extends AbstractRouterContract {
|
|
|
267
267
|
}));
|
|
268
268
|
const pathOptions = PathOptionFactory.generatePathOptions(
|
|
269
269
|
ca.tokens,
|
|
270
|
-
this.
|
|
270
|
+
this.networkType,
|
|
271
271
|
LOOPS_PER_TX
|
|
272
272
|
);
|
|
273
273
|
const connectors = this.getAvailableConnectors(cm.collateralTokens);
|
|
@@ -320,12 +320,12 @@ class RouterV300Contract extends AbstractRouterContract {
|
|
|
320
320
|
Lisk: "0x0",
|
|
321
321
|
Plasma: "0x0"
|
|
322
322
|
};
|
|
323
|
-
const pendleRouter = PENDLE_ROUTER_BY_NETWORK[this.sdk.
|
|
323
|
+
const pendleRouter = PENDLE_ROUTER_BY_NETWORK[this.sdk.networkType];
|
|
324
324
|
const pendleAdapter = cm.creditManager.adapters.mustGet(pendleRouter);
|
|
325
325
|
const pendleSwapper = getContract({
|
|
326
326
|
address: pendleSwapperAddress,
|
|
327
327
|
abi: iSwapperV300Abi,
|
|
328
|
-
client: this.sdk.
|
|
328
|
+
client: this.sdk.client
|
|
329
329
|
});
|
|
330
330
|
const result = await pendleSwapper.simulate.getBestDirectPairSwap([
|
|
331
331
|
{
|
|
@@ -48,6 +48,7 @@ export interface AnvilClientConfig<transport extends Transport = Transport, chai
|
|
|
48
48
|
cacheTime?: number;
|
|
49
49
|
pollingInterval?: number;
|
|
50
50
|
}
|
|
51
|
+
export declare function extendAnvilClient(client: PublicClient): AnvilClient;
|
|
51
52
|
export declare function createAnvilClient({ chain, transport, cacheTime, pollingInterval, }: AnvilClientConfig): AnvilClient;
|
|
52
53
|
/**
|
|
53
54
|
* View action to detect if client is an anvil client
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { Address, Hex } from "viem";
|
|
2
|
+
import { type PublicClient, type Transport } from "viem";
|
|
2
3
|
import type { BaseContract, BaseState, IBaseContract } from "./base/index.js";
|
|
3
|
-
import { TokensMeta } from "./base/index.js";
|
|
4
|
-
import type {
|
|
5
|
-
import { Provider } from "./chain/index.js";
|
|
4
|
+
import { AddressLabeller, TokensMeta } from "./base/index.js";
|
|
5
|
+
import type { GearboxChain, NetworkType } from "./chain/chains.js";
|
|
6
6
|
import type { VersionRange } from "./constants/index.js";
|
|
7
7
|
import type { IAddressProviderContract } from "./core/index.js";
|
|
8
8
|
import { BotListContract, GearStakingContract } from "./core/index.js";
|
|
@@ -17,6 +17,41 @@ import { AddressMap } from "./utils/index.js";
|
|
|
17
17
|
* State version, checked duryng hydration
|
|
18
18
|
*/
|
|
19
19
|
export declare const STATE_VERSION = 1;
|
|
20
|
+
export interface NetworkOptions {
|
|
21
|
+
/**
|
|
22
|
+
* Chain Id needs to be set, because we sometimemes use forked testnets with different chain ids
|
|
23
|
+
*/
|
|
24
|
+
chainId: number;
|
|
25
|
+
/**
|
|
26
|
+
* NetworkType needs to be set, because we sometimemes use forked testnets with different chain ids
|
|
27
|
+
*/
|
|
28
|
+
networkType: NetworkType;
|
|
29
|
+
}
|
|
30
|
+
export type ClientOptions = {
|
|
31
|
+
/**
|
|
32
|
+
* RPC URL (and fallbacks) to use.
|
|
33
|
+
*/
|
|
34
|
+
rpcURLs: string[];
|
|
35
|
+
/**
|
|
36
|
+
* RPC client timeout in milliseconds
|
|
37
|
+
*/
|
|
38
|
+
timeout?: number;
|
|
39
|
+
/**
|
|
40
|
+
* Retry count for RPC
|
|
41
|
+
*/
|
|
42
|
+
retryCount?: number;
|
|
43
|
+
} | {
|
|
44
|
+
/**
|
|
45
|
+
* Alternatively, can pass viem transport
|
|
46
|
+
*/
|
|
47
|
+
transport: Transport;
|
|
48
|
+
} | {
|
|
49
|
+
/**
|
|
50
|
+
* Alternatively, can pass entire viem client
|
|
51
|
+
* If you bring your own client, it is responsible for defining networkType and chainId
|
|
52
|
+
*/
|
|
53
|
+
client: PublicClient<Transport, GearboxChain>;
|
|
54
|
+
};
|
|
20
55
|
export type HydrateOptions<Plugins extends PluginsMap> = Omit<SDKOptions<Plugins>, "blockNumber" | "addressProvider" | "marketConfigurators">;
|
|
21
56
|
export interface SyncStateOptions {
|
|
22
57
|
blockNumber: bigint;
|
|
@@ -32,6 +67,7 @@ export declare class GearboxSDK<const Plugins extends PluginsMap = {}> {
|
|
|
32
67
|
readonly plugins: Plugins;
|
|
33
68
|
readonly logger?: ILogger;
|
|
34
69
|
readonly gasLimit: bigint | undefined;
|
|
70
|
+
readonly addressLabels: AddressLabeller;
|
|
35
71
|
/**
|
|
36
72
|
* Interest rate models can be reused across chain (and SDK operates on chain level)
|
|
37
73
|
* TODO: use whatever interface is necessary for InterestRateModels
|
|
@@ -51,8 +87,8 @@ export declare class GearboxSDK<const Plugins extends PluginsMap = {}> {
|
|
|
51
87
|
readonly tokensMeta: TokensMeta;
|
|
52
88
|
addHook: <K extends keyof SDKHooks>(hookName: K, fn: (...args: SDKHooks[K]) => void | Promise<void>) => void;
|
|
53
89
|
removeHook: <K extends keyof SDKHooks>(hookName: K, fn: (...args: SDKHooks[K]) => void | Promise<void>) => void;
|
|
54
|
-
static attach<const Plugins extends PluginsMap>(options: SDKOptions<Plugins> & Partial<NetworkOptions>
|
|
55
|
-
static hydrate<const Plugins extends PluginsMap>(options: HydrateOptions<Plugins> &
|
|
90
|
+
static attach<const Plugins extends PluginsMap>(options: SDKOptions<Plugins> & ClientOptions & Partial<NetworkOptions>): Promise<GearboxSDK<Plugins>>;
|
|
91
|
+
static hydrate<const Plugins extends PluginsMap>(options: HydrateOptions<Plugins> & ClientOptions, state: GearboxState<Plugins>): GearboxSDK<Plugins>;
|
|
56
92
|
private constructor();
|
|
57
93
|
/**
|
|
58
94
|
* Reattach SDK with the same config as before, without re-creating instance. Will load all state from scratch
|
|
@@ -63,6 +99,16 @@ export declare class GearboxSDK<const Plugins extends PluginsMap = {}> {
|
|
|
63
99
|
* Rehydrate existing SDK from new state without re-creating instance
|
|
64
100
|
*/
|
|
65
101
|
rehydrate(state: GearboxState<Plugins>): Promise<void>;
|
|
102
|
+
get client(): PublicClient<Transport, GearboxChain>;
|
|
103
|
+
/**
|
|
104
|
+
* Replaces client inflight
|
|
105
|
+
* You're responsible for all inconsistencies between new and old client
|
|
106
|
+
* @param options
|
|
107
|
+
*/
|
|
108
|
+
replaceClient(options: ClientOptions, network?: NetworkOptions): void;
|
|
109
|
+
get networkType(): NetworkType;
|
|
110
|
+
get chain(): GearboxChain;
|
|
111
|
+
get chainId(): number;
|
|
66
112
|
/**
|
|
67
113
|
* Converts contract call into some human-friendly string
|
|
68
114
|
* This method is safe and should not throw
|
|
@@ -111,7 +157,6 @@ export declare class GearboxSDK<const Plugins extends PluginsMap = {}> {
|
|
|
111
157
|
* @returns true if successful, false if was skipped or failed
|
|
112
158
|
*/
|
|
113
159
|
syncState(opts?: SyncStateOptions): Promise<boolean>;
|
|
114
|
-
get provider(): Provider;
|
|
115
160
|
get currentBlock(): bigint;
|
|
116
161
|
get timestamp(): bigint;
|
|
117
162
|
/**
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { Abi, Address, Client, ContractEventName, ContractFunctionName, DecodeFunctionDataReturnType, EncodeFunctionDataParameters, GetContractReturnType, Hex, Log } from "viem";
|
|
2
2
|
import type { GearboxSDK } from "../GearboxSDK.js";
|
|
3
3
|
import type { BaseContractStateHuman, ILogger, RawTx } from "../types/index.js";
|
|
4
|
-
import type { IAddressLabeller } from "./IAddressLabeller.js";
|
|
5
4
|
import { SDKConstruct } from "./SDKConstruct.js";
|
|
6
5
|
export interface BaseContractOptions<abi extends Abi | readonly unknown[]> {
|
|
7
6
|
abi: abi;
|
|
@@ -56,5 +55,4 @@ export declare abstract class BaseContract<abi extends Abi | readonly unknown[]>
|
|
|
56
55
|
createRawTx<functionName extends ContractFunctionName<abi> | undefined = undefined>(parameters: Omit<EncodeFunctionDataParameters<abi, functionName>, "abi"> & {
|
|
57
56
|
description?: string;
|
|
58
57
|
}): RawTx;
|
|
59
|
-
protected get addressLabels(): IAddressLabeller;
|
|
60
58
|
}
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import type { Address, PublicClient } from "viem";
|
|
2
|
-
import type { NetworkType
|
|
2
|
+
import type { NetworkType } from "../chain/index.js";
|
|
3
3
|
import type { GearboxSDK } from "../GearboxSDK.js";
|
|
4
4
|
import type { PluginsMap } from "../plugins/index.js";
|
|
5
5
|
export declare class SDKConstruct<const Plugins extends PluginsMap = {}> {
|
|
6
6
|
#private;
|
|
7
7
|
readonly sdk: GearboxSDK<Plugins>;
|
|
8
8
|
constructor(sdk: GearboxSDK<Plugins>);
|
|
9
|
-
get
|
|
10
|
-
get network(): NetworkType;
|
|
9
|
+
get networkType(): NetworkType;
|
|
11
10
|
get client(): PublicClient;
|
|
12
11
|
/**
|
|
13
12
|
* Indicates that contract state needs to be updated
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Address, PublicClient } from "viem";
|
|
2
|
-
import type { NetworkType
|
|
2
|
+
import type { NetworkType } from "../chain/index.js";
|
|
3
3
|
import type { GearboxSDK } from "../GearboxSDK.js";
|
|
4
4
|
import type { ILogger } from "../index.js";
|
|
5
5
|
export declare abstract class BasePlugin<TState extends Record<keyof TState, unknown> = {}> {
|
|
@@ -13,7 +13,6 @@ export declare abstract class BasePlugin<TState extends Record<keyof TState, unk
|
|
|
13
13
|
attach(): Promise<void>;
|
|
14
14
|
syncState(): Promise<void>;
|
|
15
15
|
abstract load(force?: boolean): Promise<TState>;
|
|
16
|
-
get provider(): Provider;
|
|
17
16
|
get network(): NetworkType;
|
|
18
17
|
get client(): PublicClient;
|
|
19
18
|
protected labelAddress(address: Address): string;
|
package/package.json
CHANGED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var Provider_exports = {};
|
|
20
|
-
__export(Provider_exports, {
|
|
21
|
-
Provider: () => Provider,
|
|
22
|
-
createTransportClient: () => createTransportClient
|
|
23
|
-
});
|
|
24
|
-
module.exports = __toCommonJS(Provider_exports);
|
|
25
|
-
var import_viem = require("viem");
|
|
26
|
-
var import_AddressLabeller = require("../base/AddressLabeller.js");
|
|
27
|
-
var import_chains = require("./chains.js");
|
|
28
|
-
function createTransportClient(opts, chain) {
|
|
29
|
-
const { timeout = 12e4, retryCount } = opts;
|
|
30
|
-
let transport;
|
|
31
|
-
if ("client" in opts) {
|
|
32
|
-
transport = () => ({
|
|
33
|
-
config: opts.client.transport.config,
|
|
34
|
-
request: opts.client.transport.request,
|
|
35
|
-
value: opts.client.transport.value
|
|
36
|
-
});
|
|
37
|
-
return [transport, opts.client];
|
|
38
|
-
}
|
|
39
|
-
if ("transport" in opts) {
|
|
40
|
-
transport = opts.transport;
|
|
41
|
-
} else {
|
|
42
|
-
const rpcs = opts.rpcURLs.map((url) => (0, import_viem.http)(url, { timeout, retryCount }));
|
|
43
|
-
transport = rpcs.length > 1 ? (0, import_viem.fallback)(rpcs) : rpcs[0];
|
|
44
|
-
}
|
|
45
|
-
return [transport, (0, import_viem.createPublicClient)({ transport, chain })];
|
|
46
|
-
}
|
|
47
|
-
class Provider {
|
|
48
|
-
chainId;
|
|
49
|
-
chain;
|
|
50
|
-
networkType;
|
|
51
|
-
addressLabels;
|
|
52
|
-
#transport;
|
|
53
|
-
#publicClient;
|
|
54
|
-
constructor(opts) {
|
|
55
|
-
const { chainId, networkType } = opts;
|
|
56
|
-
this.chainId = chainId;
|
|
57
|
-
this.networkType = networkType;
|
|
58
|
-
this.chain = (0, import_viem.defineChain)({
|
|
59
|
-
...import_chains.chains[networkType],
|
|
60
|
-
id: chainId
|
|
61
|
-
});
|
|
62
|
-
[this.#transport, this.#publicClient] = createTransportClient(
|
|
63
|
-
opts,
|
|
64
|
-
this.chain
|
|
65
|
-
);
|
|
66
|
-
this.addressLabels = new import_AddressLabeller.AddressLabeller();
|
|
67
|
-
}
|
|
68
|
-
get transport() {
|
|
69
|
-
return this.#transport;
|
|
70
|
-
}
|
|
71
|
-
set transport(transport) {
|
|
72
|
-
this.#transport = transport;
|
|
73
|
-
this.#publicClient = (0, import_viem.createPublicClient)({
|
|
74
|
-
chain: this.chain,
|
|
75
|
-
transport: this.#transport
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
get publicClient() {
|
|
79
|
-
return this.#publicClient;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
83
|
-
0 && (module.exports = {
|
|
84
|
-
Provider,
|
|
85
|
-
createTransportClient
|
|
86
|
-
});
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { createPublicClient, defineChain, fallback, http } from "viem";
|
|
2
|
-
import { AddressLabeller } from "../base/AddressLabeller.js";
|
|
3
|
-
import { chains } from "./chains.js";
|
|
4
|
-
function createTransportClient(opts, chain) {
|
|
5
|
-
const { timeout = 12e4, retryCount } = opts;
|
|
6
|
-
let transport;
|
|
7
|
-
if ("client" in opts) {
|
|
8
|
-
transport = () => ({
|
|
9
|
-
config: opts.client.transport.config,
|
|
10
|
-
request: opts.client.transport.request,
|
|
11
|
-
value: opts.client.transport.value
|
|
12
|
-
});
|
|
13
|
-
return [transport, opts.client];
|
|
14
|
-
}
|
|
15
|
-
if ("transport" in opts) {
|
|
16
|
-
transport = opts.transport;
|
|
17
|
-
} else {
|
|
18
|
-
const rpcs = opts.rpcURLs.map((url) => http(url, { timeout, retryCount }));
|
|
19
|
-
transport = rpcs.length > 1 ? fallback(rpcs) : rpcs[0];
|
|
20
|
-
}
|
|
21
|
-
return [transport, createPublicClient({ transport, chain })];
|
|
22
|
-
}
|
|
23
|
-
class Provider {
|
|
24
|
-
chainId;
|
|
25
|
-
chain;
|
|
26
|
-
networkType;
|
|
27
|
-
addressLabels;
|
|
28
|
-
#transport;
|
|
29
|
-
#publicClient;
|
|
30
|
-
constructor(opts) {
|
|
31
|
-
const { chainId, networkType } = opts;
|
|
32
|
-
this.chainId = chainId;
|
|
33
|
-
this.networkType = networkType;
|
|
34
|
-
this.chain = defineChain({
|
|
35
|
-
...chains[networkType],
|
|
36
|
-
id: chainId
|
|
37
|
-
});
|
|
38
|
-
[this.#transport, this.#publicClient] = createTransportClient(
|
|
39
|
-
opts,
|
|
40
|
-
this.chain
|
|
41
|
-
);
|
|
42
|
-
this.addressLabels = new AddressLabeller();
|
|
43
|
-
}
|
|
44
|
-
get transport() {
|
|
45
|
-
return this.#transport;
|
|
46
|
-
}
|
|
47
|
-
set transport(transport) {
|
|
48
|
-
this.#transport = transport;
|
|
49
|
-
this.#publicClient = createPublicClient({
|
|
50
|
-
chain: this.chain,
|
|
51
|
-
transport: this.#transport
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
get publicClient() {
|
|
55
|
-
return this.#publicClient;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
export {
|
|
59
|
-
Provider,
|
|
60
|
-
createTransportClient
|
|
61
|
-
};
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import type { Chain, PublicClient, Transport } from "viem";
|
|
2
|
-
import type { IAddressLabeller } from "../base/IAddressLabeller.js";
|
|
3
|
-
import type { GearboxChain, NetworkType } from "./chains.js";
|
|
4
|
-
export interface NetworkOptions {
|
|
5
|
-
/**
|
|
6
|
-
* Chain Id needs to be set, because we sometimemes use forked testnets with different chain ids
|
|
7
|
-
*/
|
|
8
|
-
chainId: number;
|
|
9
|
-
/**
|
|
10
|
-
* NetworkType needs to be set, because we sometimemes use forked testnets with different chain ids
|
|
11
|
-
*/
|
|
12
|
-
networkType: NetworkType;
|
|
13
|
-
}
|
|
14
|
-
export type TransportOptions = {
|
|
15
|
-
/**
|
|
16
|
-
* RPC URL (and fallbacks) to use.
|
|
17
|
-
*/
|
|
18
|
-
rpcURLs: string[];
|
|
19
|
-
} | {
|
|
20
|
-
/**
|
|
21
|
-
* Alternatively, can pass viem transport
|
|
22
|
-
*/
|
|
23
|
-
transport: Transport;
|
|
24
|
-
} | {
|
|
25
|
-
/**
|
|
26
|
-
* Alternatively, can pass entire viem client
|
|
27
|
-
*/
|
|
28
|
-
client: PublicClient;
|
|
29
|
-
};
|
|
30
|
-
export interface ConnectionOptions {
|
|
31
|
-
/**
|
|
32
|
-
* RPC client timeout in milliseconds
|
|
33
|
-
*/
|
|
34
|
-
timeout?: number;
|
|
35
|
-
/**
|
|
36
|
-
* Retry count for RPC
|
|
37
|
-
*/
|
|
38
|
-
retryCount?: number;
|
|
39
|
-
}
|
|
40
|
-
export declare function createTransportClient(opts: TransportOptions & ConnectionOptions, chain?: Chain): [Transport, PublicClient];
|
|
41
|
-
export declare class Provider {
|
|
42
|
-
#private;
|
|
43
|
-
readonly chainId: number;
|
|
44
|
-
readonly chain: GearboxChain;
|
|
45
|
-
readonly networkType: NetworkType;
|
|
46
|
-
readonly addressLabels: IAddressLabeller;
|
|
47
|
-
constructor(opts: NetworkOptions & TransportOptions & ConnectionOptions);
|
|
48
|
-
get transport(): Transport;
|
|
49
|
-
set transport(transport: Transport);
|
|
50
|
-
get publicClient(): PublicClient;
|
|
51
|
-
}
|