Stake any amount of ETH
Used to stake any amount of ETH into the pool.
This can only be executed by calling a smart contract method:
Copy cast send $INTEGRATION_CONTRACT_ADDRESS "stake()" --value $AMOUNT_TO_STAKE_IN_ETH
Get the amount of shares from integration contract by wallet
Used to find the amount of shares for a given wallet from the integration contract
Using the smart contract view methods
Copy cast call $INTEGRATION_CONTRACT_ADDRESS "balanceOf(address)(uint256)" $USER_ADDRESS
Get the current value of a user's staked position
Allows you to obtain the value (in ETH) of the users current staked position
For example, consider the scenario where a user staked 12 ETH several months ago. Every time they visit your app, you want to showcase the current value of the staked position accounting for the accrued value from staking rewards over time.
You can simply query the smart contract with the users wallet.
Using the smart contract view methods
Copy cast call $INTEGRATION_CONTRACT_ADDRESS "balanceOfUnderlying(address)(uint256)" $USER_ADDRESS
Using TheGraph queries
Query
Copy {
erc20(id: "INTEGRATION_CONTRACT_ADDRESS" ) {
totalSupply
totalUnderlyingSupply
balances(where:{ staker : "USER_ADDRESS" }) {
sharesBalance
}
}
}
Example query
Copy {
"data" : {
"erc20" : {
"totalSupply" : "23608675969602594618589" ,
"totalUnderlyingSupply" : "23752224529858293552006" ,
"balances" : [
{
"sharesBalance" : "499892147748515755"
}
]
}
}
}
Results
Copy {
"data" : {
"erc20" : {
"totalSupply" : "23608675969602594618589" ,
"totalUnderlyingSupply" : "23752224529858293552006" ,
"balances" : [
{
"sharesBalance" : "499892147748515755"
}
]
}
}
}
Calculate valueunderlyingBalanceValue = ((sharesBalance * totalUnderlyingSupply) / totalSupply)
Retrieving all the deposit actions of a user
TheGraph queries
Liquid20C, Liquid20A & Native20
Copy {
erc20(id: "INTEGRATION_CONTRACT_ADDRESS" ) {
deposits(where:{ staker : "USER_ADDRESS" },orderBy:createdAt,orderDirection:desc) {
hash
depositAmount
mintedShares
}
}
}
Copy {
"data" : {
"erc20" : [
{
"deposits" : [
{
"hash" : "0xb644b754d59c3693fa12a8be796bbc31db2f922964b581603c5e020b5aebd591" ,
"depositAmount" : "10000000000" ,
"mintedShares" : "9981371152"
} ,
{
"hash" : "0xd2aa2b95f27f38e57a1cf4064110f1c5771252249b16fcf55c4d6aa74bc7340e" ,
"depositAmount" : "10000000000" ,
"mintedShares" : "9982062545"
} ,
{
"hash" : "0xf640ef3b91de25f76792debb41f2f26f0886a79f3fccb4fffff372487dac22fa" ,
"depositAmount" : "100000000000" ,
"mintedShares" : "99821696059"
} ,
{
"hash" : "0xaa212b98a0c44f57ebedc50337c24853739f07164a7681a1eb6b2fc1753e8f91" ,
"depositAmount" : "100000000000" ,
"mintedShares" : "99822049624"
} ,
{
"hash" : "0xad2ad5026fda650861ea6ab0e278e39150812fa74a623879cbb3263dd157b07c" ,
"depositAmount" : "100000000000" ,
"mintedShares" : "99822049624"
} ,
{
"hash" : "0x8a5f98769d52b05bd37ef66db8976981d67e50f7401269cf2ffd2801d583ddc1" ,
"depositAmount" : "100000000000" ,
"mintedShares" : "99822049623"
}
]
}
]
}
}
Last updated 7 months ago