Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Escrow rewards and increase number of top players rewarded #162

Open
loothero opened this issue Aug 20, 2024 · 0 comments
Open

Escrow rewards and increase number of top players rewarded #162

loothero opened this issue Aug 20, 2024 · 0 comments
Assignees

Comments

@loothero
Copy link
Member

loothero commented Aug 20, 2024

To increase the chance of players earning rewards, we should increase the number of players rewarded from 3 to 10. To achieve this, we will need to switch from the current distribution system which is doing immediate token transfers to having the contract escrow the funds.

An erc20 is typically 4 storage updates (because most SN erc20s are using u256 which requires 2 felts) so paying the top three players is 12 storage updates. If instead we simply updated the claimable balance of an adventurer id, we could pay the top 12 players for approximately the same amount of gas.

The UX of this would also be improved because instead of the user tx being a bunch of token transfers as it is now, it would be a single transfer moving the $lords into the LS contract. The LS contract would then update claimable balances internally.

Contract Changes:

  1. When processing payment, LS will transfer the 3$ in lords from the player into the contract.
  2. Add a storage for reward_balance(adventurer_id) which is incremented when player receives additional rewards, instead of doing erc20 transfers.
  3. Add a claim_rewards(Array<adventurer_id>) to the contract which allows the owner of an adventurer to claim their rewards.
  4. Add events to power client. I think we can reuse the current RewardDetails event but then we also need a "ClaimedRewards" event, with the adventurer_id

Add a "Claim all" button to the client

@loothero loothero self-assigned this Aug 20, 2024
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

No branches or pull requests

1 participant