@gearbox-protocol/sdk 12.4.0-next.1 → 12.5.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/abi/errors.js +10 -1
- package/dist/cjs/dev/AccountOpener.js +2 -1
- package/dist/cjs/dev/RevolverTransport.js +4 -6
- package/dist/cjs/dev/ltUtils.js +2 -1
- package/dist/cjs/dev/migrateFaucet.js +2 -1
- package/dist/cjs/dev/providers.js +6 -2
- package/dist/cjs/dev/transports.js +3 -3
- package/dist/cjs/permissionless/bindings/compressors/token-compressor.js +7 -4
- package/dist/cjs/permissionless/bindings/governance/governor.js +3 -4
- package/dist/cjs/permissionless/bindings/market-configurator.js +4 -2
- package/dist/cjs/permissionless/bindings/price-feed-store.js +2 -1
- package/dist/cjs/permissionless/bindings/treasury-splitter.js +12 -1
- package/dist/cjs/permissionless/utils/format.js +0 -8
- package/dist/cjs/plugins/accounts-counter/AccountsCounterPlugin.js +2 -1
- package/dist/cjs/plugins/bots/BotsPlugin.js +4 -2
- package/dist/cjs/plugins/degen-distributors/DegenDistributorsPlugin.js +13 -7
- package/dist/cjs/plugins/delayed-withdrawal/DelayedWithdrawalPlugin.js +2 -1
- package/dist/cjs/plugins/pools-history/Pools7DAgoPlugin.js +2 -1
- package/dist/cjs/plugins/zappers/ZappersPlugin.js +2 -1
- package/dist/cjs/sdk/GearboxSDK.js +9 -5
- package/dist/cjs/sdk/accounts/AbstractCreditAccountsService.js +71 -38
- package/dist/cjs/sdk/base/TokensMeta.js +2 -1
- package/dist/cjs/sdk/core/address-provider/AbstractAddressProviderContract.js +20 -3
- package/dist/cjs/sdk/core/address-provider/AddressProviderV300Contract.js +1 -1
- package/dist/cjs/sdk/core/address-provider/AddressProviderV310Contract.js +1 -1
- package/dist/cjs/sdk/core/address-provider/createAddressProvider.js +29 -7
- package/dist/cjs/sdk/gauges/GaugeStakingService.js +2 -1
- package/dist/cjs/sdk/index.js +2 -0
- package/dist/cjs/sdk/market/MarketConfiguratorContract.js +15 -0
- package/dist/cjs/sdk/market/credit/CreditFacadeV300Contract.js +1 -1
- package/dist/cjs/sdk/market/credit/CreditFacadeV310Contract.js +1 -1
- package/dist/cjs/sdk/market/oracle/PriceOracleBaseContract.js +6 -0
- package/dist/cjs/sdk/pools/AbstractPoolService.js +137 -0
- package/dist/cjs/sdk/pools/PoolServiceV300.js +30 -0
- package/dist/cjs/sdk/pools/PoolServiceV310.js +30 -0
- package/dist/cjs/sdk/pools/createPoolService.js +39 -0
- package/dist/cjs/sdk/pools/index.js +26 -0
- package/dist/cjs/sdk/pools/types.js +16 -0
- package/dist/cjs/sdk/sdk-legacy/core/endpoint.js +3 -9
- package/dist/cjs/sdk/sdk-legacy/gearboxRewards/api.js +2 -1
- package/dist/cjs/sdk/utils/formatter.js +8 -0
- package/dist/esm/abi/errors.js +9 -1
- package/dist/esm/dev/AccountOpener.js +2 -1
- package/dist/esm/dev/RevolverTransport.js +5 -7
- package/dist/esm/dev/ltUtils.js +2 -1
- package/dist/esm/dev/migrateFaucet.js +2 -1
- package/dist/esm/dev/providers.js +4 -1
- package/dist/esm/dev/transports.js +2 -2
- package/dist/esm/permissionless/bindings/compressors/token-compressor.js +7 -4
- package/dist/esm/permissionless/bindings/governance/governor.js +5 -2
- package/dist/esm/permissionless/bindings/market-configurator.js +4 -2
- package/dist/esm/permissionless/bindings/price-feed-store.js +2 -1
- package/dist/esm/permissionless/bindings/treasury-splitter.js +13 -2
- package/dist/esm/permissionless/utils/format.js +0 -7
- package/dist/esm/plugins/accounts-counter/AccountsCounterPlugin.js +2 -1
- package/dist/esm/plugins/bots/BotsPlugin.js +4 -2
- package/dist/esm/plugins/degen-distributors/DegenDistributorsPlugin.js +13 -7
- package/dist/esm/plugins/delayed-withdrawal/DelayedWithdrawalPlugin.js +2 -1
- package/dist/esm/plugins/pools-history/Pools7DAgoPlugin.js +2 -1
- package/dist/esm/plugins/zappers/ZappersPlugin.js +2 -1
- package/dist/esm/sdk/GearboxSDK.js +9 -5
- package/dist/esm/sdk/accounts/AbstractCreditAccountsService.js +71 -38
- package/dist/esm/sdk/base/TokensMeta.js +2 -1
- package/dist/esm/sdk/core/address-provider/AbstractAddressProviderContract.js +20 -3
- package/dist/esm/sdk/core/address-provider/AddressProviderV300Contract.js +1 -1
- package/dist/esm/sdk/core/address-provider/AddressProviderV310Contract.js +1 -1
- package/dist/esm/sdk/core/address-provider/createAddressProvider.js +36 -8
- package/dist/esm/sdk/gauges/GaugeStakingService.js +2 -1
- package/dist/esm/sdk/index.js +1 -0
- package/dist/esm/sdk/market/MarketConfiguratorContract.js +15 -0
- package/dist/esm/sdk/market/credit/CreditFacadeV300Contract.js +6 -2
- package/dist/esm/sdk/market/credit/CreditFacadeV310Contract.js +6 -2
- package/dist/esm/sdk/market/oracle/PriceOracleBaseContract.js +6 -0
- package/dist/esm/sdk/pools/AbstractPoolService.js +113 -0
- package/dist/esm/sdk/pools/PoolServiceV300.js +6 -0
- package/dist/esm/sdk/pools/PoolServiceV310.js +6 -0
- package/dist/esm/sdk/pools/createPoolService.js +15 -0
- package/dist/esm/sdk/pools/index.js +3 -0
- package/dist/esm/sdk/pools/types.js +0 -0
- package/dist/esm/sdk/sdk-legacy/core/endpoint.js +3 -9
- package/dist/esm/sdk/sdk-legacy/gearboxRewards/api.js +2 -1
- package/dist/esm/sdk/utils/formatter.js +7 -0
- package/dist/types/abi/errors.d.ts +33 -0
- package/dist/types/dev/RevolverTransport.d.ts +2 -20
- package/dist/types/dev/providers.d.ts +8 -1
- package/dist/types/dev/transports.d.ts +1 -1
- package/dist/types/permissionless/utils/format.d.ts +0 -1
- package/dist/types/sdk/GearboxSDK.d.ts +1 -1
- package/dist/types/sdk/core/address-provider/AbstractAddressProviderContract.d.ts +2 -2
- package/dist/types/sdk/core/address-provider/AddressProviderV300Contract.d.ts +2 -2
- package/dist/types/sdk/core/address-provider/AddressProviderV310Contract.d.ts +2 -2
- package/dist/types/sdk/core/address-provider/types.d.ts +15 -0
- package/dist/types/sdk/index.d.ts +1 -0
- package/dist/types/sdk/market/MarketConfiguratorContract.d.ts +9 -0
- package/dist/types/sdk/pools/AbstractPoolService.d.ts +9 -0
- package/dist/types/sdk/pools/PoolServiceV300.d.ts +4 -0
- package/dist/types/sdk/pools/PoolServiceV310.d.ts +4 -0
- package/dist/types/sdk/pools/createPoolService.d.ts +8 -0
- package/dist/types/sdk/pools/index.d.ts +3 -0
- package/dist/types/sdk/pools/types.d.ts +92 -0
- package/dist/types/sdk/sdk-legacy/core/endpoint.d.ts +1 -3
- package/dist/types/sdk/types/state-human.d.ts +1 -1
- package/dist/types/sdk/utils/formatter.d.ts +1 -0
- package/package.json +6 -6
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { ierc20ZapperDepositsAbi } from "../../abi/iERC20ZapperDeposits.js";
|
|
2
|
+
import { iethZapperDepositsAbi } from "../../abi/iETHZapperDeposits.js";
|
|
3
|
+
import { iZapperAbi } from "../../abi/iZapper.js";
|
|
4
|
+
import { iPoolV300Abi } from "../../abi/v300.js";
|
|
5
|
+
import { SDKConstruct } from "../base/index.js";
|
|
6
|
+
class AbstractPoolService extends SDKConstruct {
|
|
7
|
+
#version;
|
|
8
|
+
constructor(sdk, version) {
|
|
9
|
+
super(sdk);
|
|
10
|
+
this.#version = version;
|
|
11
|
+
this.logger?.debug(`Created PoolService with version: ${this.#version}`);
|
|
12
|
+
}
|
|
13
|
+
addLiquidity({
|
|
14
|
+
collateral,
|
|
15
|
+
pool,
|
|
16
|
+
account,
|
|
17
|
+
zapper,
|
|
18
|
+
permit,
|
|
19
|
+
nativeTokenAddress,
|
|
20
|
+
referralCode = 0n,
|
|
21
|
+
migrate
|
|
22
|
+
}) {
|
|
23
|
+
if (zapper?.tokenIn === nativeTokenAddress) {
|
|
24
|
+
return [
|
|
25
|
+
{
|
|
26
|
+
target: zapper.zapper,
|
|
27
|
+
abi: iethZapperDepositsAbi,
|
|
28
|
+
functionName: "depositWithReferral",
|
|
29
|
+
args: [account, referralCode],
|
|
30
|
+
value: collateral.balance
|
|
31
|
+
}
|
|
32
|
+
];
|
|
33
|
+
} else if (zapper) {
|
|
34
|
+
return permit ? [
|
|
35
|
+
{
|
|
36
|
+
target: zapper.zapper,
|
|
37
|
+
abi: ierc20ZapperDepositsAbi,
|
|
38
|
+
functionName: "depositWithReferralAndPermit",
|
|
39
|
+
args: [
|
|
40
|
+
collateral.balance,
|
|
41
|
+
account,
|
|
42
|
+
referralCode,
|
|
43
|
+
permit.deadline,
|
|
44
|
+
permit.v,
|
|
45
|
+
permit.r,
|
|
46
|
+
permit.s
|
|
47
|
+
]
|
|
48
|
+
}
|
|
49
|
+
] : [
|
|
50
|
+
{
|
|
51
|
+
target: zapper.zapper,
|
|
52
|
+
abi: ierc20ZapperDepositsAbi,
|
|
53
|
+
functionName: "depositWithReferral",
|
|
54
|
+
args: [collateral.balance, account, referralCode]
|
|
55
|
+
}
|
|
56
|
+
];
|
|
57
|
+
} else {
|
|
58
|
+
if (migrate) throw Error("No zapper for migration");
|
|
59
|
+
return [
|
|
60
|
+
{
|
|
61
|
+
target: pool,
|
|
62
|
+
abi: iPoolV300Abi,
|
|
63
|
+
functionName: "depositWithReferral",
|
|
64
|
+
args: [collateral.balance, account, referralCode]
|
|
65
|
+
}
|
|
66
|
+
];
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
removeLiquidity({
|
|
70
|
+
pool,
|
|
71
|
+
amount,
|
|
72
|
+
account,
|
|
73
|
+
zapper,
|
|
74
|
+
permit
|
|
75
|
+
}) {
|
|
76
|
+
if (zapper) {
|
|
77
|
+
return permit ? [
|
|
78
|
+
{
|
|
79
|
+
target: zapper.zapper,
|
|
80
|
+
abi: iZapperAbi,
|
|
81
|
+
functionName: "redeemWithPermit",
|
|
82
|
+
args: [
|
|
83
|
+
amount,
|
|
84
|
+
account,
|
|
85
|
+
permit.deadline,
|
|
86
|
+
permit.v,
|
|
87
|
+
permit.r,
|
|
88
|
+
permit.s
|
|
89
|
+
]
|
|
90
|
+
}
|
|
91
|
+
] : [
|
|
92
|
+
{
|
|
93
|
+
target: zapper.zapper,
|
|
94
|
+
abi: iZapperAbi,
|
|
95
|
+
functionName: "redeem",
|
|
96
|
+
args: [amount, account]
|
|
97
|
+
}
|
|
98
|
+
];
|
|
99
|
+
} else {
|
|
100
|
+
return [
|
|
101
|
+
{
|
|
102
|
+
target: pool,
|
|
103
|
+
abi: iPoolV300Abi,
|
|
104
|
+
functionName: "redeem",
|
|
105
|
+
args: [amount, account, account]
|
|
106
|
+
}
|
|
107
|
+
];
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
export {
|
|
112
|
+
AbstractPoolService
|
|
113
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { isV300, isV310 } from "../constants/index.js";
|
|
2
|
+
import { PoolServiceV300 } from "./PoolServiceV300.js";
|
|
3
|
+
import { PoolServiceV310 } from "./PoolServiceV310.js";
|
|
4
|
+
function createPoolService(sdk, version) {
|
|
5
|
+
if (isV300(version)) {
|
|
6
|
+
return new PoolServiceV300(sdk, version);
|
|
7
|
+
}
|
|
8
|
+
if (isV310(version)) {
|
|
9
|
+
return new PoolServiceV310(sdk, version);
|
|
10
|
+
}
|
|
11
|
+
throw new Error(`Unsupported Pool Service version ${version}`);
|
|
12
|
+
}
|
|
13
|
+
export {
|
|
14
|
+
createPoolService
|
|
15
|
+
};
|
|
File without changes
|
|
@@ -85,15 +85,9 @@ class GearboxBackendApi {
|
|
|
85
85
|
return `${LEADERBOARD_APIS[chainId]}${url}`;
|
|
86
86
|
};
|
|
87
87
|
static getReferralUrl = () => REFERRAL_API;
|
|
88
|
-
static
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
static apyServerGearAPY = (chainId) => URLApi.getRelativeUrl("https://apy-server.fly.dev/api/rewards/gear-apy", {
|
|
92
|
-
params: { chain_id: chainId }
|
|
93
|
-
});
|
|
94
|
-
static apyServerAllPoolRewards = (chainId) => URLApi.getRelativeUrl("https://apy-server.fly.dev/api/rewards/pools/all", {
|
|
95
|
-
params: { chain_id: chainId }
|
|
96
|
-
});
|
|
88
|
+
static apyAllRewards = () => URLApi.getRelativeUrl(
|
|
89
|
+
"https://state-cache.gearbox.foundation/apy-server/latest.json"
|
|
90
|
+
);
|
|
97
91
|
}
|
|
98
92
|
class URLApi {
|
|
99
93
|
static getRelativeUrl = (url, options) => {
|
|
@@ -95,7 +95,8 @@ class GearboxRewardsApi {
|
|
|
95
95
|
const [response] = await Promise.allSettled([
|
|
96
96
|
provider.multicall({
|
|
97
97
|
allowFailure: false,
|
|
98
|
-
contracts: [...farmInfoCalls, ...rewardTokenCalls, ...farmedCalls]
|
|
98
|
+
contracts: [...farmInfoCalls, ...rewardTokenCalls, ...farmedCalls],
|
|
99
|
+
batchSize: 0
|
|
99
100
|
})
|
|
100
101
|
]);
|
|
101
102
|
const safeResponse = GearboxRewardsApi.extractFulfilled(response, reportError, "v3Rewards") || [];
|
|
@@ -91,12 +91,19 @@ function formatDuration(seconds, raw = true) {
|
|
|
91
91
|
function formatNumberToString_(value) {
|
|
92
92
|
return value.toLocaleString("en-US", { minimumIntegerDigits: 1, useGrouping: true }).replaceAll(",", "_");
|
|
93
93
|
}
|
|
94
|
+
function formatTimestamp(timestamp) {
|
|
95
|
+
return new Date(timestamp * 1e3).toLocaleString("en-GB", {
|
|
96
|
+
dateStyle: "short",
|
|
97
|
+
timeStyle: "short"
|
|
98
|
+
});
|
|
99
|
+
}
|
|
94
100
|
export {
|
|
95
101
|
fmtBinaryMask,
|
|
96
102
|
formatBN,
|
|
97
103
|
formatBNvalue,
|
|
98
104
|
formatDuration,
|
|
99
105
|
formatNumberToString_,
|
|
106
|
+
formatTimestamp,
|
|
100
107
|
numberWithCommas,
|
|
101
108
|
percentFmt,
|
|
102
109
|
toBigInt
|
|
@@ -953,6 +953,23 @@ export declare const iExceptionsV310Abi: readonly [{
|
|
|
953
953
|
readonly name: "ZeroAddressException";
|
|
954
954
|
readonly inputs: readonly [];
|
|
955
955
|
}];
|
|
956
|
+
export declare const iPartialLiquidationBotV310ErrorsAbi: readonly [{
|
|
957
|
+
readonly type: "error";
|
|
958
|
+
readonly name: "LiquidatedLessThanNeededException";
|
|
959
|
+
readonly inputs: readonly [];
|
|
960
|
+
}, {
|
|
961
|
+
readonly type: "error";
|
|
962
|
+
readonly name: "LiquidatedMoreThanNeededException";
|
|
963
|
+
readonly inputs: readonly [];
|
|
964
|
+
}, {
|
|
965
|
+
readonly type: "error";
|
|
966
|
+
readonly name: "SeizedLessThanRequiredException";
|
|
967
|
+
readonly inputs: readonly [];
|
|
968
|
+
}, {
|
|
969
|
+
readonly type: "error";
|
|
970
|
+
readonly name: "UnderlyingNotLiquidatableException";
|
|
971
|
+
readonly inputs: readonly [];
|
|
972
|
+
}];
|
|
956
973
|
export declare const errorAbis: readonly [{
|
|
957
974
|
readonly type: "error";
|
|
958
975
|
readonly inputs: readonly [];
|
|
@@ -1901,5 +1918,21 @@ export declare const errorAbis: readonly [{
|
|
|
1901
1918
|
readonly type: "address";
|
|
1902
1919
|
readonly internalType: "address";
|
|
1903
1920
|
}];
|
|
1921
|
+
}, {
|
|
1922
|
+
readonly type: "error";
|
|
1923
|
+
readonly name: "LiquidatedLessThanNeededException";
|
|
1924
|
+
readonly inputs: readonly [];
|
|
1925
|
+
}, {
|
|
1926
|
+
readonly type: "error";
|
|
1927
|
+
readonly name: "LiquidatedMoreThanNeededException";
|
|
1928
|
+
readonly inputs: readonly [];
|
|
1929
|
+
}, {
|
|
1930
|
+
readonly type: "error";
|
|
1931
|
+
readonly name: "SeizedLessThanRequiredException";
|
|
1932
|
+
readonly inputs: readonly [];
|
|
1933
|
+
}, {
|
|
1934
|
+
readonly type: "error";
|
|
1935
|
+
readonly name: "UnderlyingNotLiquidatableException";
|
|
1936
|
+
readonly inputs: readonly [];
|
|
1904
1937
|
}];
|
|
1905
1938
|
export type errorAbis = typeof errorAbis;
|
|
@@ -6,7 +6,7 @@ export declare const providerConfigSchema: z.ZodObject<{
|
|
|
6
6
|
name: z.ZodString;
|
|
7
7
|
url: z.ZodURL;
|
|
8
8
|
cooldown: z.ZodOptional<z.ZodNumber>;
|
|
9
|
-
|
|
9
|
+
httpTransportOptions: z.ZodOptional<z.ZodObject<{
|
|
10
10
|
batch: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodObject<{
|
|
11
11
|
batchSize: z.ZodOptional<z.ZodNumber>;
|
|
12
12
|
wait: z.ZodOptional<z.ZodNumber>;
|
|
@@ -40,29 +40,11 @@ export declare const SelectionStrategy: z.ZodEnum<{
|
|
|
40
40
|
*/
|
|
41
41
|
export type SelectionStrategy = z.infer<typeof SelectionStrategy>;
|
|
42
42
|
export declare const revolverTransportConfigSchema: z.ZodObject<{
|
|
43
|
-
network: z.ZodEnum<{
|
|
44
|
-
Mainnet: "Mainnet";
|
|
45
|
-
Arbitrum: "Arbitrum";
|
|
46
|
-
Optimism: "Optimism";
|
|
47
|
-
Base: "Base";
|
|
48
|
-
Sonic: "Sonic";
|
|
49
|
-
MegaETH: "MegaETH";
|
|
50
|
-
Monad: "Monad";
|
|
51
|
-
Berachain: "Berachain";
|
|
52
|
-
Avalanche: "Avalanche";
|
|
53
|
-
BNB: "BNB";
|
|
54
|
-
WorldChain: "WorldChain";
|
|
55
|
-
Etherlink: "Etherlink";
|
|
56
|
-
Hemi: "Hemi";
|
|
57
|
-
Lisk: "Lisk";
|
|
58
|
-
Plasma: "Plasma";
|
|
59
|
-
Somnia: "Somnia";
|
|
60
|
-
}>;
|
|
61
43
|
providers: z.ZodArray<z.ZodObject<{
|
|
62
44
|
name: z.ZodString;
|
|
63
45
|
url: z.ZodURL;
|
|
64
46
|
cooldown: z.ZodOptional<z.ZodNumber>;
|
|
65
|
-
|
|
47
|
+
httpTransportOptions: z.ZodOptional<z.ZodObject<{
|
|
66
48
|
batch: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodObject<{
|
|
67
49
|
batchSize: z.ZodOptional<z.ZodNumber>;
|
|
68
50
|
wait: z.ZodOptional<z.ZodNumber>;
|
|
@@ -1,6 +1,13 @@
|
|
|
1
|
+
import { z } from "zod/v4";
|
|
1
2
|
import { type NetworkType } from "../sdk/index.js";
|
|
2
3
|
export declare const SUPPORTED_RPC_PROVIDERS: readonly ["alchemy", "drpc", "thirdweb", "ankr"];
|
|
3
|
-
export
|
|
4
|
+
export declare const rpcProvidersSchema: z.ZodEnum<{
|
|
5
|
+
alchemy: "alchemy";
|
|
6
|
+
drpc: "drpc";
|
|
7
|
+
thirdweb: "thirdweb";
|
|
8
|
+
ankr: "ankr";
|
|
9
|
+
}>;
|
|
10
|
+
export type RpcProvider = z.infer<typeof rpcProvidersSchema>;
|
|
4
11
|
export declare function getRpcProviderUrl(provider: RpcProvider, network: NetworkType, apiKey: string, protocol?: "http" | "ws"): string | undefined;
|
|
5
12
|
export declare function getAlchemyUrl(network: NetworkType, apiKey: string, protocol?: "http" | "ws"): string | undefined;
|
|
6
13
|
export declare function getDrpcUrl(network: NetworkType, apiKey: string, protocol?: "http" | "ws"): string | undefined;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from "zod/v4";
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const httpTransportOptionsSchema: z.ZodObject<{
|
|
3
3
|
batch: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodObject<{
|
|
4
4
|
batchSize: z.ZodOptional<z.ZodNumber>;
|
|
5
5
|
wait: z.ZodOptional<z.ZodNumber>;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export declare function formatBytecodeSize(size: number): string;
|
|
2
2
|
export declare function formatBytecodeVersion(version: number): string;
|
|
3
|
-
export declare function formatTimestamp(timestamp: number): string;
|
|
4
3
|
export declare function shortenHash(hash: string, chars?: number): string;
|
|
5
4
|
export declare function convertPercent(percent: number): number;
|
|
6
5
|
export declare function significantTrunc(x: number): string;
|
|
@@ -40,7 +40,7 @@ export type ClientOptions = {
|
|
|
40
40
|
* Retry count for RPC
|
|
41
41
|
*/
|
|
42
42
|
retryCount?: number;
|
|
43
|
-
|
|
43
|
+
httpTransportOptions?: HttpRpcClientOptions | undefined;
|
|
44
44
|
} | {
|
|
45
45
|
/**
|
|
46
46
|
* Alternatively, can pass viem transport
|
|
@@ -3,10 +3,10 @@ import type { BaseContractArgs } from "../../base/BaseContract.js";
|
|
|
3
3
|
import { BaseContract, type ConstructOptions } from "../../base/index.js";
|
|
4
4
|
import type { VersionRange } from "../../constants/index.js";
|
|
5
5
|
import type { AddressProviderV3StateHuman } from "../../types/index.js";
|
|
6
|
-
import type { AddressProviderState } from "./types.js";
|
|
6
|
+
import type { AddressProviderAddresses, AddressProviderState } from "./types.js";
|
|
7
7
|
export default abstract class AbstractAddressProviderContract<abi extends Abi | readonly unknown[]> extends BaseContract<abi> {
|
|
8
8
|
#private;
|
|
9
|
-
constructor(options: ConstructOptions, args: BaseContractArgs<abi>, addresses?:
|
|
9
|
+
constructor(options: ConstructOptions, args: BaseContractArgs<abi>, addresses?: AddressProviderAddresses);
|
|
10
10
|
protected setInternalAddress(key: string, address: Address, version: number): void;
|
|
11
11
|
getAddress(contract: string, version?: number): Address;
|
|
12
12
|
getLatest(contract: string, range: VersionRange): [address: Address, version: number] | undefined;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Address, ContractEventName, DecodeFunctionDataReturnType, Log } from "viem";
|
|
2
2
|
import type { ConstructOptions } from "../../base/Construct.js";
|
|
3
3
|
import AbstractAddressProviderContract from "./AbstractAddressProviderContract.js";
|
|
4
|
-
import type { IAddressProviderContract } from "./types.js";
|
|
4
|
+
import type { AddressProviderAddresses, IAddressProviderContract } from "./types.js";
|
|
5
5
|
declare const abi: readonly [{
|
|
6
6
|
readonly type: "function";
|
|
7
7
|
readonly name: "addresses";
|
|
@@ -89,7 +89,7 @@ declare const abi: readonly [{
|
|
|
89
89
|
}];
|
|
90
90
|
type abi = typeof abi;
|
|
91
91
|
export declare class AddressProviderV300Contract extends AbstractAddressProviderContract<abi> implements IAddressProviderContract {
|
|
92
|
-
constructor(options: ConstructOptions, address: Address, version: number, addresses?:
|
|
92
|
+
constructor(options: ConstructOptions, address: Address, version: number, addresses?: AddressProviderAddresses);
|
|
93
93
|
protected stringifyFunctionParams(params: DecodeFunctionDataReturnType<abi>): string[];
|
|
94
94
|
processLog(log: Log<bigint, number, false, undefined, undefined, abi, ContractEventName<abi>>): void;
|
|
95
95
|
syncState(blockNumber?: bigint): Promise<void>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Address, ContractEventName, DecodeFunctionDataReturnType, Log } from "viem";
|
|
2
2
|
import type { ConstructOptions } from "../../base/Construct.js";
|
|
3
3
|
import AbstractAddressProviderContract from "./AbstractAddressProviderContract.js";
|
|
4
|
-
import type { IAddressProviderContract } from "./types.js";
|
|
4
|
+
import type { AddressProviderAddresses, IAddressProviderContract } from "./types.js";
|
|
5
5
|
declare const abi: readonly [{
|
|
6
6
|
readonly type: "function";
|
|
7
7
|
readonly inputs: readonly [];
|
|
@@ -254,7 +254,7 @@ declare const abi: readonly [{
|
|
|
254
254
|
}];
|
|
255
255
|
type abi = typeof abi;
|
|
256
256
|
export declare class AddressProviderV310Contract extends AbstractAddressProviderContract<abi> implements IAddressProviderContract {
|
|
257
|
-
constructor(options: ConstructOptions, address: Address, version?: number, addresses?:
|
|
257
|
+
constructor(options: ConstructOptions, address: Address, version?: number, addresses?: AddressProviderAddresses);
|
|
258
258
|
protected stringifyFunctionParams(params: DecodeFunctionDataReturnType<abi>): string[];
|
|
259
259
|
processLog(log: Log<bigint, number, false, undefined, undefined, abi, ContractEventName<abi>>): void;
|
|
260
260
|
syncState(blockNumber?: bigint): Promise<void>;
|
|
@@ -2,6 +2,21 @@ import type { Address } from "viem";
|
|
|
2
2
|
import type { BaseParams, IBaseContract } from "../../base/index.js";
|
|
3
3
|
import type { VersionRange } from "../../constants/versions.js";
|
|
4
4
|
import type { AddressProviderV3StateHuman } from "../../types/index.js";
|
|
5
|
+
export interface AddressProviderAddresses {
|
|
6
|
+
/**
|
|
7
|
+
* Initialize address provider with these addresses
|
|
8
|
+
* Used in hydration
|
|
9
|
+
*/
|
|
10
|
+
addresses?: Record<string, Record<number, Address>>;
|
|
11
|
+
/**
|
|
12
|
+
* Override addresses for this address provider
|
|
13
|
+
* These addresses will precede over addresses loaded from chain
|
|
14
|
+
*
|
|
15
|
+
* This is an escape hatch.
|
|
16
|
+
* We used it when we need to fix price feed compressor/market compressor urgently
|
|
17
|
+
*/
|
|
18
|
+
overrides?: Record<string, Record<number, Address>>;
|
|
19
|
+
}
|
|
5
20
|
export interface AddressProviderState {
|
|
6
21
|
baseParams: BaseParams;
|
|
7
22
|
addresses: Record<string, Record<number, Address>>;
|
|
@@ -10,6 +10,7 @@ export * from "./market/index.js";
|
|
|
10
10
|
export * from "./options.js";
|
|
11
11
|
export * from "./plugins/index.js";
|
|
12
12
|
export * from "./poolMigration/index.js";
|
|
13
|
+
export * from "./pools/index.js";
|
|
13
14
|
export * from "./router/index.js";
|
|
14
15
|
export * from "./sdk-gov-legacy/index.js";
|
|
15
16
|
export * from "./sdk-legacy/index.js";
|
|
@@ -1531,6 +1531,15 @@ export declare class MarketConfiguratorContract extends BaseContract<abi> {
|
|
|
1531
1531
|
#private;
|
|
1532
1532
|
constructor(options: ConstructOptions, address: Address);
|
|
1533
1533
|
loadCuratorName(): Promise<void>;
|
|
1534
|
+
static getPeripheryContractBatch(configurators: MarketConfiguratorContract[], client: MarketConfiguratorContract["client"], contract: PeripheryContract): Promise<({
|
|
1535
|
+
error: Error;
|
|
1536
|
+
result?: undefined;
|
|
1537
|
+
status: "failure";
|
|
1538
|
+
} | {
|
|
1539
|
+
error?: undefined;
|
|
1540
|
+
result: readonly `0x${string}`[];
|
|
1541
|
+
status: "success";
|
|
1542
|
+
})[]>;
|
|
1534
1543
|
getPeripheryContract(contract: PeripheryContract): Promise<Address>;
|
|
1535
1544
|
processLog(log: Log<bigint, number, false, undefined, undefined, abi, ContractEventName<abi>>): void;
|
|
1536
1545
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { SDKConstruct } from "../base/index.js";
|
|
2
|
+
import type { GearboxSDK } from "../GearboxSDK.js";
|
|
3
|
+
import type { AddLiquidityCall, AddLiquidityProps, RemoveLiquidityCall, RemoveLiquidityProps } from "./types.js";
|
|
4
|
+
export declare abstract class AbstractPoolService extends SDKConstruct {
|
|
5
|
+
#private;
|
|
6
|
+
constructor(sdk: GearboxSDK, version: number);
|
|
7
|
+
addLiquidity({ collateral, pool, account, zapper, permit, nativeTokenAddress, referralCode, migrate, }: AddLiquidityProps): AddLiquidityCall;
|
|
8
|
+
removeLiquidity({ pool, amount, account, zapper, permit, }: RemoveLiquidityProps): RemoveLiquidityCall;
|
|
9
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { GearboxSDK } from "../GearboxSDK.js";
|
|
2
|
+
import type { AbstractPoolService } from "./AbstractPoolService.js";
|
|
3
|
+
/**
|
|
4
|
+
* @sdk
|
|
5
|
+
* @version version of desired pool service; either v300 or v310
|
|
6
|
+
* @returns
|
|
7
|
+
*/
|
|
8
|
+
export declare function createPoolService(sdk: GearboxSDK, version: number): AbstractPoolService;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import type { Address } from "viem";
|
|
2
|
+
import type { ierc20ZapperDepositsAbi } from "../../abi/iERC20ZapperDeposits.js";
|
|
3
|
+
import type { iethZapperDepositsAbi } from "../../abi/iETHZapperDeposits.js";
|
|
4
|
+
import type { iZapperAbi } from "../../abi/iZapper.js";
|
|
5
|
+
import type { iPoolV300Abi } from "../../abi/v300.js";
|
|
6
|
+
import type { PoolData_Legacy } from "../index.js";
|
|
7
|
+
import type { Asset } from "../router/index.js";
|
|
8
|
+
interface PermitResult {
|
|
9
|
+
r: Address;
|
|
10
|
+
s: Address;
|
|
11
|
+
v: number;
|
|
12
|
+
token: Address;
|
|
13
|
+
owner: Address;
|
|
14
|
+
spender: Address;
|
|
15
|
+
value: bigint;
|
|
16
|
+
deadline: bigint;
|
|
17
|
+
nonce: bigint;
|
|
18
|
+
}
|
|
19
|
+
export interface AddLiquidityProps {
|
|
20
|
+
collateral: Asset;
|
|
21
|
+
pool: Address;
|
|
22
|
+
account: Address;
|
|
23
|
+
migrate: boolean;
|
|
24
|
+
zapper: PoolData_Legacy["zappers"][Address][Address] | undefined;
|
|
25
|
+
permit: PermitResult | undefined;
|
|
26
|
+
nativeTokenAddress: Address;
|
|
27
|
+
referralCode: bigint | undefined;
|
|
28
|
+
}
|
|
29
|
+
export type AddLiquidityCall = [
|
|
30
|
+
{
|
|
31
|
+
target: Address;
|
|
32
|
+
abi: typeof iethZapperDepositsAbi;
|
|
33
|
+
functionName: "depositWithReferral";
|
|
34
|
+
args: [Address, bigint];
|
|
35
|
+
value: bigint;
|
|
36
|
+
} | {
|
|
37
|
+
target: Address;
|
|
38
|
+
abi: typeof ierc20ZapperDepositsAbi;
|
|
39
|
+
functionName: "depositWithReferralAndPermit";
|
|
40
|
+
args: [bigint, Address, bigint, bigint, number, Address, Address];
|
|
41
|
+
} | {
|
|
42
|
+
target: Address;
|
|
43
|
+
abi: typeof ierc20ZapperDepositsAbi;
|
|
44
|
+
functionName: "depositWithReferral";
|
|
45
|
+
args: [bigint, Address, bigint];
|
|
46
|
+
} | {
|
|
47
|
+
target: Address;
|
|
48
|
+
abi: typeof iPoolV300Abi;
|
|
49
|
+
functionName: "depositWithReferral";
|
|
50
|
+
args: [bigint, Address, bigint];
|
|
51
|
+
}
|
|
52
|
+
];
|
|
53
|
+
export interface RemoveLiquidityProps {
|
|
54
|
+
pool: Address;
|
|
55
|
+
amount: bigint;
|
|
56
|
+
account: Address;
|
|
57
|
+
permit: PermitResult | undefined;
|
|
58
|
+
zapper: PoolData_Legacy["zappers"][Address][Address];
|
|
59
|
+
}
|
|
60
|
+
export type RemoveLiquidityCall = [
|
|
61
|
+
{
|
|
62
|
+
target: Address;
|
|
63
|
+
abi: typeof iZapperAbi;
|
|
64
|
+
functionName: "redeemWithPermit";
|
|
65
|
+
args: [bigint, Address, bigint, number, Address, Address];
|
|
66
|
+
} | {
|
|
67
|
+
target: Address;
|
|
68
|
+
abi: typeof iZapperAbi;
|
|
69
|
+
functionName: "redeem";
|
|
70
|
+
args: [bigint, Address];
|
|
71
|
+
} | {
|
|
72
|
+
target: Address;
|
|
73
|
+
abi: typeof iPoolV300Abi;
|
|
74
|
+
functionName: "redeem";
|
|
75
|
+
args: [bigint, Address, Address];
|
|
76
|
+
}
|
|
77
|
+
];
|
|
78
|
+
export interface IPoolsService {
|
|
79
|
+
/**
|
|
80
|
+
* Add liquidity to a pool
|
|
81
|
+
* @param props - {@link AddLiquidityProps}
|
|
82
|
+
* @returns - {@link AddLiquidityCall}
|
|
83
|
+
*/
|
|
84
|
+
addLiquidity(props: AddLiquidityProps): AddLiquidityCall;
|
|
85
|
+
/**
|
|
86
|
+
* Remove liquidity from a pool
|
|
87
|
+
* @param props - {@link RemoveLiquidityProps}
|
|
88
|
+
* @returns - {@link RemoveLiquidityCall}
|
|
89
|
+
*/
|
|
90
|
+
removeLiquidity(props: RemoveLiquidityProps): RemoveLiquidityCall;
|
|
91
|
+
}
|
|
92
|
+
export {};
|
|
@@ -13,9 +13,7 @@ export declare class GearboxBackendApi {
|
|
|
13
13
|
static getNFTMerkleUrl: (network: NetworkType, root: Address) => string;
|
|
14
14
|
static getLeaderboardUrl: (url: string, chainId: number) => string;
|
|
15
15
|
static getReferralUrl: () => string;
|
|
16
|
-
static
|
|
17
|
-
static apyServerGearAPY: (chainId: number) => string;
|
|
18
|
-
static apyServerAllPoolRewards: (chainId: number) => string;
|
|
16
|
+
static apyAllRewards: () => string;
|
|
19
17
|
}
|
|
20
18
|
interface Options {
|
|
21
19
|
params?: Record<string, string | number>;
|
|
@@ -72,7 +72,7 @@ export interface CreditFacadeStateHuman extends BaseContractStateHuman {
|
|
|
72
72
|
expirable: boolean;
|
|
73
73
|
isDegenMode: boolean;
|
|
74
74
|
degenNFT: string;
|
|
75
|
-
expirationDate:
|
|
75
|
+
expirationDate: string;
|
|
76
76
|
maxDebtPerBlockMultiplier: number;
|
|
77
77
|
botList: string;
|
|
78
78
|
minDebt: string;
|
|
@@ -9,3 +9,4 @@ export declare function fmtBinaryMask(mask: bigint): string;
|
|
|
9
9
|
export declare function numberWithCommas(x: number | bigint): string;
|
|
10
10
|
export declare function formatDuration(seconds: number, raw?: boolean): string;
|
|
11
11
|
export declare function formatNumberToString_(value: bigint | number): string;
|
|
12
|
+
export declare function formatTimestamp(timestamp: number): string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gearbox-protocol/sdk",
|
|
3
|
-
"version": "12.
|
|
3
|
+
"version": "12.5.0",
|
|
4
4
|
"description": "Gearbox SDK",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "./dist/cjs/sdk/index.js",
|
|
@@ -62,13 +62,13 @@
|
|
|
62
62
|
"date-fns": "^4.1.0",
|
|
63
63
|
"decimal.js-light": "^2.5.1",
|
|
64
64
|
"viem": ">=2.23.15 <3.0.0",
|
|
65
|
-
"zod": "^4.
|
|
65
|
+
"zod": "^4.3.5"
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|
|
68
|
-
"@biomejs/biome": "^2.3.
|
|
69
|
-
"@commitlint/cli": "^20.
|
|
70
|
-
"@commitlint/config-conventional": "^20.
|
|
71
|
-
"@gearbox-protocol/biome-config": "^1.0.
|
|
68
|
+
"@biomejs/biome": "^2.3.11",
|
|
69
|
+
"@commitlint/cli": "^20.3.0",
|
|
70
|
+
"@commitlint/config-conventional": "^20.3.0",
|
|
71
|
+
"@gearbox-protocol/biome-config": "^1.0.17",
|
|
72
72
|
"@types/cross-spawn": "^6.0.6",
|
|
73
73
|
"axios": "^1.13.2",
|
|
74
74
|
"cross-spawn": "^7.0.6",
|