Skip to content
This repository was archived by the owner on Feb 8, 2023. It is now read-only.
This repository was archived by the owner on Feb 8, 2023. It is now read-only.

OpenDeFi Hackathon: Parallel Swap on Ref.Finance #64

Closed

Description

@cameron-NEAR

Parallel Swap Bounty

Prize Bounty

5,000 in USDC

Challenge Description

Background: Ref Finance is a community driven DEFI project on NEAR Protocol. It has several components, such as an AMM swap called Ref Exchange, a general-purpose farming component called Ref Farming which supports liquidity farming, and other components which are currently under development.

Ref Exchange allows permissionless pool creation, even with the same token pairs. And it manages all pools in one smart contract. All those features give Ref Exchange great flexibility, to provide powerful and user-oriented DEFI products.

Ref Farming is a general-purpose farming product supporting LP token and multiple-token farming which allow receiving rewards of multiple tokens with one single farming token.

For detailed information about Ref Finance, please go to https://docs.ref.finance.

Task Description
In ref finance, for a given Token-A, if you want to swap for Token-B, there are always multiple pools with different liquidities and fees. You may want to use the one with max wrap-out amount. But as x*y = K shows us, any swap action would cause the swap rate to go in your unpleasant direction, especially if your swap amount is so big or the pool liquidity is so small.

So the smartest way is to split swap into several pools in order to get the max total return. Based on that, this bounty aims to find the best combination.

Assume:

  1. There are several pools for (Token-A, Token-B) pair with different liquidities and fees.
  2. A user wants to swap A for B several times with different amounts.
    The task is to find the best combination for each swap.

Here, the best combination has only one criteria, that is the best total swap rate or the max swap-out amount, in the given swap-in amount.

In this challenge, you need to create a demo to prove your algorithm is correct.. When evaluating, we will go through some test cases to verify your demo. In addition, a design doc is also required to explain your core algorithm.

NEAR JS API is recommended to use when accessing on-chain ref-finance contracts. You can get enough information about swap pools there.

For efficiency and to reduce overload of rpc nodes, a small backend data service may be required to store pool information, but is not necessary.

.
A simple frontend page is required, to let users input swap tokens and amounts, also show results of the best combination you found.

Resources

Submission Requirements

  • Skills: JavaScripts, NEAR JS API
  • Open source code
  • A simple frontend page that can be used to check correctness.
  • A design doc to show your core algorithm.
  • Demo deployed on testnet or mainnet of NEAR

Judging Criteria

  • The correctness of algorithm weighs 80%;
  • Low complicity when implement your algorithm;
  • One winner gets all rewards;

Winner Announcement Date

  • Winner will be selected by Ref Team one week after the hackathon ends.

Activity

  1. changed the title [-]Parallel Swap on Ref.Finance[/-] [+]OpenDeFi Hackathon: Parallel Swap on Ref.Finance[/+] on Aug 18, 2021
  2. gitcoinbot commented on Aug 18, 2021

    @gitcoinbot

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


    This issue now has a funding of 5000.0 USDC (5000.0 USD @ $1.0/USDC) attached to it.

  3. gitcoinbot commented on Aug 25, 2021

    @gitcoinbot

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


    Work has been started.

    These users each claimed they can complete the work by 2 weeks from now.
    Please review their action plans below:

    1) giddyphysicist has started work.

    I am working on an algorithm to optimally allocate tokens to swap in parallel amongst different AMM liquidity pools. I have a model for the liquidity pools and am working on a closed-form solution to the allocation, taking fees into account. I plan on unit testing the algorithm on a variety of different configurations of the system to ensure it is working properly. And I will wrap the results in a web front end for demonstration purposes.

    Learn more on the Gitcoin Issue Details page.

  4. gitcoinbot commented on Sep 6, 2021

    @gitcoinbot

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


    Work for 5000.0 USDC (5000.00 USD @ $1.0/USDC) has been submitted by:


  5. gitcoinbot commented on Sep 8, 2021

    @gitcoinbot

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


    Work for 5000.0 USDC (5000.00 USD @ $1.0/USDC) has been submitted by:

    1. @lev-stambler

    @cameron-NEAR please take a look at the submitted work:


  6. aidai524 commented on Sep 18, 2021

    @aidai524

    I recommend that @giddyphysicist can got our reward for this mission. We run his project code, watched his video and whiterpaper, the functions he implemented meet our requirements very well, I believe these theories are very helpful for us to optimize the swap function, I hope to communicate with him later and see how to integrate your code into our project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions