-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathinterface.ts
163 lines (137 loc) · 2.89 KB
/
interface.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
import { B256Address, WalletLocked, WalletUnlocked } from "fuels";
import BN from "./utils/BN";
export type MarketStatusOutput = "Opened" | "Paused" | "Closed";
export interface OrderbookContracts {
market: B256Address;
tokenFactory: B256Address;
pyth: B256Address;
}
export interface Asset {
address: B256Address;
symbol: string;
decimals: number;
}
interface BaseOptions {
contractAddresses: OrderbookContracts;
gasPrice: string;
gasLimitMultiplier: string;
}
export interface Options extends BaseOptions {
wallet: WalletLocked | WalletUnlocked;
}
export interface OptionsSpark extends BaseOptions {
wallet?: WalletLocked | WalletUnlocked;
}
export interface SparkParams {
networkUrl: string;
indexerApiUrl: string;
contractAddresses?: OrderbookContracts;
wallet?: WalletLocked | WalletUnlocked;
gasPrice?: string;
gasLimitMultiplier?: string;
pythUrl?: string;
}
export interface SpotOrderWithoutTimestamp {
id: string;
assetType: AssetType;
orderType: OrderType;
trader: B256Address;
baseSize: BN;
orderPrice: BN;
}
export interface UserMarketBalance {
liquid: {
base: string;
quote: string;
};
locked: {
base: string;
quote: string;
};
}
export type MarketCreateEvent = {
id: string;
assetId: B256Address;
decimal: number;
};
export type WriteTransactionResponse = {
transactionId: string;
value: unknown;
};
export interface GraphQLResponse<T> {
data: T;
errors?: { message: string }[];
}
export enum OrderType {
Buy = "Buy",
Sell = "Sell",
}
export enum AssetType {
Base = "Base",
Quote = "Quote",
}
export type Status = "Active" | "Canceled" | "Closed";
export interface SpotMarketCreateEvent {
id: number;
asset_id: B256Address;
asset_decimals: string;
timestamp: string;
createdAt: string;
updatedAt: string;
}
export interface GetOrdersParams {
limit: number;
orderType?: OrderType;
status?: Status[];
user?: B256Address;
asset?: B256Address;
}
export interface DepositParams {
amount: string;
asset: B256Address;
}
export interface CreateOrderParams {
amount: string;
tokenType: AssetType;
price: string;
type: OrderType;
}
export interface WithdrawParams {
amount: string;
assetType: AssetType;
}
export interface Order {
id: string;
asset: B256Address;
asset_type: AssetType;
amount: string;
initial_amount: string;
order_type: OrderType;
price: string;
status: Status;
user: B256Address;
timestamp: string;
}
export interface GetTradeOrderEventsParams {
limit: number;
}
export interface MatchOrderEvent {
id: string;
owner: B256Address;
counterparty: B256Address;
asset: B256Address;
match_size: string;
match_price: string;
timestamp: string;
}
export interface TradeOrderEvent {
id: string;
timestamp: string;
trade_price: string;
trade_size: string;
}
export type Volume = {
volume24h: string;
high24h: string;
low24h: string;
};