Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TS] [CLOB-895] short term place orders for TS #39

Merged
merged 5 commits into from
Sep 21, 2023

Conversation

jonfung-dydx
Copy link
Contributor

@jonfung-dydx jonfung-dydx commented Sep 20, 2023

Equivalent of #32 for TS. LMK If I missed anything.

Copy link
Contributor

@johnqh johnqh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is in sync with Python code but I have two refactoring request. We will need to refactor the Python code too (maybe in separate ticket)

@@ -1,7 +1,9 @@
import { Order_TimeInForce } from '@dydxprotocol/v4-proto/src/codegen/dydxprotocol/clob/order';

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of modifying composite_examples.ts, can you copy it to a separate composite_short_term_examples.ts with the new code? We still need this composite_examples.ts to test regular placeOrder for FE.

@@ -23,25 +25,24 @@ async function test(): Promise<void> {
const subaccount = new Subaccount(wallet, 0);
for (const orderParams of ordersParams) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ordersParams come from human_readable_orders.json, which is designed to include all combinations for our FE. For testing short_term orders, let's create a new short_term_orders.json file for all the test cases. I think you can eliminate a bunch of them and make the test quicker.

@@ -1,7 +1,9 @@
import { Order_TimeInForce } from '@dydxprotocol/v4-proto/src/codegen/dydxprotocol/clob/order';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this the correct Order_TIF we want to be using as a a parameter? Note that I took out everything related to OrderExecution too

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a translation layer in example to translate orderExecution string to Order_TimeInForce

@jonfung-dydx jonfung-dydx requested a review from johnqh September 20, 2023 21:10
@jonfung-dydx jonfung-dydx changed the title [CLOB-895] short term place orders for TS [TS] [CLOB-895] short term place orders for TS Sep 21, 2023
subticks,
timeInForce,
reduceOnly,
0, // Client metadata is 0 for short term orders.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: client metadata can be non-zero for short-term and stateful orders

}
}

function orderExecutionToTimeInForce(orderExecution: string): Order_TimeInForce {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: do you think this function should be defined within v4-client-js/src/clients/composite-client.ts and called within placeShortTermOrder?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess I'm fine with you leaving it here if it's meant to translate from a JSON order

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is only meant to translate from the JSON example file, so will keep it in here

@jonfung-dydx jonfung-dydx merged commit d6709f3 into main Sep 21, 2023
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants