@gearbox-protocol/sdk 13.0.0-beta.3 → 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 +42 -40
- package/dist/cjs/sdk/utils/endpoints.js +2 -2
- package/dist/cjs/sdk/utils/formatter.js +3 -3
- 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 +3 -3
- package/dist/esm/sdk/utils/endpoints.js +1 -1
- package/dist/esm/sdk/utils/formatter.js +1 -1
- 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 +1 -1
- package/dist/types/sdk/utils/endpoints.d.ts +1 -1
- package/package.json +6 -2
|
@@ -1,15 +1,15 @@
|
|
|
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
15
|
constructor() {
|
|
@@ -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);
|
|
@@ -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
|
}
|
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",
|