Rasa TP/SL Implementation
The TPSL (Take Profit Stop Loss) feature provided by rasa capital enables users to efficiently manage their trades by automating take profit and stop loss orders.
In the latest version, we have integrated support for Account Abstraction (ERC-4337), enabling interaction with smart wallets for enhanced functionality and flexibility.
This document provides an overview of the functionality, request structure, and details regarding the integration of account abstraction using ERC-4337.
API Endpoint
Base URL:
https://base-hedger82.rasa.capital/conditional-order
Request Body Format: The API expects the following JSON payload structure:
Parameter Descriptions
Top-Level Fields
quote_id
(string):A unique identifier for the trade quote associated with the order.
sign_type
("v1" | "v2"):Defines the signature validation mechanism:
v1: Basic EOA signing.
v2: ERC-1271-compliant on-chain validation for smart wallets.
timestamp
(number):A UNIX timestamp representing the moment the request body was created.
signature
(string):A cryptographic hash used to authenticate the request. It varies based on the
sign_type
:
For v1, it is a typical ECDSA signature.
For v2, this is a smart wallet signature sent for validation via the ERC-1271 mechanism.
Orders Array Fields
Each object in the orders array includes the following fields:
â quantity
(string): The amount of order will be closed when reach to the takeProfit or stopLoss.
â price
(string): The price at which the order will execute.
â conditional_price
(string): A threshold price for triggering the conditional order.
â order_type
(number): Represents the type of order:
1: Market Order
2: Limit Order
â conditional_order_type
("take_profit
" | "stop_loss
"): Specifies whether the order is a take profit or stop loss.
How to Generate the signature
Field
signature
FieldThe signature
field is a cryptographic hash that authenticates the request. Here's a step-by-step guide on how to generate and include this value in your request:
Prepare the Request Body:
â Create a JSON object containing all the required fields in the request body.
â Leave the signature
field empty at this stage but populate all other fields (e.g.,quote_id, sign_type, timestamp,
and orders
).
Sign the Json:
â Use the appropriate signing method based on the sign_type:
v1: Sign the hash using an ECDSA private key (off-chain signature).
v2: Use a smart wallet library to sign the hash, which adheres to the ERC-1271 standard.
Insert the Signature:
â Place the generated signature into the previously empty signature
field of the JSON request body.
Send the Request:
â The final JSON object, now containing the valid signature, should be sent to the API endpoint.
Last updated