@andy-liquid-labs/lighter-ts-sdk 1.0.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.
Files changed (85) hide show
  1. package/README.md +381 -0
  2. package/dist/index.d.mts +3686 -0
  3. package/dist/index.d.ts +3686 -0
  4. package/dist/index.js +6168 -0
  5. package/dist/index.js.map +1 -0
  6. package/dist/index.mjs +5939 -0
  7. package/dist/index.mjs.map +1 -0
  8. package/package.json +57 -0
  9. package/src/api/exchange/change-account-tier.ts +38 -0
  10. package/src/api/exchange/fastwithdraw.ts +38 -0
  11. package/src/api/exchange/index.ts +7 -0
  12. package/src/api/exchange/notification-ack.ts +36 -0
  13. package/src/api/exchange/send-tx-batch.ts +53 -0
  14. package/src/api/exchange/send-tx.ts +105 -0
  15. package/src/api/exchange/tokens-create.ts +50 -0
  16. package/src/api/exchange/tokens-revoke.ts +38 -0
  17. package/src/api/index.ts +3 -0
  18. package/src/api/info/account-by-l1-address.ts +23 -0
  19. package/src/api/info/account.ts +80 -0
  20. package/src/api/info/announcement.ts +24 -0
  21. package/src/api/info/api-keys.ts +32 -0
  22. package/src/api/info/asset-details.ts +42 -0
  23. package/src/api/info/candles.ts +31 -0
  24. package/src/api/info/exchange-stats.ts +16 -0
  25. package/src/api/info/fastbridge-info.ts +15 -0
  26. package/src/api/info/funding-rates.ts +22 -0
  27. package/src/api/info/fundings.ts +29 -0
  28. package/src/api/info/index.ts +20 -0
  29. package/src/api/info/next-nonce.ts +26 -0
  30. package/src/api/info/order-book-details.ts +125 -0
  31. package/src/api/info/order-books.ts +23 -0
  32. package/src/api/info/recent-trades.ts +24 -0
  33. package/src/api/info/root-info.ts +13 -0
  34. package/src/api/info/root-status.ts +13 -0
  35. package/src/api/info/tx-from-l1-hash.ts +20 -0
  36. package/src/api/info/tx.ts +45 -0
  37. package/src/api/info/txs.ts +19 -0
  38. package/src/api/info/withdrawal-delay.ts +13 -0
  39. package/src/api/info-private/account-active-orders.ts +31 -0
  40. package/src/api/info-private/account-inactive-orders.ts +83 -0
  41. package/src/api/info-private/account-limits.ts +35 -0
  42. package/src/api/info-private/account-metadata.ts +43 -0
  43. package/src/api/info-private/deposit-history.ts +49 -0
  44. package/src/api/info-private/export.ts +41 -0
  45. package/src/api/info-private/fastwithdraw-info.ts +35 -0
  46. package/src/api/info-private/index.ts +18 -0
  47. package/src/api/info-private/l1-metadata.ts +35 -0
  48. package/src/api/info-private/liquidations.ts +96 -0
  49. package/src/api/info-private/pnl.ts +52 -0
  50. package/src/api/info-private/position-funding.ts +54 -0
  51. package/src/api/info-private/public-pools-metadata.ts +46 -0
  52. package/src/api/info-private/referral-points.ts +43 -0
  53. package/src/api/info-private/tokens.ts +44 -0
  54. package/src/api/info-private/trades.ts +66 -0
  55. package/src/api/info-private/transfer-fee-info.ts +37 -0
  56. package/src/api/info-private/transfer-history.ts +54 -0
  57. package/src/api/info-private/withdraw-history.ts +49 -0
  58. package/src/client/clientManager.ts +121 -0
  59. package/src/client/exchange-client.ts +637 -0
  60. package/src/client/http/client.ts +137 -0
  61. package/src/client/http/index.ts +6 -0
  62. package/src/client/http/interface.ts +89 -0
  63. package/src/client/index.ts +11 -0
  64. package/src/client/info-client.ts +383 -0
  65. package/src/client/info-private-client.ts +444 -0
  66. package/src/client/txClient.ts +597 -0
  67. package/src/client/ws-client.ts +457 -0
  68. package/src/crypto/ecgfp5.ts +722 -0
  69. package/src/crypto/goldilocks.ts +136 -0
  70. package/src/crypto/gorand.ts +777 -0
  71. package/src/crypto/index.ts +6 -0
  72. package/src/crypto/poseidon2.ts +365 -0
  73. package/src/crypto/scalar.ts +375 -0
  74. package/src/index.ts +112 -0
  75. package/src/signer/index.ts +5 -0
  76. package/src/signer/keyManager.ts +132 -0
  77. package/src/types/bridge.ts +24 -0
  78. package/src/types/constants.ts +252 -0
  79. package/src/types/errors.ts +168 -0
  80. package/src/types/index.ts +12 -0
  81. package/src/types/requests.ts +197 -0
  82. package/src/types/txInfo.ts +1277 -0
  83. package/src/types/txInfoPools.ts +502 -0
  84. package/src/types/txInfoSerializer.ts +348 -0
  85. package/src/types/ws.ts +407 -0
@@ -0,0 +1,15 @@
1
+ import { AxiosInstance } from "axios";
2
+
3
+ export interface FastBridgeInfoResponse {
4
+ code: number;
5
+ message?: string;
6
+ fast_bridge_limit: string;
7
+ }
8
+
9
+ export async function getFastBridgeInfo(
10
+ client: AxiosInstance,
11
+ ): Promise<FastBridgeInfoResponse> {
12
+ return client
13
+ .get<FastBridgeInfoResponse>("/api/v1/fastbridge/info")
14
+ .then((response) => response.data);
15
+ }
@@ -0,0 +1,22 @@
1
+ import { AxiosInstance } from "axios";
2
+
3
+ export interface FundingRate {
4
+ market_id: number;
5
+ exchange: "binance" | "bybit" | "hyperliquid" | "lighter";
6
+ symbol: string;
7
+ rate: number;
8
+ }
9
+
10
+ export interface FundingRatesResponse {
11
+ code: number;
12
+ message?: string;
13
+ funding_rates: FundingRate[];
14
+ }
15
+
16
+ export async function getFundingRates(
17
+ client: AxiosInstance,
18
+ ): Promise<FundingRatesResponse> {
19
+ return client
20
+ .get<FundingRatesResponse>("/api/v1/funding-rates")
21
+ .then((response) => response.data);
22
+ }
@@ -0,0 +1,29 @@
1
+ import { AxiosInstance } from "axios";
2
+
3
+ export interface Funding {
4
+ timestamp: number;
5
+ market_id: number;
6
+ funding_id: number;
7
+ rate: string;
8
+ }
9
+
10
+ export interface FundingsRequest {
11
+ market_id: number;
12
+ resolution: string;
13
+ start_timestamp?: number;
14
+ end_timestamp?: number;
15
+ count_back?: number;
16
+ }
17
+
18
+ export interface FundingsResponse {
19
+ fundings: Funding[];
20
+ }
21
+
22
+ export async function getFundings(
23
+ client: AxiosInstance,
24
+ params: FundingsRequest,
25
+ ): Promise<FundingsResponse> {
26
+ return client
27
+ .get<FundingsResponse>("/api/v1/fundings", { params })
28
+ .then((response) => response.data);
29
+ }
@@ -0,0 +1,20 @@
1
+ export * from "./account";
2
+ export * from "./account-by-l1-address";
3
+ export * from "./announcement";
4
+ export * from "./api-keys";
5
+ export * from "./asset-details";
6
+ export * from "./candles";
7
+ export * from "./exchange-stats";
8
+ export * from "./fastbridge-info";
9
+ export * from "./funding-rates";
10
+ export * from "./fundings";
11
+ export * from "./next-nonce";
12
+ export * from "./order-book-details";
13
+ export * from "./order-books";
14
+ export * from "./recent-trades";
15
+ export * from "./root-info";
16
+ export * from "./root-status";
17
+ export * from "./tx";
18
+ export * from "./tx-from-l1-hash";
19
+ export * from "./txs";
20
+ export * from "./withdrawal-delay";
@@ -0,0 +1,26 @@
1
+ import { AxiosInstance } from "axios";
2
+
3
+ export interface NextNonceRequest {
4
+ account_index: number;
5
+ api_key_index: number;
6
+ }
7
+
8
+ export interface NextNonceResponse {
9
+ account_index: number;
10
+ api_key_index: number;
11
+ nonce: number;
12
+ }
13
+
14
+ export async function getNextNonce(
15
+ client: AxiosInstance,
16
+ params: NextNonceRequest,
17
+ ): Promise<NextNonceResponse> {
18
+ return client
19
+ .get<NextNonceResponse>("/api/v1/nextNonce", {
20
+ params: {
21
+ account_index: params.account_index,
22
+ api_key_index: params.api_key_index,
23
+ },
24
+ })
25
+ .then((response) => response.data);
26
+ }
@@ -0,0 +1,125 @@
1
+ import { AxiosInstance } from "axios";
2
+
3
+ export interface OrderBookDetailsRequest {
4
+ market_id?: number;
5
+ }
6
+
7
+ export interface OrderBookDetail {
8
+ symbol: string;
9
+ market_id: number;
10
+ market_type: string;
11
+ status: string;
12
+ taker_fee: string;
13
+ maker_fee: string;
14
+ liquidation_fee: string;
15
+ min_base_amount: string;
16
+ min_quote_amount: string;
17
+ order_quote_limit: string;
18
+ supported_size_decimals: number;
19
+ supported_price_decimals: number;
20
+ supported_quote_decimals: number;
21
+ size_decimals: number;
22
+ price_decimals: number;
23
+ quote_multiplier: number;
24
+ default_initial_margin_fraction: number;
25
+ min_initial_margin_fraction: number;
26
+ maintenance_margin_fraction: number;
27
+ closeout_margin_fraction: number;
28
+ last_trade_price: number;
29
+ daily_trades_count: number;
30
+ daily_base_token_volume: number;
31
+ daily_quote_token_volume: number;
32
+ daily_price_low: number;
33
+ daily_price_high: number;
34
+ daily_price_change: number;
35
+ open_interest: number;
36
+ daily_chart: any;
37
+ market_config: {
38
+ market_margin_mode: number;
39
+ insurance_fund_account_index: number;
40
+ };
41
+ }
42
+
43
+ export interface SpotOrderBookDetail {
44
+ symbol: string;
45
+ market_id: number;
46
+ market_type: string;
47
+ base_asset_id: string;
48
+ quote_asset_id: string;
49
+ status: string;
50
+ taker_fee: string;
51
+ maker_fee: string;
52
+ liquidation_fee: string;
53
+ min_base_amount: string;
54
+ min_quote_amount: string;
55
+ order_quote_limit: string;
56
+ supported_size_decimals: number;
57
+ supported_price_decimals: number;
58
+ supported_quote_decimals: number;
59
+ size_decimals: number;
60
+ price_decimals: number;
61
+ last_trade_price: number;
62
+ daily_trades_count: number;
63
+ daily_base_token_volume: number;
64
+ daily_quote_token_volume: number;
65
+ daily_price_low: number;
66
+ daily_price_high: number;
67
+ daily_price_change: number;
68
+ }
69
+
70
+ export interface OrderBookDetailsResponse {
71
+ code: number;
72
+ order_book_details: OrderBookDetail[];
73
+ spot_order_book_details: SpotOrderBookDetail[];
74
+ }
75
+
76
+ export async function getOrderBookDetails(
77
+ client: AxiosInstance,
78
+ params?: OrderBookDetailsRequest,
79
+ ): Promise<OrderBookDetailsResponse> {
80
+ return client
81
+ .get<OrderBookDetailsResponse>("/api/v1/orderBookDetails", {
82
+ params:
83
+ params?.market_id !== undefined
84
+ ? { market_id: params.market_id }
85
+ : undefined,
86
+ })
87
+ .then((response) => response.data);
88
+ }
89
+
90
+ export interface OrderBookOrdersRequest {
91
+ market_id: number;
92
+ limit?: number;
93
+ }
94
+
95
+ export interface OrderBookOrder {
96
+ order_index: number;
97
+ order_id: string;
98
+ owner_account_index: number;
99
+ initial_base_amount: string;
100
+ remaining_base_amount: string;
101
+ price: string;
102
+ order_expiry: number;
103
+ }
104
+
105
+ export interface OrderBookOrdersResponse {
106
+ code?: number;
107
+ total_asks?: number;
108
+ total_bids?: number;
109
+ bids?: OrderBookOrder[];
110
+ asks?: OrderBookOrder[];
111
+ }
112
+
113
+ export async function getOrderBookOrders(
114
+ client: AxiosInstance,
115
+ params: OrderBookOrdersRequest,
116
+ ): Promise<OrderBookOrdersResponse> {
117
+ return client
118
+ .get<OrderBookOrdersResponse>("/api/v1/orderBookOrders", {
119
+ params: {
120
+ market_id: params.market_id,
121
+ ...(params.limit !== undefined ? { limit: params.limit } : {}),
122
+ },
123
+ })
124
+ .then((response) => response.data);
125
+ }
@@ -0,0 +1,23 @@
1
+ import { AxiosInstance } from "axios";
2
+
3
+ export interface PriceLevel {
4
+ price: string;
5
+ size: string;
6
+ }
7
+
8
+ export interface OrderBook {
9
+ market_id: number;
10
+ bids: PriceLevel[];
11
+ asks: PriceLevel[];
12
+ last_update_id: string;
13
+ }
14
+
15
+ export type OrderBooksResponse = OrderBook[];
16
+
17
+ export async function getOrderBooks(
18
+ client: AxiosInstance,
19
+ ): Promise<OrderBooksResponse> {
20
+ return client
21
+ .get<OrderBooksResponse>("/api/v1/orderBooks")
22
+ .then((response) => response.data);
23
+ }
@@ -0,0 +1,24 @@
1
+ import { AxiosInstance } from "axios";
2
+
3
+ import { Trade } from "../info-private/trades";
4
+
5
+ export interface RecentTradesRequest {
6
+ market_id: number;
7
+ limit: number;
8
+ }
9
+
10
+ export type RecentTradesResponse = Trade[];
11
+
12
+ export async function getRecentTrades(
13
+ client: AxiosInstance,
14
+ params: RecentTradesRequest,
15
+ ): Promise<RecentTradesResponse> {
16
+ return client
17
+ .get<RecentTradesResponse>("/api/v1/recentTrades", {
18
+ params: {
19
+ market_id: params.market_id,
20
+ limit: params.limit,
21
+ },
22
+ })
23
+ .then((response) => response.data);
24
+ }
@@ -0,0 +1,13 @@
1
+ import { AxiosInstance } from "axios";
2
+
3
+ export interface RootInfoResponse {
4
+ contract_address: string;
5
+ }
6
+
7
+ export async function getRootInfo(
8
+ client: AxiosInstance,
9
+ ): Promise<RootInfoResponse> {
10
+ return client
11
+ .get<RootInfoResponse>("/info")
12
+ .then((response) => response.data);
13
+ }
@@ -0,0 +1,13 @@
1
+ import { AxiosInstance } from "axios";
2
+
3
+ export interface RootStatusResponse {
4
+ status: number;
5
+ network_id: number;
6
+ timestamp: string;
7
+ }
8
+
9
+ export async function getRootStatus(
10
+ client: AxiosInstance,
11
+ ): Promise<RootStatusResponse> {
12
+ return client.get<RootStatusResponse>("/").then((response) => response.data);
13
+ }
@@ -0,0 +1,20 @@
1
+ import { AxiosInstance } from "axios";
2
+
3
+ import { Transaction } from "./tx";
4
+
5
+ export interface TransactionFromL1TxHashRequest {
6
+ l1_tx_hash: string;
7
+ }
8
+
9
+ export async function getTransactionFromL1TxHash(
10
+ client: AxiosInstance,
11
+ params: TransactionFromL1TxHashRequest,
12
+ ): Promise<Transaction> {
13
+ return client
14
+ .get<Transaction>("/api/v1/txFromL1TxHash", {
15
+ params: {
16
+ l1_tx_hash: params.l1_tx_hash,
17
+ },
18
+ })
19
+ .then((response) => response.data);
20
+ }
@@ -0,0 +1,45 @@
1
+ import { AxiosInstance } from "axios";
2
+
3
+ export interface TransactionRequest {
4
+ by: "hash" | "index";
5
+ value: string;
6
+ }
7
+
8
+ export interface Transaction {
9
+ hash: string;
10
+ block_height: number;
11
+ sequence_index: number;
12
+ account_index: number;
13
+ nonce: number;
14
+ type: string | number;
15
+ info?: string;
16
+ event_info?: string;
17
+ data?: any;
18
+ status: number | "pending" | "confirmed" | "failed";
19
+ transaction_index?: number;
20
+ l1_address?: string;
21
+ expire_at?: number;
22
+ queued_at?: number;
23
+ committed_at?: number;
24
+ verified_at?: number;
25
+ executed_at?: number;
26
+ parent_hash?: string;
27
+ created_at?: string;
28
+ updated_at?: string;
29
+ code?: number;
30
+ message?: string;
31
+ }
32
+
33
+ export async function getTransaction(
34
+ client: AxiosInstance,
35
+ params: TransactionRequest,
36
+ ): Promise<Transaction> {
37
+ return client
38
+ .get<Transaction>("/api/v1/tx", {
39
+ params: {
40
+ by: params.by,
41
+ value: params.value,
42
+ },
43
+ })
44
+ .then((response) => response.data);
45
+ }
@@ -0,0 +1,19 @@
1
+ import { AxiosInstance } from "axios";
2
+
3
+ import { Transaction } from "./tx";
4
+
5
+ export interface TransactionsRequest {
6
+ cursor?: string;
7
+ limit?: number;
8
+ }
9
+
10
+ export type TransactionsResponse = Transaction[];
11
+
12
+ export async function getTransactions(
13
+ client: AxiosInstance,
14
+ params?: TransactionsRequest,
15
+ ): Promise<TransactionsResponse> {
16
+ return client
17
+ .get<TransactionsResponse>("/api/v1/txs", { params })
18
+ .then((response) => response.data);
19
+ }
@@ -0,0 +1,13 @@
1
+ import { AxiosInstance } from "axios";
2
+
3
+ export interface WithdrawalDelayResponse {
4
+ seconds: number;
5
+ }
6
+
7
+ export async function getWithdrawalDelay(
8
+ client: AxiosInstance,
9
+ ): Promise<WithdrawalDelayResponse> {
10
+ return client
11
+ .get<WithdrawalDelayResponse>("/api/v1/withdrawalDelay")
12
+ .then((response) => response.data);
13
+ }
@@ -0,0 +1,31 @@
1
+ import { AxiosInstance, AxiosRequestConfig } from "axios";
2
+
3
+ import { Orders } from "./account-inactive-orders";
4
+
5
+ export interface AccountActiveOrdersRequest {
6
+ account_index: number;
7
+ market_id: number;
8
+ auth?: string;
9
+ }
10
+
11
+ export async function getAccountActiveOrders(
12
+ client: AxiosInstance,
13
+ params: AccountActiveOrdersRequest,
14
+ authorization?: string,
15
+ ): Promise<Orders> {
16
+ const config: AxiosRequestConfig = {
17
+ params: {
18
+ account_index: params.account_index,
19
+ market_id: params.market_id,
20
+ ...(params.auth ? { auth: params.auth } : {}),
21
+ },
22
+ };
23
+
24
+ if (authorization) {
25
+ config.headers = { Authorization: authorization };
26
+ }
27
+
28
+ return client
29
+ .get<Orders>("/api/v1/accountActiveOrders", config)
30
+ .then((response) => response.data);
31
+ }
@@ -0,0 +1,83 @@
1
+ import { AxiosInstance, AxiosRequestConfig } from "axios";
2
+
3
+ export interface Order {
4
+ order_index: number;
5
+ client_order_index: number;
6
+ order_id: string;
7
+ client_order_id: string;
8
+ market_index: number;
9
+ owner_account_index: number;
10
+ initial_base_amount: string;
11
+ price: string;
12
+ nonce: number;
13
+ remaining_base_amount: string;
14
+ is_ask: boolean;
15
+ base_size: number;
16
+ base_price: number;
17
+ filled_base_amount: string;
18
+ filled_quote_amount: string;
19
+ side: string;
20
+ type: string;
21
+ time_in_force: string;
22
+ reduce_only: boolean;
23
+ trigger_price: string;
24
+ order_expiry: number;
25
+ status: string;
26
+ trigger_status: string;
27
+ trigger_time: number;
28
+ parent_order_index: number;
29
+ parent_order_id: string;
30
+ to_trigger_order_id_0?: string;
31
+ to_trigger_order_id_1?: string;
32
+ to_cancel_order_id_0?: string;
33
+ to_cancel_order_id_1?: string;
34
+ block_height: number;
35
+ timestamp: number;
36
+ }
37
+
38
+ export interface Orders {
39
+ code: number;
40
+ orders: Order[];
41
+ }
42
+
43
+ export interface AccountInactiveOrdersRequest {
44
+ account_index: number;
45
+ limit: number;
46
+ auth?: string;
47
+ market_id?: number;
48
+ ask_filter?: number;
49
+ between_timestamps?: string;
50
+ cursor?: string;
51
+ }
52
+
53
+ export async function getAccountInactiveOrders(
54
+ client: AxiosInstance,
55
+ params: AccountInactiveOrdersRequest,
56
+ authorization?: string,
57
+ ): Promise<Orders> {
58
+ const config: AxiosRequestConfig = {
59
+ params: {
60
+ account_index: params.account_index,
61
+ limit: params.limit,
62
+ ...(params.auth ? { auth: params.auth } : {}),
63
+ ...(params.market_id !== undefined
64
+ ? { market_id: params.market_id }
65
+ : {}),
66
+ ...(params.ask_filter !== undefined
67
+ ? { ask_filter: params.ask_filter }
68
+ : {}),
69
+ ...(params.between_timestamps
70
+ ? { between_timestamps: params.between_timestamps }
71
+ : {}),
72
+ ...(params.cursor ? { cursor: params.cursor } : {}),
73
+ },
74
+ };
75
+
76
+ if (authorization) {
77
+ config.headers = { Authorization: authorization };
78
+ }
79
+
80
+ return client
81
+ .get<Orders>("/api/v1/accountInactiveOrders", config)
82
+ .then((response) => response.data);
83
+ }
@@ -0,0 +1,35 @@
1
+ import { AxiosInstance, AxiosRequestConfig } from "axios";
2
+
3
+ export interface AccountLimitsRequest {
4
+ account_index: number;
5
+ auth?: string;
6
+ }
7
+
8
+ export interface AccountLimitsResponse {
9
+ code: number;
10
+ message?: string;
11
+ max_llp_percentage: number;
12
+ user_tier: string;
13
+ can_create_public_pool: boolean;
14
+ }
15
+
16
+ export async function getAccountLimits(
17
+ client: AxiosInstance,
18
+ params: AccountLimitsRequest,
19
+ authorization?: string,
20
+ ): Promise<AccountLimitsResponse> {
21
+ const config: AxiosRequestConfig = {
22
+ params: {
23
+ account_index: params.account_index,
24
+ ...(params.auth ? { auth: params.auth } : {}),
25
+ },
26
+ };
27
+
28
+ if (authorization) {
29
+ config.headers = { Authorization: authorization };
30
+ }
31
+
32
+ return client
33
+ .get<AccountLimitsResponse>("/api/v1/accountLimits", config)
34
+ .then((response) => response.data);
35
+ }
@@ -0,0 +1,43 @@
1
+ import { AxiosInstance, AxiosRequestConfig } from "axios";
2
+
3
+ export interface AccountMetadataRequest {
4
+ by: "index" | "l1_address";
5
+ value: string;
6
+ auth?: string;
7
+ }
8
+
9
+ export interface AccountMetadataInfo {
10
+ account_index: number;
11
+ name: string;
12
+ description: string;
13
+ can_invite: boolean;
14
+ referral_points_percentage: string;
15
+ }
16
+
17
+ export interface AccountMetadataResponse {
18
+ code: number;
19
+ message?: string;
20
+ account_metadatas: AccountMetadataInfo;
21
+ }
22
+
23
+ export async function getAccountMetadata(
24
+ client: AxiosInstance,
25
+ params: AccountMetadataRequest,
26
+ authorization?: string,
27
+ ): Promise<AccountMetadataResponse> {
28
+ const config: AxiosRequestConfig = {
29
+ params: {
30
+ by: params.by,
31
+ value: params.value,
32
+ ...(params.auth ? { auth: params.auth } : {}),
33
+ },
34
+ };
35
+
36
+ if (authorization) {
37
+ config.headers = { Authorization: authorization };
38
+ }
39
+
40
+ return client
41
+ .get<AccountMetadataResponse>("/api/v1/accountMetadata", config)
42
+ .then((response) => response.data);
43
+ }
@@ -0,0 +1,49 @@
1
+ import { AxiosInstance, AxiosRequestConfig } from "axios";
2
+
3
+ export interface DepositHistoryRequest {
4
+ account_index: number;
5
+ l1_address: string;
6
+ cursor?: string;
7
+ filter?: string;
8
+ }
9
+
10
+ export interface DepositHistoryItem {
11
+ id: string;
12
+ account_index: number;
13
+ l1_address: string;
14
+ l2_address: string;
15
+ amount: string;
16
+ l1_tx_hash: string;
17
+ status: string;
18
+ timestamp: number;
19
+ created_at: string;
20
+ }
21
+
22
+ export interface DepositHistoryResponse {
23
+ code: number;
24
+ deposits: DepositHistoryItem[];
25
+ cursor?: string;
26
+ }
27
+
28
+ export async function getDepositHistory(
29
+ client: AxiosInstance,
30
+ params: DepositHistoryRequest,
31
+ authorization?: string,
32
+ ): Promise<DepositHistoryResponse> {
33
+ const config: AxiosRequestConfig = {
34
+ params: {
35
+ account_index: params.account_index,
36
+ l1_address: params.l1_address,
37
+ ...(params.cursor ? { cursor: params.cursor } : {}),
38
+ ...(params.filter ? { filter: params.filter } : {}),
39
+ },
40
+ };
41
+
42
+ if (authorization) {
43
+ config.headers = { Authorization: authorization };
44
+ }
45
+
46
+ return client
47
+ .get<DepositHistoryResponse>("/api/v1/deposit/history", config)
48
+ .then((response) => response.data);
49
+ }