The Gator SDK provides easy programmatic access to decentralized exchanges on NEAR.
1. Compute Swap Routes
A typical usage is to find the best swap route. This is what you can access on the gator.fi web page:
import { Gator } from'@gator/sdk';constgator=newGator();constroutes gator.computeRoutes({ input:'wrap.near', output:'aurora.near', amount:'3'});consttxs=gator.generateTransactions(routes[0]);// Transactions are ready to be signed and sent to blockchainawaitwallet.signAndSendTransactions({ transactions: txs });
2. Find Best Bid/Offer - simple arbitrage bot
The Gator SDK also allows you to find the best bid/offer across decentralized exchanges on NEAR. The functions computeBestBid and computeBestOffer does the necessarily conversion so the numbers fit into a traditional base/quote pair paradigm. For example, we can use the Gator SDK to implement a simple arbitrage strategy: