TreasuryLib

This Solidity library is called TreasuryLib, which contains various functions related to the treasury management. Let's break down the variables, events, functions, and internal functions present in this library:

Variables

Storage (struct)

A struct that holds the storage data for the Treasury library.

Fields

NameTypeDescription

accountant

address

The address of the accountant contract.

sabt

address

The address of the SABT contract.

claims

mapping

Mapping of UID to the number of claims.

totalClaim

uint32

The total number of claims.

settlementId

uint32

The ID of the settlement.

Constants

USER_META_ID

The ID of the meta representing a user.

INVESTOR_META_ID

The ID of the meta representing an investor.

FOUNDATION_META_ID

The ID of the meta representing a foundation.

DENOM

The denominator used for calculations.

Errors

MembershipNotOwned

An error that indicates the membership is not owned by the sender.

InvalidMetaId

An error that indicates an invalid meta ID for a given UID.

EraNotPassed

An error that indicates the era has not yet passed.

NoTotalMP

An error that indicates there is no total membership point for the era.

NoTotalTokens

An error that indicates there are no total tokens for the era.

ShareLimitExceeded

An error that indicates the share limit for claims has been exceeded.

Functions

_checkMembership

Checks if the sender owns the membership with the given UID and meta ID.

Parameters

ParameterTypeDescription

self

Storage

The Storage struct.

uid_

uint32

The UID of the membership.

metaId_

uint16

The ID of the meta.

_checkEraPassed

Checks if the given era has already passed.

Parameters

ParameterTypeDescription

self

Storage

The Storage struct.

nthEra_

uint32

The nth era to check.

_exchange

Exchanges membership points for rewards.

Parameters

ParameterTypeDescription

self

Storage

The Storage struct.

token

address

The address of the token to receive as reward.

nthEra

uint32

The nth era of the points to exchange.

uid

uint32

The UID of the member.

point

uint64

The amount of membership points to exchange.

_claim

Claims rewards for a given era and member.

Parameters

ParameterTypeDescription

self

Storage

The Storage struct.

token

address

The address of the token to claim.

nthEra

uint32

The nth era of the rewards to claim.

uid

uint32

The UID of the member.

_settle

Settles the rewards for a given era and member.

Parameters

ParameterTypeDescription

self

Storage

The Storage struct.

token

address

The address of the token to settle.

nthEra

uint32

The nth era of the rewards to settle.

uid

uint32

The UID of the member.

_setClaim

Sets the number of claims for a given UID.

Parameters

ParameterTypeDescription

self

Storage

The Storage struct.

uid

uint32

The UID of the member.

num

uint32

The number of claims.

_setSettlement

Sets the ID of the settlement.

Parameters

ParameterTypeDescription

self

Storage

The Storage struct.

uid

uint32

The ID of the settlement.

_getReward

Calculates the reward amount for a given token, era, and membership point.

Parameters

ParameterTypeDescription

self

Storage

The Storage struct.

token

address

The address of the reward token.

nthEra

uint32

The nth era of the membership point.

point

uint256

The amount of membership points.

Returns the calculated reward amount.

_getClaim

Calculates the claim amount for a given token, era, and member.

Parameters

ParameterTypeDescription

self

Storage

The Storage struct.

token

address

The address of the reward token.

uid

uint32

The UID of the member.

nthEra

uint32

The nth era of the claim.

Returns the calculated claim amount.

_getSettlement

Calculates the settlement amount for a given token and era.

Parameters

ParameterTypeDescription

self

Storage

The Storage struct.

token

address

The address of the reward token.

nthEra

uint32

The nth era of the settlement.

Returns the calculated settlement amount.

Last updated