codingenchanter725 / SMAK-Staking

Staking Project

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Contributors Forks Discord Telegram LinkedIn Twitter Reddit portfolio_view

Smartlink

Smartlink addresses one of the biggest challenges in the global marketplace: ‘Need to Trust,’ by introducing decentralized escrow services and payments processing based on Tezos' institutional-grade smart contracts that suppress the need for buyers and sellers to trust each other.

Smartlink aims to provide a user-centered escrow solution to secure online and face-to-face transactions while broadening payments acceptance options through integrated cryptocurrencies.

Smartlink proposes a new method to initiate commercial transactions by offering Trust-As-A-Service to incentivize commitment and eliminate the trust deficit in the global marketplace.

SMAK staking

Variables

Name Type Description
admin TAddress Address of the admin
reserve TAddress Address of the token reserve to pay the stakings
userStakeLockPack UserStakeLockPack See the schema below
StakeLock TRecord Structure of a locked staking
StakeLock.timestamp TTimestamp Timestamp of the begining of the staking
StakeLock.rate TNat Rate of the staking
StakeLock.value TNat Amount of tokens staked
userStakeFlexPack TBig_map(TNat, TMap(TAddress, StakeFlex)) Storage of all the flex stakings
StakeFlex TRecord Structure of a flex staking
StakeFlex.timestamp TTimestamp Timestamp of the begining of the staking
StakeLock.reward TNat Rewards for the past period of the staking
StakeLock.value TNat Amount of tokens staked
stakingOptions TMap(TNat, stakingOption) Storage of all the staking packs
stakingOption TRecord Structure of a staking option
stakingOption.minStake TNat Minimum amount of tokens that can be sent in one transaction
stakingOption.maxStake TNat Maximum amount of tokens that can be sent in one transaction
stakingOption.stakingPeriod TInt Duration of a staking
stakingOption.stakingPercentage TNat Rate of the staking
votingContract TAddress Address of the voting contract that will be implemented in the future
stakingHistory TMap(TTimestamp, TInt) Mapping of the number of SMAK staked at a timestamp
addressId TBig_map(TAddress, TNat) Mapping of addresses to which part of the userStakeFlexPack big map it's in
maxValuesNb TNat Number of address each case of the userStakeFlexPack big map can contain (to prevent from gas exhaustion when updating the staking flex rate)

UserStakeLockPack

This is the structure of the nested maps userStakeLockPack UserStakeLockPack's structure

Functions

Setters

updateMetaData:

@sp.entry_point
def updateMetadata(self,params):
        sp.set_type(params, sp.TRecord(url = sp.TBytes))

Updates the contract's metadata. Only the admin can use this function.

updateReserve:

@sp.entry_point
def updateReserve(self, params):
    sp.set_type(params, sp.TRecord(reserve=sp.TAddress))

Sets the reserve address.

updateAdmin:

@sp.entry_point
def updateAdmin(self, params):
    sp.set_type(params, sp.TRecord(admin=sp.TAddress))

Sets the admin address of the contract.

updateContract:

@sp.entry_point
def updateContract(self, params):
    sp.set_type(params, sp.TRecord(contract = sp.TAddress))

Sets the address of the token contract.

updateVotingContract:

@sp.entry_point
def updateVotingContract(self, params):
    sp.set_type(params, sp.TRecord(contract = sp.TAddress))

Sets the adress of the voting contract.

is_voting_contract:

@sp.sub_entry_point
    def is_voting_contract(self, contract):

Verifies if the address in param is the voting contract address.

createStakingOption:

@sp.entry_point
def createStakingOption(self, params):
    sp.set_type(params, sp.TRecord(_id = sp.TNat, rate = sp.TNat, _max = sp.TNat, _min = sp.TNat, duration = sp.TInt).layout(("_id as id", ("rate", ("_max as max", ("_min as min", "duration"))))))

Function used to create a stacking pack (Period / APY). Only Admin or voting contract can use this function.

updateStakingOptionRate:

@sp.entry_point
def updateStakingOptionRate(self, params):
    sp.set_type(params, sp.TRecord(_id = sp.TNat, rate = sp.TNat).layout(("_id as id", "rate")))

Sets the new rate of the staking pack.

updateStakingOptionDuration:

@sp.entry_point
def updateStakingOptionDuration(self, params):
    sp.set_type(params, sp.TRecord(_id = sp.TNat, duration = sp.TInt).layout(("_id as id", "duration")))

Sets the new duration of the staking pack.

updateStakingOptionMax:

@sp.entry_point
def updateStakingOptionMax(self, params):
    sp.set_type(params, sp.TRecord(_id = sp.TNat, _max = sp.TNat).layout(("_id as id", "_max as max")))

Sets the new max amount per transaction.

updateStakingOptionMin:

@sp.entry_point
def updateStakingOptionMin(self, params):
    sp.set_type(params, sp.TRecord(_id = sp.TNat, _min = sp.TNat).layout(("_id as id", "_min as min")))

Sets the new min per transaction

updateMaxValuesNb:

@sp.entry_point
def updateMaxValuesNb(self, params):
    sp.set_type(params, sp.TRecord(value = sp.TNat))

Sets the new maximum value of staking flex per big map case.

Core functions

addStaker:

def addStaker(self, addr):
    sp.if (~self.data.userStakeLockPack.contains(addr) & ~self.data.addressId.contains(addr)):
        self.data.numberOfStakers += 1

Internal function that will add a staker to the staker map (for the dashboard graph)

delStaker:

def delStaker(self, addr):
        sp.if (~self.data.userStakeLockPack.contains(addr) & ~self.data.addressId.contains(addr)):
            self.data.numberOfStakers -= 1

Internal function that will remove a staker to the staker map (for the dashboard graph)

stakeLock:

@sp.entry_point
def stakeLock(self, params):
    sp.set_type(params, sp.TRecord(pack = sp.TNat, amount = sp.TNat))

Stakes the amount of tokens using the parameters of the pack specified. Will initialize the map for the user if it's his first staking.

stakeFlex:

@sp.entry_point
def stakeFlex(self, params):
    sp.set_type(params, sp.TRecord(amount = sp.TNat))

Stakes the amount of tokens using the flex pack parameters. Will initialize the staking for the user if it's his first staking. Else it will only update the staking.

updateStakingFlex:

def updateStakingFlex(self, id_, addr, amount):

Internal function that updates a staking flex for a user if it already exists (adds the amount to the stake and computes the rewards for the last period).

unstakeLock:

@sp.entry_point
def unstakeLock(self, params):
    sp.set_type(params, sp.TRecord(pack=sp.TNat, index=sp.TNat))

Unstakes the specified stake. If the stake period isn't finished the user won't receive his rewards.

unlockWithReward:

@sp.sub_entry_point
def unlockWithReward(self, params):
    sp.set_type(params, sp.TRecord(pack = sp.TNat, index = sp.TNat))

Internal function called by unstakeLock if the staking period has finished. Will send the user his tokens back + the rewards.

unlockWithoutReward:

 @sp.sub_entry_point
def unlockWithoutReward(self, params):
    sp.set_type(params, sp.TRecord(index = sp.TNat, pack = sp.TNat))

Internal function called by unstakeLock if the staking period has not finished. Will only send the user his tokens back.

unstakeFlex:

@sp.entry_point
def unstakeFlex(self, params):
    sp.set_type(params, sp.TRecord(amount = sp.TNat))

Computes the reward for the last staking period, sets the timestamp to the actual timestamp, updates the value of the stake and sends the user his tokens back.

claimRewardFlex:

@sp.entry_point
def claimRewardFlex(self):

Sends the rewards available to the user.

getReward:

 def getReward(self, params):
        sp.set_type(params, sp.TRecord(start=sp.TTimestamp, end = sp.TTimestamp, value= sp.TNat, rate=sp.TNat))

Internal function that will compute the rewards for a period.

updateRedeemedRewards:

def updateRedeemedRewards(self, addr, value):

Internal function that will update the redeemed rewards for a user.

updateStakingFlexRate:

@sp.entry_point
def updateStakingFlexRate(self, params):
    sp.set_type(params, sp.TRecord(id_=sp.TNat))

Function that will compute the rewards for all the staking flex in the big map case and will update the old cached flex rate to the new one. Only the admin can call this function.

SMAK Lottery

Variables

Name Type Description
admin TAddress Address of the admin
reserve TAddress Address of the token reserve to pay the lottery winners
FA12TokenContract TAddress Address of the token contract
limit TNat Maximum number of tickets sold before picking a winner
tickets TBig_map(TNat, TAddress) Mapping of the ticket number to the address of its owner
id TNat Number of the current ticket to be sold
previous_winners TBig_map(TNat, TRecord(winner : TAddress, ticket : TNat)) Mapping of the round to the winner and his ticket number
price TNat Price of a ticket
winning_price TNat Amount of SMAK to be won
round_num TNat Current round number
paused TBool Bool to pause the contract

Functions

buyTicket:

@sp.entry_point
def buyTicket(self, params):
    sp.set_type(params, sp.TNat)

Function that will sell the number of tickets entered as a parameter to a user.

selectWinner:

@sp.entry_point
def selectWinner(self, params):
    sp.verify(sp.sender == self.data.admin, Error.AccessDenied)
    sp.set_type(params, sp.TNat)

Function that will select a winner with the number given by the admin. Only the admin can call this function.

resetLottery:

def resetLottery(self):
    self.data.id = sp.nat(0)
    sp.for i in sp.range(0, self.data.limit):
        del self.data.tickets[i]

Function that will delete all the tickets.

pause:

@sp.entry_point
def pause(self, params):
    sp.set_type(params, sp.TUnit)
    sp.verify(sp.sender == self.data.admin, Error.AccessDenied)
    self.data.paused = sp.bool(True) 

Function that will pause the contract. Only the admin can call this function.

About

Staking Project


Languages

Language:Vue 55.3%Language:TypeScript 22.5%Language:SCSS 7.8%Language:Python 6.6%Language:JavaScript 4.5%Language:LigoLANG 3.1%Language:HTML 0.2%Language:Shell 0.1%