警告:您可能成为了企图假冒本网站内容的目标。 我们检测到该网站被IFRAME包裹,这意味着与EOS Canada无关的人试图向您展示他们的内容与我们的内容相关,可能为了让您相信他们与EOS Canada有关。 我们与任何试图这样做的组织都没有联系,它也没有受到我们的认可



WARNING: you may have been the target of an attempt to misrepresent the content of this site. We detected that the site was wrapped in an IFRAME, which means that someone else, not associated with EOS Canada, attempted to show you their content combined in some way with ours, possibly to make you believe they are associated with EOS Canada. We are not associated with, and do not endorse, any organization attempting to do this.
background-flotant-top-right-01

Blog: EOS Block Producer Tips & News

background-flotant-top-left-01

REX - A Technical Understanding from the Source Code

May 02, 2019 / by Josh Kauffman

After much anticipation, REX has finally been released! We’ve seen many great tutorials on *how* to use REX, but we haven’t seen many explaining the many actions you can use when interacting with REX. EOS Canada wanted to take a dive through the code and help educate the EOS community.

There are eight terms we’d like to first define to ensure that we all understand them, as they are very important to any REX discussion.
 

Mature - When you purchase REX tokens, you will be unable to trade them back into EOS tokens for at least four days. During this period, those tokens are referred to as maturing. You can have up to four different maturity dates at any given time. Also, if you elect to use a savings bucket, when you want to move REX tokens out of your savings, it will also take four days before they have matured, thus making them accessible.

Four days - All calculations are based off of 00:00 UTC of the following day. So if a user purchases REX tokens at 16:00 UTC today, they will only become available to sell back into EOS (considered matured) four days and eight hours from now. So whenever people say “four days”, it’s actually four days from the next 00:00 UTC.

30 days - Loans that are taken out to borrow either CPU or Network resources are open for 30 days. Only a user who is borrowing those resources (paying a fee into REX) needs to keep track of the 30-day time period. A user who is leasing out their tokens’ resources (earning value from REX) only needs to be aware of the four-day maturing period.

Savings - To add a layer of security, a savings bucket was added, allowing users to store their REX tokens without them maturing. An example of where this would be useful is if your account has separate active and owner permissions and the keys controlling your active permission became compromised. If your REX tokens were already matured, the person who has control over your active permission will be able to trade your REX tokens into EOS and make off with those as well. If they were in your savings account, you’d be able to utilize your owner permission to change your active permission, and cancel the pending maturity of your savings bucket.

REX fund - To interact with REX, you’ll need to first have EOS tokens in your REX fund. EOS tokens are held in your REX fund, not REX tokens.

Voting requirement - One participation requirement that was placed on users who want to rent out their resources through REX is that they must either be voting for at least 21 Block Producers or have delegated their vote to a proxy.

Liquidity crunch - If there isn't enough EOS tokens in the unlent pool to cover a requested withdrawal, then a “liquidity crunch” occurs. This means that all withdrawal orders will be queued, waiting for either new EOS tokens to enter the REX pool, or for resource loans to expire. There is no risk of a user not getting back their EOS tokens, they may just need to wait up to 30 days (at most) to get them.

Market rates - REX is powered by a Bancor relay, which means that the price is not determined by users setting their own pricing, rather by the system itself calculating a market rate for the given ratios of EOS and REX tokens in the pool. This is why it is impossible to determine a rate of return, or a renewal price for a loan, as everything is determined at the time of purchase and the time of sale based on the current conditions.

We’d also like to highlight two important things that we’ve seen asked a lot. The way that the value of EOS-to-REX is determined means that the amount of EOS that you put in will always be equal to, or lower than the amount of EOS returned when you choose to trade your REX tokens. This means that you can never lose EOS by holding REX, you can only gain (or at worst break even).

The other point to highlight is that airdrops can choose to respect your REX balance or not when it comes time to take a snapshot of accounts. This means that there is no guarantee that the tokens you hold in REX will be included, and will be dependent on the developers of each airdrop.

We’re going to now review all of the actions that you might call while interacting with REX, and explain each one.

buyrex Once you have EOS tokens in your REX fund, you may use the buyrex action to trade your EOS tokens for REX tokens.
closerex This action will first check to see if your account has any REX tokens, any open loans for either CPU or Network bandwidth, or any EOS tokens in your REX fund. If those checks all come back empty, then you can free up any RAM being used to store data for your account in the eosio.rex contract.
cnclrexorder If you have an unfilled sellrex order for your account, this will cancel that order.
consolidate Since REX tokens require 4 days before they mature, you can have up to 4 buckets open at a time, each consuming their own amount of RAM. If you would like to free up RAM and have them all consolidated into a single bucket that will then mature 4 days from this point, you could use the consolidate action.
defcpuloan If you had put aside some EOS tokens to fund the renewal of an open CPU loan before it expires and wish to defund some or all of those tokens, you would call this action.
defnetloan If you had put aside some EOS tokens to fund the renewal of an open Network loan before it expires and wish to defund some or all of those tokens, you would call this action.
deposit This action allows you to deposit EOS tokens into your REX fund.
fundcpuloan If you have an open CPU loan and would like to renew it at its time of expiry, you need to allocate EOS from your REX fund towards that loan using the loan ID.
fundnetloan If you have an open Network loan and would like to renew it at its time of expiry, you need to allocate EOS from your REX fund towards that loan using the loan ID.
mvfrsavings If you have placed REX tokens into your savings bucket using the mvtosavings action, you will need to call this action to begin the 4 day countdown before being able to trade them for EOS tokens.
mvtosavings If you would like to move some (or all) of your REX tokens into the savings bucket, you would call this action. It will check to ensure that you have enough REX tokens not transferring into your savings bucket to complete any sellrex orders you may have open. You do not need to wait for REX tokens to mature before moving them into your savings bucket.
rentcpu This action should be called only by users who wish to rent CPU bandwidth from the REX pool. You can assign the received CPU bandwidth to any account of your choosing, and can also immediately add EOS tokens to fund a renewal of that loan upon expiration within that same action.
rentnet This action should be called only by users who wish to rent Network resources from the REX pool. You can assign the received Network bandwidth to any account of your choosing, and can also immediately add EOS tokens to fund a renewal of that loan upon expiration within that same action.
rexexec Whenever most actions associated to REX are called, they also run 2 “maintenance actions”. These are actions where the contract updates the REX pool, processes any sell orders, processes any loans, moves tokens from eosio.names into eosio.rex, etc… All of these are found in the runrex action (which cannot be called directly by a user).
sellrex Users would use this action to sell their REX tokens for EOS tokens. If there is currently a liquidity crunch, then your sell order would be placed in queue. If you have previously opened a sell order, calling this action again will combine the two sell orders.
unstaketorex This action allows users to purchase REX using their tokens which are currently staked to either CPU or Network resources.
updaterex This action allows a user to update their vote weight to include any proceeds to which they are entitled if they were to sell their REX into EOS at this moment. A user can achieve the same result by just recasting their vote.
withdraw To remove EOS tokens in a user’s REX fund, they will use the withdraw action.

We hope that this helps deepen your understanding of REX and how it works. Make sure to review some of the great walkthroughs of the many User Interfaces already available to you, so that you can have the best “REX-perience” possible! If you have any questions, please contact us in the EOS Canada Telegram channel, or feel free to join the EOS REX Telegram channel.

Topics: Education, EOSIO, resources, developer, REX

Josh Kauffman

Written by Josh Kauffman

Josh wants to educate those around him. Since learning of cryptocurrency, he’s become a missionary -- urging those around him to understand this technology that will underpin tomorrow’s world. His latest passion is the crypto space, looking to be part of those who lead the drive towards Web 3.0.

dfuse - Template Blog Post Thumbnail-5

Building on EOSIO?

Develop your project with dfuse, the most powerful blockchain API.

BUILD NOW

cubes-solid

ABCs of EOS

A glossary of terms that every EOS user should know.

MORE