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
88 changes: 88 additions & 0 deletions aspens-admin/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,34 @@ enum Commands {
chain_network: String,
},

/// Set an instance's operator fee (recipient + bps). The arborter submits the
/// on-chain setOperatorFee as the instance's operator_admin.
SetOperatorFee {
/// Chain network whose instance to update (e.g., "base-sepolia")
#[arg(long)]
chain_network: String,

/// Operator-fee recipient address (0x-hex EVM / base58 Solana)
#[arg(long)]
recipient: String,

/// Operator fee in basis points
#[arg(long)]
bps: u32,
},

/// Rotate an instance's operator_admin key. After rotation the new admin
/// (not the arborter) gates operator-fee changes.
RotateOperatorAdmin {
/// Chain network whose instance to update
#[arg(long)]
chain_network: String,

/// The new operator_admin address (0x-hex EVM / base58 Solana)
#[arg(long)]
new_admin: String,
},

/// Delete a trade contract from a chain
DeleteTradeContract {
/// Chain network to remove contract from (e.g., "base-sepolia")
Expand Down Expand Up @@ -836,6 +864,66 @@ async fn run() -> Result<()> {
}
}

Commands::SetOperatorFee {
chain_network,
recipient,
bps,
} => {
let jwt = get_jwt()?;
info!(
"Setting operator fee {} bps -> {} on chain {}",
bps, recipient, chain_network
);
let result = executor
.execute(admin::set_operator_fee(
stack_url.clone(),
jwt,
chain_network.clone(),
recipient.clone(),
bps,
))
.map_err(|e| {
eyre::eyre!(format_error(
&e,
&format!("set operator fee on chain {}", chain_network)
))
})?;
if result.tx_signature.is_empty() {
println!("Operator fee set (no on-chain tx returned)");
} else {
println!("Operator fee set: tx {}", result.tx_signature);
}
}

Commands::RotateOperatorAdmin {
chain_network,
new_admin,
} => {
let jwt = get_jwt()?;
info!(
"Rotating operator admin -> {} on chain {}",
new_admin, chain_network
);
let result = executor
.execute(admin::set_operator_admin(
stack_url.clone(),
jwt,
chain_network.clone(),
new_admin.clone(),
))
.map_err(|e| {
eyre::eyre!(format_error(
&e,
&format!("rotate operator admin on chain {}", chain_network)
))
})?;
if result.tx_signature.is_empty() {
println!("Operator admin rotated (no on-chain tx returned)");
} else {
println!("Operator admin rotated: tx {}", result.tx_signature);
}
}

Commands::DeleteTradeContract { chain_network } => {
let jwt = get_jwt()?;
info!("Deleting trade contract from chain {}", chain_network);
Expand Down
98 changes: 98 additions & 0 deletions aspens/proto/generated/xyz.aspens.arborter_config.v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,41 @@ pub struct SetTradeContractResponse {
#[prost(message, optional, tag = "1")]
pub trade_contract: ::core::option::Option<TradeContract>,
}
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct SetOperatorFeeRequest {
/// The chain network whose instance to update. e.g. base-sepolia
#[prost(string, tag = "1")]
pub chain_network: ::prost::alloc::string::String,
/// Operator-fee recipient address (0x-hex for EVM, base58 for Solana).
#[prost(string, tag = "2")]
pub recipient: ::prost::alloc::string::String,
/// Operator fee in basis points. Combined with maintenance bps the contract
/// rejects a total above the bps denominator (10000).
#[prost(uint32, tag = "3")]
pub bps: u32,
}
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct SetOperatorFeeResponse {
/// On-chain tx hash / signature for the setOperatorFee call (0x-hex EVM,
/// base58 Solana).
#[prost(string, tag = "1")]
pub tx_signature: ::prost::alloc::string::String,
}
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct SetOperatorAdminRequest {
/// The chain network whose instance to update.
#[prost(string, tag = "1")]
pub chain_network: ::prost::alloc::string::String,
/// The new operator_admin key (0x-hex for EVM, base58 for Solana).
#[prost(string, tag = "2")]
pub new_admin: ::prost::alloc::string::String,
}
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct SetOperatorAdminResponse {
/// On-chain tx hash / signature for the setOperatorAdmin call.
#[prost(string, tag = "1")]
pub tx_signature: ::prost::alloc::string::String,
}
/// Request message for the service
///
/// Add optional filters in the future (e.g., chain or market name)
Expand Down Expand Up @@ -723,6 +758,69 @@ pub mod config_service_client {
);
self.inner.unary(req, path, codec).await
}
/// rpc service to set an instance's operator fee (recipient + bps). The
/// arborter submits the on-chain setOperatorFee/set_operator_fee as the
/// instance's operator_admin (the arborter signer, while unrotated).
pub async fn set_operator_fee(
&mut self,
request: impl tonic::IntoRequest<super::SetOperatorFeeRequest>,
) -> std::result::Result<
tonic::Response<super::SetOperatorFeeResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic_prost::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/xyz.aspens.arborter_config.v1.ConfigService/SetOperatorFee",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new(
"xyz.aspens.arborter_config.v1.ConfigService",
"SetOperatorFee",
),
);
self.inner.unary(req, path, codec).await
}
/// rpc service to rotate an instance's operator_admin key. After rotation the
/// new admin (not the arborter) gates operator-fee changes.
pub async fn set_operator_admin(
&mut self,
request: impl tonic::IntoRequest<super::SetOperatorAdminRequest>,
) -> std::result::Result<
tonic::Response<super::SetOperatorAdminResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic_prost::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/xyz.aspens.arborter_config.v1.ConfigService/SetOperatorAdmin",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new(
"xyz.aspens.arborter_config.v1.ConfigService",
"SetOperatorAdmin",
),
);
self.inner.unary(req, path, codec).await
}
/// rpc service to get the configuration
pub async fn get_config(
&mut self,
Expand Down
70 changes: 69 additions & 1 deletion aspens/src/commands/admin/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ use config_pb::{
DeleteTokenRequest, DeleteTokenResponse, DeleteTradeContractRequest,
DeleteTradeContractResponse, DeployContractRequest, DeployContractResponse, Empty,
GetDeployCalldataRequest, GetDeployCalldataResponse, SetChainRequest, SetChainResponse,
SetMarketRequest, SetMarketResponse, SetTokenRequest, SetTokenResponse,
SetMarketRequest, SetMarketResponse, SetOperatorAdminRequest, SetOperatorAdminResponse,
SetOperatorFeeRequest, SetOperatorFeeResponse, SetTokenRequest, SetTokenResponse,
SetTradeContractRequest, SetTradeContractResponse, UpdateAdminRequest, UpdateAdminResponse,
VersionInfo,
};
Expand Down Expand Up @@ -294,6 +295,73 @@ pub async fn set_trade_contract(
Ok(response.into_inner())
}

/// Set an instance's operator fee — recipient + bps (requires auth, fees Phase 4).
///
/// The arborter submits the on-chain `setOperatorFee` as the instance's
/// `operator_admin` (the arborter signer, while unrotated). Returns the on-chain
/// tx hash/signature.
///
/// # Arguments
/// * `url` - The Aspens stack gRPC URL
/// * `jwt` - Valid JWT token
/// * `chain_network` - Chain whose instance to update
/// * `recipient` - Operator-fee recipient address (0x-hex EVM / base58 Solana)
/// * `bps` - Operator fee in basis points
pub async fn set_operator_fee(
url: String,
jwt: String,
chain_network: String,
recipient: String,
bps: u32,
) -> Result<SetOperatorFeeResponse> {
let channel = create_channel(&url).await?;
let mut client = ConfigServiceClient::new(channel);

let request = authenticated_request(
&jwt,
SetOperatorFeeRequest {
chain_network,
recipient,
bps,
},
);
let response = client.set_operator_fee(request).await?;

Ok(response.into_inner())
}

/// Rotate an instance's `operator_admin` key (requires auth, fees Phase 4).
///
/// Signed by the current admin (the arborter, while unrotated). After this the
/// new admin — not the arborter — gates operator-fee changes. Returns the
/// on-chain tx hash/signature.
///
/// # Arguments
/// * `url` - The Aspens stack gRPC URL
/// * `jwt` - Valid JWT token
/// * `chain_network` - Chain whose instance to update
/// * `new_admin` - The new operator_admin address (0x-hex EVM / base58 Solana)
pub async fn set_operator_admin(
url: String,
jwt: String,
chain_network: String,
new_admin: String,
) -> Result<SetOperatorAdminResponse> {
let channel = create_channel(&url).await?;
let mut client = ConfigServiceClient::new(channel);

let request = authenticated_request(
&jwt,
SetOperatorAdminRequest {
chain_network,
new_admin,
},
);
let response = client.set_operator_admin(request).await?;

Ok(response.into_inner())
}

/// Delete a trade contract from a chain (requires auth)
///
/// # Arguments
Expand Down
Loading