feat: migrate smart-updown contract to SPL-token (фантики)

- create_bet: escrow фантиков с bettor на vault (PDA[global,vault]) через anchor_spl::token
- close_bet: выплата фантиков из vault на bettor (CPI с signer_seeds vault)
- state/constants: comments про единицы (token units decimals=6), + VAULT_SEED
- IDL регенерирован (idl/ + relayer/idl/) с аккаунтами bettor_token/vault_token/token_program
- тесты обновлены под токен (10/10 + doctest)
This commit is contained in:
Caffeine
2026-09-09 22:00:41 +03:00
parent ff2289e68d
commit 45d64d45a7
10 changed files with 1106 additions and 120 deletions
+139 -18
View File
@@ -10,7 +10,14 @@
{
"name": "close_bet",
"discriminator": [
2
185,
206,
13,
184,
176,
108,
140,
107
],
"accounts": [
{
@@ -57,15 +64,54 @@
}
},
{
"name": "bettor",
"docs": [
"CHECK: recipient must be the bet's bettor and is validated in the handler."
],
"writable": true
"name": "bettor"
},
{
"name": "clock",
"address": "SysvarC1ock11111111111111111111111111111111"
},
{
"name": "vault_token",
"docs": [
"Program-owned token vault: PDA([GLOBAL_SEED, VAULT_SEED]); payouts are paid out from here."
],
"writable": true,
"pda": {
"seeds": [
{
"kind": "const",
"value": [
103,
108,
111,
98,
97,
108
]
},
{
"kind": "const",
"value": [
118,
97,
117,
108,
116
]
}
]
}
},
{
"name": "bettor_token",
"docs": [
"Bettor's SPL-token account; the payout is sent here."
],
"writable": true
},
{
"name": "token_program",
"address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
}
],
"args": [
@@ -82,7 +128,14 @@
{
"name": "create_bet",
"discriminator": [
1
197,
42,
153,
2,
59,
63,
143,
246
],
"accounts": [
{
@@ -136,6 +189,49 @@
{
"name": "system_program",
"address": "11111111111111111111111111111111"
},
{
"name": "bettor_token",
"docs": [
"Bettor's SPL-token account (our \"fanti\" mint); bet amount is pulled from here."
],
"writable": true
},
{
"name": "vault_token",
"docs": [
"Program-owned token vault: PDA([GLOBAL_SEED, VAULT_SEED]); bet amounts are escrowed here."
],
"writable": true,
"pda": {
"seeds": [
{
"kind": "const",
"value": [
103,
108,
111,
98,
97,
108
]
},
{
"kind": "const",
"value": [
118,
97,
117,
108,
116
]
}
]
}
},
{
"name": "token_program",
"address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
}
],
"args": [
@@ -160,7 +256,14 @@
{
"name": "initialize",
"discriminator": [
0
175,
175,
109,
31,
13,
152,
155,
237
],
"accounts": [
{
@@ -214,7 +317,14 @@
{
"name": "update",
"discriminator": [
3
219,
200,
88,
176,
158,
63,
253,
127
],
"accounts": [
{
@@ -380,10 +490,9 @@
"types": [
{
"name": "Bet",
"serialization": "bytemuck",
"repr": {
"kind": "c"
},
"docs": [
"Open bet. `amount` is in token base units (decimals = 6), not lamports."
],
"type": {
"kind": "struct",
"fields": [
@@ -488,10 +597,13 @@
},
{
"name": "Global",
"serialization": "bytemuck",
"repr": {
"kind": "c"
},
"docs": [
"Global game state.",
"",
"All money-related fields are denominated in **SPL-token base units**",
"(our \"fanti\" token, decimals = 6), not in lamports:",
"`min_amount`/`max_amount` bound a bet amount in token units."
],
"type": {
"kind": "struct",
"fields": [
@@ -541,6 +653,15 @@
"name": "GLOBAL_SEED",
"type": "bytes",
"value": "[103, 108, 111, 98, 97, 108]"
},
{
"name": "VAULT_SEED",
"docs": [
"Vault PDA seed: the token vault lives at PDA([GLOBAL_SEED, VAULT_SEED]).",
"It cannot reuse GLOBAL_SEED alone — that PDA address is the `global` state account itself."
],
"type": "bytes",
"value": "[118, 97, 117, 108, 116]"
}
]
}
}