[wip] Add exploratory xGNANA contracts#3
Conversation
| } | ||
|
|
||
| function exchangeRate() public view returns (uint256) { | ||
| return gnanaBalance() * 1e18 / totalSupply(); |
There was a problem hiding this comment.
if totalSupply() == 0, which it is in the beginning, will keep the exchange rate at 0 (or just error even actually).
A simple check on this returning 1 should fix it.
There was a problem hiding this comment.
Nice catch! Definitely need to update that.
| return gnanaBalance() * 1e18 / totalSupply(); | ||
| } | ||
|
|
||
| function redeem(uint256 xGnanaAmount) external { |
There was a problem hiding this comment.
I think redeem is more fitting but withdraw is used in a lot of places so just worth a mention
There was a problem hiding this comment.
Sushi and SpookySwap use enter and leave instead of deposit and redeem/withdraw.
I think I prefer deposit and redeem but maybe worth a little vote.
There was a problem hiding this comment.
I'm happy to explore this more.
|
|
||
| function syncDelegateVotingPower(address delegator, address delegatee, bool withRevert) public { | ||
| bool synced = _syncDelegateVotingPower(delegator, delegatee); | ||
| if(withRevert && !synced) { |
There was a problem hiding this comment.
Should probably turn this internal and provide a public function which automatically reverts if the delegatee is not registered.
| * where a protocol can fill up with tokens and distribute tokens to xGNANA holders who | ||
| * delegate their voting power. | ||
| */ | ||
| interface IxTokenWithBribes { |
There was a problem hiding this comment.
Maybe IxTokenDelegatorCallback is more generic and "bribes" would still fall under this, but of course the idea is to be extensible and allow many other options.
|
|
||
| function _syncDelegateVotingPower(address delegator, address delegatee) internal returns (bool){ | ||
| if(_registeredCallbackDelegatees.contains(delegatee)) { | ||
| IERC20VotesDelegatee(delegatee).syncDelegatePower(delegator); |
There was a problem hiding this comment.
The tricky part is that an external contract could cause a denial of service if they revert inside this function.
The whitelist is important for that, but may not catch the edge cases. Paladin strongly recommended against using a try/catch as there is a way to purposely throw it which could allow users to unstake xGNANA and still have bribe rewards on another contract.
The nice thing is that worst case we can de-whitelist a delagatee contract and it would allow xGNANA to be redeemed again.
xGNANA Prototype
I believe this could be a valid prototype for
xGNANAto provide the features and modularity we desire.The important concept in this design is the ability to have external contracts that could be delegated to, and if voting power is adjusted, they could be called to account for changes.
Considerations
TODO (If this prototype is considered for merge)
Factory
BribecontractxGNANABribeFactorywith whitelist capabilities for deployment of non-upgradablexGNANABribecontracts whichxGNANAholders candelegatevotes to