Skip to content

multiplecall query quote #838

Open
Open
@hubuyt001

Description

@hubuyt001

now i query a pair quote like code
`const jsonRpcProvider = new ethers.providers.JsonRpcProvider(
rpcUrl,
);
const router = new AlphaRouter({
chainId: ChainId.MAINNET,
provider: jsonRpcProvider,
})

const options: SwapOptionsSwapRouter02 = {
recipient: walletAddress,
slippageTolerance: new Percent(
slippageBps * 100,
100 * 100
),
deadline: Math.floor(Date.now() / 1000 + 1800),
type: SwapType.SWAP_ROUTER_02,
}
const context = new NodeContext('ETH');
let inputToken: Token = await context.getTokenMintInfo(
rpcUrl,
inputMint
);

let outputToken: Token = await context.getTokenMintInfo(
rpcUrl,
outputMint
);

const route = await router.route(
CurrencyAmount.fromRawAmount(
inputToken,
amount.toString()
),
outputToken,
TradeType.EXACT_INPUT,
options
)
if (route) {
const executionPrice = route.quote.toFixed(6); // Price after trade
const midPrice = route.trade.executionPrice.toFixed(6); // Mid-market price
// Calculate price impact
const priceImpact = parseFloat(route.trade.priceImpact.toSignificant(6));
logger.info('Execution Price: $',executionPrice);
logger.info('Mid Price: ', midPrice);
logger.info('Price Impact: ', priceImpact);
}
throw new Error("Failed to get quote");`

now i want to batch query , can query the quotes of about 20 currency pairs in one query.
Using multiplecall2 technology, const route = await router.route(
CurrencyAmount.fromRawAmount(
inputToken,
amount.toString()
),
outputToken,
TradeType.EXACT_INPUT,
options
) What is the contract address of route? What is the name of the route method in the contract?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions