Skip to content

Commit

Permalink
WIP: specialize SettlerIntent on all other chains
Browse files Browse the repository at this point in the history
  • Loading branch information
duncancmt committed Aug 28, 2024
1 parent 1f6ebb8 commit cc4b257
Show file tree
Hide file tree
Showing 11 changed files with 419 additions and 34 deletions.
43 changes: 39 additions & 4 deletions src/chains/Arbitrum.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ pragma solidity ^0.8.25;
import {SettlerBase} from "../SettlerBase.sol";
import {Settler} from "../Settler.sol";
import {SettlerMetaTxn} from "../SettlerMetaTxn.sol";
import {SettlerIntent} from "../SettlerIntent.sol";

import {IERC20} from "forge-std/interfaces/IERC20.sol";
import {MaverickV2, IMaverickV2Pool} from "../core/MaverickV2.sol";
Expand Down Expand Up @@ -39,6 +40,7 @@ import {dackieSwapV3ArbitrumFactory, dackieSwapV3ForkId} from "../core/univ3fork
import {SettlerAbstract} from "../SettlerAbstract.sol";
import {AbstractContext} from "../Context.sol";
import {Permit2PaymentAbstract} from "../core/Permit2PaymentAbstract.sol";
import {Permit2PaymentMetaTxn} from "../core/Permit2Payment.sol";

abstract contract ArbitrumMixin is FreeMemory, SettlerBase, MaverickV2, CurveTricrypto, DodoV2 {
constructor() {
Expand Down Expand Up @@ -124,9 +126,9 @@ abstract contract ArbitrumMixin is FreeMemory, SettlerBase, MaverickV2, CurveTri

/// @custom:security-contact [email protected]
contract ArbitrumSettler is Settler, ArbitrumMixin {
constructor(bytes20 gitCommit) Settler(gitCommit) {}
constructor(bytes20 gitCommit) SettlerBase(gitCommit) {}

function _dispatchVIP(bytes4 action, bytes calldata data) internal override DANGEROUS_freeMemory returns (bool) {
function _dispatchVIP(bytes4 action, bytes calldata data) internal virtual override DANGEROUS_freeMemory returns (bool) {
if (super._dispatchVIP(action, data)) {
return true;
} else if (action == ISettlerActions.MAVERICKV2_VIP.selector) {
Expand Down Expand Up @@ -168,6 +170,7 @@ contract ArbitrumSettler is Settler, ArbitrumMixin {

function _dispatch(uint256 i, bytes4 action, bytes calldata data)
internal
virtual
override(SettlerAbstract, SettlerBase, ArbitrumMixin)
returns (bool)
{
Expand All @@ -181,10 +184,11 @@ contract ArbitrumSettler is Settler, ArbitrumMixin {

/// @custom:security-contact [email protected]
contract ArbitrumSettlerMetaTxn is SettlerMetaTxn, ArbitrumMixin {
constructor(bytes20 gitCommit) SettlerMetaTxn(gitCommit) {}
constructor(bytes20 gitCommit) SettlerBase(gitCommit) {}

function _dispatchVIP(bytes4 action, bytes calldata data, bytes calldata sig)
internal
virtual
override
DANGEROUS_freeMemory
returns (bool)
Expand Down Expand Up @@ -219,13 +223,44 @@ contract ArbitrumSettlerMetaTxn is SettlerMetaTxn, ArbitrumMixin {
// Solidity inheritance is stupid
function _dispatch(uint256 i, bytes4 action, bytes calldata data)
internal
virtual
override(SettlerAbstract, SettlerBase, ArbitrumMixin)
returns (bool)
{
return super._dispatch(i, action, data);
}

function _msgSender() internal view override(SettlerMetaTxn, AbstractContext) returns (address) {
function _msgSender() internal view virtual override(SettlerMetaTxn, AbstractContext) returns (address) {
return super._msgSender();
}
}

/// @custom:security-contact [email protected]
contract ArbitrumSettlerIntent is SettlerIntent, ArbitrumSettlerMetaTxn {
constructor(bytes20 gitCommit) ArbitrumSettlerMetaTxn(gitCommit) {}

// Solidity inheritance is stupid
function _dispatch(uint256 i, bytes4 action, bytes calldata data)
internal
override(ArbitrumSettlerMetaTxn, SettlerBase, SettlerAbstract)
returns (bool)
{
return super._dispatch(i, action, data);
}

function _msgSender() internal view override(SettlerIntent, ArbitrumSettlerMetaTxn) returns (address) {
return super._msgSender();
}

function _witnessTypeSuffix() internal pure override(SettlerIntent, Permit2PaymentMetaTxn) returns (string memory) {
return super._witnessTypeSuffix();
}

function _tokenId() internal pure override(SettlerIntent, SettlerMetaTxn, SettlerAbstract) returns (uint256) {
return super._tokenId();
}

function _dispatchVIP(bytes4 action, bytes calldata data, bytes calldata sig) internal override(ArbitrumSettlerMetaTxn, SettlerMetaTxn) returns (bool) {
return super._dispatchVIP(action, data, sig);
}
}
40 changes: 37 additions & 3 deletions src/chains/Avalanche.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ pragma solidity ^0.8.25;
import {SettlerBase} from "../SettlerBase.sol";
import {Settler} from "../Settler.sol";
import {SettlerMetaTxn} from "../SettlerMetaTxn.sol";
import {SettlerIntent} from "../SettlerIntent.sol";

import {IERC20} from "forge-std/interfaces/IERC20.sol";
import {DodoV2, IDodoV2} from "../core/DodoV2.sol";
Expand All @@ -24,6 +25,7 @@ import {
import {SettlerAbstract} from "../SettlerAbstract.sol";
import {AbstractContext} from "../Context.sol";
import {Permit2PaymentAbstract} from "../core/Permit2PaymentAbstract.sol";
import {Permit2PaymentMetaTxn} from "../core/Permit2Payment.sol";

abstract contract AvalancheMixin is FreeMemory, SettlerBase, DodoV2 {
constructor() {
Expand Down Expand Up @@ -72,7 +74,7 @@ abstract contract AvalancheMixin is FreeMemory, SettlerBase, DodoV2 {

/// @custom:security-contact [email protected]
contract AvalancheSettler is Settler, AvalancheMixin {
constructor(bytes20 gitCommit) Settler(gitCommit) {}
constructor(bytes20 gitCommit) SettlerBase(gitCommit) {}

function _dispatchVIP(bytes4 action, bytes calldata data) internal override DANGEROUS_freeMemory returns (bool) {
return super._dispatchVIP(action, data);
Expand Down Expand Up @@ -103,10 +105,11 @@ contract AvalancheSettler is Settler, AvalancheMixin {

/// @custom:security-contact [email protected]
contract AvalancheSettlerMetaTxn is SettlerMetaTxn, AvalancheMixin {
constructor(bytes20 gitCommit) SettlerMetaTxn(gitCommit) {}
constructor(bytes20 gitCommit) SettlerBase(gitCommit) {}

function _dispatchVIP(bytes4 action, bytes calldata data, bytes calldata sig)
internal
virtual
override
DANGEROUS_freeMemory
returns (bool)
Expand All @@ -117,13 +120,44 @@ contract AvalancheSettlerMetaTxn is SettlerMetaTxn, AvalancheMixin {
// Solidity inheritance is stupid
function _dispatch(uint256 i, bytes4 action, bytes calldata data)
internal
virtual
override(SettlerAbstract, SettlerBase, AvalancheMixin)
returns (bool)
{
return super._dispatch(i, action, data);
}

function _msgSender() internal view override(SettlerMetaTxn, AbstractContext) returns (address) {
function _msgSender() internal view virtual override(SettlerMetaTxn, AbstractContext) returns (address) {
return super._msgSender();
}
}

/// @custom:security-contact [email protected]
contract SepoliSaettlerIntent is SettlerIntent, AvalancheSettlerMetaTxn {
constructor(bytes20 gitCommit) AvalancheSettlerMetaTxn(gitCommit) {}

// Solidity inheritance is stupid
function _dispatch(uint256 i, bytes4 action, bytes calldata data)
internal
override(AvalancheSettlerMetaTxn, SettlerBase, SettlerAbstract)
returns (bool)
{
return super._dispatch(i, action, data);
}

function _msgSender() internal view override(SettlerIntent, AvalancheSettlerMetaTxn) returns (address) {
return super._msgSender();
}

function _witnessTypeSuffix() internal pure override(SettlerIntent, Permit2PaymentMetaTxn) returns (string memory) {
return super._witnessTypeSuffix();
}

function _tokenId() internal pure override(SettlerIntent, SettlerMetaTxn, SettlerAbstract) returns (uint256) {
return super._tokenId();
}

function _dispatchVIP(bytes4 action, bytes calldata data, bytes calldata sig) internal override(AvalancheSettlerMetaTxn, SettlerMetaTxn) returns (bool) {
return super._dispatchVIP(action, data, sig);
}
}
40 changes: 37 additions & 3 deletions src/chains/Base.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ pragma solidity ^0.8.25;
import {SettlerBase} from "../SettlerBase.sol";
import {Settler} from "../Settler.sol";
import {SettlerMetaTxn} from "../SettlerMetaTxn.sol";
import {SettlerIntent} from "../SettlerIntent.sol";

import {IERC20} from "forge-std/interfaces/IERC20.sol";
import {DodoV2, IDodoV2} from "../core/DodoV2.sol";
Expand Down Expand Up @@ -42,6 +43,7 @@ import {kinetixV3BaseFactory, kinetixV3ForkId} from "../core/univ3forks/KinetixV
import {SettlerAbstract} from "../SettlerAbstract.sol";
import {AbstractContext} from "../Context.sol";
import {Permit2PaymentAbstract} from "../core/Permit2PaymentAbstract.sol";
import {Permit2PaymentMetaTxn} from "../core/Permit2Payment.sol";

abstract contract BaseMixin is FreeMemory, SettlerBase, MaverickV2, DodoV2 {
constructor() {
Expand Down Expand Up @@ -155,7 +157,7 @@ abstract contract BaseMixin is FreeMemory, SettlerBase, MaverickV2, DodoV2 {

/// @custom:security-contact [email protected]
contract BaseSettler is Settler, BaseMixin {
constructor(bytes20 gitCommit) Settler(gitCommit) {}
constructor(bytes20 gitCommit) SettlerBase(gitCommit) {}

function _dispatchVIP(bytes4 action, bytes calldata data) internal override DANGEROUS_freeMemory returns (bool) {
if (super._dispatchVIP(action, data)) {
Expand Down Expand Up @@ -202,10 +204,11 @@ contract BaseSettler is Settler, BaseMixin {

/// @custom:security-contact [email protected]
contract BaseSettlerMetaTxn is SettlerMetaTxn, BaseMixin {
constructor(bytes20 gitCommit) SettlerMetaTxn(gitCommit) {}
constructor(bytes20 gitCommit) SettlerBase(gitCommit) {}

function _dispatchVIP(bytes4 action, bytes calldata data, bytes calldata sig)
internal
virtual
override
DANGEROUS_freeMemory
returns (bool)
Expand All @@ -231,13 +234,44 @@ contract BaseSettlerMetaTxn is SettlerMetaTxn, BaseMixin {
// Solidity inheritance is stupid
function _dispatch(uint256 i, bytes4 action, bytes calldata data)
internal
virtual
override(SettlerAbstract, SettlerBase, BaseMixin)
returns (bool)
{
return super._dispatch(i, action, data);
}

function _msgSender() internal view override(SettlerMetaTxn, AbstractContext) returns (address) {
function _msgSender() internal view virtual override(SettlerMetaTxn, AbstractContext) returns (address) {
return super._msgSender();
}
}

/// @custom:security-contact [email protected]
contract BaseSettlerIntent is SettlerIntent, BaseSettlerMetaTxn {
constructor(bytes20 gitCommit) BaseSettlerMetaTxn(gitCommit) {}

// Solidity inheritance is stupid
function _dispatch(uint256 i, bytes4 action, bytes calldata data)
internal
override(BaseSettlerMetaTxn, SettlerBase, SettlerAbstract)
returns (bool)
{
return super._dispatch(i, action, data);
}

function _msgSender() internal view override(SettlerIntent, BaseSettlerMetaTxn) returns (address) {
return super._msgSender();
}

function _witnessTypeSuffix() internal pure override(SettlerIntent, Permit2PaymentMetaTxn) returns (string memory) {
return super._witnessTypeSuffix();
}

function _tokenId() internal pure override(SettlerIntent, SettlerMetaTxn, SettlerAbstract) returns (uint256) {
return super._tokenId();
}

function _dispatchVIP(bytes4 action, bytes calldata data, bytes calldata sig) internal override(BaseSettlerMetaTxn, SettlerMetaTxn) returns (bool) {
return super._dispatchVIP(action, data, sig);
}
}
50 changes: 47 additions & 3 deletions src/chains/Blast.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ pragma solidity ^0.8.25;
import {SettlerBase} from "../SettlerBase.sol";
import {Settler} from "../Settler.sol";
import {SettlerMetaTxn} from "../SettlerMetaTxn.sol";
import {SettlerIntent} from "../SettlerIntent.sol";

import {FreeMemory} from "../utils/FreeMemory.sol";

Expand Down Expand Up @@ -36,6 +37,7 @@ import {SettlerAbstract} from "../SettlerAbstract.sol";
import {AbstractContext} from "../Context.sol";
import {Permit2PaymentAbstract} from "../core/Permit2PaymentAbstract.sol";
import {Permit2PaymentBase} from "../core/Permit2Payment.sol";
import {Permit2PaymentMetaTxn} from "../core/Permit2Payment.sol";

abstract contract BlastMixin is FreeMemory, SettlerBase {
constructor() {
Expand Down Expand Up @@ -109,7 +111,7 @@ abstract contract BlastMixin is FreeMemory, SettlerBase {

/// @custom:security-contact [email protected]
contract BlastSettler is Settler, BlastMixin {
constructor(bytes20 gitCommit) Settler(gitCommit) {}
constructor(bytes20 gitCommit) SettlerBase(gitCommit) {}

function _dispatchVIP(bytes4 action, bytes calldata data) internal override DANGEROUS_freeMemory returns (bool) {
return super._dispatchVIP(action, data);
Expand All @@ -135,10 +137,11 @@ contract BlastSettler is Settler, BlastMixin {

/// @custom:security-contact [email protected]
contract BlastSettlerMetaTxn is SettlerMetaTxn, BlastMixin {
constructor(bytes20 gitCommit) SettlerMetaTxn(gitCommit) {}
constructor(bytes20 gitCommit) SettlerBase(gitCommit) {}

function _dispatchVIP(bytes4 action, bytes calldata data, bytes calldata sig)
internal
virtual
override
DANGEROUS_freeMemory
returns (bool)
Expand All @@ -149,6 +152,7 @@ contract BlastSettlerMetaTxn is SettlerMetaTxn, BlastMixin {
function _isRestrictedTarget(address target)
internal
pure
virtual
override(Permit2PaymentBase, BlastMixin, Permit2PaymentAbstract)
returns (bool)
{
Expand All @@ -158,13 +162,53 @@ contract BlastSettlerMetaTxn is SettlerMetaTxn, BlastMixin {
// Solidity inheritance is stupid
function _dispatch(uint256 i, bytes4 action, bytes calldata data)
internal
virtual
override(SettlerAbstract, SettlerBase, BlastMixin)
returns (bool)
{
return super._dispatch(i, action, data);
}

function _msgSender() internal view override(SettlerMetaTxn, AbstractContext) returns (address) {
function _msgSender() internal view virtual override(SettlerMetaTxn, AbstractContext) returns (address) {
return super._msgSender();
}
}

/// @custom:security-contact [email protected]
contract BlastSettlerIntent is SettlerIntent, BlastSettlerMetaTxn {
constructor(bytes20 gitCommit) BlastSettlerMetaTxn(gitCommit) {}

// Solidity inheritance is stupid
function _isRestrictedTarget(address target)
internal
pure
override(BlastSettlerMetaTxn, Permit2PaymentBase, Permit2PaymentAbstract)
returns (bool)
{
return super._isRestrictedTarget(target);
}

function _dispatch(uint256 i, bytes4 action, bytes calldata data)
internal
override(BlastSettlerMetaTxn, SettlerBase, SettlerAbstract)
returns (bool)
{
return super._dispatch(i, action, data);
}

function _msgSender() internal view override(SettlerIntent, BlastSettlerMetaTxn) returns (address) {
return super._msgSender();
}

function _witnessTypeSuffix() internal pure override(SettlerIntent, Permit2PaymentMetaTxn) returns (string memory) {
return super._witnessTypeSuffix();
}

function _tokenId() internal pure override(SettlerIntent, SettlerMetaTxn, SettlerAbstract) returns (uint256) {
return super._tokenId();
}

function _dispatchVIP(bytes4 action, bytes calldata data, bytes calldata sig) internal override(BlastSettlerMetaTxn, SettlerMetaTxn) returns (bool) {
return super._dispatchVIP(action, data, sig);
}
}
Loading

0 comments on commit cc4b257

Please sign in to comment.