-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chore: loan instantiation * chore: deref account_ids * chore: spawn loan job * chore: collateralize loan in job * chore: iteration on loan job * chore: iteration on business logic * chore: wip calculating interest using daily rate * chore: return DateTime<Utc> for next_interest_at * refactor: interest calculation * refactor: make terms types more expressive * refactor: interest calculation --------- Co-authored-by: bodymindarts <[email protected]>
- Loading branch information
1 parent
b16bc9e
commit 9b8ce11
Showing
16 changed files
with
864 additions
and
33 deletions.
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
core/.sqlx/query-21a5005cfcced3969c2312254d5131b15a248e3e5bc52fead48033cf688969dc.json
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,47 @@ | ||
use crate::primitives::{LedgerAccountId, Satoshis, UsdCents}; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
use super::cala::graphql::*; | ||
|
||
#[derive(Debug, Copy, Clone, Serialize, Deserialize)] | ||
pub struct LoanAccountIds { | ||
pub collateral_account_id: LedgerAccountId, | ||
pub outstanding_account_id: LedgerAccountId, | ||
pub interest_account_id: LedgerAccountId, | ||
} | ||
|
||
impl LoanAccountIds { | ||
#[allow(clippy::new_without_default)] | ||
pub fn new() -> Self { | ||
Self { | ||
collateral_account_id: LedgerAccountId::new(), | ||
outstanding_account_id: LedgerAccountId::new(), | ||
interest_account_id: LedgerAccountId::new(), | ||
} | ||
} | ||
} | ||
|
||
pub struct LoanBalance { | ||
pub collateral: Satoshis, | ||
pub outstanding: UsdCents, | ||
pub interest_incurred: UsdCents, | ||
} | ||
|
||
impl From<fixed_term_loan_balance::ResponseData> for LoanBalance { | ||
fn from(data: fixed_term_loan_balance::ResponseData) -> Self { | ||
LoanBalance { | ||
collateral: data | ||
.collateral | ||
.map(|b| Satoshis::from_btc(b.settled.normal_balance.units)) | ||
.unwrap_or_else(|| Satoshis::ZERO), | ||
outstanding: data | ||
.loan_outstanding | ||
.map(|b| UsdCents::from_usd(b.settled.normal_balance.units)) | ||
.unwrap_or_else(|| UsdCents::ZERO), | ||
interest_incurred: data | ||
.interest_income | ||
.map(|b| UsdCents::from_usd(b.settled.normal_balance.units)) | ||
.unwrap_or_else(|| UsdCents::ZERO), | ||
} | ||
} | ||
} |
Oops, something went wrong.