-
Notifications
You must be signed in to change notification settings - Fork 1
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
SwapFeeManager contract for managing Dex and Burn Fees #8
base: dev
Are you sure you want to change the base?
Conversation
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.
Thanks! nice language :)
test/SwapFeeManagerTest.js
Outdated
expect(finalDexFeeBalance - initialDexFeeBalance).to.equal(ethers.parseEther("0.75")); | ||
expect(finalBurnFeeBalance - initialBurnFeeBalance).to.equal(ethers.parseEther("0.25")); |
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.
ummmm, why are we checking the balance difference and not just the new balance?
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.
Before each test we get a set of default hardhat accounts, which have non-zero eth balances
accounts = await ethers.getSigners(); |
when you run tests, these accounts persist their state (including balance) across tests in the same testing session.
Initial ETH Dex Fee Wallet Balance: 10000000000000000000000
Initial ETH Burn Fee Wallet Balance: 10000000000000000000000
Final ETH Dex Fee Wallet Balance: 10000750000000000000000
Final ETH Burn Fee Wallet Balance: 10000250000000000000000
✔ should correctly split and withdraw Ether fees (61ms)
Initial ERC20 Dex Fee Wallet Balance: 0
Initial ERC20 Burn Fee Wallet Balance: 0
Initial ETH Dex Fee Wallet Balance: 10000750000000000000000
Initial ETH Burn Fee Wallet Balance: 10000250000000000000000
Final ERC20 Dex Fee Wallet Balance: 750000000000000000
Final ERC20 Burn Fee Wallet Balance: 250000000000000000
✔ should correctly split and withdraw ERC20 token fees (113ms)
As for Erc20 token, in log we see 0, as we dont transfer tokens manually to account as in these for example from EtomicSwapTakerV2.js
etomic-swap/test/EtomicSwapTakerV2Test.js
Line 67 in 9881905
await token.transfer(accounts[1].address, ethers.parseEther('100')); |
well, I can set balance to 0 with hardhat rpc 2af148a
contracts/SwapFeeManager.sol
Outdated
uint256 totalBalance = address(this).balance; | ||
require(totalBalance > 0, "No fees to split"); | ||
|
||
uint256 burnFeeAmount = (totalBalance * 25) / 100; |
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.
can we set these percentages as const?
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.
yep we can, as constants are fixed at compile-time it doesnt increase gas usage 2af148a
4c0f115
to
2af148a
Compare
The
SwapFeeManager
contract handles the management and distribution of Dex and burn fees. Key features include:Fee Distribution:
dexFeeWallet
.burnFeeWallet
.Ether Management:
splitAndWithdraw
function splits and transfers the Ether to the designated wallets.ERC20 Token Management:
splitAndWithdrawToken
function, which similarly splits and transfers the token balance.Access Control:
Event Logging:
FeesSplit
event whenever fees are split and distributed.