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 51d16dc

Browse files
authoredMar 7, 2025
feat: update functions and type according to latest espresso repo (#24)
* feat: update functions and type according to latest espresso repo * fix: add additional npm package to package-lock.json * fix: fix duplicated orderstatus type issue * fix: reinstall npm package
1 parent 9f7e310 commit 51d16dc

File tree

6 files changed

+2380
-1480
lines changed

6 files changed

+2380
-1480
lines changed
 

‎package-lock.json

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

‎src/client/accounts/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {
1717
GetAccountBalanceResponse,
1818
GenerateNewAPIKeyResponse,
1919
AccountBalance,
20+
GetAPIKeyResponse,
2021
// AccountStream,
2122
// AccountBalanceStream,
2223
} from '../../types';
@@ -65,6 +66,11 @@ export class Accounts extends Api {
6566
return this.resolveAxiosData(res);
6667
}
6768

69+
public getApiKey(): Promise<GetAPIKeyResponse> {
70+
const res = this.axiosInstance.get('/accounts/api-key');
71+
return this.resolveAxiosData(res);
72+
}
73+
6874
public buildDepositTransaction(
6975
data: BuildDepositTransactionRequest,
7076
): Promise<BuildDepositTransactionResponse> {

‎src/client/app/index.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { AxiosInstance } from 'axios';
22
import { Api } from '../api';
3-
import { GetTermsAndConditionResponse } from '../../types';
3+
import { GetHydraCycleResponse, GetTermsAndConditionResponse } from '../../types';
44

55
export class App extends Api {
66
private axiosInstance: AxiosInstance;
@@ -14,4 +14,9 @@ export class App extends Api {
1414
const res = this.axiosInstance.get('/app/terms-and-conditions');
1515
return this.resolveAxiosData(res);
1616
}
17+
18+
public getHydraCycle(): Promise<GetHydraCycleResponse> {
19+
const res = this.axiosInstance.get('/app/hydra-cycle');
20+
return this.resolveAxiosData(res);
21+
}
1722
}

‎src/types/models/order.ts

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

3-
export type OrderStatus = 'building' | 'open' | 'closed' | 'failed' | 'cancelled';
3+
export type OrderStatus = 'building' | 'processing' | 'open' | 'closed' | 'failed' | 'cancelled';
44

55
export type OrderSide = 'buy' | 'sell';
66

@@ -16,18 +16,34 @@ export const OrderTypes = {
1616
LimitOrder: 'limit' as OrderType,
1717
};
1818

19+
export type OrderExecutionRole = 'maker' | 'taker';
20+
21+
export type OrderExecutionRecordJSON = {
22+
id: string;
23+
order_id: string;
24+
execution_price: number;
25+
filled_amount: string;
26+
fee_unit: string;
27+
fee_amount: string;
28+
role: OrderExecutionRole;
29+
counter_party_order_id: string;
30+
create_time: number;
31+
};
32+
1933
export type OrderJSON = {
2034
order_id: string;
2135
status: OrderStatus;
2236
symbol: TradingSymbol;
2337
orig_qty: string;
2438
executed_qty: string;
2539
side: OrderSide;
26-
price: string;
40+
price: number;
2741
type: OrderType;
28-
fee_amount: number;
42+
fee_charged: string;
43+
fee_unit: string;
2944
executed_price: number;
3045
slippage: string;
3146
create_time: number;
3247
update_time: number;
48+
fills?: OrderExecutionRecordJSON[];
3349
};

‎src/types/requests/index.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Asset, UTxO } from '@meshsdk/core';
1+
import { UTxO } from '@meshsdk/core';
22
import { TradingSymbol, OrderSide, OrderType } from '../models/order';
33

44
// SignInRequest to be refactored
@@ -12,6 +12,11 @@ export type SignInRequest = {
1212
// quantity: number;
1313
// };
1414

15+
export type Asset = {
16+
unit: string;
17+
quantity: string;
18+
};
19+
1520
export type BuildDepositTransactionRequest = {
1621
deposit_amount: Asset[];
1722
input_utxos: UTxO[];
@@ -34,7 +39,7 @@ export type GetMarketDepthRequest = {
3439
};
3540

3641
export type GetMarketPriceRequest = {
37-
pair: string;
42+
pair: TradingSymbol;
3843
};
3944

4045
export type Interval = '15m' | '30m' | '1h' | '1d' | '1w' | '1M';
@@ -53,7 +58,7 @@ export type BuildPlaceOrderTransactionRequest = {
5358
quantity: number;
5459
price?: number;
5560
max_slippage_basis_point?: number;
56-
max_slippage?: boolean;
61+
max_slippage: boolean;
5762
};
5863

5964
export type PostOrderRequest = BuildPlaceOrderTransactionRequest;
@@ -70,3 +75,9 @@ export type BuildCancelOrderTransactionRequest = {
7075
export type SubmitCancelOrderTransactionRequest = {
7176
signed_tx: string;
7277
};
78+
79+
export type Status = 'open' | 'closed';
80+
81+
export type GetOrderRecordRequest = {
82+
status?: Status;
83+
};

‎src/types/responses/index.ts

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,7 @@ export type SignInResponse = {
3131
// tx_hash: string;
3232
// };
3333

34-
export type TransactionStatus =
35-
| 'building'
36-
| 'held_for_order'
37-
| 'submitted'
38-
| 'submission_failed'
39-
| 'confirmed';
34+
export type TransactionStatus = 'building' | 'submitted' | 'submission_failed' | 'confirmed';
4035

4136
export type DepositRecord = {
4237
created_at: string;
@@ -53,6 +48,7 @@ export type GetOrderRecordResponse = {
5348

5449
export type WithdrawalRecord = {
5550
created_at: string;
51+
status: TransactionStatus;
5652
assets: Asset[];
5753
};
5854

@@ -62,6 +58,7 @@ export type GetAccountBalanceResponse = AccountBalance[];
6258

6359
export type GenerateNewAPIKeyResponse = {
6460
api_key: string;
61+
created_at: string;
6562
};
6663

6764
export type BuildDepositTransactionResponse = {
@@ -80,9 +77,7 @@ export type SubmitWithdrawalTransactionResponse = {
8077
tx_hash: string;
8178
};
8279

83-
export type GetTermsAndConditionResponse = {
84-
value: string;
85-
};
80+
export type GetTermsAndConditionResponse = string;
8681

8782
export type MarketDepth = {
8883
price: number;
@@ -128,3 +123,13 @@ export type BuildCancelOrderTransactionResponse = {
128123
export type SubmitCancelOrderTransactionResponse = {
129124
tx_hash: string;
130125
};
126+
127+
export type GetAPIKeyResponse = {
128+
api_key: string;
129+
created_at: string;
130+
};
131+
132+
export type GetHydraCycleResponse = {
133+
start: string;
134+
end: string;
135+
};

0 commit comments

Comments
 (0)
Please sign in to comment.