GooseFX GAMMA Swap API is based on Jupiter API client (https://github.com/jup-ag/jupiter-swap-api-client). It can be run in either rpc-polling mode or grpc-sub mode. GRPC is preferred for performance. It is also wire-compatible with the Jupiter swap-api so existing clients can be used for it.
The server relies on the qn_estimatePriorityFees endpoint for automatically setting automatic priority fees by request. This is the only additional dependency apart from rpc and grpc. As for referral fees, we have integrated this program with ours, and anyone can get a share of trade fees by creating a referral account and referral token-accounts. This setup will have to be done separately however. The swap-api will pass these accounts to the swap instructions only if a referral-account is specified. Otherwise, swaps will still work, but no fees will be shared.
-
cargo run use-rpc
to run in rpc-polling mode. This requires that theRPC_NEW_POOLS_FREQUENCY
andRPC_ACCOUNT_REFRESH_FREQUENCY
env variables be set, or passed as args withgpa-poll-frequency-seconds
andrefresh-frequency-seconds
respectively -
cargo run use-grpc
to run in grpc-subscription mode. This requires a compulsoryGRPC_ADDR
value and optionalGRPC_X_TOKEN
value to be present in the env or passed as args instead withaddr
andx-token
respectively.
Flags include:
[Required]
The Solana Json-RPC endpoint:--rpc-url
orRPC_URL
in env[Required]
The Amm config address:--amm-config
orAMM_CONFIG
in env[Required]
The Amm program-id:--amm-program-id
orAMM_PROGRAM_ID
in env[Required]
The server host configuration:--host
orHOST
in env[Required]
The server port configuration:--port
orPORT
in env[Required]
The blockhash poll frequency:--blockhash-poll-frequency
orBLOCKHASH_POLL_FREQUENCY
in env[Optional]
URL to a Quicknode-hosted priority-fee endpoint:--priofee-url
orPRIOFEE_URL
in env. Note: The binary will still run if this isn't specified, it will lack support for automatically setting priority fees on the user's transaction.[Optional]
Address of the referral account for getting a share of swap fees:--referral-account
orREFERRAL_ACCOUNT
in env[Optional]
Override the default duration(in seconds) between updating the priofee response:priofee-poll-frequency-secs
orPRIOFEE_POLL_FREQUENCY_SECS
in env[Optional]
Override the default number of blocks considered for the priority-fee response:priofee-n-blocks
orPRIOFEE_N_BLOCKS
in env[Optional]
Override the referral program. GAMMA currently uses this program deployed on mainnet at REFER4ZgmyYx9c6He5XfaTMiGfdLwRnkV4RPp9t9iF3
The package also includes a binary for making swaps with the http-api. First run the binary with the steps above and then cargo run --bin swap
to make a mainnet swap for 0.01 SOL -> USDC
. This requires that a keypair.json
file containing a funded wallet's keypair be present in the workspace root.
Note! Low liquidity in Gamma pools atm might result in a high price-impact and less output for your trades.
cargo run --bin quote
to demo getting a quote from the swap APIcargo run --bin swap
to demo swapping 0.01 SOL for USDC using the swap API. This requires akeypair.json
file to be present in the root