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
a3fbab91
Unverified
Commit
a3fbab91
authored
Sep 08, 2023
by
eddie
Committed by
GitHub
Sep 08, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: uniswapx start time buffer (#7279)
* wip * feat: use startTimeBufferSecs from API response
parent
1ac1002c
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
13 additions
and
3 deletions
+13
-3
quote1.json
cypress/fixtures/uniswapx/quote1.json
+2
-0
quote2.json
cypress/fixtures/uniswapx/quote2.json
+2
-0
useUniswapXSwapCallback.ts
src/hooks/useUniswapXSwapCallback.ts
+1
-3
types.ts
src/state/routing/types.ts
+6
-0
utils.ts
src/state/routing/utils.ts
+1
-0
constants.ts
src/test-utils/constants.ts
+1
-0
No files found.
cypress/fixtures/uniswapx/quote1.json
View file @
a3fbab91
...
@@ -32,6 +32,7 @@
...
@@ -32,6 +32,7 @@
"quoteId"
:
"f9f47cd7-a62c-4622-9ac7-51d0e662245a"
,
"quoteId"
:
"f9f47cd7-a62c-4622-9ac7-51d0e662245a"
,
"requestId"
:
"2d16f993-6429-4755-ba50-1383789459dc"
,
"requestId"
:
"2d16f993-6429-4755-ba50-1383789459dc"
,
"auctionPeriodSecs"
:
60
,
"auctionPeriodSecs"
:
60
,
"startTimeBufferSecs"
:
30
,
"deadlineBufferSecs"
:
12
,
"deadlineBufferSecs"
:
12
,
"slippageTolerance"
:
"0.5"
,
"slippageTolerance"
:
"0.5"
,
"permitData"
:
{
"permitData"
:
{
...
@@ -252,6 +253,7 @@
...
@@ -252,6 +253,7 @@
"quoteId"
:
"f9f47cd7-a62c-4622-9ac7-51d0e662245a"
,
"quoteId"
:
"f9f47cd7-a62c-4622-9ac7-51d0e662245a"
,
"requestId"
:
"2d16f993-6429-4755-ba50-1383789459dc"
,
"requestId"
:
"2d16f993-6429-4755-ba50-1383789459dc"
,
"auctionPeriodSecs"
:
60
,
"auctionPeriodSecs"
:
60
,
"startTimeBufferSecs"
:
30
,
"deadlineBufferSecs"
:
12
,
"deadlineBufferSecs"
:
12
,
"slippageTolerance"
:
"0.5"
,
"slippageTolerance"
:
"0.5"
,
"permitData"
:
{
"permitData"
:
{
...
...
cypress/fixtures/uniswapx/quote2.json
View file @
a3fbab91
...
@@ -32,6 +32,7 @@
...
@@ -32,6 +32,7 @@
"quoteId"
:
"09ce28b7-1ddf-4317-a28d-d21092be9f84"
,
"quoteId"
:
"09ce28b7-1ddf-4317-a28d-d21092be9f84"
,
"requestId"
:
"f00535d4-461a-4363-afbe-7a5ab7061cd1"
,
"requestId"
:
"f00535d4-461a-4363-afbe-7a5ab7061cd1"
,
"auctionPeriodSecs"
:
60
,
"auctionPeriodSecs"
:
60
,
"startTimeBufferSecs"
:
30
,
"deadlineBufferSecs"
:
12
,
"deadlineBufferSecs"
:
12
,
"slippageTolerance"
:
"0.5"
,
"slippageTolerance"
:
"0.5"
,
"permitData"
:
{
"permitData"
:
{
...
@@ -252,6 +253,7 @@
...
@@ -252,6 +253,7 @@
"quoteId"
:
"09ce28b7-1ddf-4317-a28d-d21092be9f84"
,
"quoteId"
:
"09ce28b7-1ddf-4317-a28d-d21092be9f84"
,
"requestId"
:
"f00535d4-461a-4363-afbe-7a5ab7061cd1"
,
"requestId"
:
"f00535d4-461a-4363-afbe-7a5ab7061cd1"
,
"auctionPeriodSecs"
:
60
,
"auctionPeriodSecs"
:
60
,
"startTimeBufferSecs"
:
30
,
"deadlineBufferSecs"
:
12
,
"deadlineBufferSecs"
:
12
,
"slippageTolerance"
:
"0.5"
,
"slippageTolerance"
:
"0.5"
,
"permitData"
:
{
"permitData"
:
{
...
...
src/hooks/useUniswapXSwapCallback.ts
View file @
a3fbab91
...
@@ -13,8 +13,6 @@ import { UserRejectedRequestError } from 'utils/errors'
...
@@ -13,8 +13,6 @@ import { UserRejectedRequestError } from 'utils/errors'
import
{
signTypedData
}
from
'
utils/signing
'
import
{
signTypedData
}
from
'
utils/signing
'
import
{
didUserReject
,
swapErrorToUserReadableMessage
}
from
'
utils/swapErrorToUserReadableMessage
'
import
{
didUserReject
,
swapErrorToUserReadableMessage
}
from
'
utils/swapErrorToUserReadableMessage
'
const
DEFAULT_START_TIME_PADDING_SECONDS
=
30
type
DutchAuctionOrderError
=
{
errorCode
?:
number
;
detail
?:
string
}
type
DutchAuctionOrderError
=
{
errorCode
?:
number
;
detail
?:
string
}
type
DutchAuctionOrderSuccess
=
{
hash
:
string
}
type
DutchAuctionOrderSuccess
=
{
hash
:
string
}
type
DutchAuctionOrderResponse
=
DutchAuctionOrderError
|
DutchAuctionOrderSuccess
type
DutchAuctionOrderResponse
=
DutchAuctionOrderError
|
DutchAuctionOrderSuccess
...
@@ -69,7 +67,7 @@ export function useUniswapXSwapCallback({
...
@@ -69,7 +67,7 @@ export function useUniswapXSwapCallback({
try
{
try
{
const
updatedNonce
=
await
getUpdatedNonce
(
account
,
trade
.
order
.
chainId
)
const
updatedNonce
=
await
getUpdatedNonce
(
account
,
trade
.
order
.
chainId
)
const
startTime
=
Math
.
floor
(
Date
.
now
()
/
1000
)
+
DEFAULT_START_TIME_PADDING_SECONDS
const
startTime
=
Math
.
floor
(
Date
.
now
()
/
1000
)
+
trade
.
startTimeBufferSecs
setTraceData
(
'
startTime
'
,
startTime
)
setTraceData
(
'
startTime
'
,
startTime
)
const
endTime
=
startTime
+
trade
.
auctionPeriodSecs
const
endTime
=
startTime
+
trade
.
auctionPeriodSecs
...
...
src/state/routing/types.ts
View file @
a3fbab91
...
@@ -114,6 +114,7 @@ type URADutchOrderQuoteResponse = {
...
@@ -114,6 +114,7 @@ type URADutchOrderQuoteResponse = {
quote
:
{
quote
:
{
auctionPeriodSecs
:
number
auctionPeriodSecs
:
number
deadlineBufferSecs
:
number
deadlineBufferSecs
:
number
startTimeBufferSecs
:
number
orderInfo
:
DutchOrderInfoJSON
orderInfo
:
DutchOrderInfoJSON
quoteId
?:
string
quoteId
?:
string
requestId
?:
string
requestId
?:
string
...
@@ -236,6 +237,7 @@ export class DutchOrderTrade extends IDutchOrderTrade<Currency, Currency, TradeT
...
@@ -236,6 +237,7 @@ export class DutchOrderTrade extends IDutchOrderTrade<Currency, Currency, TradeT
// The gas estimate of the reference classic trade, if there is one.
// The gas estimate of the reference classic trade, if there is one.
classicGasUseEstimateUSD
?:
number
classicGasUseEstimateUSD
?:
number
auctionPeriodSecs
:
number
auctionPeriodSecs
:
number
startTimeBufferSecs
:
number
deadlineBufferSecs
:
number
deadlineBufferSecs
:
number
slippageTolerance
:
Percent
slippageTolerance
:
Percent
...
@@ -250,6 +252,7 @@ export class DutchOrderTrade extends IDutchOrderTrade<Currency, Currency, TradeT
...
@@ -250,6 +252,7 @@ export class DutchOrderTrade extends IDutchOrderTrade<Currency, Currency, TradeT
approveInfo
,
approveInfo
,
classicGasUseEstimateUSD
,
classicGasUseEstimateUSD
,
auctionPeriodSecs
,
auctionPeriodSecs
,
startTimeBufferSecs
,
deadlineBufferSecs
,
deadlineBufferSecs
,
slippageTolerance
,
slippageTolerance
,
}:
{
}:
{
...
@@ -263,6 +266,7 @@ export class DutchOrderTrade extends IDutchOrderTrade<Currency, Currency, TradeT
...
@@ -263,6 +266,7 @@ export class DutchOrderTrade extends IDutchOrderTrade<Currency, Currency, TradeT
wrapInfo
:
WrapInfo
wrapInfo
:
WrapInfo
classicGasUseEstimateUSD
?:
number
classicGasUseEstimateUSD
?:
number
auctionPeriodSecs
:
number
auctionPeriodSecs
:
number
startTimeBufferSecs
:
number
deadlineBufferSecs
:
number
deadlineBufferSecs
:
number
slippageTolerance
:
Percent
slippageTolerance
:
Percent
})
{
})
{
...
@@ -275,6 +279,7 @@ export class DutchOrderTrade extends IDutchOrderTrade<Currency, Currency, TradeT
...
@@ -275,6 +279,7 @@ export class DutchOrderTrade extends IDutchOrderTrade<Currency, Currency, TradeT
this
.
auctionPeriodSecs
=
auctionPeriodSecs
this
.
auctionPeriodSecs
=
auctionPeriodSecs
this
.
deadlineBufferSecs
=
deadlineBufferSecs
this
.
deadlineBufferSecs
=
deadlineBufferSecs
this
.
slippageTolerance
=
slippageTolerance
this
.
slippageTolerance
=
slippageTolerance
this
.
startTimeBufferSecs
=
startTimeBufferSecs
}
}
public
get
totalGasUseEstimateUSD
():
number
{
public
get
totalGasUseEstimateUSD
():
number
{
...
@@ -351,6 +356,7 @@ type UniswapXConfig = {
...
@@ -351,6 +356,7 @@ type UniswapXConfig = {
swapper
?:
string
swapper
?:
string
exclusivityOverrideBps
?:
number
exclusivityOverrideBps
?:
number
auctionPeriodSecs
?:
number
auctionPeriodSecs
?:
number
startTimeBufferSecs
?:
number
}
}
export
type
RoutingConfig
=
(
UniswapXConfig
|
ClassicAPIConfig
)[]
export
type
RoutingConfig
=
(
UniswapXConfig
|
ClassicAPIConfig
)[]
src/state/routing/utils.ts
View file @
a3fbab91
...
@@ -277,6 +277,7 @@ export async function transformRoutesToTrade(
...
@@ -277,6 +277,7 @@ export async function transformRoutesToTrade(
wrapInfo
,
wrapInfo
,
approveInfo
,
approveInfo
,
auctionPeriodSecs
:
data
.
quote
.
auctionPeriodSecs
,
auctionPeriodSecs
:
data
.
quote
.
auctionPeriodSecs
,
startTimeBufferSecs
:
data
.
quote
.
startTimeBufferSecs
,
deadlineBufferSecs
:
data
.
quote
.
deadlineBufferSecs
,
deadlineBufferSecs
:
data
.
quote
.
deadlineBufferSecs
,
slippageTolerance
:
toSlippagePercent
(
data
.
quote
.
slippageTolerance
),
slippageTolerance
:
toSlippagePercent
(
data
.
quote
.
slippageTolerance
),
})
})
...
...
src/test-utils/constants.ts
View file @
a3fbab91
...
@@ -121,6 +121,7 @@ export const TEST_DUTCH_TRADE_ETH_INPUT = new DutchOrderTrade({
...
@@ -121,6 +121,7 @@ export const TEST_DUTCH_TRADE_ETH_INPUT = new DutchOrderTrade({
classicGasUseEstimateUSD
:
7.87
,
classicGasUseEstimateUSD
:
7.87
,
auctionPeriodSecs
:
120
,
auctionPeriodSecs
:
120
,
deadlineBufferSecs
:
30
,
deadlineBufferSecs
:
30
,
startTimeBufferSecs
:
30
,
slippageTolerance
:
new
Percent
(
5
,
100
),
slippageTolerance
:
new
Percent
(
5
,
100
),
})
})
...
...
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