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
27 changes: 3 additions & 24 deletions options_market/src/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,26 +103,6 @@ pub fn refund_claimed(env: &Env, owner: Address, position_id: u64, amount: i128)
);
}

pub fn position_transferred(env: &Env, from: Address, to: Address, position_id: u64) {
env.events().publish(
(Symbol::new(env, "position_transferred"), from, to),
position_id,
);
}

pub fn position_split(
env: &Env,
owner: Address,
position_id: u64,
new_position_id: u64,
split_contracts: i128,
) {
env.events().publish(
(Symbol::new(env, "position_split"), owner),
(position_id, new_position_id, split_contracts),
);
}

pub fn fee_rate_updated(env: &Env, new_bps: i128) {
env.events()
.publish((Symbol::new(env, "fee_rate_updated"),), new_bps);
Expand All @@ -135,13 +115,12 @@ pub fn series_escrowed_to_vault(env: &Env, series_id: u64, amount: i128) {
);
}

pub fn payout_forfeited(env: &Env, owner: Address, position_id: u64, amount: i128) {
pub fn vault_updated(env: &Env, old_vault: Option<Address>, new_vault: Address) {
env.events().publish(
(Symbol::new(env, "payout_forfeited"), owner),
(position_id, amount),
(Symbol::new(env, "vault_updated"),),
(old_vault, new_vault),
);
}

pub fn option_auto_exercised(
env: &Env,
owner: Address,
Expand Down
57 changes: 55 additions & 2 deletions options_market/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,63 @@
#![no_std]

//! Zenith Protocol — Decentralized Options Market on Stellar Soroban
//!
//! Supports European-style put and call options on XLM, BTC, ETH, and SOL.
//! Premium is set by the admin (computed off-chain via Black-Scholes).
//! Writers lock collateral; buyers pay premium. Settlement at expiry via oracle.

use soroban_sdk::{
contract, contractimpl, panic_with_error, token, Address, BytesN, Env, Symbol, Vec,
};

mod error;
mod events;
mod math;
mod multisig_client;
mod price_oracle_client;
mod storage;
mod types;
mod vault_client;

use error::Error;
use math::{
calc_fee, calc_payout, DEFAULT_FEE_RATE_BPS, MAX_BATCH_SIZE, MAX_FEE_RATE_BPS,
MAX_SERIES_PER_UNDERLYING, MIN_COLLATERAL_RATIO, PRICE_PRECISION, RATE_PRECISION,
SETTLEMENT_WINDOW,
};
use storage::{
add_user_position, fee_rate_bps, next_position_id, require_active_series, require_not_paused,
}

#[cfg(test)]
mod test;

#[cfg(test)]
mod test_adversaries;
//! Zenith Protocol — Decentralized Options Market on Stellar Soroban
//!
//! Supports European-style put and call options on XLM, BTC, ETH, and SOL.
//! Premium is set by the admin (computed off-chain via Black-Scholes).
//! Writers lock collateral; buyers pay premium. Settlement at expiry via oracle.

use soroban_sdk::{
contract, contractimpl, panic_with_error, token, Address, BytesN, Env, Symbol, Vec,
};

mod error;
mod events;
mod math;
mod multisig_client;
mod price_oracle_client;
mod storage;
mod types;
mod vault_client;

use error::Error;
use math::{
calc_fee, calc_payout, DEFAULT_FEE_RATE_BPS, MAX_BATCH_SIZE, MAX_FEE_RATE_BPS,
MAX_SERIES_PER_UNDERLYING, MIN_COLLATERAL_RATIO, PRICE_PRECISION, RATE_PRECISION,
SETTLEMENT_WINDOW,
};
use storage::{
add_user_position, fee_rate_bps, next_position_id, require_active_series, require_not_paused,
};
use types::{DataKey, OptionPosition, OptionSeries, OptionType, PositionSide, SeriesState};
Loading