Skip to content
This repository has been archived by the owner on Jan 15, 2021. It is now read-only.

xDAI Config changes #1429

Merged
merged 14 commits into from
Sep 22, 2020
29 changes: 28 additions & 1 deletion config-default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ dexPriceEstimator:
url_production: https://dex-price-estimator.rinkeby.gnosis.io
url_develop: https://price-estimate-rinkeby.dev.gnosisdev.com

- networkId: 100
# TODO: No production URL yet. For now, using DEV also in PRODUCTION
#url_production: https://dex-price-estimator.xdai.gnosis.io
url_production: https://price-estimate-xdai.dev.gnosisdev.com
url_develop: https://price-estimate-xdai.dev.gnosisdev.com

# Subgraph abstraction, used for getting the last price
theGraphApi:
type: 'the-graph' # choices: the-graph
Expand All @@ -63,6 +69,9 @@ theGraphApi:
- networkId: 4
url: https://api.thegraph.com/subgraphs/name/gnosis/protocol-rinkeby

- networkId: 100
url: https://api.thegraph.com/subgraphs/name/gnosis/protocol-xdai

# Eth node config
defaultProviderConfig:
type: 'infura' # Choices: infura | url
Expand All @@ -84,6 +93,8 @@ exchangeContractConfig:
blockNumber: 9340147
- networkId: 4
blockNumber: 5844678
- networkId: 100
blockNumber: 11948310

# Wallet Connect
walletConnect:
Expand Down Expand Up @@ -133,6 +144,7 @@ disabledTokens:
- address: '0x6Fb0855c404E09c47C3fBCA25f08d4E41f9F062f'
- address: '0xFC4B8ED459e00e5400be803A9BB3954234FD50e3'
4: [] # Rinkeby
100: [] # xDAI

# Initial token selection for the sell token and buy token
initialTokenSelection:
Expand All @@ -150,6 +162,7 @@ initialTokenList:
addressByNetwork:
'1': '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'
'4': '0xc778417E063141139Fce010982780140Aa0cD5Ab'
'100': '0x6A023CCd1ff6F2045C3309768eAd9E68F978f6e1'

- id: 2
name: Tether USD
Expand All @@ -158,14 +171,15 @@ initialTokenList:
addressByNetwork:
'1': '0xdAC17F958D2ee523a2206206994597C13D831ec7'
'4': '0xa9881E6459CA05d7D7C95374463928369cD7a90C'
'100': '0x4ECaBa5870353805a9F068101A40E0f32ed605C6'

- id: 3
name: TrueUSD
symbol: TUSD
decimals: 18
addressByNetwork:
'1': '0x0000000000085d4780B73119b644AE5ecd22b376'
'4': '0x0000000000085d4780B73119b644AE5ecd22b376'
'4': '0x0000000000085d4780B73119b644AE5ecd22b376'
anxolin marked this conversation as resolved.
Show resolved Hide resolved

- id: 4
name: USD Coin
Expand All @@ -174,6 +188,7 @@ initialTokenList:
addressByNetwork:
'1': '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'
'4': '0x4DBCdF9B62e891a7cec5A2568C3F4FAF9E8Abe2b'
'100': '0xDDAfbb505ad214D7b80b1f830fcCc89B60fb7A83'

- id: 5
name: Paxos Standard
Expand All @@ -198,6 +213,7 @@ initialTokenList:
addressByNetwork:
'1': '0x6B175474E89094C44Da98b954EedeAC495271d0F'
'4': '0x5592EC0cfb4dbc12D3aB100b257153436a1f0FEa'
'100': '0x44fA8E6f47987339850636F88629646662444217'

- id: 8
name: Synth sETH
Expand All @@ -214,6 +230,7 @@ initialTokenList:
addressByNetwork:
'1': '0x57Ab1E02fEE23774580C119740129eAC7081e9D3'
'4': '0x1b642a124cdfa1e5835276a6ddaa6cfc4b35d52c'
'100': '0xB1950Fb2C9C0CbC8553578c67dB52Aa110A93393'

- id: 10
name: Synth sBTC
Expand Down Expand Up @@ -258,6 +275,7 @@ initialTokenList:
addressByNetwork:
'1': '0x6810e776880C02933D47DB1b9fc05908e5386b96'
'4': '0xd0Dab4E640D95E9E8A47545598c33e31bDb53C7c'
'100': '0x9C58BAcC331c9aa871AFD802DB6379a98e80CEdb'

- id: 19
name: Panvala pan
Expand All @@ -266,10 +284,19 @@ initialTokenList:
addressByNetwork:
'1': '0xD56daC73A4d6766464b38ec6D91eB45Ce7457c44'

- id: 20
name: STAKE
symbol: STAKE
decimals: 18
addressByNetwork:
'1': '0x0ae055097c6d159879521c384f1d2123d1f195e6'
'100': '0xb7D311E2Eb55F2f68a9440da38e7989210b9A05e'

- id: 0
name: OWL
symbol: OWL
decimals: 18
addressByNetwork:
'1': '0x1A5F9352Af8aF974bFC03399e3767DF6370d82e4'
'4': '0xa7D1C04fAF998F9161fC9F800a99A809b84cfc9D'
'100': '0x0905Ab807F8FD040255F0cF8fa14756c1D824931'
4 changes: 2 additions & 2 deletions src/api/deposit/DepositApi.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import BN from 'bn.js'
import { assert } from '@gnosis.pm/dex-js'
import { assert, toBN } from '@gnosis.pm/dex-js'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Importing toBN from dex-js is ok here because it ultimately comes from web3 which is a peer dep for dex-js and therefore local web3 is used. But I would be wary of just importing any utility function because of potential version conflictsor duplicating deps.

For example if we ever need a function that makes use of bignumber.js and import it by the way of dex-js, it would be good to move bignumber.js to peer deps too.


import { logDebug, toBN } from 'utils'
import { logDebug } from 'utils'
import { ZERO } from 'const'

import { BatchExchangeContract, batchExchangeAbi } from '@gnosis.pm/dex-js'
Expand Down
1 change: 1 addition & 0 deletions src/api/deposit/batchExchangeAddresses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ function _getAddress(networkId: number): string {
const addressesByNetwork = {
[Network.Rinkeby]: _getAddress(Network.Rinkeby),
[Network.Mainnet]: _getAddress(Network.Mainnet),
[Network.xDai]: _getAddress(Network.xDai),
}

export const getAddressForNetwork = (networkId: Network): string | null => {
Expand Down
4 changes: 2 additions & 2 deletions src/api/erc20/Erc20Api.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import BN from 'bn.js'
import { AbiItem } from 'web3-utils'
import { Erc20Contract } from '@gnosis.pm/dex-js'
import { Erc20Contract, toBN } from '@gnosis.pm/dex-js'
import erc20Abi from '@gnosis.pm/dex-js/build/contracts/abi/Erc20.json'

import { TxOptionalParams, Receipt } from 'types'
import { ZERO } from 'const'
import { logDebug, toBN } from 'utils'
import { logDebug } from 'utils'

import ERC20_DETAILS from 'api/erc20/erc20Details.json'

Expand Down
4 changes: 4 additions & 0 deletions src/api/gasStation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ import { WalletApi } from './wallet/WalletApi'
const GAS_STATIONS = {
1: 'https://safe-relay.gnosis.pm/api/v1/gas-station/',
4: 'https://safe-relay.staging.gnosisdev.com/api/v1/gas-station/',
// Pending price estimation

// TODO: Pending review what makes sense here. How do gas prices are stablished in xDAI network
100: undefined,
Comment on lines +8 to +9
Copy link
Contributor

@Velenir Velenir Sep 22, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does web3.eth.getGasPrice() return? Is it a variable number over time?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll find out soon enough, I'm making a PR only for the gas, see #1398

}

export type GasPriceLevel = Exclude<keyof GasStationResponse, 'lastUpdate'>
Expand Down
2 changes: 1 addition & 1 deletion src/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ function createExchangeApi(erc20Api: Erc20Api, injectedDependencies: DepositApiD
}

function createTokenListApi(): TokenList {
const networkIds = [Network.Mainnet, Network.Rinkeby]
const networkIds = [Network.Mainnet, Network.Rinkeby, Network.xDai]

let tokenListApi: TokenList
if (process.env.MOCK_TOKEN_LIST === 'true') {
Expand Down
3 changes: 2 additions & 1 deletion src/api/wallet/WalletApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@ import { Network, Command } from 'types'
import BN from 'bn.js'
import assert from 'assert'
import { getDefaultProvider } from '..'
import { toBN } from '@gnosis.pm/dex-js'

import Web3Modal, { getProviderInfo, IProviderOptions, IProviderInfo, isMobile } from 'web3modal'
import { IClientMeta } from '@walletconnect/types'

import Web3 from 'web3'
import { BlockHeader } from 'web3-eth'

import { logDebug, toBN, txDataEncoder, generateWCOptions } from 'utils'
import { logDebug, txDataEncoder, generateWCOptions } from 'utils'

import { subscribeToWeb3Event } from './subscriptionHelpers'
import { getMatchingScreenSize, subscribeToScreenSizeChange } from 'utils/mediaQueries'
Expand Down
3 changes: 2 additions & 1 deletion src/api/wallet/WalletApiMock.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { Network, Command } from 'types'
import BN from 'bn.js'
import assert from 'assert'
import { toWei } from '@gnosis.pm/dex-js'

import { logDebug, wait, toWei } from 'utils'
import { logDebug, wait } from 'utils'
import { USER_1, USER_2 } from '../../../test/data'
import { WalletApi, WalletInfo, ProviderInfo } from './WalletApi'

Expand Down
4 changes: 3 additions & 1 deletion src/api/weth/WethApi.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Web3 from 'web3'

import { Network, WithTxOptionalParams, Receipt } from 'types'
import { WETH_ADDRESS_MAINNET, WETH_ADDRESS_RINKEBY } from 'const'
import { WETH_ADDRESS_MAINNET, WETH_ADDRESS_RINKEBY, WETH_ADDRESS_XDAI } from 'const'
import { wethAbi } from '@gnosis.pm/dex-js'
import { logDebug } from 'utils'

Expand Down Expand Up @@ -31,6 +31,8 @@ function getWethAddressByNetwork(networkId: number): string {
return WETH_ADDRESS_MAINNET
case Network.Rinkeby:
return WETH_ADDRESS_RINKEBY
case Network.xDai:
return WETH_ADDRESS_XDAI
default:
throw new Error(`WethApi was not deployed to network ${networkId}`)
}
Expand Down
3 changes: 2 additions & 1 deletion src/components/OrderBookChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ import * as am4core from '@amcharts/amcharts4/core'
import * as am4charts from '@amcharts/amcharts4/charts'
import am4themesSpiritedaway from '@amcharts/amcharts4/themes/spiritedaway'

import { getNetworkFromId, safeTokenName } from 'utils'
import { safeTokenName } from 'utils'

import { TokenDetails, Network } from 'types'
import { getNetworkFromId } from '@gnosis.pm/dex-js'

export interface OrderBookChartProps {
/**
Expand Down
4 changes: 2 additions & 2 deletions src/components/TradesWidget/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { faFileCsv } from '@fortawesome/free-solid-svg-icons'
import styled from 'styled-components'

import { formatPrice, formatAmount, invertPrice, formatAmountFull } from '@gnosis.pm/dex-js'
import { formatPrice, formatAmount, invertPrice, formatAmountFull, getNetworkFromId } from '@gnosis.pm/dex-js'

import FilterTools from 'components/FilterTools'
import { CardTable } from 'components/layout/SwapLayout/Card'
Expand All @@ -22,7 +22,7 @@ import { Trade } from 'api/exchange/ExchangeApi'

import { toCsv, CsvColumns } from 'utils/csv'
import { filterTradesFn } from 'utils/filter'
import { getNetworkFromId, divideBN } from 'utils'
import { divideBN } from 'utils'
import { symbolOrAddress } from 'utils/display'

const OverflowContainer = styled(BalancesWidget)`
Expand Down
3 changes: 2 additions & 1 deletion src/components/UserWallet/WalletComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,12 @@ import useSafeState from 'hooks/useSafeState'
import { useConnectWallet } from 'hooks/useConnectWallet'
import useNoScroll from 'hooks/useNoScroll'

import { abbreviateString, getNetworkFromId } from 'utils'
import { abbreviateString } from 'utils'
// TODO: probably not do this
import WalletImg from 'assets/img/eth-network.svg'
import { Spinner } from 'components/common/Spinner'
import { walletApi } from 'api'
import { getNetworkFromId } from '@gnosis.pm/dex-js'

interface UserWalletProps extends RouteComponentProps {
className: string
Expand Down
7 changes: 3 additions & 4 deletions src/const.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,6 @@ if (process.env.ETH_NODE_URL) {
export const ETH_NODE_URL = ethNodeUrl

export const STORAGE_KEY_LAST_PROVIDER = 'lastProvider'
export const STORAGE_PENDING_ORDER_TX_HASHES = {
1: 'STORAGE_PENDING_ORDER_TX_HASHES_1',
4: 'STORAGE_PENDING_ORDER_TX_HASHES_4',
}
export const STORAGE_KEY_DISABLED_TOKENS_ADDRESSES = 'disabledTokens'

export const TRADES_LOCAL_STORAGE_KEY = 'TRADES_PER_ACCOUNT'
Expand All @@ -163,6 +159,8 @@ export const INPUT_PRECISION_SIZE = 6

export const WETH_ADDRESS_MAINNET = '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'
export const WETH_ADDRESS_RINKEBY = '0xc778417E063141139Fce010982780140Aa0cD5Ab'
export const WETH_ADDRESS_XDAI = '0x6A023CCd1ff6F2045C3309768eAd9E68F978f6e1'

export const ORDER_BOOK_HOPS_DEFAULT = 2
export const ORDER_BOOK_HOPS_MAX = 2

Expand Down Expand Up @@ -210,5 +208,6 @@ export const DISABLED_TOKEN_MAPS = Object.keys(disabledTokens).reduce<DisabledTo
{
[Network.Mainnet]: {},
[Network.Rinkeby]: {},
[Network.xDai]: {},
},
)
6 changes: 5 additions & 1 deletion src/reducers-actions/pendingOrders.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { PendingTxObj } from 'api/exchange/ExchangeApi'
import { Actions } from 'reducers-actions'
import { toBN, setStorageItem } from 'utils'
import { setStorageItem } from 'utils'
import { toBN } from '@gnosis.pm/dex-js'

const STORAGE_PENDING_ORDER_KEY = 'STORAGE_PENDING_ORDER_TX_HASHES'

Expand Down Expand Up @@ -66,11 +67,14 @@ export interface PendingOrdersState {
'0x90dcJsdkjb22': [],
'0xd9sjsdasnci1': [],
},
100: {
},
}
*/
export const EMPTY_PENDING_ORDERS_STATE = {
1: {},
4: {},
100: {},
}

export const reducer = (state: PendingOrdersState, action: ReducerType): PendingOrdersState => {
Expand Down
3 changes: 2 additions & 1 deletion src/reducers-actions/trades.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import BigNumber from 'bignumber.js'
import { toBN } from '@gnosis.pm/dex-js'

import { Trade, TradeReversion, EventWithBlockInfo } from 'api/exchange/ExchangeApi'

import { Actions } from 'reducers-actions'

import { logDebug, dateToBatchId, toBN, setStorageItem, flattenMapOfLists } from 'utils'
import { logDebug, dateToBatchId, setStorageItem, flattenMapOfLists } from 'utils'
import { TRADES_LOCAL_STORAGE_KEY } from 'const'

// ******** TYPES/INTERFACES
Expand Down
1 change: 1 addition & 0 deletions src/types/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export interface TokenOverride {
export interface DisabledTokens {
[Network.Mainnet]: TokenOverride[]
[Network.Rinkeby]: TokenOverride[]
[Network.xDai]: TokenOverride[]
}

export interface Config {
Expand Down
1 change: 1 addition & 0 deletions src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export enum Network {
Rinkeby = 4,
Goerli = 5,
Kovan = 42,
xDai = 100,
}

export interface MinimalTokenDetails {
Expand Down
25 changes: 0 additions & 25 deletions src/utils/ethereum.ts

This file was deleted.

1 change: 0 additions & 1 deletion src/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
export * from './time'
export * from './format'
export * from './ethereum'
export * from './miscellaneous'
export * from './autoconnect'
export * from './price'
Expand Down
Loading