import { Provider } from '@ethersproject/providers'; import { LoyaltyStatus } from '../domain/loyalty'; /** * Multicall3 — the same address on every EVM chain it is deployed to * (https://www.multicall3.com). One `eth_call` to it reads everything below * in ONE block, which is what makes the figures consistent with each other. */ export declare const MULTICALL3_ADDRESS = "0xcA11bde05977b3631167028862bE2a173976CA11"; /** The SDK's own reading disagreed with `UserManager.userLoyaltyLevel` at the same block. */ export declare class LoyaltyLevelMismatchError extends Error { readonly chainLevel: number; readonly computedLevel: number; readonly blockNumber: number; constructor(chainLevel: number, computedLevel: number, blockNumber: number); } export interface LoyaltyFacadeConfig { /** The provider to read through (resolved per call, so `connect` is honoured). */ provider: () => Provider; isLiteDeployment: boolean; contracts: { SystemVariables: string; UserManager: string; IKSULocking: string; UserLoyaltyRewards: string; }; stableAssetDecimals: number; /** Defaults to `MULTICALL3_ADDRESS`. */ multicall3Address?: string; } /** * Loyalty level for one lender — the level, every level's threshold, what * reaching each one takes, and each level's KSU bonus rate. * * Base only: Lite deployments (XDC) have no KSU, no locking and no levels, and * `getStatus` says so (`{ supported: false }`) without touching the network. */ export declare class LoyaltyFacade { private readonly _config; constructor(_config: LoyaltyFacadeConfig); /** * The lender's loyalty status, read from chain in ONE call (Multicall3), * so every figure comes from the same block. * * Reads: `SystemVariables.loyaltyThresholds`, `ksuEpochTokenPriceFresh` * (the price the contract's own level read uses); `KSULocking.balanceOf` * (rKSU) and `userTotalDeposits` (KASU locked); * `UserManager.userTotalPendingAndActiveDepositedAmountForCurrentEpoch` * (the lent amount the level counts now), `userTotalPendingAndActiveDepositedAmount` * (pending up to the NEXT epoch — the requirements use the larger) and * `userLoyaltyLevel`; `UserLoyaltyRewards.loyaltyEpochRewardRates` for * levels 0..10. The level is computed from those inputs exactly as * `UserManager._userLoyaltyLevel` does and checked against * `userLoyaltyLevel`; a disagreement throws `LoyaltyLevelMismatchError` * rather than show requirements the contract would not honour. * * The level counts LOCKED KASU (rKSU), never KASU held in a wallet: * buying KASU alone does not change it. `levels[n].additionalKsu` is the * extra KASU to lock at full weight (the 720-day lock, 1 rKSU per KSU) to * reach level n at `requirementLentUsd` and today's price — a MINIMUM: * interest, new deposits and price moves raise it before the next * clearing records the level, and buying costs fees, so pre-fill with * headroom and net off KASU already held unlocked. For a lock with another * rKSU multiplier, `ksuToLockFor(additional rKSU, multiplier)` gives the * exact amount (never a float division — `_lock` floors what it mints). * * ```ts * const status = await kasu.loyalty.getStatus(address); * if (status.supported) { * const gold = status.levels[2]; * prefillBuy(gold.additionalKsu); // exact decimal string, or null * } * ``` * * @throws on an invalid address, a failed read, or a chain state outside * what the contract allows (`RangeError`). */ getStatus(user: string): Promise; }