Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
29 changes: 10 additions & 19 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,32 +14,22 @@ jobs:
id-token: write
contents: write
steps:
- name: Load secret
uses: 1password/load-secrets-action@581a835fb51b8e7ec56b71cf2ffddd7e68bb25e0
with:
# Export loaded secrets as environment variables
export-env: true
env:
OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }}
# You may need to change this to your vault name and secret name
# Refer to it by calling env.NPM_TOKEN
# This token is also limited by IP to ONLY work on the runner
NPM_TOKEN: op://npm-deploy/npm-runner-token/secret
- uses: bullfrogsec/bullfrog@1831f79cce8ad602eef14d2163873f27081ebfb3 # v0.8.4

- name: Checkout
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0

- name: Setup Node
uses: actions/setup-node@1a4442cacd436585916779262731d5b162bc6ec7
uses: actions/setup-node@7c12f8017d5436eb855f1ed4399f037a36fbd9e8 # v2
with:
cache: yarn
node-version: 18
node-version: 20
registry-url: 'https://registry.npmjs.org'

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
uses: foundry-rs/foundry-toolchain@50d5a8956f2e319df19e6b57539d7e2acb9f8c1e # v1.5.0
with:
version: stable
version: v1.4.3

- name: Install dependencies
run: |
Expand All @@ -49,9 +39,10 @@ jobs:
- name: Compile
run: yarn compile

- name: Install npm
run: npm install -g npm@latest

- name: Release
env:
NPM_CONFIG_USERCONFIG: /dev/null
NODE_AUTH_TOKEN: ${{ env.NPM_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: echo "//registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}" > ~/.npmrc && yarn publish
run: yarn publish
14 changes: 8 additions & 6 deletions .github/workflows/forge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@ jobs:
name: Foundry project
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: bullfrogsec/bullfrog@1831f79cce8ad602eef14d2163873f27081ebfb3 # v0.8.4

- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
submodules: recursive

# Must Insall node modules for forge to reference in remappings
- uses: actions/setup-node@v1
# Must Install node modules for forge to reference in remappings
- uses: actions/setup-node@7c12f8017d5436eb855f1ed4399f037a36fbd9e8 # v2
with:
node-version: 18.x
registry-url: https://registry.npmjs.org
Expand All @@ -33,7 +35,7 @@ jobs:
- id: yarn-cache
run: echo "::set-output name=dir::$(yarn cache dir)"

- uses: actions/cache@v3
- uses: actions/cache@6f8efc29b200d32929f49075959781ed54ec270c # v3.5.0
with:
path: ${{ steps.yarn-cache.outputs.dir }}
key: yarn-${{ hashFiles('**/yarn.lock') }}
Expand All @@ -44,9 +46,9 @@ jobs:
# End of node module support

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
uses: foundry-rs/foundry-toolchain@50d5a8956f2e319df19e6b57539d7e2acb9f8c1e # v1.5.0
with:
version: stable
version: v1.4.3

- name: Run Forge build
run: |
Expand Down
10 changes: 6 additions & 4 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: bullfrogsec/bullfrog@1831f79cce8ad602eef14d2163873f27081ebfb3 # v0.8.4

- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
submodules: recursive

- name: Set up node
uses: actions/setup-node@v1
uses: actions/setup-node@7c12f8017d5436eb855f1ed4399f037a36fbd9e8 # v2
with:
node-version: 18.x
registry-url: https://registry.npmjs.org
Expand All @@ -29,9 +31,9 @@ jobs:
run: yarn install --frozen-lockfile

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
uses: foundry-rs/foundry-toolchain@50d5a8956f2e319df19e6b57539d7e2acb9f8c1e # v1.5.0
with:
version: stable
version: v1.4.3

- name: Run Forge build
run: |
Expand Down
12 changes: 7 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: bullfrogsec/bullfrog@1831f79cce8ad602eef14d2163873f27081ebfb3 # v0.8.4

- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
submodules: recursive

- uses: actions/setup-node@v1
- uses: actions/setup-node@7c12f8017d5436eb855f1ed4399f037a36fbd9e8 # v2
with:
node-version: 18.x
registry-url: https://registry.npmjs.org
Expand All @@ -27,7 +29,7 @@ jobs:
- id: yarn-cache
run: echo "::set-output name=dir::$(yarn cache dir)"

- uses: actions/cache@v3
- uses: actions/cache@6f8efc29b200d32929f49075959781ed54ec270c # v3.5.0
with:
path: ${{ steps.yarn-cache.outputs.dir }}
key: yarn-${{ hashFiles('**/yarn.lock') }}
Expand All @@ -38,9 +40,9 @@ jobs:
run: yarn install --frozen-lockfile

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
uses: foundry-rs/foundry-toolchain@50d5a8956f2e319df19e6b57539d7e2acb9f8c1e # v1.5.0
with:
version: stable
version: v1.4.3

# This is required separately from yarn test because it generates the typechain definitions
- name: Compile
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,7 @@ typechain-types
#Hardhat files
cache
artifacts

# Yarn files
.yarn/
.yarnrc.yml
6 changes: 3 additions & 3 deletions contracts/UniversalRouter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import {MigratorImmutables, MigratorParameters} from './modules/MigratorImmutabl

contract UniversalRouter is IUniversalRouter, Dispatcher {
constructor(RouterParameters memory params)
UniswapImmutables(
UniswapParameters(params.v2Factory, params.v3Factory, params.pairInitCodeHash, params.poolInitCodeHash)
)
UniswapImmutables(UniswapParameters(
params.v2Factory, params.v3Factory, params.pairInitCodeHash, params.poolInitCodeHash
))
V4SwapRouter(params.v4PoolManager)
PaymentsImmutables(PaymentsParameters(params.permit2, params.weth9))
MigratorImmutables(MigratorParameters(params.v3NFTPositionManager, params.v4PositionManager))
Expand Down
34 changes: 18 additions & 16 deletions contracts/base/Dispatcher.sol
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,15 @@ abstract contract Dispatcher is Payments, V2SwapRouter, V3SwapRouter, V4SwapRout
permitBatch := add(inputs.offset, calldataload(inputs.offset))
}
bytes calldata data = inputs.toBytes(1);
(success, output) = address(PERMIT2).call(
abi.encodeWithSignature(
'permit(address,((address,uint160,uint48,uint48)[],address,uint256),bytes)',
msgSender(),
permitBatch,
data
)
);
(success, output) = address(PERMIT2)
.call(
abi.encodeWithSignature(
'permit(address,((address,uint160,uint48,uint48)[],address,uint256),bytes)',
msgSender(),
permitBatch,
data
)
);
} else if (command == Commands.SWEEP) {
// equivalent: abi.decode(inputs, (address, address, uint256))
address token;
Expand Down Expand Up @@ -192,14 +193,15 @@ abstract contract Dispatcher is Payments, V2SwapRouter, V3SwapRouter, V4SwapRout
permitSingle := inputs.offset
}
bytes calldata data = inputs.toBytes(6); // PermitSingle takes first 6 slots (0..5)
(success, output) = address(PERMIT2).call(
abi.encodeWithSignature(
'permit(address,((address,uint160,uint48,uint48),address,uint256),bytes)',
msgSender(),
permitSingle,
data
)
);
(success, output) = address(PERMIT2)
.call(
abi.encodeWithSignature(
'permit(address,((address,uint160,uint48,uint48),address,uint256),bytes)',
msgSender(),
permitSingle,
data
)
);
} else if (command == Commands.WRAP_ETH) {
// equivalent: abi.decode(inputs, (address, uint256))
address recipient;
Expand Down
4 changes: 2 additions & 2 deletions contracts/libraries/Locker.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ library Locker {

function set(address locker) internal {
// The locker is always msg.sender or address(0) so does not need to be cleaned
assembly ("memory-safe") {
assembly ('memory-safe') {
tstore(LOCKER_SLOT, locker)
}
}

function get() internal view returns (address locker) {
assembly ("memory-safe") {
assembly ('memory-safe') {
locker := tload(LOCKER_SLOT)
}
}
Expand Down
4 changes: 2 additions & 2 deletions contracts/libraries/MaxInputAmount.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ library MaxInputAmount {
bytes32 constant MAX_AMOUNT_IN_SLOT = 0xaf28d9864a81dfdf71cab65f4e5d79a0cf9b083905fb8971425e6cb581b3f692;

function set(uint256 maxAmountIn) internal {
assembly ("memory-safe") {
assembly ('memory-safe') {
tstore(MAX_AMOUNT_IN_SLOT, maxAmountIn)
}
}

function get() internal view returns (uint256 maxAmountIn) {
assembly ("memory-safe") {
assembly ('memory-safe') {
maxAmountIn := tload(MAX_AMOUNT_IN_SLOT)
}
}
Expand Down
10 changes: 6 additions & 4 deletions contracts/modules/uniswap/v2/V2SwapRouter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,9 @@ abstract contract V2SwapRouter is UniswapImmutables, Permit2Payments {
address[] calldata path,
address payer
) internal {
address firstPair =
UniswapV2Library.pairFor(UNISWAP_V2_FACTORY, UNISWAP_V2_PAIR_INIT_CODE_HASH, path[0], path[1]);
address firstPair = UniswapV2Library.pairFor(
UNISWAP_V2_FACTORY, UNISWAP_V2_PAIR_INIT_CODE_HASH, path[0], path[1]
);
if (
amountIn != Constants.ALREADY_PAID // amountIn of 0 to signal that the pair already has the tokens
) {
Expand Down Expand Up @@ -86,8 +87,9 @@ abstract contract V2SwapRouter is UniswapImmutables, Permit2Payments {
address[] calldata path,
address payer
) internal {
(uint256 amountIn, address firstPair) =
UniswapV2Library.getAmountInMultihop(UNISWAP_V2_FACTORY, UNISWAP_V2_PAIR_INIT_CODE_HASH, amountOut, path);
(uint256 amountIn, address firstPair) = UniswapV2Library.getAmountInMultihop(
UNISWAP_V2_FACTORY, UNISWAP_V2_PAIR_INIT_CODE_HASH, amountOut, path
);
if (amountIn > amountInMaximum) revert V2TooMuchRequested();

payOrPermit2Transfer(path[0], payer, firstPair, amountIn);
Expand Down
15 changes: 8 additions & 7 deletions contracts/modules/uniswap/v3/V3SwapRouter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,14 @@ abstract contract V3SwapRouter is UniswapImmutables, Permit2Payments, IUniswapV3

zeroForOne = isExactIn ? tokenIn < tokenOut : tokenOut < tokenIn;

(amount0Delta, amount1Delta) = IUniswapV3Pool(computePoolAddress(tokenIn, tokenOut, fee)).swap(
recipient,
zeroForOne,
amount,
(zeroForOne ? MIN_SQRT_RATIO + 1 : MAX_SQRT_RATIO - 1),
abi.encode(path, payer)
);
(amount0Delta, amount1Delta) = IUniswapV3Pool(computePoolAddress(tokenIn, tokenOut, fee))
.swap(
recipient,
zeroForOne,
amount,
(zeroForOne ? MIN_SQRT_RATIO + 1 : MAX_SQRT_RATIO - 1),
abi.encode(path, payer)
);
}

function computePoolAddress(address tokenA, address tokenB, uint24 fee) private view returns (address pool) {
Expand Down
3 changes: 3 additions & 0 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,7 @@ unichain_sepolia = "https://sepolia.unichain.org"
base_sepolia = "https://sepolia.base.org"
op_sepolia = "https://sepolia.optimism.io"

[lint]
lint_on_build = false

# See more config options https://github.com/foundry-rs/foundry/tree/master/config
Loading