@pear-protocol/exchanges-sdk 0.6.5 → 0.6.7
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/client/base-ws.js +15 -6
- package/dist/client/binance/exchange-ws.js +22 -8
- package/dist/client/binance/rest.js +40 -27
- package/dist/client/binance/ws.js +21 -2
- package/dist/client/bybit/exchange-ws.js +13 -6
- package/dist/client/bybit/rest.js +30 -36
- package/dist/client/bybit/ws.js +16 -2
- package/dist/client/exchange-ws.js +5 -0
- package/dist/client/hmac.js +9 -1
- package/dist/client/hyperliquid/exchange-ws.js +13 -5
- package/dist/client/hyperliquid/rest.js +37 -7
- package/dist/client/hyperliquid/ws.js +10 -4
- package/dist/client/index.js +9 -2
- package/dist/client/lighter/constants.js +4 -0
- package/dist/client/lighter/exchange-ws.js +13 -5
- package/dist/client/lighter/rest.js +153 -18
- package/dist/client/lighter/ws.js +10 -4
- package/dist/client/okx/exchange-ws.js +13 -6
- package/dist/client/okx/rest.js +27 -24
- package/dist/client/okx/ws.js +5 -0
- package/dist/helper/factory.js +3 -0
- package/dist/helper/hyperliquid/helper.js +18 -23
- package/dist/helper/lighter/auth-token.helper.js +68 -0
- package/dist/helper/lighter/cctp-deposit.helper.js +297 -0
- package/dist/helper/lighter/ethereum/abi.js +55 -11
- package/dist/helper/lighter/ethereum/index.js +22 -3
- package/dist/helper/lighter/ethereum/usdc.helper.js +77 -0
- package/dist/helper/lighter/helper.js +116 -37
- package/dist/helper/lighter/index.js +1 -0
- package/dist/helper/lighter/onboarding.helper.js +28 -0
- package/dist/helper/lighter/types.js +6 -1
- package/dist/helper/subaccount.helper.js +20 -0
- package/dist/index.d.ts +202 -1
- package/dist/sdk.js +18 -7
- package/dist/status/base.js +16 -3
- package/dist/status/binance/status.js +3 -0
- package/dist/status/bybit/status.js +3 -0
- package/dist/status/factory.js +3 -0
- package/dist/status/hyperliquid/status.js +8 -6
- package/dist/status/lighter/status.js +11 -3
- package/dist/status/okx/status.js +3 -0
- package/dist/syncer/base.js +63 -24
- package/dist/syncer/binance/syncer.js +14 -13
- package/dist/syncer/bybit/syncer.js +10 -6
- package/dist/syncer/factory.js +3 -0
- package/dist/syncer/hyperliquid/funding.js +3 -0
- package/dist/syncer/hyperliquid/syncer.js +52 -66
- package/dist/syncer/lighter/funding.js +3 -0
- package/dist/syncer/lighter/syncer.js +26 -25
- package/dist/syncer/okx/syncer.js +15 -13
- package/dist/tracker/base.js +15 -5
- package/dist/tracker/binance/mapper.js +5 -1
- package/dist/tracker/binance/tracker.js +63 -23
- package/dist/tracker/binance/types.js +2 -2
- package/dist/tracker/bybit/mapper.js +7 -1
- package/dist/tracker/bybit/tracker.js +68 -24
- package/dist/tracker/bybit/types.js +2 -2
- package/dist/tracker/hyperliquid/const.js +3 -1
- package/dist/tracker/hyperliquid/mapper.js +36 -20
- package/dist/tracker/hyperliquid/tracker.js +147 -54
- package/dist/tracker/hyperliquid/types.js +2 -2
- package/dist/tracker/index.js +3 -0
- package/dist/tracker/lighter/mapper.js +41 -31
- package/dist/tracker/lighter/tracker.js +68 -27
- package/dist/tracker/lighter/types.js +4 -4
- package/dist/tracker/okx/mapper.js +8 -0
- package/dist/tracker/okx/tracker.js +69 -18
- package/dist/tracker/okx/types.js +2 -2
- package/dist/tracker/utils.js +4 -0
- package/package.json +3 -3
- package/dist/client/hyperliquid/client.test.js +0 -41
- package/dist/client/lighter/constants.test.js +0 -22
- package/dist/client/lighter/rest.test.js +0 -158
- package/dist/helper/hyperliquid/helper.test.js +0 -72
- package/dist/helper/lighter/helper.test.js +0 -289
- package/dist/sdk.test.js +0 -117
- package/dist/status/hyperliquid/status.test.js +0 -94
- package/dist/status/lighter/status.test.js +0 -86
- package/dist/syncer/base.test.js +0 -178
- package/dist/syncer/hyperliquid/funding.test.js +0 -63
- package/dist/syncer/hyperliquid/syncer.test.js +0 -271
- package/dist/syncer/lighter/funding.test.js +0 -48
- package/dist/syncer/lighter/syncer.test.js +0 -274
- package/dist/tracker/base.test.js +0 -132
- package/dist/tracker/binance/tracker.test.js +0 -138
- package/dist/tracker/bybit/tracker.test.js +0 -145
- package/dist/tracker/hyperliquid/mapper.test.js +0 -260
- package/dist/tracker/hyperliquid/tracker.test.js +0 -597
- package/dist/tracker/lighter/mapper.test.js +0 -199
- package/dist/tracker/lighter/tracker.test.js +0 -515
- package/dist/tracker/okx/tracker.test.js +0 -126
- package/dist/tracker/utils.test.js +0 -8
|
@@ -1,47 +1,36 @@
|
|
|
1
|
-
import { parseUnits, parseEther } from 'viem';
|
|
1
|
+
import { parseUnits, isAddress, parseEther } from 'viem';
|
|
2
2
|
import { fetchApiKeys, fetchAccount, fetchAccountsByL1Address, fetchAssetDetails } from '../../client/lighter/rest';
|
|
3
|
+
import { parseUsdcAmount } from '../subaccount.helper';
|
|
4
|
+
import { depositUsdcViaCctp, createExternalCctpDepositIntent, listCctpDepositNetworks } from './cctp-deposit.helper';
|
|
3
5
|
import { writeWithdraw, writeDeposit } from './ethereum';
|
|
4
|
-
import {
|
|
6
|
+
import { LIGHTER_ACCOUNT_NOT_REGISTERED_CODE, readOnboardingStatus } from './onboarding.helper';
|
|
7
|
+
import { MIN_LIGHTER_FAST_WITHDRAW_USDC, AssetId } from './types';
|
|
5
8
|
|
|
9
|
+
var __defProp = Object.defineProperty;
|
|
10
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
6
11
|
const MIN_USER_API_KEY_INDEX = 4;
|
|
7
12
|
const MAX_API_KEY_INDEX = 254;
|
|
13
|
+
const MIN_FAST_WITHDRAW_USDC_UNITS = parseUsdcAmount(MIN_LIGHTER_FAST_WITHDRAW_USDC);
|
|
8
14
|
function findAvailableApiKeyIndex(apiKeys) {
|
|
9
15
|
const occupied = new Set(apiKeys.map((key) => key.api_key_index));
|
|
10
16
|
for (let index = MIN_USER_API_KEY_INDEX; index <= MAX_API_KEY_INDEX; index += 1) {
|
|
11
17
|
if (!occupied.has(index)) return index;
|
|
12
18
|
}
|
|
13
|
-
throw new Error(
|
|
14
|
-
`No available Lighter API key slots: non-reserved indices ${MIN_USER_API_KEY_INDEX}-${MAX_API_KEY_INDEX} are occupied`
|
|
15
|
-
);
|
|
16
|
-
}
|
|
17
|
-
function validateDecimals(decimals, source) {
|
|
18
|
-
if (!Number.isSafeInteger(decimals) || decimals < 0 || decimals > 255) {
|
|
19
|
-
throw new Error(`Invalid ${source} decimals: ${decimals}`);
|
|
20
|
-
}
|
|
21
|
-
return decimals;
|
|
22
|
-
}
|
|
23
|
-
async function resolveAssetDecimals(assetId, field, suppliedDecimals, demo) {
|
|
24
|
-
if (suppliedDecimals !== void 0) return validateDecimals(suppliedDecimals, field);
|
|
25
|
-
const assets = await fetchAssetDetails(demo);
|
|
26
|
-
const asset = assets.find((candidate) => candidate.asset_id === assetId);
|
|
27
|
-
if (!asset) throw new Error(`Lighter asset ${assetId} was not returned by assetDetails`);
|
|
28
|
-
return validateDecimals(asset[field], `assetDetails.${field}`);
|
|
29
|
-
}
|
|
30
|
-
function validateApprovalRequirements(requirements) {
|
|
31
|
-
for (const [name, value] of [
|
|
32
|
-
["minPerpsMakerFee", requirements.minPerpsMakerFee],
|
|
33
|
-
["minPerpsTakerFee", requirements.minPerpsTakerFee]
|
|
34
|
-
]) {
|
|
35
|
-
if (!Number.isSafeInteger(value) || value < 0) {
|
|
36
|
-
throw new Error(`Invalid Lighter integrator ${name}: ${value}`);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
19
|
+
throw new Error(`No available Lighter API key slots: non-reserved indices ${MIN_USER_API_KEY_INDEX}-${MAX_API_KEY_INDEX} are occupied`);
|
|
39
20
|
}
|
|
21
|
+
__name(findAvailableApiKeyIndex, "findAvailableApiKeyIndex");
|
|
40
22
|
function createLighterHelper(sdk, demo = false) {
|
|
41
|
-
|
|
23
|
+
const helper = {
|
|
24
|
+
/** Reports whether an L1 address still needs its first deposit before it owns a Lighter account. */
|
|
25
|
+
async checkOnboarding(l1Address) {
|
|
26
|
+
if (!isAddress(l1Address)) {
|
|
27
|
+
throw new Error(`Invalid Lighter L1 address: ${l1Address}`);
|
|
28
|
+
}
|
|
29
|
+
return readOnboardingStatus(l1Address, demo);
|
|
30
|
+
},
|
|
42
31
|
async lookupAccount(l1Address) {
|
|
43
32
|
const data = await fetchAccountsByL1Address(l1Address, demo);
|
|
44
|
-
if (data.code ===
|
|
33
|
+
if (data.code === LIGHTER_ACCOUNT_NOT_REGISTERED_CODE) {
|
|
45
34
|
throw new Error("Account not registered on Lighter");
|
|
46
35
|
}
|
|
47
36
|
const accounts = data.sub_accounts ?? [];
|
|
@@ -62,9 +51,7 @@ function createLighterHelper(sdk, demo = false) {
|
|
|
62
51
|
const minMakerFee = requirements?.minPerpsMakerFee ?? 0;
|
|
63
52
|
const minTakerFee = requirements?.minPerpsTakerFee ?? 0;
|
|
64
53
|
const integrators = account.approved_integrators ?? [];
|
|
65
|
-
return integrators.some(
|
|
66
|
-
(integrator) => integrator.account_index === integratorAccountIndex && integrator.approval_expiry > Date.now() && integrator.max_perps_maker_fee >= minMakerFee && integrator.max_perps_taker_fee >= minTakerFee
|
|
67
|
-
);
|
|
54
|
+
return integrators.some((integrator) => integrator.account_index === integratorAccountIndex && integrator.approval_expiry > Date.now() && integrator.max_perps_maker_fee >= minMakerFee && integrator.max_perps_taker_fee >= minTakerFee);
|
|
68
55
|
},
|
|
69
56
|
async connectWallet(walletClient, params) {
|
|
70
57
|
if (demo) {
|
|
@@ -86,7 +73,11 @@ function createLighterHelper(sdk, demo = false) {
|
|
|
86
73
|
accountIndex: params.accountIndex,
|
|
87
74
|
apiKeyIndex
|
|
88
75
|
});
|
|
89
|
-
return {
|
|
76
|
+
return {
|
|
77
|
+
txHash,
|
|
78
|
+
apiKeyIndex,
|
|
79
|
+
apiPrivateKey: privateKey
|
|
80
|
+
};
|
|
90
81
|
},
|
|
91
82
|
async approveIntegrator(walletClient, params) {
|
|
92
83
|
if (demo) {
|
|
@@ -107,7 +98,21 @@ function createLighterHelper(sdk, demo = false) {
|
|
|
107
98
|
accountIndex: params.accountIndex,
|
|
108
99
|
apiKeyIndex: params.apiKeyIndex
|
|
109
100
|
});
|
|
110
|
-
return {
|
|
101
|
+
return {
|
|
102
|
+
txHash
|
|
103
|
+
};
|
|
104
|
+
},
|
|
105
|
+
/** Lists the source networks Lighter credits through an intent address right now. */
|
|
106
|
+
async listDepositNetworks() {
|
|
107
|
+
return listCctpDepositNetworks(demo);
|
|
108
|
+
},
|
|
109
|
+
/** Creates a CCTP intent address for USDC deposits from a currently supported chain. */
|
|
110
|
+
async createExternalCctpDepositIntent(params) {
|
|
111
|
+
return createExternalCctpDepositIntent(params, demo);
|
|
112
|
+
},
|
|
113
|
+
/** Runs the complete direct native-USDC deposit flow. */
|
|
114
|
+
async depositUsdcViaCctp(params) {
|
|
115
|
+
return depositUsdcViaCctp(sdk, params, demo);
|
|
111
116
|
},
|
|
112
117
|
async deposit(walletClient, params) {
|
|
113
118
|
if (demo) {
|
|
@@ -132,7 +137,45 @@ function createLighterHelper(sdk, demo = false) {
|
|
|
132
137
|
amount,
|
|
133
138
|
value
|
|
134
139
|
});
|
|
135
|
-
return {
|
|
140
|
+
return {
|
|
141
|
+
txHash
|
|
142
|
+
};
|
|
143
|
+
},
|
|
144
|
+
/** Performs a wallet-authorized fast USDC withdrawal through Lighter's transfer pool. */
|
|
145
|
+
async fastWithdraw(walletClient, params) {
|
|
146
|
+
if (demo) {
|
|
147
|
+
throw new Error("Lighter demo fast withdrawals are unavailable because backend signing is mainnet-only");
|
|
148
|
+
}
|
|
149
|
+
if (!isAddress(params.toAddress)) {
|
|
150
|
+
throw new Error(`Invalid Lighter fast withdrawal address: ${params.toAddress}`);
|
|
151
|
+
}
|
|
152
|
+
const amount = parseUsdcAmount(params.amount);
|
|
153
|
+
if (amount < MIN_FAST_WITHDRAW_USDC_UNITS) {
|
|
154
|
+
throw new Error(`Lighter fast withdrawal minimum is ${MIN_LIGHTER_FAST_WITHDRAW_USDC} USDC`);
|
|
155
|
+
}
|
|
156
|
+
const { messageToSign, txInfo, fee } = await sdk.core.misc.lighter.prepareFastWithdraw({
|
|
157
|
+
accountIndex: params.accountIndex,
|
|
158
|
+
toAddress: params.toAddress,
|
|
159
|
+
amount,
|
|
160
|
+
apiKeyIndex: params.apiKeyIndex,
|
|
161
|
+
apiPrivateKey: params.apiPrivateKey
|
|
162
|
+
});
|
|
163
|
+
const l1Signature = await walletClient.signMessage({
|
|
164
|
+
account: walletClient.account,
|
|
165
|
+
message: messageToSign
|
|
166
|
+
});
|
|
167
|
+
const { txHash } = await sdk.core.misc.lighter.submitFastWithdraw({
|
|
168
|
+
accountIndex: params.accountIndex,
|
|
169
|
+
toAddress: params.toAddress,
|
|
170
|
+
apiKeyIndex: params.apiKeyIndex,
|
|
171
|
+
apiPrivateKey: params.apiPrivateKey,
|
|
172
|
+
txInfo,
|
|
173
|
+
l1Signature
|
|
174
|
+
});
|
|
175
|
+
return {
|
|
176
|
+
txHash,
|
|
177
|
+
fee
|
|
178
|
+
};
|
|
136
179
|
},
|
|
137
180
|
async withdraw(walletClient, params) {
|
|
138
181
|
if (demo) {
|
|
@@ -145,9 +188,45 @@ function createLighterHelper(sdk, demo = false) {
|
|
|
145
188
|
routeType: params.routeType,
|
|
146
189
|
baseAmount: parseUnits(params.amount, l2Decimals)
|
|
147
190
|
});
|
|
148
|
-
return {
|
|
191
|
+
return {
|
|
192
|
+
txHash
|
|
193
|
+
};
|
|
149
194
|
}
|
|
150
195
|
};
|
|
196
|
+
return helper;
|
|
197
|
+
}
|
|
198
|
+
__name(createLighterHelper, "createLighterHelper");
|
|
199
|
+
function validateDecimals(decimals, source) {
|
|
200
|
+
if (!Number.isSafeInteger(decimals) || decimals < 0 || decimals > 255) {
|
|
201
|
+
throw new Error(`Invalid ${source} decimals: ${decimals}`);
|
|
202
|
+
}
|
|
203
|
+
return decimals;
|
|
204
|
+
}
|
|
205
|
+
__name(validateDecimals, "validateDecimals");
|
|
206
|
+
async function resolveAssetDecimals(assetId, field, suppliedDecimals, demo) {
|
|
207
|
+
if (suppliedDecimals !== void 0) return validateDecimals(suppliedDecimals, field);
|
|
208
|
+
const assets = await fetchAssetDetails(demo);
|
|
209
|
+
const asset = assets.find((candidate) => candidate.asset_id === assetId);
|
|
210
|
+
if (!asset) throw new Error(`Lighter asset ${assetId} was not returned by assetDetails`);
|
|
211
|
+
return validateDecimals(asset[field], `assetDetails.${field}`);
|
|
212
|
+
}
|
|
213
|
+
__name(resolveAssetDecimals, "resolveAssetDecimals");
|
|
214
|
+
function validateApprovalRequirements(requirements) {
|
|
215
|
+
for (const [name, value] of [
|
|
216
|
+
[
|
|
217
|
+
"minPerpsMakerFee",
|
|
218
|
+
requirements.minPerpsMakerFee
|
|
219
|
+
],
|
|
220
|
+
[
|
|
221
|
+
"minPerpsTakerFee",
|
|
222
|
+
requirements.minPerpsTakerFee
|
|
223
|
+
]
|
|
224
|
+
]) {
|
|
225
|
+
if (!Number.isSafeInteger(value) || value < 0) {
|
|
226
|
+
throw new Error(`Invalid Lighter integrator ${name}: ${value}`);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
151
229
|
}
|
|
230
|
+
__name(validateApprovalRequirements, "validateApprovalRequirements");
|
|
152
231
|
|
|
153
232
|
export { MAX_API_KEY_INDEX, MIN_USER_API_KEY_INDEX, createLighterHelper, findAvailableApiKeyIndex };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { fetchAccountsByL1Address } from '../../client/lighter/rest';
|
|
2
|
+
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
5
|
+
const LIGHTER_ACCOUNT_NOT_REGISTERED_CODE = 21100;
|
|
6
|
+
async function readOnboardingStatus(l1Address, demo) {
|
|
7
|
+
const data = await fetchAccountsByL1Address(l1Address, demo);
|
|
8
|
+
if (data.code === LIGHTER_ACCOUNT_NOT_REGISTERED_CODE) {
|
|
9
|
+
return {
|
|
10
|
+
step: "deposit-required"
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
const accounts = data.sub_accounts ?? [];
|
|
14
|
+
const main = accounts.find((account) => account.account_type === 0);
|
|
15
|
+
if (!main) {
|
|
16
|
+
return {
|
|
17
|
+
step: "deposit-required"
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
return {
|
|
21
|
+
step: "account-ready",
|
|
22
|
+
mainAccountIndex: main.index,
|
|
23
|
+
subAccountIndexes: accounts.filter((account) => account.account_type !== 0).map((account) => account.index)
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
__name(readOnboardingStatus, "readOnboardingStatus");
|
|
27
|
+
|
|
28
|
+
export { LIGHTER_ACCOUNT_NOT_REGISTERED_CODE, readOnboardingStatus };
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
1
3
|
const AssetId = {
|
|
2
4
|
ETH: 1,
|
|
3
5
|
LIT: 2,
|
|
@@ -13,6 +15,8 @@ const RouteType = {
|
|
|
13
15
|
PERP: 0,
|
|
14
16
|
SPOT: 1
|
|
15
17
|
};
|
|
18
|
+
const MIN_LIGHTER_CCTP_DEPOSIT_USDC = "5";
|
|
19
|
+
const MIN_LIGHTER_FAST_WITHDRAW_USDC = "4";
|
|
16
20
|
const L2_ASSET_DECIMALS = {
|
|
17
21
|
[AssetId.ETH]: 8,
|
|
18
22
|
[AssetId.LIT]: 8,
|
|
@@ -32,5 +36,6 @@ function getAssetDecimals(assetId) {
|
|
|
32
36
|
}
|
|
33
37
|
return decimals;
|
|
34
38
|
}
|
|
39
|
+
__name(getAssetDecimals, "getAssetDecimals");
|
|
35
40
|
|
|
36
|
-
export { ASSET_DECIMALS, AssetId, L2_ASSET_DECIMALS, RouteType, getAssetDecimals };
|
|
41
|
+
export { ASSET_DECIMALS, AssetId, L2_ASSET_DECIMALS, MIN_LIGHTER_CCTP_DEPOSIT_USDC, MIN_LIGHTER_FAST_WITHDRAW_USDC, RouteType, getAssetDecimals };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { parseUnits } from 'viem';
|
|
2
|
+
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
5
|
+
const USDC_DECIMALS = 6;
|
|
6
|
+
const USDC_AMOUNT_PATTERN = /^\d+(?:\.\d{1,6})?$/;
|
|
7
|
+
const INVALID_USDC_AMOUNT_MESSAGE = "USDC amount must be a positive decimal with at most 6 fractional digits";
|
|
8
|
+
function parseUsdcAmount(amount) {
|
|
9
|
+
if (!USDC_AMOUNT_PATTERN.test(amount)) {
|
|
10
|
+
throw new Error(INVALID_USDC_AMOUNT_MESSAGE);
|
|
11
|
+
}
|
|
12
|
+
const units = parseUnits(amount, USDC_DECIMALS);
|
|
13
|
+
if (units <= 0n || units > BigInt(Number.MAX_SAFE_INTEGER)) {
|
|
14
|
+
throw new Error(INVALID_USDC_AMOUNT_MESSAGE);
|
|
15
|
+
}
|
|
16
|
+
return Number(units);
|
|
17
|
+
}
|
|
18
|
+
__name(parseUsdcAmount, "parseUsdcAmount");
|
|
19
|
+
|
|
20
|
+
export { parseUsdcAmount };
|
package/dist/index.d.ts
CHANGED
|
@@ -254,9 +254,78 @@ type ApiKey = {
|
|
|
254
254
|
public_key: string;
|
|
255
255
|
transaction_time: number;
|
|
256
256
|
};
|
|
257
|
+
/** A source network Lighter currently credits through an intent address. */
|
|
258
|
+
type LighterDepositNetwork = {
|
|
259
|
+
name: string;
|
|
260
|
+
chainId: number;
|
|
261
|
+
explorer: string;
|
|
262
|
+
};
|
|
263
|
+
type LighterDepositStatus = 'failed' | 'pending' | 'completed' | 'claimable';
|
|
264
|
+
/** One deposit in Lighter's per-account history, credited or still bridging. */
|
|
265
|
+
type LighterDeposit = {
|
|
266
|
+
id: string;
|
|
267
|
+
assetId: number;
|
|
268
|
+
/** Human-readable amount Lighter credited; the intent record never carries this. */
|
|
269
|
+
amount: string;
|
|
270
|
+
/** Unix seconds since epoch, matching Lighter's deposit-history wire format. */
|
|
271
|
+
timestamp: number;
|
|
272
|
+
status: LighterDepositStatus;
|
|
273
|
+
l1TxHash: string;
|
|
274
|
+
};
|
|
257
275
|
|
|
258
276
|
type WalletClientWithAccount = WalletClient<Transport, Chain | undefined, Account>;
|
|
259
277
|
|
|
278
|
+
/** Native USDC contracts and transfer operations for Lighter's CCTP source chains. */
|
|
279
|
+
|
|
280
|
+
/** Circle's native USDC token on every source chain supported by this build. */
|
|
281
|
+
declare const LIGHTER_CCTP_USDC_ADDRESSES: Record<number, `0x${string}`>;
|
|
282
|
+
/** USDC carries six decimals on every supported source chain. */
|
|
283
|
+
declare const LIGHTER_CCTP_USDC_DECIMALS = 6;
|
|
284
|
+
/** The ERC-20 calls used to read and transfer native USDC. */
|
|
285
|
+
declare const usdcAbi: readonly [{
|
|
286
|
+
readonly inputs: readonly [{
|
|
287
|
+
readonly internalType: "address";
|
|
288
|
+
readonly name: "to";
|
|
289
|
+
readonly type: "address";
|
|
290
|
+
}, {
|
|
291
|
+
readonly internalType: "uint256";
|
|
292
|
+
readonly name: "amount";
|
|
293
|
+
readonly type: "uint256";
|
|
294
|
+
}];
|
|
295
|
+
readonly name: "transfer";
|
|
296
|
+
readonly outputs: readonly [{
|
|
297
|
+
readonly internalType: "bool";
|
|
298
|
+
readonly name: "";
|
|
299
|
+
readonly type: "bool";
|
|
300
|
+
}];
|
|
301
|
+
readonly stateMutability: "nonpayable";
|
|
302
|
+
readonly type: "function";
|
|
303
|
+
}, {
|
|
304
|
+
readonly inputs: readonly [{
|
|
305
|
+
readonly internalType: "address";
|
|
306
|
+
readonly name: "account";
|
|
307
|
+
readonly type: "address";
|
|
308
|
+
}];
|
|
309
|
+
readonly name: "balanceOf";
|
|
310
|
+
readonly outputs: readonly [{
|
|
311
|
+
readonly internalType: "uint256";
|
|
312
|
+
readonly name: "";
|
|
313
|
+
readonly type: "uint256";
|
|
314
|
+
}];
|
|
315
|
+
readonly stateMutability: "view";
|
|
316
|
+
readonly type: "function";
|
|
317
|
+
}];
|
|
318
|
+
/** Names native USDC for a source chain this SDK can transfer from safely. */
|
|
319
|
+
declare function getLighterCctpUsdcAddress(chainId: number): `0x${string}` | undefined;
|
|
320
|
+
|
|
321
|
+
/** Shares one live Lighter auth token per account without crossing rotated credentials. */
|
|
322
|
+
|
|
323
|
+
type LighterAuthCredentials = {
|
|
324
|
+
accountIndex: number;
|
|
325
|
+
apiKeyIndex: number;
|
|
326
|
+
apiPrivateKey: string;
|
|
327
|
+
};
|
|
328
|
+
|
|
260
329
|
declare const AssetId: {
|
|
261
330
|
readonly ETH: 1;
|
|
262
331
|
readonly LIT: 2;
|
|
@@ -274,6 +343,8 @@ declare const RouteType: {
|
|
|
274
343
|
readonly SPOT: 1;
|
|
275
344
|
};
|
|
276
345
|
type RouteType = (typeof RouteType)[keyof typeof RouteType];
|
|
346
|
+
declare const MIN_LIGHTER_CCTP_DEPOSIT_USDC = "5";
|
|
347
|
+
declare const MIN_LIGHTER_FAST_WITHDRAW_USDC = "4";
|
|
277
348
|
/** Lighter L2/base-amount precision (`assetDetails.decimals`). */
|
|
278
349
|
declare const L2_ASSET_DECIMALS: Record<number, number>;
|
|
279
350
|
/**
|
|
@@ -298,6 +369,103 @@ type DepositParams = {
|
|
|
298
369
|
/** Optional cached `assetDetails.l1_decimals`; the helper fetches assetDetails when omitted. */
|
|
299
370
|
l1Decimals?: number;
|
|
300
371
|
};
|
|
372
|
+
type CctpDepositIntentParams = {
|
|
373
|
+
/** A `chainId` from `listDepositNetworks()`; Lighter adds networks without a release. */
|
|
374
|
+
chainId: number;
|
|
375
|
+
/** The L1 owner whose main Lighter account receives funds, not necessarily the sender. */
|
|
376
|
+
ownerAddress: `0x${string}`;
|
|
377
|
+
};
|
|
378
|
+
type CctpDepositIntentResult = {
|
|
379
|
+
/** Send at least `MIN_LIGHTER_CCTP_DEPOSIT_USDC` on the selected chain to this address. */
|
|
380
|
+
intentAddress: `0x${string}`;
|
|
381
|
+
/** Local deadline before Lighter's documented ten-minute cancellation boundary. */
|
|
382
|
+
expiresAt: number;
|
|
383
|
+
};
|
|
384
|
+
/**
|
|
385
|
+
* A step in a deposit's life after its transfer is submitted.
|
|
386
|
+
*
|
|
387
|
+
* `credited` carries the history entry, whose `amount` is the figure Lighter actually
|
|
388
|
+
* booked — the only place that figure appears. `registered` is the terminal state of a
|
|
389
|
+
* first deposit, which carries the account indexes instead of a history entry. `untracked`
|
|
390
|
+
* ends a transfer this caller cannot follow, and `unsettled` ends one whose watch window
|
|
391
|
+
* closed first, so nobody waits for an outcome that never arrives.
|
|
392
|
+
*/
|
|
393
|
+
type CctpDepositProgress = {
|
|
394
|
+
state: 'confirming';
|
|
395
|
+
txHash: string;
|
|
396
|
+
} | {
|
|
397
|
+
state: 'bridging';
|
|
398
|
+
txHash: string;
|
|
399
|
+
} | {
|
|
400
|
+
state: 'credited';
|
|
401
|
+
txHash: string;
|
|
402
|
+
deposit: LighterDeposit;
|
|
403
|
+
} | {
|
|
404
|
+
state: 'failed';
|
|
405
|
+
txHash: string;
|
|
406
|
+
deposit: LighterDeposit;
|
|
407
|
+
} | {
|
|
408
|
+
state: 'action-required';
|
|
409
|
+
txHash: string;
|
|
410
|
+
deposit: LighterDeposit;
|
|
411
|
+
} | {
|
|
412
|
+
state: 'registered';
|
|
413
|
+
txHash: string;
|
|
414
|
+
mainAccountIndex: number;
|
|
415
|
+
subAccountIndexes: number[];
|
|
416
|
+
} | {
|
|
417
|
+
state: 'untracked';
|
|
418
|
+
txHash: string;
|
|
419
|
+
} | {
|
|
420
|
+
state: 'unsettled';
|
|
421
|
+
txHash: string;
|
|
422
|
+
};
|
|
423
|
+
/** Wallet transport a deposit borrows from its caller, keeping this SDK free of any wallet library. */
|
|
424
|
+
type CctpDepositWalletAdapter = {
|
|
425
|
+
readUsdcBalance: (chainId: number, ownerAddress: `0x${string}`) => Promise<bigint>;
|
|
426
|
+
retrieveWallet: (chainId: number) => Promise<WalletClientWithAccount>;
|
|
427
|
+
confirmTransaction: (chainId: number, txHash: string) => Promise<void>;
|
|
428
|
+
};
|
|
429
|
+
/** Credentials that let a deposit watch read the credited main account's deposit history. */
|
|
430
|
+
type CctpDepositHistorySettlement = {
|
|
431
|
+
follow: 'deposit-history';
|
|
432
|
+
selectedAccountIndex: number;
|
|
433
|
+
retrieveCredentials: () => Promise<Pick<LighterAuthCredentials, 'apiKeyIndex' | 'apiPrivateKey'>>;
|
|
434
|
+
};
|
|
435
|
+
/** Marks the deposit that creates the account, leaving registration as the only readable outcome. */
|
|
436
|
+
type CctpDepositRegistrationSettlement = {
|
|
437
|
+
follow: 'account-registration';
|
|
438
|
+
};
|
|
439
|
+
/**
|
|
440
|
+
* How a submitted deposit is followed to its Lighter outcome.
|
|
441
|
+
*
|
|
442
|
+
* A first deposit cannot supply credentials — it is the deposit that creates the account — so
|
|
443
|
+
* it re-runs the onboarding read instead of the authenticated deposit history.
|
|
444
|
+
*/
|
|
445
|
+
type CctpDepositSettlement = CctpDepositHistorySettlement | CctpDepositRegistrationSettlement;
|
|
446
|
+
type CctpDepositParams = {
|
|
447
|
+
/** The L1 wallet whose main Lighter account receives the deposit. */
|
|
448
|
+
ownerAddress: `0x${string}`;
|
|
449
|
+
/** The browser wallet allowed to use the direct-transfer path. */
|
|
450
|
+
connectedAddress: `0x${string}` | undefined;
|
|
451
|
+
/** A `chainId` from `listDepositNetworks()`; the connected wallet must already be on it. */
|
|
452
|
+
chainId: number;
|
|
453
|
+
/** Positive human-readable USDC amount with at most six fractional digits. */
|
|
454
|
+
amount: string;
|
|
455
|
+
/** Supplies wallet transport operations without coupling the SDK to Wagmi. */
|
|
456
|
+
wallet: CctpDepositWalletAdapter;
|
|
457
|
+
/** Receives source-confirmation and Lighter-settlement state changes. */
|
|
458
|
+
onProgress: (progress: CctpDepositProgress) => void;
|
|
459
|
+
/** Stops in-memory settlement polling when the owning view changes. */
|
|
460
|
+
signal?: AbortSignal;
|
|
461
|
+
/** Follows deposit history for a funded account, or account registration for a first deposit. */
|
|
462
|
+
settlement?: CctpDepositSettlement;
|
|
463
|
+
};
|
|
464
|
+
type CctpDepositResult = {
|
|
465
|
+
txHash: string;
|
|
466
|
+
/** The intent address the transfer credits, so a caller can link to what it funded. */
|
|
467
|
+
intentAddress: `0x${string}`;
|
|
468
|
+
};
|
|
301
469
|
type WithdrawParams = {
|
|
302
470
|
accountIndex: number;
|
|
303
471
|
assetId: number;
|
|
@@ -306,6 +474,14 @@ type WithdrawParams = {
|
|
|
306
474
|
/** Optional cached `assetDetails.decimals`; the helper fetches assetDetails when omitted. */
|
|
307
475
|
l2Decimals?: number;
|
|
308
476
|
};
|
|
477
|
+
type FastWithdrawParams = {
|
|
478
|
+
accountIndex: number;
|
|
479
|
+
toAddress: `0x${string}`;
|
|
480
|
+
/** Positive human-readable USDC amount with at most six fractional digits. */
|
|
481
|
+
amount: string;
|
|
482
|
+
apiKeyIndex: number;
|
|
483
|
+
apiPrivateKey: string;
|
|
484
|
+
};
|
|
309
485
|
type ConnectWalletResult = {
|
|
310
486
|
txHash: string;
|
|
311
487
|
apiKeyIndex: number;
|
|
@@ -331,12 +507,35 @@ type DepositResult = {
|
|
|
331
507
|
type WithdrawResult = {
|
|
332
508
|
txHash: string;
|
|
333
509
|
};
|
|
510
|
+
type FastWithdrawResult = {
|
|
511
|
+
txHash: string;
|
|
512
|
+
/** Integer USDC units Lighter charged on top of the amount. */
|
|
513
|
+
fee: number;
|
|
514
|
+
};
|
|
515
|
+
/**
|
|
516
|
+
* The next action an L1 address must take before it can hold a Lighter trade account.
|
|
517
|
+
*
|
|
518
|
+
* Lighter registers an account only when its first deposit lands, so a brand-new address
|
|
519
|
+
* reports `deposit-required` until the transfer settles. Poll this to learn when it has.
|
|
520
|
+
*/
|
|
521
|
+
type LighterOnboardingStatus = {
|
|
522
|
+
step: 'deposit-required';
|
|
523
|
+
} | {
|
|
524
|
+
step: 'account-ready';
|
|
525
|
+
mainAccountIndex: number;
|
|
526
|
+
subAccountIndexes: number[];
|
|
527
|
+
};
|
|
334
528
|
interface LighterHelper {
|
|
529
|
+
checkOnboarding(l1Address: string): Promise<LighterOnboardingStatus>;
|
|
335
530
|
lookupAccount(l1Address: string): Promise<LighterLookupResult>;
|
|
336
531
|
checkIntegratorApproval(accountIndex: number, integratorAccountIndex: number, requirements?: IntegratorApprovalRequirements): Promise<boolean>;
|
|
337
532
|
connectWallet(walletClient: WalletClientWithAccount, params: ConnectWalletParams): Promise<ConnectWalletResult>;
|
|
338
533
|
approveIntegrator(walletClient: WalletClientWithAccount, params: ApproveIntegratorParams): Promise<ApproveIntegratorResult>;
|
|
534
|
+
listDepositNetworks(): Promise<LighterDepositNetwork[]>;
|
|
535
|
+
createExternalCctpDepositIntent(params: CctpDepositIntentParams): Promise<CctpDepositIntentResult>;
|
|
536
|
+
depositUsdcViaCctp(params: CctpDepositParams): Promise<CctpDepositResult>;
|
|
339
537
|
deposit(walletClient: WalletClientWithAccount, params: DepositParams): Promise<DepositResult>;
|
|
538
|
+
fastWithdraw(walletClient: WalletClientWithAccount, params: FastWithdrawParams): Promise<FastWithdrawResult>;
|
|
340
539
|
withdraw(walletClient: WalletClientWithAccount, params: WithdrawParams): Promise<WithdrawResult>;
|
|
341
540
|
}
|
|
342
541
|
type LighterLookupResult = {
|
|
@@ -564,6 +763,8 @@ declare class LighterAccountSyncer extends BaseAccountSyncer<RawFill$1> {
|
|
|
564
763
|
private readonly apiKeyIndex;
|
|
565
764
|
private readonly apiPrivateKey;
|
|
566
765
|
constructor(config: AccountSyncerConfig);
|
|
766
|
+
/** Returns this account's shared Lighter auth token. */
|
|
767
|
+
private retrieveAuthToken;
|
|
567
768
|
protected listExternalPositions({ instruments, }: ListExternalPositionsParams): Promise<HttpTypes.ExternalPosition[]>;
|
|
568
769
|
protected listExternalFills({ since, instruments, }: ListExternalFillsParams): Promise<HttpTypes.UnknownExternalFill[]>;
|
|
569
770
|
protected listExternalFunding({ since, instruments, }: ListExternalFundingParams): Promise<HttpTypes.FundingPaymentEntry[]>;
|
|
@@ -1024,4 +1225,4 @@ declare class ExchangesSDK {
|
|
|
1024
1225
|
private fetchCredentials;
|
|
1025
1226
|
}
|
|
1026
1227
|
|
|
1027
|
-
export { ACCOUNT_TYPE_LABELS, ASSET_DECIMALS, type AccountBalance, type AccountHealthStatus, type AccountPosition, type AccountSnapshot, type AccountStatus, type AccountSyncer, type AccountSyncerConfig, type AccountTracker, type AccountTrackerConfig, type AccountType, type AccountWarningReason, type ApiKey, type ApproveIntegratorParams, type ApproveIntegratorResult, type AssetBalance, AssetId, type AssetSnapshotMap, type BalanceCallback, BaseAccountSyncer, BaseAccountTracker, BaseWs, BinanceAccountSyncer, BinanceAccountTracker, type BinanceAccountTrackerConfig, BinanceAccountType, BinanceExchangeWs, BinanceUserDataWs, type BinanceUserDataWsConfig, BinanceWsApi, type BinanceWsApiConfig, BybitAccountSyncer, BybitAccountTracker, type BybitAccountTrackerConfig, BybitAccountType, BybitExchangeWs, BybitWs, type BybitWsConfig, type CheckApiWalletParams, type ConnectOptions, type ConnectWalletParams, type ConnectWalletResult, type CreateAccountTrackerConfig, type CreateExchangeWsConfig, type DepositParams, type DepositResult, type ExchangeConnection, type ExchangeHelperExchange, type ExchangeHelperMap, type ExchangeState, ExchangeWs, type ExchangeWsByConnector, ExchangesSDK, type ExchangesSDKConfig, HyperliquidAccountSyncer, HyperliquidAccountTracker, type HyperliquidAccountTrackerConfig, HyperliquidAccountType, HyperliquidExchangeWs, type HyperliquidHelper, HyperliquidWs, type IntegratorApprovalRequirements, L2_ASSET_DECIMALS, LighterAccountSyncer, LighterAccountTracker, type LighterAccountTrackerConfig, LighterAccountType, LighterExchangeWs, type LighterHelper, type LighterLookupResult, LighterWs, type ListExternalFillsParams, type ListExternalFundingParams, type ListExternalPositionsParams, MAX_API_KEY_INDEX, MIN_USER_API_KEY_INDEX, type MarginMode, type MessageListener, OkxAccountSyncer, OkxAccountTracker, type OkxAccountTrackerConfig, OkxAccountType, OkxExchangeWs, OkxWs, type OkxWsConfig, type OpenListener, type PositionsCallback, RouteType, type StateUpdate, type SupportedCredentials, type TrackedAssetCallback, type TrackedAssetInfo, type WalletClientWithAccount, type WithdrawParams, type WithdrawResult, type WsMessage, createAccountSyncer, createAccountTracker, createExchangeWs, createHyperliquidHelper, createLighterHelper, findAvailableApiKeyIndex, getAssetDecimals };
|
|
1228
|
+
export { ACCOUNT_TYPE_LABELS, ASSET_DECIMALS, type AccountBalance, type AccountHealthStatus, type AccountPosition, type AccountSnapshot, type AccountStatus, type AccountSyncer, type AccountSyncerConfig, type AccountTracker, type AccountTrackerConfig, type AccountType, type AccountWarningReason, type ApiKey, type ApproveIntegratorParams, type ApproveIntegratorResult, type AssetBalance, AssetId, type AssetSnapshotMap, type BalanceCallback, BaseAccountSyncer, BaseAccountTracker, BaseWs, BinanceAccountSyncer, BinanceAccountTracker, type BinanceAccountTrackerConfig, BinanceAccountType, BinanceExchangeWs, BinanceUserDataWs, type BinanceUserDataWsConfig, BinanceWsApi, type BinanceWsApiConfig, BybitAccountSyncer, BybitAccountTracker, type BybitAccountTrackerConfig, BybitAccountType, BybitExchangeWs, BybitWs, type BybitWsConfig, type CctpDepositHistorySettlement, type CctpDepositIntentParams, type CctpDepositIntentResult, type CctpDepositParams, type CctpDepositProgress, type CctpDepositRegistrationSettlement, type CctpDepositResult, type CctpDepositSettlement, type CctpDepositWalletAdapter, type CheckApiWalletParams, type ConnectOptions, type ConnectWalletParams, type ConnectWalletResult, type CreateAccountTrackerConfig, type CreateExchangeWsConfig, type DepositParams, type DepositResult, type ExchangeConnection, type ExchangeHelperExchange, type ExchangeHelperMap, type ExchangeState, ExchangeWs, type ExchangeWsByConnector, ExchangesSDK, type ExchangesSDKConfig, type FastWithdrawParams, type FastWithdrawResult, HyperliquidAccountSyncer, HyperliquidAccountTracker, type HyperliquidAccountTrackerConfig, HyperliquidAccountType, HyperliquidExchangeWs, type HyperliquidHelper, HyperliquidWs, type IntegratorApprovalRequirements, L2_ASSET_DECIMALS, LIGHTER_CCTP_USDC_ADDRESSES, LIGHTER_CCTP_USDC_DECIMALS, LighterAccountSyncer, LighterAccountTracker, type LighterAccountTrackerConfig, LighterAccountType, type LighterDeposit, type LighterDepositNetwork, LighterExchangeWs, type LighterHelper, type LighterLookupResult, type LighterOnboardingStatus, LighterWs, type ListExternalFillsParams, type ListExternalFundingParams, type ListExternalPositionsParams, MAX_API_KEY_INDEX, MIN_LIGHTER_CCTP_DEPOSIT_USDC, MIN_LIGHTER_FAST_WITHDRAW_USDC, MIN_USER_API_KEY_INDEX, type MarginMode, type MessageListener, OkxAccountSyncer, OkxAccountTracker, type OkxAccountTrackerConfig, OkxAccountType, OkxExchangeWs, OkxWs, type OkxWsConfig, type OpenListener, type PositionsCallback, RouteType, type StateUpdate, type SupportedCredentials, type TrackedAssetCallback, type TrackedAssetInfo, type WalletClientWithAccount, type WithdrawParams, type WithdrawResult, type WsMessage, createAccountSyncer, createAccountTracker, createExchangeWs, createHyperliquidHelper, createLighterHelper, findAvailableApiKeyIndex, getAssetDecimals, getLighterCctpUsdcAddress, usdcAbi };
|
package/dist/sdk.js
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import { configureProxy } from '@pear-protocol/utils';
|
|
2
|
-
import './helper';
|
|
3
2
|
import { createExchangeHelper } from './helper/factory';
|
|
4
3
|
import { checkAccountStatus } from './status';
|
|
5
4
|
import { createAccountSyncer } from './syncer';
|
|
6
5
|
import { createAccountTracker } from './tracker';
|
|
7
6
|
|
|
7
|
+
var __defProp = Object.defineProperty;
|
|
8
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
8
9
|
class ExchangesSDK {
|
|
10
|
+
static {
|
|
11
|
+
__name(this, "ExchangesSDK");
|
|
12
|
+
}
|
|
9
13
|
sdk;
|
|
10
14
|
demo;
|
|
11
15
|
constructor(config) {
|
|
@@ -17,10 +21,10 @@ class ExchangesSDK {
|
|
|
17
21
|
return this.fetchCredentials(tradeAccountId);
|
|
18
22
|
}
|
|
19
23
|
/**
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
+
* Options come in per call rather than at construction: the approval targets live in the
|
|
25
|
+
* backend's fee-recipient source and can change, so the caller fetches (and caches) them and
|
|
26
|
+
* passes the current values with every check.
|
|
27
|
+
*/
|
|
24
28
|
async status(connection, options) {
|
|
25
29
|
return checkAccountStatus(connection.connector, {
|
|
26
30
|
sdk: this.sdk,
|
|
@@ -45,9 +49,16 @@ class ExchangesSDK {
|
|
|
45
49
|
createHelper(exchange) {
|
|
46
50
|
switch (exchange) {
|
|
47
51
|
case "hyperliquid":
|
|
48
|
-
return createExchangeHelper({
|
|
52
|
+
return createExchangeHelper({
|
|
53
|
+
exchange: "hyperliquid",
|
|
54
|
+
demo: this.demo
|
|
55
|
+
});
|
|
49
56
|
case "lighter":
|
|
50
|
-
return createExchangeHelper({
|
|
57
|
+
return createExchangeHelper({
|
|
58
|
+
exchange: "lighter",
|
|
59
|
+
sdk: this.sdk,
|
|
60
|
+
demo: this.demo
|
|
61
|
+
});
|
|
51
62
|
}
|
|
52
63
|
}
|
|
53
64
|
createSyncer(connection) {
|
package/dist/status/base.js
CHANGED
|
@@ -1,10 +1,23 @@
|
|
|
1
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
const ACTIVE_STATUS = {
|
|
4
|
+
status: "active",
|
|
5
|
+
reasons: []
|
|
6
|
+
};
|
|
2
7
|
function activeStatus() {
|
|
3
|
-
return {
|
|
8
|
+
return {
|
|
9
|
+
...ACTIVE_STATUS,
|
|
10
|
+
reasons: []
|
|
11
|
+
};
|
|
4
12
|
}
|
|
13
|
+
__name(activeStatus, "activeStatus");
|
|
5
14
|
function warningStatus(reasons) {
|
|
6
15
|
if (reasons.length === 0) return activeStatus();
|
|
7
|
-
return {
|
|
16
|
+
return {
|
|
17
|
+
status: "warning",
|
|
18
|
+
reasons
|
|
19
|
+
};
|
|
8
20
|
}
|
|
21
|
+
__name(warningStatus, "warningStatus");
|
|
9
22
|
|
|
10
23
|
export { activeStatus, warningStatus };
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { fetchAccountStatus } from '../../client/binance/rest';
|
|
2
2
|
import { warningStatus } from '../base';
|
|
3
3
|
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
4
6
|
async function checkBinanceAccountStatus(config) {
|
|
5
7
|
const reasons = [];
|
|
6
8
|
try {
|
|
@@ -10,5 +12,6 @@ async function checkBinanceAccountStatus(config) {
|
|
|
10
12
|
}
|
|
11
13
|
return warningStatus(reasons);
|
|
12
14
|
}
|
|
15
|
+
__name(checkBinanceAccountStatus, "checkBinanceAccountStatus");
|
|
13
16
|
|
|
14
17
|
export { checkBinanceAccountStatus };
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { fetchAccountInfo } from '../../client/bybit/rest';
|
|
2
2
|
import { warningStatus } from '../base';
|
|
3
3
|
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
4
6
|
async function checkBybitAccountStatus(config) {
|
|
5
7
|
const reasons = [];
|
|
6
8
|
try {
|
|
@@ -10,5 +12,6 @@ async function checkBybitAccountStatus(config) {
|
|
|
10
12
|
}
|
|
11
13
|
return warningStatus(reasons);
|
|
12
14
|
}
|
|
15
|
+
__name(checkBybitAccountStatus, "checkBybitAccountStatus");
|
|
13
16
|
|
|
14
17
|
export { checkBybitAccountStatus };
|
package/dist/status/factory.js
CHANGED
|
@@ -4,6 +4,8 @@ import { checkHyperliquidAccountStatus } from './hyperliquid/status';
|
|
|
4
4
|
import { checkLighterAccountStatus } from './lighter/status';
|
|
5
5
|
import { checkOkxAccountStatus } from './okx/status';
|
|
6
6
|
|
|
7
|
+
var __defProp = Object.defineProperty;
|
|
8
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
7
9
|
function checkAccountStatus(exchange, config) {
|
|
8
10
|
switch (exchange) {
|
|
9
11
|
case "binance":
|
|
@@ -22,5 +24,6 @@ function checkAccountStatus(exchange, config) {
|
|
|
22
24
|
}
|
|
23
25
|
}
|
|
24
26
|
}
|
|
27
|
+
__name(checkAccountStatus, "checkAccountStatus");
|
|
25
28
|
|
|
26
29
|
export { checkAccountStatus };
|