βοΈDeveloper Guide
1. Compute Swap Routes
import { Gator } from '@gator/sdk';
const gator = new Gator();
const routes gator.computeRoutes({
input: 'wrap.near',
output: 'aurora.near',
amount: '3'
});
const txs = gator.generateTransactions(routes[0]);
// Transactions are ready to be signed and sent to blockchain
await wallet.signAndSendTransactions({ transactions: txs });2. Find Best Bid/Offer - simple arbitrage bot
while (true) {
const base = 'aurora.near';
const quote = 'wrap.near';
// Aggregate bid / ask levels within 10 bips
const bestBid = gator.computeBestBid({ base, quote }, 0.001);
const bestOffer = gator.computeBestOffer({ base, quote }, 0.001);
if (bestBid['price'] < bestOffer['price']) {
const amount = Math.min(bestBid['amount'], bestOffer['amount'])
await wallet.signAndSendTransactions({
transactions: [
...gator.generateTransactions({ ...bestBid, amount }),
...gator.generateTransactions({ ...bestOffer, amount }),
]
})
}
await new Promise((r) => setTimeout(r, 5000));
}Last updated