Registry Pool

Registry Pool


UPDATE 8/20/2024

wethRegistry.sol - Updates

1. Changes to distributeBalancetoSlot

The function distributeBalancetoSlot now distributes funds in an 80:20 ratio:

  • 80% of the funds are allocated as rewards based on user steps.
  • 20% of the funds are allocated as rewards based on the rbFactor of the user's shoe.

This change is crucial as it introduces a dual reward mechanism, rewarding both user activity and the attributes of their digital items (shoes).

2. Updated Slot Struct

The Slot struct has been updated with two new members to support the reward distribution changes:

struct Slot {
    uint256 slotId;
    uint256 numberOfUsers;
    address[] users;
    uint256[] rbfs;       // Array storing rbFactors for users in the slot
    uint256 rewardFund;    // Fund allocated for step-based rewards
    uint256 rbRewardFund;  // Fund allocated for rbFactor-based rewards
}
  • rbfs: An array that holds the rbFactor values of the users in the slot.
  • rbRewardFund: The amount of funds dedicated to rewards based on rbFactor.

These two new members allow for a separate fund distribution based on the user's shoe rbFactor.

END UPDATE


WethRegistry.sol

Overview

The WethRegistry contract manages user slots and distributes rewards based on the reserve balance. It uses Chainlink Automation to ensure timely distribution of rewards.

Inheritance

The contract inherits from:

  • AutomationCompatibleInterface: Provides compatibility with Chainlink Automation.

Constructor

No constructor is defined in this contract.

Structs

  • Slot: Represents a slot with attributes like slot ID, number of users, users, and reward fund.

Mappings

  • s_slot: Maps slot IDs to Slot structs.
  • s_userSlotId: Maps user addresses to their slot IDs.

Functions

_createSlot

function _createSlot(uint256 _slotId) internal
  • Parameters:
    • _slotId: The ID of the slot to create.
  • Description: Creates a new slot with the given ID.

_addUserToSlot

function _addUserToSlot(uint256 _slotId, address _user) public
  • Parameters:
    • _slotId: The ID of the slot to add the user to.
    • _user: The address of the user to add.
  • Description: Adds a user to the specified slot. If the slot is full, a new slot is created.

_updateSlotCountAndCreateNewSlot

function _updateSlotCountAndCreateNewSlot() internal
  • Description: Updates the slot count and creates a new slot if the current slot is full.

_updateReserveBalance

function _updateReserveBalance(uint256 _amount) public
  • Parameters:
    • _amount: The amount to add to the reserve balance.
  • Description: Updates the reserve balance by adding the specified amount.

setRandomSlotData

function setRandomSlotData(uint256 _slotId, uint256 _numberOfUsers, address[] memory _users, uint256 _rewardFund) public
  • Parameters:
    • _slotId: The ID of the slot.
    • _numberOfUsers: The number of users in the slot.
    • _users: The array of user addresses.
    • _rewardFund: The reward fund for the slot.
  • Description: Sets random data for a slot.

distributeBalanceToSlot

function distributeBalanceToSlot() public
  • Description: Distributes the reserve balance to all slots. This function is called by Chainlink Automation.

checkUpkeep

function checkUpkeep(bytes calldata /* checkData */) external view override returns (bool upkeepNeeded, bytes memory /* performData */)
  • Description: Checks if upkeep is needed based on the distribution timestamp.

performUpkeep

function performUpkeep(bytes calldata /* performData */) external override
  • Description: Performs upkeep by updating the distribution timestamp.

View Functions

  • _getReserveBalance(): Returns the reserve balance.
  • _getSlotData(uint256 _slotId): Returns the data for a specific slot.
  • _getUserSlotId(address _user): Returns the slot ID for a specific user.
  • _getCurrentNumberOfSlots(): Returns the current number of slots.
  • rewardAllotmentToDifferentSlots(): Returns the reward allotment to different slots.