Observed since 20 Oct, 22:10 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
@0g-brier/protocol
The Dynamic Pari-mutuel Market maths behind Brier, in TypeScript — pricing, quoting, units and deployment manifests.
The Dynamic Pari-mutuel Market maths behind Brier, in TypeScript. A mirror of the Solidity library, pinned to it by vectors generated from the contracts themselves — a mirror is only worth having if something fails when it drifts.
npm i @0g-brier/protocol
import {dpm, WAD, networkFor} from "@0g-brier/protocol";
const q: readonly [bigint, bigint] = [1000n * WAD, 1200n * WAD]; // [NO, YES]
dpm.probability(q, 1); // 0.590… — P(YES)
dpm.price(q, 1); // 0.768… — the marginal PRICE per share
Those are different numbers, and confusing them is the mistake this package
exists to prevent. The implied probability is pᵢ²; the marginal price is pᵢ.
A price shown with a % sign is a lie about the instrument.
A winning share pays 1/pᵢ, funded entirely by the pool — so every later buyer on
your side dilutes you, including your own next order. dpm.costUp, sharesForSpend
and quote size a trade against that.
Deployment manifests load through the ./node entry point:
import {loadDeployment} from "@0g-brier/protocol/node";
const {contracts} = loadDeployment(16661, "./deployments"); // 0G mainnet
MIT.
Download counts and popularity will appear here as the collector receives them.
| Package / target | Requirement | Relationship |
|---|---|---|
tsxEnvironment{
"local_name": "tsx",
"alias": false,
"peer_metadata": null
} | ^4.19.2 | development |
vitestEnvironment{
"local_name": "vitest",
"alias": false,
"peer_metadata": null
} | ^3.0.5 | development |
typescriptEnvironment{
"local_name": "typescript",
"alias": false,
"peer_metadata": null
} | ^5.7.2 | development |
@types/nodeEnvironment{
"local_name": "@types/node",
"alias": false,
"peer_metadata": null
} | ^22.10.0 | development |
Source distribution
{
"shasum": "261c0c25a949076b25c9ab2ea2ca3a99482a8bfa",
"tarball": "https://registry.npmjs.org/@0g-brier/protocol/-/protocol-0.1.0.tgz",
"fileCount": 38,
"integrity": "sha512-sSRRELEwY5Y5sYFzfQYEHBRlL4NVf9xJjEgnLTMr1szzIQUa+EPs7sw4nsx69vrEHhaY5hmUl6lKA8rYSEDFrw==",
"signatures": [
{
"sig": "MEUCIQCKXv4aHc/+P8gWN00vX4Rh2zwXTe67AlTkGO29vHk0PgIgIl2sgziXSqdzHtgwbTrys4o6vUfhjOgFeCwhbJqMsKU=",
"keyid": "SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"
}
],
"unpackedSize": 40638
}Observed since 20 Oct, 22:10 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
package_version:3312089d380ff582e9dd6a406410da64b07dee79c54e283dd614c5f71bfb0ee6