Skip to content

Commit 647bf6b

Browse files
committed
Update currency docs
1 parent 1b953a0 commit 647bf6b

1 file changed

Lines changed: 107 additions & 20 deletions

File tree

docs/rgs_docs/RGS.md

Lines changed: 107 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -64,26 +64,113 @@ For example, to place a $1 bet, pass `"1000000"` as the amount.
6464
Currency impacts **only** the display layer; it does not affect gameplay logic.
6565

6666
## Supported Currencies
67-
68-
- USD (United States Dollar)
69-
- CAD (Canadian Dollar)
70-
- JPY (Japanese Yen)
71-
- EUR (Euro)
72-
- RUB (Russian Ruble)
73-
- CNY (Chinese Yuan)
74-
- PHP (Philippine Peso)
75-
- INR (Indian Rupee)
76-
- IDR (Indonesian Rupiah)
77-
- KRW (South Korean Won)
78-
- BRL (Brazilian Real)
79-
- MXN (Mexican Peso)
80-
- DKK (Danish Krone)
81-
- PLN (Polish Złoty)
82-
- VND (Vietnamese Đồng)
83-
- TRY (Turkish Lira)
84-
- CLP (Chilean Peso)
85-
- ARS (Argentine Peso)
86-
- PEN (Peruvian Sol)
67+
{: #supported-currencies}
68+
69+
| Currency | Abbreviation | Display | Example |
70+
| ---------------------- | ------------ | -------- | -------- |
71+
| United States Dollar | USD | $ | $10.00 |
72+
| Canadian Dollar | CAD | CA$ | CA$10.00 |
73+
| Japanese Yen | JPY | ¥ | ¥10 |
74+
| Euro | EUR || €10.00 |
75+
| Russian Ruble | RUB || ₽10.00 |
76+
| Chinese Yuan | CNY | CN¥ | CN¥10.00 |
77+
| Philippine Peso | PHP || ₱10.00 |
78+
| Indian Rupee | INR || ₹10.00 |
79+
| Indonesian Rupiah | IDR | Rp | Rp10 |
80+
| South Korean Won | KRW || ₩10 |
81+
| Brazilian Real | BRL | R$ | R$10.00 |
82+
| Mexican Peso | MXN | MX$ | MX$10.00 |
83+
| Danish Krone | DKK | KR | 10.00 KR |
84+
| Polish Złoty | PLN || 10.00 zł |
85+
| Vietnamese Đồng | VND || 10 ₫ |
86+
| Turkish Lira | TRY || ₺10.00 |
87+
| Chilean Peso | CLP | CLP | 10 CLP |
88+
| Argentine Peso | ARS | ARS | 10.00 ARS|
89+
| Peruvian Sol | PEN | S/ | S/10.00 |
90+
| Stake Gold Coin | XGC | GC | 10.00 GC |
91+
| Stake Cash | XSC | SC | 10.00 SC |
92+
93+
Here are some functions that will help you achieve the display format for the currencies.
94+
95+
```javascript
96+
/**
97+
* Available currency codes for Stake Engine
98+
*/
99+
type Currency =
100+
| 'USD' // (United States Dollar)
101+
| 'CAD' // (Canadian Dollar)
102+
| 'JPY' // (Japanese Yen)
103+
| 'EUR' // (Euro)
104+
| 'RUB' // (Russian Ruble)
105+
| 'CNY' // (Chinese Yuan)
106+
| 'PHP' // (Philippine Peso)
107+
| 'INR' // (Indian Rupee)
108+
| 'IDR' // (Indonesian Rupiah)
109+
| 'KRW' // (South Korean Won)
110+
| 'BRL' // (Brazilian Real)
111+
| 'MXN' // (Mexican Peso)
112+
| 'DKK' // (Danish Krone)
113+
| 'PLN' // (Polish Złoty)
114+
| 'VND' // (Vietnamese Đồng)
115+
| 'TRY' // (Turkish Lira)
116+
| 'CLP' // (Chilean Peso)
117+
| 'ARS' // (Argentine Peso)
118+
| 'PEN' // (Peruvian Sol)
119+
| 'XGC' // Stake US Gold Coin
120+
| 'XSC'; // Stake US Stake Cash
121+
122+
/**
123+
* Currency metadata: symbol, default decimals, symbol placement
124+
*
125+
*/
126+
const CurrencyMeta: Record<
127+
Currency,
128+
{ symbol: string; decimals: number; symbolAfter?: boolean }
129+
> = {
130+
USD: { symbol: '$', decimals: 2 },
131+
CAD: { symbol: 'CA$', decimals: 2 },
132+
JPY: { symbol: '¥', decimals: 0 },
133+
EUR: { symbol: '', decimals: 2 },
134+
RUB: { symbol: '', decimals: 2 },
135+
CNY: { symbol: 'CN¥', decimals: 2 },
136+
PHP: { symbol: '', decimals: 2 },
137+
INR: { symbol: '', decimals: 2 },
138+
IDR: { symbol: 'Rp', decimals: 0 },
139+
KRW: { symbol: '', decimals: 0 },
140+
BRL: { symbol: 'R$', decimals: 2 },
141+
MXN: { symbol: 'MX$', decimals: 2 },
142+
DKK: { symbol: 'KR', decimals: 2, symbolAfter: true },
143+
PLN: { symbol: '', decimals: 2, symbolAfter: true },
144+
VND: { symbol: '', decimals: 0, symbolAfter: true },
145+
TRY: { symbol: '', decimals: 2 },
146+
CLP: { symbol: 'CLP', decimals: 0, symbolAfter: true },
147+
ARS: { symbol: 'ARS', decimals: 2, symbolAfter: true },
148+
PEN: { symbol: 'S/', decimals: 2, symbolAfter: true },
149+
XGC: { symbol: 'GC', decimals: 2 },
150+
XSC: { symbol: 'SC', decimals: 2 },
151+
};
152+
153+
/**
154+
* Formats a number with its currency symbol, respecting default decimals and symbol placement.
155+
* The function is intended to be used for displaying balances.
156+
*/
157+
function DisplayBalance(balance: Balance): string {
158+
// Grabs the currency, if it doesn't exist in the list then it will display
159+
// the currency code behind the balance value.
160+
const meta = CurrencyMeta[balance.currency] ?? {
161+
symbol: balance.currency,
162+
decimals: 2,
163+
symbolAfter: true,
164+
};
165+
const formattedAmount = balance.amount.toFixed(meta.decimals);
166+
167+
if (meta.symbolAfter) {
168+
return `${formattedAmount} ${meta.symbol}`;
169+
} else {
170+
return `${meta.symbol}${formattedAmount}`;
171+
}
172+
}
173+
```
87174
88175
### Social Casino Currencies
89176

0 commit comments

Comments
 (0)