-
Notifications
You must be signed in to change notification settings - Fork 102
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
feat(volume-fee): free some assets from fee #5180
Conversation
Deployment failed with the following error:
View Documentation: https://vercel.com/docs/accounts/team-members-and-roles |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
const shouldSkipFee = get(shouldSkipFeeAtom) | ||
|
||
if (!widgetPartnerFee && shouldSkipFee) { | ||
console.debug('Tax free trade detected', tradeState) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the log after testing
apps/cowswap-frontend/src/modules/volumeFee/updaters/TaxFreeAssetsUpdater.tsx
Show resolved
Hide resolved
apps/cowswap-frontend/src/modules/volumeFee/updaters/TaxFreeAssetsUpdater.tsx
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Soft approve. I think is good enough, but the CMS design wouldn't be my first choice
We can actually make a registry with 2 fields, one mandatory, one optional
This is easier to maintain in the CMS and simpler to use
setTaxFreeAssets(state) | ||
}, | ||
SWR_CONFIG, | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel we have many updaters with a very similar logic. Just different fetch function and local storage var. Maybe we should make it more homogeneous at some point
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, I would think that the logic of the "last check" is something SWR does for you. If serves a local cached data if it hasn't been invalidated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should make it more homogeneous at some point
Good idea!
I will try to add a factory for this case next time
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"last check" is something SWR does for you
It works within the current session, but if you reload the page it will reset, so we have to add localStorage state
Summary
In order to make some assets free from volume fees, we added a new list in CMS.
The list is fetched from CMS as
/api/tax-free-assets
. There is a limit on items count - 500 (for all networks).The list might contain two types of items:
{ chainId: "MAINNET", tokenIds: "0xae7ab96520de3a18e5e111b5eaab095312d7fe84,0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee" }
When two tokenIds are specified, then only this specific pair will be free from fees. In this example it is
stETH/ETH
andETH/stETH
trades{ chainId: "MAINNET", tokenIds: "0xdef1ca1fb7fbcdc777520aa7f396b4e015f497ab" }
When only one tokenId is specified, then all trades with this token will be free from fees. In this example it is
*/COW
andCOW/*
tradesWhen a rule works, then you should see
Tax free trade detected
message in console (debug level).To Test
For testing I added two rules in Sepolia (you can change it in CMS in Tax Free Assets collection):
tax-free-assets
collection in CMStaxFreeAssetsUpdateTime
localStorage key and reload the page. Then you should see/api/tax-free-assets
request in network.