8000 fix(volume-fee): remove hardcoded stablecoins check for Safe fee by shoom3301 · Pull Request #5436 · cowprotocol/cowswap · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix(volume-fee): remove hardcoded stablecoins check for Safe fee #5436

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const FEE_PERCENTAGE_BPS = {
export const safeAppFeeAtom = atom<VolumeFee | null>((get) => {
const { chainId } = get(walletInfoAtom)
const { isSafeApp } = get(walletDetailsAtom)
const { isSafeAppFeeEnabled, isSafeAppStableCoinsFeeEnabled } = get(featureFlagsAtom)
const { isSafeAppFeeEnabled } = get(featureFlagsAtom)
const { inputCurrency, outputCurrency, inputCurrencyFiatAmount, outputCurrencyFiatAmount, orderKind } =
get(derivedTradeStateAtom) || {}

Expand All @@ -54,8 +54,6 @@ export const safeAppFeeAtom = atom<VolumeFee | null>((get) => {
const isOutputStableCoin = !!outputCurrency && stablecoins.has(getCurrencyAddress(outputCurrency).toLowerCase())
const isStableCoinTrade = isInputStableCoin && isOutputStableCoin

if (isStableCoinTrade && !isSafeAppStableCoinsFeeEnabled) return null

const bps = (() => {
if (fiatAmount < FEE_TIERS.TIER_1) {
return isStableCoinTrade ? FEE_PERCENTAGE_BPS.STABLE.TIER_1 : FEE_PERCENTAGE_BPS.REGULAR.TIER_1
Expand All @@ -68,5 +66,11 @@ export const safeAppFeeAtom = atom<VolumeFee | null>((get) => {
return isStableCoinTrade ? FEE_PERCENTAGE_BPS.STABLE.TIER_3 : FEE_PERCENTAGE_BPS.REGULAR.TIER_3
})()

console.debug('[Volume Fee] Calculated a fee for Safe App (not added yet)', {
bps,
fiatAmount,
isStableCoinTrade,
})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

were you intending to add this message?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. It's not easy for Elena to test the volume fee calculation, so I added this debug log.


return { bps, recipient: SAFE_FEE_RECIPIENT }
})
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const shouldSkipFeeAtom = atom<boolean>((get) => {
const inputCurrencyAddress = getCurrencyAddress(inputCurrency).toLowerCase()
const outputCurrencyAddress = getCurrencyAddress(outputCurrency).toLowerCase()

return correlatedTokens.some((tokens) => {
const isCorrelated = correlatedTokens.some((tokens) => {
// If there is only one asset in the list, it means that it is a global correlated token
const addresses = Object.keys(tokens)
if (addresses.length === 1) {
Expand All @@ -56,6 +56,16 @@ const shouldSkipFeeAtom = atom<boolean>((get) => {
return tokens[inputCurrencyAddress] && tokens[outputCurrencyAddress]
}
})

if (isCorrelated) {
console.debug('[Volume Fee] Skipping fee for correlated tokens', {
inputCurrencyAddress,
outputCurrencyAddress,
correlatedTokens,
})
}

return isCorrelated
})

const widgetPartnerFeeAtom = atom<VolumeFee | undefined>((get) => {
Expand Down
Loading
0