Start on insurance fund implementation#75
Conversation
Co-authored-by: Bastian Müller <bastian@turbolent.com>
|
Tracked by Issue: #84 |
| debitIncome = totalDebitBalance * debitRate | ||
| insuranceAmount = totalCreditBalance * insuranceRate | ||
| creditRate = (debitIncome - insuranceAmount) / totalCreditBalance |
There was a problem hiding this comment.
More clearly:
creditRate = debitRate * (totalDebitBalance / totalCreditBalance) - insuranceRate
Co-authored-by: Bastian Müller <bastian@turbolent.com>
…_exists; transaction: collect_insurance
Added mock: set_insurance_swapper_mock.cdc
…saction. Moved flowTokenIdentifier to test_helpers.
debitIncome = self.totalDebitBalance * (self.curentDebitRate ^ time_elapsed - 1.0) insuranceAmount = debitIncome * insuranceRate
| import "MockDexSwapper" | ||
| import "DeFiActions" | ||
|
|
||
| /// TEST-ONLY: Test transaction to configure a MockDexSwapper as the insurance swapper for a token. |
There was a problem hiding this comment.
This transaction hard-codes a MOET-typed source for swapped funds but allows specifying a different output type for the created Swapper. I think we should:
- change the file name and documentation to reflect that this will always swap to MOET
- remove the
swapperOutTypeIdentifierparameter and hard-code it to MOET
There was a problem hiding this comment.
I intentionally kept swapperOutTypeIdentifier configurable in this test transaction so we can explicitly test the validation logic in setInsuranceSwapper.
In particular, this allows us to verify that the function correctly rejects invalid swappers and triggers the expected error:
Swapper output type must be MOET. If the transaction hard-codes the output type to MOET, these failure paths would no longer be testable via transactions.
I also updated the documentation (942a305) for cadence/tests/transactions/flow-credit-market/pool-governance/set_insurance_swapper_mock.cdc to clarify that this flexibility is intended for test-only use.
For production usage, there is a dedicated transaction at:
cadence/transactions/flow-credit-market/pool-governance/set_insurance_swapper.cdc
There was a problem hiding this comment.
Makes sense -- thanks for explaining + adding that to the docs
Co-authored-by: Jordan Schalm <jordan.schalm@gmail.com>
jordanschalm
left a comment
There was a problem hiding this comment.
Reviewed the diff since my last review. Looks good besides the coverage file.
|
@Gornutz, @liobrasil, since you’ve already reviewed this PR, would you mind taking a final look so we could merge it? Thanks! |
Closes: #84
Description
Implementation of insurance fund
For contributor use:
masterbranchFiles changedin the Github PR explorer