You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Feb 8, 2023. It is now read-only.
Repository navigation
This repository was archived by the owner on Feb 8, 2023. It is now read-only.
OpenDeFi Hackathon: Parallel Swap on Ref.Finance #64
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.
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:
There are several pools for (Token-A, Token-B) pair with different liquidities and fees.
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.
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.
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.
Activity
[-]Parallel Swap on Ref.Finance[/-][+]OpenDeFi Hackathon: Parallel Swap on Ref.Finance[/+]gitcoinbot commentedon Aug 18, 2021
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.
gitcoinbot commentedon Aug 25, 2021
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.
gitcoinbot commentedon Sep 6, 2021
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:
gitcoinbot commentedon Sep 8, 2021
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:
@cameron-NEAR please take a look at the submitted work:
aidai524 commentedon Sep 18, 2021
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.