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
d5643469
Commit
d5643469
authored
Oct 28, 2018
by
Chi Kei Chan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix exchange rate calc
parent
22b6c0b0
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
11 deletions
+9
-11
web3connect.js
src/ducks/web3connect.js
+1
-2
index.js
src/pages/Send/index.js
+4
-5
index.js
src/pages/Swap/index.js
+4
-4
No files found.
src/ducks/web3connect.js
View file @
d5643469
...
...
@@ -46,7 +46,6 @@ const initialState = {
const
TOKEN_LABEL_FALLBACK
=
{
'
0x89d24A6b4CcB1B6fAA2625fE562bDD9a23260359
'
:
'
DAI
'
,
'
0x9f8F72aA9304c8B593d555F12eF6589cC3A579A2
'
:
'
MKR
'
,
'
0x9B913956036a3462330B0642B20D3879ce68b450
'
:
'
BAT + ETH
'
};
// selectors
...
...
@@ -101,7 +100,7 @@ export const selectors = () => (dispatch, getState) => {
};
};
const
Balance
=
(
value
,
label
=
''
,
decimals
=
18
)
=>
({
const
Balance
=
(
value
,
label
=
''
,
decimals
=
0
)
=>
({
value
:
BN
(
value
),
label
:
label
.
toUpperCase
(),
decimals
:
+
decimals
,
...
...
src/pages/Send/index.js
View file @
d5643469
...
...
@@ -201,8 +201,8 @@ class Send extends Component {
outputReserve
:
outputReserveB
,
});
const
exchangeRate
=
outputAmountB
.
dividedBy
(
inputAmountA
);
const
outputValue
=
outputAmountB
.
dividedBy
(
BN
(
10
**
outputDecimalsB
)).
toFixed
(
7
);
const
exchangeRate
=
BN
(
outputValue
).
dividedBy
(
BN
(
oldInputValue
));
const
appendState
=
{};
...
...
@@ -241,10 +241,10 @@ class Send extends Component {
outputReserve
:
outputReserveA
,
});
const
exchangeRate
=
outputAmountB
.
dividedBy
(
inputAmountA
);
const
inputValue
=
inputAmountA
.
isNegative
()
?
'
N/A
'
:
inputAmountA
.
dividedBy
(
BN
(
10
**
inputDecimalsA
)).
toFixed
(
7
);
const
exchangeRate
=
BN
(
oldOutputValue
).
dividedBy
(
BN
(
inputValue
));
const
appendState
=
{};
...
...
@@ -298,8 +298,8 @@ class Send extends Component {
const
inputAmount
=
BN
(
oldInputValue
).
multipliedBy
(
10
**
inputDecimals
);
const
outputAmount
=
calculateEtherTokenOutput
({
inputAmount
,
inputReserve
,
outputReserve
});
const
exchangeRate
=
outputAmount
.
dividedBy
(
inputAmount
);
const
outputValue
=
outputAmount
.
dividedBy
(
BN
(
10
**
outputDecimals
)).
toFixed
(
7
);
const
exchangeRate
=
BN
(
outputValue
).
dividedBy
(
BN
(
oldInputValue
));
const
appendState
=
{};
...
...
@@ -322,10 +322,10 @@ class Send extends Component {
const
outputAmount
=
BN
(
oldOutputValue
).
multipliedBy
(
10
**
outputDecimals
);
const
inputAmount
=
calculateEtherTokenInput
({
outputAmount
,
inputReserve
,
outputReserve
});
const
exchangeRate
=
outputAmount
.
dividedBy
(
inputAmount
);
const
inputValue
=
inputAmount
.
isNegative
()
?
'
N/A
'
:
inputAmount
.
dividedBy
(
BN
(
10
**
inputDecimals
)).
toFixed
(
7
);
const
exchangeRate
=
BN
(
oldOutputValue
).
dividedBy
(
BN
(
inputValue
));
const
appendState
=
{};
...
...
@@ -711,7 +711,6 @@ class Send extends Component {
const
{
value
:
inputBalance
,
decimals
:
inputDecimals
}
=
selectors
().
getBalance
(
account
,
inputCurrency
);
const
{
value
:
outputBalance
,
decimals
:
outputDecimals
}
=
selectors
().
getBalance
(
account
,
outputCurrency
);
const
{
inputError
,
outputError
,
isValid
}
=
this
.
validate
();
return
(
...
...
src/pages/Swap/index.js
View file @
d5643469
...
...
@@ -197,8 +197,8 @@ class Swap extends Component {
outputReserve
:
outputReserveB
,
});
const
exchangeRate
=
outputAmountB
.
dividedBy
(
inputAmountA
);
const
outputValue
=
outputAmountB
.
dividedBy
(
BN
(
10
**
outputDecimalsB
)).
toFixed
(
7
);
const
exchangeRate
=
BN
(
outputValue
).
dividedBy
(
BN
(
oldInputValue
));
const
appendState
=
{};
...
...
@@ -237,10 +237,10 @@ class Swap extends Component {
outputReserve
:
outputReserveA
,
});
const
exchangeRate
=
outputAmountB
.
dividedBy
(
inputAmountA
);
const
inputValue
=
inputAmountA
.
isNegative
()
?
'
N/A
'
:
inputAmountA
.
dividedBy
(
BN
(
10
**
inputDecimalsA
)).
toFixed
(
7
);
const
exchangeRate
=
BN
(
oldOutputValue
).
dividedBy
(
BN
(
inputValue
));
const
appendState
=
{};
...
...
@@ -294,8 +294,8 @@ class Swap extends Component {
const
inputAmount
=
BN
(
oldInputValue
).
multipliedBy
(
10
**
inputDecimals
);
const
outputAmount
=
calculateEtherTokenOutput
({
inputAmount
,
inputReserve
,
outputReserve
});
const
exchangeRate
=
outputAmount
.
dividedBy
(
inputAmount
);
const
outputValue
=
outputAmount
.
dividedBy
(
BN
(
10
**
outputDecimals
)).
toFixed
(
7
);
const
exchangeRate
=
BN
(
outputValue
).
dividedBy
(
BN
(
oldInputValue
));
const
appendState
=
{};
...
...
@@ -318,10 +318,10 @@ class Swap extends Component {
const
outputAmount
=
BN
(
oldOutputValue
).
multipliedBy
(
10
**
outputDecimals
);
const
inputAmount
=
calculateEtherTokenInput
({
outputAmount
,
inputReserve
,
outputReserve
});
const
exchangeRate
=
outputAmount
.
dividedBy
(
inputAmount
);
const
inputValue
=
inputAmount
.
isNegative
()
?
'
N/A
'
:
inputAmount
.
dividedBy
(
BN
(
10
**
inputDecimals
)).
toFixed
(
7
);
const
exchangeRate
=
BN
(
oldOutputValue
).
dividedBy
(
BN
(
inputValue
));
const
appendState
=
{};
...
...
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