Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
swap-v2-sdk
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
swap-v2-sdk
Commits
d10e687c
Unverified
Commit
d10e687c
authored
Feb 14, 2020
by
Noah Zinsmeister
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
v2.0.0-beta.10
parent
fd5d1e4d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
1 deletion
+9
-1
package.json
package.json
+1
-1
exchange.ts
src/entities/exchange.ts
+5
-0
trade.ts
src/entities/trade.ts
+3
-0
No files found.
package.json
View file @
d10e687c
{
"name"
:
"@uniswap/sdk"
,
"license"
:
"GPL-3.0-or-later"
,
"version"
:
"2.0.0-beta.
9
"
,
"version"
:
"2.0.0-beta.
10
"
,
"main"
:
"dist/index.js"
,
"typings"
:
"dist/index.d.ts"
,
"files"
:
[
...
...
src/entities/exchange.ts
View file @
d10e687c
...
...
@@ -76,6 +76,11 @@ export class Exchange {
return
this
.
tokenAmounts
[
1
].
token
}
public
reserveOf
(
token
:
Token
):
TokenAmount
{
invariant
(
token
.
equals
(
this
.
token0
)
||
token
.
equals
(
this
.
token1
),
'
TOKEN
'
)
return
token
.
equals
(
this
.
token0
)
?
this
.
reserve0
:
this
.
reserve1
}
public
getOutputAmount
(
inputAmount
:
TokenAmount
):
[
TokenAmount
,
Exchange
]
{
invariant
(
inputAmount
.
token
.
equals
(
this
.
token0
)
||
inputAmount
.
token
.
equals
(
this
.
token1
),
'
TOKEN
'
)
invariant
(
JSBI
.
greaterThan
(
inputAmount
.
raw
,
ZERO
),
'
ZERO
'
)
...
...
src/entities/trade.ts
View file @
d10e687c
...
...
@@ -44,6 +44,9 @@ export class Trade {
constructor
(
route
:
Route
,
amount
:
TokenAmount
,
tradeType
:
TradeType
)
{
invariant
(
amount
.
token
.
equals
(
tradeType
===
TradeType
.
EXACT_INPUT
?
route
.
input
:
route
.
output
),
'
TOKEN
'
)
const
firstExchange
=
route
.
exchanges
[
tradeType
===
TradeType
.
EXACT_INPUT
?
0
:
route
.
exchanges
.
length
-
1
]
// ensure that the amount is strictly less that the exchange's balance
invariant
(
JSBI
.
lessThan
(
amount
.
raw
,
firstExchange
.
reserveOf
(
amount
.
token
).
raw
),
'
RESERVE
'
)
const
amounts
:
TokenAmount
[]
=
new
Array
(
route
.
path
.
length
)
const
nextExchanges
:
Exchange
[]
=
new
Array
(
route
.
exchanges
.
length
)
if
(
tradeType
===
TradeType
.
EXACT_INPUT
)
{
...
...
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