Buy Node is a specialized trading node for executing buy operations, an instance node of Swap Node. It provides clear buy semantics and simplifies token purchase configuration.
Amber (Orange) / Emerald (Green)
Buy Node is designed specifically for token purchase operations. It internally uses Swap Node's complete exchange functionality but provides more intuitive parameter naming. Users only need to specify the token to buy and the payment token, and the node automatically handles the exchange logic.
Main Uses:
Simplified parameter configuration
Automatic exchange direction handling
Core Features:
π° Buy Semantics: buy_token and base_token parameters are more intuitive
π Auto Mapping: Internally converts to Swap Node's from/to parameters
π Full Functionality: Inherits all Swap Node features
π― Buy-Focused: Optimized user experience
Relationship with Swap Node
Buy Node is an instance node of Swap Node:
Parameter Mapping:
base_token β from_token (payment token)
buy_token β to_token (token to purchase)
Parameter
Type
Required
Default
Description
{mode:"spend_fixed",value:""}
Amount (v0.4.1 supports 4 modes)
Vault object (from Vault Node, contains chain, address, balance)
amount_in_human_readable Parameter
Description: Amount setting, v0.4.1 supports 4 modes for flexible amount control.
Type: Switch (Mode Selector)
Data Structure:
Supported Modes:
Spend fixed amount of base_token
Spend percentage of base_token balance (0-100)
Buy fixed amount of buy_token
Increase buy_token holdings by percentage
Mode 1: spend_fixed (Fixed Spending)
Specify exact amount of base_token to spend.
Mode 2: spend_percent (Percentage Spending)
Spend a percentage of base_token balance (0-100).
Mode 3: buy_fixed (Fixed Purchase Amount)
Specify exact amount of buy_token to purchase.
Mode 4: buy_percent (Increase Holdings Percentage)
Increase current buy_token holdings by specified percentage.
Backward Compatibility:
"number" mode auto-maps to "spend_fixed"
"percentage" mode auto-maps to "spend_percent"
slippery Parameter
Format: Percentage (recommended 0.5-5.0)
Scenario
Recommended
Description
vault Parameter
Source: Vault Node output
Description:
Must be received from upstream Vault Node
Contains complete vault info: chain, address, holdings, total_value_usd, etc.
Used for trade execution, balance queries, and chain determination
Output Parameters
Output ID
Display Name
Data Type
Description
Key Fields:
from_token: base_token value
to_token: buy_token value
amount_in: Actual payment amount
amount_out: Actual purchase amount
tx_hash: Transaction hash
Example 1: Buy APT with USDT (spend_fixed mode)
Scenario: Spend 100 USDT to buy APT.
Workflow:
Buy Node Configuration:
Example 2: Buy with 50% Balance (spend_percent mode)
Scenario: Use 50% of USDT balance to buy xBTC.
Example 3: Buy Fixed Token Amount (buy_fixed mode)
Scenario: Buy exactly 10 APT.
Example 4: Increase Holdings (buy_percent mode)
Scenario: Increase APT holdings by 20%.
Conditional Trading
If buy_token or base_token is an empty string "", the node will skip execution and return a trade_receipt with skipped: true.
Mode Selection (v0.4.1)
Purchase specific quantity
Technical Specifications
Hyperion (Aptos), Flow DEX
Maintained by: TradingFlow Development Team Version: 1.0.0