The Solidity behind stock-token liquidity, PEG custody and PegPad fee routing.
Peg · Application · X
Five selected primitives from the Peg application, published with their original Solidity source, pinned compiler dependencies, and a reproducible staking test suite.
| Contract | Responsibility | Key properties |
|---|---|---|
| PegAsset.sol | Fixed-unit stock-token wrapper | Exact transfer accounting, bounded immutable wrap fees, minimum output and deadline checks. |
| PegPool.sol | Constant-product liquidity pool | ERC-20 LP shares, 30 bps retained swap fee, minimum shares/output, locked initial liquidity. |
| PegNativeEntry.sol | Atomic ETH / USDG entry | Immutable market allowlist, call-specific balance deltas and refunds. |
| PegPadFeeRouterV2.sol | PegPad creator-fee routing | Bound creator/executor/market; Pons curve collection and 50/25/25 distribution. |
| PegStakingVault.sol | PEG principal custody | Immutable token and chain, caller-owned balances, exact transfers, reentrancy protection, independent withdrawals. |
The following is the actual public entry point in PegStakingVault.sol:
function withdraw(uint256 amount) external nonReentrant {
_checkChain();
if (amount == 0) revert InvalidAmount();
if (amount > stakedBalance[msg.sender]) revert InsufficientStake();
_requireBacking();
stakedBalance[msg.sender] -= amount;
totalStaked -= amount;
_sendExact(msg.sender, amount);
emit Withdrawn(msg.sender, amount, stakedBalance[msg.sender]);
}
Principal belongs to the depositor. The vault has no owner, upgrade switch, principal investment, lock period, fee, or donation sweep. Reward accounting is external; the vault does not generate or guarantee the interface's reward rate.
Node.js 22 or later:
npm ci
npm run build
npm test
Pinned tools: Solidity 0.8.36, OpenZeppelin 5.6.1, optimizer 200 runs,
Shanghai EVM, via IR for the aggregate build. Build output goes to ignored build/; no RPC, private key or wallet
is required. Tests use an isolated in-memory Ganache chain.
The 30-test staking suite covers artifact reproduction, constructor validation, multiple accounts, partial and immediate withdrawal, transfer taxes, rebasing, issuer restrictions, donations, deficit repair, reentrancy and conservation. This suite covers staking custody; it is not a complete pool, wrapper or routing test suite or an independent security audit.
The staking vault configured by Peg on Robinhood Chain (4663) is
0x431d61b1a57F8d4fd1C0406dc424d5beEEc07A8F.
The historical deployment receipt
and frozen peg-staking-vault-v1.json make the staking version explicit.
compile-staking-vault.mjs reproduces that artifact independently; the aggregate
build is for source compilation and is not a deployment-bytecode attestation.
Pool, wrapper, native-entry and PegPad files are source snapshots. A particular deployed market must be matched to its own artifact and constructor arguments before integration. The source comments retain their original laboratory terminology.
The V2 router binds a creator, executor, stock market and runtime commitments. It collects eligible Pons curve fees, sends 50% of available net creator proceeds to the creator, uses 25% for Peg liquidity and 25% for PEG buyback and burn. Price-sensitive execution requires the bound executor and protected output limits. Mainnet deployment must attest all configured venues and code hashes. This source publication does not turn distribution into an automatic per-trade operation; post-graduation fee conversion still depends on external Pons execution.
This repository contains these five primitives. The web application, launch factory and operational infrastructure are separate components. The contracts target standard non-rebasing, exact-transfer ERC-20 assets; underlying issuer restrictions can still prevent transfers. Wrapper redemption returns the underlying token, not cash or direct legal share ownership.
Source snapshot: September 11, 2026. Solidity files retain their MIT SPDX headers. Dependencies retain their own licenses.