stargate-protocol / stargate-v2

Other
8 stars 5 forks source link

🪲 assert a cap for caller bps #75

Closed ryandgoulding closed 5 days ago

ryandgoulding commented 5 days ago

This helps avoid caller applications to OFTWrapper from setting fee bps arbitrarily high. This is not needed for the defaultBps, as only the owner can set that.

github-actions[bot] commented 5 days ago

Gas profile

src/StargateOFT.sol:StargateOFT contract
Deployment Cost Deployment Size
4063849 19618
Function Name min avg median max # calls
getAddressConfig 1441 1441 1441 1441 256
paths 568 1653 2568 2568 5609
plannerFee 273 273 273 273 2
quoteOFT 5052 8732 9552 13147 1998
quoteSend 3170 73511 115158 126658 1335
sendToken 66010 349803 453777 513843 1079
setAddressConfig 125476 125476 125476 125476 48
setOFTPath 47758 47758 47758 47758 48
stargateType 340 340 340 340 530
token 326 326 326 326 1299
treasuryFee 2413 2413 2413 2413 244
withdrawPlannerFee 24792 26986 24792 31492 232
withdrawTreasuryFee 48484 49438 48520 65632 222
src/StargatePool.sol:StargatePool contract
Deployment Cost Deployment Size
6374155 32017
Function Name min avg median max # calls
addTreasuryFee 49500 49544 49548 49560 270
deposit 72474 142016 153390 162810 2121
getAddressConfig 11419 11419 11419 11419 256
lpToken 280 280 280 280 417
paths 634 1418 634 2634 7529
plannerFee 284 284 284 284 2
poolBalance 432 1432 1432 2432 4
quoteOFT 5496 8158 5496 15996 12564
quoteRedeemSend 126597 126597 126597 126597 504
quoteSend 3171 17681 3171 134149 6758
recoverToken 41908 47294 47614 47614 372
redeem 69563 69617 69623 69635 256
redeemSend 60262 487306 520622 520694 504
redeemable 8141 8141 8141 8151 368
sendToken 67179 178781 117777 753231 6758
setAddressConfig 125486 125496 125498 125498 54
setOFTPath 47759 47759 47759 47759 96
sharedDecimals 272 272 272 272 5
stargateType 340 340 340 340 2954
token 326 326 326 326 11203
treasuryFee 2413 2413 2413 2413 280
tvl 375 375 375 375 4
withdrawPlannerFee 24837 27430 24837 31537 248
withdrawTreasuryFee 47179 47339 47227 64291 274
src/StargatePoolMigratable.sol:StargatePoolMigratable contract
Deployment Cost Deployment Size
6594865 33091
Function Name min avg median max # calls
allowBurn 46380 46397 46404 46416 256
burnAllowanceSD 419 419 419 419 512
burnLocked 67178 67188 67199 67199 256
deposit 153451 155881 155878 158302 512
getAddressConfig 1464 1464 1464 1464 768
lpToken 325 325 325 325 256
paths 612 612 612 612 4864
poolBalance 432 432 432 432 512
quoteOFT 5496 8307 5711 14229 1792
quoteSend 3214 54904 44202 126702 1280
sendToken 115653 403050 479123 538260 1024
setAddressConfig 125521 125521 125521 125521 256
setOFTPath 25821 25821 25821 25821 256
stargateType 318 318 318 318 1024
token 326 326 326 326 1536
tvl 375 375 375 375 512
src/StargatePoolNative.sol:StargatePoolNative contract
Deployment Cost Deployment Size
6357386 31870
Function Name min avg median max # calls
deposit 122165 122186 122189 122201 256
getAddressConfig 11419 11419 11419 11419 256
lpToken 280 280 280 280 59
paths 2634 2634 2634 2634 8
quoteOFT 12211 12211 12211 12211 256
quoteSend 80159 80159 80159 80159 256
sendToken 467950 467992 467998 468022 256
setAddressConfig 125498 125498 125498 125498 24
setOFTPath 47759 47759 47759 47759 48
sharedDecimals 272 272 272 272 1
stargateType 340 340 340 340 282
token 326 326 326 326 519
src/feelibs/FeeLibV1.sol:FeeLibV1 contract
Deployment Cost Deployment Size
888161 4245
Function Name min avg median max # calls
applyFeeView 1720 2433 1789 4763 18362
feeConfigs 850 1308 850 2850 1117
owner 329 329 329 329 1280
setFeeConfig 25191 39806 35313 52653 4672
setPaused 30318 35218 30342 47478 1802
src/messaging/CreditMessaging.sol:CreditMessaging contract
Deployment Cost Deployment Size
3272394 15229
Function Name min avg median max # calls
allowInitializePath 839 1839 1839 2839 3104
assetIds 645 1313 645 2645 1544
endpoint 328 328 328 328 768
planner 428 1803 2428 2428 5502
quoteSendCredits 7636 98998 123497 510416 6270
sendCredits 24373 362355 432126 737891 7038
setAssetId 33412 70211 76724 93824 1920
setGasLimit 47461 47526 47509 47689 1268
setPeer 47704 47727 47728 47752 1012
setPlanner 46967 46997 46967 47195 76
src/messaging/TokenMessaging.sol:TokenMessaging contract
Deployment Cost Deployment Size
4671385 21997
Function Name min avg median max # calls
MSG_TYPE_TAXI 317 317 317 317 762
allowInitializePath 867 1867 1867 2867 6176
assetIds 623 623 623 623 6137
busQueues 815 1534 815 2815 3227
driveBus 424849 531935 544513 5143264 2340
endpoint 285 285 285 285 62
initializeBusQueueStorage 11462140 11462140 11462140 11462140 66
quoteDriveBus 44818 104158 124413 277024 2340
quoteRideBus 984 1513 994 2994 6908
quoteTaxi 40706 95722 118706 125666 3774
setAssetId 33456 55267 55866 93868 844
setEnforcedOptions 52643 52643 52643 52643 244
setFares 31117 36341 31117 48217 346
setGasLimit 48137 48137 48137 48149 346
setMaxNumPassengers 30479 47298 47579 47579 244
setNativeDropAmount 47568 47568 47568 47568 244
setPeer 47700 47700 47700 47700 346
setPlanner 46989 47129 47217 47217 172
src/peripheral/rewarder/StargateMultiRewarder.sol:StargateMultiRewarder contract
Deployment Cost Deployment Size
2599362 12028
Function Name min avg median max # calls
allocPointsByReward 1543 3240 2895 4098 17
allocPointsByStake 2932 3232 2932 4135 20
connect 21876 34185 34743 45378 8
extendReward 24142 41938 52647 52647 15
getRewards 3580 8983 7492 18211 145
onUpdate 22786 22786 22786 22786 2
renounceOwnership 432 1432 1432 2432 2
rewardDetails 1291 1379 1291 7291 476
rewardTokens 1190 1522 1443 2866 20
setAllocPoints 25113 215035 230705 350376 12
setReward 24632 182094 171633 208339 1558
staking 251 251 251 251 2
stopReward 75898 107366 105606 140595 3
transferOwnership 24059 28420 28610 28610 48
src/peripheral/rewarder/StargateStaking.sol:StargateStaking contract
Deployment Cost Deployment Size
1379340 6087
Function Name min avg median max # calls
balanceOf 816 1565 816 2816 3475
claim 29761 68774 55635 135846 12
deposit 29296 85002 91741 199914 1553
depositTo 29796 29835 29835 29875 2
emergencyWithdraw 29146 68467 70763 70763 78
isPool 628 1128 628 2628 8
owner 2343 2343 2343 2343 2
rewarder 623 623 623 623 659
setPool 24530 141898 142531 142531 1325
tokens() 1538 2076 2235 2802 14
tokens(uint256,uint256) 750 1629 1486 2183 14
tokensLength 437 837 437 2437 5
totalSupply 620 1309 620 2620 1519
transferOwnership 28588 28588 28588 28588 45
withdraw 29328 51387 34110 151010 269
withdrawToAndCall 30206 92398 98830 144967 16
src/peripheral/zapper/StargateZapperV1.sol:StargateZapperV1 contract
Deployment Cost Deployment Size
1937286 9260
Function Name min avg median max # calls
configureLpToken 24289 73152 77028 77033 26
configureV1Pool 24284 81521 112456 115013 10
depositAndStake 24360 167301 213192 279961 19
factoryV1 262 262 262 262 1
lpToAsset 619 619 619 619 2
lpToPool 621 621 621 621 1
migrateV1LpToV2Stake 28578 138333 35624 374971 9
onWithdrawReceived 22935 22935 22935 22935 4
receive 21055 21055 21055 21055 1
renounceOwnership 23518 23518 23518 23518 1
routerV1 284 284 284 284 1
staking 284 284 284 284 1
sweep 24667 39680 35059 62439 8
transferOwnership 24059 24059 24059 24059 1
src/usdc/StargateOFTUSDC.sol:StargateOFTUSDC contract
Deployment Cost Deployment Size
4079767 19674
Function Name min avg median max # calls
getAddressConfig 7441 7441 7441 7441 2
paths 568 853 568 2568 14
quoteOFT 5052 8650 9552 11799 10
quoteSend 5170 81662 113158 126658 6
sendToken 112474 322327 322327 532181 4
setAddressConfig 125476 125476 125476 125476 2
stargateType 340 340 340 340 2
token 326 326 326 326 4
src/usdc/StargatePoolUSDC.sol:StargatePoolUSDC contract
Deployment Cost Deployment Size
6555153 32898
Function Name min avg median max # calls
allowBurn 46437 46437 46437 46437 2
burnAllowanceSD 419 419 419 419 2
burnLockedUSDC 53955 60662 60662 67370 2
deposit 153334 160426 160426 167518 4
getAddressConfig 1464 4130 1464 9464 6
lpToken 303 303 303 303 2
paths 612 612 612 612 38
poolBalance 432 432 432 432 2
quoteOFT 5496 9236 7496 14229 14
quoteSend 5214 69404 44202 126702 10
sendToken 115572 407606 483695 547464 8
setAddressConfig 125509 125515 125515 125521 4
setOFTPath 25824 36780 36780 47737 4
stargateType 318 318 318 318 8
token 326 326 326 326 12
tvl 375 375 375 375 4
src/usdc/impl/v2/FiatTokenV2_2.sol:FiatTokenV2_2 contract
Deployment Cost Deployment Size
4345618 19890
Function Name min avg median max # calls
approve 26841 26841 26841 26841 8
balanceOf 660 760 660 2660 20
blacklister 427 427 427 427 1
burn 11938 14204 11938 18738 3
configureMinter 50627 50627 50627 50627 3
decimals 381 1181 381 2381 5
initialize 4302 101226 106539 180719 6
initializeV2 4797 45821 50262 71568 6
initializeV2_1 2490 30196 28095 49287 6
initializeV2_2 2868 20654 18990 34887 6
isMinter 2632 2632 2632 2632 1
masterMinter 449 449 449 449 1
mint 26835 43935 43935 61035 5
owner 399 399 399 399 1
pauser 449 449 449 449 1
removeMinter 13927 13927 13927 13927 1
rescuer 400 400 400 400 1
totalSupply 395 395 395 395 6
transfer 16366 16366 16366 16366 4
transferFrom 22358 33045 39458 39458 8
transferOwnership 7061 7061 7061 7061 1
updateBlacklister 8775 8775 8775 8775 1
updateMasterMinter 8731 8731 8731 8731 1
updatePauser 8754 8754 8754 8754 1
updateRescuer 25877 25877 25877 25877 1
src/utils/LPToken.sol:LPToken contract
Deployment Cost Deployment Size
0 0
Function Name min avg median max # calls
approve 46284 46284 46284 46284 1
balanceOf 563 1901 2563 2563 2466
stargate 305 305 305 305 24
totalSupply 2349 2349 2349 2349 4
src/utils/OFTTokenERC20.sol:OFTTokenERC20 contract
Deployment Cost Deployment Size
1046130 5255
Function Name min avg median max # calls
addMinter 23872 46906 47337 47337 59
approve 29184 42362 46284 46332 1065
balanceOf 626 1008 626 2626 6427
burnFrom 24002 31166 34749 34749 3
decimals 357 580 357 2357 430
mint 23990 61934 70222 70522 253
minters 619 1119 619 2619 12
name 1198 1198 1198 1198 256
removeMinter 23829 25336 25172 27172 4
symbol 1241 1241 1241 1241 256
totalSupply 349 1349 1349 2349 6
src/utils/OFTTokenERC20Upgradeable.sol:OFTTokenERC20Upgradeable contract
Deployment Cost Deployment Size
1249206 5597
Function Name min avg median max # calls
addMinter 23872 47165 47124 47340 777
approve 26119 46231 46307 46403 1809
balanceOf 626 964 626 2626 4532
burnFrom 24002 34778 34790 35049 258
decimals 357 357 357 357 900
initialize 118786 135758 138698 138698 271
mint 24001 59430 70234 70594 1035
minters 619 1119 619 2619 12
name 1224 1224 1224 1224 256
owner 346 346 346 346 256
removeMinter 23829 25390 25391 27175 260
symbol 1244 1244 1244 1244 256
totalSupply 349 530 349 2349 2816
github-actions[bot] commented 5 days ago

Gas diff

Name Δ Δ%
test_estimateSendFeeV2_oft 3440 0.092
test_estimateSendFeeV2_proxy 3440 0.097
test_estimateSendFeeEpv2_oft 3461 0.110
test_estimateSendFee_oft 3462 0.114
test_estimateSendFee_proxy 3483 0.124
test_estimateSendFeeEpv2_adapter 3439 0.132
test_epv2_sendOFT 4738 0.281