-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
UI plugged into loan offer from Bobtimus
The UI now properly display the values given by Bobtimus. When taking a loan the UI values are not sent yet though, it still uses hardcoded values from within the extension wallet.
- Loading branch information
Showing
11 changed files
with
291 additions
and
40 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
use crate::{LiquidUsdt, Rate}; | ||
use elements::bitcoin::Amount; | ||
use rust_decimal::Decimal; | ||
|
||
#[derive(Debug, Clone, serde::Serialize)] | ||
pub struct LoanOffer { | ||
// TODO: Potentially add an id if we want to track offers - for now we just check if an incoming request is acceptable | ||
pub rate: Rate, | ||
|
||
#[serde(with = "::elements::bitcoin::util::amount::serde::as_sat")] | ||
pub fee_sats_per_vbyte: Amount, | ||
|
||
#[serde(serialize_with = "LiquidUsdt::serialize_to_nominal")] | ||
pub min_principal: LiquidUsdt, | ||
#[serde(serialize_with = "LiquidUsdt::serialize_to_nominal")] | ||
pub max_principal: LiquidUsdt, | ||
|
||
/// The maximum LTV that defines at what point the lender liquidates | ||
/// | ||
/// LTV ... loan to value | ||
/// LTV = principal_amount/loan_value | ||
/// where: | ||
/// principal_amount: the amount lent out | ||
/// loan_value: the amount of collateral | ||
/// | ||
/// Simple Example (interest / fees not taken into account): | ||
/// | ||
/// The borrower takes out a loan at: | ||
/// max_ltv = 0.7 (70%) | ||
/// rate: 1 BTC = $100 | ||
/// principal_amount: $100 | ||
/// collateral: 2 BTC = $200 (over-collateralized by 200%) | ||
/// current LTV = 100 / 200 = 0.5 (50%) | ||
/// Since the actual LTV 0.5 < 0.7, so all is good. | ||
/// | ||
/// Let's say Bitcoin value falls to $70: | ||
/// LTV = 100 / 2 * 70 => 100 / 140 = 0.71 | ||
/// The actual LTV 0.71 > 0.7 so the lender liquidates. | ||
/// | ||
/// The max_ltv protects the lender from Bitcoin falling too much. | ||
pub max_ltv: Decimal, | ||
|
||
pub interest: Vec<Interest>, | ||
} | ||
|
||
#[derive(Debug, Clone, serde::Serialize)] | ||
pub struct Interest { | ||
/// Timelock in blocks | ||
pub timelock: u64, | ||
/// Interest rate in percent | ||
pub interest_rate: Decimal, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.