@gearbox-protocol/sdk 13.0.0-beta.2 → 13.0.0-beta.4
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/abi/iPriceFeed.js +84 -0
- package/dist/cjs/permissionless/bindings/cross-chain-multisig.js +3 -3
- package/dist/cjs/permissionless/bindings/instance-manager.js +2 -2
- package/dist/cjs/plugins/adapters/contracts/MellowDepositQueueAdapterContract.js +0 -6
- package/dist/cjs/plugins/adapters/contracts/MellowRedeemQueueAdapterContract.js +0 -6
- package/dist/cjs/sdk/GearboxSDK.js +0 -2
- package/dist/cjs/sdk/base/BaseContract.js +5 -2
- package/dist/cjs/sdk/base/ChainContractsRegister.js +2 -10
- package/dist/cjs/sdk/base/Construct.js +25 -19
- package/dist/cjs/sdk/base/SDKConstruct.js +1 -1
- package/dist/cjs/sdk/market/adapters/PlaceholderAdapterContracts.js +16 -0
- package/dist/cjs/sdk/market/pricefeeds/updates/PriceUpdatesCache.js +0 -17
- package/dist/cjs/sdk/market/pricefeeds/updates/PythUpdater.js +1 -1
- package/dist/cjs/sdk/market/pricefeeds/updates/RedstoneUpdater.js +1 -1
- package/dist/cjs/sdk/market/pricefeeds/updates/fetchPythPayloads.js +2 -2
- package/dist/cjs/sdk/utils/assetsMath.js +10 -9
- package/dist/cjs/sdk/utils/creditAccount.js +44 -40
- package/dist/cjs/sdk/utils/endpoints.js +71 -0
- package/dist/cjs/sdk/utils/formatter.js +3 -3
- package/dist/cjs/sdk/utils/index.js +2 -0
- package/dist/cjs/sdk/utils/priceMath.js +3 -3
- package/dist/esm/abi/iPriceFeed.js +60 -0
- package/dist/esm/permissionless/bindings/cross-chain-multisig.js +3 -3
- package/dist/esm/permissionless/bindings/instance-manager.js +2 -2
- package/dist/esm/plugins/adapters/contracts/MellowDepositQueueAdapterContract.js +0 -6
- package/dist/esm/plugins/adapters/contracts/MellowRedeemQueueAdapterContract.js +0 -6
- package/dist/esm/sdk/GearboxSDK.js +0 -2
- package/dist/esm/sdk/base/BaseContract.js +5 -2
- package/dist/esm/sdk/base/ChainContractsRegister.js +2 -10
- package/dist/esm/sdk/base/Construct.js +25 -19
- package/dist/esm/sdk/base/SDKConstruct.js +1 -1
- package/dist/esm/sdk/market/adapters/PlaceholderAdapterContracts.js +16 -0
- package/dist/esm/sdk/market/pricefeeds/updates/PriceUpdatesCache.js +0 -17
- package/dist/esm/sdk/market/pricefeeds/updates/PythUpdater.js +1 -1
- package/dist/esm/sdk/market/pricefeeds/updates/RedstoneUpdater.js +1 -1
- package/dist/esm/sdk/market/pricefeeds/updates/fetchPythPayloads.js +2 -2
- package/dist/esm/sdk/utils/assetsMath.js +2 -1
- package/dist/esm/sdk/utils/creditAccount.js +5 -3
- package/dist/esm/sdk/utils/endpoints.js +46 -0
- package/dist/esm/sdk/utils/formatter.js +1 -1
- package/dist/esm/sdk/utils/index.js +1 -0
- package/dist/esm/sdk/utils/priceMath.js +1 -1
- package/dist/types/abi/iPriceFeed.d.ts +87 -0
- package/dist/types/permissionless/bindings/cross-chain-multisig.d.ts +3 -3
- package/dist/types/permissionless/bindings/instance-manager.d.ts +3 -3
- package/dist/types/plugins/adapters/contracts/MellowDepositQueueAdapterContract.d.ts +1 -4
- package/dist/types/plugins/adapters/contracts/MellowRedeemQueueAdapterContract.d.ts +1 -4
- package/dist/types/sdk/base/ChainContractsRegister.d.ts +0 -2
- package/dist/types/sdk/base/Construct.d.ts +7 -10
- package/dist/types/sdk/market/adapters/PlaceholderAdapterContracts.d.ts +2 -1
- package/dist/types/sdk/market/pricefeeds/updates/PriceUpdatesCache.d.ts +1 -8
- package/dist/types/sdk/utils/assetsMath.d.ts +1 -1
- package/dist/types/sdk/utils/creditAccount.d.ts +4 -3
- package/dist/types/sdk/utils/endpoints.d.ts +19 -0
- package/dist/types/sdk/utils/index.d.ts +1 -0
- package/package.json +6 -2
|
@@ -1,21 +1,4 @@
|
|
|
1
1
|
class PriceUpdatesCache {
|
|
2
|
-
static #caches = /* @__PURE__ */ new Map();
|
|
3
|
-
/**
|
|
4
|
-
* Price update caches can be shared across networks
|
|
5
|
-
* @param id - unique key to identify the cache
|
|
6
|
-
* @param opts
|
|
7
|
-
* @returns
|
|
8
|
-
*/
|
|
9
|
-
static get(id, opts) {
|
|
10
|
-
const key = `${id}:${opts.historical ? "historical" : "latest"}:${opts.ttl}`;
|
|
11
|
-
const cache = PriceUpdatesCache.#caches.get(key);
|
|
12
|
-
if (cache) {
|
|
13
|
-
return cache;
|
|
14
|
-
}
|
|
15
|
-
const newCache = new PriceUpdatesCache(opts);
|
|
16
|
-
PriceUpdatesCache.#caches.set(key, newCache);
|
|
17
|
-
return newCache;
|
|
18
|
-
}
|
|
19
2
|
#cache = /* @__PURE__ */ new Map();
|
|
20
3
|
#ttlMs;
|
|
21
4
|
#historical;
|
|
@@ -44,7 +44,7 @@ class PythUpdater extends SDKConstruct {
|
|
|
44
44
|
`using historical timestamp ${this.#historicalTimestamp}`
|
|
45
45
|
);
|
|
46
46
|
}
|
|
47
|
-
this.#cache = PriceUpdatesCache
|
|
47
|
+
this.#cache = new PriceUpdatesCache({
|
|
48
48
|
// currently staleness period is 240 seconds on all networks, add some buffer
|
|
49
49
|
// this period of 4 minutes is selected based on time that is required for user to sign transaction with wallet
|
|
50
50
|
// so it's unlikely to decrease
|
|
@@ -52,7 +52,7 @@ class RedstoneUpdater extends SDKConstruct {
|
|
|
52
52
|
`using historical timestamp ${this.#historicalTimestampMs}`
|
|
53
53
|
);
|
|
54
54
|
}
|
|
55
|
-
this.#cache = PriceUpdatesCache
|
|
55
|
+
this.#cache = new PriceUpdatesCache({
|
|
56
56
|
// currently staleness period is 240 seconds on all networks, add some buffer
|
|
57
57
|
// this period of 4 minutes is selected based on time that is required for user to sign transaction with wallet
|
|
58
58
|
// so it's unlikely to decrease
|
|
@@ -16,7 +16,7 @@ async function fetchPythPayloads(options) {
|
|
|
16
16
|
customFetch = fetch,
|
|
17
17
|
returnPrices
|
|
18
18
|
} = options;
|
|
19
|
-
const ids = Array.from(new Set(dataFeedsIds));
|
|
19
|
+
const ids = Array.from(new Set(dataFeedsIds)).sort();
|
|
20
20
|
if (ids.length === 0) {
|
|
21
21
|
return [];
|
|
22
22
|
}
|
|
@@ -27,7 +27,7 @@ async function fetchPythPayloads(options) {
|
|
|
27
27
|
if (ignoreMissingFeeds) {
|
|
28
28
|
url.searchParams.append("ignore_invalid_price_ids", "true");
|
|
29
29
|
}
|
|
30
|
-
for (const id of
|
|
30
|
+
for (const id of ids) {
|
|
31
31
|
url.searchParams.append("ids[]", id);
|
|
32
32
|
}
|
|
33
33
|
const resp = await retry(
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { BigIntMath
|
|
1
|
+
import { BigIntMath } from "./bigintMath.js";
|
|
2
2
|
import { CreditAccountDataUtils } from "./creditAccount.js";
|
|
3
|
+
import { PriceUtils } from "./priceMath.js";
|
|
3
4
|
class AssetUtils {
|
|
4
5
|
static nextAsset({
|
|
5
6
|
allowedTokens,
|
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
import {
|
|
2
|
-
BigIntMath,
|
|
3
2
|
MIN_INT96,
|
|
4
3
|
PERCENTAGE_DECIMALS,
|
|
5
4
|
PERCENTAGE_FACTOR,
|
|
6
5
|
PRICE_DECIMALS,
|
|
7
6
|
PRICE_DECIMALS_POW,
|
|
8
|
-
PriceUtils,
|
|
9
7
|
SECONDS_PER_YEAR,
|
|
10
8
|
WAD,
|
|
11
9
|
WAD_DECIMALS_POW
|
|
12
|
-
} from "../index.js";
|
|
10
|
+
} from "../constants/index.js";
|
|
11
|
+
import { BigIntMath } from "./bigintMath.js";
|
|
12
|
+
import { PriceUtils } from "./priceMath.js";
|
|
13
13
|
const MAX_UINT16 = 65535;
|
|
14
14
|
class CreditAccountDataUtils {
|
|
15
|
+
constructor() {
|
|
16
|
+
}
|
|
15
17
|
static sortBalances(balances, prices, tokens) {
|
|
16
18
|
return Object.entries(balances).sort(
|
|
17
19
|
([addr1, amount1], [addr2, amount2]) => {
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { isSupportedNetwork } from "../chain/chains.js";
|
|
2
|
+
const CHARTS_BACKEND_ADDRESS = "https://charts-server.fly.dev";
|
|
3
|
+
const STATIC_TOKEN = "https://static.gearbox.finance/tokens/";
|
|
4
|
+
class GearboxBackendApi {
|
|
5
|
+
constructor() {
|
|
6
|
+
}
|
|
7
|
+
static getChartsUrl = (url, chainId, options = { params: {} }, priceSource) => {
|
|
8
|
+
const domain = CHARTS_BACKEND_ADDRESS;
|
|
9
|
+
const priceSourceArr = priceSource ? [priceSource] : [];
|
|
10
|
+
const isMain = isSupportedNetwork(chainId);
|
|
11
|
+
const relativePath = URLApi.getRelativeUrl(
|
|
12
|
+
url,
|
|
13
|
+
isMain ? {
|
|
14
|
+
...options,
|
|
15
|
+
params: { ...options.params, chainId }
|
|
16
|
+
} : options
|
|
17
|
+
);
|
|
18
|
+
return [domain, "api", ...priceSourceArr, relativePath].join("/");
|
|
19
|
+
};
|
|
20
|
+
static getStaticTokenUrl = () => STATIC_TOKEN;
|
|
21
|
+
static getRewardsMerkleUrl = (network, root, account) => {
|
|
22
|
+
const path = `${network}_${root.slice(2)}/${account.slice(2, 4)}`;
|
|
23
|
+
const url = `https://am.gearbox.finance/${path.toLowerCase()}.json`;
|
|
24
|
+
return url;
|
|
25
|
+
};
|
|
26
|
+
static getNFTMerkleUrl = (network, root) => {
|
|
27
|
+
const url = `https://dm.gearbox.finance/${network.toLowerCase()}_${root}.json`;
|
|
28
|
+
return url;
|
|
29
|
+
};
|
|
30
|
+
static apyAllRewards = () => URLApi.getRelativeUrl(
|
|
31
|
+
"https://state-cache.gearbox.foundation/apy-server/latest.json"
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
class URLApi {
|
|
35
|
+
constructor() {
|
|
36
|
+
}
|
|
37
|
+
static getRelativeUrl = (url, options) => {
|
|
38
|
+
const { params = {} } = options || {};
|
|
39
|
+
const paramsString = Object.entries(params).map(([key, value]) => `${key}=${value}`).join("&");
|
|
40
|
+
return [url, ...paramsString ? [paramsString] : []].join("?");
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
export {
|
|
44
|
+
GearboxBackendApi,
|
|
45
|
+
URLApi
|
|
46
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { formatDuration as fmtDuration, intervalToDuration } from "date-fns";
|
|
2
2
|
import Decimal from "decimal.js-light";
|
|
3
|
-
import { LEVERAGE_DECIMALS, PERCENTAGE_FACTOR } from "../index.js";
|
|
3
|
+
import { LEVERAGE_DECIMALS, PERCENTAGE_FACTOR } from "../constants/index.js";
|
|
4
4
|
const toBigInt = (v) => {
|
|
5
5
|
const value = typeof v === "object" && v.type === "BigNumber" ? v.hex : v.toString();
|
|
6
6
|
return BigInt(value);
|
|
@@ -7,6 +7,7 @@ export * from "./bytes32ToString.js";
|
|
|
7
7
|
export * from "./childLogger.js";
|
|
8
8
|
export * from "./createRawTx.js";
|
|
9
9
|
export * from "./creditAccount.js";
|
|
10
|
+
export * from "./endpoints.js";
|
|
10
11
|
export * from "./etherscan.js";
|
|
11
12
|
export * from "./filterDust.js";
|
|
12
13
|
export * from "./formatter.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PRICE_DECIMALS, WAD } from "../index.js";
|
|
1
|
+
import { PRICE_DECIMALS, WAD } from "../constants/index.js";
|
|
2
2
|
class PriceUtils {
|
|
3
3
|
static calcTotalPrice = (price, amount, decimals = 18) => amount * WAD * price / 10n ** BigInt(decimals) / PRICE_DECIMALS;
|
|
4
4
|
static convertByPrice(totalMoney, { price: targetPrice, decimals: targetDecimals = 18 }) {
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
export declare const iPriceFeedAbi: readonly [{
|
|
2
|
+
readonly type: "function";
|
|
3
|
+
readonly name: "contractType";
|
|
4
|
+
readonly inputs: readonly [];
|
|
5
|
+
readonly outputs: readonly [{
|
|
6
|
+
readonly name: "";
|
|
7
|
+
readonly type: "bytes32";
|
|
8
|
+
readonly internalType: "bytes32";
|
|
9
|
+
}];
|
|
10
|
+
readonly stateMutability: "view";
|
|
11
|
+
}, {
|
|
12
|
+
readonly type: "function";
|
|
13
|
+
readonly name: "decimals";
|
|
14
|
+
readonly inputs: readonly [];
|
|
15
|
+
readonly outputs: readonly [{
|
|
16
|
+
readonly name: "";
|
|
17
|
+
readonly type: "uint8";
|
|
18
|
+
readonly internalType: "uint8";
|
|
19
|
+
}];
|
|
20
|
+
readonly stateMutability: "view";
|
|
21
|
+
}, {
|
|
22
|
+
readonly type: "function";
|
|
23
|
+
readonly name: "description";
|
|
24
|
+
readonly inputs: readonly [];
|
|
25
|
+
readonly outputs: readonly [{
|
|
26
|
+
readonly name: "";
|
|
27
|
+
readonly type: "string";
|
|
28
|
+
readonly internalType: "string";
|
|
29
|
+
}];
|
|
30
|
+
readonly stateMutability: "view";
|
|
31
|
+
}, {
|
|
32
|
+
readonly type: "function";
|
|
33
|
+
readonly name: "latestRoundData";
|
|
34
|
+
readonly inputs: readonly [];
|
|
35
|
+
readonly outputs: readonly [{
|
|
36
|
+
readonly name: "";
|
|
37
|
+
readonly type: "uint80";
|
|
38
|
+
readonly internalType: "uint80";
|
|
39
|
+
}, {
|
|
40
|
+
readonly name: "answer";
|
|
41
|
+
readonly type: "int256";
|
|
42
|
+
readonly internalType: "int256";
|
|
43
|
+
}, {
|
|
44
|
+
readonly name: "";
|
|
45
|
+
readonly type: "uint256";
|
|
46
|
+
readonly internalType: "uint256";
|
|
47
|
+
}, {
|
|
48
|
+
readonly name: "updatedAt";
|
|
49
|
+
readonly type: "uint256";
|
|
50
|
+
readonly internalType: "uint256";
|
|
51
|
+
}, {
|
|
52
|
+
readonly name: "";
|
|
53
|
+
readonly type: "uint80";
|
|
54
|
+
readonly internalType: "uint80";
|
|
55
|
+
}];
|
|
56
|
+
readonly stateMutability: "view";
|
|
57
|
+
}, {
|
|
58
|
+
readonly type: "function";
|
|
59
|
+
readonly name: "serialize";
|
|
60
|
+
readonly inputs: readonly [];
|
|
61
|
+
readonly outputs: readonly [{
|
|
62
|
+
readonly name: "serializedData";
|
|
63
|
+
readonly type: "bytes";
|
|
64
|
+
readonly internalType: "bytes";
|
|
65
|
+
}];
|
|
66
|
+
readonly stateMutability: "view";
|
|
67
|
+
}, {
|
|
68
|
+
readonly type: "function";
|
|
69
|
+
readonly name: "skipPriceCheck";
|
|
70
|
+
readonly inputs: readonly [];
|
|
71
|
+
readonly outputs: readonly [{
|
|
72
|
+
readonly name: "";
|
|
73
|
+
readonly type: "bool";
|
|
74
|
+
readonly internalType: "bool";
|
|
75
|
+
}];
|
|
76
|
+
readonly stateMutability: "view";
|
|
77
|
+
}, {
|
|
78
|
+
readonly type: "function";
|
|
79
|
+
readonly name: "version";
|
|
80
|
+
readonly inputs: readonly [];
|
|
81
|
+
readonly outputs: readonly [{
|
|
82
|
+
readonly name: "";
|
|
83
|
+
readonly type: "uint256";
|
|
84
|
+
readonly internalType: "uint256";
|
|
85
|
+
}];
|
|
86
|
+
readonly stateMutability: "view";
|
|
87
|
+
}];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { type Address, type
|
|
1
|
+
import { type Address, type DecodeFunctionDataReturnType, type Hex, type WalletClient } from "viem";
|
|
2
2
|
import type { RawTx } from "../../sdk/index.js";
|
|
3
|
-
import { BaseContract, type ParsedCallArgs } from "../../sdk/index.js";
|
|
3
|
+
import { BaseContract, type ChainContractsRegister, type ParsedCallArgs } from "../../sdk/index.js";
|
|
4
4
|
import type { Batch, RecoveryMessage } from "../core/proposal.js";
|
|
5
5
|
declare const abi: readonly [{
|
|
6
6
|
readonly type: "constructor";
|
|
@@ -726,7 +726,7 @@ export interface Proposal {
|
|
|
726
726
|
}
|
|
727
727
|
export declare class CrossChainMultisigContract extends BaseContract<typeof abi> {
|
|
728
728
|
#private;
|
|
729
|
-
constructor(addr: Address,
|
|
729
|
+
constructor(addr: Address, register: ChainContractsRegister);
|
|
730
730
|
getExecutedBatches(fromBlock: bigint, toBlock: bigint): Promise<Omit<Batch, "timestamp">[]>;
|
|
731
731
|
getCurrentBatches(): Promise<Batch[]>;
|
|
732
732
|
getBatchData(args: {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { type Address, type
|
|
1
|
+
import { type Address, type DecodeFunctionDataReturnType, type Hex } from "viem";
|
|
2
2
|
import type { RawTx } from "../../sdk/index.js";
|
|
3
|
-
import { BaseContract, type ParsedCall, type ParsedCallArgs } from "../../sdk/index.js";
|
|
3
|
+
import { BaseContract, type ChainContractsRegister, type ParsedCall, type ParsedCallArgs } from "../../sdk/index.js";
|
|
4
4
|
declare const abi: readonly [{
|
|
5
5
|
readonly type: "constructor";
|
|
6
6
|
readonly inputs: readonly [{
|
|
@@ -329,7 +329,7 @@ declare const abi: readonly [{
|
|
|
329
329
|
}];
|
|
330
330
|
export declare class InstanceManagerContract extends BaseContract<typeof abi> {
|
|
331
331
|
#private;
|
|
332
|
-
constructor(addr: Address,
|
|
332
|
+
constructor(addr: Address, register: ChainContractsRegister);
|
|
333
333
|
mustParseFunctionData(calldata: Hex): ParsedCall;
|
|
334
334
|
protected parseFunctionParams(params: DecodeFunctionDataReturnType<typeof abi>): ParsedCallArgs;
|
|
335
335
|
isActivated(): Promise<boolean>;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { type Address } from "viem";
|
|
2
|
-
import { type ConstructOptions
|
|
3
|
-
import type { LegacyAdapterOperation, Transfers } from "../legacyAdapterOperations.js";
|
|
2
|
+
import { type ConstructOptions } from "../../../sdk/index.js";
|
|
4
3
|
import type { ConcreteAdapterContractOptions } from "./AbstractAdapter.js";
|
|
5
4
|
import { AbstractAdapterContract } from "./AbstractAdapter.js";
|
|
6
5
|
declare const abi: readonly [];
|
|
@@ -23,7 +22,5 @@ export declare class MellowDepositQueueAdapterContract extends AbstractAdapterCo
|
|
|
23
22
|
version: number;
|
|
24
23
|
contractType?: string;
|
|
25
24
|
};
|
|
26
|
-
/** Legacy adapter not present in integrations-v3. */
|
|
27
|
-
protected classifyLegacyOperation(_parsed: ParsedCallV2, _transfers: Transfers): LegacyAdapterOperation;
|
|
28
25
|
}
|
|
29
26
|
export {};
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { type Address } from "viem";
|
|
2
|
-
import { type ConstructOptions
|
|
3
|
-
import type { LegacyAdapterOperation, Transfers } from "../legacyAdapterOperations.js";
|
|
2
|
+
import { type ConstructOptions } from "../../../sdk/index.js";
|
|
4
3
|
import type { ConcreteAdapterContractOptions } from "./AbstractAdapter.js";
|
|
5
4
|
import { AbstractAdapterContract } from "./AbstractAdapter.js";
|
|
6
5
|
declare const abi: readonly [];
|
|
@@ -21,7 +20,5 @@ export declare class MellowRedeemQueueAdapterContract extends AbstractAdapterCon
|
|
|
21
20
|
version: number;
|
|
22
21
|
contractType?: string;
|
|
23
22
|
};
|
|
24
|
-
/** Legacy adapter not present in integrations-v3. */
|
|
25
|
-
protected classifyLegacyOperation(_parsed: ParsedCallV2, _transfers: Transfers): LegacyAdapterOperation;
|
|
26
23
|
}
|
|
27
24
|
export {};
|
|
@@ -6,8 +6,6 @@ import { TokensMeta } from "./TokensMeta.js";
|
|
|
6
6
|
import type { ParsedCall, ParsedCallV2 } from "./types.js";
|
|
7
7
|
export type ContractOrInterface<T> = T extends Abi | readonly unknown[] ? BaseContract<T> : T;
|
|
8
8
|
export declare class ChainContractsRegister {
|
|
9
|
-
#private;
|
|
10
|
-
static for(client: PublicClient<Transport, Chain>, logger?: ILogger): ChainContractsRegister;
|
|
11
9
|
private readonly contracts;
|
|
12
10
|
private readonly labels;
|
|
13
11
|
readonly client: PublicClient<Transport, Chain>;
|
|
@@ -3,7 +3,7 @@ import type { NetworkType } from "../chain/index.js";
|
|
|
3
3
|
import type { ILogger } from "../types/index.js";
|
|
4
4
|
import { ChainContractsRegister } from "./ChainContractsRegister.js";
|
|
5
5
|
import type { TokensMeta } from "./TokensMeta.js";
|
|
6
|
-
export type ConstructOptions = {
|
|
6
|
+
export type ConstructOptions = ChainContractsRegister | {
|
|
7
7
|
client: PublicClient<Transport, Chain>;
|
|
8
8
|
logger?: ILogger;
|
|
9
9
|
} | {
|
|
@@ -14,8 +14,13 @@ export declare class Construct {
|
|
|
14
14
|
#private;
|
|
15
15
|
readonly logger?: ILogger;
|
|
16
16
|
readonly client: PublicClient<Transport, Chain>;
|
|
17
|
-
readonly register: ChainContractsRegister;
|
|
18
17
|
constructor(options: ConstructOptions);
|
|
18
|
+
/**
|
|
19
|
+
* Throws if register was not provided in constructor options
|
|
20
|
+
* Ephemeral contracts that do not need to access other contracts may not need it
|
|
21
|
+
*/
|
|
22
|
+
get register(): ChainContractsRegister;
|
|
23
|
+
protected safeGetRegister(): ChainContractsRegister | undefined;
|
|
19
24
|
get chain(): Chain;
|
|
20
25
|
get chainId(): number;
|
|
21
26
|
get networkType(): NetworkType;
|
|
@@ -24,15 +29,7 @@ export declare class Construct {
|
|
|
24
29
|
*/
|
|
25
30
|
get dirty(): boolean;
|
|
26
31
|
protected set dirty(value: boolean);
|
|
27
|
-
/**
|
|
28
|
-
* Syntax sugar for rgister.tokensMeta
|
|
29
|
-
*/
|
|
30
32
|
protected get tokensMeta(): TokensMeta;
|
|
31
|
-
/**
|
|
32
|
-
* Syntax suggar for getting contract labels
|
|
33
|
-
* @param address
|
|
34
|
-
* @returns
|
|
35
|
-
*/
|
|
36
33
|
protected labelAddress(address: Address, omitAddress?: boolean): string;
|
|
37
34
|
/**
|
|
38
35
|
* Returns list of addresses that should be watched for events to sync state
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type Address } from "viem";
|
|
2
2
|
import type { ConstructOptions } from "../../base/index.js";
|
|
3
3
|
import { PlaceholderContract } from "../../base/index.js";
|
|
4
4
|
import type { RelaxedBaseParams } from "../../index.js";
|
|
@@ -10,4 +10,5 @@ export declare class PlaceholderAdapterContract extends PlaceholderContract impl
|
|
|
10
10
|
#private;
|
|
11
11
|
constructor(options: ConstructOptions, args: PlaceholderAdapterContractOptions);
|
|
12
12
|
get targetContract(): Address;
|
|
13
|
+
get creditManager(): Address;
|
|
13
14
|
}
|
|
@@ -11,14 +11,7 @@ export interface PriceUpdatesCacheOptions {
|
|
|
11
11
|
}
|
|
12
12
|
export declare class PriceUpdatesCache {
|
|
13
13
|
#private;
|
|
14
|
-
|
|
15
|
-
* Price update caches can be shared across networks
|
|
16
|
-
* @param id - unique key to identify the cache
|
|
17
|
-
* @param opts
|
|
18
|
-
* @returns
|
|
19
|
-
*/
|
|
20
|
-
static get(id: string, opts: PriceUpdatesCacheOptions): PriceUpdatesCache;
|
|
21
|
-
private constructor();
|
|
14
|
+
constructor(opts: PriceUpdatesCacheOptions);
|
|
22
15
|
get(...path: Array<number | string>): Omit<TimestampedCalldata, "cached"> | undefined;
|
|
23
16
|
set(value: Omit<TimestampedCalldata, "cached">, ...path: Array<number | string>): void;
|
|
24
17
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Address } from "viem";
|
|
2
|
-
import {
|
|
2
|
+
import type { Asset } from "../router/types.js";
|
|
3
3
|
interface TokenDataSlice {
|
|
4
4
|
symbol: string;
|
|
5
5
|
decimals: number;
|
|
@@ -70,8 +70,8 @@ export interface CalcQuotaUpdateProps {
|
|
|
70
70
|
type: "recommendedQuota";
|
|
71
71
|
debt: bigint;
|
|
72
72
|
};
|
|
73
|
-
allowedToSpend: Record<Address,
|
|
74
|
-
allowedToObtain: Record<Address,
|
|
73
|
+
allowedToSpend: Record<Address, object>;
|
|
74
|
+
allowedToObtain: Record<Address, object>;
|
|
75
75
|
quotaReserve: bigint;
|
|
76
76
|
}
|
|
77
77
|
interface CalcQuotaUpdateReturnType {
|
|
@@ -101,6 +101,7 @@ export interface TimeToLiquidationProps {
|
|
|
101
101
|
healthFactor: number;
|
|
102
102
|
}
|
|
103
103
|
export declare class CreditAccountDataUtils {
|
|
104
|
+
private constructor();
|
|
104
105
|
static sortBalances(balances: Record<Address, bigint>, prices: Record<Address, bigint>, tokens: Record<Address, TokenDataSlice>): Array<[Address, bigint]>;
|
|
105
106
|
static sortAssets<T extends Asset>(balances: Array<T>, prices: Record<Address, bigint>, tokens: Record<Address, TokenDataSlice>): T[];
|
|
106
107
|
static assetComparator<T extends Asset>(t1: T, t2: T, prices1: Record<Address, bigint> | undefined, prices2: Record<Address, bigint> | undefined, tokens1: Record<Address, TokenDataSlice> | undefined, tokens2: Record<Address, TokenDataSlice> | undefined): 1 | 0 | -1;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Address } from "viem";
|
|
2
|
+
import { type NetworkType } from "../chain/chains.js";
|
|
3
|
+
type ChartsPriceSource = "chainlink" | "spot";
|
|
4
|
+
export declare class GearboxBackendApi {
|
|
5
|
+
private constructor();
|
|
6
|
+
static getChartsUrl: (url: string, chainId: number, options?: Options, priceSource?: ChartsPriceSource) => string;
|
|
7
|
+
static getStaticTokenUrl: () => string;
|
|
8
|
+
static getRewardsMerkleUrl: (network: NetworkType, root: Address, account: Address) => string;
|
|
9
|
+
static getNFTMerkleUrl: (network: NetworkType, root: Address) => string;
|
|
10
|
+
static apyAllRewards: () => string;
|
|
11
|
+
}
|
|
12
|
+
interface Options {
|
|
13
|
+
params?: Record<string, string | number>;
|
|
14
|
+
}
|
|
15
|
+
export declare class URLApi {
|
|
16
|
+
private constructor();
|
|
17
|
+
static getRelativeUrl: (url: string, options?: Options) => string;
|
|
18
|
+
}
|
|
19
|
+
export {};
|
|
@@ -7,6 +7,7 @@ export * from "./bytes32ToString.js";
|
|
|
7
7
|
export * from "./childLogger.js";
|
|
8
8
|
export * from "./createRawTx.js";
|
|
9
9
|
export * from "./creditAccount.js";
|
|
10
|
+
export * from "./endpoints.js";
|
|
10
11
|
export * from "./etherscan.js";
|
|
11
12
|
export * from "./filterDust.js";
|
|
12
13
|
export * from "./formatter.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gearbox-protocol/sdk",
|
|
3
|
-
"version": "13.0.0-beta.
|
|
3
|
+
"version": "13.0.0-beta.4",
|
|
4
4
|
"description": "Gearbox SDK",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "./dist/cjs/sdk/index.js",
|
|
@@ -49,7 +49,11 @@
|
|
|
49
49
|
"build": "tsup",
|
|
50
50
|
"dev": "tsup --watch",
|
|
51
51
|
"example": "tsx --env-file .env scripts/example.ts | pino-pretty",
|
|
52
|
-
"test": "vitest",
|
|
52
|
+
"test:watch": "vitest --project unit",
|
|
53
|
+
"test:unit": "vitest run --project unit",
|
|
54
|
+
"test:e2e": "vitest run --project e2e",
|
|
55
|
+
"test:all": "vitest run",
|
|
56
|
+
"generate:e2e": "NODE_OPTIONS='--max-old-space-size=8192' tsx --env-file .env scripts/generate-e2e-fixtures.ts",
|
|
53
57
|
"prepare": "husky",
|
|
54
58
|
"check": "biome check --write",
|
|
55
59
|
"check:ci": "biome check --diagnostic-level=error",
|