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
14 changes: 9 additions & 5 deletions Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,20 @@ help:
setup:
cd contracts && \
cargo r -r -- vendor && \
cargo r -r -- generate && \
cargo +nightly fmt --all && \
cd generated && cargo +nightly fmt --all && \
cd ../.. && \
tombi format
cargo r -r -- generate
just _format_generated_contracts

# Generate contract bindings
generate-contracts:
cd contracts && \
cargo r -r -- generate
just _format_generated_contracts

_format_generated_contracts:
cd contracts && cargo +nightly fmt --all && \
cd generated && cargo +nightly fmt --all && \
cd ../.. && \
tombi format

# Run unit tests
test-unit:
Expand Down
9 changes: 7 additions & 2 deletions contracts/artifacts/Balances.json

Large diffs are not rendered by default.

55 changes: 33 additions & 22 deletions contracts/generated/contracts-generated/balances/src/lib.rs

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -5833,10 +5833,6 @@ pub const fn deployment_info(chain_id: u64) -> Option<(Address, Option<u64>)> {
::alloy_primitives::address!("0x04501b9b1d52e67f6862d157e00d13419d2d6e95"),
Some(71296258u64),
)),
232u64 => Some((
::alloy_primitives::address!("0xFb337f8a725A142f65fb9ff4902d41cc901de222"),
Some(3007173u64),
)),
8453u64 => Some((
::alloy_primitives::address!("0x3C3eA1829891BC9bEC3d06A81d5d169e52a415e3"),
Some(21490258u64),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2753,10 +2753,6 @@ pub const fn deployment_info(chain_id: u64) -> Option<(Address, Option<u64>)> {
::alloy_primitives::address!("0x2c4c28DDBdAc9C5E7055b4C863b72eA0149D8aFE"),
Some(45854728u64),
)),
232u64 => Some((
::alloy_primitives::address!("0x2c4c28DDBdAc9C5E7055b4C863b72eA0149D8aFE"),
Some(2612937u64),
)),
8453u64 => Some((
::alloy_primitives::address!("0x2c4c28DDBdAc9C5E7055b4C863b72eA0149D8aFE"),
Some(21407137u64),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6162,10 +6162,6 @@ pub const fn deployment_info(chain_id: u64) -> Option<(Address, Option<u64>)> {
::alloy_primitives::address!("0x9008D19f58AAbD9eD0D60971565AA8510560ab41"),
Some(45859743u64),
)),
232u64 => Some((
::alloy_primitives::address!("0x9008D19f58AAbD9eD0D60971565AA8510560ab41"),
Some(2621745u64),
)),
8453u64 => Some((
::alloy_primitives::address!("0x9008D19f58AAbD9eD0D60971565AA8510560ab41"),
Some(21407238u64),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1271,10 +1271,6 @@ pub const fn deployment_info(chain_id: u64) -> Option<(Address, Option<u64>)> {
::alloy_primitives::address!("0x60Bf78233f48eC42eE3F101b9a05eC7878728006"),
None,
)),
232u64 => Some((
::alloy_primitives::address!("0x60Bf78233f48eC42eE3F101b9a05eC7878728006"),
None,
)),
8453u64 => Some((
::alloy_primitives::address!("0x60Bf78233f48eC42eE3F101b9a05eC7878728006"),
None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2177,10 +2177,6 @@ pub const fn deployment_info(chain_id: u64) -> Option<(Address, Option<u64>)> {
::alloy_primitives::address!("0x1F98431c8aD98523631AE4a59f267346ea31F984"),
None,
)),
232u64 => Some((
::alloy_primitives::address!("0xc3A5b857Ba82a2586A45a8B59ECc3AA50Bc3D0e3"),
None,
)),
8453u64 => Some((
::alloy_primitives::address!("0x33128a8fC17869897dcE68Ed026d694621f6FDfD"),
None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1113,10 +1113,6 @@ pub const fn deployment_info(chain_id: u64) -> Option<(Address, Option<u64>)> {
::alloy_primitives::address!("0x8262d639c38470F38d2eff15926F7071c28057Af"),
None,
)),
232u64 => Some((
::alloy_primitives::address!("0x8262d639c38470F38d2eff15926F7071c28057Af"),
None,
)),
8453u64 => Some((
::alloy_primitives::address!("0x8262d639c38470F38d2eff15926F7071c28057Af"),
None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2902,10 +2902,6 @@ pub const fn deployment_info(chain_id: u64) -> Option<(Address, Option<u64>)> {
::alloy_primitives::address!("0x61fFE014bA17989E743c5F6cB21bF9697530B21e"),
None,
)),
232u64 => Some((
::alloy_primitives::address!("0x1eEA2B790Dc527c5a4cd3d4f3ae8A2DDB65B2af1"),
None,
)),
8453u64 => Some((
::alloy_primitives::address!("0x3d4e44Eb1374240CE5F1B871ab261CD16335B76a"),
None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1015,10 +1015,6 @@ pub const fn deployment_info(chain_id: u64) -> Option<(Address, Option<u64>)> {
::alloy_primitives::address!("0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45"),
None,
)),
232u64 => Some((
::alloy_primitives::address!("0x6ddD32cd941041D8b61df213B9f515A7D288Dc13"),
None,
)),
8453u64 => Some((
::alloy_primitives::address!("0x2626664c2603336E57B271c5C0b26F421741e481"),
None,
Expand Down
4 changes: 0 additions & 4 deletions contracts/generated/contracts-generated/weth9/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3239,10 +3239,6 @@ pub const fn deployment_info(chain_id: u64) -> Option<(Address, Option<u64>)> {
::alloy_primitives::address!("0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270"),
None,
)),
232u64 => Some((
::alloy_primitives::address!("0x6bDc36E20D267Ff0dd6097799f82e78907105e2F"),
None,
)),
8453u64 => Some((
::alloy_primitives::address!("0x4200000000000000000000000000000000000006"),
None,
Expand Down
8 changes: 6 additions & 2 deletions contracts/solidity/Balances.sol
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ contract Balances {
/// contract when executing a trade.
/// @return canTransfer - Returns whether or not the transfer into the
/// settlement contract for the specified amount would succeed.
/// @return transferRevertReason - The revert reason bytes if the transfer
/// failed, or empty bytes if it succeeded.
function balance(
Contracts memory contracts,
address trader,
Expand All @@ -49,7 +51,8 @@ contract Balances {
uint256 tokenBalance,
uint256 allowance,
uint256 effectiveBalance,
bool canTransfer
bool canTransfer,
bytes memory transferRevertReason
) {
// Execute the interactions within the current context. This ensures
// that any pre-interactions that setup balances and/or allowances
Expand Down Expand Up @@ -96,8 +99,9 @@ contract Balances {
try contracts.vaultRelayer.transferFromAccounts(transfers) {
canTransfer = true;
}
catch {
catch (bytes memory reason) {
canTransfer = false;
transferRevertReason = reason;
}
}

Expand Down
34 changes: 12 additions & 22 deletions contracts/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,6 @@ fn build_module() -> Module {
BNB => "0x78D78E420Da98ad378D7799bE8f4AF69033EB077",
OPTIMISM => "0x61fFE014bA17989E743c5F6cB21bF9697530B21e",
POLYGON => "0x61fFE014bA17989E743c5F6cB21bF9697530B21e",
LENS => "0x1eEA2B790Dc527c5a4cd3d4f3ae8A2DDB65B2af1",
LINEA => "0x42bE4D6527829FeFA1493e1fb9F3676d2425C3C1",
PLASMA => "0xaa52bB8110fE38D0d2d2AF0B85C3A3eE622CA455",
INK => "0x96b572D2d880cf2Fa2563651BD23ADE6f5516652",
Expand All @@ -346,7 +345,6 @@ fn build_module() -> Module {
BASE => "0x2626664c2603336E57B271c5C0b26F421741e481",
AVALANCHE => "0xbb00FF08d01D300023C629E8fFfFcb65A5a578cE",
BNB => "0xB971eF87ede563556b2ED4b1C0b0019111Dd85d2",
LENS => "0x6ddD32cd941041D8b61df213B9f515A7D288Dc13",
LINEA => "0x3d4e44Eb1374240CE5F1B871ab261CD16335B76a",
PLASMA => "0x807F4E281B7A3B324825C64ca53c69F0b418dE40",
INK => "0x177778F19E89dD1012BdBe603F144088A95C4B53",
Expand All @@ -361,7 +359,6 @@ fn build_module() -> Module {
BNB => "0xdB1d10011AD0Ff90774D0C6Bb92e5C5c8b4461F7",
OPTIMISM => "0x1F98431c8aD98523631AE4a59f267346ea31F984",
POLYGON => "0x1F98431c8aD98523631AE4a59f267346ea31F984",
LENS => "0xc3A5b857Ba82a2586A45a8B59ECc3AA50Bc3D0e3",
LINEA => "0x31FAfd4889FA1269F7a13A66eE0fB458f27D72A9",
PLASMA => "0xcb2436774C3e191c85056d248EF4260ce5f27A9D",
INK => "0x640887A9ba3A9C53Ed27D0F7e8246A4F933f3424",
Expand All @@ -376,7 +373,6 @@ fn build_module() -> Module {
BNB => "0x60Bf78233f48eC42eE3F101b9a05eC7878728006",
OPTIMISM => "0x60Bf78233f48eC42eE3F101b9a05eC7878728006",
POLYGON => "0x60Bf78233f48eC42eE3F101b9a05eC7878728006",
LENS => "0x60Bf78233f48eC42eE3F101b9a05eC7878728006",
LINEA => "0x60bf78233f48ec42ee3f101b9a05ec7878728006",
PLASMA => "0x60Bf78233f48eC42eE3F101b9a05eC7878728006",
INK => "0x60Bf78233f48eC42eE3F101b9a05eC7878728006",
Expand All @@ -391,7 +387,6 @@ fn build_module() -> Module {
BNB => ("0x04501b9b1d52e67f6862d157e00d13419d2d6e95", 48411237),
OPTIMISM => ("0x04501b9b1d52e67f6862d157e00d13419d2d6e95", 134607215),
POLYGON => ("0x04501b9b1d52e67f6862d157e00d13419d2d6e95", 71296258),
LENS => ("0xFb337f8a725A142f65fb9ff4902d41cc901de222", 3007173),
LINEA => ("0x04501b9b1d52e67f6862d157e00d13419d2d6e95", 24522097),
PLASMA => ("0x04501b9b1d52e67f6862d157e00d13419d2d6e95", 3521855),
]))
Expand Down Expand Up @@ -456,7 +451,6 @@ fn build_module() -> Module {
BNB => ("0x2c4c28DDBdAc9C5E7055b4C863b72eA0149D8aFE", 48173639),
OPTIMISM => ("0x2c4c28DDBdAc9C5E7055b4C863b72eA0149D8aFE", 134254466),
POLYGON => ("0x2c4c28DDBdAc9C5E7055b4C863b72eA0149D8aFE", 45854728),
LENS => ("0x2c4c28DDBdAc9C5E7055b4C863b72eA0149D8aFE", 2612937),
LINEA => ("0x2c4c28DDBdAc9C5E7055b4C863b72eA0149D8aFE", 24333100),
PLASMA => ("0x2c4c28DDBdAc9C5E7055b4C863b72eA0149D8aFE", 3439709),
INK => ("0x2c4c28DDBdAc9C5E7055b4C863b72eA0149D8aFE", 34436840),
Expand All @@ -472,7 +466,6 @@ fn build_module() -> Module {
BNB => ("0x9008D19f58AAbD9eD0D60971565AA8510560ab41", 48173641),
OPTIMISM => ("0x9008D19f58AAbD9eD0D60971565AA8510560ab41", 134254624),
POLYGON => ("0x9008D19f58AAbD9eD0D60971565AA8510560ab41", 45859743),
LENS => ("0x9008D19f58AAbD9eD0D60971565AA8510560ab41", 2621745),
LINEA => ("0x9008D19f58AAbD9eD0D60971565AA8510560ab41", 24333100),
PLASMA => ("0x9008D19f58AAbD9eD0D60971565AA8510560ab41", 3439711),
INK => ("0x9008D19f58AAbD9eD0D60971565AA8510560ab41", 34436849),
Expand All @@ -487,7 +480,6 @@ fn build_module() -> Module {
BNB => "0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c",
OPTIMISM => "0x4200000000000000000000000000000000000006",
POLYGON => "0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270",
LENS => "0x6bDc36E20D267Ff0dd6097799f82e78907105e2F",
LINEA => "0xe5d7c2a44ffddf6b295a15c148167daaaf5cf34f",
PLASMA => "0x6100E367285b01F48D07953803A2d8dCA5D19873",
INK => "0x4200000000000000000000000000000000000006",
Expand Down Expand Up @@ -538,27 +530,25 @@ fn build_module() -> Module {
BNB => "0x8262d639c38470F38d2eff15926F7071c28057Af",
OPTIMISM => "0x8262d639c38470F38d2eff15926F7071c28057Af",
POLYGON => "0x8262d639c38470F38d2eff15926F7071c28057Af",
LENS => "0x8262d639c38470F38d2eff15926F7071c28057Af",
GNOSIS => "0x8262d639c38470F38d2eff15926F7071c28057Af",
SEPOLIA => "0x8262d639c38470F38d2eff15926F7071c28057Af",
LINEA => "0xf6E57e72F7dB3D9A51a8B4c149C00475b94A37e4",
PLASMA => "0x8262d639c38470F38d2eff15926F7071c28057Af",
INK => "0x8262d639c38470F38d2eff15926F7071c28057Af",
]))
.add_contract(Contract::new("Balances").with_networks(networks![
MAINNET => "0x3e8C6De9510e7ECad902D005DE3Ab52f35cF4f1b",
ARBITRUM_ONE => "0x3e8C6De9510e7ECad902D005DE3Ab52f35cF4f1b",
BASE => "0x3e8C6De9510e7ECad902D005DE3Ab52f35cF4f1b",
AVALANCHE => "0x3e8C6De9510e7ECad902D005DE3Ab52f35cF4f1b",
BNB => "0x3e8C6De9510e7ECad902D005DE3Ab52f35cF4f1b",
OPTIMISM => "0x3e8C6De9510e7ECad902D005DE3Ab52f35cF4f1b",
POLYGON => "0x3e8C6De9510e7ECad902D005DE3Ab52f35cF4f1b",
LENS => "0x3e8C6De9510e7ECad902D005DE3Ab52f35cF4f1b",
GNOSIS => "0x3e8C6De9510e7ECad902D005DE3Ab52f35cF4f1b",
SEPOLIA => "0x3e8C6De9510e7ECad902D005DE3Ab52f35cF4f1b",
PLASMA => "0x3e8C6De9510e7ECad902D005DE3Ab52f35cF4f1b",
LINEA => "0x361350f708f7c0c63c8a505226592c3e5d1faa29",
INK => "0x3e8C6De9510e7ECad902D005DE3Ab52f35cF4f1b",
MAINNET => "0x88b4B74082BffB2976C306CB3f7E9093AE48B94F",
ARBITRUM_ONE => "0x88b4B74082BffB2976C306CB3f7E9093AE48B94F",
BASE => "0x88b4B74082BffB2976C306CB3f7E9093AE48B94F",
AVALANCHE => "0x88b4B74082BffB2976C306CB3f7E9093AE48B94F",
BNB => "0x88b4B74082BffB2976C306CB3f7E9093AE48B94F",
OPTIMISM => "0x88b4B74082BffB2976C306CB3f7E9093AE48B94F",
POLYGON => "0x88b4B74082BffB2976C306CB3f7E9093AE48B94F",
GNOSIS => "0x88b4B74082BffB2976C306CB3f7E9093AE48B94F",
SEPOLIA => "0x88b4B74082BffB2976C306CB3f7E9093AE48B94F",
PLASMA => "0x88b4B74082BffB2976C306CB3f7E9093AE48B94F",
LINEA => "0x88b4B74082BffB2976C306CB3f7E9093AE48B94F",
INK => "0x88b4B74082BffB2976C306CB3f7E9093AE48B94F",
])),
)
}
1 change: 0 additions & 1 deletion contracts/src/networks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ pub const POLYGON: u64 = 137;
pub const AVALANCHE: u64 = 43114;
pub const BNB: u64 = 56;
pub const OPTIMISM: u64 = 10;
pub const LENS: u64 = 232;
pub const LINEA: u64 = 59144;
pub const PLASMA: u64 = 9745;
pub const INK: u64 = 57073;
9 changes: 6 additions & 3 deletions crates/account-balances/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ impl Query {
pub enum TransferSimulationError {
InsufficientAllowance,
InsufficientBalance,
TransferFailed,
TransferFailed(Vec<u8>),
Other(anyhow::Error),
}

Expand Down Expand Up @@ -176,13 +176,14 @@ impl BalanceSimulator {
.call()
.await?;

let (token_balance, allowance, effective_balance, can_transfer) =
let (token_balance, allowance, effective_balance, can_transfer, transfer_revert_reason) =
<(
sol_data::Uint<256>,
sol_data::Uint<256>,
sol_data::Uint<256>,
sol_data::Bool,
)>::abi_decode(&response.0)
sol_data::Bytes,
)>::abi_decode_params(&response.0)
.map_err(|err| {
tracing::error!(?err, "failed to decode balance response");
alloy_contract::Error::AbiError(alloy_dyn_abi::Error::SolTypes(err))
Expand All @@ -193,6 +194,7 @@ impl BalanceSimulator {
allowance: U256::from_le_slice(&allowance.as_le_bytes()),
effective_balance: U256::from_le_slice(&effective_balance.as_le_bytes()),
can_transfer,
transfer_revert_reason: transfer_revert_reason.to_vec(),
};

tracing::trace!(
Expand All @@ -214,6 +216,7 @@ pub struct Simulation {
pub allowance: U256,
pub effective_balance: U256,
pub can_transfer: bool,
pub transfer_revert_reason: Vec<u8>,
}

#[derive(Debug)]
Expand Down
4 changes: 3 additions & 1 deletion crates/account-balances/src/simulation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,9 @@ impl BalanceFetching for Balances {
return Err(TransferSimulationError::InsufficientAllowance);
}
if !simulation.can_transfer {
return Err(TransferSimulationError::TransferFailed);
return Err(TransferSimulationError::TransferFailed(
simulation.transfer_revert_reason,
));
}

Ok(())
Expand Down
4 changes: 2 additions & 2 deletions crates/e2e/tests/e2e/banned_users.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ async fn forked_node_mainnet_single_limit_order() {
}

/// The block number from which we will fetch state for the forked tests.
const FORK_BLOCK_MAINNET: u64 = 23112197;
const FORK_BLOCK_MAINNET: u64 = 24843565;
/// DAI whale address as per [FORK_BLOCK_MAINNET].
const DAI_WHALE_MAINNET: Address = address!("762d46904B93a1EEDBfF2fD50445CB8ffA41F9FB");
const DAI_WHALE_MAINNET: Address = address!("28c6c06298d514db089934071355e5743bf21d60");
const BANNED_USER: Address = address!("7F367cC41522cE07553e823bf3be79A889DEbe1B");

async fn forked_mainnet_onchain_banned_user_test(web3: Web3) {
Expand Down
4 changes: 2 additions & 2 deletions crates/e2e/tests/e2e/limit_orders.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ async fn local_node_buy_order_with_haircut() {
}

/// The block number from which we will fetch state for the forked tests.
const FORK_BLOCK_MAINNET: u64 = 23112197;
const FORK_BLOCK_MAINNET: u64 = 24843565;
/// USDC whale address as per [FORK_BLOCK_MAINNET].
const USDC_WHALE_MAINNET: Address = address!("28c6c06298d514db089934071355e5743bf21d60");

Expand All @@ -117,7 +117,7 @@ async fn forked_node_mainnet_single_limit_order() {
.await;
}

const FORK_BLOCK_GNOSIS: u64 = 41502478;
const FORK_BLOCK_GNOSIS: u64 = 45588623;
/// USDC whale address as per [FORK_BLOCK_GNOSIS].
const USDC_WHALE_GNOSIS: Address = address!("d4A39d219ADB43aB00739DC5D876D98Fdf0121Bf");

Expand Down
2 changes: 1 addition & 1 deletion crates/e2e/tests/e2e/liquidity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ use {
};

/// The block number from which we will fetch state for the forked tests.
pub const FORK_BLOCK: u64 = 23112197;
pub const FORK_BLOCK: u64 = 24843565;
pub const USDT_WHALE: Address = address!("F977814e90dA44bFA03b6295A0616a897441aceC");
pub const USDC_WHALE: Address = address!("28c6c06298d514db089934071355e5743bf21d60");

Expand Down
2 changes: 1 addition & 1 deletion crates/e2e/tests/e2e/liquidity_source_notification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ use {
};

/// The block number from which we will fetch state for the forked tests.
pub const FORK_BLOCK: u64 = 23326100;
pub const FORK_BLOCK: u64 = 24843565;
pub const USDT_WHALE: Address = address!("6AC38D1b2f0c0c3b9E816342b1CA14d91D5Ff60B");
pub const USDC_WHALE: Address = address!("01b8697695eab322a339c4bf75740db75dc9375e");

Expand Down
2 changes: 1 addition & 1 deletion crates/e2e/tests/e2e/quote_verification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ async fn standard_verified_quote(web3: Web3) {
}

/// The block number from which we will fetch state for the forked tests.
const FORK_BLOCK_MAINNET: u64 = 23112197;
const FORK_BLOCK_MAINNET: u64 = 24843565;

/// Tests that quotes requesting `tx_origin: 0x0000` bypass the verification
/// because those are currently used by some solvers to provide market maker
Expand Down
2 changes: 1 addition & 1 deletion crates/e2e/tests/e2e/wrapper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use {
};

/// The block number from which we will fetch state for the forked test.
const FORK_BLOCK_MAINNET: u64 = 23688436;
const FORK_BLOCK_MAINNET: u64 = 24843565;

/// EmptyWrapper contract address deployed on mainnet.
const EMPTY_WRAPPER_MAINNET: Address = address!("751871E9cA28B441Bb6d3b7C4255cf2B5873d56a");
Expand Down
Loading
Loading