kopi.money
  • Welcome
  • Introduction
    • The Kopi Money Market
    • What is a crypto wallet
    • What is a DEX?
    • Strategies to maximize earnings
    • Tokenomics
  • Using Kopi
    • Connect your wallet
  • How to trade
  • How to place orders
  • Using arbitrage
  • Working with automations
  • Essentials
    • Trade execution
    • kCoins
    • Lending
    • Borrowing
    • Fees & Protocol Income
    • Interest rates
    • Liquidations
    • Adding new tokens to the DEX
  • Tokenfactory
    • Factory tokens
    • Liquidity pool
    • Vesting
    • Offers
  • Technical details
    • Constant product
    • Prices
  • Liquidity
  • Epochs
  • Running a node
  • Transaction fees
Powered by GitBook
On this page
  • Snapshot
  • Distribution

Epochs

Each time a trade is executed on the DEX, trading users have to pay a fee. The fee then is split into two parts: One part is sent to an address controlled by the protocol which then distributes the fee income. The other half is sent to a different protocol address that collects all fee income from the DEX and paid out to liquidity providers in relation to how much they provided at the end of each epoch. Epochs on Kopi last 60 seconds.

Snapshot

At the beginning of an epoch, it is checked which address provided how much liquidity. That is done by iterating over all liquidity entries (skipping the ones that belong to the protocol). Each entry's value is then converted to the base unit XKP and put in relation to all provided liquidity (excluding the protocol).

// XKP
Address: kopi123, Amount: 600
Address: kopi234, Amount: 200
// kUSD (1 kUSD = 4 XKP)
Address: kopi234, Amount: 100 (=> 400 XKP)

// Total provided
Address: kopi123, Amount: 600 + 0 = 600
Adresss: kopi234, Amount: 200 + 400 = 600

In the shown example, one address provided only XKP while the other address also provided kUSD. Converted to XKP, both addresses are providing 600 XKP, entitling them to 50% of the upcoming epoch's fee income.

Together with each address's shares, the timestamp at which the epoch started is stored as well. After that, at the end of every block, the protocol checks whether the predefined time has passed. If yes, the epoch is finished, fees are distributed and a new snapshot is taken. The current epoch time is 60s. However, to minimize computation cost and to keep block speed high, the epoch time might be extended in the future if needed.

Distribution

When an epoch has finished, the protocol splits the income of each currency into shares in relation to what each user has provided. Then, depending on the setting, the fees are either

  • re-added as new liquidity to the DEX, belonging to the corresponding address

  • send to the provider's wallet address.

Before re-adding or sending the an address's fee income, it is checked wether the amount is below a predefined threshold: This is to prevent sending of dust. The threshold is 1000 micro units, so for example 0.001 XKP. If a wallet is entitled to receive 0.0009 XKP, this amount is stored in a dedicated protocol address and is given to the user when the amount is above the threshold. When the user has withdrawn all liquidity during an epoch, all funds are sent to the wallet, no matter how small.

PreviousLiquidityNextRunning a node

Last updated 1 month ago