📚 Overview
Implement the place_order() function to handle order creation, validation, and storage within the SwapTrade Contract. This function should generate a unique order ID, validate the token addresses and amounts, and store the order in the orderbook.
🛠️ Key Requirements
-
Create an Order struct that includes at least the following fields:
- Unique Order ID (using
uuid library or equivalent unique ID generation logic)
token_in, token_out, amount_in, min_amount_out
- Additional fields as necessary
-
Implement the place_order() function that:
- Accepts
token_in, token_out, amount_in, and min_amount_out as inputs
- Generates a unique order ID for every new order
- Validates the provided amounts and token addresses
- Stores the order within the orderbook storage
-
Write at least 3 unit tests to cover the following scenarios:
- Successful order creation with valid inputs
- Handling of invalid token addresses
- Insufficient or invalid amounts
🔍 Technical Considerations
- Utilize the
uuid library for generating unique IDs or implement an equivalent logic.
- Ensure that error handling is robust, particularly for invalid input cases.
- Follow the current project's smart contract and testing guidelines as referenced in the README.
✅ Acceptance Criteria
- The
Order struct is defined with the necessary fields.
- The
place_order() function generates a unique order ID and validates inputs correctly.
- The new order is added to the orderbook storage as expected.
- 3+ unit tests are provided to verify functionality and edge cases.
Let's ensure the implementation adheres to the project's guidelines and best practices. 🚀
📚 Overview
Implement the
place_order()function to handle order creation, validation, and storage within the SwapTrade Contract. This function should generate a unique order ID, validate the token addresses and amounts, and store the order in the orderbook.🛠️ Key Requirements
Create an
Orderstruct that includes at least the following fields:uuidlibrary or equivalent unique ID generation logic)token_in,token_out,amount_in,min_amount_outImplement the
place_order()function that:token_in,token_out,amount_in, andmin_amount_outas inputsWrite at least 3 unit tests to cover the following scenarios:
🔍 Technical Considerations
uuidlibrary for generating unique IDs or implement an equivalent logic.✅ Acceptance Criteria
Orderstruct is defined with the necessary fields.place_order()function generates a unique order ID and validates inputs correctly.Let's ensure the implementation adheres to the project's guidelines and best practices. 🚀