Instant Login
Instant Login for Instant Open/Close
Before you can perform instant open or instant close actions, your sub‑account must delegate access to the solver (Party B) for these functions. Once delegated, you must obtain an access token through a two-step SIWE (Sign-In With Ethereum) login flow. This process ensures that you are authorized to execute instant actions and that your request includes a validated expiration date.
Flow Overview
Delegate Access: First, delegate access from your sub‑account to the solver’s address so that they can call functions (such as open, request to close, or cancel close) on your behalf.
Fetch a Nonce: Query the hedger’s nonce endpoint using your sub‑account address. The nonce ensures the uniqueness of your SIWE message and prevents replay attacks.
Build and Sign the SIWE Message: Construct a SIWE message that includes your wallet address, the nonce, a statement (the sub-account), and timestamps (issued and expiration). This message must be signed by your wallet to confirm your intent.
Send Login Request: Submit your signed SIWE message to the hedger’s
/login
endpoint. Upon successful verification, you will receive an access token. This token is then used for subsequent instant open or close operations.
Delegating Access
To enable instant actions on the frontend, users must delegate specific functions to solvers so they can perform actions on the user's behalf without requiring signatures for each request.
Front-ends should ensure that the following functions are delegated to the solver addresses through the delegateAccesses()
method on the MultiAccount contract, passing these function signatures.:
sendQuote
: 0x7f2755b2sendQuoteWithAffiliate
: 0x40f1310crequestToClosePosition
: 0x501e891frequestToCancelQuote
: 0xa8ffc7abrequestToCancelCloseRequest
: 0xa63b9363allocate
: 0x90ca796b
After Delegating Access you can proceed with the login process.
Example Script
Below is a Node.js script (using ethers and axios) that demonstrates the nonce fetch and instant login flow:
Delegation of Access: Ensure that your sub‑account has already delegated access to the solver for instant actions before starting the login flow.
Upon successful login, the response includes an access token. This token must be attached in the headers of any instant open or close requests that you subsequently send.
Last updated