Usage
Creating SDK Instance
To start using the SDK in your dApp, you first need to create an instance of it. This instance provides the primary functionality to interact with the Orbs dTWAP protocol.
Note: To obtain a config object, you must contact Orbs and setup your desired parameters, along with deploying the appropriate contracts.
Example of a dTWAP config object:
Derived Swap Values
The derivedSwapValues
function takes the inputs from the UI and derives all the values required for the TWAP order.
The following arguments customChunks
, customDuration
and customFillDelay
all have default values, so only pass these in if the user specifies them in the UI.
Prepare Order Arguments
The prepareOrderArgs
function takes the values from derivedSwapValues
and parses them into arguments for the dTWAP contract method.
Order Deadline
You can use orderDeadline to get the deadline of an order to display to the user. This needs to be updated at an interval with the current time.
Get Orders
Returns a list of all a user's orders.
Wait For Orders Update
Retries fetching the user’s orders until the specific order is found. This function is useful after creating a new order, when you want to wait for confirmation that the new order has been successfully created.
Best Practices
Limit Deadline
When the user selects the limit panel we suggest to set the default deadline of the order to 1 week and if TWAP, set it to undefined as it will be derived from the chunks and fill delay.
Warnings
The derivedSwapValues
SDK function returns a warnings object containing the boolean properties above.
We recommend displaying a message to the user in the UI for each of these warnings if they are true.
Last updated