Misc
Access other information types
All the below calls give you access to public information of the contract
Get APR amount
Based on the params APR, startDate, endDate, amount get an on-chain verification of the real yielded amount
let res = await stakingContract.getAPRAmount({
APR : 5,
startDate : moment().add(1, 'minutes'),
endDate : moment().add(10, 'minutes'),
amount : 100
});
console.log(res); // 0.000008561643835616
Get total tokens needed to deposit to ensure all APR of all products
Based all products available, this function gives you access to all tokens that are needed to be deposited to ensure the smooth functioning of your ERC20 Staking Contract
let res = await stakingContract.getTotalNeededTokensForAPRbyAdmin();
console.log(res); // 0.000085616438356164
Always verify the getTotalNeededTokensForAPRbyAdmin is covered
This is easy to verify, since you just need to confirm always that :
*availableTokens > getTotalNeededTokensForAPRbyAdmin
Note : If this does not happen subscriptions to products will always fail and be reverted and not successful
Get total tokens that held by the contract
Access all tokens held by the smart contract (all that are in that contract) - independent on the origin
let res = await stakingContract.heldTokens();
Get all tokens available (not locked) to future subscriptions
Access all tokens that are available to be Yielded by a staking.
*Example : For a yield of 5% anual, which means 5 Tokens in 100 Tokens deposit in an anual timeframe, the contract has to have at least 5 Tokens in tokens Available, not locked*
let res = await stakingContract.availableTokens();
Get all locked tokens (attached to current subscriptions)
Access how much tokens are currently attached to current subscriptions for the future yield
let res = await stakingContract.futureLockedTokens();
Deposit Tokens to match the Products Maximium APR
Deposit enough APR Tokens to ensure the functioning of the system and to confirm all users can receive their staking amount
/* Get Amount Needed */
let neededTokensAmount = await stakingContract.getTotalNeededTokensForAPRbyAdmin();
/* Send ERC20 Tokens to cover the Yield */
let res = await stakingContract.depositAPRTokensByAdmin({amount : neededTokensAmount});
Updated almost 4 years ago