Skip to content
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 BalancerV3 actions to Base and Arbitrum #298

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ Master list of UniV3 forks:
* Add UniswapV3 UniV3 fork to Monad Testnet
* Add UniswapV4 actions to Sepolia
* Add UniswapV4 actions to Ink
* Add BalancerV3 actions to Base
* Add BalancerV3 actions to Arbitrum

## 2025-01-23

Expand Down
25 changes: 24 additions & 1 deletion src/chains/Arbitrum/Common.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {DodoV1, IDodoV1} from "../../core/DodoV1.sol";
import {DodoV2, IDodoV2} from "../../core/DodoV2.sol";
import {UniswapV4} from "../../core/UniswapV4.sol";
import {IPoolManager} from "../../core/UniswapV4Types.sol";
import {BalancerV3} from "../../core/BalancerV3.sol";
import {FreeMemory} from "../../utils/FreeMemory.sol";

import {ISettlerActions} from "../../ISettlerActions.sol";
Expand Down Expand Up @@ -44,7 +45,16 @@ import {ARBITRUM_POOL_MANAGER} from "../../core/UniswapV4Addresses.sol";
// Solidity inheritance is stupid
import {SettlerAbstract} from "../../SettlerAbstract.sol";

abstract contract ArbitrumMixin is FreeMemory, SettlerBase, MaverickV2, CurveTricrypto, DodoV1, DodoV2, UniswapV4 {
abstract contract ArbitrumMixin is
FreeMemory,
SettlerBase,
MaverickV2,
CurveTricrypto,
DodoV1,
DodoV2,
UniswapV4,
BalancerV3
{
constructor() {
assert(block.chainid == 42161 || block.chainid == 31337);
}
Expand All @@ -71,6 +81,19 @@ abstract contract ArbitrumMixin is FreeMemory, SettlerBase, MaverickV2, CurveTri
) = abi.decode(data, (address, IERC20, uint256, bool, uint256, uint256, bytes, uint256));

sellToUniswapV4(recipient, sellToken, bps, feeOnTransfer, hashMul, hashMod, fills, amountOutMin);
} else if (action == uint32(ISettlerActions.BALANCERV3.selector)) {
(
address recipient,
IERC20 sellToken,
uint256 bps,
bool feeOnTransfer,
uint256 hashMul,
uint256 hashMod,
bytes memory fills,
uint256 amountOutMin
) = abi.decode(data, (address, IERC20, uint256, bool, uint256, uint256, bytes, uint256));

sellToBalancerV3(recipient, sellToken, bps, feeOnTransfer, hashMul, hashMod, fills, amountOutMin);
} else if (action == uint32(ISettlerActions.MAVERICKV2.selector)) {
(
address recipient,
Expand Down
14 changes: 14 additions & 0 deletions src/chains/Arbitrum/MetaTxn.sol
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,20 @@ contract ArbitrumSettlerMetaTxn is SettlerMetaTxn, ArbitrumMixin {
);

sellToUniswapV4VIP(recipient, feeOnTransfer, hashMul, hashMod, fills, permit, sig, amountOutMin);
} else if (action == uint32(ISettlerActions.METATXN_BALANCERV3_VIP.selector)) {
(
address recipient,
bool feeOnTransfer,
uint256 hashMul,
uint256 hashMod,
bytes memory fills,
ISignatureTransfer.PermitTransferFrom memory permit,
uint256 amountOutMin
) = abi.decode(
data, (address, bool, uint256, uint256, bytes, ISignatureTransfer.PermitTransferFrom, uint256)
);

sellToBalancerV3VIP(recipient, feeOnTransfer, hashMul, hashMod, fills, permit, sig, amountOutMin);
} else if (action == uint32(ISettlerActions.METATXN_MAVERICKV2_VIP.selector)) {
(
address recipient,
Expand Down
15 changes: 15 additions & 0 deletions src/chains/Arbitrum/TakerSubmitted.sol
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,21 @@ contract ArbitrumSettler is Settler, ArbitrumMixin {
);

sellToUniswapV4VIP(recipient, feeOnTransfer, hashMul, hashMod, fills, permit, sig, amountOutMin);
} else if (action == uint32(ISettlerActions.BALANCERV3_VIP.selector)) {
(
address recipient,
bool feeOnTransfer,
uint256 hashMul,
uint256 hashMod,
bytes memory fills,
ISignatureTransfer.PermitTransferFrom memory permit,
bytes memory sig,
uint256 amountOutMin
) = abi.decode(
data, (address, bool, uint256, uint256, bytes, ISignatureTransfer.PermitTransferFrom, bytes, uint256)
);

sellToBalancerV3VIP(recipient, feeOnTransfer, hashMul, hashMod, fills, permit, sig, amountOutMin);
} else if (action == uint32(ISettlerActions.MAVERICKV2_VIP.selector)) {
(
address recipient,
Expand Down
3 changes: 2 additions & 1 deletion src/chains/Base/Common.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {DodoV2, IDodoV2} from "../../core/DodoV2.sol";
import {MaverickV2, IMaverickV2Pool} from "../../core/MaverickV2.sol";
import {UniswapV4} from "../../core/UniswapV4.sol";
import {IPoolManager} from "../../core/UniswapV4Types.sol";
import {BalancerV3} from "../../core/BalancerV3.sol";
import {FreeMemory} from "../../utils/FreeMemory.sol";

import {ISettlerActions} from "../../ISettlerActions.sol";
Expand Down Expand Up @@ -46,7 +47,7 @@ import {BASE_POOL_MANAGER} from "../../core/UniswapV4Addresses.sol";
// Solidity inheritance is stupid
import {SettlerAbstract} from "../../SettlerAbstract.sol";

abstract contract BaseMixin is FreeMemory, SettlerBase, MaverickV2, DodoV2, UniswapV4 {
abstract contract BaseMixin is FreeMemory, SettlerBase, MaverickV2, DodoV2, UniswapV4, BalancerV3 {
constructor() {
assert(block.chainid == 8453 || block.chainid == 31337);
}
Expand Down
14 changes: 14 additions & 0 deletions src/chains/Base/MetaTxn.sol
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,20 @@ contract BaseSettlerMetaTxn is SettlerMetaTxn, BaseMixin {
);

sellToUniswapV4VIP(recipient, feeOnTransfer, hashMul, hashMod, fills, permit, sig, amountOutMin);
} else if (action == uint32(ISettlerActions.METATXN_BALANCERV3_VIP.selector)) {
(
address recipient,
bool feeOnTransfer,
uint256 hashMul,
uint256 hashMod,
bytes memory fills,
ISignatureTransfer.PermitTransferFrom memory permit,
uint256 amountOutMin
) = abi.decode(
data, (address, bool, uint256, uint256, bytes, ISignatureTransfer.PermitTransferFrom, uint256)
);

sellToBalancerV3VIP(recipient, feeOnTransfer, hashMul, hashMod, fills, permit, sig, amountOutMin);
} else if (action == uint32(ISettlerActions.METATXN_MAVERICKV2_VIP.selector)) {
(
address recipient,
Expand Down
15 changes: 15 additions & 0 deletions src/chains/Base/TakerSubmitted.sol
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,21 @@ contract BaseSettler is Settler, BaseMixin {
);

sellToUniswapV4VIP(recipient, feeOnTransfer, hashMul, hashMod, fills, permit, sig, amountOutMin);
} else if (action == uint32(ISettlerActions.BALANCERV3_VIP.selector)) {
(
address recipient,
bool feeOnTransfer,
uint256 hashMul,
uint256 hashMod,
bytes memory fills,
ISignatureTransfer.PermitTransferFrom memory permit,
bytes memory sig,
uint256 amountOutMin
) = abi.decode(
data, (address, bool, uint256, uint256, bytes, ISignatureTransfer.PermitTransferFrom, bytes, uint256)
);

sellToBalancerV3VIP(recipient, feeOnTransfer, hashMul, hashMod, fills, permit, sig, amountOutMin);
} else if (action == uint32(ISettlerActions.MAVERICKV2_VIP.selector)) {
(
address recipient,
Expand Down
4 changes: 1 addition & 3 deletions src/core/UniswapV4.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ import {UnsafeMath} from "../utils/UnsafeMath.sol";

import {TooMuchSlippage, DeltaNotPositive, DeltaNotNegative, ZeroSellAmount} from "./SettlerErrors.sol";

import {
BalanceDelta, IHooks, IPoolManager, UnsafePoolManager, IUnlockCallback
} from "./UniswapV4Types.sol";
import {BalanceDelta, IHooks, IPoolManager, UnsafePoolManager, IUnlockCallback} from "./UniswapV4Types.sol";
import {Encoder, NotesLib, StateLib, Decoder, Take} from "./FlashAccountingCommon.sol";

library CreditDebt {
Expand Down
Loading