/
oracle.teal.tmpl
77 lines (66 loc) · 1.41 KB
/
oracle.teal.tmpl
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
// Oracle Example
//
// Author: Pablo Yabo
//
//
// It is a way to illustrate a bet between 2 addresses. One says that '0' will happen (team A wins)
// while the other says '1' will happen (team B wins)
// I did not code what will happen if none of these possibilities happen (e.g.: the oracle does not sign any message)
// In that case, half of the algos should go to each address after a specific round. There is an example 'split' that addresses something
// similar that could be used to address this possibility.
//
//
// Program flow:
// If the oracle signs a message with '0'
// the algos go to TMPL_ADDRA
// If the oracle signs a '1' the algos go to TMPL_ADDRB
//
// Parameters:
// - TMPL_ADDRA: Address beting for Team A.
// - TMPL_ADDRB: Address beting for Team B.
// - TMPL_ADDR_ORACLE: Oracle Address.
// - TMPL_FEE: maximum fee used by the limit order transaction.
txn TypeEnum
int 1 // Payment (either Algos-out in trade or Algos redeemed at timeout)
==
global GroupSize
int 1
==
&&
// if arg 0 == 0 then send to TMPL_ADDRA
arg 0
byte base64 MA==
==
txn CloseRemainderTo
addr TMPL_ADDRA
==
&&
txn Receiver
addr TMPL_ADDRA
==
&&
// if arg 0 == 1 then send to TMPL_ADDRB
arg 0
byte base64 MQ==
==
txn CloseRemainderTo
addr TMPL_ADDRB
==
&&
txn Receiver
addr TMPL_ADDRB
==
&&
||
// global verifications
&&
txn Fee
int TMPL_FEE
<=
&&
// verify oracle signature
arg 0
arg 1
addr TMPL_ADDR_ORACLE
ed25519verify
&&