GetSwapInstructions
curl --request GET \
--url https://api.hular.dev/json/v1/quotes/{quote_hash}/instructionsimport requests
url = "https://api.hular.dev/json/v1/quotes/{quote_hash}/instructions"
response = requests.get(url)
print(response.text)const options = {method: 'GET'};
fetch('https://api.hular.dev/json/v1/quotes/{quote_hash}/instructions', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.hular.dev/json/v1/quotes/{quote_hash}/instructions",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.hular.dev/json/v1/quotes/{quote_hash}/instructions"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.hular.dev/json/v1/quotes/{quote_hash}/instructions")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.hular.dev/json/v1/quotes/{quote_hash}/instructions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body{
"router_address": "<string>",
"src_token": "<string>",
"amount_in": "<string>",
"bridge_token": "<string>",
"min_bridge_out": "<string>",
"evm": {
"aggregator": "<string>",
"swap_calldata": "<string>",
"value": "<string>"
},
"svm": {
"setup": [
{
"program_id": "<string>",
"accounts": [
{
"pubkey": "<string>",
"is_signer": true,
"is_writable": true
}
],
"data": "<string>"
}
],
"swap": {
"program_id": "<string>",
"accounts": [
{
"pubkey": "<string>",
"is_signer": true,
"is_writable": true
}
],
"data": "<string>"
},
"cleanup": [
{
"program_id": "<string>",
"accounts": [
{
"pubkey": "<string>",
"is_signer": true,
"is_writable": true
}
],
"data": "<string>"
}
],
"lookup_tables": [
{
"address": "<string>",
"addresses": [
"<string>"
]
}
],
"allowed_swap_programs": [
"<string>"
],
"swap_programs_signature": "<string>"
}
}{
"code": 123,
"message": "<string>",
"details": [
{}
]
}Reference
GetSwapInstructions
Aggregator routing for a quote whose deposit swaps on the source chain.
GET
/
v1
/
quotes
/
{quote_hash}
/
instructions
GetSwapInstructions
curl --request GET \
--url https://api.hular.dev/json/v1/quotes/{quote_hash}/instructionsimport requests
url = "https://api.hular.dev/json/v1/quotes/{quote_hash}/instructions"
response = requests.get(url)
print(response.text)const options = {method: 'GET'};
fetch('https://api.hular.dev/json/v1/quotes/{quote_hash}/instructions', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.hular.dev/json/v1/quotes/{quote_hash}/instructions",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.hular.dev/json/v1/quotes/{quote_hash}/instructions"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.hular.dev/json/v1/quotes/{quote_hash}/instructions")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.hular.dev/json/v1/quotes/{quote_hash}/instructions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body{
"router_address": "<string>",
"src_token": "<string>",
"amount_in": "<string>",
"bridge_token": "<string>",
"min_bridge_out": "<string>",
"evm": {
"aggregator": "<string>",
"swap_calldata": "<string>",
"value": "<string>"
},
"svm": {
"setup": [
{
"program_id": "<string>",
"accounts": [
{
"pubkey": "<string>",
"is_signer": true,
"is_writable": true
}
],
"data": "<string>"
}
],
"swap": {
"program_id": "<string>",
"accounts": [
{
"pubkey": "<string>",
"is_signer": true,
"is_writable": true
}
],
"data": "<string>"
},
"cleanup": [
{
"program_id": "<string>",
"accounts": [
{
"pubkey": "<string>",
"is_signer": true,
"is_writable": true
}
],
"data": "<string>"
}
],
"lookup_tables": [
{
"address": "<string>",
"addresses": [
"<string>"
]
}
],
"allowed_swap_programs": [
"<string>"
],
"swap_programs_signature": "<string>"
}
}{
"code": 123,
"message": "<string>",
"details": [
{}
]
}rpc GetSwapInstructions(SwapInstructionsRequest) returns (SwapInstructions)
order_params.src_token differs from order_params.bridge_token_src. Call it immediately before sending the deposit; routing reflects pool state at build time.
Request
string
required
Hash returned by
GetQuote.Response
string
Contract the deposit call goes to: the
HularRouter on EVM chains, the program id on Solana.string
Input token.
string
Input amount, base units.
string
Output token of the swap. For a cross-chain quote this is the asset that bridges; for a same-chain quote it is the destination token.
string
Floor the swap output is checked against on chain.
payload is a oneof matching the source chain’s VM.
EVM: evm
string
Aggregator the router will call. Allowlisted on the contract.
string
0x hex calldata to pass through.string
Transaction value to attach. Non-zero only when the source token is the chain’s native asset.
Solana: svm
SvmInstruction[]
Instructions to run before the swap, such as creating token accounts.
SvmInstruction
The aggregator swap instruction. The deposit wraps it in the program’s
deposit_swap instruction, which runs the swap and checks the output against min_bridge_out.SvmInstruction[]
Instructions to run after the swap.
SvmLookupTable[]
Address lookup tables to attach to the versioned transaction.
SvmInstruction carries program_id, accounts (pubkey, is_signer, is_writable), and base64 data.
Using it
On EVM, map the fields straight onto the router call:const swap = await hular.getSwapInstructions({ quoteHash });
if (swap.payload.case !== "evm") throw new Error("expected evm instructions");
const evm = swap.payload.value;
await wallet.sendTransaction({
to: swap.routerAddress,
value: BigInt(evm.value),
data: encodeFunctionData({
abi: routerAbi,
functionName: "depositWithSwap",
args: [
quoteHash,
swap.srcToken,
BigInt(swap.amountIn),
evm.aggregator,
evm.swapCalldata,
swap.bridgeToken,
BigInt(swap.minBridgeOut),
],
}),
});
buildSvmSwapDeposit in the SDK assembles the versioned transaction from the payload. Same-chain quotes on EVM use the same instructions with swapAndForward instead; see Same-chain swaps.
Errors
| Code | Message | When |
|---|---|---|
INVALID_ARGUMENT | quote is not a source swap | The quote’s source token is already the bridge token. No instructions exist. |
INVALID_ARGUMENT | invalid quote hash | Not a 32-byte hex hash. |
NOT_FOUND | quote not found or expired | No stored quote with that hash. |
UNAVAILABLE | aggregator error | The aggregator failed or returned no route. |
UNAVAILABLE | source route output below committed minimum | The live route no longer clears the floor committed in the quote. Re-quote. |
Headers
Optional. Without a key the request is rate limited per client IP and quotes carry extra spread.