From fd18d56272a711f20a14d614d3cce217ecafa7c4 Mon Sep 17 00:00:00 2001 From: KOSASIH Date: Sat, 7 Dec 2024 17:08:28 +0700 Subject: [PATCH] Create collateralization.rs --- src/stablecoin/src/collateralization.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 src/stablecoin/src/collateralization.rs diff --git a/src/stablecoin/src/collateralization.rs b/src/stablecoin/src/collateralization.rs new file mode 100644 index 0000000..c21f8c0 --- /dev/null +++ b/src/stablecoin/src/collateralization.rs @@ -0,0 +1,22 @@ +// src/collateralization.rs +pub struct Collateralization { + collateral: f64, + stablecoin_value: f64, +} + +impl Collateralization { + pub fn new() -> Self { + Collateralization { + collateral: 0.0, + stablecoin_value: 314.159, + } + } + + pub fn add_collateral(&mut self, amount: f64) { + self.collateral += amount; + } + + pub fn check_collateralization(&self) -> bool { + self.collateral >= self.stablecoin_value + } +}