Interest Rate Boundary Conditions Testing#262
Conversation
…/FlowCreditMarket into UlianaAndrukhiv/180-interest-rate-testing
# Conflicts: # cadence/tests/insurance_collection_test.cdc # cadence/tests/interest_accrual_integration_test.cdc
…m:onflow/FlowCreditMarket into UlianaAndrukhiv/180-interest-rate-testing
|
|
||
| createPosition(admin: MAINNET_PROTOCOL_ACCOUNT, signer: MAINNET_FLOW_HOLDER, amount: FLOWAmount, vaultStoragePath: FLOW_VAULT_STORAGE_PATH, pushToDrawDownSink: false) | ||
| var openEvents = Test.eventsOfType(Type<FlowALPEvents.Opened>()) | ||
| let lpDepositPid = (openEvents[openEvents.length - 1] as! FlowALPEvents.Opened).pid |
There was a problem hiding this comment.
use getLastPositionId() instead from test_helper.cdc
and same in tests below
|
|
||
| // attempt to borrow FLOW (no reserves) | ||
| let openEvents = Test.eventsOfType(Type<FlowALPEvents.Opened>()) | ||
| let pid = (openEvents[openEvents.length - 1] as! FlowALPEvents.Opened).pid |
There was a problem hiding this comment.
| createPosition(admin: MAINNET_PROTOCOL_ACCOUNT, signer: flowLp, amount: FLOWAmount, vaultStoragePath: FLOW_VAULT_STORAGE_PATH, pushToDrawDownSink: false) | ||
|
|
||
| let openEvents = Test.eventsOfType(Type<FlowALPEvents.Opened>()) | ||
| let lpPid = (openEvents[openEvents.length - 1] as! FlowALPEvents.Opened).pid |
There was a problem hiding this comment.
|
|
||
| createPosition(admin: MAINNET_PROTOCOL_ACCOUNT, signer: borrower, amount: 10_000.0, vaultStoragePath: MAINNET_MOET_STORAGE_PATH, pushToDrawDownSink: false) | ||
|
|
||
| let borrowerPid: UInt64 = 1 |
There was a problem hiding this comment.
| // | ||
| // debitRate = baseRate + (slope1 * utilization / optimalUtilization) | ||
| // FLOW: debitRate = 0 + 0.04 * (0.2 / 0.45) = 0.01777777777 (1.77% APY) | ||
| let expectedFLOWDebtRate = 0.01777777 |
There was a problem hiding this comment.
declared, never used in any assertion
| // creditRate = debitRate * (1.0 - protocolFeeRate) | ||
| // protocolFeeRate = insuranceRate + stabilityFeeRate | ||
| // | ||
| // protocolFeeRate = 0.001 * 0.05 = 0.051 |
There was a problem hiding this comment.
| // protocolFeeRate = 0.001 * 0.05 = 0.051 | |
| // protocolFeeRate = 0.001 + 0.05 = 0.051 |
| } | ||
|
|
||
| // ============================================================================= | ||
| /// Verifies protocol behavior when a lending pool has liquidity but no borrows. |
There was a problem hiding this comment.
same description as at test_zero_credit_balance
| /// Verifies protocol behavior when a lending pool has liquidity but no borrows. | |
| /// Verifies that LP credit does not accrue when there are no borrows, | |
| /// then begins accruing once a borrower deposits and borrows. |
| // debitIncome = 0.0 * 0.0 = 0.0 | ||
| // protocolFeeAmount = 0.0 | ||
| // totalCreditBalance = 0.0 -> creditRate = 0.0 |
There was a problem hiding this comment.
But at this point totalCreditBalance = 5000 and totalDebitBalance = 100. This appears to be stale copy-paste from earlier in the test. The computed values in the comment don't match the state at that point.
mts1715
left a comment
There was a problem hiding this comment.
few smal fixes should be done
Closes: #180
Context
fork_interest_rate_test.cdc, a newmainnet-forktest suite coveringKinkCurvebehavior across different scenarios.swapperInTypeIdentifier / swapperOutTypeIdentifierparameters tosetInsuranceSwapperhelper.receiverVaultStoragePathparameter towithdrawFromPositionhelper, making it return the transaction result instead of asserting internally.withdraw_from_position transaction, dropping the hardcodedFlowTokenpath.MAINNET_FLOW_HOLDER_ADDRESSconstant