Agency
This contract oversees the referral mechanism in Dyson Finance. When a user deposits in Pair and is registered in the referral system, they receive additional DYSON tokens as a reward. Each user in the referral system is designated as an Agent, and the referral of an Agent is referred to as the child of that Agent.
rescueERC20
Parameters:
tokenAddress
address
Address of the ERC20 token.
to
address
Address that will receive the rescued tokens.
amount
uint
Amount of tokens to be rescued.
addController
Adds a new address as a controller. Only callable by the owner. A controller possesses the authority to invoke the adminAdd
function within the Agency contract.
Parameters:
_controller
address
Address to be added as a controller.
removeController
Removes an address from the list of controllers. Only callable by the owner.
Parameters:
_controller
address
Address to be removed from controllers.
adminAdd
Adds a new child agent to the root agent. This child becomes a 1st generation agent who owns a tier1 NFT. Only callable by the owner or controllers.
Parameters:
newUser
address
Address of the new agent.
Return Values:
id
uint
Id of the new agent.
transfer
Transfers agent data to a different user, only callable by the AgentNFT contract. It's important to note that the agent cannot be transferred again until the cooldown time, calculated as (generation + 1) * TRANSFER_CD
, is completed. This cooldown time is ten times longer than the cooldown time for swapping SP to DYSON.
Parameters:
from
address
Previous owner of the agent.
to
address
User who will receive the agent.
id
uint
Index of the agent to be transferred.
Return Values:
None
bool
True if the transfer is successful.
register
This function is a critical component that allows users to join the referral system by providing an invite code (onceSig
) and the signature of their referrer (parentSig
). This function facilitates the growth of the referral network by establishing relationships between referrers and referees within the system. Let's break down the key aspects of the register
function:
Validation: The function checks whether the current timestamp is before the specified deadline to ensure the invite code is still valid.
Agent Check: Verifies that the user calling the function does not already have an existing agent in the referral system.
One-Time Code Verification: Validates the
onceSig
(invite code) by recovering the address associated with the provided signature. Ensures the invite code has not been used before.Referrer Signature Verification: Validates the
parentSig
(referrer's signature) to confirm the legitimacy of the referrer. Notice that when the parent is a contract wallet, theparentSig
provided will be the address of the parent instead of a signature.Referrer Information Retrieval: Retrieves the referrer's agent information, including their ID, from the system.
Registration Delay Check: Ensures that the referrer has passed the registration delay before being able to refer new users.
New Agent Creation: Creates a new agent for the registering user, establishing a parent-child relationship with the referrer.
One-Time Code Deactivation: Marks the invite code as used to prevent its reuse.
Reward Transfer (Optional): If the user sent some Ether along with the registration, it is transferred to the referrer as a reward.
Note
The function makes use of cryptographic techniques, including signature verification (
ecrecover
), to ensure the security and integrity of the registration process.The function also involves an optional Ether transfer as a reward to the referrer for bringing in a new user.
Parameters:
parentSig
bytes
Referrer's signature or referrer's address.
onceSig
bytes
Invite code.
deadline
uint
Deadline of the invite code.
Return Values:
id
uint
Id of the new agent.
sign
Parent on-chain pre-sign for a referral code. This function serves as an on-chain pre-signing mechanism specifically designed for contract wallets. A contract wallet is required to provide its address as an argument to the digest parameter when invoking the sign function.
Parameters:
digest
bytes32
Digest of the referral code.
userInfo
Retrieves user's agent data.
Parameters:
_owner
address
User's address.
Return Values:
ref
address
Parent agent's owner address.
gen
uint
Generation of user's agent.
getAgent
Retrieves agent data by user's id.
Parameters:
id
uint
Id of the user.
Return Values:
owner
address
User's agent owner address.
gen
uint
Generation of user's agent.
birth
uint
Timestamp when the agent registered.
parentId
uint
Id of the agent's parent.
childrenId
uint[]
Ids of the agent's children.
Last updated