liquity / beta

Pre-release of Liquity Protocol smart contracts, intended for bug bounty inspection
28 stars 22 forks source link

Liquity Bounty 1 “Redemption Arbitrage Bot” #2

Closed 0xKolten closed 3 years ago

0xKolten commented 3 years ago

Redemption Arbitrage Bot

Join our Discord here.

Prize Bounty

Challenge Description

Liquity's newest contracts are available on Kovan test net and can be found here. A UI for the contracts can be found here.

Liquity has a redemption mechanism that allows any holder to exchange LUSD for ETH at face value, as if 1 LUSD is exactly worth $1. That is, for x LUSD you get x Dollars worth of ETH in return irrespective of the current LUSD:USD price. (See our FAQ and the README section for more information on redemptions, and refer to this explanation for more details on Liquity’s “hint” mechanism and its use in redemptions.)

However, a redemption fee is charged on the redeemed amount using the baseRate state variable in Liquity, which is dynamically updated. The system thus deducts a percentage given by (baseRate + 0.5%) from the ETH that is sent to the redeemer. The baseRate increases with each redemption, and decays exponentially according to the time passed since the last fee event - i.e. the last redemption or issuance of LUSD. The issuance of LUSD only triggers a time decay, so it can only reduce, but not increase the baseRate. The decay factor used in the protocol corresponds to a half-life of 12 hours. See this section of our Readme for more information.

The challenge consists of writing a bot that constantly monitors the ETH:USD Chainlink price and the LUSD:ETH rate using Uniswap v2 TWAP on Kovan (feel free to set up the trading pool yourself as part of this challenge) and automatically acts upon detected arbitrage opportunities by buying (testnet) LUSD for ETH and redeeming LUSD for more ETH than it paid for the LUSD in the first place. To that end, the bot should take the following factors into account:

An additional challenge arises from the fact that for some redemptions, the Liquity protocol is not able to fully serve the request, but can only partially fulfill it. There are two reasons for this:

  1. Liquity ensures that troves cannot go below a debt of 2000 LUSD (including a 50 LUSD Liquidation Reserve for gas compensation)
  2. The hints provided as part of the redemption transaction may become out of date if other transactions are processed in the meantime, changing the troves that are affected by the redemption.

The getRedemptionHints(...) function returns a set of hints and the maximum LUSD amount that can currently be redeemed for the requested amount (i.e. based on the current state).

EXAMPLE The two riskiest troves (i.e. the ones with the lowest and second lowest collateral ratios) have the following debt amounts:

  1. 3000 LUSD
  2. 5000 LUSD
Requested LUSD amount (range) Returned maximum
0 - 1000 0 - 1000 (requested amount can be redeemed exactly)
1000 - 2950 1000
2950 - 5950 2950 - 5950 (requested amount can be redeemed exactly)
5950 - 7900 5950
7900 - ??? 7900 - ??? (depending on the size of the 3rd trove)

Submission Requirements

As a minimum requirement, the trades done by the bot have to be positive with regard to the Ether held by the bot. That is, the transaction should always lead to a higher ETH balance, assuming that no third-party transactions are processed before the submitted arbitrage transaction.

The bot should be an application that can run on any regular web server 24/24 hours.

Judging Criteria

Any kind of frontrunning protection that mitigates the risk of negative trades as a result of third-party transactions (e.g. due to a higher redemption fee, updated price feed or higher slippage) is considered a plus. See the _maxFeePercentage parameter in our README.

Winner Announcement Date

A winner will be announced no later than 3 days after the GR9 Hackathon ends on ~March 31, 2021~ April 1, 2021.

gitcoinbot commented 3 years ago

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


This issue now has a funding of 1.6 ETH (2754.32 USD @ $1721.45/ETH) attached to it.

gitcoinbot commented 3 years ago

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


Work has been started.

These users each claimed they can complete the work by 1 day, 16 hours ago. Please review their action plans below:

1) lazycoder1 has started work.

I will take a crack at this task and see what I can come up with.

Learn more on the Gitcoin Issue Details page.

gitcoinbot commented 3 years ago

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


Work for 1.6 ETH (2711.84 USD @ $1819.53/ETH) has been submitted by:


gitcoinbot commented 3 years ago

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


Work for 1.6 ETH (2929.33 USD @ $1808.71/ETH) has been submitted by:

  1. @chris124567

@koltenb please take a look at the submitted work:


gitcoinbot commented 3 years ago

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


The funding of 1.6 ETH (3218.24 USD @ $2100.69/ETH) attached to this issue has been approved & issued to @chris124567.

gitcoinbot commented 3 years ago

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


The funding of 1.6 ETH (3218.24 USD @ $2100.69/ETH) attached to this issue has been approved & issued to @chris124567.