-
Notifications
You must be signed in to change notification settings - Fork 91
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
No deposit fee #117
No deposit fee #117
Changes from 1 commit
ee4426b
80e9db9
e68cd09
b9048ef
1d5a73b
8df35d7
b005318
a468913
138c840
fd88471
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -107,15 +107,18 @@ contract StableJoeStaking is Initializable, OwnableUpgradeable { | |
IERC20Upgradeable _rewardToken, | ||
IERC20Upgradeable _joe, | ||
address _feeCollector, | ||
uint256 _depositFeePercent | ||
uint256 _depositFeePercent, | ||
IERC721Upgradeable _smolJoes | ||
) external initializer { | ||
__Ownable_init(); | ||
require(address(_rewardToken) != address(0), "StableJoeStaking: reward token can't be address(0)"); | ||
require(address(_joe) != address(0), "StableJoeStaking: joe can't be address(0)"); | ||
require(address(_smolJoes) != address(0), "StableJoeStaking: smol joes can't be address(0)"); | ||
require(_feeCollector != address(0), "StableJoeStaking: fee collector can't be address(0)"); | ||
require(_depositFeePercent <= 5e17, "StableJoeStaking: max deposit fee can't be greater than 50%"); | ||
|
||
joe = _joe; | ||
smolJoes = _smolJoes; | ||
depositFeePercent = _depositFeePercent; | ||
feeCollector = _feeCollector; | ||
|
||
|
@@ -134,7 +137,7 @@ contract StableJoeStaking is Initializable, OwnableUpgradeable { | |
|
||
uint256 _fee; | ||
// Only EOAs holding Smol Joes are exempt from paying the deposit fee | ||
if (smolJoes.balanceOf(_msgSender()) == 0 || _msgSender() != tx.origin) { | ||
if ((address(smolJoes) != 0 && smolJoes.balanceOf(_msgSender()) == 0) || _msgSender() != tx.origin) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wrong parenthesis, if smolJoe is not set EOAs wouldn't pay any fees, change to: |
||
_fee = _amount.mul(depositFeePercent).div(DEPOSIT_FEE_PERCENT_PRECISION); | ||
} | ||
uint256 _amountMinusFee = _amount.sub(_fee); | ||
|
@@ -237,11 +240,12 @@ contract StableJoeStaking is Initializable, OwnableUpgradeable { | |
|
||
/** | ||
* @notice Initialize the Smol Joes address | ||
* @dev This function was added to be able to set Smol Joes during an upgrade | ||
* as the contract was already initialized | ||
* @param _smolJoes The Smol Joes contract address | ||
*/ | ||
function initializeSmolJoes(IERC721Upgradeable _smolJoes) external onlyOwner { | ||
require(address(_smolJoes) != address(0), "StableJoeStaking: smol joes can't be address(0)"); | ||
require(address(smolJoes) == address(0), "StableJoeStaking: smol joes already initialized"); | ||
function setSmolJoes(IERC721Upgradeable _smolJoes) external onlyOwner { | ||
require(address(_smolJoes) != address(0), "StableJoeStaking: smol joes can't be address(0)3"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Typo address(0)3 |
||
smolJoes = _smolJoes; | ||
emit SmolJoesInitialized(_smolJoes, smolJoes); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,22 +38,34 @@ module.exports = async function ({ getNamedAccounts, deployments }) { | |
proxyContract: "OpenZeppelinTransparentProxy", | ||
execute: { | ||
init: { | ||
methodName: "initializeSmolJoes", | ||
args: [smolJoes], | ||
methodName: "initialize", | ||
args: [ | ||
rewardToken, | ||
joeAddress, | ||
feeCollector, | ||
depositFeePercent, | ||
smolJoes, | ||
], | ||
}, | ||
}, | ||
}, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For safety reasons, don't forget to initialize the implementation even if it's useless for transparent proxies. |
||
log: true, | ||
}); | ||
if (sJoe.newlyDeployed) { | ||
console.log("Initializing implementation for safe measure..."); | ||
const impl = await ethers.getContract("StableJoeStaking_Implementation"); | ||
await impl.initialize( | ||
const sJoeImpl = await ethers.getContract( | ||
"StableJoeStaking_Implementation" | ||
); | ||
await sJoeImpl.initialize( | ||
rewardToken, | ||
joeAddress, | ||
feeCollector, | ||
depositFeePercent | ||
depositFeePercent, | ||
smolJoes | ||
); | ||
console.log("Setting Smol Joes..."); | ||
const sJoeProxy = await ethers.getContract("StableJoeStaking"); | ||
await sJoeProxy.setSmolJoes(smolJoes); | ||
Comment on lines
+66
to
+68
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If it's newly deployed then this is not necessary, as it would set it with initialize There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the upgrade though, it will be "newly deployed" but it won't call initialize. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh indeed, my bad I thought it was setting it on the implementation again |
||
} | ||
}); | ||
}; | ||
|
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.
Add a setter for smolJoe's address as we can't use initialize during an upgrade as the contract has already been initialized.