Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
892ec3f
Implement QThirtyFour contract with ticket purchasing and winner sele…
N-010 Nov 8, 2025
5a6af96
Add QReservePool and QTF contract definitions with related functional…
N-010 Nov 9, 2025
785213a
Refactor QThirtyFour.h: reposition QTF2 struct definition for clarity
N-010 Nov 10, 2025
ff98674
Merge branch 'develop' into feature/2025-11-04-QThirtyFour
N-010 Nov 27, 2025
0c1e88b
Test version for QThirtyFour
N-010 Dec 4, 2025
28b7352
CalcReserveTopUp
N-010 Dec 7, 2025
53e4729
New structs
N-010 Dec 7, 2025
ed1c941
Fees
N-010 Dec 7, 2025
11ca689
Refactoring
N-010 Dec 8, 2025
821da1c
Remove profit transfer from k3 to k2 with FR enabled
N-010 Dec 9, 2025
5c4413a
Adds tests
N-010 Dec 10, 2025
6c266f8
Updates testes
N-010 Dec 11, 2025
9022807
Does not block the purchase of a ticket at a higher price
N-010 Dec 11, 2025
095556d
- src/contracts/QThirtyFour.h: ensure k4 reseed uses up-to-date QRP…
N-010 Dec 16, 2025
e2c9963
Removes SettlementLocals and aligned_storage_t
N-010 Dec 16, 2025
041433c
Updates tests
N-010 Dec 16, 2025
e0298f8
Update tests
N-010 Dec 16, 2025
c1e2829
Update tests
N-010 Dec 16, 2025
3758979
Merge branch 'refs/heads/develop' into feature/2025-11-04-QThirtyFour
N-010 Dec 16, 2025
9dca2f2
Updates index
N-010 Dec 16, 2025
094aa9d
Updates inde• Fix k=4 settlement: protect jackpot reseed from k2/k3 r…
N-010 Dec 19, 2025
f87354d
Fixes ContractVerify
N-010 Dec 19, 2025
e0c4432
Use RL::max
N-010 Dec 19, 2025
744545d
Fixes ContractVerify
N-010 Dec 19, 2025
deb0868
QDuel
N-010 Dec 25, 2025
b7d07f5
transfer dividends to RL shareholders
N-010 Dec 25, 2025
d8b83f1
Remove magic numbers
N-010 Dec 25, 2025
9d9153d
Move test file
N-010 Dec 25, 2025
baa2d1f
Changes public to protected
N-010 Dec 25, 2025
bf89227
Adds lock mechanism
N-010 Dec 26, 2025
fd642b1
Deposit
N-010 Dec 28, 2025
d2df84c
Return qus after end epoch
N-010 Jan 2, 2026
925db64
Adds check state in tick
N-010 Jan 2, 2026
79eddd6
Transferring rooms and players to the next epoch
N-010 Jan 2, 2026
23d3b9d
Create room in tick
N-010 Jan 2, 2026
39ff797
Transferring rooms and players to the next epoch
N-010 Jan 2, 2026
3565597
Base tests
N-010 Jan 3, 2026
3f7a5da
Adds tests
N-010 Jan 3, 2026
0fce190
Fixes
N-010 Jan 3, 2026
10cdae2
Add new test
N-010 Jan 3, 2026
054ab67
Adds cleanup for HashMaps
N-010 Jan 8, 2026
f363a9a
Renames Available to Allowed for SC
N-010 Jan 8, 2026
2db5e56
Merge branch 'refs/heads/develop' into feature/2025-12-25-QDuel
N-010 Jan 12, 2026
e6d19ad
Merge branch 'develop' into feature/2025-11-04-QThirtyFour
N-010 Jan 12, 2026
fde55f1
Fixes comment
N-010 Jan 12, 2026
df816f5
Merge branch 'develop' into feature/2025-11-04-QThirtyFour
N-010 Jan 14, 2026
fbb26c7
Merge branch 'develop' into feature/2025-12-25-QDuel
N-010 Jan 14, 2026
aa392d5
Update constructionEpoch
N-010 Jan 23, 2026
41c88c6
Update constructionEpoch
N-010 Jan 23, 2026
46e094b
Merge branch 'develop' into feature/2025-11-04-QThirtyFour
Franziska-Mueller Jan 26, 2026
177db71
Merge branch 'develop' into feature/2025-12-25-QDuel
N-010 Jan 26, 2026
fa65169
Fixes build and warnings
N-010 Jan 26, 2026
4dddfc5
Merge branch 'develop' into feature/2025-11-04-QThirtyFour
N-010 Jan 26, 2026
99f7268
Merge branch 'feature/2025-12-25-QDuel' into feature/2025-11-04-QThir…
N-010 Jan 26, 2026
3375d24
Fixes warnings, order
N-010 Jan 26, 2026
705d028
Merge branch 'develop' into feature/2025-11-04-QThirtyFour
N-010 Jan 26, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/Qubic.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@
<ClInclude Include="contracts\QBond.h" />
<ClInclude Include="contracts\QIP.h" />
<ClInclude Include="contracts\SupplyWatcher_old.h" />
<ClInclude Include="contracts\QReservePool.h" />
<ClInclude Include="contracts\QThirtyFour.h" />
<ClInclude Include="contracts\TestExampleA.h" />
<ClInclude Include="contracts\TestExampleB.h" />
<ClInclude Include="contracts\TestExampleC.h" />
Expand Down
6 changes: 6 additions & 0 deletions src/Qubic.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,12 @@
<ClInclude Include="contracts\RandomLottery.h">
<Filter>contracts</Filter>
</ClInclude>
<ClInclude Include="contracts\QReservePool.h">
<Filter>contracts</Filter>
</ClInclude>
<ClInclude Include="contracts\QThirtyFour.h">
<Filter>contracts</Filter>
</ClInclude>
<ClInclude Include="contracts\QDuel.h">
<Filter>contracts</Filter>
</ClInclude>
Expand Down
30 changes: 26 additions & 4 deletions src/contract_core/contract_def.h
Original file line number Diff line number Diff line change
Expand Up @@ -215,19 +215,37 @@
#define CONTRACT_STATE2_TYPE QRWA2
#include "contracts/qRWA.h"

#ifndef NO_QDUEL
#undef CONTRACT_INDEX
#undef CONTRACT_STATE_TYPE
#undef CONTRACT_STATE2_TYPE

#define QRP_CONTRACT_INDEX 21
#define CONTRACT_INDEX QRP_CONTRACT_INDEX
#define CONTRACT_STATE_TYPE QRP
#define CONTRACT_STATE2_TYPE QRP2
#include "contracts/QReservePool.h"

#undef CONTRACT_INDEX
#undef CONTRACT_STATE_TYPE
#undef CONTRACT_STATE2_TYPE

#define QDUEL_CONTRACT_INDEX 21
#define QTF_CONTRACT_INDEX 22
#define CONTRACT_INDEX QTF_CONTRACT_INDEX
#define CONTRACT_STATE_TYPE QTF
#define CONTRACT_STATE2_TYPE QTF2
#include "contracts/QThirtyFour.h"

#ifndef NO_QDUEL
#undef CONTRACT_INDEX
#undef CONTRACT_STATE_TYPE
#undef CONTRACT_STATE2_TYPE

#define QDUEL_CONTRACT_INDEX 23
#define CONTRACT_INDEX QDUEL_CONTRACT_INDEX
#define CONTRACT_STATE_TYPE QDUEL
#define CONTRACT_STATE2_TYPE QDUEL2
#include "contracts/QDuel.h"

#endif
#endif // NO_QDUEL

// new contracts should be added above this line

Expand Down Expand Up @@ -337,6 +355,8 @@ constexpr struct ContractDescription
{"QIP", 189, 10000, sizeof(QIP)}, // proposal in epoch 187, IPO in 188, construction and first use in 189
{"QRAFFLE", 192, 10000, sizeof(QRAFFLE)}, // proposal in epoch 190, IPO in 191, construction and first use in 192
{"QRWA", 197, 10000, sizeof(QRWA)}, // proposal in epoch 195, IPO in 196, construction and first use in 197
{"QRP", 199, 10000, sizeof(IPO)}, // proposal in epoch 197, IPO in 198, construction and first use in 199
{"QTF", 199, 10000, sizeof(QTF)}, // proposal in epoch 197, IPO in 198, construction and first use in 199
#ifndef NO_QDUEL
{"QDUEL", 199, 10000, sizeof(QDUEL)}, // proposal in epoch 197, IPO in 198, construction and first use in 199
#endif
Expand Down Expand Up @@ -459,6 +479,8 @@ static void initializeContracts()
#ifndef NO_QDUEL
REGISTER_CONTRACT_FUNCTIONS_AND_PROCEDURES(QDUEL);
#endif
REGISTER_CONTRACT_FUNCTIONS_AND_PROCEDURES(QRP);
REGISTER_CONTRACT_FUNCTIONS_AND_PROCEDURES(QTF);
// new contracts should be added above this line
#ifdef INCLUDE_CONTRACT_TEST_EXAMPLES
REGISTER_CONTRACT_FUNCTIONS_AND_PROCEDURES(TESTEXA);
Expand Down
62 changes: 31 additions & 31 deletions src/contracts/QDuel.h
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
using namespace QPI;

constexpr uint32 QDUEL_MAX_NUMBER_OF_ROOMS = 512;
constexpr uint64 QDUEL_MINIMUM_DUEL_AMOUNT = 10000;
constexpr uint16 QDUEL_MAX_NUMBER_OF_ROOMS = 512;
constexpr uint16 QDUEL_MINIMUM_DUEL_AMOUNT = 10000;
constexpr uint8 QDUEL_DEV_FEE_PERCENT_BPS = 15; // 0.15% * QDUEL_PERCENT_SCALE
constexpr uint8 QDUEL_BURN_FEE_PERCENT_BPS = 30; // 0.3% * QDUEL_PERCENT_SCALE
constexpr uint8 QDUEL_SHAREHOLDERS_FEE_PERCENT_BPS = 55; // 0.55% * QDUEL_PERCENT_SCALE
constexpr uint8 QDUEL_PERCENT_SCALE = 1000;
constexpr uint16 QDUEL_PERCENT_SCALE = 1000;
constexpr uint8 QDUEL_TTL_HOURS = 3;
constexpr uint8 QDUEL_TICK_UPDATE_PERIOD = 100; // Process TICK logic once per this many ticks
constexpr uint64 QDUEL_RANDOM_LOTTERY_ASSET_NAME = 19538; // RL
constexpr uint64 QDUEL_ROOMS_REMOVAL_THRESHOLD_PERCENT = 75;
constexpr uint16 QDUEL_RANDOM_LOTTERY_ASSET_NAME = 19538; // RL
constexpr uint16 QDUEL_ROOMS_REMOVAL_THRESHOLD_PERCENT = 75;

struct QDUEL2
{
Expand Down Expand Up @@ -65,7 +65,7 @@ struct QDUEL : public ContractBase
id roomId;
id owner;
id allowedPlayer; // If zero, anyone can join
uint64 amount;
sint64 amount;
uint64 closeTimer;
DateAndTime lastUpdate;
};
Expand All @@ -75,22 +75,22 @@ struct QDUEL : public ContractBase
id userId;
id roomId;
id allowedPlayer;
uint64 depositedAmount;
uint64 locked;
uint64 stake;
uint64 raiseStep;
uint64 maxStake;
sint64 depositedAmount;
sint64 locked;
sint64 stake;
sint64 raiseStep;
sint64 maxStake;
};

struct AddUserData_input
{
id userId;
id roomId;
id allowedPlayer;
uint64 depositedAmount;
uint64 stake;
uint64 raiseStep;
uint64 maxStake;
sint64 depositedAmount;
sint64 stake;
sint64 raiseStep;
sint64 maxStake;
};

struct AddUserData_output
Expand All @@ -106,9 +106,9 @@ struct QDUEL : public ContractBase
struct CreateRoom_input
{
id allowedPlayer; // If zero, anyone can join
uint64 stake;
uint64 raiseStep;
uint64 maxStake;
sint64 stake;
sint64 raiseStep;
sint64 maxStake;
};

struct CreateRoom_output
Expand All @@ -120,7 +120,7 @@ struct QDUEL : public ContractBase
{
id owner;
id allowedPlayer;
uint64 amount;
sint64 amount;
};

struct CreateRoomRecord_output
Expand All @@ -138,14 +138,14 @@ struct QDUEL : public ContractBase

struct ComputeNextStake_input
{
uint64 stake;
uint64 raiseStep;
uint64 maxStake;
sint64 stake;
sint64 raiseStep;
sint64 maxStake;
};

struct ComputeNextStake_output
{
uint64 nextStake;
sint64 nextStake;
uint8 returnCode;
};

Expand Down Expand Up @@ -229,7 +229,7 @@ struct QDUEL : public ContractBase
struct FinalizeRoom_locals
{
UserData userData;
uint64 availableDeposit;
sint64 availableDeposit;
CreateRoomRecord_input createRoomInput;
CreateRoomRecord_output createRoomOutput;
ComputeNextStake_input nextStakeInput;
Expand Down Expand Up @@ -272,7 +272,7 @@ struct QDUEL : public ContractBase
uint8 devFeePercentBps;
uint8 burnFeePercentBps;
uint8 shareholdersFeePercentBps;
uint8 percentScale;
uint16 percentScale;
uint64 returnCode;
};

Expand Down Expand Up @@ -366,7 +366,7 @@ struct QDUEL : public ContractBase

struct Withdraw_input
{
uint64 amount;
sint64 amount;
};

struct Withdraw_output
Expand All @@ -377,7 +377,7 @@ struct QDUEL : public ContractBase
struct Withdraw_locals
{
UserData userData;
uint64 freeAmount;
sint64 freeAmount;
};

struct END_TICK_locals
Expand Down Expand Up @@ -703,7 +703,7 @@ struct QDUEL : public ContractBase

locals.totalPercent = static_cast<uint16>(input.devFeePercentBps) + static_cast<uint16>(input.burnFeePercentBps) +
static_cast<uint16>(input.shareholdersFeePercentBps);
locals.totalPercent = div(locals.totalPercent, static_cast<uint16>(QDUEL_PERCENT_SCALE));
locals.totalPercent = div(locals.totalPercent, QDUEL_PERCENT_SCALE);

if (locals.totalPercent >= 100)
{
Expand Down Expand Up @@ -838,7 +838,7 @@ struct QDUEL : public ContractBase
HashMap<id, RoomInfo, QDUEL_MAX_NUMBER_OF_ROOMS> rooms;
HashMap<id, UserData, QDUEL_MAX_NUMBER_OF_ROOMS> users;
id teamAddress;
uint64 minimumDuelAmount;
sint64 minimumDuelAmount;
uint8 devFeePercentBps;
uint8 burnFeePercentBps;
uint8 shareholdersFeePercentBps;
Expand All @@ -855,9 +855,9 @@ struct QDUEL : public ContractBase
{
output.nextStake = input.stake;

if (input.raiseStep > 1)
if (input.raiseStep > 1LL)
{
if (input.maxStake > 0 && input.stake > 0 && input.raiseStep > div(input.maxStake, input.stake))
if (input.maxStake > 0LL && input.stake > 0LL && input.raiseStep > div<sint64>(input.maxStake, input.stake))
{
output.nextStake = input.maxStake;
}
Expand Down
Loading
Loading