Skip to content

Commit

Permalink
fixup! Update getInOutTokenAddresses to use EdgeTokens
Browse files Browse the repository at this point in the history
  • Loading branch information
peachbits committed Sep 22, 2023
1 parent 29dfd52 commit eb14fb9
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/swap/defi/defiUtils.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { asMaybe, asObject, asString } from 'cleaners'
import { EdgeCurrencyConfig, EdgeToken } from 'edge-core-js/types'
import { ethers } from 'ethers'

Expand All @@ -14,6 +15,10 @@ export interface InOutTokenAddresses {
isToWrappedCurrency: boolean
}

const asContractLocation = asObject({
contractAddress: asString
})

/**
* Determine if the tokens are wrapped and return the appropriate wrapped
* contract addresses, if different.
Expand All @@ -36,9 +41,11 @@ export const getInOutTokenAddresses = (
? undefined
: allTokens[toTokenId]

const fromTokenAddress: string =
fromToken?.networkLocation?.contractAddress ?? ''
const toTokenAddress: string = toToken?.networkLocation?.contractAddress ?? ''
const fromTokenAddress =
asMaybe(asContractLocation)(fromToken?.networkLocation)?.contractAddress ??
''
const toTokenAddress =
asMaybe(asContractLocation)(toToken?.networkLocation)?.contractAddress ?? ''

const isFromWrappedCurrency =
fromTokenAddress.toLowerCase() === wrappedMainnetAddress.toLowerCase()
Expand Down

0 comments on commit eb14fb9

Please sign in to comment.