@gearbox-protocol/sdk 3.0.0-vfour.330 → 3.0.0-vfour.331
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/sdk/chain/chains.js +5 -5
- package/dist/cjs/sdk/sdk-legacy/core/endpoint.js +26 -17
- package/dist/cjs/sdk/sdk-legacy/core/strategy.js +2 -2
- package/dist/esm/sdk/chain/chains.js +5 -5
- package/dist/esm/sdk/sdk-legacy/core/endpoint.js +26 -20
- package/dist/esm/sdk/sdk-legacy/core/strategy.js +2 -2
- package/dist/types/sdk/sdk-legacy/core/endpoint.d.ts +3 -1
- package/dist/types/sdk/sdk-legacy/core/strategy.d.ts +2 -4
- package/package.json +1 -1
|
@@ -97,7 +97,7 @@ const chains = {
|
|
|
97
97
|
...import_chains.base,
|
|
98
98
|
network: "Base",
|
|
99
99
|
defaultMarketConfigurators: {},
|
|
100
|
-
isPublic:
|
|
100
|
+
isPublic: false
|
|
101
101
|
},
|
|
102
102
|
"base-rpc"
|
|
103
103
|
),
|
|
@@ -123,14 +123,14 @@ const chains = {
|
|
|
123
123
|
...import_chains.megaethTestnet,
|
|
124
124
|
network: "MegaETH",
|
|
125
125
|
defaultMarketConfigurators: {},
|
|
126
|
-
isPublic:
|
|
126
|
+
isPublic: false
|
|
127
127
|
// TODO: has no block explorer API
|
|
128
128
|
}),
|
|
129
129
|
Monad: (0, import_viem.defineChain)({
|
|
130
130
|
...import_chains.monadTestnet,
|
|
131
131
|
network: "Monad",
|
|
132
132
|
defaultMarketConfigurators: {},
|
|
133
|
-
isPublic:
|
|
133
|
+
isPublic: false
|
|
134
134
|
// TODO: has no block explorer API
|
|
135
135
|
}),
|
|
136
136
|
Berachain: withPublicNode(
|
|
@@ -138,7 +138,7 @@ const chains = {
|
|
|
138
138
|
...import_chains.berachain,
|
|
139
139
|
network: "Berachain",
|
|
140
140
|
defaultMarketConfigurators: {},
|
|
141
|
-
isPublic:
|
|
141
|
+
isPublic: false,
|
|
142
142
|
blockExplorers: {
|
|
143
143
|
default: {
|
|
144
144
|
name: "Berascan",
|
|
@@ -154,7 +154,7 @@ const chains = {
|
|
|
154
154
|
...import_chains.avalanche,
|
|
155
155
|
network: "Avalanche",
|
|
156
156
|
defaultMarketConfigurators: {},
|
|
157
|
-
isPublic:
|
|
157
|
+
isPublic: false
|
|
158
158
|
},
|
|
159
159
|
"avalanche-c-chain-rpc"
|
|
160
160
|
)
|
|
@@ -20,10 +20,14 @@ var endpoint_exports = {};
|
|
|
20
20
|
__export(endpoint_exports, {
|
|
21
21
|
GearboxBackendApi: () => GearboxBackendApi,
|
|
22
22
|
TESTNET_CHAINS: () => TESTNET_CHAINS,
|
|
23
|
-
URLApi: () => URLApi
|
|
23
|
+
URLApi: () => URLApi,
|
|
24
|
+
getMainnetByTestnet: () => getMainnetByTestnet,
|
|
25
|
+
getTestNetworkType: () => getTestNetworkType,
|
|
26
|
+
isTestNetwork: () => isTestNetwork
|
|
24
27
|
});
|
|
25
28
|
module.exports = __toCommonJS(endpoint_exports);
|
|
26
29
|
var import_chain = require("../../chain/index.js");
|
|
30
|
+
var import_mappers = require("../../utils/mappers.js");
|
|
27
31
|
const TESTNET_CHAINS = {
|
|
28
32
|
Mainnet: 7878,
|
|
29
33
|
Optimism: 7879,
|
|
@@ -36,30 +40,35 @@ const TESTNET_CHAINS = {
|
|
|
36
40
|
Berachain: 7885,
|
|
37
41
|
Avalanche: 7886
|
|
38
42
|
};
|
|
43
|
+
const CHAINS_BY_ID = import_mappers.TypedObjectUtils.swapKeyValue(TESTNET_CHAINS);
|
|
44
|
+
const MAINNET_BY_TESTNET_ID = import_mappers.TypedObjectUtils.entries(TESTNET_CHAINS).reduce((acc, [n, testnetId]) => {
|
|
45
|
+
const primaryId = import_chain.chains[n]?.id;
|
|
46
|
+
acc[testnetId] = primaryId;
|
|
47
|
+
return acc;
|
|
48
|
+
}, {});
|
|
49
|
+
const getMainnetByTestnet = (testnetId) => MAINNET_BY_TESTNET_ID[testnetId];
|
|
50
|
+
const getTestNetworkType = (chainId) => CHAINS_BY_ID[chainId];
|
|
51
|
+
const isTestNetwork = (chainId) => chainId !== void 0 && !!CHAINS_BY_ID[chainId];
|
|
39
52
|
const CHARTS_BACKEND_ADDRESSES = {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
[import_chain.chains.Sonic.id]: "https://charts-server.fly.dev",
|
|
53
|
+
...Object.values(import_chain.chains).reduce((acc, chain) => {
|
|
54
|
+
acc[chain.id] = "https://charts-server.fly.dev";
|
|
55
|
+
return acc;
|
|
56
|
+
}, {}),
|
|
45
57
|
[TESTNET_CHAINS.Mainnet]: "https://testnet.gearbox.foundation",
|
|
46
58
|
[TESTNET_CHAINS.Arbitrum]: "https://arbtest.gearbox.foundation",
|
|
47
59
|
[TESTNET_CHAINS.Optimism]: "https://opttest.gearbox.foundation"
|
|
48
|
-
// !&
|
|
60
|
+
// !& new chains
|
|
49
61
|
};
|
|
50
|
-
const LAMA_URL = "https://charts-server.fly.dev/api/defillama?ids=";
|
|
51
62
|
const STATIC_TOKEN = "https://static.gearbox.fi/tokens/";
|
|
52
63
|
const LEADERBOARD_APIS = {
|
|
53
64
|
[import_chain.chains.Mainnet.id]: "https://gpointbot.fly.dev",
|
|
54
65
|
[import_chain.chains.Optimism.id]: "https://gpointbot.fly.dev",
|
|
55
66
|
[import_chain.chains.Arbitrum.id]: "https://gpointbot.fly.dev",
|
|
56
|
-
|
|
57
|
-
[import_chain.chains.Sonic.id]: "https://gpointbot.fly.dev",
|
|
67
|
+
// !& new chains
|
|
58
68
|
[TESTNET_CHAINS.Mainnet]: "https://testnet.gearbox.foundation/gpointbot",
|
|
59
69
|
[TESTNET_CHAINS.Optimism]: "https://testnet.gearbox.foundation/gpointbot",
|
|
60
|
-
[TESTNET_CHAINS.Arbitrum]: "https://testnet.gearbox.foundation/gpointbot"
|
|
61
|
-
|
|
62
|
-
[TESTNET_CHAINS.Sonic]: "https://testnet.gearbox.foundation/gpointbot"
|
|
70
|
+
[TESTNET_CHAINS.Arbitrum]: "https://testnet.gearbox.foundation/gpointbot"
|
|
71
|
+
// !& new chains
|
|
63
72
|
};
|
|
64
73
|
const REFERRAL_API = "https://referral-gen.fly.dev/generate";
|
|
65
74
|
class GearboxBackendApi {
|
|
@@ -76,9 +85,6 @@ class GearboxBackendApi {
|
|
|
76
85
|
);
|
|
77
86
|
return [domain, "api", ...priceSourceArr, relativePath].join("/");
|
|
78
87
|
};
|
|
79
|
-
static getLlamaAPYUrl = (idList) => {
|
|
80
|
-
return `${LAMA_URL}${idList.join(",")}`;
|
|
81
|
-
};
|
|
82
88
|
static getStaticTokenUrl = () => STATIC_TOKEN;
|
|
83
89
|
static getRewardsMerkleUrl = (network, root, account) => {
|
|
84
90
|
const path = `${network}_${root.slice(2)}/${account.slice(2, 4)}`;
|
|
@@ -114,5 +120,8 @@ class URLApi {
|
|
|
114
120
|
0 && (module.exports = {
|
|
115
121
|
GearboxBackendApi,
|
|
116
122
|
TESTNET_CHAINS,
|
|
117
|
-
URLApi
|
|
123
|
+
URLApi,
|
|
124
|
+
getMainnetByTestnet,
|
|
125
|
+
getTestNetworkType,
|
|
126
|
+
isTestNetwork
|
|
118
127
|
});
|
|
@@ -52,10 +52,10 @@ class PositionUtils {
|
|
|
52
52
|
const [cm = "", lt = 0n] = sorted[0] || [];
|
|
53
53
|
return [lt, cm];
|
|
54
54
|
}
|
|
55
|
-
static isStrategyReleased(releaseAt, currentTimestamp,
|
|
55
|
+
static isStrategyReleased(releaseAt, currentTimestamp, chainId) {
|
|
56
56
|
if (releaseAt === void 0) return true;
|
|
57
57
|
if (typeof releaseAt === "number") return currentTimestamp > releaseAt;
|
|
58
|
-
const releaseAtNetwork = releaseAt[
|
|
58
|
+
const releaseAtNetwork = releaseAt[chainId];
|
|
59
59
|
if (releaseAtNetwork === void 0) return true;
|
|
60
60
|
return currentTimestamp > releaseAtNetwork;
|
|
61
61
|
}
|
|
@@ -78,7 +78,7 @@ const chains = {
|
|
|
78
78
|
...base,
|
|
79
79
|
network: "Base",
|
|
80
80
|
defaultMarketConfigurators: {},
|
|
81
|
-
isPublic:
|
|
81
|
+
isPublic: false
|
|
82
82
|
},
|
|
83
83
|
"base-rpc"
|
|
84
84
|
),
|
|
@@ -104,14 +104,14 @@ const chains = {
|
|
|
104
104
|
...megaethTestnet,
|
|
105
105
|
network: "MegaETH",
|
|
106
106
|
defaultMarketConfigurators: {},
|
|
107
|
-
isPublic:
|
|
107
|
+
isPublic: false
|
|
108
108
|
// TODO: has no block explorer API
|
|
109
109
|
}),
|
|
110
110
|
Monad: defineChain({
|
|
111
111
|
...monadTestnet,
|
|
112
112
|
network: "Monad",
|
|
113
113
|
defaultMarketConfigurators: {},
|
|
114
|
-
isPublic:
|
|
114
|
+
isPublic: false
|
|
115
115
|
// TODO: has no block explorer API
|
|
116
116
|
}),
|
|
117
117
|
Berachain: withPublicNode(
|
|
@@ -119,7 +119,7 @@ const chains = {
|
|
|
119
119
|
...berachain,
|
|
120
120
|
network: "Berachain",
|
|
121
121
|
defaultMarketConfigurators: {},
|
|
122
|
-
isPublic:
|
|
122
|
+
isPublic: false,
|
|
123
123
|
blockExplorers: {
|
|
124
124
|
default: {
|
|
125
125
|
name: "Berascan",
|
|
@@ -135,7 +135,7 @@ const chains = {
|
|
|
135
135
|
...avalanche,
|
|
136
136
|
network: "Avalanche",
|
|
137
137
|
defaultMarketConfigurators: {},
|
|
138
|
-
isPublic:
|
|
138
|
+
isPublic: false
|
|
139
139
|
},
|
|
140
140
|
"avalanche-c-chain-rpc"
|
|
141
141
|
)
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { chains, isSupportedNetwork } from "../../chain/index.js";
|
|
1
|
+
import { chains as CHAINS, isSupportedNetwork } from "../../chain/index.js";
|
|
2
|
+
import { TypedObjectUtils } from "../../utils/mappers.js";
|
|
2
3
|
const TESTNET_CHAINS = {
|
|
3
4
|
Mainnet: 7878,
|
|
4
5
|
Optimism: 7879,
|
|
@@ -11,30 +12,35 @@ const TESTNET_CHAINS = {
|
|
|
11
12
|
Berachain: 7885,
|
|
12
13
|
Avalanche: 7886
|
|
13
14
|
};
|
|
15
|
+
const CHAINS_BY_ID = TypedObjectUtils.swapKeyValue(TESTNET_CHAINS);
|
|
16
|
+
const MAINNET_BY_TESTNET_ID = TypedObjectUtils.entries(TESTNET_CHAINS).reduce((acc, [n, testnetId]) => {
|
|
17
|
+
const primaryId = CHAINS[n]?.id;
|
|
18
|
+
acc[testnetId] = primaryId;
|
|
19
|
+
return acc;
|
|
20
|
+
}, {});
|
|
21
|
+
const getMainnetByTestnet = (testnetId) => MAINNET_BY_TESTNET_ID[testnetId];
|
|
22
|
+
const getTestNetworkType = (chainId) => CHAINS_BY_ID[chainId];
|
|
23
|
+
const isTestNetwork = (chainId) => chainId !== void 0 && !!CHAINS_BY_ID[chainId];
|
|
14
24
|
const CHARTS_BACKEND_ADDRESSES = {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
[chains.Sonic.id]: "https://charts-server.fly.dev",
|
|
25
|
+
...Object.values(CHAINS).reduce((acc, chain) => {
|
|
26
|
+
acc[chain.id] = "https://charts-server.fly.dev";
|
|
27
|
+
return acc;
|
|
28
|
+
}, {}),
|
|
20
29
|
[TESTNET_CHAINS.Mainnet]: "https://testnet.gearbox.foundation",
|
|
21
30
|
[TESTNET_CHAINS.Arbitrum]: "https://arbtest.gearbox.foundation",
|
|
22
31
|
[TESTNET_CHAINS.Optimism]: "https://opttest.gearbox.foundation"
|
|
23
|
-
// !&
|
|
32
|
+
// !& new chains
|
|
24
33
|
};
|
|
25
|
-
const LAMA_URL = "https://charts-server.fly.dev/api/defillama?ids=";
|
|
26
34
|
const STATIC_TOKEN = "https://static.gearbox.fi/tokens/";
|
|
27
35
|
const LEADERBOARD_APIS = {
|
|
28
|
-
[
|
|
29
|
-
[
|
|
30
|
-
[
|
|
31
|
-
|
|
32
|
-
[chains.Sonic.id]: "https://gpointbot.fly.dev",
|
|
36
|
+
[CHAINS.Mainnet.id]: "https://gpointbot.fly.dev",
|
|
37
|
+
[CHAINS.Optimism.id]: "https://gpointbot.fly.dev",
|
|
38
|
+
[CHAINS.Arbitrum.id]: "https://gpointbot.fly.dev",
|
|
39
|
+
// !& new chains
|
|
33
40
|
[TESTNET_CHAINS.Mainnet]: "https://testnet.gearbox.foundation/gpointbot",
|
|
34
41
|
[TESTNET_CHAINS.Optimism]: "https://testnet.gearbox.foundation/gpointbot",
|
|
35
|
-
[TESTNET_CHAINS.Arbitrum]: "https://testnet.gearbox.foundation/gpointbot"
|
|
36
|
-
|
|
37
|
-
[TESTNET_CHAINS.Sonic]: "https://testnet.gearbox.foundation/gpointbot"
|
|
42
|
+
[TESTNET_CHAINS.Arbitrum]: "https://testnet.gearbox.foundation/gpointbot"
|
|
43
|
+
// !& new chains
|
|
38
44
|
};
|
|
39
45
|
const REFERRAL_API = "https://referral-gen.fly.dev/generate";
|
|
40
46
|
class GearboxBackendApi {
|
|
@@ -51,9 +57,6 @@ class GearboxBackendApi {
|
|
|
51
57
|
);
|
|
52
58
|
return [domain, "api", ...priceSourceArr, relativePath].join("/");
|
|
53
59
|
};
|
|
54
|
-
static getLlamaAPYUrl = (idList) => {
|
|
55
|
-
return `${LAMA_URL}${idList.join(",")}`;
|
|
56
|
-
};
|
|
57
60
|
static getStaticTokenUrl = () => STATIC_TOKEN;
|
|
58
61
|
static getRewardsMerkleUrl = (network, root, account) => {
|
|
59
62
|
const path = `${network}_${root.slice(2)}/${account.slice(2, 4)}`;
|
|
@@ -88,5 +91,8 @@ class URLApi {
|
|
|
88
91
|
export {
|
|
89
92
|
GearboxBackendApi,
|
|
90
93
|
TESTNET_CHAINS,
|
|
91
|
-
URLApi
|
|
94
|
+
URLApi,
|
|
95
|
+
getMainnetByTestnet,
|
|
96
|
+
getTestNetworkType,
|
|
97
|
+
isTestNetwork
|
|
92
98
|
};
|
|
@@ -29,10 +29,10 @@ class PositionUtils {
|
|
|
29
29
|
const [cm = "", lt = 0n] = sorted[0] || [];
|
|
30
30
|
return [lt, cm];
|
|
31
31
|
}
|
|
32
|
-
static isStrategyReleased(releaseAt, currentTimestamp,
|
|
32
|
+
static isStrategyReleased(releaseAt, currentTimestamp, chainId) {
|
|
33
33
|
if (releaseAt === void 0) return true;
|
|
34
34
|
if (typeof releaseAt === "number") return currentTimestamp > releaseAt;
|
|
35
|
-
const releaseAtNetwork = releaseAt[
|
|
35
|
+
const releaseAtNetwork = releaseAt[chainId];
|
|
36
36
|
if (releaseAtNetwork === void 0) return true;
|
|
37
37
|
return currentTimestamp > releaseAtNetwork;
|
|
38
38
|
}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import type { Address } from "viem";
|
|
2
2
|
import type { NetworkType } from "../../chain/index.js";
|
|
3
3
|
export declare const TESTNET_CHAINS: Record<NetworkType, number>;
|
|
4
|
+
export declare const getMainnetByTestnet: (testnetId: number) => number | undefined;
|
|
5
|
+
export declare const getTestNetworkType: (chainId: number) => NetworkType | undefined;
|
|
6
|
+
export declare const isTestNetwork: (chainId: number | undefined) => chainId is number;
|
|
4
7
|
type ChartsPriceSource = "chainlink" | "spot";
|
|
5
8
|
export declare class GearboxBackendApi {
|
|
6
9
|
static getChartsUrl: (url: string, chainId: number, options?: Options, priceSource?: ChartsPriceSource) => string;
|
|
7
|
-
static getLlamaAPYUrl: (idList: Array<string>) => string;
|
|
8
10
|
static getStaticTokenUrl: () => string;
|
|
9
11
|
static getRewardsMerkleUrl: (network: NetworkType, root: Address, account: Address) => string;
|
|
10
12
|
static getNFTMerkleUrl: (network: NetworkType, root: Address) => string;
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import type { Address } from "viem";
|
|
2
|
-
import type { NetworkType } from "../../chain/index.js";
|
|
3
|
-
import type { PartialRecord } from "../../utils/index.js";
|
|
4
2
|
import type { CreditManagerData_Legacy } from "./creditManager.js";
|
|
5
|
-
export type ReleaseAt = undefined | number |
|
|
3
|
+
export type ReleaseAt = undefined | number | Record<number, number>;
|
|
6
4
|
interface CalculateMaxAPYProps {
|
|
7
5
|
apy: number;
|
|
8
6
|
leverage: number;
|
|
@@ -13,7 +11,7 @@ export declare class PositionUtils {
|
|
|
13
11
|
static maxLeverage(lpToken: Address, cms: Array<PartialCM>): number;
|
|
14
12
|
static maxAPY({ apy, leverage, baseRateWithFee, quotaRateWithFee, }: CalculateMaxAPYProps): number;
|
|
15
13
|
protected static maxLeverageThreshold(lpToken: Address, cms: Array<PartialCM>): readonly [bigint, "" | `0x${string}`];
|
|
16
|
-
static isStrategyReleased(releaseAt: ReleaseAt, currentTimestamp: number,
|
|
14
|
+
static isStrategyReleased(releaseAt: ReleaseAt, currentTimestamp: number, chainId: number): boolean;
|
|
17
15
|
}
|
|
18
16
|
type PartialCM = Pick<CreditManagerData_Legacy, "liquidationThresholds" | "address">;
|
|
19
17
|
export {};
|