Skip to content

Commit

Permalink
improve types
Browse files Browse the repository at this point in the history
  • Loading branch information
Diogomartf committed Jan 4, 2024
1 parent 05505c2 commit 714ba03
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/entities/trades/swapr-v3/SwaprV3.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { BaseProvider } from '@ethersproject/providers'
import dayjs from 'dayjs'

import { Currency as CurrencyType, Fraction, validateAndParseAddress } from '@uniswap/sdk-core'
import { Fraction, validateAndParseAddress } from '@uniswap/sdk-core'
import invariant from 'tiny-invariant'

import { CurrencyAmount, Percent, Price, TokenAmount } from '../../fractions'
Expand All @@ -14,7 +14,6 @@ import { ChainId, ONE, TradeType } from '../../../constants'
import { UnsignedTransaction } from 'ethers'
import { TradeOptions } from '../interfaces/trade-options'
import { parseUnits } from '@ethersproject/units'
import { Route } from './entities/route'
import { SWAPR_ALGEBRA_CONTRACTS } from './constants'
import { getQuoterContract, getRouterContract } from './contracts'
import { getRoutes } from './routes'
Expand Down Expand Up @@ -107,6 +106,7 @@ export class SwaprV3Trade extends TradeWithSwapTransaction {
`SwaprV3Trade.getQuote: currencies chainId does not match provider's chainId`
)

const routes = await getRoutes(tokenIn, tokenOut, chainId)
const routes: Route<CurrencyType, CurrencyType>[] = await getRoutes(tokenIn, tokenOut, chainId)

const fee =
Expand Down
5 changes: 2 additions & 3 deletions src/entities/trades/swapr-v3/pools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@ import { computePoolAddress } from './utils/computePoolAddress'
import { Pool } from './entities/pool'
import { getPoolsContract } from './contracts'
import { ChainId } from '../../../constants'
import { WXDAI } from '../../token'

const getBaseTokens: Token[] = baseTokens.map(
({ address, decimals, symbol, name }) => new Token(ChainId.GNOSIS, address, decimals, symbol, name)
)

const WXDAI_ADDRESS = '0xe91D153E0b41518A2Ce8Dd3D7944Fa863463a97d'

const currencyAddress = (currency: Currency) => {
return currency.isNative ? WXDAI_ADDRESS : currency.address
return currency.isNative ? WXDAI[ChainId.GNOSIS].address : currency.address
}

export const setupTokens = (currencyIn: Currency, currencyOut: Currency) => {
Expand Down
6 changes: 1 addition & 5 deletions src/entities/trades/swapr-v3/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,7 @@ export function computeAllRoutes(
return allPaths
}

export async function getRoutes(
currencyIn: any,
currencyOut: any,
chainId: number
): Promise<Route<Currency, Currency>[]> {
export async function getRoutes(currencyIn: any, currencyOut: any, chainId: number) {
const pools = await getPools(currencyIn, currencyOut)
return computeAllRoutes(pools, chainId, [], [], 3)
}

0 comments on commit 714ba03

Please sign in to comment.