spotBuy action enables Vincent Apps to execute buy orders on Hyperliquid’s spot market using a Vincent User’s HyperCore spot balance.
Prerequisites
Before executing thespotBuy action, the following conditions must be met:
- Spot Balance on HyperCore: The Vincent User Agent Wallet must have sufficient balance for the quote asset in their HyperCore spot balance to cover the purchase amount. The quote asset is the second asset in the trading pair (e.g., USDC in “PURR/USDC”).
- Order Parameters: You must provide a valid trading pair symbol (e.g., “PURR/USDC”), price, and size according to Hyperliquid’s trading rules.
To learn more about executing Vincent Abilities, see the Executing
Abilities guide.
Executing the precheck Function
The precheck function validates some prerequisites for executing a spot buy, without actually performing the operation.
For the spotBuy action, the precheck function will validate the following:
- The trading pair symbol is a valid Hyperliquid trading pair (e.g., “PURR/USDC”).
- The Vincent User Agent Wallet has sufficient balance for the quote asset in their HyperCore spot balance to cover the purchase amount. The quote asset is the second asset in the trading pair (e.g. USDC in “PURR/USDC”).
- Parameters
- Implementation
- Response
The
precheck function requires the following parameters:Executing the execute Function
The execute function performs the actual buy operation, placing a buy order on Hyperliquid’s spot market.
For the spotBuy action, the execute function will:
- Place a buy order for the specified token pair at the given price and size.
- Return the order result from Hyperliquid.
- Parameters
- Implementation
- Response
The
execute function requires the following parameters:Important Considerations
Price and Size Formatting Rules
Price and Size Formatting Rules
Hyperliquid has strict formatting requirements for spot orders. See the Hyperliquid API documentation for more details.
Getting Current Market Prices
Getting Current Market Prices
You’ll need to fetch the current market price before placing an order. Use the Hyperliquid API or
SDK to get the mid price for your trading pair, then adjust it based on your strategy (e.g. 1%
above mid price for market buys).
Order Types
Order Types
You can specify either a limit or market order using the
orderType parameter. See the
Parameters section for more details.Verifying Order Success
Verifying Order Success
After the order is executed, you can verify the balances changed by checking the spot balances using a Hyperliquid SDK, or by using the Hyperliquid API.
Reference Implementation
For a complete working example showing the full spot buy workflow including balance verification and price calculation, see the buy.spec.ts end-to-end test in theability-hyperliquid package.

