fb9a7f4e8b
- ops: readGlobal читает vaultBalance (getTokenAccountBalance), createBet/closeBet передают bettorToken/vaultToken/tokenProgram, ensureVaultFunded наливает токен (mintTo, allowOwnerOffCurve) - pda: vaultPda([global,vault]), config:.env.new SMART_TOKEN_MINT, суммы в токен-единицах - check.ts: 14 проверок сигнатур создания create/close под новым токеновым IDL - @solana/spl-token dependency; .gitignore + node_modules/dist
673 lines
13 KiB
TypeScript
673 lines
13 KiB
TypeScript
/**
|
|
* Program IDL in camelCase format (see @anchor-lang/core convertIdlToCamelCase).
|
|
* Mirrors relayer/idl/smart_updown.json but with names camelCased, exactly as
|
|
* the runtime Program instance exposes them (methods/accounts/types).
|
|
*/
|
|
export type SmartUpdown = {
|
|
"address": "9ALsnxXNzDBv3mokngCHbruRTWUZiWR7pf7vswS1fCpf",
|
|
"metadata": {
|
|
"name": "smartUpdown",
|
|
"version": "0.1.0",
|
|
"spec": "0.1.0",
|
|
"description": "Created with Anchor"
|
|
},
|
|
"instructions": [
|
|
{
|
|
"name": "closeBet",
|
|
"discriminator": [
|
|
185,
|
|
206,
|
|
13,
|
|
184,
|
|
176,
|
|
108,
|
|
140,
|
|
107
|
|
],
|
|
"accounts": [
|
|
{
|
|
"name": "relayer",
|
|
"signer": true
|
|
},
|
|
{
|
|
"name": "bet",
|
|
"writable": true,
|
|
"pda": {
|
|
"seeds": [
|
|
{
|
|
"kind": "const",
|
|
"value": [
|
|
98,
|
|
101,
|
|
116
|
|
]
|
|
},
|
|
{
|
|
"kind": "arg",
|
|
"path": "id"
|
|
}
|
|
]
|
|
}
|
|
},
|
|
{
|
|
"name": "global",
|
|
"writable": true,
|
|
"pda": {
|
|
"seeds": [
|
|
{
|
|
"kind": "const",
|
|
"value": [
|
|
103,
|
|
108,
|
|
111,
|
|
98,
|
|
97,
|
|
108
|
|
]
|
|
}
|
|
]
|
|
}
|
|
},
|
|
{
|
|
"name": "bettor"
|
|
},
|
|
{
|
|
"name": "clock",
|
|
"address": "SysvarC1ock11111111111111111111111111111111"
|
|
},
|
|
{
|
|
"name": "vaultToken",
|
|
"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": "bettorToken",
|
|
"docs": [
|
|
"Bettor's SPL-token account; the payout is sent here."
|
|
],
|
|
"writable": true
|
|
},
|
|
{
|
|
"name": "tokenProgram",
|
|
"address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
|
|
}
|
|
],
|
|
"args": [
|
|
{
|
|
"name": "id",
|
|
"type": "u64"
|
|
},
|
|
{
|
|
"name": "exitPrice",
|
|
"type": "u64"
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"name": "createBet",
|
|
"discriminator": [
|
|
197,
|
|
42,
|
|
153,
|
|
2,
|
|
59,
|
|
63,
|
|
143,
|
|
246
|
|
],
|
|
"accounts": [
|
|
{
|
|
"name": "bettor",
|
|
"writable": true,
|
|
"signer": true
|
|
},
|
|
{
|
|
"name": "global",
|
|
"writable": true,
|
|
"pda": {
|
|
"seeds": [
|
|
{
|
|
"kind": "const",
|
|
"value": [
|
|
103,
|
|
108,
|
|
111,
|
|
98,
|
|
97,
|
|
108
|
|
]
|
|
}
|
|
]
|
|
}
|
|
},
|
|
{
|
|
"name": "bet",
|
|
"writable": true,
|
|
"pda": {
|
|
"seeds": [
|
|
{
|
|
"kind": "const",
|
|
"value": [
|
|
98,
|
|
101,
|
|
116
|
|
]
|
|
},
|
|
{
|
|
"kind": "arg",
|
|
"path": "id"
|
|
}
|
|
]
|
|
}
|
|
},
|
|
{
|
|
"name": "clock",
|
|
"address": "SysvarC1ock11111111111111111111111111111111"
|
|
},
|
|
{
|
|
"name": "systemProgram",
|
|
"address": "11111111111111111111111111111111"
|
|
},
|
|
{
|
|
"name": "bettorToken",
|
|
"docs": [
|
|
"Bettor's SPL-token account (our \"fanti\" mint); bet amount is pulled from here."
|
|
],
|
|
"writable": true
|
|
},
|
|
{
|
|
"name": "vaultToken",
|
|
"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": "tokenProgram",
|
|
"address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
|
|
}
|
|
],
|
|
"args": [
|
|
{
|
|
"name": "id",
|
|
"type": "u64"
|
|
},
|
|
{
|
|
"name": "side",
|
|
"type": "u64"
|
|
},
|
|
{
|
|
"name": "amount",
|
|
"type": "u64"
|
|
},
|
|
{
|
|
"name": "entryPrice",
|
|
"type": "u64"
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"name": "initialize",
|
|
"discriminator": [
|
|
175,
|
|
175,
|
|
109,
|
|
31,
|
|
13,
|
|
152,
|
|
155,
|
|
237
|
|
],
|
|
"accounts": [
|
|
{
|
|
"name": "admin",
|
|
"writable": true,
|
|
"signer": true
|
|
},
|
|
{
|
|
"name": "global",
|
|
"writable": true,
|
|
"pda": {
|
|
"seeds": [
|
|
{
|
|
"kind": "const",
|
|
"value": [
|
|
103,
|
|
108,
|
|
111,
|
|
98,
|
|
97,
|
|
108
|
|
]
|
|
}
|
|
]
|
|
}
|
|
},
|
|
{
|
|
"name": "systemProgram",
|
|
"address": "11111111111111111111111111111111"
|
|
}
|
|
],
|
|
"args": [
|
|
{
|
|
"name": "minAmount",
|
|
"type": "u64"
|
|
},
|
|
{
|
|
"name": "maxAmount",
|
|
"type": "u64"
|
|
},
|
|
{
|
|
"name": "multiplierBps",
|
|
"type": "u64"
|
|
},
|
|
{
|
|
"name": "expirySeconds",
|
|
"type": "i64"
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"name": "update",
|
|
"discriminator": [
|
|
219,
|
|
200,
|
|
88,
|
|
176,
|
|
158,
|
|
63,
|
|
253,
|
|
127
|
|
],
|
|
"accounts": [
|
|
{
|
|
"name": "admin",
|
|
"signer": true
|
|
},
|
|
{
|
|
"name": "global",
|
|
"writable": true,
|
|
"pda": {
|
|
"seeds": [
|
|
{
|
|
"kind": "const",
|
|
"value": [
|
|
103,
|
|
108,
|
|
111,
|
|
98,
|
|
97,
|
|
108
|
|
]
|
|
}
|
|
]
|
|
}
|
|
}
|
|
],
|
|
"args": [
|
|
{
|
|
"name": "newRelayer",
|
|
"type": "pubkey"
|
|
},
|
|
{
|
|
"name": "minAmount",
|
|
"type": "u64"
|
|
},
|
|
{
|
|
"name": "maxAmount",
|
|
"type": "u64"
|
|
},
|
|
{
|
|
"name": "multiplierBps",
|
|
"type": "u64"
|
|
},
|
|
{
|
|
"name": "paused",
|
|
"type": "u64"
|
|
},
|
|
{
|
|
"name": "expirySeconds",
|
|
"type": "i64"
|
|
}
|
|
]
|
|
}
|
|
],
|
|
"accounts": [
|
|
{
|
|
"name": "bet",
|
|
"discriminator": [
|
|
147,
|
|
23,
|
|
35,
|
|
59,
|
|
15,
|
|
75,
|
|
155,
|
|
32
|
|
]
|
|
},
|
|
{
|
|
"name": "global",
|
|
"discriminator": [
|
|
167,
|
|
232,
|
|
232,
|
|
177,
|
|
200,
|
|
108,
|
|
114,
|
|
127
|
|
]
|
|
}
|
|
],
|
|
"events": [
|
|
{
|
|
"name": "betClosed",
|
|
"discriminator": [
|
|
122,
|
|
20,
|
|
157,
|
|
254,
|
|
221,
|
|
0,
|
|
39,
|
|
129
|
|
]
|
|
},
|
|
{
|
|
"name": "betCreated",
|
|
"discriminator": [
|
|
32,
|
|
153,
|
|
105,
|
|
71,
|
|
188,
|
|
72,
|
|
107,
|
|
114
|
|
]
|
|
}
|
|
],
|
|
"errors": [
|
|
{
|
|
"code": 6000,
|
|
"name": "paused",
|
|
"msg": "Operation is paused"
|
|
},
|
|
{
|
|
"code": 6001,
|
|
"name": "notAdmin",
|
|
"msg": "Only the admin can perform this action"
|
|
},
|
|
{
|
|
"code": 6002,
|
|
"name": "notRelayer",
|
|
"msg": "Only the relayer is allowed to close bets"
|
|
},
|
|
{
|
|
"code": 6003,
|
|
"name": "amountBelowMin",
|
|
"msg": "Amount below the allowed minimum"
|
|
},
|
|
{
|
|
"code": 6004,
|
|
"name": "amountAboveMax",
|
|
"msg": "Amount above the allowed maximum"
|
|
},
|
|
{
|
|
"code": 6005,
|
|
"name": "invalidSide",
|
|
"msg": "Invalid side value"
|
|
},
|
|
{
|
|
"code": 6006,
|
|
"name": "betAlreadyFinalized",
|
|
"msg": "Bet is already finalized"
|
|
},
|
|
{
|
|
"code": 6007,
|
|
"name": "notExpired",
|
|
"msg": "Bet cannot be closed before expiry"
|
|
},
|
|
{
|
|
"code": 6008,
|
|
"name": "betIdMismatch",
|
|
"msg": "Bet id mismatch"
|
|
},
|
|
{
|
|
"code": 6009,
|
|
"name": "insufficientVault",
|
|
"msg": "Payout exceeds vault solvency"
|
|
}
|
|
],
|
|
"types": [
|
|
{
|
|
"name": "bet",
|
|
"docs": [
|
|
"Open bet. `amount` is in token base units (decimals = 6), not lamports."
|
|
],
|
|
"type": {
|
|
"kind": "struct",
|
|
"fields": [
|
|
{
|
|
"name": "amount",
|
|
"type": "u64"
|
|
},
|
|
{
|
|
"name": "betTime",
|
|
"type": "i64"
|
|
},
|
|
{
|
|
"name": "expireTime",
|
|
"type": "i64"
|
|
},
|
|
{
|
|
"name": "entryPrice",
|
|
"type": "u64"
|
|
},
|
|
{
|
|
"name": "exitPrice",
|
|
"type": "u64"
|
|
},
|
|
{
|
|
"name": "side",
|
|
"type": "u64"
|
|
},
|
|
{
|
|
"name": "status",
|
|
"type": "u64"
|
|
},
|
|
{
|
|
"name": "bettor",
|
|
"type": "pubkey"
|
|
}
|
|
]
|
|
}
|
|
},
|
|
{
|
|
"name": "betClosed",
|
|
"type": {
|
|
"kind": "struct",
|
|
"fields": [
|
|
{
|
|
"name": "bet",
|
|
"type": "pubkey"
|
|
},
|
|
{
|
|
"name": "exitPrice",
|
|
"type": "u64"
|
|
},
|
|
{
|
|
"name": "userWon",
|
|
"type": "bool"
|
|
},
|
|
{
|
|
"name": "payout",
|
|
"type": "u64"
|
|
},
|
|
{
|
|
"name": "status",
|
|
"type": "u64"
|
|
}
|
|
]
|
|
}
|
|
},
|
|
{
|
|
"name": "betCreated",
|
|
"type": {
|
|
"kind": "struct",
|
|
"fields": [
|
|
{
|
|
"name": "bet",
|
|
"type": "pubkey"
|
|
},
|
|
{
|
|
"name": "bettor",
|
|
"type": "pubkey"
|
|
},
|
|
{
|
|
"name": "side",
|
|
"type": "u64"
|
|
},
|
|
{
|
|
"name": "amount",
|
|
"type": "u64"
|
|
},
|
|
{
|
|
"name": "betTime",
|
|
"type": "i64"
|
|
},
|
|
{
|
|
"name": "expireTime",
|
|
"type": "i64"
|
|
},
|
|
{
|
|
"name": "entryPrice",
|
|
"type": "u64"
|
|
}
|
|
]
|
|
}
|
|
},
|
|
{
|
|
"name": "global",
|
|
"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": [
|
|
{
|
|
"name": "counter",
|
|
"type": "u64"
|
|
},
|
|
{
|
|
"name": "minAmount",
|
|
"type": "u64"
|
|
},
|
|
{
|
|
"name": "maxAmount",
|
|
"type": "u64"
|
|
},
|
|
{
|
|
"name": "multiplierBps",
|
|
"type": "u64"
|
|
},
|
|
{
|
|
"name": "expirySeconds",
|
|
"type": "i64"
|
|
},
|
|
{
|
|
"name": "paused",
|
|
"type": "u64"
|
|
},
|
|
{
|
|
"name": "admin",
|
|
"type": "pubkey"
|
|
},
|
|
{
|
|
"name": "relayer",
|
|
"type": "pubkey"
|
|
}
|
|
]
|
|
}
|
|
}
|
|
],
|
|
"constants": [
|
|
{
|
|
"name": "betSeed",
|
|
"type": "bytes",
|
|
"value": "[98, 101, 116]"
|
|
},
|
|
{
|
|
"name": "globalSeed",
|
|
"type": "bytes",
|
|
"value": "[103, 108, 111, 98, 97, 108]"
|
|
},
|
|
{
|
|
"name": "vaultSeed",
|
|
"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]"
|
|
}
|
|
]
|
|
};
|