-
Notifications
You must be signed in to change notification settings - Fork 525
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add base contracts and interfaces used in PositionManager #75
Conversation
contracts/base/PeripheryPayments.sol
Outdated
require(balanceToken >= amountMinimum, "Insufficient token"); | ||
|
||
if (balanceToken > 0) { | ||
TransferHelper.safeTransfer(IERC20Minimal(token), recipient, balanceToken); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added the IERC20Minimal casting here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably neater to us "using"
So at the top of the contract you write
using TransferHelper for IERC20Minimal
and then this line can be
token.safeTransfer(recipient, balanceToken
contracts/base/PeripheryPayments.sol
Outdated
function pay(address token, address payer, address recipient, uint256 value) internal { | ||
if (payer == address(this)) { | ||
// pay with tokens already in the contract (for the exact input multihop case) | ||
TransferHelper.safeTransfer(IERC20Minimal(token), recipient, value); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added the IERC20Minimal casting here and on line 37
/// @title Periphery Payments | ||
/// @notice Functions to ease deposits and withdrawals of ETH | ||
interface IPeripheryPayments { | ||
// TODO: figure out if we still need unwrapWETH9 from v3? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add comment here and took out unwrapWETH9
from v3
contracts/libraries/ChainId.sol
Outdated
library ChainId { | ||
/// @dev Gets the current chain ID | ||
/// @return chainId The current chain ID | ||
function get() internal view returns (uint256 chainId) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed pure
to view
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oo in solidity 0.8 we now have block.chainid
so this lib is no longer useful
/// @dev Fails with `STE` | ||
/// @param to The destination of the transfer | ||
/// @param value The value to be transferred | ||
function safeTransferETH(address to, uint256 value) internal { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added this because it's used in PeripheryPayments
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
consider using solmate's impl https://github.com/transmissions11/solmate/blob/main/src/utils/SafeTransferLib.sol
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added some initial thoughts!
contracts/base/BlockTimestamp.sol
Outdated
abstract contract BlockTimestamp { | ||
/// @dev Method that exists purely to be overridden for tests | ||
/// @return The current block timestamp | ||
function _blockTimestamp() internal view virtual returns (uint256) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think now that we work in forge this shouldnt be needed?
you can do vm.warp(timestamp)
in a test, and forge will set the current timestamp to that :)
contracts/base/ERC721Permit.sol
Outdated
require(spender != owner, "ERC721Permit: approval to current owner"); | ||
|
||
if (owner.code.length > 0) { | ||
require(IERC1271(owner).isValidSignature(digest, abi.encodePacked(r, s, v)) == 0x1626ba7e, "Unauthorized"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd change any
require(bool, error string)
into custom errors (its cheaper from a gas PoV and neater
error Unauthorized();
if (!bool) revert Unauthorized();
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it was introduced in 0.8.4 - you can see more about it here
contracts/base/PeripheryPayments.sol
Outdated
require(balanceToken >= amountMinimum, "Insufficient token"); | ||
|
||
if (balanceToken > 0) { | ||
TransferHelper.safeTransfer(IERC20Minimal(token), recipient, balanceToken); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably neater to us "using"
So at the top of the contract you write
using TransferHelper for IERC20Minimal
and then this line can be
token.safeTransfer(recipient, balanceToken
contracts/base/PeripheryPayments.sol
Outdated
|
||
/// @inheritdoc IPeripheryPayments | ||
function refundETH() external payable override { | ||
if (address(this).balance > 0) TransferHelper.safeTransferETH(msg.sender, address(this).balance); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can add another line
using TransferHelper for address
and do the same for this line too
contracts/base/ERC721Permit.sol
Outdated
) | ||
); | ||
address owner = ownerOf(tokenId); | ||
require(spender != owner, "ERC721Permit: approval to current owner"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ik mostly copied over from V3 but we should prob use custom errors now that we have them
contracts/base/ERC721Permit.sol
Outdated
require(spender != owner, "ERC721Permit: approval to current owner"); | ||
|
||
if (owner.code.length > 0) { | ||
require(IERC1271(owner).isValidSignature(digest, abi.encodePacked(r, s, v)) == 0x1626ba7e, "Unauthorized"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: magic 4 byte selector can be a constant with a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh agreed! But doesnt even need to be a constant
you could change 0x1626ba7e
to IER1271.isValidSignature.selector
contracts/base/PeripheryPayments.sol
Outdated
} | ||
|
||
/// @inheritdoc IPeripheryPayments | ||
function refundETH() external payable override { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: why payable here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yea thats weird - we should look in v3 sdk to see if we ever use this with value. since it just sends back to msg.sender anyways it seems useless
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great!! Some ideas
contracts/base/ERC721Permit.sol
Outdated
0x49ecf333e5b8c95c40fdafc95c1ad136e8914a8fb55e9dc8bb01eaa83a2df9ad; | ||
|
||
/// @inheritdoc IERC721Permit | ||
function permit(address spender, uint256 tokenId, uint256 deadline, uint8 v, bytes32 r, bytes32 s) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: maybe remove this permit fn for now and just use standard ERC721, and/or leave a comment saying auto-approve ERC721Permit2 in the future? Don't see a reason to keep dead code in especially since we didn't port tests over for it yet
contracts/base/PeripheryPayments.sol
Outdated
} | ||
|
||
/// @inheritdoc IPeripheryPayments | ||
function refundETH() external payable override { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yea thats weird - we should look in v3 sdk to see if we ever use this with value. since it just sends back to msg.sender anyways it seems useless
contracts/base/PeripheryPayments.sol
Outdated
|
||
abstract contract PeripheryPayments is IPeripheryPayments { | ||
/// @inheritdoc IPeripheryPayments | ||
function sweepToken(address token, uint256 amountMinimum, address recipient) public payable override { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can merge this and refundETH
into sweep(Currency currency, ...)
and just use CurrencyLibrary nicely here
currency.transfer(recipient, currency.balanceOfSelf());
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this abstracts native + ERC20!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
contracts/base/PeripheryPayments.sol
Outdated
/// @param payer The entity that must pay | ||
/// @param recipient The entity that will receive payment | ||
/// @param value The amount to pay | ||
function pay(address token, address payer, address recipient, uint256 value) internal { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here can use CurrencyLibrary and accept Currency as param
contracts/libraries/ChainId.sol
Outdated
library ChainId { | ||
/// @dev Gets the current chain ID | ||
/// @return chainId The current chain ID | ||
function get() internal view returns (uint256 chainId) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oo in solidity 0.8 we now have block.chainid
so this lib is no longer useful
@@ -3,6 +3,10 @@ pragma solidity ^0.8.15; | |||
|
|||
import {IERC20Minimal} from "@uniswap/v4-core/contracts/interfaces/external/IERC20Minimal.sol"; | |||
|
|||
error TransferFailed(); | |||
error STF(); | |||
error STE(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
now that we use custom errors we can make these more descriptive (they were acronyms before to save on bytes!)
maybe error SafeTransferFailed
and error SafeTransferEthFailed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oo leaving a TODO here to remove TransferHelper
to use solmate ver after we migrate twamm to it too
/// @dev Fails with `STE` | ||
/// @param to The destination of the transfer | ||
/// @param value The value to be transferred | ||
function safeTransferETH(address to, uint256 value) internal { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
consider using solmate's impl https://github.com/transmissions11/solmate/blob/main/src/utils/SafeTransferLib.sol
contracts/base/PeripheryPayments.sol
Outdated
import {SafeTransferLib} from "solmate/utils/SafeTransferLib.sol"; | ||
import {IPeripheryPayments} from "../interfaces/IPeripheryPayments.sol"; | ||
|
||
using CurrencyLibrary for Currency; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
omg i didnt know you could put this above the contract 😱
we normally put them just inside the contract header like this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://docs.soliditylang.org/en/v0.8.23/contracts.html#using-for o ya i was reading this and there are some tiny differences to file level vs contract level so if we've only done contract level elsewhere it makes sense to keep that consistent xD
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wow i had no idea, ty!
contracts/base/PeripheryPayments.sol
Outdated
using SafeTransferLib for address; | ||
using SafeTransferLib for ERC20; | ||
|
||
error InsufficientToken(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd personally define these inside the contract too? But dont feel as strongly about that... maybe @marktoda has an opinion?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe this was even copied from before
contracts/base/SelfPermit.sol
Outdated
@@ -0,0 +1,52 @@ | |||
// SPDX-License-Identifier: UNLICENSED | |||
pragma solidity >=0.5.0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
^0.8.19 like the others?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! 🚀
02a5cd2
to
324976e
Compare
* add PoolTicksCounter library * quoter exact input single * quoter test * return deltas instead * safe casting to correct types * QuoteExactInput skeleton * multiple entries * break handleRevert by type * quoteExactInput and unit tests * more QuoteExactInput tests * remove lgos * remove commented out struct * via-ir in ci * remove unused imports/functions * store iteration params locally instead of editing function input * pull out sqrtPriceLimit to its own function * PathKey to its own library * rename initializedTicksCrossed to initializedTicksLoaded * remove manual abi encoding in yul :p * fix linter warnings for Quoter * natspec for IQuoter * feat: update v4-core This commit updates v4 core to latest and fixes integration issues * fix: tests * style fixes * inheritdoc * ExactInSingleBatch * fix: update tests * fix: test router was borked * exact out * fix: alice comments * fix ExactOutput * add ExactOput unit tests * add quoteExactOutputBatch * remove solhint config * remove newline * add QuoteExactOutput in interface * refactor lockAcquired * move magic numbers to constants + doc * add more natspec * natspec * named imports * self-call branching * remove old code * remove console2 import * refactor PathKeyLib * amountOutCached * inherit ILockCallback * add base contracts and interfaces (#75) * remove unused errors * test lockAcquired reverts * remove ...Batch interface * REASON -> RESPONSE when valid * complete natspec * remove SwapInfo imports * rename to SwapParameters * move quoter structs into IQuoter interface * update to latest core * use prev values * change twamm to use pool getters * changes after merging main * use --via-ir in cli * fix formatting * fix FullRange/TWAMM hook * update ticks counter * update Quoter test * typo * typo * simplify handleRevertSingle * merge QuoteInput/OutputSingle structs * combine IQuoter structs * using ... ordering * update snapshots * move amountOutCached into inner call * using PathKeyLib for PathKey * fix amountOutCached * remove console2 import * resurface revert reason * clean up validateRevert * update natsppec * remove unused --------- Co-authored-by: Mark Toda <[email protected]> Co-authored-by: Tina <[email protected]> Co-authored-by: Sara Reynolds <[email protected]>
* Update to v4-core latest (Uniswap#64) * first pass on using new router function singatures * updated v4-core * updated .getSlot0, as it returns less data now * snapshots * add base contracts and interfaces (Uniswap#75) * Update v4 core (Uniswap#74) * feat: update v4-core This commit updates v4 core to latest and fixes integration issues * fix: tests * fix: update tests * fix: test router was borked * fix: alice comments * update to latest core * use prev values * change twamm to use pool getters * changes after merging main * use --via-ir in cli * fix formatting * fix FullRange/TWAMM hook --------- Co-authored-by: Sara Reynolds <[email protected]> * feat: Revert style quoter (Uniswap#73) * add PoolTicksCounter library * quoter exact input single * quoter test * return deltas instead * safe casting to correct types * QuoteExactInput skeleton * multiple entries * break handleRevert by type * quoteExactInput and unit tests * more QuoteExactInput tests * remove lgos * remove commented out struct * via-ir in ci * remove unused imports/functions * store iteration params locally instead of editing function input * pull out sqrtPriceLimit to its own function * PathKey to its own library * rename initializedTicksCrossed to initializedTicksLoaded * remove manual abi encoding in yul :p * fix linter warnings for Quoter * natspec for IQuoter * feat: update v4-core This commit updates v4 core to latest and fixes integration issues * fix: tests * style fixes * inheritdoc * ExactInSingleBatch * fix: update tests * fix: test router was borked * exact out * fix: alice comments * fix ExactOutput * add ExactOput unit tests * add quoteExactOutputBatch * remove solhint config * remove newline * add QuoteExactOutput in interface * refactor lockAcquired * move magic numbers to constants + doc * add more natspec * natspec * named imports * self-call branching * remove old code * remove console2 import * refactor PathKeyLib * amountOutCached * inherit ILockCallback * add base contracts and interfaces (Uniswap#75) * remove unused errors * test lockAcquired reverts * remove ...Batch interface * REASON -> RESPONSE when valid * complete natspec * remove SwapInfo imports * rename to SwapParameters * move quoter structs into IQuoter interface * update to latest core * use prev values * change twamm to use pool getters * changes after merging main * use --via-ir in cli * fix formatting * fix FullRange/TWAMM hook * update ticks counter * update Quoter test * typo * typo * simplify handleRevertSingle * merge QuoteInput/OutputSingle structs * combine IQuoter structs * using ... ordering * update snapshots * move amountOutCached into inner call * using PathKeyLib for PathKey * fix amountOutCached * remove console2 import * resurface revert reason * clean up validateRevert * update natsppec * remove unused --------- Co-authored-by: Mark Toda <[email protected]> Co-authored-by: Tina <[email protected]> Co-authored-by: Sara Reynolds <[email protected]> * (Quoter) Avoid IR (Uniswap#93) * avoid stack too deep * pack local variables into structs; remove need for IR * reorg struct * snapshots * forge fmt * restore settings * remove IR * ensure tokens are ordered properly by using salts * gas snapshot * remove console logs * chore: update v4-core:latest (Uniswap#89) * update v4-core * update to new liquidity hooks * forge fmt; reuse v4-core justfile * snapshots * rename getHooksCalls --> getHookPermissions * enforce permanent liquidity with beforeRemoveLiquidity * snapshot * update v4-core (again) * snapshots with new v4-core * v4-core:latest * pin 0.8.24 * merge in remote; regenerate snapshots * remove justfile * repin cancun * pin token addresses using vm.etch * snapshots * forge fmt * remove via-ir and custom solc from CI * test nit * Update v4-core submodule to use https (Uniswap#97) Co-authored-by: saucepoint <[email protected]> * chore: add semgrep (Uniswap#94) --------- Co-authored-by: saucepoint <[email protected]> Co-authored-by: Tina <[email protected]> Co-authored-by: marktoda <[email protected]> Co-authored-by: Sara Reynolds <[email protected]> Co-authored-by: Zach Yang <[email protected]> Co-authored-by: 0x57 <[email protected]> Co-authored-by: mr-uniswap <[email protected]>
* feat: Revert style quoter (#73) * add PoolTicksCounter library * quoter exact input single * quoter test * return deltas instead * safe casting to correct types * QuoteExactInput skeleton * multiple entries * break handleRevert by type * quoteExactInput and unit tests * more QuoteExactInput tests * remove lgos * remove commented out struct * via-ir in ci * remove unused imports/functions * store iteration params locally instead of editing function input * pull out sqrtPriceLimit to its own function * PathKey to its own library * rename initializedTicksCrossed to initializedTicksLoaded * remove manual abi encoding in yul :p * fix linter warnings for Quoter * natspec for IQuoter * feat: update v4-core This commit updates v4 core to latest and fixes integration issues * fix: tests * style fixes * inheritdoc * ExactInSingleBatch * fix: update tests * fix: test router was borked * exact out * fix: alice comments * fix ExactOutput * add ExactOput unit tests * add quoteExactOutputBatch * remove solhint config * remove newline * add QuoteExactOutput in interface * refactor lockAcquired * move magic numbers to constants + doc * add more natspec * natspec * named imports * self-call branching * remove old code * remove console2 import * refactor PathKeyLib * amountOutCached * inherit ILockCallback * add base contracts and interfaces (#75) * remove unused errors * test lockAcquired reverts * remove ...Batch interface * REASON -> RESPONSE when valid * complete natspec * remove SwapInfo imports * rename to SwapParameters * move quoter structs into IQuoter interface * update to latest core * use prev values * change twamm to use pool getters * changes after merging main * use --via-ir in cli * fix formatting * fix FullRange/TWAMM hook * update ticks counter * update Quoter test * typo * typo * simplify handleRevertSingle * merge QuoteInput/OutputSingle structs * combine IQuoter structs * using ... ordering * update snapshots * move amountOutCached into inner call * using PathKeyLib for PathKey * fix amountOutCached * remove console2 import * resurface revert reason * clean up validateRevert * update natsppec * remove unused --------- Co-authored-by: Mark Toda <[email protected]> Co-authored-by: Tina <[email protected]> Co-authored-by: Sara Reynolds <[email protected]> * (Quoter) Avoid IR (#93) * avoid stack too deep * pack local variables into structs; remove need for IR * reorg struct * snapshots * forge fmt * restore settings * remove IR * ensure tokens are ordered properly by using salts * gas snapshot * remove console logs * chore: update v4-core:latest (#89) * update v4-core * update to new liquidity hooks * forge fmt; reuse v4-core justfile * snapshots * rename getHooksCalls --> getHookPermissions * enforce permanent liquidity with beforeRemoveLiquidity * snapshot * update v4-core (again) * snapshots with new v4-core * v4-core:latest * pin 0.8.24 * merge in remote; regenerate snapshots * remove justfile * repin cancun * pin token addresses using vm.etch * snapshots * forge fmt * remove via-ir and custom solc from CI * test nit * Update v4-core submodule to use https (#97) Co-authored-by: saucepoint <[email protected]> * chore: add semgrep (#94) * [Chore] Update v4-core:latest (#100) * Update v4-core * Update various examples, BaseHook, Quoter and tests * Remove nested locking for LimitOrder * Fix Quoter * update v4-core * fix: remove getLocker as its a bool now * update v4-core: flipped signs, push dynamic fees * fix: flip delta signs * flip delta signs * flip delta signs * flip delta signs * fix getSlot0 calls * snapshots * remove deadcode * remove unused param * update core * update for modifyLiquidity; misc doc updates * correct min int256 * allow for manual fee updates --------- Co-authored-by: saucepoint <[email protected]> * changes with core update * fix casing * switch versions back * Updated lib/v4-core submodule to main branch * switch to 0.8.19 --------- Co-authored-by: Zach Yang <[email protected]> Co-authored-by: Mark Toda <[email protected]> Co-authored-by: Tina <[email protected]> Co-authored-by: Sara Reynolds <[email protected]> Co-authored-by: saucepoint <[email protected]> Co-authored-by: 0x57 <[email protected]> Co-authored-by: mr-uniswap <[email protected]> Co-authored-by: 0x57 <[email protected]> Co-authored-by: saucepoint <[email protected]> Co-authored-by: Alice Henshaw <[email protected]>
* add PoolTicksCounter library * quoter exact input single * quoter test * return deltas instead * safe casting to correct types * QuoteExactInput skeleton * multiple entries * break handleRevert by type * quoteExactInput and unit tests * more QuoteExactInput tests * remove lgos * remove commented out struct * via-ir in ci * remove unused imports/functions * store iteration params locally instead of editing function input * pull out sqrtPriceLimit to its own function * PathKey to its own library * rename initializedTicksCrossed to initializedTicksLoaded * remove manual abi encoding in yul :p * fix linter warnings for Quoter * natspec for IQuoter * feat: update v4-core This commit updates v4 core to latest and fixes integration issues * fix: tests * style fixes * inheritdoc * ExactInSingleBatch * fix: update tests * fix: test router was borked * exact out * fix: alice comments * fix ExactOutput * add ExactOput unit tests * add quoteExactOutputBatch * remove solhint config * remove newline * add QuoteExactOutput in interface * refactor lockAcquired * move magic numbers to constants + doc * add more natspec * natspec * named imports * self-call branching * remove old code * remove console2 import * refactor PathKeyLib * amountOutCached * inherit ILockCallback * add base contracts and interfaces (#75) * remove unused errors * test lockAcquired reverts * remove ...Batch interface * REASON -> RESPONSE when valid * complete natspec * remove SwapInfo imports * rename to SwapParameters * move quoter structs into IQuoter interface * update to latest core * use prev values * change twamm to use pool getters * changes after merging main * use --via-ir in cli * fix formatting * fix FullRange/TWAMM hook * update ticks counter * update Quoter test * typo * typo * simplify handleRevertSingle * merge QuoteInput/OutputSingle structs * combine IQuoter structs * using ... ordering * update snapshots * start routing * start routing contract * naive swapExactIn impl * lint + bytecode snapshot * change concept of hops to token hops * UniswapV4Routing --> Routing * use PathKey * exactInputSingle * save DRY progress * no sqrtPriceLimit for multipool hops * exactOut implemented w awkward loops/int conversions single hops passing on exactOut * gas savings from not doing double negative number * gas savings from unchecked math * add swapExactOuputSingle * break out structs into interface * PR comments * pass hook data along * gas and coherency optimization * merge Quoter * remove SwapIntention * IV4Router structs * remove SwapIntention * remove logs * natspec * rebase onto latest core * simplify function naming * Routing diana (#104) * feat: Revert style quoter (#73) * add PoolTicksCounter library * quoter exact input single * quoter test * return deltas instead * safe casting to correct types * QuoteExactInput skeleton * multiple entries * break handleRevert by type * quoteExactInput and unit tests * more QuoteExactInput tests * remove lgos * remove commented out struct * via-ir in ci * remove unused imports/functions * store iteration params locally instead of editing function input * pull out sqrtPriceLimit to its own function * PathKey to its own library * rename initializedTicksCrossed to initializedTicksLoaded * remove manual abi encoding in yul :p * fix linter warnings for Quoter * natspec for IQuoter * feat: update v4-core This commit updates v4 core to latest and fixes integration issues * fix: tests * style fixes * inheritdoc * ExactInSingleBatch * fix: update tests * fix: test router was borked * exact out * fix: alice comments * fix ExactOutput * add ExactOput unit tests * add quoteExactOutputBatch * remove solhint config * remove newline * add QuoteExactOutput in interface * refactor lockAcquired * move magic numbers to constants + doc * add more natspec * natspec * named imports * self-call branching * remove old code * remove console2 import * refactor PathKeyLib * amountOutCached * inherit ILockCallback * add base contracts and interfaces (#75) * remove unused errors * test lockAcquired reverts * remove ...Batch interface * REASON -> RESPONSE when valid * complete natspec * remove SwapInfo imports * rename to SwapParameters * move quoter structs into IQuoter interface * update to latest core * use prev values * change twamm to use pool getters * changes after merging main * use --via-ir in cli * fix formatting * fix FullRange/TWAMM hook * update ticks counter * update Quoter test * typo * typo * simplify handleRevertSingle * merge QuoteInput/OutputSingle structs * combine IQuoter structs * using ... ordering * update snapshots * move amountOutCached into inner call * using PathKeyLib for PathKey * fix amountOutCached * remove console2 import * resurface revert reason * clean up validateRevert * update natsppec * remove unused --------- Co-authored-by: Mark Toda <[email protected]> Co-authored-by: Tina <[email protected]> Co-authored-by: Sara Reynolds <[email protected]> * (Quoter) Avoid IR (#93) * avoid stack too deep * pack local variables into structs; remove need for IR * reorg struct * snapshots * forge fmt * restore settings * remove IR * ensure tokens are ordered properly by using salts * gas snapshot * remove console logs * chore: update v4-core:latest (#89) * update v4-core * update to new liquidity hooks * forge fmt; reuse v4-core justfile * snapshots * rename getHooksCalls --> getHookPermissions * enforce permanent liquidity with beforeRemoveLiquidity * snapshot * update v4-core (again) * snapshots with new v4-core * v4-core:latest * pin 0.8.24 * merge in remote; regenerate snapshots * remove justfile * repin cancun * pin token addresses using vm.etch * snapshots * forge fmt * remove via-ir and custom solc from CI * test nit * Update v4-core submodule to use https (#97) Co-authored-by: saucepoint <[email protected]> * chore: add semgrep (#94) * [Chore] Update v4-core:latest (#100) * Update v4-core * Update various examples, BaseHook, Quoter and tests * Remove nested locking for LimitOrder * Fix Quoter * update v4-core * fix: remove getLocker as its a bool now * update v4-core: flipped signs, push dynamic fees * fix: flip delta signs * flip delta signs * flip delta signs * flip delta signs * fix getSlot0 calls * snapshots * remove deadcode * remove unused param * update core * update for modifyLiquidity; misc doc updates * correct min int256 * allow for manual fee updates --------- Co-authored-by: saucepoint <[email protected]> * changes with core update * fix casing * switch versions back * Updated lib/v4-core submodule to main branch * switch to 0.8.19 --------- Co-authored-by: Zach Yang <[email protected]> Co-authored-by: Mark Toda <[email protected]> Co-authored-by: Tina <[email protected]> Co-authored-by: Sara Reynolds <[email protected]> Co-authored-by: saucepoint <[email protected]> Co-authored-by: 0x57 <[email protected]> Co-authored-by: mr-uniswap <[email protected]> Co-authored-by: 0x57 <[email protected]> Co-authored-by: saucepoint <[email protected]> Co-authored-by: Alice Henshaw <[email protected]> * update imports --------- Co-authored-by: Mark Toda <[email protected]> Co-authored-by: Tina <[email protected]> Co-authored-by: Sara Reynolds <[email protected]> Co-authored-by: Emily Williams <[email protected]> Co-authored-by: Alice Henshaw <[email protected]> Co-authored-by: diana <[email protected]> Co-authored-by: saucepoint <[email protected]> Co-authored-by: 0x57 <[email protected]> Co-authored-by: mr-uniswap <[email protected]> Co-authored-by: 0x57 <[email protected]> Co-authored-by: saucepoint <[email protected]>
* start routing * start routing contract * naive swapExactIn impl * lint + bytecode snapshot * change concept of hops to token hops * UniswapV4Routing --> Routing * use PathKey * exactInputSingle * save DRY progress * no sqrtPriceLimit for multipool hops * exactOut implemented w awkward loops/int conversions single hops passing on exactOut * gas savings from not doing double negative number * gas savings from unchecked math * add swapExactOuputSingle * break out structs into interface * PR comments * pass hook data along * gas and coherency optimization * updated lib/v4-core submodule to main branch * feat: abstract router (#86) * add PoolTicksCounter library * quoter exact input single * quoter test * return deltas instead * safe casting to correct types * QuoteExactInput skeleton * multiple entries * break handleRevert by type * quoteExactInput and unit tests * more QuoteExactInput tests * remove lgos * remove commented out struct * via-ir in ci * remove unused imports/functions * store iteration params locally instead of editing function input * pull out sqrtPriceLimit to its own function * PathKey to its own library * rename initializedTicksCrossed to initializedTicksLoaded * remove manual abi encoding in yul :p * fix linter warnings for Quoter * natspec for IQuoter * feat: update v4-core This commit updates v4 core to latest and fixes integration issues * fix: tests * style fixes * inheritdoc * ExactInSingleBatch * fix: update tests * fix: test router was borked * exact out * fix: alice comments * fix ExactOutput * add ExactOput unit tests * add quoteExactOutputBatch * remove solhint config * remove newline * add QuoteExactOutput in interface * refactor lockAcquired * move magic numbers to constants + doc * add more natspec * natspec * named imports * self-call branching * remove old code * remove console2 import * refactor PathKeyLib * amountOutCached * inherit ILockCallback * add base contracts and interfaces (#75) * remove unused errors * test lockAcquired reverts * remove ...Batch interface * REASON -> RESPONSE when valid * complete natspec * remove SwapInfo imports * rename to SwapParameters * move quoter structs into IQuoter interface * update to latest core * use prev values * change twamm to use pool getters * changes after merging main * use --via-ir in cli * fix formatting * fix FullRange/TWAMM hook * update ticks counter * update Quoter test * typo * typo * simplify handleRevertSingle * merge QuoteInput/OutputSingle structs * combine IQuoter structs * using ... ordering * update snapshots * start routing * start routing contract * naive swapExactIn impl * lint + bytecode snapshot * change concept of hops to token hops * UniswapV4Routing --> Routing * use PathKey * exactInputSingle * save DRY progress * no sqrtPriceLimit for multipool hops * exactOut implemented w awkward loops/int conversions single hops passing on exactOut * gas savings from not doing double negative number * gas savings from unchecked math * add swapExactOuputSingle * break out structs into interface * PR comments * pass hook data along * gas and coherency optimization * merge Quoter * remove SwapIntention * IV4Router structs * remove SwapIntention * remove logs * natspec * rebase onto latest core * simplify function naming * Routing diana (#104) * feat: Revert style quoter (#73) * add PoolTicksCounter library * quoter exact input single * quoter test * return deltas instead * safe casting to correct types * QuoteExactInput skeleton * multiple entries * break handleRevert by type * quoteExactInput and unit tests * more QuoteExactInput tests * remove lgos * remove commented out struct * via-ir in ci * remove unused imports/functions * store iteration params locally instead of editing function input * pull out sqrtPriceLimit to its own function * PathKey to its own library * rename initializedTicksCrossed to initializedTicksLoaded * remove manual abi encoding in yul :p * fix linter warnings for Quoter * natspec for IQuoter * feat: update v4-core This commit updates v4 core to latest and fixes integration issues * fix: tests * style fixes * inheritdoc * ExactInSingleBatch * fix: update tests * fix: test router was borked * exact out * fix: alice comments * fix ExactOutput * add ExactOput unit tests * add quoteExactOutputBatch * remove solhint config * remove newline * add QuoteExactOutput in interface * refactor lockAcquired * move magic numbers to constants + doc * add more natspec * natspec * named imports * self-call branching * remove old code * remove console2 import * refactor PathKeyLib * amountOutCached * inherit ILockCallback * add base contracts and interfaces (#75) * remove unused errors * test lockAcquired reverts * remove ...Batch interface * REASON -> RESPONSE when valid * complete natspec * remove SwapInfo imports * rename to SwapParameters * move quoter structs into IQuoter interface * update to latest core * use prev values * change twamm to use pool getters * changes after merging main * use --via-ir in cli * fix formatting * fix FullRange/TWAMM hook * update ticks counter * update Quoter test * typo * typo * simplify handleRevertSingle * merge QuoteInput/OutputSingle structs * combine IQuoter structs * using ... ordering * update snapshots * move amountOutCached into inner call * using PathKeyLib for PathKey * fix amountOutCached * remove console2 import * resurface revert reason * clean up validateRevert * update natsppec * remove unused --------- Co-authored-by: Mark Toda <[email protected]> Co-authored-by: Tina <[email protected]> Co-authored-by: Sara Reynolds <[email protected]> * (Quoter) Avoid IR (#93) * avoid stack too deep * pack local variables into structs; remove need for IR * reorg struct * snapshots * forge fmt * restore settings * remove IR * ensure tokens are ordered properly by using salts * gas snapshot * remove console logs * chore: update v4-core:latest (#89) * update v4-core * update to new liquidity hooks * forge fmt; reuse v4-core justfile * snapshots * rename getHooksCalls --> getHookPermissions * enforce permanent liquidity with beforeRemoveLiquidity * snapshot * update v4-core (again) * snapshots with new v4-core * v4-core:latest * pin 0.8.24 * merge in remote; regenerate snapshots * remove justfile * repin cancun * pin token addresses using vm.etch * snapshots * forge fmt * remove via-ir and custom solc from CI * test nit * Update v4-core submodule to use https (#97) Co-authored-by: saucepoint <[email protected]> * chore: add semgrep (#94) * [Chore] Update v4-core:latest (#100) * Update v4-core * Update various examples, BaseHook, Quoter and tests * Remove nested locking for LimitOrder * Fix Quoter * update v4-core * fix: remove getLocker as its a bool now * update v4-core: flipped signs, push dynamic fees * fix: flip delta signs * flip delta signs * flip delta signs * flip delta signs * fix getSlot0 calls * snapshots * remove deadcode * remove unused param * update core * update for modifyLiquidity; misc doc updates * correct min int256 * allow for manual fee updates --------- Co-authored-by: saucepoint <[email protected]> * changes with core update * fix casing * switch versions back * Updated lib/v4-core submodule to main branch * switch to 0.8.19 --------- Co-authored-by: Zach Yang <[email protected]> Co-authored-by: Mark Toda <[email protected]> Co-authored-by: Tina <[email protected]> Co-authored-by: Sara Reynolds <[email protected]> Co-authored-by: saucepoint <[email protected]> Co-authored-by: 0x57 <[email protected]> Co-authored-by: mr-uniswap <[email protected]> Co-authored-by: 0x57 <[email protected]> Co-authored-by: saucepoint <[email protected]> Co-authored-by: Alice Henshaw <[email protected]> * update imports --------- Co-authored-by: Mark Toda <[email protected]> Co-authored-by: Tina <[email protected]> Co-authored-by: Sara Reynolds <[email protected]> Co-authored-by: Emily Williams <[email protected]> Co-authored-by: Alice Henshaw <[email protected]> Co-authored-by: diana <[email protected]> Co-authored-by: saucepoint <[email protected]> Co-authored-by: 0x57 <[email protected]> Co-authored-by: mr-uniswap <[email protected]> Co-authored-by: 0x57 <[email protected]> Co-authored-by: saucepoint <[email protected]> * allow payer and recipient to be different * try to fix ci * improve casting * reverting 3 commits to make branch * remove unused recipient param * remove payment logic from swap logic * factor out payment functions * gas opt removing struct * gas opt: decode in assembly * merge error * use base actions router in v4router * use isolate * merge conflicts * removing submodules * renaming to stop clashes in UR * PR comments and gas optimisations * add _getLocker * Amount field on settle and take * rename snaps * correcy casting order * Add deltaresolver to router * take_all command, remove from delta resolver * Routing test helper * Separate gas tests and regular tests * remove duplicate snapshot name * another gas test * PR comments * remove unused function * PR cmments * handle hook edgecase --------- Co-authored-by: Diana Kocsis <[email protected]> Co-authored-by: Alice Henshaw <[email protected]> Co-authored-by: Zach Yang <[email protected]> Co-authored-by: Mark Toda <[email protected]> Co-authored-by: Tina <[email protected]> Co-authored-by: Sara Reynolds <[email protected]> Co-authored-by: diana <[email protected]> Co-authored-by: saucepoint <[email protected]> Co-authored-by: 0x57 <[email protected]> Co-authored-by: mr-uniswap <[email protected]> Co-authored-by: 0x57 <[email protected]> Co-authored-by: saucepoint <[email protected]> Co-authored-by: Alice <[email protected]>
Description of changes
This PR adds base contracts and interfaces that are used in PositionManagerV4 here. But these are mostly copied from v3-periphery with a few changes (ill document as comments).