x · y = k
GIWASwap · constant-product AMM · GIWA Sepolia 91342
10000
TKRW (x)
=
1e8
k
=
10000
TUSD (y)
§ 1

Architecture — Factory + Pool

One canonical pool per pair, deployed by the Factory and self-contained as an ERC-20 LP token.
Factory: GIWASwapFactory

createPool(tokenA, tokenB) deploys one GIWASwapPool and stores both orderings in getPool[a][b] and getPool[b][a]. The factory enforces: tokenA ≠ tokenB, both non-zero addresses, and no duplicate pair. Canonical ordering is token0 < token1 by address.

Pool: GIWASwapPool (GLP) — The Pool is itself an ERC-20 LP token ("GLP") whose total supply represents pro-rata ownership of the reserves. State: reserve0 and reserve1. Every action (swap, mint, burn) re-syncs reserves from actual balances and emits the corresponding event. Reserves can never silently drift from balances.

§ 2

Pricing math — exact

Every number a UI or router shows must follow from these formulas. No approximation.
// swap output (Solidity, integer arithmetic)
amtAfterFee = amountIn × (10000 − feeBps) / 10000
amountOut = amtAfterFee × rOut / (rIn + amtAfterFee)

// slippage guard
require(amountOut ≥ amountOutMin, "slippage");

// effective price and impact
effectivePrice = amountOut / amountIn
midPrice = rOut / rIn
priceImpact = 1 − (effectivePrice / midPrice)
// LP: first mint (one-time geometric mean seed)
liquidity = sqrt(amount0 × amount1) − 1000
// 1000 wei minted to address(0) — permanent lock, prevents donation attack

// LP: subsequent mint (proportional)
liquidity = min(amount0 / reserve0, amount1 / reserve1) × totalSupply

// LP: burn
amount0 = liquidity / totalSupply × reserve0
amount1 = liquidity / totalSupply × reserve1
§ 3

Trust-tiered swap fee — the differentiator

Fee tier read live from DojangScore.feeBpsFor(swapper) at swap time. Verified wallets pay less; bots pay the base rate.
Tier Basis points Swap fee % Condition
PlatinumPlatinum 10 bps 0.10 % DojangScore ≥ 800
GoldGold 15 bps 0.15 % Score 500 – 799
SilverSilver 20 bps 0.20 % Score 200 – 499
StandardUnverified 30 bps 0.30 % Score < 200
Interactive swap calculator
Fee paid
—
Amt after fee
—
Amount out
—
Price impact
—
All tiers — same trade
Platinum
— —
Gold
— —
Silver
— —
Unverified
— —
A bot staying anonymous pays 3× the fee — the cheapest Sybil-resistance marketing on the chain.
§ 4

Why this can't be ported

The tiered-fee mechanism requires DojangScore and the Upbit attester, which exist only on GIWA. There is no address to call on Ethereum mainnet, Arbitrum, or any other chain — the attestation infrastructure is chain-local and Dunamu-specific.

Combined with GIWA's ~200ms Flashblocks, the swap UX is faster and cheaper for verified wallets than any existing DEX offering. A Platinum user paying 0.10% on GIWA Sepolia is paying less than any Uniswap v3 pool (lowest: 0.01%, but only for stablecoin pairs and with no trust discount).

GIWASwap's strategic role is threefold: foundational liquidity + price discovery for the GIWA ecosystem's assets, a verification flywheel (every swap incentivizes KYC so the next one is cheaper), and fee revenue for the protocol. It is not a DEX-for-its-own-sake.

§ 5

Revenue model

// protocol fee (when enabled)
lpFee = amountIn × feeBps / 10000
protocolCut = lpFee × 1 / 6
lpShare = lpFee × 5 / 6

// protocolCut → treasury; lpShare → reserve (earns LPs implicitly)
§ 6

Security assumptions

Read before auditing, forking, or routing external assets through this pool.

Oracle-free pricing by design

The pool's own reserves are the canonical price. This means the pool cannot be manipulated by an external oracle failure, but any external UI, router, or strategy that displays or acts on the pool's price must use a TWAP (e.g. accumulated price over N blocks), not the spot reserve ratio. Spot quotes are manipulable within a single block via flash loans — using them as triggers for external logic is a known attack vector.

First-LP & seeding policy

The sqrt(x·y) − 1000 first-mint formula permanently locks 1000 GLP wei to address(0). This means total supply is always ≥ 1000 after the first deposit, preventing a full drain back to zero shares and the accompanying reserve-ratio manipulation. Recommended seeding: operator bootstraps with a balanced initial position before opening to public LPs.

DojangScore dependency

A wrong DojangScore sets the wrong fee tier for a swap. This means a verified user might pay Unverified rates, or vice versa. This is a pricing error, not an AMM correctness error. The constant-product invariant still holds; amountOut is still correctly computed for whatever fee bps is returned. The trust discount is a perk, not a safety property. The pool settles correctly regardless.

Token risk — arbitrary ERC-20s

The current implementation trusts that transfer / transferFrom behave as standard ERC-20: no fee-on-transfer, no rebasing, no reentrancy in the token hook. Malicious or non-standard tokens can break the reserve integrity invariant silently. Roadmap: an allowlist of approved token addresses + safeTransfer wrappers + post-transfer balance checks. The demo pairs (TKRW / TUSD) are our own MockERC20 instances with no surprises.

Reserves integrity

Every action recomputes reserves from balanceOf(address(this)) after the transfer, not from a stored accumulator. This means reserves can never drift from actual balances due to direct token sends. It is the same discipline that caught the vault's 1e21 share price: the dashboard that must never lie is a security control, not decoration. If the pool holds what the state says, any inconsistency surfaces immediately.

Verified wallets pay less. Bots pay triple. Trust, finally, has a price — and the price is the point.
DojangScore Docs WonVault Docs Live App
Pool: 0x8813361aA6FFdC1B5926FA95d756b7390C680059  ·  Factory: 0x7c7825AEF6b8b590dcF48d8C5059F3594B84a99F