NeoBurger - make your NEO divisible and earn more GAS

Neoburger
12 min readOct 29, 2021

--

NeoBurger is a system of smart contracts running on Neo N3 blockchain. Utilizing Neo’s governance mechanism, NeoBurger helps NEO token holders to vote for Neo council candidates in order to maximize the GAS profit generated for the holders while playing a balancing role in Neo’s governance.

As part of this system, NeoBurger issues a new NEP-17 token named bNEO, which can be exchanged for NEO at a fixed rate of 1:1. bNEO has 8 decimals, while NEO must take integer values.

This article briefly summarizes the usage, voting strategies, and implementation code of NeoBurger.

Project Information

Project Website: https://neoburger.io/home

Dashboard: https://neoburger.github.io/dashboard/

Contract address: NPmdLGJN47EddqYcxixdGMhtkr7Z5w4Aos

Contract scripthash: 0x48c40d4666f93408be1bef038b6722404d9a4c2a

Contract codes: https://github.com/neoburger/code

Quick Guide

NeoBurger provides an alternative to manually managing your vote in Neo Governance.

  1. To begin earning with NeoBurger, you can simply send your NEO to the contract address, NPmdLGJN47EddqYcxixdGMhtkr7Z5w4Aos. You will receive the same amount of bNEO instantly in the same transaction.
  2. That’s all it takes to join the platform. Now that you have bNEO, you can sit back and relax as NeoBurger automatically accumulates your GAS rewards. By holding NEO you only share 10% of GAS generated by new blocks, but you can enjoy a share in another 80% if you participate in voting! The exact amount of GAS received each epoch varies depending on the node you vote for and its proportional vote weight. NeoBurger aims to provide the best strategies to maximize your gain from voting.
  3. Redemption (unwrapping) bNEO is just as simply, but carries a small fee for each NEO redeemed. To redeem, send 0.01 GAS to NPmdLGJN47EddqYcxixdGMhtkr7Z5w4Aos for each NEO you want to redeem. In other words, you would send 1 GAS to redeem 100 NEO. When doing so, remember to leave the data parameter in the transfer method as null, which is the default setting of most user-facing wallets. Otherwise your GAS sent to our contract will be considered as a donation to all the NeoBurger users!Additionally, remember not to send too much GAS for the number of bNEO that you have.! For example, do not send 1 GAS when you have only 88.5 bNEOs. Finally, always remember to send only multiples of 0.01 GAS to our contract! Any extra GAS sent to NeoBurger will be considered to be a donation.
  4. To claim GAS rewards, you may send 0 bNEO to NPmdLGJN47EddqYcxixdGMhtkr7Z5w4Aos. This is important to note, you do not redeem NEO by sending bNEO to NeoBurger! We will return bNEO back to you if you insist on sendingus bNEO to the contract, however this will cost you extra GAS.

The GAS reward for NeoBurger users does not only come from voting, but also other users’ payments for redeeming NEO and any donations. All GAS claims include a 1% fee. You may optionally call the Sync and Claim methods of all the agent contracts before sending your bNEO, which refreshes the rewards for all the bNEO holders, allowing you to claim the GAS rewards up to the latest minute.

As a donation, you may also send NEO and GAS to our agent contracts.

Analysis on Neo’s Governance and NeoBurger

The Neo blockchain operates using dBFT consensus. Elections for the role of consensus node are hosted on the blockchain, selected from council nodes voted in using Neo’s governance. The latest election results take effect continually, with a time period of 1 epoch, or every 21 blocks (approximately 21×15=315 seconds). A single wallet on the blockchain can vote for only 1 candidate, and each NEO in that wallet can cast 1 vote. Nodes ranked 1 to 7 are elected as consensus nodes, and 8 to 21 as council nodes.

In order to incentivize NEO holders, GAS tokens are continuously distributed for both possessing NEO and for voting for council node candidates, where the gain for voting can be much higher than simply holding NEO. In every governance epoch, a sum of GAS (for sake of simplicity let’s say 100 GAS; NOT the exact value on the real chain!) is carved up by voters of each elected council node, based on the portion of votes contributed to the node. Meanwhile, a doubled sum of GAS (200 GAS by our example setup) is distributed for each elected consensus node.

For example, if an elected consensus node has received a total of 10,000 votes, where 20 votes are contributed by you, you would receive 200*20/10,000 = 0.4 GAS for this epoch of voting. A total of 200*7 + 100*14=2800 GAS is distributed for this epoch.

After a long period of “gaming”, the voting results yielded by a large number of voters becomes relatively static, and it becomes difficult for a single voter to change the rankings. If voting does not significantly affect the game, how can the user increase their GAS earnings?

This is exactly the purpose of NeoBurger: unite NEO in a pool for maximized GAS rewards and effective governance.

NeoBurger provides constant monitoring of the latest voting results, and automatically extracts the best possible GAS profit for your NEO. As the NEO balance pooled in NeoBurger increases, the platform also brings opportunities for neglected and unelected nodes to become new council and consensus members. On the other hand, in order to maintain the validity of dBFT consensus, we can also restrict the number of agents and approved council candidates in order to limit the power of NeoBurger if it grows too dominant in the future.

With NeoBurger, GAS rewards are accumulated by bNEO token holders. With its 8 decimals and 1:1 exchange rate with NEO, bNEO opens new opportunities for the token to be used, whether as a currency or in other DeFi platforms. It maximizes capital efficiency while also simplifying the process of claiming GAS for other contracts which may accumulate bNEO during their normal operation.

Components of NeoBurger

The NeoBurger system involves a core contract and a list of agent contracts, all deployed on Neo blockchain. The core is responsible for managing agents and users’ GAS, NEO and bNEO, while the agents, controlled by the core contract, act as “wallets” casting votes for council candidates.

  • Permission management

The owner of NeoBurger core contract has the power to setAgent and allowCandidate, while the strategist of NeoBurger, who is responsible for actually casting votes with the best strategy, must obey the provided constraints of the number of agents and approved candidates. As NeoBurger evolves in the future, the owner can be a DAO, and the strategist can be a bot or a smart contract.

  • The voting system

The core contract of NeoBurger controls multiple agents which emulate multiple wallets for the purpose of voting. Utilizing trigVote and trigTransfer methods in the core contract, the strategist can adjust the voting target and NEO balance of each agent, thus achieving the best possible GAS gains.

If you would like to read the list our agents (you will need it as a keen user!), try invoking this script on Neo blockchain:

AAARwB8MBWFnZW50DBQqTJpNQCJniwPvG74INPlmRg3ESEFifVtSAAERwB8MBWFnZW50DBQqTJpNQCJniwPvG74INPlmRg3ESEFifVtSAAIRwB8MBWFnZW50DBQqTJpNQCJniwPvG74INPlmRg3ESEFifVtSAAMRwB8MBWFnZW50DBQqTJpNQCJniwPvG74INPlmRg3ESEFifVtSAAQRwB8MBWFnZW50DBQqTJpNQCJniwPvG74INPlmRg3ESEFifVtSAAURwB8MBWFnZW50DBQqTJpNQCJniwPvG74INPlmRg3ESEFifVtSAAYRwB8MBWFnZW50DBQqTJpNQCJniwPvG74INPlmRg3ESEFifVtS

Paste the script to https://neo.org/converter/index to understand it at assembly level. The script directly reads the storage of the NeoBurger core contract.

  • GAS management

There are 3 NEP-17 tokens (NEO, GAS, bNEO) used during operation of NeoBurger, but GAS management is the most tricky. GAS serves the following purposes: rewarding bNEO holders, charging the fee for redeeming NEO, and the fee paid to the owner. The latter two purposes are simply processed in OnNEP17Payment, while the logic of GAS reward management is distributed across n contracts and thus handling it is slightly more complicated.

To scrutinize the rewards, let’s first view the agent. GAS rewards are originally accumulated in agents, since they are the “wallets” directly participating in voting. Foremost, the interesting Sync method in the agent contract sends zero NEO to the agent itself. According to Neo’s source code on NEO balance changing, this operation triggers the Neo blockchain to distribute the GAS reward (including GAS for possessing NEO and voting) to the NEO holder (the agent) immediately. Then, the Claim method sends all the latest GAS rewards in the agent to the core contract to be claimed. Therefore, before sending 0 bNEO to claim your rewards, you may call Sync and Claim of all the agents to get the rewards updated to the latest minute, and increase your (and all the other users’) claimed rewards.

Now we are to focus on the core of NeoBurger. The key to GAS management lies in the value of RPS, which stands for “Reward Per NEO token Stored”, and SyncAccount, which computes the reward for users whenever bNEO is transferred.

RPS is an ever-increasing value to record each user’s historically earned GAS and compute the current GAS that all the users should have earned since the last time SyncAccount was called. As long as new GAS is sent to the core contract, RPS is refreshed for the incoming GAS, while the 1% fee is deducted. Then, SyncAccount is executed on the change of any account’s bNEO and GAS balance. Since we have put the historical RPS value in each account’s storage field PREFIXREWARD when the account was synchronized last time, the newly earned GAS of the account can be computed using the difference of the current RPS and the account’s historical RPS.

Analysis on our Strategies

(Skip this if you don't really care about maths!)

This section explains our mathematical ideas to maximize GAS rewards, provided for your reference. Note that we actually run mixed-integer nonlinear programming (MINLP) models to generate strategies for use in real operations, and we do not directly utilize any equation derived in this section. The examples here are purely didactic in purpose.

To explain our strategies, let’s illustrate the basic ideas with some examples involving 25 candidates. In this example, all the other NEO holders have decided on their votes, and we are now making our own decision.

We fetch and sort the received number of votes of each candidate in descending order (excluding our own votes), and get other NEO holders’ voting result as a vector:

V=[11389644, 3026316, 2199890, 2037751, 2031570, 2017408, 2010919, ||| 2007341, 2001625, 1002449, 1000025, 1000000, 643952, 472529, 457142, 443430, 442899, 442838, 442541, 442415, 441257, ||| 1093, 195, 180, 0]

In the vector above, each number represents the number of votes a candidate has received, and ||| are separators used only for visual convenience, splitting the ranking classes of consensus nodes and council nodes. Here we denote Vi as the i-th element in the vector V. For instance, V7==2010919. We apologize for not being able to show well-formatted mathematics, restricted by the medium we are using.

Strategy 1: Maximizing the portion of our votes

We assume that we have a (small) number of N NEOs. The first question is: what to do if we have only one wallet with N=1548 NEO, and we want to maximize our gain of GAS? Note that with such a small number of NEO, we are not able to change any class ranking by voting. We cannot push a council node to consensus, or an unelectable node to council.

Well, the problem can simply be reduced to maximizing our portion of votes. Certainly there is no benefit voting for nodes with an already large number of votes. Testing an all-in voting strategy for the 7th candidate (the last consensus node), we derive a gain of:

G7=200*1548/(2010919+1548)=0.153841

Comparatively, if we vote for 21st candidate (the last council node), we get

G21=100*1548/(441257+1548)=0.349590

Therefore, we will decide to vote for the 21st candidate. We can write down our formatted decision as the following vector:

v=[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1548, 0, 0, 0, 0]

Strategy 2: Distributing NEO among candidates

With only one wallet, we do not always reach maximal efficiency. This is because with multiple wallets, we can vote for many candidates in a single epoch. This gives our second question: what voting vector v is the best if we have an unlimited number of wallets and N=1548 NEO? Note that here, we still cannot change the class of rankings.

This question mostly requires some tedious mathematical derivations, so we are just showing our ideas for a limit of 2 wallets. It’s not difficult to find that we may only distribute our GAS between V7 and V6, or V7 and V21, or V20 and V21.

  • Case 1: G6,7: distribution between V7 and V6

In this case we should have all the elements in v be 0, except v7 and v6. Besides, we have the constraint v6=N-v7. Therefore, we are to maximize the following function:

The derivative of G6,7 with respect to v7 is:

Then the analytical solution of dG6,7/dv7=0 (we view V7 and N as constants) is:

Considering the usual case in reality that N>0 and V6≥V7≥0, we have

Then with v7 we can also solve v6=N-v7.

  • Case 2: G20,21: distribution between V20 and V21

There is no substantial difference between the mathematical derivations of G20,21 and G6,7.

The only difference is that the coefficient in the function G20,21 should be 100 instead of 200.

This replacement of the coefficient makes no difference in solving the equation of the derivative.

  • Case 3: G21,7: distribution between V21 and V7

The steps are still straightforward. With v21=N-v7, we have the equation

The solution is

Considering the reality,

The simple steps above, which involves only derivatives and solving equations, can quickly uncover the appropriate solution when only 2 wallets are available. Plugging the data from the real Neo blockchain into the analytical solutions, we find the following voting vector

v=[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 485, 1063, 0, 0, 0, 0]

with a gain of G20,21=0.349829.

In real operations we do not even have to solve equations. Convenient methods including gradient descent and branch & bound can help us find the solution to a large number of wallets without pen and paper. If we have 3 wallets, the optimal solution is

v=[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 281, 344, 923, 0, 0, 0, 0]

with a gain of G=0.349890. And the solution with an unlimited number of wallets is

v=[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 99, 249, 311, 889, 0, 0, 0, 0]

with G=0.349897. Notice that in our case, we need no more than 4 wallets to achieve global optimality. However, the gain with 4 wallets (0.349890) is only slightly larger than using only 1 wallet (0.349590), and both transferring NEO among wallets and triggering votes also costs a non-negligible amount of GAS. Consequently, there is no necessity in this case to maintain the larger number of wallets due to these additional costs.

With only 1 wallet with 1548 NEOs, we gain G/N=0.000225833 for each NEO we have.

Strategy 3: Pushing candidates to a higher class!

Now let’s consider an example where we have enough NEO to push a candidate from the council to a consensus role!

We provide the following toy example for a clear view.

V=[100,100,100,100,100, 100,99, ||| 75,5,5, 5,5,5,5,5, 5,5,5,5,5, 5, ||| 0,0,0,0]

N=50

If we simply utilize the two strategies above with 2 wallets, the solution is

v=[0, 0, 0, 0, 0, 0, 0, ||| 0, 25, 0, 0, 0, 0, 25, 0, 0, 0, 0, 0, 0, 0, ||| 0, 0, 0, 0]

G=166.666667

G/N=3.333333

But we can still vote like this

v=[0, 0, 0, 0, 0, 0, 0, ||| 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ||| 25, 25, 0, 0]

V+v=[100, 100, 100, 100, 100, 100, 99, ||| 75, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, ||| 25, 25, 0, 0]

In this case we push 2 unelectable nodes to council, and get

G=200.000000

G/N=4.000000

With such cases, the potential gain may increase dramatically. Although the situation is not achievable from the onset in NeoBurger due to the lack of NEO, we are eagerly looking forward to your participation so that together we may increase our pool of NEO. As mentioned before, restrictions can be enforced in order to maintain the validity of dBFT consensus on Neo blockchain, preventing NeoBurger from becoming an overly dominant (and potential manipulator) of governance.

This concludes our introduction to the NeoBurger project. Thank you for your attention, we look forward to your participation and to generating even better GAS yields for all Neo users.

--

--