Skip to content

Conversation

@dylanjeffers
Copy link
Contributor

@dylanjeffers dylanjeffers commented Dec 10, 2025

Adds /prizes endpoint that takes wallet, and signature, verifies user spent the correct amount of coin and sent to the right address, and then randomly gives user a claimed_prize

Copy link
Member

@raymondjacobson raymondjacobson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

flow looks super good. i think table design could probably be a bit simpler

"go.uber.org/zap"
)

type WheelSpinRequest struct {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we maybe generalize this to just "prizes" instead of wheel spin?

tables being

prizes
claimed_prizes

@@ -0,0 +1,22 @@
BEGIN;

CREATE TABLE IF NOT EXISTS wheel_spin_configs (
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this table isn't super necessary. The prizes themselves could refer directly to the mint and I think we'd save ourselves some work / complexity

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makes sense, the idea here was if we have new wheels for same mint but different spin amounts. but you think it's fine to not build that in for now?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah i don't think we need to have it but i see your point. i'm okay doing it but maybe instead of wheels we could call it a prize group or something

}
defer prizeRows.Close()

var prizes []Prize
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice

FROM wheel_spin_prizes
WHERE config_id = $1 AND is_active = true
ORDER BY id
`, configID)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the config isn't a necessary step really if we put amount and mint into the prizes table, which I think would be a bit simpler

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah down to go with this. a thought though: to determine which prizes are active in the wheel and what there percentages are, should that actually be defined in the config table or also just do in the prizes table?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think it doesn't need to be that generalized yet but fair enough. i'm okay either way

}

// Get active prizes for this config
// Use writePool to ensure we see the latest data (important in tests, and safe in production)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is the write pool needed? the replication is super fast and idt we need it for the tests?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agreed not needed

&balanceChange.Account,
)
} else {
// If mint not provided, find any spend transaction for this wallet
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think prob best to always assert having a signature

Copy link
Member

@raymondjacobson raymondjacobson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm can go either way on the tables but i think we should stay away from "wheel" as the name for these prize groups or prize pools

@dylanjeffers dylanjeffers changed the title Add wheel spin API Add prize API Dec 10, 2025
@dylanjeffers dylanjeffers merged commit ac6e605 into main Dec 10, 2025
5 checks passed
@dylanjeffers dylanjeffers deleted the add-wheel-spin branch December 10, 2025 22:24
yakMintAddress = "ZDaUDL4XFdEct7UgeztrFQAptsvh4ZdhyZDZ1RpxYAK"
yakClaimAmount = 2000000000 // 2 YAK with 9 decimals - amount required to claim a prize
yakAirdropAmount = 1000000000 // 1 YAK with 9 decimals - amount awarded in coin airdrop prizes
prizeReceiverAddress = "EHd892m3xNWGBuAXnafavqcFjXXUZp9bGecdSDNP2SLR"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what address is this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just a random wallet I own for testing purposes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants