Skip to content

Commit 76f7308

Browse files
committed
feat: post only order + cancel all
1 parent 20cdadd commit 76f7308

File tree

5 files changed

+43
-9
lines changed

5 files changed

+43
-9
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@deltadefi-protocol/sdk",
33
"description": "The Typescript SDK for DeltaDeFi protocol",
4-
"version": "0.3.30",
4+
"version": "0.3.31",
55
"main": "./dist/index.cjs",
66
"browser": "./dist/index.js",
77
"module": "./dist/index.js",
@@ -77,4 +77,4 @@
7777
"npm run eslint --fix"
7878
]
7979
}
80-
}
80+
}

src/client/orders/index.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ import {
66
SubmitPlaceOrderTransactionRequest,
77
SubmitPlaceOrderTransactionResponse,
88
SubmitCancelOrderTransactionRequest,
9+
BuildCancelAllOrdersTransactionResponse,
10+
SubmitCancelAllOrdersTransactionResponse,
11+
SubmitCancelAllOrdersTransactionRequest,
912
} from '../../types';
1013
import { Api } from '../api';
1114

@@ -48,6 +51,15 @@ export class Orders extends Api {
4851
return this.resolveAxiosData(res);
4952
}
5053

54+
/**
55+
* Builds cancel all orders transactions.
56+
* @returns A promise that resolves to the build cancel all orders transaction response.
57+
*/
58+
public buildCancelAllOrdersTransaction(): Promise<BuildCancelAllOrdersTransactionResponse> {
59+
const res = this.axiosInstance.delete(`/order/cancel-all/build`);
60+
return this.resolveAxiosData(res);
61+
}
62+
5163
/**
5264
* Submits a place order transaction.
5365
* @param data - The submit place order transaction request data.
@@ -71,4 +83,16 @@ export class Orders extends Api {
7183
const res = this.axiosInstance.delete('/order/submit', { data });
7284
return this.resolveAxiosData(res);
7385
}
86+
87+
/**
88+
* Submits cancel all orders transaction.
89+
* @param data - The submit cancel all orders transaction request data.
90+
* @returns The transaction hash of cancelled all orders.
91+
*/
92+
public async submitCancelAllOrdersTransaction(
93+
data: SubmitCancelAllOrdersTransactionRequest,
94+
): Promise<SubmitCancelAllOrdersTransactionResponse> {
95+
const res = this.axiosInstance.delete('/order/submit', { data });
96+
return this.resolveAxiosData(res);
97+
}
7498
}

src/types/models/account.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
import { Asset } from '../requests';
1+
export type Asset = {
2+
unit: string;
3+
quantity: string;
4+
};
25

36
export type AccountBalance = {
47
asset: string;

src/types/requests/index.ts

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

55
// SignInRequest to be refactored
66
export type SignInRequest = {
@@ -16,11 +16,6 @@ export type SignInRequest = {
1616
// quantity: number;
1717
// };
1818

19-
export type Asset = {
20-
unit: string;
21-
quantity: string;
22-
};
23-
2419
export type BuildDepositTransactionRequest = {
2520
deposit_amount: Asset[];
2621
input_utxos: UTxO[];
@@ -81,6 +76,7 @@ export type BuildPlaceOrderTransactionRequest = {
8176
price?: number;
8277
max_slippage_basis_point?: number;
8378
limit_slippage?: boolean;
79+
post_only?: boolean;
8480
};
8581

8682
export type PostOrderRequest = BuildPlaceOrderTransactionRequest;
@@ -94,6 +90,10 @@ export type SubmitCancelOrderTransactionRequest = {
9490
signed_tx: string;
9591
};
9692

93+
export type SubmitCancelAllOrdersTransactionRequest = {
94+
signed_txs: string[];
95+
};
96+
9797
export type Status = 'openOrder' | 'orderHistory' | 'tradingHistory';
9898

9999
export type GetOrderRecordRequest = {

src/types/responses/index.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,13 @@ export type BuildCancelOrderTransactionResponse = {
147147
tx_hex: string;
148148
};
149149

150+
export type BuildCancelAllOrdersTransactionResponse = {
151+
tx_hexes: string[];
152+
};
153+
export type SubmitCancelAllOrdersTransactionResponse = {
154+
cancelled_order_ids: string[];
155+
};
156+
150157
export type GetAPIKeyResponse = {
151158
api_key: string;
152159
created_at: string;

0 commit comments

Comments
 (0)