Skip to content

Commit

Permalink
⚡ Optimize
Browse files Browse the repository at this point in the history
  • Loading branch information
z0r0z committed Jan 10, 2024
1 parent 0658b84 commit 483a7d1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 24 deletions.
24 changes: 12 additions & 12 deletions .gas-snapshot
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
DagonTest:testBurn(address,uint96) (runs: 256, μ: 153049, ~: 153049)
DagonTest:testDeploy() (gas: 2224552)
DagonTest:testFailBurnOverBalance(address,uint96) (runs: 256, μ: 187675, ~: 188686)
DagonTest:testFailBurnOverThreshold(address,uint96) (runs: 256, μ: 218927, ~: 219938)
DagonTest:testDeploy() (gas: 2218938)
DagonTest:testFailBurnOverBalance(address,uint96) (runs: 256, μ: 187519, ~: 188686)
DagonTest:testFailBurnOverThreshold(address,uint96) (runs: 256, μ: 218771, ~: 219938)
DagonTest:testFailInvalidThresholdExceedsSupply() (gas: 159129)
DagonTest:testFailInvalidThresholdExceedsSupply2() (gas: 164264)
DagonTest:testFailInvalidThresholdNull() (gas: 159177)
Expand All @@ -11,24 +11,24 @@ DagonTest:testFailIsValidSignatureWeighted() (gas: 231153)
DagonTest:testFailIsValidSignatureWeightedERC1155() (gas: 36227)
DagonTest:testFailIsValidSignatureWeightedERC20() (gas: 235720)
DagonTest:testFailIsValidSignatureWeightedERC6909() (gas: 227309)
DagonTest:testFailIsValidSignatureWeightedERC721() (gas: 208941)
DagonTest:testFailIsValidSignatureWeightedERC721() (gas: 208929)
DagonTest:testFailSetTokenInvalidStd(address) (runs: 256, μ: 158171, ~: 158171)
DagonTest:testFailTransferFromInactiveAuth(address,address,uint96) (runs: 256, μ: 191966, ~: 192899)
DagonTest:testFailTransferOverBalance(address,address,uint96) (runs: 256, μ: 186474, ~: 187407)
DagonTest:testFailTransferFromInactiveAuth(address,address,uint96) (runs: 256, μ: 192121, ~: 192899)
DagonTest:testFailTransferOverBalance(address,address,uint96) (runs: 256, μ: 186629, ~: 187407)
DagonTest:testInstall() (gas: 137482)
DagonTest:testIsValidSignature() (gas: 150958)
DagonTest:testIsValidSignature2of3() (gas: 197462)
DagonTest:testIsValidSignature3of3() (gas: 205252)
DagonTest:testIsValidSignatureOnchain() (gas: 197623)
DagonTest:testIsValidSignatureWeighted() (gas: 234909)
DagonTest:testIsValidSignatureWeightedERC1155() (gas: 247851)
DagonTest:testIsValidSignatureWeightedERC20() (gas: 247655)
DagonTest:testIsValidSignatureWeightedERC6909() (gas: 247825)
DagonTest:testIsValidSignatureWeightedERC721() (gas: 207552)
DagonTest:testIsValidSignatureWeightedERC1155() (gas: 247815)
DagonTest:testIsValidSignatureWeightedERC20() (gas: 247619)
DagonTest:testIsValidSignatureWeightedERC6909() (gas: 247789)
DagonTest:testIsValidSignatureWeightedERC721() (gas: 207528)
DagonTest:testNameAndSymbolAndDecimals(uint256) (runs: 256, μ: 15035, ~: 15035)
DagonTest:testSetAuth(address) (runs: 256, μ: 145746, ~: 145746)
DagonTest:testSetThreshold() (gas: 147627)
DagonTest:testSetToken(address) (runs: 256, μ: 148419, ~: 148419)
DagonTest:testSetURI() (gas: 165149)
DagonTest:testTransfer(address,address,uint88) (runs: 256, μ: 176139, ~: 176995)
DagonTest:testTransferWithAuth(address,address,uint96) (runs: 256, μ: 180155, ~: 180943)
DagonTest:testTransfer(address,address,uint88) (runs: 256, μ: 176217, ~: 176995)
DagonTest:testTransferWithAuth(address,address,uint96) (runs: 256, μ: 180039, ~: 180943)
16 changes: 4 additions & 12 deletions src/Dagon.sol
Original file line number Diff line number Diff line change
Expand Up @@ -346,9 +346,7 @@ contract Dagon is ERC6909 {
assembly ("memory-safe") {
mstore(0x00, 0x70a08231000000000000000000000000) // `balanceOf(address)`.
mstore(0x14, account) // Store the `account` argument.
if iszero(staticcall(gas(), token, 0x10, 0x24, 0x20, 0x20)) {
revert(codesize(), codesize()) // For gas estimation.
}
pop(staticcall(gas(), token, 0x10, 0x24, 0x20, 0x20))
amount := mload(0x20)
}
}
Expand All @@ -364,9 +362,7 @@ contract Dagon is ERC6909 {
mstore(0x00, 0x00fdd58e000000000000000000000000) // `balanceOf(address,uint256)`.
mstore(0x14, account) // Store the `account` argument.
mstore(0x34, id) // Store the `id` argument.
if iszero(staticcall(gas(), token, 0x10, 0x44, 0x20, 0x20)) {
revert(codesize(), codesize()) // For gas estimation.
}
pop(staticcall(gas(), token, 0x10, 0x44, 0x20, 0x20))
amount := mload(0x20)
mstore(0x34, 0)
}
Expand All @@ -376,9 +372,7 @@ contract Dagon is ERC6909 {
function _totalSupply(address token) internal view virtual returns (uint256 supply) {
assembly ("memory-safe") {
mstore(0x00, 0x18160ddd) // `totalSupply()`.
if iszero(staticcall(gas(), token, 0x1c, 0x04, 0x20, 0x20)) {
revert(codesize(), codesize()) // For gas estimation.
}
pop(staticcall(gas(), token, 0x1c, 0x04, 0x20, 0x20))
supply := mload(0x20)
}
}
Expand All @@ -393,9 +387,7 @@ contract Dagon is ERC6909 {
assembly ("memory-safe") {
mstore(0x00, 0xbd85b039) // `totalSupply(uint256)`.
mstore(0x20, id) // Store the `id` argument.
if iszero(staticcall(gas(), token, 0x1c, 0x24, 0x20, 0x20)) {
revert(codesize(), codesize()) // For gas estimation.
}
pop(staticcall(gas(), token, 0x1c, 0x24, 0x20, 0x20))
supply := mload(0x20)
}
}
Expand Down

0 comments on commit 483a7d1

Please sign in to comment.