Section 14 of 15

Build
+15 Lynx

LQTYStaking: Fee Distribution and Borrowing Fees

Key takeaway: LQTYStaking is the protocol's revenue distribution contract. Stakers lock LQTY tokens; in return they earn the borrowing fees (paid in LUSD) and the redemption fees (paid in ETH). The accounting uses two additive running sums: F_LUSD = F_LUSD + (fee × 1e18) / totalLQTYStaked per borrowing event, F_ETH = F_ETH + (fee × 1e18) / totalLQTYStaked per redemption. A staker's pending gain is stake × (F_current - F_snapshot) / 1e18. This is the additive counterpart to the Stability Pool's multiplicative P — same per-share-reward idea, opposite shape. Side-by-side these two contracts are a textbook illustration of why the choice between additive and multiplicative depends on whether the underlying stake decays.

What You Are Building

Three things wire up:

  1. LQTYStaking — the staking contract with stake, unstake, increaseF_LUSD, increaseF_ETH, and the lazy-read getPendingETHGain / getPendingLUSDGain.
  2. Real _triggerBorrowingFee in BorrowerOperations — replaces the stub from sections 7 and 8. Mints the fee to LQTYStaking and calls increaseF_LUSD.
  3. LQTYToken stub — a simple ERC-20 with a sendToLQTYStaking helper that lets LQTYStaking pull tokens from a staker without an approve (mirroring the LUSDToken.sendToPool pattern from section 3).

The LQTY emission curve (CommunityIssuance) is out of scope per the module's scoping decision — we keep LQTY as a stake-tracking unit and skip the time-based issuance to Stability Pool depositors.

Your Code

Solution.sol
Solidity
Loading editor...

Requirements

Write your implementation, then click Run Tests. Tests execute on the server.

Sign up free — keep reading + earn 15 Lynx

Zealynx Academy is free. Track your progress, earn Lynx, and climb the leaderboard.

Sign up free to continue

Already have an account? Log in