Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
36bdf20
First pass at Uniswap V3 + allocated allowlist DTL
0xJem Jan 28, 2025
100e14b
chore: Update soldeer.lock
0xJem Jan 28, 2025
520a45f
Mark BaseDTL functions as virtual
0xJem Jan 28, 2025
aea4707
Fix compiler error
0xJem Jan 28, 2025
f04bbc8
Workaround for setting merkle root
0xJem Jan 28, 2025
3b46f12
Modify BaseDTL and derivatives to support passing in the permissions
0xJem Jan 28, 2025
49c15cc
Correct permissions for allocated allowlist DTL. Misc fixes.
0xJem Jan 28, 2025
c7f86fd
Tests for new DTL
0xJem Jan 28, 2025
632c409
Add missing check in allowlist
0xJem Jan 28, 2025
a39e44b
Add tests for setMerkleRoot
0xJem Jan 28, 2025
5fea07f
Correct docs
0xJem Jan 28, 2025
2ecad81
Fix issue with test salts
0xJem Jan 28, 2025
47bcd13
Disable tests that were giving a stack too deep error
0xJem Jan 28, 2025
e30a907
Use stable version of foundry
0xJem Jan 29, 2025
4c9f69e
Extract interface
0xJem Jan 29, 2025
803df6e
Remove redundant owner from DTL
0xJem Jan 29, 2025
79da311
Add deployment script
0xJem Jan 29, 2025
5bc93cc
Add salt generation
0xJem Jan 29, 2025
b296fa9
Correct function
0xJem Jan 29, 2025
3af891c
Correct address prefix
0xJem Jan 29, 2025
3e87913
Base sepolia deployment
0xJem Jan 29, 2025
19252df
Add deployment sequence
0xJem Feb 18, 2025
dd999a1
Adjust compiler version for interface
0xJem Feb 18, 2025
9390357
Add optimizer flags
0xJem Feb 18, 2025
4316b20
chore: salt for DTL
0xJem Feb 18, 2025
140fb96
Merge branch 'develop' into uniswap-v3-allowlist-dtl
0xJem Feb 24, 2025
0fe44eb
Updates to imports. Salts.
0xJem Feb 24, 2025
a0dea25
chore: update deployment salt
0xJem Feb 24, 2025
f8ba1f0
deploy: uni-v3 allocated allowlist to base
Oighty Feb 25, 2025
4aa6ef5
chore: linting
0xJem Feb 25, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ jobs:

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly

# Providing the SSH key to the checkout action does not work with our config.
# It likely is because of the install script wiping the lib/ directory.
Expand Down
3 changes: 3 additions & 0 deletions deployments/.base-sepolia-1738161094.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"deployments.callbacks.BatchUniswapV3DirectToLiquidityWithAllocatedAllowlist": "0xEE4d06C1c96Ae19D1D77ac279881a639307E97E2"
}
3 changes: 3 additions & 0 deletions deployments/.base-v1.0.1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"deployments.callbacks.BatchUniswapV3DirectToLiquidityWithAllocatedAllowlist": "0xEE25c5B81Ac47c97F4458c5b20916cE35B7638F7"
}
107 changes: 99 additions & 8 deletions script/deploy/Deploy.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import {GUniFactory} from "@g-uni-v1-core-0.9.9/GUniFactory.sol";
// Callbacks
import {UniswapV2DirectToLiquidity} from "../../src/callbacks/liquidity/UniswapV2DTL.sol";
import {UniswapV3DirectToLiquidity} from "../../src/callbacks/liquidity/UniswapV3DTL.sol";
import {UniswapV3DTLWithAllocatedAllowlist} from
"../../src/callbacks/liquidity/UniswapV3DTLWithAllocatedAllowlist.sol";
import {CappedMerkleAllowlist} from "../../src/callbacks/allowlists/CappedMerkleAllowlist.sol";
import {MerkleAllowlist} from "../../src/callbacks/allowlists/MerkleAllowlist.sol";
import {TokenAllowlist} from "../../src/callbacks/allowlists/TokenAllowlist.sol";
Expand Down Expand Up @@ -286,11 +288,22 @@ contract Deploy is Script, WithDeploySequence, WithSalts {
"UniswapV2Router.factory() does not match given Uniswap V2 factory address"
);

Callbacks.Permissions memory permissions = Callbacks.Permissions({
onCreate: true,
onCancel: true,
onCurate: true,
onPurchase: false,
onBid: false,
onSettle: true,
receiveQuoteTokens: true,
sendBaseTokens: false
});

// Get the salt
bytes32 salt_ = _getSalt(
sequenceName_,
type(UniswapV2DirectToLiquidity).creationCode,
abi.encode(atomicAuctionHouse, uniswapV2Factory, uniswapV2Router)
abi.encode(atomicAuctionHouse, uniswapV2Factory, uniswapV2Router, permissions)
);

// Revert if the salt is not set
Expand All @@ -302,7 +315,7 @@ contract Deploy is Script, WithDeploySequence, WithSalts {
vm.broadcast();
UniswapV2DirectToLiquidity cbAtomicUniswapV2Dtl = new UniswapV2DirectToLiquidity{
salt: salt_
}(atomicAuctionHouse, uniswapV2Factory, uniswapV2Router);
}(atomicAuctionHouse, uniswapV2Factory, uniswapV2Router, permissions);
console2.log("");
console2.log(" deployed at:", address(cbAtomicUniswapV2Dtl));

Expand Down Expand Up @@ -330,11 +343,22 @@ contract Deploy is Script, WithDeploySequence, WithSalts {
"UniswapV2Router.factory() does not match given Uniswap V2 factory address"
);

Callbacks.Permissions memory permissions = Callbacks.Permissions({
onCreate: true,
onCancel: true,
onCurate: true,
onPurchase: false,
onBid: false,
onSettle: true,
receiveQuoteTokens: true,
sendBaseTokens: false
});

// Get the salt
bytes32 salt_ = _getSalt(
deploymentKey,
type(UniswapV2DirectToLiquidity).creationCode,
abi.encode(batchAuctionHouse, uniswapV2Factory, uniswapV2Router)
abi.encode(batchAuctionHouse, uniswapV2Factory, uniswapV2Router, permissions)
);

// Revert if the salt is not set
Expand All @@ -345,7 +369,7 @@ contract Deploy is Script, WithDeploySequence, WithSalts {

vm.broadcast();
UniswapV2DirectToLiquidity cbBatchUniswapV2Dtl = new UniswapV2DirectToLiquidity{salt: salt_}(
batchAuctionHouse, uniswapV2Factory, uniswapV2Router
batchAuctionHouse, uniswapV2Factory, uniswapV2Router, permissions
);
console2.log("");
console2.log(" deployed at:", address(cbBatchUniswapV2Dtl));
Expand Down Expand Up @@ -375,11 +399,22 @@ contract Deploy is Script, WithDeploySequence, WithSalts {
"GUniFactory.factory() does not match given Uniswap V3 factory address"
);

Callbacks.Permissions memory permissions = Callbacks.Permissions({
onCreate: true,
onCancel: true,
onCurate: true,
onPurchase: false,
onBid: false,
onSettle: true,
receiveQuoteTokens: true,
sendBaseTokens: false
});

// Get the salt
bytes32 salt_ = _getSalt(
deploymentKey,
type(UniswapV3DirectToLiquidity).creationCode,
abi.encode(atomicAuctionHouse, uniswapV3Factory, gUniFactory)
abi.encode(atomicAuctionHouse, uniswapV3Factory, gUniFactory, permissions)
);

// Revert if the salt is not set
Expand All @@ -391,7 +426,7 @@ contract Deploy is Script, WithDeploySequence, WithSalts {
vm.broadcast();
UniswapV3DirectToLiquidity cbAtomicUniswapV3Dtl = new UniswapV3DirectToLiquidity{
salt: salt_
}(atomicAuctionHouse, uniswapV3Factory, gUniFactory);
}(atomicAuctionHouse, uniswapV3Factory, gUniFactory, permissions);
console2.log("");
console2.log(" deployed at:", address(cbAtomicUniswapV3Dtl));

Expand Down Expand Up @@ -420,11 +455,22 @@ contract Deploy is Script, WithDeploySequence, WithSalts {
"GUniFactory.factory() does not match given Uniswap V3 factory address"
);

Callbacks.Permissions memory permissions = Callbacks.Permissions({
onCreate: true,
onCancel: true,
onCurate: true,
onPurchase: false,
onBid: false,
onSettle: true,
receiveQuoteTokens: true,
sendBaseTokens: false
});

// Get the salt
bytes32 salt_ = _getSalt(
deploymentKey,
type(UniswapV3DirectToLiquidity).creationCode,
abi.encode(batchAuctionHouse, uniswapV3Factory, gUniFactory)
abi.encode(batchAuctionHouse, uniswapV3Factory, gUniFactory, permissions)
);

// Revert if the salt is not set
Expand All @@ -435,14 +481,59 @@ contract Deploy is Script, WithDeploySequence, WithSalts {

vm.broadcast();
UniswapV3DirectToLiquidity cbBatchUniswapV3Dtl = new UniswapV3DirectToLiquidity{salt: salt_}(
batchAuctionHouse, uniswapV3Factory, gUniFactory
batchAuctionHouse, uniswapV3Factory, gUniFactory, permissions
);
console2.log("");
console2.log(" deployed at:", address(cbBatchUniswapV3Dtl));

return (address(cbBatchUniswapV3Dtl), _PREFIX_CALLBACKS, deploymentKey);
}

function deployBatchUniswapV3DirectToLiquidityWithAllocatedAllowlist(
string memory sequenceName_
) public returns (address, string memory, string memory) {
console2.log("");
console2.log("Deploying UniswapV3DirectToLiquidityWithAllocatedAllowlist (Batch)");

// Get configuration variables
address batchAuctionHouse = _getAddressNotZero("deployments.BatchAuctionHouse");
address uniswapV3Factory = _getEnvAddressOrOverride(
"constants.uniswapV3.factory", sequenceName_, "args.uniswapV3Factory"
);
address gUniFactory =
_getEnvAddressOrOverride("constants.gUni.factory", sequenceName_, "args.gUniFactory");
string memory deploymentKey = _getDeploymentKey(sequenceName_);
console2.log(" deploymentKey:", deploymentKey);

// Check that the GUni factory and Uniswap V3 factory are consistent
require(
GUniFactory(gUniFactory).factory() == uniswapV3Factory,
"GUniFactory.factory() does not match given Uniswap V3 factory address"
);

// Get the salt
bytes32 salt_ = _getSalt(
deploymentKey,
type(UniswapV3DTLWithAllocatedAllowlist).creationCode,
abi.encode(batchAuctionHouse, uniswapV3Factory, gUniFactory)
);

// Revert if the salt is not set
require(salt_ != bytes32(0), "Salt not set");

// Deploy the module
console2.log(" salt:", vm.toString(salt_));

vm.broadcast();
UniswapV3DTLWithAllocatedAllowlist cbBatchUniswapV3Dtl = new UniswapV3DTLWithAllocatedAllowlist{
salt: salt_
}(batchAuctionHouse, uniswapV3Factory, gUniFactory);
console2.log("");
console2.log(" deployed at:", address(cbBatchUniswapV3Dtl));

return (address(cbBatchUniswapV3Dtl), _PREFIX_CALLBACKS, deploymentKey);
}

function deployAtomicCappedMerkleAllowlist(
string memory sequenceName_
) public returns (address, string memory, string memory) {
Expand Down
7 changes: 7 additions & 0 deletions script/deploy/sequences/uniswap-v3-allocated-dtl.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"sequence": [
{
"name": "BatchUniswapV3DirectToLiquidityWithAllocatedAllowlist"
}
]
}
6 changes: 4 additions & 2 deletions script/env.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@
"BatchMerkleAllowlist": "0x98c5c24eB3FFEFeCd1a666423978f7A030319A78",
"BatchTokenAllowlist": "0x98a5d4827A57056d30df93C7Bd4Bc294cC6dC0b9",
"BatchUniswapV2DirectToLiquidity": "0xE6F93df14cB554737A26acd2aB5fEf649921D7F2",
"BatchUniswapV3DirectToLiquidity": "0xE64d6e058dD5F76CCc8566c07b994090a24CCB75"
"BatchUniswapV3DirectToLiquidity": "0xE64d6e058dD5F76CCc8566c07b994090a24CCB75",
"BatchUniswapV3DirectToLiquidityWithAllocatedAllowlist": "0xEE25c5B81Ac47c97F4458c5b20916cE35B7638F7"
}
}
},
Expand All @@ -92,7 +93,8 @@
"BatchMerkleAllowlist": "0x98d64E00D9d6550913E73C940Ff476Cf1723d834",
"BatchTokenAllowlist": "0x9801e45362a2bb7C9F22486CC3F5cA9224e9CC55",
"BatchUniswapV2DirectToLiquidity": "0xE6546c03B1b9DFC4238f0A2923FdefD5E4af7659",
"BatchUniswapV3DirectToLiquidity": "0xE68b21C071534781BC4c40E6BF1bCFC23638fF4B"
"BatchUniswapV3DirectToLiquidity": "0xE68b21C071534781BC4c40E6BF1bCFC23638fF4B",
"BatchUniswapV3DirectToLiquidityWithAllocatedAllowlist": "0xEE4d06C1c96Ae19D1D77ac279881a639307E97E2"
}
}
},
Expand Down
35 changes: 35 additions & 0 deletions script/salts/dtl-uniswap/UniswapDTLSalts.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import {WithDeploySequence} from "../../deploy/WithDeploySequence.s.sol";
// Uniswap
import {UniswapV2DirectToLiquidity} from "../../../src/callbacks/liquidity/UniswapV2DTL.sol";
import {UniswapV3DirectToLiquidity} from "../../../src/callbacks/liquidity/UniswapV3DTL.sol";
import {UniswapV3DTLWithAllocatedAllowlist} from
"../../../src/callbacks/liquidity/UniswapV3DTLWithAllocatedAllowlist.sol";

contract UniswapDTLSalts is Script, WithDeploySequence, WithSalts {
string internal constant _ADDRESS_PREFIX = "E6";
Expand Down Expand Up @@ -67,6 +69,17 @@ contract UniswapDTLSalts is Script, WithDeploySequence, WithSalts {

_generateV3(sequenceName, auctionHouse, deploymentKey);
}
// Batch Uniswap V3 with Allocated Allowlist
else if (
keccak256(abi.encodePacked(sequenceName))
== keccak256(
abi.encodePacked("BatchUniswapV3DirectToLiquidityWithAllocatedAllowlist")
)
) {
address auctionHouse = _envAddressNotZero("deployments.BatchAuctionHouse");

_generateV3WithAllocatedAllowlist(sequenceName, auctionHouse, deploymentKey);
}
// Something else
else {
console2.log(" Skipping unknown sequence: %s", sequenceName);
Expand Down Expand Up @@ -116,4 +129,26 @@ contract UniswapDTLSalts is Script, WithDeploySequence, WithSalts {
);
_setSalt(bytecodePath, _ADDRESS_PREFIX, deploymentKey_, bytecodeHash);
}

function _generateV3WithAllocatedAllowlist(
string memory sequenceName_,
address auctionHouse_,
string memory deploymentKey_
) internal {
// Get input variables or overrides
address envUniswapV3Factory = _getEnvAddressOrOverride(
"constants.uniswapV3.factory", sequenceName_, "args.uniswapV3Factory"
);
address envGUniFactory =
_getEnvAddressOrOverride("constants.gUni.factory", sequenceName_, "args.gUniFactory");

// Calculate salt for the UniswapV2DirectToLiquidity
bytes memory contractCode = type(UniswapV3DTLWithAllocatedAllowlist).creationCode;
(string memory bytecodePath, bytes32 bytecodeHash) = _writeBytecode(
deploymentKey_,
contractCode,
abi.encode(auctionHouse_, envUniswapV3Factory, envGUniFactory)
);
_setSalt(bytecodePath, "EE", deploymentKey_, bytecodeHash);
}
}
12 changes: 10 additions & 2 deletions script/salts/salts.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@
"BatchUniswapV2DirectToLiquidity": {
"0x5425c9b9254dc9126002dd9f7b17b6ff643b79c5aed0ed2f116b70af3e163500": "0x262dcec529815acf06c81b7e0845ece78296140a248524da0cdd182fa8133ee9"
},
"BatchUniswapV3DirectToLiquidityWithAllocatedAllowlist": {
"0x181fdad91467a532ae9ebdc80915f54694efba1225f67606039c1b85f01fd483": "0x56fa0a987993fead1434db033954e96847b8fa412ba170eb7b3e3148dbf27e15",
"0x6daa621e22611091db5b051a7dbfb5c0f0ec3bf75454115e2fb4a9079c66289b": "0x3b013f20c0e68b196c5c4cd04e299b9faa4b2d71d25ac31bd70cc0d7a116e688",
"0xfa068f11166e923192737f1de5d84c5c9f17a2cb504fdff8ab2bae2703c1dc55": "0xef23d7a54ac5936b84aad715bec0f1b580f0b35fee8236ddcf010491cb621399"
},
"CappedMerkleAllowlist": {
"0x0249dded8310d17581f166a526ea9ded65b81112ccac0ee8a144e9770d2b8432": "0xf5746fa34aeff9866dc5ec58712f7f47045aea15db39a0aabf4dadc9d35c8854",
"0x0ae7777d88dd21a8b9ca3dd9212307295a83aed438fef9dad0b62d57fbaf1025": "0x1de5ae5b126bd2cee8eb4f083080f5c30baa692580cf823fa5f382a7bfc70ac5",
Expand Down Expand Up @@ -116,13 +121,16 @@
"0x71369782a004f899a09f30d15d07aea6e386231640ec5a67bf3f0ab2a7a335fe": "0xd546a781322897bd5be8fe859ddca634489f023edcc804545f0dc039f046cc2c"
},
"Test_UniswapV2DirectToLiquidity": {
"0xf2b190e690a84e7be857af56398803943b855c7d589c61a9bb7795689a1f4086": "0x1446d0144b25261ce97bd9dfb74f095481741349546de789031f8189b39b687f"
"0x820db70374c2ffd13fd66deb7afba776b3a403561c28ce10994cae4694e96ee0": "0xb8f5361234f91908bda276227b012d5bb03026757344a7af40459a72ab0722f4"
},
"Test_UniswapV2Router": {
"0x82202d1015ce048c53cd194a4407a02c152ee834d4b503f3dbd41d3799ee0dbb": "0x67226a40a6c0b7968e2cf7c37240a16ea7f3deb588c2421d67ce10cb4494de7e"
},
"Test_UniswapV3DTLWithAllocatedAllowlist": {
"0xbf5ebfb1c6601a4c83bbbe4701337ff6b3e558cb0221311247283d935a83a8fc": "0xa16fae553d108a500f1bb1c5a5b24764bd9e62d7b166452f6d624fabca71f8c5"
},
"Test_UniswapV3DirectToLiquidity": {
"0x74a1f48af0886eb246c7a5ccd3fddc432320f2a6eab09cdeb998e4ea545bf8b4": "0x8d2eb44a9a6a44de1d0e1ccb0b9999633aaaf2bcf2b7b6671ec32b357939e645"
"0xa7b0391bbf2ed03a6ff5ee2b487f9bd689c7c030e44ca4c25de20346bc766a92": "0x46f99bc00335e71bcbeaaa0f83a5aca76278fda55cc32647f208ac5eb334166b"
},
"Test_UniswapV3Factory": {
"0xa56c03532e32af77794962a9477657f2caf39ad7070587c208fbf10ad705cf85": "0x19b9379f4d7172b3d99ce2f2bef5f3be5de1a581ed516956adcdf2f887aed861"
Expand Down
42 changes: 40 additions & 2 deletions script/salts/test/TestSalts.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ import {BALwithCappedAllowlist} from
"../../../src/callbacks/liquidity/BaselineV2/BALwithCappedAllowlist.sol";
import {BALwithTokenAllowlist} from
"../../../src/callbacks/liquidity/BaselineV2/BALwithTokenAllowlist.sol";
import {UniswapV3DTLWithAllocatedAllowlist} from
"../../../src/callbacks/liquidity/UniswapV3DTLWithAllocatedAllowlist.sol";

contract TestSalts is Script, WithEnvironment, Permit2User, WithSalts, TestConstants {
string internal constant _CAPPED_MERKLE_ALLOWLIST = "CappedMerkleAllowlist";
Expand Down Expand Up @@ -193,21 +195,57 @@ contract TestSalts is Script, WithEnvironment, Permit2User, WithSalts, TestConst
}

function generateUniswapV2DirectToLiquidity() public {
bytes memory args = abi.encode(_AUCTION_HOUSE, _UNISWAP_V2_FACTORY, _UNISWAP_V2_ROUTER);
bytes memory args = abi.encode(
_AUCTION_HOUSE,
_UNISWAP_V2_FACTORY,
_UNISWAP_V2_ROUTER,
Callbacks.Permissions({
onCreate: true,
onCancel: true,
onCurate: true,
onPurchase: false,
onBid: false,
onSettle: true,
receiveQuoteTokens: true,
sendBaseTokens: false
})
);
bytes memory contractCode = type(UniswapV2DirectToLiquidity).creationCode;
(string memory bytecodePath, bytes32 bytecodeHash) =
_writeBytecode("UniswapV2DirectToLiquidity", contractCode, args);
_setTestSalt(bytecodePath, "E6", "UniswapV2DirectToLiquidity", bytecodeHash);
}

function generateUniswapV3DirectToLiquidity() public {
bytes memory args = abi.encode(_AUCTION_HOUSE, _UNISWAP_V3_FACTORY, _GUNI_FACTORY);
bytes memory args = abi.encode(
_AUCTION_HOUSE,
_UNISWAP_V3_FACTORY,
_GUNI_FACTORY,
Callbacks.Permissions({
onCreate: true,
onCancel: true,
onCurate: true,
onPurchase: false,
onBid: false,
onSettle: true,
receiveQuoteTokens: true,
sendBaseTokens: false
})
);
bytes memory contractCode = type(UniswapV3DirectToLiquidity).creationCode;
(string memory bytecodePath, bytes32 bytecodeHash) =
_writeBytecode("UniswapV3DirectToLiquidity", contractCode, args);
_setTestSalt(bytecodePath, "E6", "UniswapV3DirectToLiquidity", bytecodeHash);
}

function generateUniswapV3DTLWithAllocatedAllowlist() public {
bytes memory args = abi.encode(_AUCTION_HOUSE, _UNISWAP_V3_FACTORY, _GUNI_FACTORY);
bytes memory contractCode = type(UniswapV3DTLWithAllocatedAllowlist).creationCode;
(string memory bytecodePath, bytes32 bytecodeHash) =
_writeBytecode("UniswapV3DTLWithAllocatedAllowlist", contractCode, args);
_setTestSalt(bytecodePath, "EE", "UniswapV3DTLWithAllocatedAllowlist", bytecodeHash);
}

function generateGUniFactory() public {
// Generate a salt for a GUniFactory
bytes memory args = abi.encode(_UNISWAP_V3_FACTORY);
Expand Down
Loading
Loading