Skip to content
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
34 changes: 33 additions & 1 deletion src/external_match_client/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ use reqwest::{
use crate::{
ARBITRUM_ONE_RELAYER_BASE_URL, ARBITRUM_SEPOLIA_RELAYER_BASE_URL, AssembleQuoteOptionsV2,
BASE_MAINNET_RELAYER_BASE_URL, BASE_SEPOLIA_RELAYER_BASE_URL,
ETHEREUM_SEPOLIA_RELAYER_BASE_URL, ExternalMatchOptions, RequestQuoteOptions,
ETHEREUM_MAINNET_RELAYER_BASE_URL, ETHEREUM_SEPOLIA_RELAYER_BASE_URL, ExternalMatchOptions,
RequestQuoteOptions,
api_types::{
ASSEMBLE_MATCH_BUNDLE_ROUTE, AssemblyType, ExternalMatchResponseV2,
GET_MARKET_DEPTH_BY_MINT_ROUTE, GET_MARKETS_DEPTH_ROUTE, GET_MARKETS_ROUTE,
Expand Down Expand Up @@ -46,6 +47,8 @@ const BASE_SEPOLIA_AUTH_BASE_URL: &str = "https://base-sepolia.v2.auth-server.re
const BASE_MAINNET_AUTH_BASE_URL: &str = "https://base-mainnet.v2.auth-server.renegade.fi";
/// The Ethereum Sepolia auth server base URL
const ETHEREUM_SEPOLIA_AUTH_BASE_URL: &str = "https://ethereum-sepolia.v2.auth-server.renegade.fi";
/// The Ethereum Mainnet auth server base URL
const ETHEREUM_MAINNET_AUTH_BASE_URL: &str = "https://ethereum-mainnet.v2.auth-server.renegade.fi";

// ----------
// | Client |
Expand Down Expand Up @@ -199,6 +202,35 @@ impl ExternalMatchClient {
)
}

/// Create a new client for the Ethereum Mainnet network
pub fn new_ethereum_mainnet_client(
api_key: &str,
api_secret: &str,
) -> Result<Self, ExternalMatchClientError> {
Self::new(
api_key,
api_secret,
ETHEREUM_MAINNET_AUTH_BASE_URL,
ETHEREUM_MAINNET_RELAYER_BASE_URL,
)
}

/// Create a new client for the Ethereum Mainnet network with custom HTTP
/// client
pub fn new_ethereum_mainnet_with_client(
api_key: &str,
api_secret: &str,
client: reqwest::Client,
) -> Result<Self, ExternalMatchClientError> {
Self::new_with_client(
api_key,
api_secret,
ETHEREUM_MAINNET_AUTH_BASE_URL,
ETHEREUM_MAINNET_RELAYER_BASE_URL,
client,
)
}

// ------------------
// | Markets Routes |
// ------------------
Expand Down
5 changes: 5 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ pub(crate) const BASE_MAINNET_RELAYER_BASE_URL: &str =
/// The Ethereum Sepolia relayer base URL
pub(crate) const ETHEREUM_SEPOLIA_RELAYER_BASE_URL: &str =
"https://ethereum-sepolia.v2.relayer.renegade.fi";
/// The Ethereum Mainnet relayer base URL
pub(crate) const ETHEREUM_MAINNET_RELAYER_BASE_URL: &str =
"https://ethereum-mainnet.v2.relayer.renegade.fi";

// --- Chain IDs --- //

Expand All @@ -59,3 +62,5 @@ pub const BASE_MAINNET_CHAIN_ID: u64 = 8453;
pub const BASE_SEPOLIA_CHAIN_ID: u64 = 84532;
/// The Ethereum Sepolia chain ID
pub const ETHEREUM_SEPOLIA_CHAIN_ID: u64 = 11155111;
/// The Ethereum Mainnet chain ID
pub const ETHEREUM_MAINNET_CHAIN_ID: u64 = 1;
13 changes: 13 additions & 0 deletions src/renegade_wallet_client/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,19 @@ impl RenegadeClient {
Self::new(RenegadeClientConfig::new_base_mainnet_admin(key, admin_hmac_key))
}

/// Create a new wallet on Ethereum Mainnet
pub fn new_ethereum_mainnet(key: &PrivateKeySigner) -> Result<Self, RenegadeClientError> {
Self::new(RenegadeClientConfig::new_ethereum_mainnet(key))
}

/// Create a new admin wallet on Ethereum Mainnet
pub fn new_ethereum_mainnet_admin(
key: &PrivateKeySigner,
admin_hmac_key: HmacKey,
) -> Result<Self, RenegadeClientError> {
Self::new(RenegadeClientConfig::new_ethereum_mainnet_admin(key, admin_hmac_key))
}

/// Whether the client is on a chain in which Renegade is deployed as a
/// solidity contract
pub fn is_solidity_chain(&self) -> bool {
Expand Down
47 changes: 46 additions & 1 deletion src/renegade_wallet_client/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ use renegade_types_core::HmacKey;
use crate::{
ARBITRUM_ONE_CHAIN_ID, ARBITRUM_ONE_RELAYER_BASE_URL, ARBITRUM_SEPOLIA_CHAIN_ID,
ARBITRUM_SEPOLIA_RELAYER_BASE_URL, BASE_MAINNET_CHAIN_ID, BASE_MAINNET_RELAYER_BASE_URL,
BASE_SEPOLIA_CHAIN_ID, BASE_SEPOLIA_RELAYER_BASE_URL, ETHEREUM_SEPOLIA_CHAIN_ID,
BASE_SEPOLIA_CHAIN_ID, BASE_SEPOLIA_RELAYER_BASE_URL, ETHEREUM_MAINNET_CHAIN_ID,
ETHEREUM_MAINNET_RELAYER_BASE_URL, ETHEREUM_SEPOLIA_CHAIN_ID,
ETHEREUM_SEPOLIA_RELAYER_BASE_URL,
};

Expand Down Expand Up @@ -43,6 +44,10 @@ pub(crate) const BASE_SEPOLIA_DARKPOOL_ADDRESS: Address =
/// The darkpool address on Ethereum Sepolia
pub(crate) const ETHEREUM_SEPOLIA_DARKPOOL_ADDRESS: Address =
address!("0x45537c28F245645CC1E7F7258FCC18A189CE16e3");
/// The darkpool address on Ethereum Mainnet
/// TODO: Set after deployment
pub(crate) const ETHEREUM_MAINNET_DARKPOOL_ADDRESS: Address =
address!("0x0000000000000000000000000000000000000000");

// --- Permit2 Addresses --- //

Expand All @@ -61,6 +66,9 @@ pub(crate) const BASE_SEPOLIA_PERMIT2_ADDRESS: Address =
/// The permit2 address on Ethereum Sepolia
pub(crate) const ETHEREUM_SEPOLIA_PERMIT2_ADDRESS: Address =
address!("0x000000000022D473030F116dDEE9F6B43aC78BA3");
/// The permit2 address on Ethereum Mainnet
pub(crate) const ETHEREUM_MAINNET_PERMIT2_ADDRESS: Address =
address!("0x000000000022D473030F116dDEE9F6B43aC78BA3");

// --- Executor Addresses --- //

Expand All @@ -79,6 +87,10 @@ pub(crate) const BASE_SEPOLIA_EXECUTOR_ADDRESS: Address =
/// The executor address on Ethereum Sepolia
pub(crate) const ETHEREUM_SEPOLIA_EXECUTOR_ADDRESS: Address =
address!("0x92467D2FF278383187f0aB04F8511EF45c31b723");
/// The executor address on Ethereum Mainnet
/// TODO: Set after deployment
pub(crate) const ETHEREUM_MAINNET_EXECUTOR_ADDRESS: Address =
address!("0x0000000000000000000000000000000000000000");

// --- Relayer Fee Recipient Addresses --- //

Expand All @@ -97,6 +109,9 @@ pub(crate) const BASE_SEPOLIA_RELAYER_FEE_RECIPIENT: Address =
/// The relayer fee recipient address on Ethereum Sepolia
pub(crate) const ETHEREUM_SEPOLIA_RELAYER_FEE_RECIPIENT: Address =
address!("0x0000000000000000000000000000000000000000");
/// The relayer fee recipient address on Ethereum Mainnet
pub(crate) const ETHEREUM_MAINNET_RELAYER_FEE_RECIPIENT: Address =
address!("0x0000000000000000000000000000000000000000");

/// The client config
#[derive(Debug, Clone)]
Expand Down Expand Up @@ -271,4 +286,34 @@ impl RenegadeClientConfig {
admin_hmac_key: Some(admin_hmac_key),
}
}

/// Create a new client config for Ethereum Mainnet
pub fn new_ethereum_mainnet(key: &PrivateKeySigner) -> Self {
Self {
relayer_base_url: ETHEREUM_MAINNET_RELAYER_BASE_URL.to_string(),
historical_state_base_url: MAINNET_HISTORICAL_STATE_BASE_URL.to_string(),
chain_id: ETHEREUM_MAINNET_CHAIN_ID,
darkpool_address: ETHEREUM_MAINNET_DARKPOOL_ADDRESS,
permit2_address: ETHEREUM_MAINNET_PERMIT2_ADDRESS,
executor_address: ETHEREUM_MAINNET_EXECUTOR_ADDRESS,
relayer_fee_recipient: ETHEREUM_MAINNET_RELAYER_FEE_RECIPIENT,
key: key.clone(),
admin_hmac_key: None,
}
}

/// Create a new admin client config for Ethereum Mainnet
pub fn new_ethereum_mainnet_admin(key: &PrivateKeySigner, admin_hmac_key: HmacKey) -> Self {
Self {
relayer_base_url: ETHEREUM_MAINNET_RELAYER_BASE_URL.to_string(),
historical_state_base_url: MAINNET_HISTORICAL_STATE_BASE_URL.to_string(),
chain_id: ETHEREUM_MAINNET_CHAIN_ID,
darkpool_address: ETHEREUM_MAINNET_DARKPOOL_ADDRESS,
permit2_address: ETHEREUM_MAINNET_PERMIT2_ADDRESS,
executor_address: ETHEREUM_MAINNET_EXECUTOR_ADDRESS,
relayer_fee_recipient: ETHEREUM_MAINNET_RELAYER_FEE_RECIPIENT,
key: key.clone(),
admin_hmac_key: Some(admin_hmac_key),
}
}
}
11 changes: 3 additions & 8 deletions src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,8 @@
use std::time::{SystemTime, UNIX_EPOCH};

use crate::{
ARBITRUM_ONE_CHAIN_ID,
ARBITRUM_SEPOLIA_CHAIN_ID,
BASE_MAINNET_CHAIN_ID,
BASE_SEPOLIA_CHAIN_ID,
// ETHEREUM_MAINNET_CHAIN_ID,
ETHEREUM_SEPOLIA_CHAIN_ID,
ARBITRUM_ONE_CHAIN_ID, ARBITRUM_SEPOLIA_CHAIN_ID, BASE_MAINNET_CHAIN_ID, BASE_SEPOLIA_CHAIN_ID,
ETHEREUM_MAINNET_CHAIN_ID, ETHEREUM_SEPOLIA_CHAIN_ID,
};

// -----------
Expand All @@ -24,8 +20,7 @@ pub fn get_env_agnostic_chain(chain_id: u64) -> String {
match chain_id {
ARBITRUM_ONE_CHAIN_ID | ARBITRUM_SEPOLIA_CHAIN_ID => "arbitrum".to_string(),
BASE_MAINNET_CHAIN_ID | BASE_SEPOLIA_CHAIN_ID => "base".to_string(),
// ETHEREUM_MAINNET_CHAIN_ID |
ETHEREUM_SEPOLIA_CHAIN_ID => "ethereum".to_string(),
ETHEREUM_MAINNET_CHAIN_ID | ETHEREUM_SEPOLIA_CHAIN_ID => "ethereum".to_string(),
_ => panic!("Unsupported chain ID: {chain_id}"),
}
}