reward-economy-kit

Live demo, open source

Payout to points, reversals and cash-out prices, exact to the last unit

Enter an offer payout and your currency settings. Every number on the right is returned by the library's own functions from src/index.js, running in your browser with integer math only.

Integer-only BigInt math JavaScript and PHP 164 shared test vectors

Examples

Inputs

Offer and currency
Time-limited bonus
Reversal
Cash-out

Points credited

Why integers

If the offer is reversed

Cash-out

Inflation check

Library calls behind these numbers


  

Use it

npm install github:moonetix/reward-economy-kit

import { defineCurrency, parseUsd, pointsForPayout, applyReversal } from 'reward-economy-kit';

const coins = defineCurrency({ rate: '1000', userShareBps: 6000 });
const credited = pointsForPayout(parseUsd('0.85'), coins, { bonusBps: 1000 });
applyReversal({ balance: 400n, credited });

A PHP port with the same results lives in php/. The design guide in docs/guide.md covers choosing a rate, a share and a rounding mode.