Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 19547d2

Browse files
committedApr 23, 2024
feat: adding types for account orders
1 parent 995c117 commit 19547d2

File tree

5 files changed

+37
-13
lines changed

5 files changed

+37
-13
lines changed
 

‎package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "utxo-orderbook-sdk",
33
"description": "",
4-
"version": "0.1.18",
4+
"version": "0.1.19",
55
"license": "Apache-2.0",
66
"main": "dist/cjs/index.js",
77
"module": "dist/mjs/index.js",

‎src/client/accounts/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {
1616
BuildWithdrawalTransactionResponse,
1717
SubmitWithdrawalTransactionRequest,
1818
SubmitWithdrawalTransactionResponse,
19+
GetOrdersResponse,
1920
} from '../../types';
2021
import { Api } from '../api';
2122

@@ -42,6 +43,11 @@ export class Accounts extends Api {
4243
return this.resolveAxiosData(res);
4344
}
4445

46+
public getOrders(): Promise<GetOrdersResponse> {
47+
const res = this.axiosInstance.get('/accounts/orders');
48+
return this.resolveAxiosData(res);
49+
}
50+
4551
public updateBalance(): Promise<GetBalanceResponse> {
4652
const res = this.axiosInstance.get('/accounts/balance/update');
4753
return this.resolveAxiosData(res);

‎src/types/constant.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
export type TradingPair = 'ADAUSDX';
22
export type TradingSide = 'buy' | 'sell';
33
export type TradingType = 'limit' | 'market';
4+
export type TimeInForce = 'GTC';

‎src/types/models/order.ts

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,27 @@
1-
import { TradingPair, TradingSide, TradingType } from 'types/constant';
1+
import { TimeInForce, TradingPair, TradingSide, TradingType } from '../constant';
2+
3+
export type OrderStatus =
4+
| 'build'
5+
| 'pending'
6+
| 'open'
7+
| 'pending_cancel'
8+
| 'cancelled'
9+
| 'pending_settle'
10+
| 'partial_filled'
11+
| 'fully_filled';
212

313
export type Order = {
4-
id: string;
5-
expiry: string;
6-
trading_pair: TradingPair;
7-
order_type: TradingType;
8-
order_side: TradingSide;
14+
pair: TradingPair;
15+
order_id: string;
916
slippage: number;
10-
price: number;
11-
total_quantity: number;
12-
owner: string;
13-
order_status: string;
14-
created_at: string;
15-
updated_at: string;
17+
price: string;
18+
orig_qty: string;
19+
executed_qty: string;
20+
status: OrderStatus;
21+
time_in_force: TimeInForce;
22+
expiry_time: number;
23+
type: TradingType;
24+
side: TradingSide;
25+
create_time: number;
26+
update_time: number;
1627
};

‎src/types/responses/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { Order } from '../models';
2+
13
export type SignInResponse = {
24
token: string;
35
is_ready: boolean;
@@ -14,6 +16,10 @@ export type GetBalanceResponse = {
1416
};
1517
};
1618

19+
export type GetOrdersResponse = {
20+
orders: Order[];
21+
};
22+
1723
export type BuildSendRefScriptsTransactionResponse = {
1824
tx_hex: string;
1925
};

0 commit comments

Comments
 (0)
Please sign in to comment.