Drivers participate in on-chain auctions to compete for the opportunity to fulfill user intents, ensuring that users receive the best possible outcomes for their transactions. They act as the operational core that processes and completes transactions by finding optimal execution paths. In other protocols, this role is commonly known as a Solver or Relayer, but we refer to them as Drivers to emphasize their dynamic role in navigating and steering transactions to successful completion.
Copy .env.sample
into .env
and set the required values including:
-
JUP_V6_ENDPOINT
for using custom or self hosted jup endpoint -
JUP_API_KEY
for swapping on Solana via Jupiter jup.ag -
ONE_INCH_API_KEY
for swapping on EVM chains via 1inch -
EVM_PRIVATE_KEY
Hex encoded private key of your EVM wallet (for all chains) -
SOLANA_PRIVATE_KEY
Base-58 encoded private key of your Solana wallet -
XXX_RPC
Your desired rpc for chainXXX
. We strongly encourage getting private rpcs with higher throughputs but default public rpcs are provided
Optional .env
overrides:
ETHEREUM_FLASHBOT_RPC
writes to ethereum are sent thorugh flashbots rpc to avoid expensive revert costs. You could provide something elseSOLANA_SEND_RPCS
solana transactions are broadcasted to multiple rpcs to decrease transacttion landing times
Install NodeJS (node 20 is recommended)
npm install
npx ts-node .
You only need to provide native USDC
and ETH
(wormhole's WETH
on solana) to fulfill swaps. Based on the source asset (which is either USDC
or ETH
) the equivalent asset is chosen on the destination chain and used to fulfill the order via a simple transfer or in-chain swap using swap aggregators.
-
User submits their swap on-chain or off-chain (for gasless swaps)
-
Mayan explorer indexes the swap and notifies registered drivers (via websockets or long polling)
-
Driver receives the swap and starts bidding on the auction using the mayan auction program's
bid
instruction -
- If the destination is solana, driver registers itself as winner using mayan program's
registerWinner
instruction 2. If the destination is an evm chain, driver posts a wormhole message to the destination chain using mayan progarm'spostAuction
instruction
- If the destination is solana, driver registers itself as winner using mayan program's
-
Driver fulfills the auction on the destination chain: 1. On solana the driver sends a transaction that transfers assets and calls the mayan programs
fulfill
instruction 2. On evm chains the driver gets the wormhole signed VAA and uses the proof of auction to fulfill the promised amount using eitherfulfillOrder
method of the main contract orfulfillWithERC20,fulfillWithEth
methods of the fulfill helper contract. -
If the destination chain is solana, another step is required for completiion. Driver calls the
settle
instruction of the mayan programs. -
After fulfilling multiple orders, fulfillment proofs are gathered in batch using
postBatch
solana instruction or evm method. Then signed VAAs are using in source chains to unlock assets. If the order was fulfilled without batch, proof will be immediatelly issues and available after being signed by wormhole gaurdians
- routers.ts Helper functions for fetching intra-chain swap params from swap aggregators like jupiter or 1inch
- register.ts registers the driver wallets to mayan backend. This helps us provide more accurate quotes according to driver balances. It also ensures that your AddressLookupTables are indexed properly
- unlocker.ts responsible for unlocking fulfilled swaps
- lut.ts tries to use existing mayan AddressLookupTables to fit transactions. Creates new tables otherwise. These tables are indexed via mayan and closed later on
- finality.ts Provides a balance between risk of block reversal and fast fulfillment