!refactor(Karma): remove mintAllowance()

This is no longer a necessary requirement.
This commit removes `mintAllowance()`, it's internal counterpart and its
usage.

BREAKING CHANGE:

`mintAllowance()` no longer exists.

Closes #192
This commit is contained in:
r4bbit
2025-03-25 14:24:46 +01:00
parent 695a208804
commit 5a39dca010
4 changed files with 71 additions and 189 deletions

View File

@@ -10,7 +10,7 @@
|-------------------------------------------------------------------------------------------+-----------------+--------+--------+--------+---------| |-------------------------------------------------------------------------------------------+-----------------+--------+--------+--------+---------|
| Function Name | Min | Avg | Median | Max | # Calls | | Function Name | Min | Avg | Median | Max | # Calls |
|-------------------------------------------------------------------------------------------+-----------------+--------+--------+--------+---------| |-------------------------------------------------------------------------------------------+-----------------+--------+--------+--------+---------|
| fallback | 746 | 132251 | 190917 | 190965 | 515 | | fallback | 746 | 142836 | 190919 | 190943 | 446 |
╰-------------------------------------------------------------------------------------------+-----------------+--------+--------+--------+---------╯ ╰-------------------------------------------------------------------------------------------+-----------------+--------+--------+--------+---------╯
╭-----------------------------------------------------+-----------------+---------+---------+---------+---------╮ ╭-----------------------------------------------------+-----------------+---------+---------+---------+---------╮
@@ -18,13 +18,13 @@
+===============================================================================================================+ +===============================================================================================================+
| Deployment Cost | Deployment Size | | | | | | Deployment Cost | Deployment Size | | | | |
|-----------------------------------------------------+-----------------+---------+---------+---------+---------| |-----------------------------------------------------+-----------------+---------+---------+---------+---------|
| 4816329 | 23319 | | | | | | 4773681 | 23120 | | | | |
|-----------------------------------------------------+-----------------+---------+---------+---------+---------| |-----------------------------------------------------+-----------------+---------+---------+---------+---------|
| | | | | | | | | | | | | |
|-----------------------------------------------------+-----------------+---------+---------+---------+---------| |-----------------------------------------------------+-----------------+---------+---------+---------+---------|
| Function Name | Min | Avg | Median | Max | # Calls | | Function Name | Min | Avg | Median | Max | # Calls |
|-----------------------------------------------------+-----------------+---------+---------+---------+---------| |-----------------------------------------------------+-----------------+---------+---------+---------+---------|
| run | 4015668 | 4015668 | 4015668 | 4015668 | 117 | | run | 3975779 | 3975779 | 3975779 | 3975779 | 105 |
╰-----------------------------------------------------+-----------------+---------+---------+---------+---------╯ ╰-----------------------------------------------------+-----------------+---------+---------+---------+---------╯
╭-----------------------------------------------------------+-----------------+---------+---------+---------+---------╮ ╭-----------------------------------------------------------+-----------------+---------+---------+---------+---------╮
@@ -66,7 +66,7 @@
|---------------------------------------------------------+-----------------+-----+--------+-----+---------| |---------------------------------------------------------+-----------------+-----+--------+-----+---------|
| Function Name | Min | Avg | Median | Max | # Calls | | Function Name | Min | Avg | Median | Max | # Calls |
|---------------------------------------------------------+-----------------+-----+--------+-----+---------| |---------------------------------------------------------+-----------------+-----+--------+-----+---------|
| activeNetworkConfig | 597 | 597 | 597 | 597 | 341 | | activeNetworkConfig | 597 | 597 | 597 | 597 | 317 |
╰---------------------------------------------------------+-----------------+-----+--------+-----+---------╯ ╰---------------------------------------------------------+-----------------+-----+--------+-----+---------╯
╭-------------------------------------------------------------------------------+-----------------+---------+---------+---------+---------╮ ╭-------------------------------------------------------------------------------+-----------------+---------+---------+---------+---------╮
@@ -88,41 +88,39 @@
+=====================================================================================+ +=====================================================================================+
| Deployment Cost | Deployment Size | | | | | | Deployment Cost | Deployment Size | | | | |
|------------------------------+-----------------+--------+--------+--------+---------| |------------------------------+-----------------+--------+--------+--------+---------|
| 0 | 10022 | | | | | | 0 | 9823 | | | | |
|------------------------------+-----------------+--------+--------+--------+---------| |------------------------------+-----------------+--------+--------+--------+---------|
| | | | | | | | | | | | | |
|------------------------------+-----------------+--------+--------+--------+---------| |------------------------------+-----------------+--------+--------+--------+---------|
| Function Name | Min | Avg | Median | Max | # Calls | | Function Name | Min | Avg | Median | Max | # Calls |
|------------------------------+-----------------+--------+--------+--------+---------| |------------------------------+-----------------+--------+--------+--------+---------|
| acceptOwnership | 12042 | 12042 | 12042 | 12042 | 1 | | acceptOwnership | 12020 | 12020 | 12020 | 12020 | 1 |
|------------------------------+-----------------+--------+--------+--------+---------| |------------------------------+-----------------+--------+--------+--------+---------|
| addRewardDistributor | 2589 | 65564 | 70586 | 70586 | 153 | | addRewardDistributor | 2589 | 66822 | 70586 | 70586 | 127 |
|------------------------------+-----------------+--------+--------+--------+---------| |------------------------------+-----------------+--------+--------+--------+---------|
| allowance | 482 | 482 | 482 | 482 | 3 | | allowance | 482 | 482 | 482 | 482 | 2 |
|------------------------------+-----------------+--------+--------+--------+---------| |------------------------------+-----------------+--------+--------+--------+---------|
| approve | 419 | 419 | 419 | 419 | 3 | | approve | 419 | 419 | 419 | 419 | 2 |
|------------------------------+-----------------+--------+--------+--------+---------| |------------------------------+-----------------+--------+--------+--------+---------|
| balanceOf | 4041 | 11707 | 10041 | 21041 | 9 | | balanceOf | 10019 | 13685 | 10019 | 21019 | 6 |
|------------------------------+-----------------+--------+--------+--------+---------| |------------------------------+-----------------+--------+--------+--------+---------|
| getRewardDistributors | 1162 | 3406 | 3406 | 5650 | 6 | | getRewardDistributors | 1140 | 3384 | 3384 | 5628 | 4 |
|------------------------------+-----------------+--------+--------+--------+---------| |------------------------------+-----------------+--------+--------+--------+---------|
| initialize | 95872 | 95872 | 95872 | 95872 | 117 | | initialize | 95872 | 95872 | 95872 | 95872 | 105 |
|------------------------------+-----------------+--------+--------+--------+---------| |------------------------------+-----------------+--------+--------+--------+---------|
| mint | 2654 | 56378 | 72352 | 72352 | 18 | | mint | 2632 | 37252 | 48792 | 48792 | 8 |
|------------------------------+-----------------+--------+--------+--------+---------|
| mintAllowance | 6722 | 6758 | 6758 | 6795 | 2 |
|------------------------------+-----------------+--------+--------+--------+---------| |------------------------------+-----------------+--------+--------+--------+---------|
| owner | 363 | 1029 | 363 | 2363 | 3 | | owner | 363 | 1029 | 363 | 2363 | 3 |
|------------------------------+-----------------+--------+--------+--------+---------| |------------------------------+-----------------+--------+--------+--------+---------|
| removeRewardDistributor | 2632 | 12148 | 4824 | 28990 | 9 | | removeRewardDistributor | 2632 | 12148 | 4824 | 28990 | 6 |
|------------------------------+-----------------+--------+--------+--------+---------| |------------------------------+-----------------+--------+--------+--------+---------|
| setReward | 22043 | 152059 | 164241 | 164241 | 290 | | setReward | 22021 | 157523 | 164219 | 164219 | 276 |
|------------------------------+-----------------+--------+--------+--------+---------| |------------------------------+-----------------+--------+--------+--------+---------|
| totalSupply | 3545 | 5726 | 3545 | 11545 | 11 | | totalSupply | 3545 | 8211 | 9545 | 11545 | 6 |
|------------------------------+-----------------+--------+--------+--------+---------| |------------------------------+-----------------+--------+--------+--------+---------|
| transfer | 417 | 417 | 417 | 417 | 3 | | transfer | 417 | 417 | 417 | 417 | 2 |
|------------------------------+-----------------+--------+--------+--------+---------| |------------------------------+-----------------+--------+--------+--------+---------|
| transferFrom | 511 | 511 | 511 | 511 | 3 | | transferFrom | 511 | 511 | 511 | 511 | 2 |
|------------------------------+-----------------+--------+--------+--------+---------| |------------------------------+-----------------+--------+--------+--------+---------|
| transferOwnership | 26328 | 26328 | 26328 | 26328 | 1 | | transferOwnership | 26328 | 26328 | 26328 | 26328 | 1 |
╰------------------------------+-----------------+--------+--------+--------+---------╯ ╰------------------------------+-----------------+--------+--------+--------+---------╯
@@ -186,7 +184,7 @@
|------------------------------------------------------+-----------------+--------+--------+--------+---------| |------------------------------------------------------+-----------------+--------+--------+--------+---------|
| getAccountVaults | 5230 | 5230 | 5230 | 5230 | 4 | | getAccountVaults | 5230 | 5230 | 5230 | 5230 | 4 |
|------------------------------------------------------+-----------------+--------+--------+--------+---------| |------------------------------------------------------+-----------------+--------+--------+--------+---------|
| getVault | 1970 | 7396 | 1970 | 17970 | 4181 | | getVault | 1970 | 7418 | 1970 | 17970 | 4182 |
|------------------------------------------------------+-----------------+--------+--------+--------+---------| |------------------------------------------------------+-----------------+--------+--------+--------+---------|
| initialize | 92752 | 92752 | 92752 | 92752 | 92 | | initialize | 92752 | 92752 | 92752 | 92752 | 92 |
|------------------------------------------------------+-----------------+--------+--------+--------+---------| |------------------------------------------------------+-----------------+--------+--------+--------+---------|
@@ -194,7 +192,7 @@
|------------------------------------------------------+-----------------+--------+--------+--------+---------| |------------------------------------------------------+-----------------+--------+--------+--------+---------|
| leave | 94998 | 94998 | 94998 | 94998 | 1 | | leave | 94998 | 94998 | 94998 | 94998 | 1 |
|------------------------------------------------------+-----------------+--------+--------+--------+---------| |------------------------------------------------------+-----------------+--------+--------+--------+---------|
| lock | 7040 | 44973 | 48575 | 90631 | 1034 | | lock | 7040 | 45107 | 48575 | 90631 | 1034 |
|------------------------------------------------------+-----------------+--------+--------+--------+---------| |------------------------------------------------------+-----------------+--------+--------+--------+---------|
| migrateToVault | 13570 | 72911 | 15777 | 189386 | 3 | | migrateToVault | 13570 | 72911 | 15777 | 189386 | 3 |
|------------------------------------------------------+-----------------+--------+--------+--------+---------| |------------------------------------------------------+-----------------+--------+--------+--------+---------|
@@ -212,7 +210,7 @@
|------------------------------------------------------+-----------------+--------+--------+--------+---------| |------------------------------------------------------+-----------------+--------+--------+--------+---------|
| rewardStartTime | 430 | 1430 | 1430 | 2430 | 2 | | rewardStartTime | 430 | 1430 | 1430 | 2430 | 2 |
|------------------------------------------------------+-----------------+--------+--------+--------+---------| |------------------------------------------------------+-----------------+--------+--------+--------+---------|
| rewardsBalanceOf | 2273 | 3483 | 3886 | 6273 | 268 | | rewardsBalanceOf | 2273 | 3477 | 3886 | 6273 | 268 |
|------------------------------------------------------+-----------------+--------+--------+--------+---------| |------------------------------------------------------+-----------------+--------+--------+--------+---------|
| rewardsBalanceOfAccount | 10220 | 10220 | 10220 | 10220 | 1 | | rewardsBalanceOfAccount | 10220 | 10220 | 10220 | 10220 | 1 |
|------------------------------------------------------+-----------------+--------+--------+--------+---------| |------------------------------------------------------+-----------------+--------+--------+--------+---------|
@@ -222,33 +220,33 @@
|------------------------------------------------------+-----------------+--------+--------+--------+---------| |------------------------------------------------------+-----------------+--------+--------+--------+---------|
| setTrustedCodehash | 24216 | 24216 | 24216 | 24216 | 92 | | setTrustedCodehash | 24216 | 24216 | 24216 | 24216 | 92 |
|------------------------------------------------------+-----------------+--------+--------+--------+---------| |------------------------------------------------------+-----------------+--------+--------+--------+---------|
| stake | 2639 | 141122 | 62283 | 248368 | 2668 | | stake | 2639 | 140781 | 62283 | 248368 | 2668 |
|------------------------------------------------------+-----------------+--------+--------+--------+---------| |------------------------------------------------------+-----------------+--------+--------+--------+---------|
| stakedBalanceOf | 2600 | 2600 | 2600 | 2600 | 1 | | stakedBalanceOf | 2600 | 2600 | 2600 | 2600 | 1 |
|------------------------------------------------------+-----------------+--------+--------+--------+---------| |------------------------------------------------------+-----------------+--------+--------+--------+---------|
| totalMP | 805 | 1257 | 1257 | 1710 | 6 | | totalMP | 805 | 1257 | 1257 | 1710 | 6 |
|------------------------------------------------------+-----------------+--------+--------+--------+---------| |------------------------------------------------------+-----------------+--------+--------+--------+---------|
| totalMPAccrued | 385 | 1066 | 385 | 2385 | 4161 | | totalMPAccrued | 385 | 1069 | 385 | 2385 | 4162 |
|------------------------------------------------------+-----------------+--------+--------+--------+---------| |------------------------------------------------------+-----------------+--------+--------+--------+---------|
| totalMPStaked | 429 | 1110 | 429 | 2429 | 4164 | | totalMPStaked | 429 | 1112 | 429 | 2429 | 4165 |
|------------------------------------------------------+-----------------+--------+--------+--------+---------| |------------------------------------------------------+-----------------+--------+--------+--------+---------|
| totalMaxMP | 407 | 1088 | 407 | 2407 | 4161 | | totalMaxMP | 407 | 1091 | 407 | 2407 | 4162 |
|------------------------------------------------------+-----------------+--------+--------+--------+---------| |------------------------------------------------------+-----------------+--------+--------+--------+---------|
| totalRewardsAccrued | 407 | 407 | 407 | 407 | 3 | | totalRewardsAccrued | 407 | 407 | 407 | 407 | 3 |
|------------------------------------------------------+-----------------+--------+--------+--------+---------| |------------------------------------------------------+-----------------+--------+--------+--------+---------|
| totalRewardsSupply | 998 | 1627 | 1792 | 6737 | 290 | | totalRewardsSupply | 998 | 1624 | 1792 | 6737 | 290 |
|------------------------------------------------------+-----------------+--------+--------+--------+---------| |------------------------------------------------------+-----------------+--------+--------+--------+---------|
| totalShares | 662 | 662 | 662 | 662 | 6 | | totalShares | 662 | 662 | 662 | 662 | 6 |
|------------------------------------------------------+-----------------+--------+--------+--------+---------| |------------------------------------------------------+-----------------+--------+--------+--------+---------|
| totalStaked | 408 | 1088 | 408 | 2408 | 4168 | | totalStaked | 408 | 1091 | 408 | 2408 | 4169 |
|------------------------------------------------------+-----------------+--------+--------+--------+---------| |------------------------------------------------------+-----------------+--------+--------+--------+---------|
| unstake | 41572 | 44283 | 41598 | 80836 | 269 | | unstake | 41572 | 44532 | 41598 | 80836 | 269 |
|------------------------------------------------------+-----------------+--------+--------+--------+---------| |------------------------------------------------------+-----------------+--------+--------+--------+---------|
| updateAccount | 368128 | 368128 | 368128 | 368128 | 1 | | updateAccount | 368128 | 368128 | 368128 | 368128 | 1 |
|------------------------------------------------------+-----------------+--------+--------+--------+---------| |------------------------------------------------------+-----------------+--------+--------+--------+---------|
| updateGlobalState | 15820 | 25876 | 29230 | 29230 | 8 | | updateGlobalState | 15820 | 25876 | 29230 | 29230 | 8 |
|------------------------------------------------------+-----------------+--------+--------+--------+---------| |------------------------------------------------------+-----------------+--------+--------+--------+---------|
| updateVault | 34573 | 37046 | 34573 | 115695 | 1023 | | updateVault | 34573 | 37053 | 34573 | 115695 | 1024 |
|------------------------------------------------------+-----------------+--------+--------+--------+---------| |------------------------------------------------------+-----------------+--------+--------+--------+---------|
| upgradeTo | 10257 | 10873 | 10257 | 12723 | 4 | | upgradeTo | 10257 | 10873 | 10257 | 12723 | 4 |
|------------------------------------------------------+-----------------+--------+--------+--------+---------| |------------------------------------------------------+-----------------+--------+--------+--------+---------|
@@ -276,7 +274,7 @@
|----------------------------------------+-----------------+--------+--------+--------+---------| |----------------------------------------+-----------------+--------+--------+--------+---------|
| leave | 12161 | 126408 | 69597 | 354278 | 4 | | leave | 12161 | 126408 | 69597 | 354278 | 4 |
|----------------------------------------+-----------------+--------+--------+--------+---------| |----------------------------------------+-----------------+--------+--------+--------+---------|
| lock | 12091 | 60392 | 64041 | 106094 | 1035 | | lock | 12091 | 60526 | 64041 | 106094 | 1035 |
|----------------------------------------+-----------------+--------+--------+--------+---------| |----------------------------------------+-----------------+--------+--------+--------+---------|
| migrateToVault | 29058 | 99593 | 31265 | 238456 | 3 | | migrateToVault | 29058 | 99593 | 31265 | 238456 | 3 |
|----------------------------------------+-----------------+--------+--------+--------+---------| |----------------------------------------+-----------------+--------+--------+--------+---------|
@@ -284,13 +282,13 @@
|----------------------------------------+-----------------+--------+--------+--------+---------| |----------------------------------------+-----------------+--------+--------+--------+---------|
| register | 12696 | 78061 | 78622 | 78622 | 362 | | register | 12696 | 78061 | 78622 | 78622 | 362 |
|----------------------------------------+-----------------+--------+--------+--------+---------| |----------------------------------------+-----------------+--------+--------+--------+---------|
| stake | 12071 | 175157 | 77776 | 303936 | 2669 | | stake | 12071 | 174725 | 77776 | 303936 | 2669 |
|----------------------------------------+-----------------+--------+--------+--------+---------| |----------------------------------------+-----------------+--------+--------+--------+---------|
| stakeManager | 369 | 369 | 369 | 369 | 361 | | stakeManager | 369 | 369 | 369 | 369 | 361 |
|----------------------------------------+-----------------+--------+--------+--------+---------| |----------------------------------------+-----------------+--------+--------+--------+---------|
| trustStakeManager | 7580 | 7580 | 7580 | 7580 | 1 | | trustStakeManager | 7580 | 7580 | 7580 | 7580 | 1 |
|----------------------------------------+-----------------+--------+--------+--------+---------| |----------------------------------------+-----------------+--------+--------+--------+---------|
| unstake | 12048 | 60588 | 57041 | 111858 | 270 | | unstake | 12048 | 60951 | 57041 | 111858 | 270 |
|----------------------------------------+-----------------+--------+--------+--------+---------| |----------------------------------------+-----------------+--------+--------+--------+---------|
| withdraw | 20711 | 20711 | 20711 | 20711 | 1 | | withdraw | 20711 | 20711 | 20711 | 20711 | 1 |
╰----------------------------------------+-----------------+--------+--------+--------+---------╯ ╰----------------------------------------+-----------------+--------+--------+--------+---------╯
@@ -306,7 +304,7 @@
|----------------------------------------------------+-----------------+------+--------+--------+---------| |----------------------------------------------------+-----------------+------+--------+--------+---------|
| Function Name | Min | Avg | Median | Max | # Calls | | Function Name | Min | Avg | Median | Max | # Calls |
|----------------------------------------------------+-----------------+------+--------+--------+---------| |----------------------------------------------------+-----------------+------+--------+--------+---------|
| fallback | 708 | 6596 | 2454 | 394505 | 23157 | | fallback | 708 | 6605 | 2454 | 394505 | 23163 |
|----------------------------------------------------+-----------------+------+--------+--------+---------| |----------------------------------------------------+-----------------+------+--------+--------+---------|
| implementation | 346 | 2345 | 2346 | 2346 | 4344 | | implementation | 346 | 2345 | 2346 | 2346 | 4344 |
╰----------------------------------------------------+-----------------+------+--------+--------+---------╯ ╰----------------------------------------------------+-----------------+------+--------+--------+---------╯
@@ -330,7 +328,7 @@
+===============================================================================================================================================+ +===============================================================================================================================================+
| Deployment Cost | Deployment Size | | | | | | Deployment Cost | Deployment Size | | | | |
|------------------------------------------------------------------------------------------+-----------------+-------+--------+-------+---------| |------------------------------------------------------------------------------------------+-----------------+-------+--------+-------+---------|
| 1204853 | 6015 | | | | | | 1204853 | 6207 | | | | |
|------------------------------------------------------------------------------------------+-----------------+-------+--------+-------+---------| |------------------------------------------------------------------------------------------+-----------------+-------+--------+-------+---------|
| | | | | | | | | | | | | |
|------------------------------------------------------------------------------------------+-----------------+-------+--------+-------+---------| |------------------------------------------------------------------------------------------+-----------------+-------+--------+-------+---------|
@@ -376,13 +374,13 @@
|-------------------------------------------------------------------+-----------------+-------+--------+-------+---------| |-------------------------------------------------------------------+-----------------+-------+--------+-------+---------|
| Function Name | Min | Avg | Median | Max | # Calls | | Function Name | Min | Avg | Median | Max | # Calls |
|-------------------------------------------------------------------+-----------------+-------+--------+-------+---------| |-------------------------------------------------------------------+-----------------+-------+--------+-------+---------|
| rewardsBalanceOfAccount | 549 | 1882 | 2549 | 2549 | 18 | | rewardsBalanceOfAccount | 549 | 1882 | 2549 | 2549 | 12 |
|-------------------------------------------------------------------+-----------------+-------+--------+-------+---------| |-------------------------------------------------------------------+-----------------+-------+--------+-------+---------|
| setTotalKarmaShares | 43589 | 43589 | 43589 | 43589 | 26 | | setTotalKarmaShares | 43589 | 43589 | 43589 | 43589 | 12 |
|-------------------------------------------------------------------+-----------------+-------+--------+-------+---------| |-------------------------------------------------------------------+-----------------+-------+--------+-------+---------|
| setUserKarmaShare | 44194 | 44194 | 44194 | 44194 | 6 | | setUserKarmaShare | 44194 | 44194 | 44194 | 44194 | 4 |
|-------------------------------------------------------------------+-----------------+-------+--------+-------+---------| |-------------------------------------------------------------------+-----------------+-------+--------+-------+---------|
| totalRewardsSupply | 324 | 990 | 324 | 2324 | 90 | | totalRewardsSupply | 324 | 324 | 324 | 324 | 12 |
╰-------------------------------------------------------------------+-----------------+-------+--------+-------+---------╯ ╰-------------------------------------------------------------------+-----------------+-------+--------+-------+---------╯
╭---------------------------------------------------------------------+-----------------+-------+--------+-------+---------╮ ╭---------------------------------------------------------------------+-----------------+-------+--------+-------+---------╮
@@ -404,17 +402,17 @@
+==================================================================================================+ +==================================================================================================+
| Deployment Cost | Deployment Size | | | | | | Deployment Cost | Deployment Size | | | | |
|---------------------------------------------+-----------------+-------+--------+-------+---------| |---------------------------------------------+-----------------+-------+--------+-------+---------|
| 770741 | 3987 | | | | | | 770657 | 3987 | | | | |
|---------------------------------------------+-----------------+-------+--------+-------+---------| |---------------------------------------------+-----------------+-------+--------+-------+---------|
| | | | | | | | | | | | | |
|---------------------------------------------+-----------------+-------+--------+-------+---------| |---------------------------------------------+-----------------+-------+--------+-------+---------|
| Function Name | Min | Avg | Median | Max | # Calls | | Function Name | Min | Avg | Median | Max | # Calls |
|---------------------------------------------+-----------------+-------+--------+-------+---------| |---------------------------------------------+-----------------+-------+--------+-------+---------|
| approve | 29075 | 31480 | 29183 | 46259 | 2664 | | approve | 29075 | 31479 | 29183 | 46259 | 2664 |
|---------------------------------------------+-----------------+-------+--------+-------+---------| |---------------------------------------------+-----------------+-------+--------+-------+---------|
| balanceOf | 561 | 1348 | 561 | 2561 | 4955 | | balanceOf | 561 | 1350 | 561 | 2561 | 4956 |
|---------------------------------------------+-----------------+-------+--------+-------+---------| |---------------------------------------------+-----------------+-------+--------+-------+---------|
| mint | 33964 | 37109 | 34072 | 68248 | 2673 | | mint | 33964 | 37108 | 34072 | 68248 | 2673 |
╰---------------------------------------------+-----------------+-------+--------+-------+---------╯ ╰---------------------------------------------+-----------------+-------+--------+-------+---------╯
╭-----------------------------------------------------------------------------+-----------------+--------+--------+--------+---------╮ ╭-----------------------------------------------------------------------------+-----------------+--------+--------+--------+---------╮

View File

@@ -6,28 +6,16 @@ EmergencyExitTest:test_EmergencyExitToAlternateAddress() (gas: 455942)
EmergencyExitTest:test_EmergencyExitWithLock() (gas: 453031) EmergencyExitTest:test_EmergencyExitWithLock() (gas: 453031)
EmergencyExitTest:test_EmergencyExitWithRewards() (gas: 440921) EmergencyExitTest:test_EmergencyExitWithRewards() (gas: 440921)
EmergencyExitTest:test_OnlyOwnerCanEnableEmergencyMode() (gas: 39176) EmergencyExitTest:test_OnlyOwnerCanEnableEmergencyMode() (gas: 39176)
FuzzTests:testFuzz_AccrueMP(uint128,uint64,uint64) (runs: 1003, μ: 393113, ~: 358403) FuzzTests:testFuzz_AccrueMP(uint128,uint64,uint64) (runs: 1003, μ: 391761, ~: 358391)
FuzzTests:testFuzz_AccrueMP_Relock(uint128,uint64,uint64,uint64) (runs: 1003, μ: 494093, ~: 461619) FuzzTests:testFuzz_AccrueMP_Relock(uint128,uint64,uint64,uint64) (runs: 1003, μ: 493828, ~: 461619)
FuzzTests:testFuzz_EmergencyExit(uint256,uint256) (runs: 1002, μ: 518928, ~: 510133) FuzzTests:testFuzz_EmergencyExit(uint256,uint256) (runs: 1002, μ: 519049, ~: 510169)
FuzzTests:testFuzz_Lock(uint256,uint64) (runs: 1004, μ: 776226, ~: 775635) FuzzTests:testFuzz_Lock(uint256,uint64) (runs: 1004, μ: 776285, ~: 775635)
FuzzTests:testFuzz_Relock(uint256,uint64,uint64) (runs: 1004, μ: 401592, ~: 374430) FuzzTests:testFuzz_Relock(uint256,uint64,uint64) (runs: 1004, μ: 395664, ~: 374421)
FuzzTests:testFuzz_Rewards(uint256,uint256,uint256,uint16,uint16) (runs: 1000, μ: 617176, ~: 618486) FuzzTests:testFuzz_Rewards(uint256,uint256,uint256,uint16,uint16) (runs: 1000, μ: 617159, ~: 618464)
FuzzTests:testFuzz_Stake(uint256,uint64) (runs: 1004, μ: 300320, ~: 268430) FuzzTests:testFuzz_Stake(uint256,uint64) (runs: 1004, μ: 297458, ~: 268424)
FuzzTests:testFuzz_Unstake(uint128,uint64,uint16,uint128) (runs: 1003, μ: 496639, ~: 466512) FuzzTests:testFuzz_Unstake(uint128,uint64,uint16,uint128) (runs: 1003, μ: 497858, ~: 466515)
FuzzTests:testFuzz_UpdateVault(uint128,uint64,uint64) (runs: 1003, μ: 393136, ~: 358426) FuzzTests:testFuzz_UpdateVault(uint128,uint64,uint64) (runs: 1003, μ: 391784, ~: 358414)
IntegrationTest:testStakeFoo() (gas: 1438852) IntegrationTest:testStakeFoo() (gas: 1438852)
KarmaMintAllowanceTest:testAddKarmaDistributorOnlyOwner() (gas: 364802)
KarmaMintAllowanceTest:testBalanceOf() (gas: 441486)
KarmaMintAllowanceTest:testBalanceOfWithNoSystemTotalKarma() (gas: 49545)
KarmaMintAllowanceTest:testMintAllowance_Available() (gas: 352610)
KarmaMintAllowanceTest:testMintAllowance_NotAvailable() (gas: 352615)
KarmaMintAllowanceTest:testMintOnlyOwner() (gas: 394857)
KarmaMintAllowanceTest:testMint_Ok() (gas: 419959)
KarmaMintAllowanceTest:testMint_RevertWithAllowanceExceeded() (gas: 400580)
KarmaMintAllowanceTest:testRemoveKarmaDistributorOnlyOwner() (gas: 88877)
KarmaMintAllowanceTest:testRemoveUnknownKarmaDistributor() (gas: 41416)
KarmaMintAllowanceTest:testTotalSupply() (gas: 349359)
KarmaMintAllowanceTest:testTransfersNotAllowed() (gas: 40219)
KarmaNFTTest:testApproveNotAllowed() (gas: 10507) KarmaNFTTest:testApproveNotAllowed() (gas: 10507)
KarmaNFTTest:testGetApproved() (gas: 10531) KarmaNFTTest:testGetApproved() (gas: 10531)
KarmaNFTTest:testIsApprovedForAll() (gas: 10705) KarmaNFTTest:testIsApprovedForAll() (gas: 10705)
@@ -38,28 +26,28 @@ KarmaNFTTest:testSetMetadataGenerator() (gas: 1010377)
KarmaNFTTest:testSetMetadataGeneratorRevert() (gas: 1006937) KarmaNFTTest:testSetMetadataGeneratorRevert() (gas: 1006937)
KarmaNFTTest:testTokenURI() (gas: 1105935) KarmaNFTTest:testTokenURI() (gas: 1105935)
KarmaNFTTest:testTransferNotAllowed() (gas: 10701) KarmaNFTTest:testTransferNotAllowed() (gas: 10701)
KarmaOwnershipTest:testAddKarmaDistributorOnlyOwner() (gas: 364790) KarmaOwnershipTest:testAddKarmaDistributorOnlyOwner() (gas: 364768)
KarmaOwnershipTest:testBalanceOf() (gas: 441456) KarmaOwnershipTest:testBalanceOf() (gas: 423830)
KarmaOwnershipTest:testBalanceOfWithNoSystemTotalKarma() (gas: 49523) KarmaOwnershipTest:testBalanceOfWithNoSystemTotalKarma() (gas: 49479)
KarmaOwnershipTest:testInitialOwner() (gas: 17601) KarmaOwnershipTest:testInitialOwner() (gas: 17601)
KarmaOwnershipTest:testMintOnlyOwner() (gas: 394821) KarmaOwnershipTest:testMintOnlyOwner() (gas: 371195)
KarmaOwnershipTest:testOwnershipTransfer() (gas: 98069) KarmaOwnershipTest:testOwnershipTransfer() (gas: 98047)
KarmaOwnershipTest:testRemoveKarmaDistributorOnlyOwner() (gas: 88842) KarmaOwnershipTest:testRemoveKarmaDistributorOnlyOwner() (gas: 88820)
KarmaOwnershipTest:testRemoveUnknownKarmaDistributor() (gas: 41398) KarmaOwnershipTest:testRemoveUnknownKarmaDistributor() (gas: 41398)
KarmaOwnershipTest:testTotalSupply() (gas: 349329) KarmaOwnershipTest:testTotalSupply() (gas: 331725)
KarmaOwnershipTest:testTransfersNotAllowed() (gas: 40196) KarmaOwnershipTest:testTransfersNotAllowed() (gas: 40196)
KarmaTest:testAddKarmaDistributorOnlyOwner() (gas: 364790) KarmaTest:testAddKarmaDistributorOnlyOwner() (gas: 364768)
KarmaTest:testBalanceOf() (gas: 441456) KarmaTest:testBalanceOf() (gas: 423830)
KarmaTest:testBalanceOfWithNoSystemTotalKarma() (gas: 49589) KarmaTest:testBalanceOfWithNoSystemTotalKarma() (gas: 49545)
KarmaTest:testMintOnlyOwner() (gas: 394821) KarmaTest:testMintOnlyOwner() (gas: 371195)
KarmaTest:testRemoveKarmaDistributorOnlyOwner() (gas: 88820) KarmaTest:testRemoveKarmaDistributorOnlyOwner() (gas: 88798)
KarmaTest:testRemoveUnknownKarmaDistributor() (gas: 41398) KarmaTest:testRemoveUnknownKarmaDistributor() (gas: 41398)
KarmaTest:testTotalSupply() (gas: 349329) KarmaTest:testTotalSupply() (gas: 331725)
KarmaTest:testTransfersNotAllowed() (gas: 40241) KarmaTest:testTransfersNotAllowed() (gas: 40241)
LeaveTest:test_LeaveShouldProperlyUpdateAccounting() (gas: 9674621) LeaveTest:test_LeaveShouldProperlyUpdateAccounting() (gas: 9674621)
LeaveTest:test_RevertWhenStakeManagerIsTrusted() (gas: 354861) LeaveTest:test_RevertWhenStakeManagerIsTrusted() (gas: 354861)
LeaveTest:test_TrustNewStakeManager() (gas: 9725694) LeaveTest:test_TrustNewStakeManager() (gas: 9725694)
LockTest:test_LockFailsWithInvalidPeriod(uint256) (runs: 1004, μ: 408038, ~: 408063) LockTest:test_LockFailsWithInvalidPeriod(uint256) (runs: 1004, μ: 408039, ~: 408063)
LockTest:test_LockFailsWithNoStake() (gas: 91490) LockTest:test_LockFailsWithNoStake() (gas: 91490)
LockTest:test_LockFailsWithZero() (gas: 364923) LockTest:test_LockFailsWithZero() (gas: 364923)
LockTest:test_LockMultipleTimesExceedMaxLock() (gas: 663872) LockTest:test_LockMultipleTimesExceedMaxLock() (gas: 663872)
@@ -80,12 +68,12 @@ NFTMetadataGeneratorSVGTest:testSetImageStringsRevert() (gas: 35891)
NFTMetadataGeneratorURLTest:testGenerateMetadata() (gas: 108341) NFTMetadataGeneratorURLTest:testGenerateMetadata() (gas: 108341)
NFTMetadataGeneratorURLTest:testSetBaseURL() (gas: 50631) NFTMetadataGeneratorURLTest:testSetBaseURL() (gas: 50631)
NFTMetadataGeneratorURLTest:testSetBaseURLRevert() (gas: 36066) NFTMetadataGeneratorURLTest:testSetBaseURLRevert() (gas: 36066)
RewardsStreamerMP_RewardsTest:testRewardsBalanceOf() (gas: 1329234) RewardsStreamerMP_RewardsTest:testRewardsBalanceOf() (gas: 1329190)
RewardsStreamerMP_RewardsTest:testSetRewards() (gas: 224724) RewardsStreamerMP_RewardsTest:testSetRewards() (gas: 224702)
RewardsStreamerMP_RewardsTest:testSetRewards_RevertsBadAmount() (gas: 61302) RewardsStreamerMP_RewardsTest:testSetRewards_RevertsBadAmount() (gas: 61280)
RewardsStreamerMP_RewardsTest:testSetRewards_RevertsBadDuration() (gas: 101060) RewardsStreamerMP_RewardsTest:testSetRewards_RevertsBadDuration() (gas: 101038)
RewardsStreamerMP_RewardsTest:testSetRewards_RevertsNotAuthorized() (gas: 39322) RewardsStreamerMP_RewardsTest:testSetRewards_RevertsNotAuthorized() (gas: 39322)
RewardsStreamerMP_RewardsTest:testTotalRewardsSupply() (gas: 762981) RewardsStreamerMP_RewardsTest:testTotalRewardsSupply() (gas: 762937)
StakeTest:test_StakeMultipleAccounts() (gas: 602123) StakeTest:test_StakeMultipleAccounts() (gas: 602123)
StakeTest:test_StakeMultipleAccountsAndRewards() (gas: 610639) StakeTest:test_StakeMultipleAccountsAndRewards() (gas: 610639)
StakeTest:test_StakeMultipleAccountsMPIncreasesMaxMPDoesNotChange() (gas: 1013731) StakeTest:test_StakeMultipleAccountsMPIncreasesMaxMPDoesNotChange() (gas: 1013731)
@@ -130,7 +118,7 @@ UnstakeTest:test_UnstakeOneAccount() (gas: 577982)
UnstakeTest:test_UnstakeOneAccountAndAccruedMP() (gas: 577933) UnstakeTest:test_UnstakeOneAccountAndAccruedMP() (gas: 577933)
UnstakeTest:test_UnstakeOneAccountAndRewards() (gas: 498234) UnstakeTest:test_UnstakeOneAccountAndRewards() (gas: 498234)
UnstakeTest:test_UnstakeOneAccountWithLockUpAndAccruedMP() (gas: 594073) UnstakeTest:test_UnstakeOneAccountWithLockUpAndAccruedMP() (gas: 594073)
UpdateVaultTest:test_UpdateAccount() (gas: 2501420) UpdateVaultTest:test_UpdateAccount() (gas: 2501398)
UpgradeTest:test_RevertWhenNotOwner() (gas: 3589969) UpgradeTest:test_RevertWhenNotOwner() (gas: 3589969)
UpgradeTest:test_UpgradeStakeManager() (gas: 9561860) UpgradeTest:test_UpgradeStakeManager() (gas: 9561860)
VaultRegistrationTest:test_VaultRegistration() (gas: 63138) VaultRegistrationTest:test_VaultRegistration() (gas: 63138)

View File

@@ -17,7 +17,6 @@ contract Karma is Initializable, ERC20Upgradeable, Ownable2StepUpgradeable, UUPS
using EnumerableSet for EnumerableSet.AddressSet; using EnumerableSet for EnumerableSet.AddressSet;
error Karma__TransfersNotAllowed(); error Karma__TransfersNotAllowed();
error Karma__MintAllowanceExceeded();
error Karma__DistributorAlreadyAdded(); error Karma__DistributorAlreadyAdded();
error Karma__UnknownDistributor(); error Karma__UnknownDistributor();
@@ -115,10 +114,6 @@ contract Karma is Initializable, ERC20Upgradeable, Ownable2StepUpgradeable, UUPS
* @param amount The amount of tokens to mint. * @param amount The amount of tokens to mint.
*/ */
function mint(address account, uint256 amount) external onlyOwner { function mint(address account, uint256 amount) external onlyOwner {
if (amount > _mintAllowance()) {
revert Karma__MintAllowanceExceeded();
}
_mint(account, amount); _mint(account, amount);
} }
@@ -142,16 +137,6 @@ contract Karma is Initializable, ERC20Upgradeable, Ownable2StepUpgradeable, UUPS
return super.totalSupply() + _externalSupply(); return super.totalSupply() + _externalSupply();
} }
function _mintAllowance() internal view returns (uint256) {
uint256 maxSupply = _externalSupply() * 3;
uint256 fullTotalSupply = _totalSupply();
if (maxSupply <= fullTotalSupply) {
return 0;
}
return maxSupply - fullTotalSupply;
}
/** /**
* @notice Returns the external supply of the token. * @notice Returns the external supply of the token.
* @dev The external supply is the sum of the rewards from all reward distributors. * @dev The external supply is the sum of the rewards from all reward distributors.
@@ -202,15 +187,6 @@ contract Karma is Initializable, ERC20Upgradeable, Ownable2StepUpgradeable, UUPS
return rewardDistributors.values(); return rewardDistributors.values();
} }
/**
* @notice Returns the mint allowance.
* @dev The mint allowance is the difference between the external supply and the total supply.
* @return The mint allowance.
*/
function mintAllowance() public view returns (uint256) {
return _mintAllowance();
}
/** /**
* @notice Returns the balance of an account. * @notice Returns the balance of an account.
* @dev The balance of an account is the sum of the balance of the account and the external rewards * @dev The balance of an account is the sum of the balance of the account and the external rewards

View File

@@ -6,7 +6,6 @@ import { DeployKarmaScript } from "../script/DeployKarma.s.sol";
import { DeploymentConfig } from "../script/DeploymentConfig.s.sol"; import { DeploymentConfig } from "../script/DeploymentConfig.s.sol";
import { Karma } from "../src/Karma.sol"; import { Karma } from "../src/Karma.sol";
import { KarmaDistributorMock } from "./mocks/KarmaDistributorMock.sol"; import { KarmaDistributorMock } from "./mocks/KarmaDistributorMock.sol";
import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol";
contract KarmaTest is Test { contract KarmaTest is Test {
Karma public karma; Karma public karma;
@@ -168,82 +167,3 @@ contract KarmaOwnershipTest is KarmaTest {
assertEq(karma.owner(), alice); assertEq(karma.owner(), alice);
} }
} }
contract KarmaMintAllowanceTest is KarmaTest {
function setUp() public override {
super.setUp();
}
function testMintAllowance_Available() public {
vm.startBroadcast(owner);
karma.setReward(address(distributor1), 1000 ether, 1000);
karma.setReward(address(distributor2), 2000 ether, 2000);
vm.stopBroadcast();
// 3000 external => maxSupply = 9000
distributor1.setTotalKarmaShares(1000 ether);
distributor2.setTotalKarmaShares(2000 ether);
vm.prank(owner);
karma.mint(owner, 500 ether);
// totalSupply = 3500
uint256 mintAllowance = karma.mintAllowance();
assertEq(mintAllowance, 5500 ether);
}
function testMintAllowance_NotAvailable() public {
vm.startBroadcast(owner);
karma.setReward(address(distributor1), 1000 ether, 1000);
karma.setReward(address(distributor2), 2000 ether, 2000);
vm.stopBroadcast();
// 3000 external => maxSupply = 9000
distributor1.setTotalKarmaShares(1000 ether);
distributor2.setTotalKarmaShares(2000 ether);
vm.prank(owner);
karma.mint(owner, 6000 ether);
// totalSupply = 9_000
uint256 mintAllowance = karma.mintAllowance();
assertEq(mintAllowance, 0);
}
function testMint_RevertWithAllowanceExceeded() public {
vm.startBroadcast(owner);
karma.setReward(address(distributor1), 1000 ether, 1000);
karma.setReward(address(distributor2), 2000 ether, 2000);
vm.stopBroadcast();
// 3000 external => maxSupply = 9000
distributor1.setTotalKarmaShares(1000 ether);
distributor2.setTotalKarmaShares(2000 ether);
vm.prank(owner);
karma.mint(owner, 500 ether);
// totalSupply = 3500
// allowed to mint 5500
vm.prank(owner);
vm.expectRevert(Karma.Karma__MintAllowanceExceeded.selector);
karma.mint(owner, 6000 ether);
}
function testMint_Ok() public {
vm.startBroadcast(owner);
karma.setReward(address(distributor1), 1000 ether, 1000);
karma.setReward(address(distributor2), 2000 ether, 2000);
vm.stopBroadcast();
// 3000 external => maxSupply = 9000
distributor1.setTotalKarmaShares(1000 ether);
distributor2.setTotalKarmaShares(2000 ether);
vm.prank(owner);
karma.mint(owner, 500 ether);
assertEq(karma.totalSupply(), 3500 ether);
// totalSupply = 3500
// allowed to mint 5500
vm.prank(owner);
karma.mint(owner, 5500 ether);
assertEq(karma.totalSupply(), 9000 ether);
}
}