bancorprotocol / carbon-backend Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
data structure:
pair: baseToken_quoteToken
{
base_id: base token address
base_name: base token name
base_symbol: base token symbol
quote_id: quote token address
quote_name: quote token name
quote_symbol: quote token symbol
last_price: Last transacted price of base currency based on given quote currency
base_volume: 24-hour trading volume denoted in BASE currency
quote_volume: 24 hour trading volume denoted in QUOTE currency
}
using the last known trade, use the sourceAmount and targetAmount to calculate the effective price of the last trade.
last_price =
example:
ex:1
100 baseToken -> 5321.123 quoteToken
if sourceToken=baseToken,
last_price= targetAmount/sourceAmount = 5321.123/100 = 5.321123 quoteToken
ex:2
5321.123 quoteToken -> 100 baseToken
if sourceToken=baseToken, //false
else, sourceToken != baseToken,
last_price = sourceAmount/targetAmount = 5321.123/100 = 5.321123 quoteToken
aggregating all transactions amounts and denoting in the BASE token.
=sum(transaction.baseToken.amount)
ex:
trade 100 baseToken -> 5321.123 quoteToken
base_volume = 100
aggregating all transactions amounts and denoting in the QUOTE token.
=sum(transaction.quoteToken.amount)
ex:
trade 100 baseToken -> 5321.123 quoteToken
quote_volume = 5321.123
Examples:
{
"0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599_0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2": {
"base_id": "0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599",
"base_name": "Wrapped BTC",
"base_symbol": "WBTC",
"quote_id": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
"quote_name": "Wrapped Ether",
"quote_symbol": "WETH",
"last_price": "30.45692523596447546478",
"base_volume": "1725.0451867",
"quote_volume": "52450.878529932577252127"
},
"0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2_0xdAC17F958D2ee523a2206206994597C13D831ec7": {
"base_id": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
"base_name": "Wrapped Ether",
"base_symbol": "WETH",
"quote_id": "0xdAC17F958D2ee523a2206206994597C13D831ec7",
"quote_name": "Tether USD",
"quote_symbol": "USDT",
"last_price": "345.2244580923542612263",
"base_volume": "195644.931427163765765227",
"quote_volume": "67443916.533922"
},
as a user, i would like to have access to my account history (carbon related) and see transaction performed by me and trades that have used my strategy. the information should include display currency value at the time of transaction (historically).
Case 1: user creates a new strategy to sell 10 ETH
Flow:
Case 2: trade happens against a carbon strategy (or a list of them)
Flow:
on this file:
https://github.com/bancorprotocol/carbon-backend/blob/main/src/v1/market-rate/market-rate.controller.ts
replace this:
'0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee': 'sei-network',
'0xace5f7ea93439af39b46d2748fa1ac19951c8d7c': 'usd-coin',
'0xf983afa393199d6902a1dd04f8e93465915ffd8b': 'tether',
'0x027d2e627209f1ceba52adc8a5afe9318459b44b': 'sei-network',
};
with this:
'0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee': 'sei-network',
'0x3894085Ef7Ff0f0aeDf52E2A2704928d1Ec074F1': 'usd-coin',
'0xB75D0B03c06A926e488e2659DF1A861F860bD3d1': 'tether',
'0xE30feDd158A2e3b13e9badaeABaFc5516e95e8C7': 'sei-network',
};
since the calculation we use is relying on current token prices to calculate the ROI, in some cases it can lead to impossible values.
please add the following rule to the data feed the API returns.
IF {ROI} <= -100%, set it to 0.
the end result should be that if the ROI is smaller than -100% (which is not a viable value), we zero it out.
example:
ROI = -105%
IF -105% <= -100% -> true -> set ROI==0
ROI = -94%
IF 94% <= -100% -> false -> keep ROI as -94%
The /historical_trades/ticker_id is used to return data on historical completed trades for a given market pair.
Example query:
.../api/historical_trades?ticker_id=BTC_ETH&limit=10
Response parameters:
Example response:
“buy”: [
{
"trade_id":1234567,
"price":"50.1",
"base_volume":"0.1",
"target_volume":"1",
"trade_timestamp":"1700050000",
"type":"buy"
}
],
“sell”: [
{
"trade_id":1234567,
"price":"50.1",
"base_volume":"0.1",
"target_volume":"1",
"trade_timestamp":"1700050000",
"type":"sell"
}
]
the example below yields a 500 error, should instead return a meaningful error such as "unsupported token"
https://api.carbondefi.xyz/v1/market-rate?address=0xa6Ec49E06C25F63292bac1Abc1896451A0f4cFB7&convert=USD,EUR,JPY,GBP,AUD,CAD,CHF,CNY,ETH
requires fetching the transaction along the event
The /orderbook/ticker_id endpoint is to provide order book information with at least depth = 100 (50 each side) returned for a given market pair/ticker.
ticker_id:
depth
Example query:
.../api/orderbook?ticker_id=BTC_ETH&depth=200
Note that for more liquid or closely priced pairs, the lack of order depth may result in miscalculation of depth/spread.
{
"ticker_id": //baseToken_quoteToken,
"ticker_symbols": //baseToken.symbol_quoteToken.symbol
"timestamp": //Unix timestamp in milliseconds for when the last updated time occurred.,
"bids": //An array containing 2 elements. The offer price and quantity for each bid order
"asks": //An array containing 2 elements. The ask price and quantity for each ask order
}
example:
{
"ticker_id": "BTC_ETH",
"timestamp":"1700050000",
"bids":[
[
"49.8", //price in quoteToken
"0.50000000" //amount in baseToken
],
[
"49.9", //price in quoteToken
"6.40000000" //amount in baseToken
]
],
"asks":[
[
"50.1", //price in quoteToken
"9.20000000" //amount in baseToken
],
[
"50.2", //price in quoteToken
"7.9000000" //amount in baseToken
]
]
}
same as bids
API requirements:
Publicly accessible, no-authentication API endpoints are required
Reasonable rate limits to ensure tickers/pairs list, market data, orderbook data can be queried on a minutely basis.
Data available in JSON format.
To whitelist CoinGecko’s IP address where necessary.
The /tickers endpoint provides 24-hour pricing and volume information on each market pair available on an exchange.
same information required for #1 plus:
for a specific pair,
= sum(token0.balance)*token0.usdRate + sum(token1,balance)*token1.usdRate
including all orders, in both directions.
last wei of liquidity on the "sell" baseToken side
last wei of liquidity on the "buy" baseToken side
we would like to maintain a price history database that would be used for the simulator and future development of the charting modal. once we have the data, we would be able to switch out of tradingView and use a customised library.
maintaining the most recent 7 days data
maintaining the data for the last 6 months
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.