-
Notifications
You must be signed in to change notification settings - Fork 969
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* forge install: erc-6909 * migrate 1155 to 6909 * rm old 6909 * forge install: erc-6909 * add event arg * rm old 6909 * forge install: erc-6909 * update test event * Add gas snaps * squash: support arbitrary calldata on test routers (#361) * Chore: update licenses (#364) * chore: update README * chore: update interface licenses * chore: update Hooks.sol license * chore: update types licenses * Migrate SwapMath tests to foundry (#363) * write SwapMath Tests * write gas snapshots tests * delete SwapMath hardhat implementation * eliminate SwapMathTest + add gas snapshots * delete js snapshots * migrate echidna test * forge fmt * test titles * remove console import --------- Co-authored-by: Job Mwitah <[email protected]> Co-authored-by: Mwitah <[email protected]> * add base hook for tests (#377) * change natspec to ILockCallback.lockAcquired (#376) * feat: update to solidity 0.8.22 (#378) - Enforce evm_version to avoid compiling push0 - Remove unchecked loops which are unchecked by default in 0.8.22 * Cache dynamic fee in slot0 (#360) * Bug: Require different currencies (#380) * Require different currencies * hardhat snapshots * Add new custom type function * remove extra paren * Replace MockERC20 with solmate's MockERC20 (#374) * rename MockERC20 -> UniMockERC20 * remove UniMockERC20 in favor of solmate/MockERC20 * update snapshots * Fixing compiler warnings (#386) * fix: add gas snaps for swaps with 1155 as input/output (#383) * Add snaps for 1155 swaps * remove lib * Add gas prefix * Delete Hardhat (#372) Co-authored-by: Sara Reynolds <[email protected]> Co-authored-by: Alice <[email protected]> Co-authored-by: Sara Reynolds <[email protected]> * feat: use standard forge directory structure (#389) * feat: standard foundry directory structure This commit moves to the standard foundry directory structure with contracts in src/ and tests in test/. * feat: remove JS stuff * fix: remove out dir * fix: workflows * fix: re-add js scripts * fix: add back js stuff * feat: yarn lock * fix: alice comments * Improve forge tests (#391) * Updating lots of tests * Fixed final test * remove console2 * mark PR comment * Fix Issue #397: Incorrect Documentation (#399) * feat: move whitepapers to docs dir to cleanup root (#393) * feat: move whitepapers to docs dir to cleanup root * fix: remove draft so links dont break * add snapshots to CI with tolerance (#401) * Implement Claims accounting as minimal balance (#379) * Add MinimalBalance * Initial commmit * Router custodies Claims, has access to priviledged burnFrom anbd tests * updategas * remove 6909 lib * yarn snapshots * Add gas snaps for swapping from claims balance * fix gas snaps by removing aux logic in router * gas * remove lib * Add transfer to minimalBalance, update tests * nit: rename * add back custom errors * move addition out of unchecked * Add transfer overflow check * Rename impl test * nit comments * comment# * Remove unused inheritance * remove comment * Remove poolClaimTest * fix interfaces * Feedback * Add address(0) and address(this) check for transfer * remove address(0) check * Remove batchBurn * Move mock claims to diff file * Add gas snaps for collect protocol fees * Add balance checks, make balances mapping private * Fix imports * fix fs perms * Remove uint256 in mapping and use Currency * feedback * Add gas snaps * fix: whitepaper link (#400) I accidentally broke the link from readme * Add solc binaries and transient storage lock library (#395) * Updated solc setup and instructions (#406) * Added contribution instructions * missing space * Updated solc config * feat: move JS scripts to subdir and add helper (#405) This commit moves our JS helper scripts into a test subdirectory and adds a helper abstract contract to more easily build the ffi commands to interop with javascript testers * Set tick spacing range as constants (#369) * Set tick spacing range as constants While tick and tick spacing both use int24 as their type, each has a different range. Tick spacing has a range of [1, 32767]. This commit updates Tick test cases to use proper tick spacing range instead that of tick. Resolves issue #371 * Restore a unit test on tick spacing liquidity This commit adds back the unit test that checks for tick spacing liquidity given the entire tick range as the input argument. This is an alternative change mentioned on the issue referred below. resolves #369 * Remove duplicate constants from test suite This commit moves MIN_TICK, MAX_TICK, MIN_TICK_SPACING, and MAX_TICK_SPACING constants from test suite constants file to TickMath library. Previous to this commit, TickMath library declared MIN_TICK and MAX_TICK constants with the same value from the test suite constants file. Removing duplicate constants from the test file and referencing them from the production file prevents future dicrepancies between production and test environments. * Remove unused import * Remove unnecessary override keywords * Update forge snapshots * Part 1: Improve forge tests (#407) * Revert messages * Common take and settle contract for tests * improving swap and take tests * add asserts for modify position * extra asserts in modify position * asserts in donate test * More deployment helpers * native set up in deployer * simplify initialize tests * few more corrections * more cleanup * remove console logs * snapshots and test fix post merge * snapshots * accidentally pushed foundry.toml * PR comments * remove forge snapshot --check (#417) * feat: update justfile with custom solc (#418) For folks who dont want to update their global env they can use `just test` or `just build` which sets solc using cli arg * Fix typos (#365) * Fix typos * Fix typo in src/libraries/Lockers.sol * Update just prep and build (#421) * udpate prep and add build * Update justfile * fix tests * remove totalsupply * remove lib * remove solmate * forge install: solmate main * Add comment * Add solmate 6909 and remove claims * feat: add variadic args to justfile (#423) allows to pass on args to forge i.e. `forge test --mt fuzz` * move up settle and remove solmate * forge install: solmate * copy erc6909 locally and use _mint and _burn * forge fmt * remove lib * forge install: solmate v6 * rmeove solmate * forge install: solmate 2001af43ae * fix gas snaps * remove unchecked without totalSupply * Lock on initialize (#424) * Lock on initialize * Rename initialize error * fix CI fuzz edge case * NoOp implementation with flag (#324) * cherrypicking * tests running and update snaps * test supoprt * format and run hardhat tests * remove irrelevant comment * test noops * add tests for noop * lint and snapshots * fix hook tests * clean * foundry toml * helper function * Revert early if pool isnt initialized * Extra tests * Tests NoOps on disallowed hooks fail * linting * snapshots * helper function for initialized pool * PR comments * PR comment test coverage * Final PR comments * comments about sentinel value * Fix masking tests * decrease calls to assume --------- Co-authored-by: Alex <[email protected]> Co-authored-by: hensha256 <[email protected]> * update testss * rm solmate * forge install: solmate main * Use solmate 6909 * fmt * cache msg sender * Explain different solc options (#429) * explain solc options * Add reference in readme * random linting issue * Access lock (#404) * Fix broken tests that were using old claims balance format * Add V46909 and reorder params * Add V46909 and Mock contract for test * Add revert tests * burnFrom internal * remove old gas snaps and add native tests * feat: add lock target (#300) * feat: add lock target * feat: store lockOriginator * fix: tests * feat: lockOriginator => lockCaller * feat: add invalid locker tests * fix: remove unused params * fix tests and snaps * forge fmt * expectEmit() all * expect emit all * Prevent ProtocolFeeController from bricking pool initialization on revert (#362) * Default protocol fees to 0 if protocolFeeController reverts * snapshots * fix comment * add another malicious contract * remove useless var assignment * make call and decode return in assembly * fix typo in var assingmenet * clean up tests * update snapshots# * check withdrawFee == 0 on tests too * add test * separate out fetchProtocolFees and checkProtocolFees * manually revert in setProtocolFees * Add success return value to fetchProtocolFEes * Add test for FeeTooLarge passing on initialzie but not on setProtocolFees * check low level call success * clean up * add comment * simplify * udpate snaps * fix compiler warnings * fix result type * fix formatting * Add more descriptive error message * Change error name again * Add comments * update gas specs * fix merge conflict t4ests * fix tests * Add tests for setProtocolFee with invalid controllers * Add missing snaps * Feedback changes * fix initialize tests * fix fmt * Fix comment * comments and revise order --------- Co-authored-by: Sara Reynolds <[email protected]> * feedback * Add IERC69009, does not compile * Revert "Add IERC69009, does not compile" This reverts commit 4e89408. * added delta overflow checks (#433) * add pool getters (#438) * add getters * update snaps * clean test * A few cleanup tasks (#437) * Fix compiler warnings * todo for mapping transient * fixing tests with fuzzing * remove console logs * Update PoolDonateTest.sol * remove amount overload --------- Co-authored-by: Sara Reynolds <[email protected]> * Remove hook fees and protocol fee on withdrawal (#432) * Remove hook fees and protocol fee on withdrawal * hook fee tests * Update AccessLockHook.sol * assume -> bound * more comments on fee grnaularity * refactor: hooks callsites (#439) * feat: hooks refactor * fix: tests * feat: noop -> shouldExecute * fix: remove shouldCall functions for helper * fix: using for in test * fix: alice comment * merge conflicts * fix fialing test * Copy solmate 6909 locally to get interface inheritance * natspec * expose getters in pool interface * Use id for mint/burn instead of currency * forge fmt * Add burnFrom no approval test * feedback * feedback * forge install: ERC-6909 main * remove lib * Add commit SHA * merge conflicts galore * forge install: solmate 4b47a19038b798b4a33d9749d25e570443520647 * fix conflict * fix libs * del * forge install: openzeppelin-contracts v4.4.2 * fix tests from conflcits and gas * forge fmt * removed unused file * fix: faling fuzz tests (#441) * Add failing fuzz test * Add bounds * added out of range checks * changed assume to bound * forge fmt * changed Position -> Liquidity on merge main * moved amount helper to utils --------- Co-authored-by: Austin Adams <[email protected]> * fix gas snap * forge test * feedback --------- Co-authored-by: jtriley.eth <[email protected]> Co-authored-by: saucepoint <[email protected]> Co-authored-by: Erin Koen <[email protected]> Co-authored-by: Emily Williams <[email protected]> Co-authored-by: Job Mwitah <[email protected]> Co-authored-by: Mwitah <[email protected]> Co-authored-by: Sara Reynolds <[email protected]> Co-authored-by: Ed Mazurek <[email protected]> Co-authored-by: marktoda <[email protected]> Co-authored-by: Alice <[email protected]> Co-authored-by: Sara Reynolds <[email protected]> Co-authored-by: Jose Carlos Montero Gomez <[email protected]> Co-authored-by: hyunchel <[email protected]> Co-authored-by: xiaolou86 <[email protected]> Co-authored-by: emma <[email protected]> Co-authored-by: Alex <[email protected]> Co-authored-by: hensha256 <[email protected]> Co-authored-by: Austin Adams <[email protected]> Co-authored-by: Austin Adams <[email protected]>
- Loading branch information
1 parent
99cd9d5
commit 1f350fa
Showing
52 changed files
with
715 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
323249 | ||
323277 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
200141 | ||
200111 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
200109 | ||
200079 |
2 changes: 1 addition & 1 deletion
2
.forge-snapshots/before swap hook, already cached dynamic fee.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
194300 | ||
194367 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
146667 | ||
146705 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
137771 | ||
137750 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
185216 | ||
185163 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
27033 | ||
27001 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
15224 | ||
15223 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
74200 | ||
74274 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
323262 | ||
323262 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
200100 | ||
200100 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
200042 | ||
200042 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
255129 | ||
255189 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
58013 | ||
58076 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
38699 | ||
38667 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
23823 | ||
25102 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
106962 | ||
106952 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
208322 | ||
208312 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
204612 | ||
204602 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
195638 | ||
195676 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
204206 | ||
204244 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
173543 | ||
174149 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
172131 | ||
172798 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
126266 | ||
126304 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
113757 | ||
113795 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
133995 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
132930 | ||
132930 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
129926 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
198205 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
215075 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
216399 | ||
216399 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
193401 | ||
193468 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
113735 | ||
113773 |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
51304 | ||
51425 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
200144 | ||
200232 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule forge-std
updated
11 files
+1 −1 | package.json | |
+11 −3 | src/StdChains.sol | |
+2 −2 | src/StdCheats.sol | |
+61 −33 | src/StdUtils.sol | |
+106 −1 | src/Vm.sol | |
+216 −0 | src/mocks/MockERC20.sol | |
+221 −0 | src/mocks/MockERC721.sol | |
+2 −6 | test/StdChains.t.sol | |
+2 −2 | test/Vm.t.sol | |
+441 −0 | test/mocks/MockERC20.t.sol | |
+721 −0 | test/mocks/MockERC721.t.sol |
Submodule solmate
updated
14 files
+211 −181 | .gas-snapshot | |
+1 −0 | README.md | |
+1 −1 | package-lock.json | |
+1 −1 | package.json | |
+26 −1 | src/test/CREATE3.t.sol | |
+378 −0 | src/test/ERC6909.t.sol | |
+1 −2 | src/test/SafeCastLib.t.sol | |
+14 −0 | src/test/SignedWadMath.t.sol | |
+22 −0 | src/test/utils/mocks/MockERC6909.sol | |
+118 −0 | src/tokens/ERC6909.sol | |
+5 −1 | src/utils/CREATE3.sol | |
+1 −1 | src/utils/SafeCastLib.sol | |
+7 −7 | src/utils/SafeTransferLib.sol | |
+12 −2 | src/utils/SignedWadMath.sol |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity >=0.8.0; | ||
|
||
import {IERC6909Claims} from "./interfaces/external/IERC6909Claims.sol"; | ||
|
||
/// @notice Minimalist and gas efficient standard ERC6909 implementation. | ||
/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/tokens/ERC6909.sol) | ||
/// @dev Copied from the commit at 4b47a19038b798b4a33d9749d25e570443520647 | ||
/// @dev This contract has been modified from the implementation at the above link. | ||
abstract contract ERC6909 is IERC6909Claims { | ||
/*////////////////////////////////////////////////////////////// | ||
EVENTS | ||
//////////////////////////////////////////////////////////////*/ | ||
|
||
event OperatorSet(address indexed owner, address indexed operator, bool approved); | ||
|
||
event Approval(address indexed owner, address indexed spender, uint256 indexed id, uint256 amount); | ||
|
||
event Transfer(address caller, address indexed from, address indexed to, uint256 indexed id, uint256 amount); | ||
|
||
/*////////////////////////////////////////////////////////////// | ||
ERC6909 STORAGE | ||
//////////////////////////////////////////////////////////////*/ | ||
|
||
mapping(address => mapping(address => bool)) public isOperator; | ||
|
||
mapping(address => mapping(uint256 => uint256)) public balanceOf; | ||
|
||
mapping(address => mapping(address => mapping(uint256 => uint256))) public allowance; | ||
|
||
/*////////////////////////////////////////////////////////////// | ||
ERC6909 LOGIC | ||
//////////////////////////////////////////////////////////////*/ | ||
|
||
function transfer(address receiver, uint256 id, uint256 amount) public virtual returns (bool) { | ||
balanceOf[msg.sender][id] -= amount; | ||
|
||
balanceOf[receiver][id] += amount; | ||
|
||
emit Transfer(msg.sender, msg.sender, receiver, id, amount); | ||
|
||
return true; | ||
} | ||
|
||
function transferFrom(address sender, address receiver, uint256 id, uint256 amount) public virtual returns (bool) { | ||
if (msg.sender != sender && !isOperator[sender][msg.sender]) { | ||
uint256 allowed = allowance[sender][msg.sender][id]; | ||
if (allowed != type(uint256).max) allowance[sender][msg.sender][id] = allowed - amount; | ||
} | ||
|
||
balanceOf[sender][id] -= amount; | ||
|
||
balanceOf[receiver][id] += amount; | ||
|
||
emit Transfer(msg.sender, sender, receiver, id, amount); | ||
|
||
return true; | ||
} | ||
|
||
function approve(address spender, uint256 id, uint256 amount) public virtual returns (bool) { | ||
allowance[msg.sender][spender][id] = amount; | ||
|
||
emit Approval(msg.sender, spender, id, amount); | ||
|
||
return true; | ||
} | ||
|
||
function setOperator(address operator, bool approved) public virtual returns (bool) { | ||
isOperator[msg.sender][operator] = approved; | ||
|
||
emit OperatorSet(msg.sender, operator, approved); | ||
|
||
return true; | ||
} | ||
|
||
/*////////////////////////////////////////////////////////////// | ||
ERC165 LOGIC | ||
//////////////////////////////////////////////////////////////*/ | ||
|
||
function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) { | ||
return interfaceId == 0x01ffc9a7 // ERC165 Interface ID for ERC165 | ||
|| interfaceId == 0x0f632fb3; // ERC165 Interface ID for ERC6909 | ||
} | ||
|
||
/*////////////////////////////////////////////////////////////// | ||
INTERNAL MINT/BURN LOGIC | ||
//////////////////////////////////////////////////////////////*/ | ||
|
||
function _mint(address receiver, uint256 id, uint256 amount) internal virtual { | ||
balanceOf[receiver][id] += amount; | ||
|
||
emit Transfer(msg.sender, address(0), receiver, id, amount); | ||
} | ||
|
||
function _burn(address sender, uint256 id, uint256 amount) internal virtual { | ||
balanceOf[sender][id] -= amount; | ||
|
||
emit Transfer(msg.sender, sender, address(0), id, amount); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity >=0.8.0; | ||
|
||
import {ERC6909} from "./ERC6909.sol"; | ||
|
||
/// @notice ERC6909Claims inherits ERC6909 and implements an internal burnFrom function | ||
abstract contract ERC6909Claims is ERC6909 { | ||
/// @notice Burn `amount` tokens of token type `id` from `from`. | ||
/// @dev if sender is not `from` they must be an operator or have sufficient allowance. | ||
/// @param from The address to burn tokens from. | ||
/// @param id The currency to burn. | ||
/// @param amount The amount to burn. | ||
function _burnFrom(address from, uint256 id, uint256 amount) internal { | ||
address sender = msg.sender; | ||
if (from != sender && !isOperator[from][sender]) { | ||
uint256 senderAllowance = allowance[from][sender][id]; | ||
if (senderAllowance != type(uint256).max) { | ||
allowance[from][sender][id] = senderAllowance - amount; | ||
} | ||
} | ||
_burn(from, id, amount); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.