diff --git a/daemon/src/maker.rs b/daemon/src/maker.rs index 9fedf66..031d468 100644 --- a/daemon/src/maker.rs +++ b/daemon/src/maker.rs @@ -30,6 +30,7 @@ mod maker_inc_connections; mod model; mod monitor; mod oracle; +mod payout_curve; mod routes; mod routes_maker; mod seed; diff --git a/daemon/src/payout_curve.rs b/daemon/src/payout_curve.rs new file mode 100644 index 0000000..31959dd --- /dev/null +++ b/daemon/src/payout_curve.rs @@ -0,0 +1,13 @@ +use crate::model::{Leverage, Usd}; +use anyhow::Result; +use bdk::bitcoin; +use cfd_protocol::Payout; + +pub fn calculate( + _price: Usd, + _quantity: Usd, + _maker_payin: bitcoin::Amount, + (_taker_payin, _leverage): (bitcoin::Amount, Leverage), +) -> Result> { + Ok(vec![]) +} diff --git a/daemon/src/setup_contract.rs b/daemon/src/setup_contract.rs index 15e9d32..9f5d7d4 100644 --- a/daemon/src/setup_contract.rs +++ b/daemon/src/setup_contract.rs @@ -1,7 +1,7 @@ -use crate::model; use crate::model::cfd::{Cfd, Dlc}; use crate::wallet::Wallet; use crate::wire::{Msg0, Msg1, Msg2, SetupMsg}; +use crate::{model, payout_curve}; use anyhow::{Context, Result}; use bdk::bitcoin::secp256k1::{schnorrsig, Signature, SECP256K1}; use bdk::bitcoin::{Amount, PublicKey, Transaction}; @@ -61,6 +61,13 @@ pub async fn new( ) } + let payouts = payout_curve::calculate( + cfd.order.price, + cfd.quantity_usd, + params.maker().lock_amount, + (params.taker().lock_amount, cfd.order.leverage), + )?; + let own_cfd_txs = create_cfd_transactions( (params.maker().clone(), *params.maker_punish()), (params.taker().clone(), *params.taker_punish()), @@ -69,7 +76,7 @@ pub async fn new( model::cfd::Cfd::CET_TIMELOCK, cfd.refund_timelock_in_blocks(), ), - vec![], + payouts, sk, ) .context("Failed to create CFD transactions")?; diff --git a/daemon/src/taker.rs b/daemon/src/taker.rs index 2f0d39a..8659ee2 100644 --- a/daemon/src/taker.rs +++ b/daemon/src/taker.rs @@ -30,6 +30,7 @@ mod logger; mod model; mod monitor; mod oracle; +mod payout_curve; mod routes; mod routes_taker; mod seed;