-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathquottery.h
160 lines (139 loc) · 4.51 KB
/
quottery.h
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
#pragma once
#include "structs.h"
// SC structs
struct QuotteryjoinBet_input
{
uint32_t betId;
int numberOfSlot;
uint32_t option;
uint32_t _placeHolder;
};
struct QuotteryissueBet_input
{
uint8_t betDesc[32];
uint8_t optionDesc[32*8];
uint8_t oracleProviderId[32*8];
uint32_t oracleFees[8];
uint32_t closeDate;
uint32_t endDate;
uint64_t amountPerSlot;
uint32_t maxBetSlotPerOption;
uint32_t numberOfOption;
};
struct qtryBasicInfo_output
{
uint64_t feePerSlotPerHour; // Amount of qus
uint64_t gameOperatorFee; // 4 digit number ABCD means AB.CD% | 1234 is 12.34%
uint64_t shareholderFee; // 4 digit number ABCD means AB.CD% | 1234 is 12.34%
uint64_t minBetSlotAmount; // amount of qus
uint64_t burnFee; // percentage
uint64_t nIssuedBet; // number of issued bet
uint64_t moneyFlow;
uint64_t moneyFlowThroughIssueBet;
uint64_t moneyFlowThroughJoinBet;
uint64_t moneyFlowThroughFinalizeBet;
uint64_t earnedAmountForShareHolder;
uint64_t paidAmountForShareHolder;
uint64_t earnedAmountForBetWinner;
uint64_t distributedAmount;
uint64_t burnedAmount;
uint8_t gameOperator[32];
static constexpr unsigned char type()
{
return RespondContractFunction::type();
}
};
struct getBetInfo_input
{
uint32_t betId;
};
struct getBetInfo_output
{
// meta data info
uint32_t betId;
uint32_t nOption; // options number
uint8_t creator[32];
uint8_t betDesc[32]; // 32 bytes
uint8_t optionDesc[8*32]; // 8x(32)=256bytes
uint8_t oracleProviderId[8*32]; // 256x8=2048bytes
uint32_t oracleFees[8]; // 4x8 = 32 bytes
uint32_t openDate; // creation date, start to receive bet
uint32_t closeDate; // stop receiving bet date
uint32_t endDate; // result date
// Amounts and numbers
uint64_t minBetAmount;
uint32_t maxBetSlotPerOption;
uint32_t currentBetState[8]; // how many bet slots have been filled on each option
char betResultWonOption[8];
char betResultOPId[8];
static constexpr unsigned char type()
{
return RespondContractFunction::type();
}
};
struct getBetOptionDetail_input
{
uint32_t betId;
uint32_t betOption;
};
struct getBetOptionDetail_output
{
uint8_t bettor[32*1024];
static constexpr unsigned char type()
{
return RespondContractFunction::type();
}
};
struct getActiveBet_output
{
uint32_t count;
uint32_t betId[1024];
static constexpr unsigned char type()
{
return RespondContractFunction::type();
}
};
struct getActiveBetByCreator_input
{
uint8_t creator[32];
};
struct getActiveBetByCreator_output
{
uint32_t count;
uint32_t betId[1024];
static constexpr unsigned char type()
{
return RespondContractFunction::type();
}
};
struct publishResult_input
{
uint32_t betId;
uint32_t winOption;
};
#pragma pack(1)
struct cancelBet_input
{
uint32_t betId;
};
#pragma pop()
void quotteryIssueBet(const char* nodeIp, int nodePort, const char* seed, uint32_t scheduledTickOffset);
void quotteryPrintBetInfo(const char* nodeIp, const int nodePort, int betId);
void quotteryPrintBasicInfo(const char* nodeIp, const int nodePort);
void quotteryJoinBet(const char* nodeIp, int nodePort, const char* seed, uint32_t betId, int numberOfBetSlot, uint64_t amountPerSlot, uint8_t option, uint32_t scheduledTickOffset);
void quotteryPrintBetOptionDetail(const char* nodeIp, const int nodePort, uint32_t betId, uint32_t betOption);
void quotteryPrintActiveBet(const char* nodeIp, const int nodePort);
void quotteryPrintActiveBetByCreator(const char* nodeIp, const int nodePort, const char* identity);
void quotteryCancelBet(const char* nodeIp, const int nodePort, const char* seed, const uint32_t betId, const uint32_t scheduledTickOffset);
void quotteryPublishResult(const char* nodeIp, const int nodePort, const char* seed, const uint32_t betId, const uint32_t winOption, const uint32_t scheduledTickOffset);
// Get the basic information of quottery
void quotteryGetBasicInfo(const char* nodeIp, const int nodePort, qtryBasicInfo_output& result);
// Core function
void quotteryGetActiveBet(const char* nodeIp, const int nodePort, getActiveBet_output& result);
// Get detail information of a bet ID
void quotteryGetBetInfo(
const char* nodeIp,
const int nodePort,
int betId,
getBetInfo_output& result);
void unpackQuotteryDate(uint8_t& _year, uint8_t& _month, uint8_t& _day, uint8_t& _hour, uint8_t& _minute, uint8_t& _second, uint32_t data);