Rate Contract
Loan rate rebalancing and rate swaps are done through the Rate contract. Users lending will use this contract to ensure that they get the correct interest accrued on the funds being lent out. Rebalancing can only occur when the stable interest rate is below the current floating rate. Users who are borrowing will use this contract to swap from stable or floating rates on their loans.
Request
Fields:
Claimable Balance Id: ID of the claimable balance representing the loan that needs to have its interest rate swapped.
Target Rate: Target interest rate for the loan (fixed or floating)
High-Level Contract Process Flow
User enters the contract through an event handler which transforms their request.
Contract prerequisite data from horizon.
Pool Account Data
User Account Data
User Position Data
Contract builds a transaction builder object.
This is the object operations will be added to throughout the rest of the contract process flow.
If the user is not the owner of the liability balance the contract verifies that the balance is fixed rate and that its interest rate is lower than the current floating interest rate. If either of these things are not the case the contract rejects.
Contract adds a
claimClaimableBalance
operation where the pool claims the specified liabiliity balance.The contract calculates accrued interest and adds it to the liability balance.
The contact calculates all unclaimed YBX issuance associated with this liability balance.
Contract adds a
createClaimableBalace
operation where the pool creates a liability balance with the target interest rate.If the user is the owner they sponsor the liability balance. If they are not the owner the escrow account sponsors the liability balance.
The rebalancer must pay the escrow account the necessary minimum reserve for sponsoring the liability balance.
Contract creates a
payment
operation where the distribution account pays any unclaimed YBX to the user.Contract adds all necessary Utilization Tracker operations.
Turret builds transaction builder into an XDR and returns it along with a signature.
Diagram
User Account: The pool claims the liability claimable balance and recreates it with a floating interest rate.
Last updated