Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getter for repayment amount #78

Open
bonomat opened this issue Aug 14, 2021 · 3 comments
Open

Getter for repayment amount #78

bonomat opened this issue Aug 14, 2021 · 3 comments

Comments

@bonomat
Copy link
Member

bonomat commented Aug 14, 2021

When displaying the loan details in the UI we want to show how much the user has to pay when repaying the loan.
At the moment we can only access the collateral amount but not the repayment amount.

I guess the function repayment_amount on CollateralContrtact just needs to be public for that.

baru/src/loan.rs

Lines 418 to 427 in 87b7677

fn repayment_amount<C>(&self, secp: &Secp256k1<C>) -> Result<Amount>
where
C: Verification,
{
let TxOutSecrets { value, .. } = self
.repayment_principal_output
.unblind(secp, self.repayment_principal_output_blinder)?;
Ok(Amount::from_sat(value))
}

This functionality is needed in :

comit-network/waves#242

@bonomat
Copy link
Member Author

bonomat commented Aug 14, 2021

I guess a better solution would be to have a clear getter for this value. That way we don't have to provide secp.

@DeliciousHair
Copy link
Contributor

Two things:

  • Is that amount even correct? That is, is the interest included in repayment_principal_output, and if it is maybe it should be re-named to make this clear.
  • Would this calculation be better handled on the waves side of things alone?

@bonomat
Copy link
Member Author

bonomat commented Aug 14, 2021

Is that amount even correct? That is, is the interest included in repayment_principal_output, and if it is maybe it should be re-named to make this clear.

The number seems to be correct, i.e. it includes the interest amount when paying back the loan.

Would this calculation be better handled on the waves side of things alone?

Imho the calculation is already happening on our side but once sent to Bobtimus it disappears.
We could just add an additional field to our DTOs but it wouldn't give us any guarantees that the values in the repayment transaction are the same.
Have a look here where we construct LoanDetails which is used to show data to the user: https://github.com/comit-network/waves/blob/06701f852298e28bbba69d5d83ed44e36301775a/extension/wallet/src/wallet/extract_loan.rs#L11

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants