From fdd41c9c375004445645edb8143215a40ef8ada4 Mon Sep 17 00:00:00 2001 From: Lucas Soriano del Pino Date: Wed, 6 Oct 2021 12:42:29 +1100 Subject: [PATCH 1/2] Use new generate_payouts API --- daemon/src/payout_curve.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/daemon/src/payout_curve.rs b/daemon/src/payout_curve.rs index bb370f1..4361989 100644 --- a/daemon/src/payout_curve.rs +++ b/daemon/src/payout_curve.rs @@ -2,7 +2,7 @@ use crate::model::{Leverage, Usd}; use anyhow::Result; use bdk::bitcoin; use cfd_protocol::interval::MAX_PRICE_DEC; -use cfd_protocol::Payout; +use cfd_protocol::{generate_payouts, Payout}; pub fn calculate( price: Usd, @@ -12,13 +12,13 @@ pub fn calculate( ) -> Result> { let dollars = price.try_into_u64()?; let payouts = vec![ - Payout::new( + generate_payouts( 0..=(dollars - 10), maker_payin + taker_payin, bitcoin::Amount::ZERO, )?, - Payout::new((dollars - 10)..=(dollars + 10), maker_payin, taker_payin)?, - Payout::new( + generate_payouts((dollars - 10)..=(dollars + 10), maker_payin, taker_payin)?, + generate_payouts( (dollars + 10)..=MAX_PRICE_DEC, bitcoin::Amount::ZERO, maker_payin + taker_payin, From 62c8ffb65b796a7a41e76c91b947e20c0fe24530 Mon Sep 17 00:00:00 2001 From: Lucas Soriano del Pino Date: Wed, 6 Oct 2021 12:43:11 +1100 Subject: [PATCH 2/2] Avoid overlapping CETs in dummy payouts --- daemon/src/payout_curve.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/daemon/src/payout_curve.rs b/daemon/src/payout_curve.rs index 4361989..ea86576 100644 --- a/daemon/src/payout_curve.rs +++ b/daemon/src/payout_curve.rs @@ -17,9 +17,9 @@ pub fn calculate( maker_payin + taker_payin, bitcoin::Amount::ZERO, )?, - generate_payouts((dollars - 10)..=(dollars + 10), maker_payin, taker_payin)?, + generate_payouts((dollars - 9)..=(dollars + 10), maker_payin, taker_payin)?, generate_payouts( - (dollars + 10)..=MAX_PRICE_DEC, + (dollars + 11)..=MAX_PRICE_DEC, bitcoin::Amount::ZERO, maker_payin + taker_payin, )?,