Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Peg — Tokenized stocks. Community liquidity.

Peg SDK

Typed, verifiable reads for PEG on Robinhood Chain.

TypeScript Chain Scope

A small integration toolkit for dashboards, research tools and community applications that need to read PEG balances and funded staking positions. It connects public deployment identities to typed results, exact token arithmetic and reproducible examples.

Application · Solidity contracts · Peg organization · X

What you can build

Integration Available data
Wallet overview Exact PEG token balance in raw units.
Staking dashboard V2 principal, accrued PEG rewards, total principal and reserve balance.
Migration prompt Existing v1 principal and whether a full v1 exit is required by the app.
Reserve monitor Whether the current reserve covers the queried account's current rewards.
Data export JSON-safe snapshots with block number, hash and timestamp.

Start locally

Node.js 22 or newer is required. This is a source repository; the package is not published on npm.

git clone https://github.com/use-peg/peg-sdk.git
cd peg-sdk
npm ci
npm test
npm run read -- 0xYourPublicWalletAddress

npm test builds strict TypeScript and runs eight offline checks. The read command uses the public RPC and makes no wallet requests. An optional PEG_RPC_URL environment variable selects another trusted endpoint for Robinhood Chain.

TypeScript: read a position

import { JsonRpcProvider } from "ethers";
import { PEG, PegReader, formatPeg } from "./dist/index.js";

const provider = new JsonRpcProvider(PEG.rpcUrl);
try {
  const position = await new PegReader(provider).staking(walletAddress);
  console.log({
    staked: formatPeg(position.staked),
    earned: formatPeg(position.earned),
    legacyStake: formatPeg(position.legacyStaked),
    rewardsCovered: position.rewardsCovered,
    block: position.blockNumber,
  });
} finally {
  provider.destroy();
}

Every monetary field is a bigint in 18-decimal raw PEG units. formatPeg converts units to a decimal string. snapshotJson serializes raw amounts as strings without losing precision.

Read verification

The TypeScript reader performs these checks before returning a snapshot:

  1. The provider reports chain ID 4663.
  2. The block is recent, has a hash and is not unexpectedly in the future.
  3. Both deployed v2 runtime hashes match the manifest in index.ts.
  4. PEG reports the expected symbol and 18 decimals.
  5. All balances use the same explicit block height.
  6. The block hash still matches after the reads finish.

A missing RPC response, wrong network, unexpected contract or reorganization rejects the read. It does not appear as an invented zero balance. Consumers should display the snapshot's block information and handle errors before retrying.

import { PegReadError } from "./dist/index.js";

try {
  const position = await reader.staking(walletAddress);
  render(position);
} catch (error: unknown) {
  if (error instanceof PegReadError) {
    console.error(error.code, error.message);
  } else {
    throw error;
  }
}

Exact amount helpers

import { PEG, parsePeg, formatPeg, projectRewards } from "./dist/index.js";

const principal = parsePeg("1000.000000000000000001");
const annualEstimate = projectRewards(principal, PEG.yearSeconds);
console.log(formatPeg(annualEstimate));

projectRewards is a simple estimate for unchanged principal at the configured 12% APR. Actual entitlement comes from the vault's earned(account) method. A projection is neither a token price nor a guarantee that the reserve will remain funded.

Python: inspect the same public state

The standard-library example is useful for scripts and notebooks:

python3 read_position.py 0xYourPublicWalletAddress

It validates the network, reads wallet/v1/v2/reward balances at a single block and checks that the block remains canonical. Results use decimal strings. The Python example intentionally omits runtime attestation; use the TypeScript reader when that check is required.

Deployment manifest

Component Robinhood Chain address
PEG 0x7F362D5EF8b02cedF2B5C5f76b9D7Aaa667085C8
Legacy v1 vault 0x431d61b1a57F8d4fd1C0406dc424d5beEEc07A8F
Funded v2 vault 0xa250fd639824e789B732D744Bb8A1384db5c0557
V2 reward reserve 0x815B82903fc35dE6257794fdBF88D60b80bBb8bA

Manifest snapshot: September 11, 2026. The v2 vault holds principal; the separate reserve pays earned PEG. V1 positions retain their original withdrawal path. The manifest pins reviewed deployed bytecode; updating it requires independently checking the replacement deployment.

Repository map

File Purpose
index.ts Public manifest, ABI fragments, read client, error types and exact amount helpers.
sdk.test.ts Precision, input rejection, projections, JSON serialization and fail-closed reader checks.
example.ts A bounded RPC CLI using PegReader.
read_position.py Python standard-library position inspection.

Scope

This toolkit reads public chain data. It contains no signer, key handling, token approvals, deposit preparation or transaction broadcast. Runtime matching proves code identity, not an independent security audit. Freshness checks and block consistency are observations through the selected RPC, not consensus finality guarantees.

Current reserve coverage is a snapshot for one account. Rewards continue to accrue and other accounts can claim. Transaction execution still belongs in the application's fresh preparation and wallet confirmation flow.

For pools, swaps, token launches and fund management, use Peg. For selected protocol source snapshots and the separate 30-test custody suite, see peg-contracts.

About

Read-only TypeScript integrations for PEG and funded staking on Robinhood Chain. Typed snapshots, exact token arithmetic, runtime verification, and TypeScript / Python examples.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors