bancorprotocol / carbon-app Goto Github PK
View Code? Open in Web Editor NEWHome Page: https://app.carbondefi.xyz
License: MIT License
Home Page: https://app.carbondefi.xyz
License: MIT License
as a user i would like to have the option to delete an existing strategy.
this option will withdraw all associated budget (for both tokens) and delete the strategy (and NFT)
flow
end result -> all funds should be moved from the strategy to the user and NFT should be burned.
We should support all ERC-20 tokens, and therefore should support token list management similarly to what we're doing in the V3 app, including assuring that proper icons are displayed - but without the complexity of having to compare against our pools.
As a user, I would like to be able to approve using my tokens
Token approval popup
https://www.figma.com/file/YpsatcY9jtxJr0SJwlFYNj/Carbon-Screen-Design?node-id=1626%3A48146&t=L9LCB8b5RZBMfIXy-4
https://www.figma.com/file/YpsatcY9jtxJr0SJwlFYNj/Carbon-Screen-Design?node-id=1626%3A48178&t=L9LCB8b5RZBMfIXy-4
https://www.figma.com/file/YpsatcY9jtxJr0SJwlFYNj/Carbon-Screen-Design?node-id=1626%3A48491&t=L9LCB8b5RZBMfIXy-4
https://www.figma.com/file/YpsatcY9jtxJr0SJwlFYNj/Carbon-Screen-Design?node-id=2012%3A38116&t=L9LCB8b5RZBMfIXy-4
https://www.figma.com/file/YpsatcY9jtxJr0SJwlFYNj/Carbon-Screen-Design?node-id=2160%3A55987&t=L9LCB8b5RZBMfIXy-4
the approval flow and text changes based on different values.
IMPORTANT
"create strategy" CTA in the approval popup is disabled if there is a need for approve
If token0.balance = 0 AND token1.balance = 0,
defaults:
once the user clicks the approve, we should follow this process.
Add filter sort to overview
part of the epic issue: #81
as a user, i would like to have visibility into the closest available orders to buy and sell the base asset.
orderbook is a visualization that helps identify the buckets and liquidity above or below last known price
this visualization is similar to the depth chart but only shows the closest 14 buckets to the last known price
this is the same data we use in #94
this section will explain how we expect the book to behave
How should we calculate mid-market price?
IF the book is empty, there is no value and no data to show.
-- mid- market price is a calculated value that can be one of three options:
-- IF sell.book or buy.book are empty
--- [true] mid-price is the point in which the lowest.buy or highest.sell bucket of the existing order is
--- [false] IF sell lowest bucket > buy highest bucket
---- [true] means the orders overlap, use the interception bucket as mid-market point
---- [false] means the orders do not overlap, mid-market is the average between them
set min (or fixed?) width to the strategy cards. When the screen is narrow move to a new line
Add support for wallet connect - latest version of react-web3
As a user, I would like to have the option to choose my order type Buy/Sell or Buy and Sell
Giving the user the option to choose between Dual order (BUY & Sell) and Single order (Buy / Sell)
possible solution: Virtual Lists (https://tanstack.com/virtual/v3/docs/guide/introduction)
as a user, i would like to have visibility and know that i am connected to the wrong network (on metamask) which will prevent me from interacting with the Carbon frontend.
Notifying users their wallet is not connected to a supported network by adding a popup and status indicator.
Once a user wallet is connected to the app, we follow the wallet RPC.
IF RPC is pointing to an unsupported network, show "incorrect network" indication.
currently, we only support this:
https://docs.metamask.io/guide/rpc-api.html#usage-with-wallet-switchethereumchain
I think we should consider creating a queryKey Service to stay on top of the keys we are using and to make sure we are invalidating the correct keys.
Lets discuss this on a sync before starting to work on this.
Currently using numbro and numeral
We need a navigation service to programatically navigate to different routes.
Lets create a 'goToPage' service based on how we did it in the Bancor V3 app.
As a user, I would like to have the option to connect or disconnect my wallet to the Carbon frontend.
Menu where a user can choose and connect his wallet
Show an error message in any of the scenarios below
MetaMask / WalletConnect / Coinbase Wallet / Formatic
As a user, I would like to have the option to set the prices of my orders.
Giving the users the option to set their desirable prices for their orders
We have two states users can choose from, Specific price, and Range
updated - see next comment
As a user, I would like to have the option to choose the tokens I want to use in my strategy
A token pair selection section allows users to choose tokens for their strategies.
check console logs and fix errors
strategy logos
current: token0 is below token1 in the display
updated: token0 should be over token1
https://www.figma.com/file/YpsatcY9jtxJr0SJwlFYNj/Carbon-Screen-Design?node-id=1520%3A34855&t=L9LCB8b5RZBMfIXy-4
price limit/range visual image
trim down the height of the visual
buy/sell sections - reduce padding
reduce the space and padding between the different rows in each section
strategy not found
when searching, if the search string result in showing 0 strategies
https://www.figma.com/file/YpsatcY9jtxJr0SJwlFYNj/Carbon-Screen-Design?node-id=2159%3A55488&t=L9LCB8b5RZBMfIXy-4
add number rounding
on the overview page (and only on the overview page), please support number rounding based on the decimal display we show.
this should be implemented to both price
and budget
values we show on the strategy card
As a user, I would like to have the option to confirm my strategy on Carbon
Confirmation flow where user can confirms his strategy and approves the use of his liquidity on Carbon
once a user clicks the "create strategy" on the #69 form, we would like to follow this process.
IF token0.balance AND token1.balance = 0
[true] user is not depositing into the strategy -> skip the approval popup and trigger the transaction on the connected wallet
[false] (means that one of the tokens is not 0), IF token0.balance>existing approve OR token1.balance>existing approve
As a user, I would like to have the option to pause and reactivate my strategy.
Allow users to pause their strategy by taking it off curve and then reactivate it with a new price point
This option will set both orders to price 0 and basically disable them from being traded.
TBD
This option will give the user the option to set a new price for both orders and enable the strategy for being tradable
TBD
Required capabilities:
Set fork
Impersonate user
Reset to mainnet
As a user, I would like to have the option to choose how to allocate my tokens when creating a strategy.
Token allocation section is part of the strategy creation and allows the user to define the associated budget to deposit for each token in the strategy.
this is relevant for creation flow only. editing flow will have its own issue with details.
in order to better communicate issues with the input values, we would like to have a clear error indication in such cases.
display:
leave only the relevant messages
Use TradeView components to create a chart component that allows to select fixed/range prices based on historical prices
https://github.com/tradingview/lightweight-charts
As a user, I'd like to be able to select the tokens I want to use on Carbon easily
Add a token list to trade and strategy pages so users can select, search and add their tokens easily.
this section outlines general behavior the token dropdown and popup would have in every page/flow we include it.
Similarly to V3 - we will need to show and manage notifications. Let's achieve this by a decoupled service that offers a proper API and support similar flows as we do today.
As a user, I would like to have good visibility regarding the tokens pair I have selected.
Tokens׳ pair display rules system
Due to the contract design, we are not saving the initial intent of the user (e.g., ETH to USDC or USDC to ETH).
The user's tokens pair is only saved by the address of TokenA and TokenB in numerical order. Therefore, TokenA will always be the address with the lower numerical value, and TokenB will always be the address with the higher numerical value, regardless of the user's intent. As a way of making it more logical for the user, we would like to add a set of rules that will assist us in organizing the information in the presentation.
The ruling system's purpose is the create a uniform view of the user's pair choices.
Currently, we don't know the correct order of the pairs, to avoid showing different views, we decided to go with the best practice approach and pre-defined display that will order them in the same way every time - (Token -> Numeraire).
To do so, we will implement a ruling system to identify which token is which
tokenA and tokenB address
Address 1 - 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48
Address 2 - 0xdAC17F958D2ee523a2206206994597C13D831ec7
Address 1 - USDC/index 1
Address 2 - USDT/index 2
tokenA (index 1) -> tokenB (index 2)
USDC -> USDT
open the app and scroll
part of the epic: #81
As a user, I would like to have to option to see and choose token pairs with liquidity on Carbon
A list contains all Carbons' active token pairs with liquidity.
pool ETH/USDC
if search starts with ETH -> show the pool data where ETH is the base asset and USDC is the quoted asset.
if search starts with USDC -> show the pool data where USDC is the base asset and ETH is the quoted asset.
When the user enters the list, he should see only pairs containing ETH / WBTC / BNT / USDC / USDT / DAI sorted by alphanumeric( ascending order) as a default.
example:
BNT/DAI
BNT/ETH
DAI/LINK
ETH/USDT
USDC/DAI
USDT/LINK
WBTC/DAI
When searching, show user all pairs related to his search and not only from the default view which is explained above
example:
search string: ETH or ETH contract address
show results where the first token in the string is "ETH"
valid result: ETH/USDC, ETH/USDT, ETH/BNT...
invalid results (should not show up): USDC/ETH, WBTC/ETH
example:
search string: ETH US
show results where the first token is "ETH" and the second token includes "US"
valid result: ETH/USDC, ETH/USDT
The same behavior as in strategy page (#48 )
https://www.figma.com/file/YpsatcY9jtxJr0SJwlFYNj/Carbon-Screen-Design?node-id=2375%3A45022&t=WYzr31iPMySeZHJ4-4
once a pair has been selected, fetch the relevant data and display it on the frontend
part of the epic: #81
as a user, i would like to have the option to view a depth chart for the selected pair.
when we display pair information, we would like to include a depth chart visual.
What is a depth chart?
A depth chart is a tool for understanding the supply and demand of Bitcoin at a given moment for a range of prices. It is a visual representation of an order book, which is the outstanding buy or sell orders of an asset at varying price levels.
this section will explain how to pull the relevant order data from the available strategies and make it available for the frontend (this is the same process we would need for the order book display)
in the SDK, https://docs.google.com/document/d/19Rs3RVNthffyc1_jQ4B-3ZHkg1sbaEIJwSYwfD_2ayg/edit#
Given that there are multiple pairs, we should try to default to some automated process in defining bucket size and the process of data fetching.
- 100 buckets is a value we might want to change
- display can use portion of the available buckets (assume we display 50 buckets while we fetch to receive 100)
sdk function will return the sell orders of the token.
normalizing the data:
response for sell USDC to ETH
(this represents "buy" ETH)
example
if the selected pair is ETH/USDC
sell USDC will represent buy ETH.
assume the response is:
[1150.000001, 1155, 50000]
1150.000001 is the tickStart
1155 is the tickEnd
50000 is the amount of liquidity in USDC
liquidity amount in ETH -> 50000 * (1/1150.000001) = 43.4782608318 ETH
response for sell ETH to USDC
example
if the selected pair is ETH/USDC
sell ETH will return rates in ETH per USDC.
assume the response is:
[0.0008298755187, 0.0008333333333, 25]
0.0008298755187 is the tickStart
0.0008333333333 is the tickEnd
25 is the amount of liquidity in ETH
new tickStart = 1/tickEnd= 1/0.0008333333333 = 1200
new tickEnd = 1/tickStart = 1/0.0008298755187 = 1204.9999999596
this section will explain the chart behavior
references:
https://www.highcharts.com/samples/stock/demo/depth-chart?codepen
https://www.binance.com/en/trade/ETH_USDT?theme=light&type=spot
this section will explain how to place the relevant data on the chart
if there is no data to show, use this mockup:
https://www.figma.com/file/YpsatcY9jtxJr0SJwlFYNj/Carbon-Screen-Design?node-id=2041%3A38182&t=LuvWDO7FnCzILJ6h-4
this axis represents the price of the asset. (horizontal)
assuming ETH/USDC, it will represent the price of ETH in units of USDC which means showing it as 1100, 1200, 1300, etc
Data organization
since the data is always organized around the mid-price (which is always in the middle of the chart area), we need to identify the amount of data we have in each direction before we display the data
this axis represents the amount of liquidity in the token (vertical)
assuming ETH/USDC, it will represent the amount of tokens in each price point (bucket). this amount is in the base token, meaning in this case the amount of ETH tokens.
example:
- bucket 1 has 100 tokens: chart view shows 100 tokens
- bucket 2 has 50 tokens: chart view shows 150 tokens
- bucket 3 has 0 tokens: chart view shows 150 tokens
Create a self contained data fetching service with transaction management and a clean API to allow isolating the UI components from directly working with chain providers.
Recommendation is to implement it with react-query.
Also - have it returning mock strategy data, depending on env/config/flag - so that we can use it in development phase - and later on for tests
part of epic: #81
As a user I would like to have the option the sell or buy tokens using the frontend.
A simple and easy way where users can insert their details for the buy or sell orders
https://www.figma.com/file/YpsatcY9jtxJr0SJwlFYNj/Carbon-Screen-Design?node-id=1849%3A40044&t=C9AatagrmdAWxDXf-4
Buy - Green , Sell - Red
-- Amount field refers to the quantity of the token user is going to use in the buy or sell order
-- For reference, this is the "source" token that the user is deducting from its wallet.
-- Total field refers to the total amount of tokens the user is going to get from his order
-- For reference, this is the "target" token that the user is receiving into the wallet
The Amount field and Total field are directly related to each other.
Meaning if a user inserts a value of 10 in the Amount field and the current market price of the token is 100, the Total field will automatically update to 1,000 (10 units x 100 per token). If the user changes the Total field to 900 the amount field automatically updates to 9 (900 total / 100 per token)
-- Market price is the token price at a specific time, it can vary depending on the quantity of tokens available
Example:
1. User wants to trade ETH to USDC
-- If the user inputs the "Amount" field use **tradeBySourceAmount** (indication of how much ETH user wants to sell)
-- If user inputs the "Total" field use **tradeByTargetAmount** (indication of how much of USDC user wants to buy)
2. Retrieve the orders suggested in the SDK response, sum them and divide it by the user input
-- tradeBySourceAmount orders sum / Amount = Price
-- Total / tradeByTargetAmount orders sum= Price
As a user, I would like to be able to trade my tokens and obtain as much information as possible on strategies on Carbon using the frontend.
Trade page should allow users to trade between existing pairs on Carbon protocol while showing all available orders that are available for this pair.
-- Trade page behavior before the user chooses the pair he wishes
bonus enhancement
-- Here will be presented all the page components and their explanation this issue has been divided into four parts due to its complexity
Paste this code as high in the of the page as possible:
<!-- Google Tag Manager -->
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-5H2KXW7');</script>
<!-- End Google Tag Manager -->
Additionally, paste this code immediately after the opening tag:
<!-- Google Tag Manager (noscript) -->
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-5H2KXW7"
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<!-- End Google Tag Manager (noscript) -->
as a user, i would like to have the ability to navigate between different sections of the site and connect my wallet to perform transactions and view my strategies
top menu behavior
when clicking the logo -> open app.carbondefi.xyz
The title of the selected tab should be highlighted.
on mobile, we would like to break the menu into top and bottom parts.
Mockup:
https://www.figma.com/file/YpsatcY9jtxJr0SJwlFYNj/Carbon-Screen-Design?node-id=1709%3A60502&t=vhs2bLfA2YPkxmTz-3
sticky to the top
sticky to the bottom
As a user, I would like to have better control when setting my strategy prices
A better ability for users to adjust their strategy price
currently our button component is very minimal and not based of any specs.
We need to discuss the following:
it would be good to have color palettes like this:
https://tailwindcss.com/docs/customizing-colors
this allows us to have consistent color mapping, eg:
a button primary variant is mapped to color blue for example:
with normal state: primary-500
with hover state: primary-400
with disabled state primary-100
a button error variant is mapped to color red for example:
with normal state: error-500
with hover state: error-400
with disabled state error-100
if we can get these palettes provided by design team, or pick a palette from the tailwind included colors - great!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.