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

WIP: BalancerV3 #278

Draft
wants to merge 23 commits into
base: master
Choose a base branch
from
Draft
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
12 changes: 10 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,9 @@ Master list of UniV3 forks:
* `UNISWAPV4`, `UNISWAPV4_VIP`, and `METATXN_UNISWAPV4_VIP`
* See comments in [UniswapV4.sol](src/core/UniswapV4.sol) regarding how to
encode `fills`
* See comments in [UniswapV4.sol](src/core/UniswapV4.sol) regarding how to
compute a perfect token hash function
* See comments in
[FlashAccountingCommon.sol](src/core/FlashAccountingCommon.sol) regarding
how to compute a perfect token hash function
* Add `msgSender()(address)` accessor on Base to retrieve the current taker
* Improve accuracy, gas, and convergence region coverage in SolidlyV1/VelodromeV2 action (`VELODROME`)
* Add DodoV1 actions to more chains
Expand All @@ -59,6 +60,13 @@ Master list of UniV3 forks:
* Add `rebateClaimer()(address)` function on Mainnet Settlers for gas rebate program
* Add SolidlyV3 UniV3 fork to Sonic
* Add Wagmi UniV3 fork to Sonic
* Add actions for BalancerV3
* `BALANCERV3`, `BALANCERV3_VIP`, and `METATXN_BALANCERV3_VIP`
* See comments in [BalancerV3.sol](src/core/BalancerV3.sol) regarding how to
encode `fills`
* See comments in
[FlashAccountingCommon.sol](src/core/FlashAccountingCommon.sol) regarding
how to compute a perfect token hash function

## 2024-12-18

Expand Down
30 changes: 30 additions & 0 deletions src/ISettlerActions.sol
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,36 @@ interface ISettlerActions {
uint256 amountOutMin
) external;

function BALANCERV3(
address recipient,
address sellToken,
uint256 bps,
bool feeOnTransfer,
uint256 hashMul,
uint256 hashMod,
bytes memory fills,
uint256 amountOutMin
) external;
function BALANCERV3_VIP(
address recipient,
bool feeOnTransfer,
uint256 hashMul,
uint256 hashMod,
bytes memory fills,
ISignatureTransfer.PermitTransferFrom memory permit,
bytes memory sig,
uint256 amountOutMin
) external;
function METATXN_BALANCERV3_VIP(
address recipient,
bool feeOnTransfer,
uint256 hashMul,
uint256 hashMod,
bytes memory fills,
ISignatureTransfer.PermitTransferFrom memory permit,
uint256 amountOutMin
) external;

/// @dev Trades against UniswapV3 using the contracts balance for funding
// Pre-req: Funded
// Post-req: Payout
Expand Down
17 changes: 16 additions & 1 deletion src/chains/Mainnet/Common.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {CurveTricrypto} from "../../core/CurveTricrypto.sol";
import {DodoV1, IDodoV1} from "../../core/DodoV1.sol";
import {DodoV2, IDodoV2} from "../../core/DodoV2.sol";
import {UniswapV4} from "../../core/UniswapV4.sol";
import {BalancerV3} from "../../core/BalancerV3.sol";
import {FreeMemory} from "../../utils/FreeMemory.sol";

import {ISettlerActions} from "../../ISettlerActions.sol";
Expand Down Expand Up @@ -50,7 +51,8 @@ abstract contract MainnetMixin is
CurveTricrypto,
DodoV1,
DodoV2,
UniswapV4
UniswapV4,
BalancerV3
{
constructor() {
assert(block.chainid == 1 || block.chainid == 31337);
Expand Down Expand Up @@ -83,6 +85,19 @@ abstract contract MainnetMixin is
abi.decode(data, (address, uint256, bool, uint256));

sellToMakerPsm(recipient, bps, buyGem, 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
16 changes: 15 additions & 1 deletion src/chains/Mainnet/MetaTxn.sol
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ contract MainnetSettlerMetaTxn is SettlerMetaTxn, MainnetMixin {
{
if (super._dispatchVIP(action, data, sig)) {
return true;
} else if (action == uint32(ISettlerActions.UNISWAPV4_VIP.selector)) {
} else if (action == uint32(ISettlerActions.METATXN_UNISWAPV4_VIP.selector)) {
(
address recipient,
bool feeOnTransfer,
Expand All @@ -39,6 +39,20 @@ contract MainnetSettlerMetaTxn is SettlerMetaTxn, MainnetMixin {
);

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/Mainnet/TakerSubmitted.sol
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,21 @@ contract MainnetSettler is Settler, MainnetMixin {
);

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
Loading
Loading