There are many terminologies specific to DeFi and leveraged yield farming protocols that might not be familiar to many users. Even amongst DeFi protocols, terminologies and calculations used can still vary greatly. As such, we believe it's worthwhile to explain the meanings of the key terms and calculations in Alpaca Finance, which we do below.

Total Value Locked (TVL) is a common metric within DeFi. It measures the total value of the capital invested into a protocol at a current time. For Alpaca Finance, we count the following elements within our TVL

Value of total LP tokens locked in the farms

Value of deposits that are not borrowed (the borrowed amount is already accounted for in the LP value)

**Lending APY **

Lending interest rate is a floating rate based on the utilization of the pool. We use a triple-slope interest model to optimize the borrowing rate. You can see our interest rate model here.

Lending APY accrues and autocompounds in your ibTokens. When withdrawing, you will see their value has grown above the base token, Learn more here.

Lending interest is compounded every second. Thus, lending APY shown is calculated using continuous compounding; APY = e ^ (APR) - 1.

**Staking APY **

Staking APY is earned in ALPACA by staking your ibTokens on the Stake page.

APR is calculated based on the value of ALPACA rewards being distributed per block divided by the total value of ibTokens being staked.

The APY shown assumes daily compounding of the rewards.

**ib Tokens**

Please refer to ibTokens section for more information.

**Yield Farming:**

This part of the yield refers to income from liquidity incentives provided by AMM platforms. For example, PancakeSwap provides CAKE token rewards for LPs in selected pools.

We compound CAKE rewards for you by selling CAKE into BNB/BUSD and adding that back into your position as LP tokens. This yield will reflect in your position value rising over time.

The frequency of auto-compounding is not set. It occurs every time a user interacts with the pool (which can be quite frequent).

APR is calculated based on the value of CAKE rewards being distributed per block divided by the total value of reserves in the liquidity pool.

Given the high frequency of auto-compounding, farming yield APY is calculated using a continuous compounding formula.

**Trading Fees:**

DEXes charge fees for every trade, a portion of which goes to liquidity providers

**PancakeSwap**charges 0.25% fees for every trade, of which .17% accrues to liquidity providers**WaultSwap**charges 0.20% fees for every trade, of which 0.14% accrues to liquidity providers

Trading fees APR is calculated using the average of actual trading volume.

**PancakeSwap**: 7-day average**WaultSwap**: 3-day average

**ALPACA Rewards:**

Leveraged yield farmers will earn ALPACA rewards based on the size of their borrowed assets relative to the total borrowed assets.

APR is calculated based on the total value of ALPACA rewards distributed per block divided by the your equity value.

APY is calculated assuming daily compounding.

**Borrowing Interest:**

Borrowing interest is the Lending APR multiplied by the utilization level of the pool, after taking out the 19% of Lending APR for protocol fees.

Hence, borrowing interest APR is a floating rate based on the utilization of the lending pool. We use a triple-slope interest model to optimize the borrowing interest. You can see our interest rate model here.

Interest is calculated and compounded every second.

APY shown is based on a continuous compounding formula.

**Position Value**

The total value of your farming position.

This shows the value of the underlying assets in your position if they were converted into your borrowed primitive - e.g., BNB, BUSD, etc. This is what this position size would give you in the borrowed primitive after price impact and trading fees (though it includes debt value).

**Debt Value**

Total debt value of your farming position.

This value is the sum of your borrowed principal and accrued interest.

**Equity Value**

Equity Value is what you can expect to receive back if you close your position and choose to receive all the assets back in borrowed primitive.

Equity Value = Position Value - Debt Value.

**Current APY**

APY calculation follows the same formula discussed above and is based on the current leverage level.

**Debt Ratio**

Debt Ratio = Debt Value / Position Value

**Liquidation Threshold**

This is the Debt Ratio threshold for your position. Beyond this limit, your position could be liquidated.

**Safety Buffer**

This is the buffer between the current Debt Ratio and the Liquidation Threshold, aka your safe space.