Postmortem: tfUSDC Price Irregularity

Review of TrueFi’s DAO Pools token pricing methodology that exposed tfToken holders to limited arbitrage risk

Rafael Cosman
TrueFi
6 min readMay 11, 2022

--

In summary: On April 27th, 2022, a member of the APWine team reported a drop in the price of tfUSDC, the LP token of TrueFi’s USDC DAO portfolio. After some internal investigation, we determined that this was due to an issue in the way these portfolios interpolate loan value.

No principal funds were at risk of loss, although the price reporting discrepancy resulted in a potential arbitrage opportunity centered around loan repayments which could have affected tfToken (tfUSDC, tfTUSD, tfUSDT, tfBUSD) holders.

At this time, this arbitrage opportunity has been closed with an interim fix. After extensive review, a plan involving a contract upgrade is in the works. This post will be updated once this mitigation is live.

A necessary pause to protocol fees will mean TRU stakers will not enjoy tfUSDC rewards for loan repayments until a final fix agreed on by the community, developed, audited, and deployed. There is no interruption to TRU incentives for stakers, however, currently +20% APY.

In Simple Terms: Irregularities in tfToken Price Calculator

tfTokens represent a lender’s claim to the principal and interest in TrueFi’s DAO portfolios, which lend the USDC, USDT, TUSD, and BUSD stablecoins to reputable crypto funds. Using USDC as an example, when a USDC loan goes out, the value of tfUSDC increases gradually until the repayment date to reflect the interest generated by the new loan, minus a protocol fee that goes to the treasury. This code has been working as written and performing as intended, but it introduced noticeable price irregularities as large loans began to introduce large protocol fees.

To date, tfUSDC would go up in price over the span of the loan to reflect the incoming interest payments, ignoring the protocol fee until the repayment date. This meant the protocol fee would hit tfUSDC all at once. Especially large loans, the type of which TrueFi is increasingly making in these pools, could temporarily push short-term tfUSDC yield into the negative. Though no principal was ever at risk, this fluctuation created a limited arbitrage opportunity on tfTokens that could have affected the expected yields enjoyed by TrueFi lenders.

While a solution that would calculate the protocol fee on loan origination and spread out its cost smoothly to tfTokens over the full term of each loan has been proposed, we believe it’s imperative to involve the community in having a voice in changes to the protocol.

Before the fix is audited and deployed, a temporary solution has been to pause the protocol fee across all DAO pools. This immediately eliminates the arbitrage vulnerability, but will mean TRU stakers will not enjoy tfUSDC awards on loan repayment until the final fix is live.

It’s important to note unsecured lending on TrueFi carries risks commensurate with the competitive yields. Besides protocol fees, tfToken price may go down due to other causes like defaults or penalties. Though the tfToken pricing code was working as written, its design now needs to be upgraded for the scale of TrueFi today.

Deeper Look: DAO portfolio follows standard share price

Assuming no defaults and no idle fund strategy, the total TOKEN value of a tf{TOKEN} DAO portfolio is calculated as

total value = liquid value + illiquid value

where liquid value is mostly the TOKEN balance held by the DAO portfolio, and illiquid value is mostly the sum of values of outstanding loans:

illiquid value = sum(loan values)

Disregarding liquid exit fees, when a lender joins or exits a portfolio, their underlying TOKENs are exchanged for tf{TOKEN}s (or vice versa) at a common share price of:

share price = total value / total supply

Notably, this means that lender actions (joining and exiting) should not materially affect share price. Only borrower actions (e.g., paying back interest or defaulting) should affect the share price.

Loan value is linear over a loan term

We calculate the value of a single loan as if it increases in a straight line, block-by-block, over the loan term.

At the beginning of the loan term, the loan value should be principal. At the end of the loan term, the loan value should be principal + interest. At any time between 0 and term, the loan value is given by

loan value = principal + interest * time / loan term

Under ideal repayment circumstances, these endpoints ought to line up perfectly with principal TOKENs transferred to the borrower and principal + interest TOKENs returned from the borrower. This would present no discontinuities in the overall portfolio value over time.

Having no discontinuities is great, because a sudden jump or drop would be an opportunity for arbitrage. If a sneaky lender could predict a discontinuity, then they could join and then exit (or exit and then join) around the loan repayment, at the expense of other lenders in the portfolio.

Discontinuity in share price

Unfortunately, in our DAO portfolios, we had overlooked a discontinuity caused by instant fees taken during loan repayment:

1. When a loan is repaid, the protocol assesses a 10% fee on the interest of the loan. This causes loan value to instantly drop from principal + interest to principal + (interest — fee) == principal + 90% * interest.

2. If necessary, this fee amount is swapped for USDC, as a convenience for stakers to claim.

The swap may result in some DEX slippage losses, but stablecoins typically don’t have much relative movement against each other.

Moreover, any losses here don’t translate to changes in share price, since the fee has already left the portfolio.

3. The USDC fee amount is then reinvested into the tfUSDC DAO portfolio on behalf of stkTRU holders.

Like with any other join or exit, this reinvestment should not affect portfolio value.

Therefore the price drop comes purely from a 10% * interest fee that is taken when a loan is repaid.

Historical discontinuities

In the past, each loan repayment also caused this small price drop, but we had not noticed due to a couple factors:

  1. The loan principal was typically smaller, relative to the portfolio value.

We typically don’t issue large loans relative to portfolio value, to reduce risk from a single borrower.

However, if portfolio value subsequently decreases due to lender exits, then the remaining loans take up a greater proportion of portfolio value.

2. The loan term was typically shorter, again resulting in a smaller interest amount relative to the portfolio value.

3. We didn’t see several loan repayments occur around the same time.

If loan1, loan2, and loan3 all repay around the same time, then the fees value drop is 10% * (interest1 + interest2 + interest3), which can be 3x larger than the price drop from a single loan repayment.

Mitigations and Conclusion

To immediately address this vulnerability, TrueFi technical contributors on the TrustToken team agreed to freeze TrueFi’s protocol fees on the DAO Pools. This quickly closes the arbitrage attack vector on tfTokens by pausing the fee that causes the token’s price irregularity, but it comes with a tradeoff:

While protocol fees are paused to allow a formal upgrade to be discussed, designed, audited, and deployed, TRU stakers will not receive tfToken rewards during loan repayments. TRU incentives of +20% APY remain unaffected. This decision was made to protect TrueFi’s users and is not expected to result in substantial unrealized gains, it will affect TrueFi’s stakers until the final fix is live and protocol fees return.

Many thanks to our friends and partners at

, and TrueFi community members who reported these price discrepancies, as well as the engineers contributing to TrueFi who determined the root cause and fixed the issue.

--

--