dApp Integration Guide
Integration Flow
The integration flow consists of two paths: a traditional DEX flow and an Atlas flow with MEV protection. Here's how it works:
- User enters their swap details and toggles MEV protection
- If MEV protection is disabled:
- User approves the dApp router
- Transaction is sent directly to the dApp router
- Standard DEX confirmation process
- If MEV protection is enabled:
- User approves the Atlas router
- Transaction is sent to Fastlane's auction system
- Fastlane returns an optimized transaction
- User signs and submits the Atlas transaction
- Transaction is confirmed with MEV protection
Fastlane Setup
- Fastlane smart contract needs to enable the dApp router address through an onchain transaction
- Fastlane auctioneer needs the dApp router ABI in order to decode transactions
Frontend Integration
-
Toggle to allow user's to opt-in to Fastlane MEV Protection
- Most dApps make MEV protection an opt-in feature, but it doesn't have to be opt-in, it can also be opt-out.
-
Approve
- When doing the approval transaction, you need to make sure to approve the correct router.
- If toggle on → approve Atlas Router
- If toggle off → approve dApp Router
-
Allowance
- After a user has done an approval transaction, you need to make sure that any allowance checks use the correct router.
- Note that if the user were to do the approval on one router and then toggle the MEV Protection before actually doing the swap, then they would need to do a new approval transaction on the correct router.
- If toggle on → check allowance of Atlas Router
- If toggle off → check allowance of dApp Router
- After a user has done an approval transaction, you need to make sure that any allowance checks use the correct router.
-
Swap
- The user should only be able to click the swap button after the appropriate allowance check above. Clicking swap, sends the below payload to the Fastlane auction. The auction will return the transaction details that the user needs to sign and submit for inclusion in the next block.
- If toggle on → swap on Atlas Router
- If toggle off → swap on dApp Router
// ATLAS SWAP
interface AtlasResponse {
from: Hex;
to: Hex;
value: Hex;
data: Hex;
gas: Hex;
maxFeePerGas: Hex;
}
const auctioneerEndpoint = process.env.ATLAS_AUCTIONEER;
const refundRecipient = process.env.ATLAS_REFUND_RECIPIENT;
const refundPercent = process.env.ATLAS_REFUND_PERCENT;
const payload = {
jsonrpc: "2.0",
method: "atlas_sendUnsignedTransaction",
params: [{
// All transaction values MUST be hex strings '0x...'
transaction: {
chainId: chainId,
//pass normal tx details for user's swap
from: userAddress,
to: dAppRouter, //NOT ATLAS - use same tx details as a normal protocol swap
value: value,
data: data,
maxFeePerGas: maxFeePerGas,
},
refundRecipient: refundRecipient,
refundPercent: refundPercent,
bidTokenIsOutputToken: true, //use false to receive bid in native token
}],
id: 1
};
try {
const response = await fetch(auctioneerEndpoint, {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify(payload)
});
//...handle response to sign and submit the transaction...
const result = await response.json() as AtlasResponse;
const hash = await eoaClient.sendTransaction({
to: result.to,
value: BigInt(result.value),
gas: BigInt(result.gas),
maxFeePerGas: BigInt(result.maxFeePerGas),
data: result.data,
});
await publicClient.waitForTransactionReceipt({ hash });
} catch (error) {
//...handle error...
console.error("Error sending Atlas unsigned transaction:", error);
throw error;
}
Environment Variables
ATLAS_ROUTER
: 0x4a730A56344873FB28f7C3d65A67Fea56f5e0F46ATLAS_AUCTIONEER=https://auctioneer-fra.fastlane-labs.xyz
ATLAS_REFUND_RECIPIENT=<YOUR_PROTOCOL_REFUND_ADDRESS>
- the user gets 90% of MEV captured, but dApps can add an extra refund recipient to split the 90%
ATLAS_REFUND_PERCENT=<0-90>
- Can be anything between 0 and 90. If set to 0, the user gets 90%, if set to 90, the user gets 0% and the refundRecipient gets 90%.
Chain Support
- Monad Testnet (10143)
- All EVM Chains…coming soon!
- If there is a specific chain you want to see supported, please reach out!