synapsecns/sanguine

View on GitHub
packages/synapse-interface/actions/swapPoolCalculateAddLiquidity.ts

Summary

Maintainability
A
0 mins
Test Coverage
import { readContract } from '@wagmi/core'

import { Token } from '@/utils/types'
import { SYNAPSE_ROUTER_ABI } from '@/constants/abis/synapseRouter'
import { wagmiConfig } from '@/wagmiConfig'

const ROUTER_ADDRESS = '0x7E7A0e201FD38d3ADAA9523Da6C109a07118C96a'

export const swapPoolCalculateAddLiquidity = async ({
  chainId,
  pool,
  inputs,
}: {
  chainId: number
  pool: Token
  inputs: bigint[]
}) => {
  const amount = await readContract(wagmiConfig, {
    chainId,
    address: ROUTER_ADDRESS,
    abi: SYNAPSE_ROUTER_ABI,
    functionName: 'calculateAddLiquidity',
    args: [pool.swapAddresses[chainId], inputs],
  })
  return amount
}