Borrowing under different scenarios

What happens underneath the hood when a borrowing tx is executed
Borrowers withdraw asset tokens from the pool by locking collateral. The pool transfers CCT tokens from the CCT token pool to the borrower & mints more Bond tokens(BT) to the Bond token pool. This represents his principal amount borrowed from the pool. He also gets more CCT tokens by the contract equivalent to Bond tokens minted in the pool, representing the interest component on his borrowed amount. The total CCT tokens minted then represent the total collateral to be locked by the borrower.

The flow of a borrow transaction:

  1. 1.
    When borrowing is initiated, USDC/ETH is locked to mint BT and CCT.
  2. 2.
    BT added in the pool and CCT tokens are withdrawn equivalent to the principal borrowed and denominated as collateral bases on the transition price. So for e.g., when KΔy USDC is withdrawn from the asset pool, Δy CCT tokens are simultaneously withdrawn from the CCT token pool, and dΔz new bond tokens are minted in the bond token pool.
Also, Δz equivalent of CCT tokens are newly minted and transferred to the borrower representing the interest component locked as collateral.
3. Now, the user holds a total of Δy+dΔz CCT ETH tokens. They represent Δy+dΔz ETH locked & debt of K*Δy+dΔz USDC

Borrowing dynamics under different scenarios::

Every borrower on Timeswap holds Collateral claim tokens(CCT) and can use any of the two pool tokens as collateral while borrowing. The collateral locked by the borrower is not used and is kept in a separate pool; this ensures the pools are always solvent whenever the borrower withdraws his locked collateral.
Borrowers' collateral is utilised for two purposes:
  • Minting CCT & Bond tokens.
  • Converting CCT tokens to appropriate collateral. (Borrowed Tokens)

Before diving further, let's revisit utility of Collateral claim tokens!

If you hold 1 CCT ETH, you can withdraw 1 ETH by locking K USDC. 1 CCT ETH -> K CCT USDC after this. If you hold K CCT USDC, you can withdraw K USDC by locking 1 ETH. K CCT USDC -> 1 CCT ETH after this.
Since only one token exists in the pool at a given instant, borrowing the second token is made possible by swapping the token in the pool to other token via DEX. Borrowing non-pool tokens can cost a high APR compared to borrowing tokens in the pool due to the higher default risk involved for lenders.

With that out of the way, let's look at the working of both cases:

  1. 1.
    Spot Price > Strike Price(S>K):
  • USDC being lower in value(K*USDC < 1 ETH) is the asset available in the pool due to rebalancing.
  • To borrow KΔy USDC, Δy+dΔz ETH is locked.
  • Borrower gets Δy+dΔz ETH CCT tokens with a debt of K*(Δy+dΔz) USDC
Here's how the calculation would look like at the core AMM:
where dΔz is the amount of BT added, and Δy is the amount of CCT USDC withdrawn.
A similar procedure is conducted while borrowing ETH with USDC as collateral when Spot Price (S)< Strike Price (K).
2. Spot Price < Strike Price (S<K)
  • ETH being lower in value(1 ETH < K*USDC), is the asset available in the pool due to rebalancing.
  • To borrow USDC, Δx+dΔz ETH is locked and Δx ETH is swapped at DEX to get SΔx USDC and transferred to borrower
  • Borrower gets Δx+dΔz CCT ETH with a debt of K*(Δx+dΔz) USDC
(A DEX is involved to process the transaction.)
Here's how the calculation will look within the AMM:
where dΔz is amount of Bond tokens added to the pool, Δx is the amount of CCT ETH withdrawn.
Borrowers while borrowing USDC by locking ETH will hold SΔx as debt & hold Δx + dΔz CCT ETH.
Similar procedure is conducted while borrowing ETH with USDC as collateral when Spot Price (S) > Strike Price (K), the pool will contain CCT USDC. Check out Borrowing Deep Dive to understand more scenarios.