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
7f597c0f
Unverified
Commit
7f597c0f
authored
Oct 13, 2023
by
cartcrom
Committed by
GitHub
Oct 13, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor: use bips base constant (#7464)
* refactor: use bips base constant * fix: missed usage
parent
cfaf5d79
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
28 additions
and
22 deletions
+28
-22
index.tsx
src/components/AccountDrawer/MiniPortfolio/Pools/index.tsx
+2
-1
index.tsx
src/components/PositionPreview/index.tsx
+2
-1
RoutingDiagram.tsx
src/components/RoutingDiagram/RoutingDiagram.tsx
+2
-1
misc.ts
src/constants/misc.ts
+10
-9
NftBalance.ts
src/graphql/data/nft/NftBalance.ts
+2
-1
useSwapTaxes.ts
src/hooks/useSwapTaxes.ts
+3
-3
PoolDetailsHeader.tsx
src/pages/PoolDetails/PoolDetailsHeader.tsx
+2
-1
computeFiatValuePriceImpact.tsx
src/utils/computeFiatValuePriceImpact.tsx
+3
-3
prices.ts
src/utils/prices.ts
+2
-2
No files found.
src/components/AccountDrawer/MiniPortfolio/Pools/index.tsx
View file @
7f597c0f
...
@@ -6,6 +6,7 @@ import { TraceEvent } from 'analytics'
...
@@ -6,6 +6,7 @@ import { TraceEvent } from 'analytics'
import
{
useToggleAccountDrawer
}
from
'
components/AccountDrawer
'
import
{
useToggleAccountDrawer
}
from
'
components/AccountDrawer
'
import
Row
from
'
components/Row
'
import
Row
from
'
components/Row
'
import
{
MouseoverTooltip
}
from
'
components/Tooltip
'
import
{
MouseoverTooltip
}
from
'
components/Tooltip
'
import
{
BIPS_BASE
}
from
'
constants/misc
'
import
{
useFilterPossiblyMaliciousPositions
}
from
'
hooks/useFilterPossiblyMaliciousPositions
'
import
{
useFilterPossiblyMaliciousPositions
}
from
'
hooks/useFilterPossiblyMaliciousPositions
'
import
{
useSwitchChain
}
from
'
hooks/useSwitchChain
'
import
{
useSwitchChain
}
from
'
hooks/useSwitchChain
'
import
{
EmptyWalletModule
}
from
'
nft/components/profile/view/EmptyWalletContent
'
import
{
EmptyWalletModule
}
from
'
nft/components/profile/view/EmptyWalletContent
'
...
@@ -162,7 +163,7 @@ function PositionListItem({ positionInfo }: { positionInfo: PositionInfo }) {
...
@@ -162,7 +163,7 @@ function PositionListItem({ positionInfo }: { positionInfo: PositionInfo }) {
</
ThemedText
.
SubHeader
>
</
ThemedText
.
SubHeader
>
</
Row
>
</
Row
>
}
}
descriptor=
{
<
ThemedText
.
BodySmall
>
{
`${pool.fee /
10000
}%`
}
</
ThemedText
.
BodySmall
>
}
descriptor=
{
<
ThemedText
.
BodySmall
>
{
`${pool.fee /
BIPS_BASE
}%`
}
</
ThemedText
.
BodySmall
>
}
right=
{
right=
{
<>
<>
<
MouseoverTooltip
<
MouseoverTooltip
...
...
src/components/PositionPreview/index.tsx
View file @
7f597c0f
...
@@ -9,6 +9,7 @@ import { Break } from 'components/earn/styled'
...
@@ -9,6 +9,7 @@ import { Break } from 'components/earn/styled'
import
CurrencyLogo
from
'
components/Logo/CurrencyLogo
'
import
CurrencyLogo
from
'
components/Logo/CurrencyLogo
'
import
RateToggle
from
'
components/RateToggle
'
import
RateToggle
from
'
components/RateToggle
'
import
{
RowBetween
,
RowFixed
}
from
'
components/Row
'
import
{
RowBetween
,
RowFixed
}
from
'
components/Row
'
import
{
BIPS_BASE
}
from
'
constants/misc
'
import
JSBI
from
'
jsbi
'
import
JSBI
from
'
jsbi
'
import
{
ReactNode
,
useCallback
,
useState
}
from
'
react
'
import
{
ReactNode
,
useCallback
,
useState
}
from
'
react
'
import
{
Bound
}
from
'
state/mint/v3/actions
'
import
{
Bound
}
from
'
state/mint/v3/actions
'
...
@@ -104,7 +105,7 @@ export const PositionPreview = ({
...
@@ -104,7 +105,7 @@ export const PositionPreview = ({
<
Trans
>
Fee tier
</
Trans
>
<
Trans
>
Fee tier
</
Trans
>
</
ThemedText
.
DeprecatedLabel
>
</
ThemedText
.
DeprecatedLabel
>
<
ThemedText
.
DeprecatedLabel
>
<
ThemedText
.
DeprecatedLabel
>
<
Trans
>
{
position
?.
pool
?.
fee
/
10000
}
%
</
Trans
>
<
Trans
>
{
position
?.
pool
?.
fee
/
BIPS_BASE
}
%
</
Trans
>
</
ThemedText
.
DeprecatedLabel
>
</
ThemedText
.
DeprecatedLabel
>
</
RowBetween
>
</
RowBetween
>
</
AutoColumn
>
</
AutoColumn
>
...
...
src/components/RoutingDiagram/RoutingDiagram.tsx
View file @
7f597c0f
...
@@ -6,6 +6,7 @@ import Badge from 'components/Badge'
...
@@ -6,6 +6,7 @@ import Badge from 'components/Badge'
import
DoubleCurrencyLogo
from
'
components/DoubleLogo
'
import
DoubleCurrencyLogo
from
'
components/DoubleLogo
'
import
CurrencyLogo
from
'
components/Logo/CurrencyLogo
'
import
CurrencyLogo
from
'
components/Logo/CurrencyLogo
'
import
Row
,
{
AutoRow
}
from
'
components/Row
'
import
Row
,
{
AutoRow
}
from
'
components/Row
'
import
{
BIPS_BASE
}
from
'
constants/misc
'
import
{
useTokenInfoFromActiveList
}
from
'
hooks/useTokenInfoFromActiveList
'
import
{
useTokenInfoFromActiveList
}
from
'
hooks/useTokenInfoFromActiveList
'
import
{
Box
}
from
'
rebass
'
import
{
Box
}
from
'
rebass
'
import
styled
from
'
styled-components
'
import
styled
from
'
styled-components
'
...
@@ -148,7 +149,7 @@ function Pool({ currency0, currency1, feeAmount }: { currency0: Currency; curren
...
@@ -148,7 +149,7 @@ function Pool({ currency0, currency1, feeAmount }: { currency0: Currency; curren
<
Box
margin=
"0 4px 0 12px"
>
<
Box
margin=
"0 4px 0 12px"
>
<
DoubleCurrencyLogo
currency0=
{
tokenInfo1
}
currency1=
{
tokenInfo0
}
size=
{
20
}
/>
<
DoubleCurrencyLogo
currency0=
{
tokenInfo1
}
currency1=
{
tokenInfo0
}
size=
{
20
}
/>
</
Box
>
</
Box
>
<
BadgeText
>
{
feeAmount
/
10000
}
%
</
BadgeText
>
<
BadgeText
>
{
feeAmount
/
BIPS_BASE
}
%
</
BadgeText
>
</
PoolBadge
>
</
PoolBadge
>
</
MouseoverTooltip
>
</
MouseoverTooltip
>
)
)
...
...
src/constants/misc.ts
View file @
7f597c0f
...
@@ -9,24 +9,25 @@ export const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000'
...
@@ -9,24 +9,25 @@ export const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000'
export
const
DEFAULT_DEADLINE_FROM_NOW
=
60
*
10
export
const
DEFAULT_DEADLINE_FROM_NOW
=
60
*
10
export
const
L2_DEADLINE_FROM_NOW
=
60
*
5
export
const
L2_DEADLINE_FROM_NOW
=
60
*
5
// transaction popup dismisal amounts
// transaction popup dismis
s
al amounts
export
const
DEFAULT_TXN_DISMISS_MS
=
10000
export
const
DEFAULT_TXN_DISMISS_MS
=
10000
export
const
L2_TXN_DISMISS_MS
=
5000
export
const
L2_TXN_DISMISS_MS
=
5000
export
const
BIG_INT_ZERO
=
JSBI
.
BigInt
(
0
)
export
const
BIG_INT_ZERO
=
JSBI
.
BigInt
(
0
)
export
const
BIPS_BASE
=
10
_000
// one basis JSBI.BigInt
// one basis JSBI.BigInt
const
BIPS_BASE
=
JSBI
.
BigInt
(
10000
)
export
const
ONE_BIPS
=
new
Percent
(
JSBI
.
BigInt
(
1
),
BIPS_BASE
)
export
const
ONE_BIPS
=
new
Percent
(
JSBI
.
BigInt
(
1
),
BIPS_BASE
)
// used for warning states
// used for warning states
export
const
ALLOWED_PRICE_IMPACT_LOW
:
Percent
=
new
Percent
(
JSBI
.
BigInt
(
100
),
BIPS_BASE
)
// 1%
export
const
ALLOWED_PRICE_IMPACT_LOW
:
Percent
=
new
Percent
(
1
,
100
)
// 1%
export
const
ALLOWED_PRICE_IMPACT_MEDIUM
:
Percent
=
new
Percent
(
JSBI
.
BigInt
(
300
),
BIPS_BASE
)
// 3%
export
const
ALLOWED_PRICE_IMPACT_MEDIUM
:
Percent
=
new
Percent
(
3
,
100
)
// 3%
export
const
ALLOWED_PRICE_IMPACT_HIGH
:
Percent
=
new
Percent
(
JSBI
.
BigInt
(
500
),
BIPS_BASE
)
// 5%
export
const
ALLOWED_PRICE_IMPACT_HIGH
:
Percent
=
new
Percent
(
5
,
100
)
// 5%
// if the price slippage exceeds this number, force the user to type 'confirm' to execute
// if the price slippage exceeds this number, force the user to type 'confirm' to execute
export
const
PRICE_IMPACT_WITHOUT_FEE_CONFIRM_MIN
:
Percent
=
new
Percent
(
JSBI
.
BigInt
(
1000
),
BIPS_BASE
)
// 10%
export
const
PRICE_IMPACT_WITHOUT_FEE_CONFIRM_MIN
:
Percent
=
new
Percent
(
10
,
100
)
// 10%
// for non expert mode disable swaps above this
// for non expert mode disable swaps above this
export
const
BLOCKED_PRICE_IMPACT_NON_EXPERT
:
Percent
=
new
Percent
(
JSBI
.
BigInt
(
1500
),
BIPS_BASE
)
// 15%
export
const
BLOCKED_PRICE_IMPACT_NON_EXPERT
:
Percent
=
new
Percent
(
15
,
100
)
// 15%
export
const
ZERO_PERCENT
=
new
Percent
(
'
0
'
)
export
const
ZERO_PERCENT
=
new
Percent
(
0
)
export
const
ONE_HUNDRED_PERCENT
=
new
Percent
(
'
1
'
)
export
const
ONE_HUNDRED_PERCENT
=
new
Percent
(
1
)
src/graphql/data/nft/NftBalance.ts
View file @
7f597c0f
import
{
BIPS_BASE
}
from
'
constants/misc
'
import
{
parseEther
}
from
'
ethers/lib/utils
'
import
{
parseEther
}
from
'
ethers/lib/utils
'
import
gql
from
'
graphql-tag
'
import
gql
from
'
graphql-tag
'
import
{
GenieCollection
,
WalletAsset
}
from
'
nft/types
'
import
{
GenieCollection
,
WalletAsset
}
from
'
nft/types
'
...
@@ -190,7 +191,7 @@ export function useNftBalance(
...
@@ -190,7 +191,7 @@ export function useNftBalance(
collectionIsVerified: asset?.collection?.isVerified,
collectionIsVerified: asset?.collection?.isVerified,
lastPrice: queryAsset.node.lastPrice?.value,
lastPrice: queryAsset.node.lastPrice?.value,
floorPrice: asset?.collection?.markets?.[0]?.floorPrice?.value,
floorPrice: asset?.collection?.markets?.[0]?.floorPrice?.value,
basisPoints: queryAsset?.node?.listingFees?.[0]?.basisPoints ?? 0 /
10000
,
basisPoints: queryAsset?.node?.listingFees?.[0]?.basisPoints ?? 0 /
BIPS_BASE
,
listing_date: asset?.listings?.edges?.[0]?.node?.createdAt?.toString(),
listing_date: asset?.listings?.edges?.[0]?.node?.createdAt?.toString(),
date_acquired: queryAsset.node.lastPrice?.timestamp?.toString(),
date_acquired: queryAsset.node.lastPrice?.timestamp?.toString(),
sellOrders: asset?.listings?.edges.map((edge: any) => edge.node),
sellOrders: asset?.listings?.edges.map((edge: any) => edge.node),
...
...
src/hooks/useSwapTaxes.ts
View file @
7f597c0f
...
@@ -5,7 +5,7 @@ import { useWeb3React } from '@web3-react/core'
...
@@ -5,7 +5,7 @@ import { useWeb3React } from '@web3-react/core'
import
FOT_DETECTOR_ABI
from
'
abis/fee-on-transfer-detector.json
'
import
FOT_DETECTOR_ABI
from
'
abis/fee-on-transfer-detector.json
'
import
{
FeeOnTransferDetector
}
from
'
abis/types
'
import
{
FeeOnTransferDetector
}
from
'
abis/types
'
import
{
sendAnalyticsEvent
}
from
'
analytics
'
import
{
sendAnalyticsEvent
}
from
'
analytics
'
import
{
ZERO_PERCENT
}
from
'
constants/misc
'
import
{
BIPS_BASE
,
ZERO_PERCENT
}
from
'
constants/misc
'
import
{
useEffect
,
useState
}
from
'
react
'
import
{
useEffect
,
useState
}
from
'
react
'
import
{
useContract
}
from
'
./useContract
'
import
{
useContract
}
from
'
./useContract
'
...
@@ -53,8 +53,8 @@ async function getSwapTaxes(
...
@@ -53,8 +53,8 @@ async function getSwapTaxes(
addresses
.
forEach
((
address
,
index
)
=>
{
addresses
.
forEach
((
address
,
index
)
=>
{
const
{
sellFeeBps
,
buyFeeBps
}
=
data
[
index
]
const
{
sellFeeBps
,
buyFeeBps
}
=
data
[
index
]
const
sellTax
=
new
Percent
(
sellFeeBps
.
toNumber
(),
10000
)
const
sellTax
=
new
Percent
(
sellFeeBps
.
toNumber
(),
BIPS_BASE
)
const
buyTax
=
new
Percent
(
buyFeeBps
.
toNumber
(),
10000
)
const
buyTax
=
new
Percent
(
buyFeeBps
.
toNumber
(),
BIPS_BASE
)
FEE_CACHE
[
address
]
=
{
sellTax
,
buyTax
}
FEE_CACHE
[
address
]
=
{
sellTax
,
buyTax
}
})
})
...
...
src/pages/PoolDetails/PoolDetailsHeader.tsx
View file @
7f597c0f
...
@@ -4,6 +4,7 @@ import blankTokenUrl from 'assets/svg/blank_token.svg'
...
@@ -4,6 +4,7 @@ import blankTokenUrl from 'assets/svg/blank_token.svg'
import
Column
from
'
components/Column
'
import
Column
from
'
components/Column
'
import
{
ChainLogo
}
from
'
components/Logo/ChainLogo
'
import
{
ChainLogo
}
from
'
components/Logo/ChainLogo
'
import
Row
from
'
components/Row
'
import
Row
from
'
components/Row
'
import
{
BIPS_BASE
}
from
'
constants/misc
'
import
{
chainIdToBackendName
}
from
'
graphql/data/util
'
import
{
chainIdToBackendName
}
from
'
graphql/data/util
'
import
{
useCurrency
}
from
'
hooks/Tokens
'
import
{
useCurrency
}
from
'
hooks/Tokens
'
import
useTokenLogoSource
from
'
hooks/useAssetLogoSource
'
import
useTokenLogoSource
from
'
hooks/useAssetLogoSource
'
...
@@ -88,7 +89,7 @@ export function PoolDetailsHeader({
...
@@ -88,7 +89,7 @@ export function PoolDetailsHeader({
{
token0
?.
symbol
}
/
{
token1
?.
symbol
}
{
token0
?.
symbol
}
/
{
token1
?.
symbol
}
</
ThemedText
.
HeadlineSmall
>
</
ThemedText
.
HeadlineSmall
>
</
Row
>
</
Row
>
{
!!
feeTier
&&
<
FeeTier
>
{
feeTier
/
10000
}
%
</
FeeTier
>
}
{
!!
feeTier
&&
<
FeeTier
>
{
feeTier
/
BIPS_BASE
}
%
</
FeeTier
>
}
<
ToggleReverseArrows
data
-
testid=
"toggle-tokens-reverse-arrows"
onClick=
{
toggleReversed
}
/>
<
ToggleReverseArrows
data
-
testid=
"toggle-tokens-reverse-arrows"
onClick=
{
toggleReversed
}
/>
</
Row
>
</
Row
>
</
HeaderColumn
>
</
HeaderColumn
>
...
...
src/utils/computeFiatValuePriceImpact.tsx
View file @
7f597c0f
import
{
Percent
}
from
'
@uniswap/sdk-core
'
import
{
Percent
}
from
'
@uniswap/sdk-core
'
import
{
BIPS_BASE
}
from
'
constants/misc
'
const
PRECISION
=
10000
export
function
computeFiatValuePriceImpact
(
export
function
computeFiatValuePriceImpact
(
fiatValueInput
:
number
|
undefined
|
null
,
fiatValueInput
:
number
|
undefined
|
null
,
fiatValueOutput
:
number
|
undefined
|
null
fiatValueOutput
:
number
|
undefined
|
null
...
@@ -9,6 +9,6 @@ export function computeFiatValuePriceImpact(
...
@@ -9,6 +9,6 @@ export function computeFiatValuePriceImpact(
if
(
fiatValueInput
===
0
)
return
undefined
if
(
fiatValueInput
===
0
)
return
undefined
const
ratio
=
1
-
fiatValueOutput
/
fiatValueInput
const
ratio
=
1
-
fiatValueOutput
/
fiatValueInput
const
numerator
=
Math
.
floor
(
ratio
*
PRECISION
)
const
numerator
=
Math
.
floor
(
ratio
*
BIPS_BASE
)
return
new
Percent
(
numerator
,
PRECISION
)
return
new
Percent
(
numerator
,
BIPS_BASE
)
}
}
src/utils/prices.ts
View file @
7f597c0f
...
@@ -2,19 +2,19 @@ import { Trade } from '@uniswap/router-sdk'
...
@@ -2,19 +2,19 @@ import { Trade } from '@uniswap/router-sdk'
import
{
Currency
,
CurrencyAmount
,
Fraction
,
Percent
,
TradeType
}
from
'
@uniswap/sdk-core
'
import
{
Currency
,
CurrencyAmount
,
Fraction
,
Percent
,
TradeType
}
from
'
@uniswap/sdk-core
'
import
{
Pair
}
from
'
@uniswap/v2-sdk
'
import
{
Pair
}
from
'
@uniswap/v2-sdk
'
import
{
FeeAmount
}
from
'
@uniswap/v3-sdk
'
import
{
FeeAmount
}
from
'
@uniswap/v3-sdk
'
import
JSBI
from
'
jsbi
'
import
{
DefaultTheme
}
from
'
styled-components
'
import
{
DefaultTheme
}
from
'
styled-components
'
import
{
import
{
ALLOWED_PRICE_IMPACT_HIGH
,
ALLOWED_PRICE_IMPACT_HIGH
,
ALLOWED_PRICE_IMPACT_LOW
,
ALLOWED_PRICE_IMPACT_LOW
,
ALLOWED_PRICE_IMPACT_MEDIUM
,
ALLOWED_PRICE_IMPACT_MEDIUM
,
BIPS_BASE
,
BLOCKED_PRICE_IMPACT_NON_EXPERT
,
BLOCKED_PRICE_IMPACT_NON_EXPERT
,
ONE_HUNDRED_PERCENT
,
ONE_HUNDRED_PERCENT
,
ZERO_PERCENT
,
ZERO_PERCENT
,
}
from
'
../constants/misc
'
}
from
'
../constants/misc
'
const
THIRTY_BIPS_FEE
=
new
Percent
(
JSBI
.
BigInt
(
30
),
JSBI
.
BigInt
(
10000
)
)
const
THIRTY_BIPS_FEE
=
new
Percent
(
30
,
BIPS_BASE
)
const
INPUT_FRACTION_AFTER_FEE
=
ONE_HUNDRED_PERCENT
.
subtract
(
THIRTY_BIPS_FEE
)
const
INPUT_FRACTION_AFTER_FEE
=
ONE_HUNDRED_PERCENT
.
subtract
(
THIRTY_BIPS_FEE
)
export
function
computeRealizedPriceImpact
(
trade
:
Trade
<
Currency
,
Currency
,
TradeType
>
):
Percent
{
export
function
computeRealizedPriceImpact
(
trade
:
Trade
<
Currency
,
Currency
,
TradeType
>
):
Percent
{
...
...
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