@pear-protocol/exchanges-sdk 0.1.11 → 0.2.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/helper/lighter/helper.js +25 -0
- package/dist/index.d.ts +9 -1
- package/package.json +4 -4
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
import { parseUnits, parseEther } from 'viem';
|
|
1
2
|
import { fetchApiKeys, fetchAccount, fetchAccountsByL1Address } from '../../client/lighter/rest';
|
|
3
|
+
import { writeWithdraw, writeDeposit } from './ethereum';
|
|
4
|
+
import { getAssetDecimals } from './types';
|
|
2
5
|
|
|
3
6
|
function createLighterHelper(sdk) {
|
|
4
7
|
return {
|
|
@@ -60,6 +63,28 @@ function createLighterHelper(sdk) {
|
|
|
60
63
|
apiKeyIndex: params.apiKeyIndex
|
|
61
64
|
});
|
|
62
65
|
return { txHash };
|
|
66
|
+
},
|
|
67
|
+
async deposit(walletClient, params) {
|
|
68
|
+
const txHash = await writeDeposit(walletClient, {
|
|
69
|
+
to: params.to,
|
|
70
|
+
assetIndex: params.assetId,
|
|
71
|
+
routeType: params.routeType,
|
|
72
|
+
// `amount` is a human string in the asset's own units; scale to base units.
|
|
73
|
+
amount: parseUnits(params.amount, getAssetDecimals(params.assetId)),
|
|
74
|
+
// Native-ETH deposits are payable; `nativeValue` is the ETH sent as
|
|
75
|
+
// msg.value (18-decimal wei), separate from the accounting `amount`.
|
|
76
|
+
value: params.nativeValue ? parseEther(params.nativeValue) : void 0
|
|
77
|
+
});
|
|
78
|
+
return { txHash };
|
|
79
|
+
},
|
|
80
|
+
async withdraw(walletClient, params) {
|
|
81
|
+
const txHash = await writeWithdraw(walletClient, {
|
|
82
|
+
accountIndex: params.accountIndex,
|
|
83
|
+
assetIndex: params.assetId,
|
|
84
|
+
routeType: params.routeType,
|
|
85
|
+
baseAmount: parseUnits(params.amount, getAssetDecimals(params.assetId))
|
|
86
|
+
});
|
|
87
|
+
return { txHash };
|
|
63
88
|
}
|
|
64
89
|
};
|
|
65
90
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -275,11 +275,19 @@ type ApproveIntegratorParams = {
|
|
|
275
275
|
type ApproveIntegratorResult = {
|
|
276
276
|
txHash: string;
|
|
277
277
|
};
|
|
278
|
+
type DepositResult = {
|
|
279
|
+
txHash: string;
|
|
280
|
+
};
|
|
281
|
+
type WithdrawResult = {
|
|
282
|
+
txHash: string;
|
|
283
|
+
};
|
|
278
284
|
interface LighterHelper {
|
|
279
285
|
lookupAccount(l1Address: string): Promise<LighterLookupResult>;
|
|
280
286
|
checkIntegratorApproval(accountIndex: number, integratorAccountIndex: number): Promise<boolean>;
|
|
281
287
|
connectWallet(walletClient: WalletClientWithAccount, params: ConnectWalletParams): Promise<ConnectWalletResult>;
|
|
282
288
|
approveIntegrator(walletClient: WalletClientWithAccount, params: ApproveIntegratorParams): Promise<ApproveIntegratorResult>;
|
|
289
|
+
deposit(walletClient: WalletClientWithAccount, params: DepositParams): Promise<DepositResult>;
|
|
290
|
+
withdraw(walletClient: WalletClientWithAccount, params: WithdrawParams): Promise<WithdrawResult>;
|
|
283
291
|
}
|
|
284
292
|
type LighterLookupResult = {
|
|
285
293
|
mainAccountIndex: number;
|
|
@@ -814,4 +822,4 @@ declare class ExchangesSDK {
|
|
|
814
822
|
private fetchCredentials;
|
|
815
823
|
}
|
|
816
824
|
|
|
817
|
-
export { ACCOUNT_TYPE_LABELS, ASSET_DECIMALS, type AccountBalance, type AccountHealthStatus, type AccountPosition, type AccountStatus, type AccountSyncer, type AccountSyncerConfig, type AccountTracker, type AccountTrackerConfig, type AccountType, type AccountWarningReason, type ApiKey, type ApproveIntegratorParams, type ApproveIntegratorResult, type AssetBalance, AssetId, 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 ExchangeConnection, type ExchangeHelperExchange, type ExchangeHelperMap, type ExchangeState, ExchangeWs, type ExchangeWsByConnector, ExchangesSDK, type ExchangesSDKConfig, HyperliquidAccountSyncer, HyperliquidAccountTracker, type HyperliquidAccountTrackerConfig, HyperliquidAccountType, HyperliquidExchangeWs, type HyperliquidHelper, HyperliquidWs, LighterAccountSyncer, LighterAccountTracker, type LighterAccountTrackerConfig, LighterAccountType, LighterExchangeWs, type LighterHelper, type LighterLookupResult, LighterWs, type ListExternalFillsParams, 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 WsMessage, createAccountSyncer, createAccountTracker, createExchangeWs, createHyperliquidHelper, createLighterHelper, getAssetDecimals };
|
|
825
|
+
export { ACCOUNT_TYPE_LABELS, ASSET_DECIMALS, type AccountBalance, type AccountHealthStatus, type AccountPosition, type AccountStatus, type AccountSyncer, type AccountSyncerConfig, type AccountTracker, type AccountTrackerConfig, type AccountType, type AccountWarningReason, type ApiKey, type ApproveIntegratorParams, type ApproveIntegratorResult, type AssetBalance, AssetId, 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, LighterAccountSyncer, LighterAccountTracker, type LighterAccountTrackerConfig, LighterAccountType, LighterExchangeWs, type LighterHelper, type LighterLookupResult, LighterWs, type ListExternalFillsParams, 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, getAssetDecimals };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pear-protocol/exchanges-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Pear Protocol Exchanges SDK",
|
|
5
5
|
"private": false,
|
|
6
6
|
"type": "module",
|
|
@@ -26,9 +26,9 @@
|
|
|
26
26
|
"typecheck": "tsc --noEmit"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@pear-protocol/core-sdk": "^
|
|
30
|
-
"@pear-protocol/types": "^
|
|
31
|
-
"@pear-protocol/utils": "^0.0.
|
|
29
|
+
"@pear-protocol/core-sdk": "^1.0.0",
|
|
30
|
+
"@pear-protocol/types": "^1.0.0",
|
|
31
|
+
"@pear-protocol/utils": "^0.0.23",
|
|
32
32
|
"bignumber.js": "^11.1.1",
|
|
33
33
|
"partysocket": "^1.0.3",
|
|
34
34
|
"viem": "^2.48.8"
|