Skip to content

Interest Rate Boundary Conditions Testing#262

Open
UlyanaAndrukhiv wants to merge 20 commits intomainfrom
UlianaAndrukhiv/180-interest-rate-testing
Open

Interest Rate Boundary Conditions Testing#262
UlyanaAndrukhiv wants to merge 20 commits intomainfrom
UlianaAndrukhiv/180-interest-rate-testing

Conversation

@UlyanaAndrukhiv
Copy link
Copy Markdown
Contributor

Closes: #180

Context

  • Added fork_interest_rate_test.cdc, a new mainnet-fork test suite covering KinkCurve behavior across different scenarios.
  • Added explicit swapperInTypeIdentifier / swapperOutTypeIdentifier parameters to setInsuranceSwapper helper.
  • Added receiverVaultStoragePath parameter to withdrawFromPosition helper, making it return the transaction result instead of asserting internally.
  • Added support for any token type to withdraw_from_position transaction, dropping the hardcoded FlowToken path.
  • Updated MAINNET_FLOW_HOLDER_ADDRESS constant

@UlyanaAndrukhiv UlyanaAndrukhiv self-assigned this Mar 11, 2026
@UlyanaAndrukhiv UlyanaAndrukhiv marked this pull request as ready for review March 11, 2026 15:22
@UlyanaAndrukhiv UlyanaAndrukhiv requested a review from a team as a code owner March 11, 2026 15:22
@UlyanaAndrukhiv UlyanaAndrukhiv requested review from a team and jordanschalm March 16, 2026 10:06
…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
Copy link
Copy Markdown
Contributor

@mts1715 mts1715 Mar 30, 2026

Choose a reason for hiding this comment

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

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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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


createPosition(admin: MAINNET_PROTOCOL_ACCOUNT, signer: borrower, amount: 10_000.0, vaultStoragePath: MAINNET_MOET_STORAGE_PATH, pushToDrawDownSink: false)

let borrowerPid: UInt64 = 1
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

//
// debitRate = baseRate + (slope1 * utilization / optimalUtilization)
// FLOW: debitRate = 0 + 0.04 * (0.2 / 0.45) = 0.01777777777 (1.77% APY)
let expectedFLOWDebtRate = 0.01777777
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

declared, never used in any assertion

// creditRate = debitRate * (1.0 - protocolFeeRate)
// protocolFeeRate = insuranceRate + stabilityFeeRate
//
// protocolFeeRate = 0.001 * 0.05 = 0.051
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
// 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.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

same description as at test_zero_credit_balance

Suggested change
/// 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.

Comment on lines +288 to +290
// debitIncome = 0.0 * 0.0 = 0.0
// protocolFeeAmount = 0.0
// totalCreditBalance = 0.0 -> creditRate = 0.0
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor

@mts1715 mts1715 left a comment

Choose a reason for hiding this comment

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

few smal fixes should be done

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.

Interest Rate Boundary Conditions Testing

3 participants