Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
interface
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
LuckySwap
interface
Commits
4ba7dd95
Unverified
Commit
4ba7dd95
authored
May 13, 2020
by
Noah Zinsmeister
Committed by
GitHub
May 13, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix invariant bug due to dummy ETH (#766)
* fix invariant bug due to dummy ETH * fix lint issue
parent
0733cdd6
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
4 deletions
+2
-4
V1.ts
src/data/V1.ts
+2
-4
No files found.
src/data/V1.ts
View file @
4ba7dd95
...
@@ -6,7 +6,6 @@ import IUniswapV1Factory from '../constants/abis/v1_factory.json'
...
@@ -6,7 +6,6 @@ import IUniswapV1Factory from '../constants/abis/v1_factory.json'
import
{
V1_FACTORY_ADDRESS
}
from
'
../constants
'
import
{
V1_FACTORY_ADDRESS
}
from
'
../constants
'
import
{
useContract
}
from
'
../hooks
'
import
{
useContract
}
from
'
../hooks
'
import
{
SWRKeys
}
from
'
.
'
import
{
SWRKeys
}
from
'
.
'
import
{
AddressZero
}
from
'
@ethersproject/constants
'
import
{
useETHBalances
,
useTokenBalances
}
from
'
../state/wallet/hooks
'
import
{
useETHBalances
,
useTokenBalances
}
from
'
../state/wallet/hooks
'
function
getV1PairAddress
(
contract
:
Contract
):
(
_
:
SWRKeys
,
tokenAddress
:
string
)
=>
Promise
<
string
>
{
function
getV1PairAddress
(
contract
:
Contract
):
(
_
:
SWRKeys
,
tokenAddress
:
string
)
=>
Promise
<
string
>
{
...
@@ -24,7 +23,6 @@ function useV1PairAddress(tokenAddress: string) {
...
@@ -24,7 +23,6 @@ function useV1PairAddress(tokenAddress: string) {
return
data
return
data
}
}
const
DUMMY_ETH
=
new
Token
(
ChainId
.
MAINNET
,
AddressZero
,
18
)
function
useMockV1Pair
(
token
?:
Token
)
{
function
useMockV1Pair
(
token
?:
Token
)
{
const
mainnet
=
token
?.
chainId
===
ChainId
.
MAINNET
const
mainnet
=
token
?.
chainId
===
ChainId
.
MAINNET
const
isWETH
=
token
?.
equals
(
WETH
[
ChainId
.
MAINNET
])
const
isWETH
=
token
?.
equals
(
WETH
[
ChainId
.
MAINNET
])
...
@@ -34,7 +32,7 @@ function useMockV1Pair(token?: Token) {
...
@@ -34,7 +32,7 @@ function useMockV1Pair(token?: Token) {
const
ETHBalance
=
useETHBalances
([
v1PairAddress
])[
v1PairAddress
]
const
ETHBalance
=
useETHBalances
([
v1PairAddress
])[
v1PairAddress
]
return
tokenBalance
&&
ETHBalance
return
tokenBalance
&&
ETHBalance
?
new
Pair
(
tokenBalance
,
new
TokenAmount
(
DUMMY_ETH
,
ETHBalance
.
toString
()))
?
new
Pair
(
tokenBalance
,
new
TokenAmount
(
WETH
[
ChainId
.
MAINNET
]
,
ETHBalance
.
toString
()))
:
undefined
:
undefined
}
}
...
@@ -56,7 +54,7 @@ export function useV1TradeLinkIfBetter(trade: Trade, minimumDelta: Percent = new
...
@@ -56,7 +54,7 @@ export function useV1TradeLinkIfBetter(trade: Trade, minimumDelta: Percent = new
pairs
=
[
inputPair
,
outputPair
]
pairs
=
[
inputPair
,
outputPair
]
}
}
const
route
=
pairs
&&
new
Route
(
pairs
,
inputIsWETH
?
DUMMY_ETH
:
trade
.
route
.
input
)
const
route
=
pairs
&&
new
Route
(
pairs
,
trade
.
route
.
input
)
const
v1Trade
=
const
v1Trade
=
route
&&
route
&&
new
Trade
(
new
Trade
(
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment