Abstract
Following the deployment of Pyth Express Relay on Solana (OP-PIP38), this proposal aims to upgrade the Pyth Express Relay Program to support direct swaps with the searchers.
Rationale
Pyth Express Relay auction mechanism released in OP-PIP38 has been successfully integrated by Kamino to build Limit Orders . In the current model, searchers bid for the right of fulfilling orders in the Kamino Limit Order program, leveraging Pyth Express Relay’s off-chain auction. A portion of the searcher bids (currently 47%) is retained by the DAO.
This integration is attracting volume (100M since early December) and producing revenue for the DAO (130 SOL).
Given this success, we are proposing to extend Pyth Express Relay on Solana to allow transacting directly with the searchers. This effectively implements market orders and will allow Pyth Express Relay to tap into the 500M+ daily volume of swaps on Solana.
Description
This change will enable creating a quote API for Pyth Express Relay, similar to the API of swap aggregators. Integrators will be able to call it from their frontend to route users’ swap orders to the searchers.
The off-chain auction is preserved and the searcher that provides the best price will receive the order-flow.
Swaps will be subject to two fees, payable in the user provided token or the searcher provided token:
- A referral fee, set by the integrator
- A platform fee, set by the DAO. The platform fee is redistributed to:
- The relayer (currently 6%)
- The DAO (currently 94%)
The platform and the platform fee split are set by the DAO. We suggest initially setting the platform fee to 0bps.
Implementation Plan
-
Proposal id: DU8N4MCUxjDSbiuy7NejrzeyvgB1fw82WjNae1nnMCKW
-
Extend the Pyth Express Relay Program with a
swap
instruction:- feat: swap program v2 by guibescos · Pull Request #304 · pyth-network/per · GitHub added a
swap
instruction with takes in a user’s token accounts and a searcher’s token accounts and their signatures and performs a swap ensuring all the referral and platform fees are paid. - feat(swap): add deadline by guibescos · Pull Request #313 · pyth-network/per · GitHub added a deadline so searchers can know for how long their quote might be valid.
- Fix/improve quote api by anihamde · Pull Request #366 · pyth-network/per · GitHub renamed some accounts in the code to increase readability.
- Add relayer signer to ER swap by danimhr · Pull Request #377 · pyth-network/per · GitHub added a third signer, the relayer, that will only sign the transaction if the searcher has won the auction.
- feat: add good errors to the svm program by guibescos · Pull Request #406 · pyth-network/per · GitHub improved some of the error handling, adding some extra error variants so that the reason for on-chain failures can be identified better.
- feat: swap program v2 by guibescos · Pull Request #304 · pyth-network/per · GitHub added a
-
Verification steps (Skip to step 12 if you don’t want to build the program locally):
- Make sure you have git, rust and Docker installed.
- git: install
git
from here - rust: install
rust
from here - Docker: install Docker from here
- Install the
solana
cli:sh -c "$(curl -sSfL https://release.anza.xyz/stable/install)"
- Install the
solana-verify
cli :cargo install solana-verify --git https://github.com/Ellipsis-Labs/solana-verifiable-build --rev 121568e
- clone the per repo by running the following command:
git clone
https://github.com/pyth-network/per
- change your directory to
per/contracts/svm
by doingcd per/contracts/svm
- checkout commit
00940ec
by doinggit checkout 00940ec5d4c6cb8c2c23870daa98bdf1ece14680
- Build the program by running
solana-verify build
- Check the hash of the artifact
sha256sum target/deploy/express_relay.so
- Alternatively you can check the hash in this Github workflow that builds the program feat: add good errors to the svm program (#406) · pyth-network/per@00940ec · GitHub in “Print Hash”.
- check the hash of the deployed buffer
solana program -u m dump BHGHV3BthoKgrBMiVud6xvNCLN9hokTecPX7fL8UU29B temp_file && sha256sum temp_file && rm temp_file
- Make sure the hash from step 11 (or 12) and 13 match
- Make sure the upgrade authority of the buffer
BHGHV3BthoKgrBMiVud6xvNCLN9hokTecPX7fL8UU29B
is the Pythian Council6oXTdojyfDS8m5VtTaYB9xRCxpKGSvKJFndLUPV3V3wT