SDKs@solio/coreContractsRoutergetAmountOut

getAmountOut()

function getAmountOut(client, props): Promise<{
  receiveAmount: bigint;
  raisingAmount: bigint;
 }>

Calculates the output amount for a given input amount and token addresses using the router contract.

Parameters

ParameterTypeDescription
clientReadClientThe read client to use for the contract call.
propsRouterGetAmountOutPropsAn object containing the properties for the function.
type RouterGetAmountOutProps: {
  address: Address;
  payAddress: Address;
  receiveAddress: Address;
  payAmount: bigint;
};

Returns

Promise<{ receiveAmount: bigint; raisingAmount: bigint; }>

A promise that resolves to an object containing the receive and raising amounts.

Example

router.ts
import { router } from '@solio/core';
import { createClient, http } from 'viem';
import { sepolia } from 'viem/chains';
const readClient = createClient({
 chain: sepolia,
 transport: http(),
})
const { receiveAmount, raisingAmount } = await router.read.getAmountOut(readClient, {
 address: '0x...', // router contract address
 payAddress: '0x...',
 receiveAddress: '0x...',
 payAmount: 100n
});
console.log(receiveAmount,raisingAmount);