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-rpcto run in rpc-polling mode. This requires that theRPC_NEW_POOLS_FREQUENCYandRPC_ACCOUNT_REFRESH_FREQUENCYenv variables be set, or passed as args withgpa-poll-frequency-secondsandrefresh-frequency-secondsrespectively -
cargo run use-grpcto run in grpc-subscription mode. This requires a compulsoryGRPC_ADDRvalue and optionalGRPC_X_TOKENvalue to be present in the env or passed as args instead withaddrandx-tokenrespectively.
Flags include:
[Required]The Solana Json-RPC endpoint:--rpc-urlorRPC_URLin env[Required]The Amm config address:--amm-configorAMM_CONFIGin env[Required]The Amm program-id:--amm-program-idorAMM_PROGRAM_IDin env[Required]The server host configuration:--hostorHOSTin env[Required]The server port configuration:--portorPORTin env[Required]The blockhash poll frequency:--blockhash-poll-frequencyorBLOCKHASH_POLL_FREQUENCYin env[Optional]URL to a Quicknode-hosted priority-fee endpoint:--priofee-urlorPRIOFEE_URLin 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-accountorREFERRAL_ACCOUNTin env[Optional]Override the default duration(in seconds) between updating the priofee response:priofee-poll-frequency-secsorPRIOFEE_POLL_FREQUENCY_SECSin env[Optional]Override the default number of blocks considered for the priority-fee response:priofee-n-blocksorPRIOFEE_N_BLOCKSin 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 quoteto demo getting a quote from the swap APIcargo run --bin swapto demo swapping 0.01 SOL for USDC using the swap API. This requires akeypair.jsonfile to be present in the root