synapsecns/sanguine

View on GitHub
packages/rest-api/src/validations/validSwapTokens.ts

Summary

Maintainability
A
0 mins
Test Coverage
import { tokenAddressToToken } from '../utils/tokenAddressToToken'

export const validSwapTokens = (
  chain: number | string,
  fromToken: string,
  toToken: string
) => {
  const fromTokenInfo = tokenAddressToToken(chain.toString(), fromToken)
  const toTokenInfo = tokenAddressToToken(chain.toString(), toToken)

  if (!fromTokenInfo || !toTokenInfo) {
    return false
  }

  return fromTokenInfo.swappable.includes(toToken)
}