Autofarm compounding reinvested farm rewards into the vault's deposit asset
Autofarm compounding used vault strategies to harvest farm rewards and reinvest them into the vault's deposit asset. In the archived V2 implementation, that reinvestment could increase the assets backing each depositor's shares. Pending AUTO rewards followed separate accounting and weren't automatically part of that growth. The reinvestment route depended on the strategy: some branches restaked rewards directly, while others converted rewards and rebuilt liquidity-provider (LP) tokens. Reward deductions reduced the amount available for reinvestment. StratX2's earn() function required an enabled compounding mode, an unpaused strategy, and an accepted caller. Autofarm's public code organization was archived on August 9, 2023. The archive doesn't establish a particular vault's present operating status.
The short version: Autofarm's V2 strategies could increase the deposit tokens backing each share without increasing a depositor's internal share count.
Deposit shares measured the claim on compounded assets
A depositor participated through the asset that the selected V2 pool accepted, and a successful deposit recorded internal shares representing a proportional claim on the strategy's deposit tokens, called
want
in the contracts. For StratX2, the
isAutoComp
setting determined whether deposits entered the external farm. Its non-compounding branch held the deposit tokens without running that farming path.
For a pool with nonzero total shares,
stakedWantTokens()
returned user shares multiplied by
wantLockedTotal
, divided by
sharesTotal
.
Successful reinvestment could increase the deposit tokens backing those shares while leaving the depositor's share count unchanged. The accounting measured token quantities; it didn't assign them a fixed market value. Integer division also made token precision relevant to the smallest recorded changes.
The
Deposit
event recorded the submitted amount; it didn't measure a later harvest's reinvestment.
Did collecting AUTO also compound the farm rewards?
Collecting pending AUTO through AutoFarmV2 didn't call the strategy's
earn()
function, which performed farm-reward reinvestment. The main contract calculated AUTO entitlements using a pool's allocation and accumulated rewards per share. Its zero-amount deposit path could process an existing depositor's pending AUTO without adding strategy funds. The transfer was capped by the AUTO balance available in the main contract. Consequently, an AUTO payment showed a reward distribution, while growth in the strategy's deposit-token backing concerned compounding. Pending AUTO used AUTO units, while the depositor's vault claim used the pool's deposit-token units.
How did harvested rewards become deposit assets?
StratX2 restaked rewards directly in its CAKE-staking and same-asset branches, while its paired-liquidity branch rebuilt LP tokens. The function first harvested through the configured external farm. After reward deductions, the direct branches called
_farm()
and returned without entering the paired-liquidity conversion logic. CAKE staking used PancakeSwap's dedicated staking functions.
For paired liquidity, the strategy allocated half the remaining earned-token amount toward each component. It skipped a component swap when the reward token already matched that component. When both component balances were positive, the strategy passed their available balances to the router's liquidity-addition function and farmed the resulting LP tokens.
Harvesting, conversion, and redeposit were operations within the same
earn()
call; they didn't require separate user transactions.
Reward deductions came before reinvestment
A positive controller fee reduced the strategy's earned-token balance before the remaining rewards entered the buyback calculation. A positive buyback rate then applied to that remainder. These deductions reduced rewards available for compounding; their calculation base wasn't the depositor's entire vault balance. Zero settings skipped their respective deductions. The deployed strategy's settings therefore affected how much of a harvest reached reinvestment, alongside the conversion prices that its router obtained.
The buyback destination was configurable. In StratX2, rewards already denominated in AUTO could be transferred directly there; other reward tokens used a conversion route. A buyback setting didn't establish an unconditional payment to depositors.
What determined when a V2 strategy could compound?
V2 StratX2 compounded during successful
earn()
calls, subject to its compounding-mode, pause, and caller checks. The function itself imposed no fixed minimum interval between calls. With
onlyGov
enabled, the caller had to match
govAddress
. Disabling that restriction removed the governance-only caller check, while the compounding-mode and pause requirements still applied. Those settings controlled access to the harvest function; elapsed time alone didn't execute reinvestment.
The rest of the call also had to succeed. External farming, reward transfers, and any required conversion depended on their respective contracts. A reverted transaction rolled back its changes, so an attempted harvest couldn't be treated as completed reinvestment. Those dependencies also prevented a fixed harvest frequency from establishing a fixed return.
A permitted harvest increased assets per share
A depositor wanted to trigger V2 StratX2 compounding from their own wallet. All balances, settings, and outcomes in this example are hypothetical. The depositor held 126 internal shares out of 756 total shares, backed by 2,436 deposit tokens.
The strategy was unpaused,
isAutoComp
was enabled, and
onlyGov
was disabled. Those settings admitted the depositor's call to
earn()
. Assume the external operations succeeded and reinvestment added 114 deposit tokens, net of deductions and conversion effects. No other deposits or withdrawals changed either balance.
The initial claim was 126 × 2,436 ÷ 756 = 406 deposit tokens. Strategy assets then reached 2,550 tokens. The claim became 126 × 2,550 ÷ 756 = 425 deposit tokens, a gain of 19 tokens with the same 126 shares.
If
onlyGov
had been enabled and the caller hadn't matched
govAddress
, the function would have rejected the call before harvesting. That attempt would have added no reinvested assets. The arithmetic described the successful path's deposit-token claim, not a pending AUTO payment.
Venus reward reinvestment followed a separate lending path
The archived Venus strategy harvested its rewards, applied deductions, and converted the remainder into the deposit asset when necessary.
In
StratVLEV2
, the reward-reinvestment function finished by calling
_farm(false)
.
That argument supplied available assets without running another configured borrowing loop, although the strategy still updated its lending balances and could deleverage when its borrowing relationship exceeded the target; deposits used
_farm(true)
. Its asset accounting combined idle tokens and supplied assets, then subtracted borrowing. Lending interest could therefore change net backing alongside harvested rewards, so the reward amount alone didn't determine the change in each share's deposit-token claim.
Annualized yield depended on repeated net reinvestment
Compounded growth depended on the rewards that the underlying farm supplied and the deposit assets that conversion actually produced. A projected annual percentage yield (APY) assumed repeated reinvestment. A constant-rate model expressed annual growth as
(1 + r)^n - 1
, where
r
meant the net return per reinvestment expressed as a decimal, and
n
meant the number of reinvestments over a year. That relationship described compound growth, so dividing the annual yield by the number of days didn't recover its daily rate. Changes in farming income, reward-token prices, deductions, or execution changed the growth that subsequent cycles could produce. Reinvesting more often couldn't fix an underlying decline in the amount earned.
For an LP strategy, accumulating more LP tokens also remained separate from their market value and underlying token exposure. A larger token claim could coexist with a lower monetary value. Lending strategies had an additional dependency on interest and borrowing. StratX2 restaked rewards or rebuilt LP tokens, while supplied assets and outstanding borrowing shaped net backing in StratVLEV2.
Autofarm compounding: reader questions
Could V2 compounding continue after a pool stopped allocating new AUTO rewards?
Farm-reward reinvestment could continue independently of new AUTO allocations if the strategy and underlying farm supported it. StratX2's earn() function didn't use the pool's AUTO allocation to enable compounding. It still depended on its compounding mode, pause state, caller permissions, available rewards, and successful external operations.
Did converting dust immediately compound the leftover tokens?
Converting dust didn't itself run the harvest-and-redeposit cycle. In StratX2, convertDustToEarned() swapped eligible component-token leftovers into the configured reward token. The function required an unpaused strategy with compounding enabled and excluded CAKE-staking mode. A later earn() call handled reinvestment of that reward balance.
Was lastEarnBlock proof that a harvest produced positive returns?
A newer lastEarnBlock recorded the block of a successful earn() call, without specifying the amount reinvested. It wasn't a measurement of profit or deposit-token growth. The quantity change came from the strategy's asset accounting, with lending positions also reflecting supplied assets and borrowing. The block field alone couldn't establish a positive return.
Could a slippage check stop a reward-conversion swap?
A reward-conversion swap could revert if execution couldn't satisfy the strategy's minimum-output check. StratX2 calculated that minimum from the router's output quote multiplied by slippageFactor and divided by 1,000. The parameter governed this strategy's conversion checks; it wasn't a fixed slippage rate for every vault.
How did StratX2 handle native BNB when its reward asset was WBNB?
StratX2 wrapped its native BNB balance into WBNB when WBNB was the configured reward token. That step came after harvesting and before reading the earned-token balance, so subsequent reward handling used WBNB. The condition concerned the strategy's reward asset, without changing which deposit token the pool accepted.
Were unharvested farm rewards reinvested during an emergency withdrawal?
AutoFarmV2's emergency-withdrawal path didn't call strategy earn() or settle pending AUTO rewards. It requested withdrawal of the user's existing proportional deposit-token claim, then cleared the user's shares and reward debt. Strategy withdrawal still relied on its own external calls; the emergency label didn't promise recovery when those calls couldn't succeed.
Did rewardDebt represent borrowing against the compounded deposit?
In AutoFarmV2, rewardDebt was an AUTO reward-accounting offset that the contract subtracted from the accumulated entitlement to calculate pending AUTO, then refreshed after deposits or withdrawals; it didn't represent borrowing or reduce the strategy assets used to calculate the deposit-token claim.