Inspiration
I wanted to create a DEX which can be interesting for all types of investors. Cryptocurrencies is a volatile market, sometimes there are tokens that can do x10 or x100 in a very short time. To identify these kinds of tokens is not a simple task, so it is better to diversify investments in multiple tokens. It means to study and identify promising tokens. I wanted to create a innovative way to do weighted investments on multiple promising tokens at a same time. Baskets can be very interesting instruments which can enable us to do this.
A DEX where market experts can create baskets of most promising tokens and investors invest in these baskets. The basket creator will earn some rewards as number of USD invested in their baskets increase. Investors will get rewards if they buy and hold baskets. Investors can also create custom baskets so that they can create a proper weighted hedge on their investments.
Solana and serum has provided a way to easily buy multiple tokens. I have used these technologies to implement such a DEX.
What it does
I have created a smart contract where you can create and trade baskets. You can create a basket by specifying its underlying and associated amount for each underlying token. When you buy a basket the underlying tokens are bought at the market price (IOC) and stored in token pools. The authority of these token pools is maintained by the smart contract. After successfully buying all the underlying tokens we mint the buyer a special fungible basket token. The price of the basket token is updated by the smart contract. An offchain program is responsible for updating basket prices, token prices and to track all current orders. If orders are not completed successfully within a certain time it is responsible for reverting those orders.
The token pools for underlying markets will be used for staking and lending, the rewards will be shared between the basket holders.
How we built it
I have build a smart contract using anchor framework in rust. The DEX to buy underlying tokens is Serum and Pyth is used to calculate basket prices.
Challenges we ran into
Solana has a limit on transaction size, so we cannot pass all the market data of serum while doing a trade.
Accomplishments that we're proud of
- Implementing a working smart contract which mints, burns and maintains underlying pools.
- Writing tests in typescript to test the smart contract.
- Creation of a new basket token for each basket.
- Calculation of basket price by aggregating price of individual token. Client API can get current basketprice from underlying structures to follow PNL of the basket.
What we learned
Solana, Anchor, Serum, Finance
What's next for Fruit Basket
- Implementing an advanced and user friendly UI.
- Integration of derived instruments like futures, options and other derivatives.
- More accurately pricing and risk calculation baskets using orderbooks.
- Implementing cross chain tokens and pools.
- Compose and decompose functions.
- Implementing off chain client to track and process the basket transactions. Should be quite simple and strait forwards.
- Implementing a way to analyze market condition and volatility to calculate the max price for buy and min price for sell (reducing almost all trade context reverts).
- Implementing basket swap.
- Publishing basket prices using pyth.
- Integrating staking and/or lending.
- Implementing a reward strategy for creating, buying and holding baskets. (creating a new reward token)
- Creating an interface to help add and configure new tokens and derived tokens like PERP Futures.
- More accurately pricing and risk calculation baskets using orderbooks.
- Adding other quote currencies other than USDC.
Built With
- anchor
- pyth
- rust
- serum
- solana
- typescript



Log in or sign up for Devpost to join the conversation.