External Router Migration
Copy // Ethereum
address router = 0x533E164ded63f4c55E83E1f409BDf2BaC5278035 ;
CrocSwapRouter (router). swap (
base ,
quote ,
poolIdx ,
isBuy ,
inBaseQty ,
qty ,
tip ,
limitPrice ,
minOut ,
settleFlags);
//Scroll
address router = 0xfB5f26851E03449A0403Ca945eBB4201415fd1fc ;
CrocSwapRouter (router). swap (
base ,
quote ,
poolIdx ,
isBuy ,
inBaseQty ,
qty ,
tip ,
limitPrice ,
minOut ,
settleFlags);
Copy const { ethers } = require ( 'ethers' );
const provider = new ethers . providers .JsonRpcProvider ( ... );
const routerAbi = ... // See below
const etherRouterAddr = "0x533E164ded63f4c55E83E1f409BDf2BaC5278035"
const scrollRouterAddr = "0xfB5f26851E03449A0403Ca945eBB4201415fd1fc"
const contract = new ethers .Contract (etherRouterAddr , routerAbi , provider);
contract .swap (
baseAddress ,
quoteAddress ,
420 ,
isBuy ,
inBaseQty ,
qty ,
0 ,
limitPrice ,
minOut ,
0 );
Copy [
{
"inputs" : [
{
"internalType" : "address" ,
"name" : "base" ,
"type" : "address"
} ,
{
"internalType" : "address" ,
"name" : "quote" ,
"type" : "address"
} ,
{
"internalType" : "uint256" ,
"name" : "poolIdx" ,
"type" : "uint256"
} ,
{
"internalType" : "bool" ,
"name" : "isBuy" ,
"type" : "bool"
} ,
{
"internalType" : "bool" ,
"name" : "inBaseQty" ,
"type" : "bool"
} ,
{
"internalType" : "uint128" ,
"name" : "qty" ,
"type" : "uint128"
} ,
{
"internalType" : "uint16" ,
"name" : "tip" ,
"type" : "uint16"
} ,
{
"internalType" : "uint128" ,
"name" : "limitPrice" ,
"type" : "uint128"
} ,
{
"internalType" : "uint128" ,
"name" : "minOut" ,
"type" : "uint128"
} ,
{
"internalType" : "uint8" ,
"name" : "reserveFlags" ,
"type" : "uint8"
}
] ,
"name" : "swap" ,
"outputs" : [
{
"internalType" : "int128" ,
"name" : "baseFlow" ,
"type" : "int128"
} ,
{
"internalType" : "int128" ,
"name" : "quoteFlow" ,
"type" : "int128"
}
] ,
"stateMutability" : "payable" ,
"type" : "function"
} ,
]
Swapping to/from dex balance surplus collateral is not available through this contract.