Skip to main content

On-Chain & Off-Chain Implementation

1. Component Split

ComponentLocationRationale
deposit() functionOn-chainAccepts stablecoin, mints kToken variant, records deposit in ledger. Immutable record.
Intent Class flagOn-chainStored per deposit in ledger. Cannot be changed after deposit.
kToken-fx / kToken-fullOn-chainTwo separate ERC-20 contracts per currency, each with own Liquidity Index.
Routing Decision LogicOff-chain (Backend)Reads pool balances and admin config. Instructs on-chain deposit() with target pool.
Pending QueueOff-chain (Backend)FIFO queue for overflow deposits. Auto-processes when capacity opens.
Admin Config StoreOff-chain (Backend)Pool thresholds, fee tiers, split ratios. Read by routing engine. Changeable by admin without on-chain tx.
Fee Tier MultiplierOff-chain (config) + On-chain (execution)Config stored off-chain; fee split calculation executed on-chain in Vault updateIndex().
Overflow TaggingOff-chain (Backend)Tags Class B overflow capital in Yield Pool for priority recall.

2. Smart Contract Functions (New / Modified)

FunctionParametersDescription
deposit()pool, amount, intentClassDeposits stablecoin into specified pool. Mints kXXX-fx or kXXX-full based on intentClass. Records deposit timestamp, amount, class in ledger.
updateIndex()amount, tokenVariantModified to accept tokenVariant parameter. Updates only the specified kToken's Liquidity Index.
getPoolBalance()pool, currencyReturns current balance. Used by off-chain routing engine.
getClassTVL()currency, intentClassReturns total TVL for a specific class within a currency pool. Used for pro-rata fee distribution.