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
36242d14
Unverified
Commit
36242d14
authored
Oct 19, 2023
by
eddie
Committed by
GitHub
Oct 19, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: add temporary logging to swap_signed (#7472)
parent
b02352e8
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
6 deletions
+23
-6
useUniswapXSwapCallback.ts
src/hooks/useUniswapXSwapCallback.ts
+9
-3
useUniversalRouter.ts
src/hooks/useUniversalRouter.ts
+14
-3
No files found.
src/hooks/useUniswapXSwapCallback.ts
View file @
36242d14
import
{
BigNumber
}
from
'
@ethersproject/bignumber
'
import
{
BigNumber
}
from
'
@ethersproject/bignumber
'
import
*
as
Sentry
from
'
@sentry/react
'
import
*
as
Sentry
from
'
@sentry/react
'
import
{
SwapEventName
}
from
'
@uniswap/analytics-events
'
import
{
CustomUserProperties
,
SwapEventName
}
from
'
@uniswap/analytics-events
'
import
{
Percent
}
from
'
@uniswap/sdk-core
'
import
{
Percent
}
from
'
@uniswap/sdk-core
'
import
{
DutchOrder
,
DutchOrderBuilder
}
from
'
@uniswap/uniswapx-sdk
'
import
{
DutchOrder
,
DutchOrderBuilder
}
from
'
@uniswap/uniswapx-sdk
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
{
sendAnalyticsEvent
,
useTrace
}
from
'
analytics
'
import
{
sendAnalyticsEvent
,
useTrace
}
from
'
analytics
'
import
{
useCachedPortfolioBalancesQuery
}
from
'
components/PrefetchBalancesWrapper/PrefetchBalancesWrapper
'
import
{
useCachedPortfolioBalancesQuery
}
from
'
components/PrefetchBalancesWrapper/PrefetchBalancesWrapper
'
import
{
getConnection
}
from
'
connection
'
import
{
formatSwapSignedAnalyticsEventProperties
}
from
'
lib/utils/analytics
'
import
{
formatSwapSignedAnalyticsEventProperties
}
from
'
lib/utils/analytics
'
import
{
useCallback
}
from
'
react
'
import
{
useCallback
}
from
'
react
'
import
{
DutchOrderTrade
,
TradeFillType
}
from
'
state/routing/types
'
import
{
DutchOrderTrade
,
TradeFillType
}
from
'
state/routing/types
'
...
@@ -13,6 +14,7 @@ import { trace } from 'tracing/trace'
...
@@ -13,6 +14,7 @@ import { trace } from 'tracing/trace'
import
{
SignatureExpiredError
,
UserRejectedRequestError
}
from
'
utils/errors
'
import
{
SignatureExpiredError
,
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
'
import
{
getWalletMeta
}
from
'
utils/walletMeta
'
type
DutchAuctionOrderError
=
{
errorCode
?:
number
;
detail
?:
string
}
type
DutchAuctionOrderError
=
{
errorCode
?:
number
;
detail
?:
string
}
type
DutchAuctionOrderSuccess
=
{
hash
:
string
}
type
DutchAuctionOrderSuccess
=
{
hash
:
string
}
...
@@ -54,7 +56,7 @@ export function useUniswapXSwapCallback({
...
@@ -54,7 +56,7 @@ export function useUniswapXSwapCallback({
fiatValues
:
{
amountIn
?:
number
;
amountOut
?:
number
;
feeUsd
?:
number
}
fiatValues
:
{
amountIn
?:
number
;
amountOut
?:
number
;
feeUsd
?:
number
}
allowedSlippage
:
Percent
allowedSlippage
:
Percent
})
{
})
{
const
{
account
,
provider
}
=
useWeb3React
()
const
{
account
,
provider
,
connector
}
=
useWeb3React
()
const
analyticsContext
=
useTrace
()
const
analyticsContext
=
useTrace
()
const
{
data
}
=
useCachedPortfolioBalancesQuery
({
account
})
const
{
data
}
=
useCachedPortfolioBalancesQuery
({
account
})
...
@@ -122,6 +124,10 @@ export function useUniswapXSwapCallback({
...
@@ -122,6 +124,10 @@ export function useUniswapXSwapCallback({
portfolioBalanceUsd
,
portfolioBalanceUsd
,
}),
}),
...
analyticsContext
,
...
analyticsContext
,
// TODO (WEB-2993): remove these after debugging missing user properties.
[
CustomUserProperties
.
WALLET_ADDRESS
]:
account
,
[
CustomUserProperties
.
WALLET_TYPE
]:
getConnection
(
connector
).
getName
(),
[
CustomUserProperties
.
PEER_WALLET_AGENT
]:
provider
?
getWalletMeta
(
provider
)?.
agent
:
undefined
,
})
})
const
res
=
await
fetch
(
`
${
UNISWAP_API_URL
}
/order`
,
{
const
res
=
await
fetch
(
`
${
UNISWAP_API_URL
}
/order`
,
{
...
@@ -160,6 +166,6 @@ export function useUniswapXSwapCallback({
...
@@ -160,6 +166,6 @@ export function useUniswapXSwapCallback({
response: { orderHash: body.hash, deadline: updatedOrder.info.deadline },
response: { orderHash: body.hash, deadline: updatedOrder.info.deadline },
}
}
}),
}),
[account, provider, trade, allowedSlippage, fiatValues,
analyticsContext, portfolioBalanceUsd
]
[account, provider, trade, allowedSlippage, fiatValues,
portfolioBalanceUsd, analyticsContext, connector
]
)
)
}
}
src/hooks/useUniversalRouter.ts
View file @
36242d14
import
{
BigNumber
}
from
'
@ethersproject/bignumber
'
import
{
BigNumber
}
from
'
@ethersproject/bignumber
'
import
{
t
}
from
'
@lingui/macro
'
import
{
t
}
from
'
@lingui/macro
'
import
{
SwapEventName
}
from
'
@uniswap/analytics-events
'
import
{
CustomUserProperties
,
SwapEventName
}
from
'
@uniswap/analytics-events
'
import
{
Percent
}
from
'
@uniswap/sdk-core
'
import
{
Percent
}
from
'
@uniswap/sdk-core
'
import
{
FlatFeeOptions
,
SwapRouter
,
UNIVERSAL_ROUTER_ADDRESS
}
from
'
@uniswap/universal-router-sdk
'
import
{
FlatFeeOptions
,
SwapRouter
,
UNIVERSAL_ROUTER_ADDRESS
}
from
'
@uniswap/universal-router-sdk
'
import
{
FeeOptions
,
toHex
}
from
'
@uniswap/v3-sdk
'
import
{
FeeOptions
,
toHex
}
from
'
@uniswap/v3-sdk
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
{
sendAnalyticsEvent
,
useTrace
}
from
'
analytics
'
import
{
sendAnalyticsEvent
,
useTrace
}
from
'
analytics
'
import
{
useCachedPortfolioBalancesQuery
}
from
'
components/PrefetchBalancesWrapper/PrefetchBalancesWrapper
'
import
{
useCachedPortfolioBalancesQuery
}
from
'
components/PrefetchBalancesWrapper/PrefetchBalancesWrapper
'
import
{
getConnection
}
from
'
connection
'
import
useBlockNumber
from
'
lib/hooks/useBlockNumber
'
import
useBlockNumber
from
'
lib/hooks/useBlockNumber
'
import
{
formatCommonPropertiesForTrade
,
formatSwapSignedAnalyticsEventProperties
}
from
'
lib/utils/analytics
'
import
{
formatCommonPropertiesForTrade
,
formatSwapSignedAnalyticsEventProperties
}
from
'
lib/utils/analytics
'
import
{
useCallback
}
from
'
react
'
import
{
useCallback
}
from
'
react
'
...
@@ -17,6 +18,7 @@ import { calculateGasMargin } from 'utils/calculateGasMargin'
...
@@ -17,6 +18,7 @@ import { calculateGasMargin } from 'utils/calculateGasMargin'
import
{
UserRejectedRequestError
,
WrongChainError
}
from
'
utils/errors
'
import
{
UserRejectedRequestError
,
WrongChainError
}
from
'
utils/errors
'
import
isZero
from
'
utils/isZero
'
import
isZero
from
'
utils/isZero
'
import
{
didUserReject
,
swapErrorToUserReadableMessage
}
from
'
utils/swapErrorToUserReadableMessage
'
import
{
didUserReject
,
swapErrorToUserReadableMessage
}
from
'
utils/swapErrorToUserReadableMessage
'
import
{
getWalletMeta
}
from
'
utils/walletMeta
'
import
{
PermitSignature
}
from
'
./usePermitAllowance
'
import
{
PermitSignature
}
from
'
./usePermitAllowance
'
...
@@ -52,7 +54,7 @@ export function useUniversalRouterSwapCallback(
...
@@ -52,7 +54,7 @@ export function useUniversalRouterSwapCallback(
fiatValues
:
{
amountIn
?:
number
;
amountOut
?:
number
;
feeUsd
?:
number
},
fiatValues
:
{
amountIn
?:
number
;
amountOut
?:
number
;
feeUsd
?:
number
},
options
:
SwapOptions
options
:
SwapOptions
)
{
)
{
const
{
account
,
chainId
,
provider
}
=
useWeb3React
()
const
{
account
,
chainId
,
provider
,
connector
}
=
useWeb3React
()
const
analyticsContext
=
useTrace
()
const
analyticsContext
=
useTrace
()
const
blockNumber
=
useBlockNumber
()
const
blockNumber
=
useBlockNumber
()
const
isAutoSlippage
=
useUserSlippageTolerance
()[
0
]
===
'
auto
'
const
isAutoSlippage
=
useUserSlippageTolerance
()[
0
]
===
'
auto
'
...
@@ -125,6 +127,10 @@ export function useUniversalRouterSwapCallback(
...
@@ -125,6 +127,10 @@ export function useUniversalRouterSwapCallback(
portfolioBalanceUsd
,
portfolioBalanceUsd
,
}),
}),
...
analyticsContext
,
...
analyticsContext
,
// TODO (WEB-2993): remove these after debugging missing user properties.
[
CustomUserProperties
.
WALLET_ADDRESS
]:
account
,
[
CustomUserProperties
.
WALLET_TYPE
]:
getConnection
(
connector
).
getName
(),
[
CustomUserProperties
.
PEER_WALLET_AGENT
]:
provider
?
getWalletMeta
(
provider
)?.
agent
:
undefined
,
})
})
if
(
tx
.
data
!==
response
.
data
)
{
if
(
tx
.
data
!==
response
.
data
)
{
sendAnalyticsEvent
(
SwapEventName
.
SWAP_MODIFIED_IN_WALLET
,
{
sendAnalyticsEvent
(
SwapEventName
.
SWAP_MODIFIED_IN_WALLET
,
{
...
@@ -163,11 +169,16 @@ export function useUniversalRouterSwapCallback(
...
@@ -163,11 +169,16 @@ export function useUniversalRouterSwapCallback(
chainId
,
chainId
,
provider
,
provider
,
trade
,
trade
,
options
,
options
.
slippageTolerance
,
options
.
deadline
,
options
.
permit
,
options
.
feeOptions
,
options
.
flatFeeOptions
,
analyticsContext
,
analyticsContext
,
blockNumber
,
blockNumber
,
isAutoSlippage
,
isAutoSlippage
,
fiatValues
,
fiatValues
,
portfolioBalanceUsd
,
portfolioBalanceUsd
,
connector
,
])
])
}
}
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