Skip to content
This repository has been archived by the owner on Mar 18, 2019. It is now read-only.

Writing LRC Fee Burning Contracts

mfinestone edited this page Oct 4, 2018 · 9 revisions

Writing LRC Fee Burning Contracts - ETHSF Prize

Introduction

In Loopring Protocol 2.0 we have introduced a new fee model. One of the many changes is that a part of the fee earned by wallets and miners is reserved to burn LRC (we call this the burn rate). If the fee is paid in LRC this is straighforward, we simply burn the LRC directly. If the fee is paid in a non-LRC token however, we first have to sell the non-LRC token for LRC so the LRC can be burned.

Task for ETHSF ($3500 in LRC for best solution)

Write a contract that sells the non-LRC tokens and burns the resulting LRC. You are free to sell the tokens in any way you like. Of course, we'd like to burn as much LRC as possible with these funds. Selling the funds should also be completely trustless. Anyone will be able to trigger the function that is used to burn the LRC.

Some ideas:

Implementation overview

As a part of the Loopring smart contracts, we have a dedicated contract holding all fees called FeeHolder. Contracts can be authorized to withdraw the part of the fees that needs to be burned. It's up to these contracts to implement a way to sell the non-LRC tokens in some way for LRC. The BurnManager currently can only burn LRC directly.

Getting started

Your folder should look like this:

+ MyFolder
  - protocol2
  - protocol2-js
  • Compile the loopring smart contracts.

See the readme at the protocol 2 repository.

npm install
npm run compile
  • Try to run the BurnManager tests to see if everything is working correctly.
npm run testrpc
npm run test -- transpiled/test/testBurnManager.js
  • Modify burn() in TaxManager.sol