Skip to main content

ClayMatic.sol

View Methods

getExchangeRate()

Returns the current exchange rate accounting for any slashing or donations and a boolean value indicating whether a slashing event has occurred (Note: Slashing is not currently enabled on Polygon).

function getExchangeRate() returns (uint256, bool)

getNodes()

Returns Information regarding nodes that protocol supports and respective staked amount on each node.

function getNodes() returns (StakingNode[], uint256[])

StakingNode Structure:

NameTypeDescription
iduint256Validator node Id
validatorAddressaddressValidator node address
pointsuint256Points allocated to validator
stakeduint256Total amount of stake on validator

getLiquidityCsToken()

Returns total liquidity of csToken currently available in the contract.

function getLiquidityCsToken() returns (uint256)

getMaxWithdrawAmountCs()

Returns maximum amount of csToken that can be withdrawn in a given transaction.

function getMaxWithdrawAmountCs() returns (uint256)

getEpoch()

Returns current epoch in Polygon's StakeManager contract & Withdrawal delay.

function getEpoch() returns (uint256, uint256)

funds()

Returns all protocol's funds.

function funds() returns (Funds)

Funds Structure:

NameTypeDescription
currentDeposituint256Total number of tokens deposited by users
stakedDeposituint256Total number of tokens currently staked on nodes
accruedFeesuint256Total fees accrued by protocol

fees()

Returns all types protocol's fees. Protocol uses 2 point decimal precision(i.e base unit is 10000)

function fees() returns (Fees)

Fees Structure:

NameTypeDescription
depositFeeuint256Fee percent on deposit
withdrawFeeuint256Fee percent on withdraw
instantWithdrawFeeuint256Fee percentage on instant withdraw
rewardFeeuint256Fee percent on accrued rewards

withdrawOrders()

Returns information regarding withdraw order for given user address and oderId.

function withdrawOrders(address, uint256) returns (WithdrawOrder)

WithdrawOrder Structure:

NameTypeDescription
amountuint256Total amount of tokens unstaked from validators by user
feeuint256Fee percentage to be paid by the user
orderIdsuint256[]List of order ids from the validators
nodeIdsuint256[]List of corresponding nodeIds

Methods

deposit()

Sends underlying tokens to contract and mints csToken to msg.sender.

function deposit(uint256 amountToken) returns (bool)

Note: Requirements:

  • msg.sender must have approved amountToken of Token to this contract.

Parameters:

NameTypeDescription
_amountTokenuint256Amount of underlying tokens sent from msg.sender to this contract

Returns:

Bool confirmation of transaction.

depositDelegate()

Sends Token to contract and mints csToken to delegator.

function deposit(uint256 amountToken, uint256 delegator) returns (bool)

Note: Requirements:

  • msg.sender must have approved amountToken of Token to this contract.

Parameters:

NameTypeDescription
amountTokenuint256Amount of Token sent from msg.sender to this contract
delegatoraddressAddress of entity receiving csToken

Returns:

Bool confirmation of transaction.

withdraw()

Burns csToken from user, un-stake respective amounts of tokens from validator node(s) and creates a withdraw order.

function withdraw(uint256 amountCs) returns (uint256)

Note: Requirements:

  • msg.sender must have approved amountCs of csToken to this contract.

Parameters:

NameTypeDescription
amountCsuint256Amount of csToken to be withdrawn

Returns:

Withdraw Order ID.

claim()

Checks the validity of given orderIds, claims tokens from the corresponding validators nodes and transfers the amount to user.

function claim(uint256[] orderIds) returns (bool)

Note: Requirements:

  • All orderIds must have fulfilled the un-bonding period.

Parameters:

NameTypeDescription
orderIdsuint256[]Array of withdraw order ids issued at withdraw()

Returns:

Bool confirmation of transaction.

instantWithdraw()

Burns csToken from user and instantly returns Token to user.

function instantWithdraw(uint256 amountCs) returns (bool)

Note: Requirements:

  • msg.sender must have approved amountCs of csToken to this contract.
  • Contract must have sufficient liquidity.

Parameters:

NameTypeDescription
amountCsuint256Amount of csToken to be withdrawn

Returns:

Bool confirmation of transaction.

autoBalance()

Claims rewards, transfers fees to vault and stakes into nodes

function autoBalance() returns (bool)

Returns:

Bool confirmation of transaction.