Browse Source

Merge pull request #181 from comit-network/dummy-payouts

upload-correct-windows-binary
Thomas Eizinger 3 years ago
committed by GitHub
parent
commit
98f92067c7
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      cfd_protocol/src/interval.rs
  2. 25
      daemon/src/payout_curve.rs

2
cfd_protocol/src/interval.rs

@ -6,7 +6,7 @@ use std::ops::RangeInclusive;
mod digit_decomposition;
/// Maximum supported BTC price in whole USD.
const MAX_PRICE_DEC: u64 = (BASE as u64).pow(MAX_DIGITS as u32) - 1;
pub const MAX_PRICE_DEC: u64 = (BASE as u64).pow(MAX_DIGITS as u32) - 1;
/// Maximum number of binary digits for BTC price in whole USD.
const MAX_DIGITS: usize = 20;

25
daemon/src/payout_curve.rs

@ -1,13 +1,30 @@
use crate::model::{Leverage, Usd};
use anyhow::Result;
use bdk::bitcoin;
use cfd_protocol::interval::MAX_PRICE_DEC;
use cfd_protocol::Payout;
pub fn calculate(
_price: Usd,
price: Usd,
_quantity: Usd,
_maker_payin: bitcoin::Amount,
(_taker_payin, _leverage): (bitcoin::Amount, Leverage),
maker_payin: bitcoin::Amount,
(taker_payin, _leverage): (bitcoin::Amount, Leverage),
) -> Result<Vec<Payout>> {
Ok(vec![])
let dollars = price.try_into_u64()?;
let payouts = vec![
Payout::new(
0..=(dollars - 10),
maker_payin + taker_payin,
bitcoin::Amount::ZERO,
)?,
Payout::new((dollars - 10)..=(dollars + 10), maker_payin, taker_payin)?,
Payout::new(
(dollars + 10)..=MAX_PRICE_DEC,
bitcoin::Amount::ZERO,
maker_payin + taker_payin,
)?,
]
.concat();
Ok(payouts)
}

Loading…
Cancel
Save