-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypes.ts
More file actions
92 lines (86 loc) · 2.9 KB
/
Copy pathtypes.ts
File metadata and controls
92 lines (86 loc) · 2.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/** A coin in the line-up, as `ShellrPacks.coins(i)` returns it. */
export interface Coin {
token: `0x${string}`;
/** The Uniswap v3 fee tier this coin's ETH pair lives in: 500, 3000, 10000. */
poolFee: number;
/** 0 mythic, 1 legendary, 2 epic, 3 rare, 4 common. */
band: 0 | 1 | 2 | 3 | 4;
/** A dead coin is skipped by the draw but keeps its index, so history holds. */
live: boolean;
}
/**
* Everything the draw needs, read off the contract.
*
* Deliberately a plain object rather than a client: `drawPack` has to run in a
* test, in a browser and in the keeper, and only one of those three has an RPC
* URL. Fetch it once with `readDrawConfig`, then the draw is pure.
*/
export interface DrawConfig {
coins: Coin[];
/** Odds per coin band, in basis points, in band order. Totals 10_000. */
bandBps: readonly number[];
/** Odds per payout band, in basis points. Totals 10_000. */
payoutBps: readonly number[];
/** The low end of each payout band, in basis points of the stake. */
payoutLo: readonly number[];
/** The high end of each payout band. */
payoutHi: readonly number[];
/** The house's cut, taken at the till on an ETH purchase. */
feeBps: number;
/** Roughly what one draw is sized at, before the wobble. */
sliceWei: bigint;
minCoins: number;
maxCoins: number;
}
/** One line of a pack: a coin, and the ETH spent buying it. */
export interface PackDraw {
coin: Coin;
amountIn: bigint;
}
/** A pack, recomputed from its secret. */
export interface DrawnPack {
seed: `0x${string}`;
/** What was left after the fee, and what the multiplier applies to. */
stake: bigint;
fee: bigint;
count: number;
/** The multiplier in basis points. 10_000 is break-even. */
payout: number;
/** `stake * payout / 10_000` - what actually reaches the router. */
spend: bigint;
draws: PackDraw[];
}
/** A pack as the contract stores it. */
export interface Pack {
id: bigint;
buyer: `0x${string}`;
/** What the buyer sent, before the fee. */
paid: bigint;
clientSeed: `0x${string}`;
/** The queued commitment this pack consumed at the moment of purchase. */
commitment: `0x${string}`;
/** Zero until the pack is revealed. */
secret: `0x${string}`;
boughtAt: number;
settled: boolean;
refunded: boolean;
/** True when the pack was paid for in $SHELLR rather than ETH. */
inToken: boolean;
}
/** What `verifyPack` concluded, and why. */
export interface Verification {
ok: boolean;
/** Populated when `ok` is false. One line, meant to be shown to a user. */
reason?: string;
/** The recomputed pack, present whenever the secret matched its commitment. */
drawn?: DrawnPack;
}
/** The five fixed tiers, as the site sells them. */
export interface Tier {
key: "basic" | "common" | "rare" | "starter" | "premium";
label: string;
/** Price in wei. */
price: bigint;
/** The best band this tier can reach. 0 is mythic. */
bestBand: 0 | 1 | 2 | 3 | 4;
}