🎯User/Fee Flow

Detailed view of user interactions and protocol fees.

Glossary

TOKEN — ERC20 token.

brTOKEN — Den receipt token for TOKEN.

ARBERA — Protocol and reward token for the Den LPs.

HONEY — Token paired with brTOKEN in the Den LP.

Many tokens can be used as a Den's paired LP token, below examples are using HONEY.

Fees

Fees taken on user actions

buy.fee — Fee on buying Den tokens (in brTOKEN).

sell.fee — Fee on selling Den tokens (in brTOKEN).

bond.fee — Fee on wrapping TOKEN for brTOKEN (in brTOKEN).

debond.fee — Fee on unwrapping brTOKEN for TOKEN (in brTOKEN).

burn.fee — Burn rate of brTOKEN (Growing Dens) on top of all of the above fees.

After the burn-fee, but before swapping for ARBERA

  1. partner.fee — Fee for Den creator (in brTOKEN).

  2. yield.protocol.fee — Protocol fee (in brTOKEN).

After swapping rewards to ARBERA

Swapping path: brTOKENHONEYARBERA.

  1. yield.admin.fee — Future yield fee (in ARBERA or other reward tokens).

The rest of fees (in ARBERA) are distributed to Den LPs.

User actions

Let's go through each user action and see the tokens and fees flow.

Wrapping into Den

  1. User wraps X TOKEN (calls bond() on Den contract).

  2. Den mints Y = X/R brTOKEN (based on TOKEN:brTOKEN ratio R).

    1. (Y * bond.fee) * (1 - burn.fee) brTOKEN stays in the Den contract.

    2. (Y * bond.fee) * burn.fee brTOKEN is burned (Growing Dens).

  3. User receives Y * (1 - bond.fee) brTOKEN.

  1. First depositor wraps fee free.

  2. Den creator has 7 days to wrap fee free — for first deposit only.

Unwrapping from Den

  1. User unwraps Y brTOKEN (calls debond() on Den contract).

  2. Den burns Y * (1 - debond.fee) brTOKEN.

  3. (Y * debond.fee) * (1 - burn.fee) brTOKEN stays in the Den contract.

  4. (Y * debond.fee) * burn.fee brTOKEN is burned (Growing Dens).

  5. User receives R * Y * (1 - debond.fee) TOKEN (based on TOKEN:brTOKEN ratio R).

No fee if unwrapping 98% brTOKEN or more.

Buying Den token

  1. User buys X brTOKEN with HONEY (via Den LP).

  2. (X * buy.fee) * (1 - burn.fee) brTOKEN stays in the Den contract.

  3. (X * buy.fee) * burn.fee brTOKEN is burned (Growing Dens).

  4. User receives X * (1 - buy.fee) brTOKEN.

Selling Den token

  1. User sells X brTOKEN for HONEY (via Den LP pool).

  2. (X * sell.fee) * (1 - burn.fee) brTOKEN stays in the Den contract.

  3. (X * sell.fee) * burn.fee brTOKEN is burned (Growing Dens).

  4. User receives X * (1 - sell.fee) brTOKEN to swap for HONEY.

Staking/Unstaking/Transferring Staked Den LP Token

  1. User interacts with X Staked brTOKEN-HONEY LP (calls stake(), unstake() or _transfer()).

Transferring brTOKEN

  1. User transfers X brTOKEN (calls _transfer() on Den contract).

  2. Triggers Fee distribution unless it's a transfer from Den LP.

Taking Flash Loan

  1. User takes X TOKEN flashloan paying 10 HONEY (calls flash() on Den contract).

  2. Triggers Fee distribution if Den LP rewards are in HONEY,

  3. Otherwise if paired Den LP token is HONEY, fee is sent to TokenRewards contract.

  4. Otherwise, HONEY is sent to the treasury.

Fee distribution

This is being called on all Den and Staked Den LP transfers (except when Buying Den token).

Wrapping TOKEN into brTOKEN also doesn't trigger Fee Distribution.

  1. User triggers _processPreSwapFeesAndSwap() on Den contract.

  2. If accumulated fees AF in Den contract (in brTOKEN) are at least 0.025% of Den's LP balance of brTOKEN B, then Fees To Swap FTS = max(AF, 1% * B) brTOKEN.

  3. Swapping for HONEY (Den paired LP token):

    1. FTS * partner.fee brTOKEN are sent to the Den creator address.

    2. FTS * yield.protocol.fee brTOKEN are sent to the Arbera treasury.

    3. FTS * (1 - partner.fee - yield.protocol.fee) brTOKEN are swapped to HONEY.

  4. HONEY (from point 3.3) is swapped for Y ARBERA.

  5. Y * yield.admin.fee ARBERA is sent to treasury for Future LP Yield.

  6. Y * (1 - yield.admin.fee) ARBERA are deposited as rewards for Staked Den LPs.

Last updated