Wrap sKLIMA
Why would you wrap sKLIMA?
wsKLIMA is an index-adjusted wrapper for sKLIMA. Some people may find this useful for accounting purposes. Unlike an sKLIMA balance, a wsKLIMA balance will not increase over time.
When wsKLIMA is unwrapped, holders receive sKLIMA based on the latest (ever-increasing) index, so the total yield is the same.
What is the index?
The Index refers to the amount of KLIMA tokens accumulated if a staker had staked 1 KLIMA token from the first rebasing epoch.
The index can be used to track or check an sKLIMA position by marking down the index number at the point that KLIMA is staked, and that sKLIMA is unstaked.
Similarly, the index can be used to define a wsKLIMA position. This is achieved by dividing the index number when wsKLIMA is unwrapped by the index at the time of wrapping.
Wrapping sKLIMA via Solidity
Requirements
Get some MATIC to pay for gas fees
Get some sKLIMA tokens to wrap
Get the contract addresses from here:
1. Transfer sKLIMA to your contract
You can transfer sKLIMA tokens to your contract via web3.js and JSON RPC (like using Metamask) or choose to implement a deposit and stake function that calls KLIMA's standard ERC20 approve and transfer functions to allow your contract to transfer users' KLIMA tokens to your contract and stake it.
2. Approving the wsKLIMA contract
Your contract's function calls the sKLIMA token's standard ERC20 approve function to allow the wsKLIMA contract to withdraw sKLIMA tokens from your contract. In the example below, an interface named IERC20 to interact with the sKLIMA token smart contact.
3. Wrapping sKLIMA tokens
Your contract's function calls the wsKLIMA contract's wrap function. In the example below, an interface named IwsKLIMA is used to interact with the wsKLIMA contract.
Once wrapped, you will receive wsKLIMA tokens proportional to the amount of sKLIMA divided by the current index. to represent the staked KLIMA. sKLIMA is an ERC20 and can transferred using the IERC20 interface.
Example
Unwrapping wsKLIMA via Solidity
Requirements
Get some MATIC to pay for gas fees
Get some wsKLIMA tokens to unwrap
The following assumes your contract already holds wsKLIMA. You can follow the same steps above to transfer wsKLIMA to your contract if necessary.
1. Unwrapping wsKLIMA tokens
Your contract's function calls the wsKLIMA contract's unwrap function. In the example below, an interface named IwsKLIMA is used to interact with the wsKLIMA contract.
Once unwrapped, you will receive a proportional amount of sKLIMA multiplied by the current index. sKLIMA is an ERC20 and can transferred using the IERC20 interface.
Example
Last updated
Was this helpful?