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

feat: time handling for interest #17

Merged
merged 4 commits into from
Aug 21, 2024
Merged

Conversation

Teolhyn
Copy link
Contributor

@Teolhyn Teolhyn commented Aug 21, 2024

  • Time (in ledger sequences) is now stored in loan manager storage
  • add_interest calculates time between the present and last update to get correct amount of interest
  • Added some unit tests to loan_pool

@Teolhyn Teolhyn requested a review from kovipu August 21, 2024 05:04
.storage()
.persistent()
.get(&key)
.unwrap_or(current_ledger.into_val(&e)); // If there is no previous ledger, use current.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Googlasin mitä eroa on unwrap_or ja unwrap_or_else välillä koska en tiennyt. Ei tässä kohtaa väliä kumpaa käyttää, mutta jos toi else-haara olisi kallista laskea, niin unwrap_or_else olisi helppo tapa optimoida.

https://stackoverflow.com/a/56726618

@@ -109,7 +112,7 @@ impl LoanPoolTrait for LoanPoolContract {
*/
let address = String::from_str(
&e,
"CCR7ARWZN4WODMEWVTRCMPPJJQKE2MBKUPJBSYWCDEOT3OLBPAPEGLPH",
"CB6MHNR6FJMQHJZDWOKAU4KESR4OARLPZ4RMN57R55P2QUBH4QJENHLY",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tää oli kaiketi väliaikanen ratkasu?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Joo tämä juuri pitäisi korjata 'Store loan manager’s ID for liquidity pool' tiketissä.

let withdraw_args = vec![&e, user.to_val(), amount_2];
let _withdraw_result: (i128, i128) =
e.invoke_contract(&contract_id, &Symbol::new(&e, "withdraw"), withdraw_args);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Solidit testit 👏

@Teolhyn Teolhyn merged commit 32da3b4 into main Aug 21, 2024
5 checks passed
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

Successfully merging this pull request may close these issues.

2 participants