Integration Guide (onchain quoting)
1. Pool Discovery
ABI
function getRouters() external view returns (address[] memory routers)function getRouterPools(address router) external view returns (address[] memory assets, address[] memory pools)
Ethers.js example
import { ethers } from "ethers";
const portalAddress = process.env.PORTAL_ADDRESS;
const provider = new ethers.JsonRpcProvider(process.env.RPC_URL);
const portalAbi = [
"function getRouters() external view returns (address[])",
"function getRouterPools(address router) external view returns (address[])"
];
const portal = new ethers.Contract(
portalAddress,
portalAbi,
provider
);
async function discoverPools() {
const routers = await portal.getRouters();
console.log("Routers:", routers);
const pools = await portal.getRouterPools(routers[0]);
const [poolAddresses, assetAddresses] = pools;
console.log("Pools and assets for router 0:");
poolsAddresses.forEach((pool, i) => {
console.log("Pool:", pool, "Asset:", assetAddresses[i])
})
return {router: routers[0], assets: assetAddresses};
}
discoverPools();2. Quoting
ABI
Ethers.js example
3. Swapping
ABI
Ethers.js example
4. Full flow example
Done ☺️
Last updated