Skip to content

Commit 44c3cc3

Browse files
authored
Update typescript SDK (#41)
1 parent 7bbc36f commit 44c3cc3

File tree

7 files changed

+1552
-994
lines changed

7 files changed

+1552
-994
lines changed

package-lock.json

Lines changed: 1509 additions & 978 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@deltadefi-protocol/typescript-sdk",
33
"description": "The Typescript SDK for interacting with DeltaDeFi protocol",
4-
"version": "0.3.22",
4+
"version": "0.3.23",
55
"main": "./dist/index.cjs",
66
"browser": "./dist/index.js",
77
"module": "./dist/index.js",

src/client/accounts/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
BuildWithdrawalTransactionResponse,
1212
SubmitWithdrawalTransactionRequest,
1313
SubmitWithdrawalTransactionResponse,
14+
GetOrderRecordRequest,
1415
GetOrderRecordResponse,
1516
GetDepositRecordsResponse,
1617
GetWithdrawalRecordsResponse,
@@ -95,8 +96,8 @@ export class Accounts extends Api {
9596
* Retrieves order records.
9697
* @returns A promise that resolves to the order records response.
9798
*/
98-
public getOrderRecords(): Promise<GetOrderRecordResponse> {
99-
const res = this.axiosInstance.get('/accounts/order-records');
99+
public getOrderRecords(data: GetOrderRecordRequest): Promise<GetOrderRecordResponse> {
100+
const res = this.axiosInstance.get('/accounts/order-records', { params: data });
100101
return this.resolveAxiosData(res);
101102
}
102103

src/client/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export class ApiClient {
4646
if (network === 'mainnet') {
4747
// TODO: input production link once available
4848
baseURL = 'https://api.deltadefi.io';
49-
wsURL = 'wss://api-staging.deltadefi.io';
49+
wsURL = 'wss://api.deltadefi.io';
5050
} else {
5151
baseURL = 'https://api-staging.deltadefi.io';
5252
wsURL = 'wss://api-staging.deltadefi.io';

src/types/models/order.ts

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
1-
export type TradingSymbol = 'ADAUSDX';
1+
export type TradingSymbol = 'ADAUSDM';
22

3-
export type OrderStatus = 'building' | 'processing' | 'open' | 'closed' | 'failed' | 'cancelled';
3+
export type OrderStatus =
4+
| 'open'
5+
| 'fully_filled'
6+
| 'partially_filled'
7+
| 'cancelled'
8+
| 'partially_cancelled'
9+
| 'failed';
410

511
export type OrderSide = 'buy' | 'sell';
612

@@ -47,3 +53,17 @@ export type OrderJSON = {
4753
update_time: number;
4854
fills?: OrderExecutionRecordJSON[];
4955
};
56+
57+
export type OrderFillingRecordJSON = {
58+
execution_id: string;
59+
order_id: string;
60+
status: OrderStatus;
61+
symbol: TradingSymbol;
62+
executed_qty: string;
63+
side: OrderSide;
64+
type: OrderType;
65+
fee_charged: string;
66+
fee_unit: string;
67+
executed_price: number;
68+
created_time: number;
69+
};

src/types/requests/index.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,10 @@ export type SubmitCancelOrderTransactionRequest = {
7979
signed_tx: string;
8080
};
8181

82-
export type Status = 'open' | 'closed';
82+
export type Status = 'openOrder' | 'orderHistory' | 'tradingHistory';
8383

8484
export type GetOrderRecordRequest = {
85-
status?: Status;
85+
status: Status; // Must be either 'openOrder' | 'orderHistory' | 'tradingHistory'
86+
limit: number; // default number is 10 while number must be between 1 and 250
87+
page: number; // default number is 1 while number must be between 1 and 1000
8688
};

src/types/responses/index.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import { Asset } from '@meshsdk/core';
2-
import { OrderJSON, AccountBalance } from '../models';
1+
import { OrderJSON, AccountBalance, OrderFillingRecordJSON } from '../models';
32

43
export type SignInResponse = {
54
token: string;
@@ -40,23 +39,30 @@ export type GetOperationKeyResponse = {
4039

4140
export type TransactionStatus = 'building' | 'submitted' | 'submission_failed' | 'confirmed';
4241

42+
export type AssetRecord = {
43+
asset: string;
44+
asset_unit: string;
45+
qty: number;
46+
};
47+
4348
export type DepositRecord = {
4449
created_at: string;
4550
status: TransactionStatus;
46-
assets: Asset[];
51+
assets: AssetRecord[];
4752
tx_hash: string;
4853
};
4954

5055
export type GetDepositRecordsResponse = DepositRecord[];
5156

5257
export type GetOrderRecordResponse = {
53-
Orders: OrderJSON[];
58+
orders: OrderJSON[];
59+
order_filling_records: OrderFillingRecordJSON[];
5460
};
5561

5662
export type WithdrawalRecord = {
5763
created_at: string;
5864
status: TransactionStatus;
59-
assets: Asset[];
65+
assets: AssetRecord[];
6066
};
6167

6268
export type GetWithdrawalRecordsResponse = WithdrawalRecord[];
@@ -127,9 +133,7 @@ export type BuildCancelOrderTransactionResponse = {
127133
tx_hex: string;
128134
};
129135

130-
export type SubmitCancelOrderTransactionResponse = {
131-
tx_hash: string;
132-
};
136+
export type SubmitCancelOrderTransactionResponse = object;
133137

134138
export type GetAPIKeyResponse = {
135139
api_key: string;

0 commit comments

Comments
 (0)