Expand description
cow-composable — Layer 5 CoW Protocol composable (conditional) orders for the CoW
Protocol SDK.
Composable orders are validated on-chain by handler contracts and managed
through the ComposableCow factory. This module provides:
TwapOrder— Time-Weighted Average Price orders with ABI encodingMultiplexer— manages multiple orders under a single Merkle rootConditionalOrderFactory— decode on-chain params into typed orderscreate_calldata/remove_calldata—ComposableCowcalldata builderscreate_with_context_calldata—createWithContextforAtMiningTimeTWAP orders
§Example — single TWAP order
use alloy_primitives::{Address, B256, U256};
use cow_composable::{DurationOfPart, TwapData, TwapOrder, TwapStartTime};
use cow_types::OrderKind;
let data = TwapData {
sell_token: Address::ZERO,
buy_token: Address::ZERO,
receiver: Address::ZERO,
sell_amount: U256::from(24_000_000u64), // divisible by num_parts
buy_amount: U256::from(21_600_000u64),
start_time: TwapStartTime::AtMiningTime,
part_duration: 3_600,
num_parts: 24,
app_data: B256::ZERO,
partially_fillable: false,
kind: OrderKind::Sell,
duration_of_part: DurationOfPart::Auto,
};
let order = TwapOrder::new(data);
assert!(order.is_valid());
let params = order.to_params()?;
let cd = cow_composable::create_calldata(¶ms, &[], &[]);
println!("calldata: 0x{}", alloy_primitives::hex::encode(&cd));Re-exports§
pub use calldata::create_calldata;pub use calldata::create_with_context_calldata;pub use calldata::remove_calldata;pub use calldata::set_root_calldata;pub use calldata::set_root_with_context_calldata;pub use factory::ConditionalOrderFactory;pub use factory::ConditionalOrderKind;pub use gat::GAT_HANDLER_ADDRESS;pub use gat::GatData;pub use gat::GatOrder;pub use gat::decode_gat_static_input;pub use gat::encode_gat_struct;pub use multiplexer::Multiplexer;pub use multiplexer::OrderProof;pub use multiplexer::ProofWithParams;pub use stop_loss::STOP_LOSS_HANDLER_ADDRESS;pub use stop_loss::StopLossData;pub use stop_loss::StopLossOrder;pub use stop_loss::decode_stop_loss_static_input;pub use stop_loss::encode_stop_loss_struct;pub use twap::TwapOrder;pub use twap::data_to_struct;pub use twap::decode_params;pub use twap::decode_twap_static_input;pub use twap::decode_twap_struct;pub use twap::encode_params;pub use twap::encode_twap_struct;pub use twap::format_epoch;pub use twap::order_id;pub use twap::struct_to_data;pub use types::BlockInfo;pub use types::COMPOSABLE_COW_ADDRESS;pub use types::CURRENT_BLOCK_TIMESTAMP_FACTORY_ADDRESS;pub use types::ConditionalOrderParams;pub use types::DEFAULT_TEST_HANDLER;pub use types::DEFAULT_TEST_SALT;pub use types::DurationOfPart;pub use types::GpV2OrderStruct;pub use types::IsNotValid;pub use types::IsValid;pub use types::IsValidResult;pub use types::MAX_FREQUENCY;pub use types::PollResult;pub use types::ProofLocation;pub use types::ProofStruct;pub use types::TWAP_HANDLER_ADDRESS;pub use types::TestConditionalOrderParams;pub use types::TwapData;pub use types::TwapStartTime;pub use types::TwapStruct;pub use types::create_test_conditional_order;pub use utils::balance_to_string;pub use utils::create_set_domain_verifier_tx;pub use utils::default_token_formatter;pub use utils::from_struct_to_order;pub use utils::get_block_info;pub use utils::get_domain_verifier;pub use utils::get_domain_verifier_calldata;pub use utils::get_is_valid_result;pub use utils::is_composable_cow;pub use utils::is_extensible_fallback_handler;pub use utils::is_valid_abi;pub use utils::kind_to_string;pub use utils::transform_data_to_struct;pub use utils::transform_struct_to_data;
Modules§
- calldata
- ABI-encoded calldata builders for the
ComposableCowcontract. - factory
ConditionalOrderFactory— instantiate conditional orders from on-chain params.- gat
GoodAfterTime(GAT) conditional order handler.- multiplexer
Multiplexer— manages a set of conditional orders under a single Merkle root.- stop_
loss StopLossconditional order handler.- twap
TWAP(Time-Weighted Average Price) conditional order and composable-order utilities.- types
- Types for
CoWProtocol composable (conditional) orders. - utils
- Utility helpers for composable (conditional) orders.