staked ELX
  • Welcome to stELX
  • GUIDES
    • Stake
  • GOVERNANCE
    • Overview
    • Operators
    • Operator Onboarding
    • Community Codes
  • TECHNICAL
    • Integrate
    • Contract Addresses
    • Audits
    • Security
  • INFO
    • What is Elixir (ELX)
    • Community tools & links
    • Transparency and Risks
Powered by GitBook
On this page
  • Minting (Staking)
  • Community Codes
  • Burning (Unstaking)
  • ABIs
Export as PDF
  1. TECHNICAL

Integrate

How to integrate staking and unstaking stELX on your frontend or from smart contracts.

Minting (Staking)

  1. Send a transaction to the overseer with the function signature mint(address to, uint256 communityCode)(uint256) , which returns the amount of StakedELX (as of right now this will always be the same amount as minted). There is also another function signature mint(address to) that is callable if you do not have a community code to stake to. The to address is the address the stELX tokens will be minted to and the communityCode is the code representing the validator you want those tokens to be designated too. The amount minted will be the amount of ELX included in the value of the transaction.

  2. This will mint stELX to the user.

function Example_Mint() public {
    address user = address(0x1234);
    vm.deal(user, 10 ether);

    vm.startPrank(user); // using the private key of the user
    uint256 mintedShares = minter.mint{value: 10 ether}(user, "<validator code>"); // mint 10 stHYPE
    
    minter.mint{value: 10 ether}(user); // mint another 10 stELX to user
}

Community Codes

These will be whitelisted at the smart contract level for approved partners.

These are passed as a param to the staking and unstaking functions in order to track ELX flow and rewards throughout the ecosystem.

Burning (Unstaking)

Burning is has the potential to be a multistep process depending on the amount of free (unstaked) tokens available in the protocol. We will always keep a small float of the total supply unstaked in order to instantly fulfil burns, but if it is the burn of a large amount of tokens or there is high outflow volume steps become a two-step process. You can access the amount of free tokens (if a burn has less than this amount it will be processed atomically) by calling maxRedeemable()

  1. Approve the overseer with the amount of stELX tokens that you want to unstake.

  2. Call burnAndRedeemIfPossible(address to, uint256 amount, string communityCode) to burn amount of tokens from communityCode the redeemed ELX will go to the to address. Note: if you do not want to burn from a community code leave the field a blank string (""). maxRedeemable() of these tokens will be burned instantly and sent to the to address, and the rest will be processed in a burn request. This function returns the burnID which will be used to redeem the burn once it has been finished.

  3. If this was a large burn or there was not enough tokens, wait some time until redeemable(uint256 burnID is true

  4. Call redeem(uint256 burnID) which will send the pending ELX to the to address specified in the previous transaction

function Example_Burn() public {
    uint256 decimals = 10 ** 18;

    address user = address(0x1234); // set up with a balance of 10 stELX
    vm.startPrank(user);
    
    // 1. approve 10 stELX (18 decimals)
    stELX.approve(overseer, 10 * decimals); 

    // 2. redeem the max amount of tokens instantly available
    uint256 maxRedeemable = burner.maxRedeemable(); // 5 ELX
    uint256 burnID = burner.burnAndRedeemIfPossible(address(user), 10 ether, "<validator code>");
    require(address(user).balance = 5 ether, "user should have 5 ELX now");
    
    // 3. wait some time
    
    // ...
    
    // 4. redeem the burn for the rest of the tokens
    burner.redeem(burnID);
    require(address(user).balance = 10, "user should have all of their ELX now");
}

ABIs

PreviousCommunity CodesNextContract Addresses

Last updated 2 months ago

21KB
burner.json
14KB
minter.json
29KB
overseeer.json
35KB
stelx.json
18KB
wstELX.json