Swap

Get swap quote with energy delegation

Get a price quote and unsigned transaction for swapping tokens on SunSwap DEX with automatic energy delegation. Sign the returned unsignedTx and broadcast via /api/v2/agent/broadcast. Use X-API-Key to pay from TRX balance, or request without authentication for TRX 402 instructions. USDC x402 is supported only by /buy-energy.

post/api/v2/agent/swap

Request

  • Base URL: https://powersun.vip
  • URL: https://powersun.vip/api/v2/agent/swap
  • Auth: one of:
    • API key in header X-API-Key
    • none

Request body

fromTokenstring required

Token to sell — symbol (TRX, USDT, SUN, ...) or TRC-20 contract address

toTokenstring required

Token to buy — symbol or TRC-20 contract address

amountInstring required

Amount in base units (SUN for TRX, 6 decimals for USDT)

slippageBpsinteger

Slippage tolerance in basis points (default: 50 = 0.5%)

senderAddressstring

TRON address of the sender (defaults to registered address)

Example request

{
  "fromToken": "TRX",
  "toToken": "USDT",
  "amountIn": "10000000",
  "slippageBps": 100
}

Response

Swap quote with unsigned transaction

unsignedTxobject

Unsigned TRON transaction to sign with your private key

Example response

{
  "quote": {
    "fromSymbol": "TRX",
    "toSymbol": "USDT"
  }
}

Changes

No recorded changes to this operation across all 1 revision of this API.