diff --git a/.env-mock b/.env-mock
index 65e1b4d..f402083 100644
--- a/.env-mock
+++ b/.env-mock
@@ -1,2 +1,3 @@
VITE_WS_URL=ws://localhost:3001
+VITE_SNAPSHOT_URL=http://localhost:3001/snapshot
REQUIRE_AUTH=NOAUTH
diff --git a/package.json b/package.json
index 54c755a..ad5a789 100644
--- a/package.json
+++ b/package.json
@@ -21,6 +21,7 @@
"flexsearch": "^0.7.43",
"lru-cache": "^11.0.2",
"luxon": "^3.4.4",
+ "lz-string": "^1.5.0",
"pinia": "2.1.6",
"pinia-plugin-persistedstate": "^4.1.3",
"roboto-fontface": "*",
diff --git a/public/snapshot.js b/public/snapshot.js
new file mode 100644
index 0000000..cbd28d6
--- /dev/null
+++ b/public/snapshot.js
@@ -0,0 +1,28 @@
+console.log('snapshot.js')
+
+async function getSnapCode() {
+ const formData = new FormData;
+ formData.append('language', 'en');
+ formData.append('timezone', 'Etc/UTC');
+ formData.append('symbol', 'BTC/USD');
+ formData.append('preparedImage', window.snapshotImage, 'blob');
+
+ try {
+ const response = await fetch('https://tradingview.com/snapshot/', {
+ method: 'POST',
+ body: formData,
+ credentials: "same-origin",
+ });
+
+ if (!response.ok) {
+ console.error('Failed to upload snapshot:', response.status, response);
+ return null;
+ }
+ return await response.text();
+ } catch (error) {
+ console.error('Error uploading snapshot:', error);
+ return null
+ }
+}
+
+getSnapCode().then((code)=>console.log('snapshot code', code)).catch((e)=>console.error('snapshot error', e))
diff --git a/src/charts/chart.js b/src/charts/chart.js
index c9c86e7..e651804 100644
--- a/src/charts/chart.js
+++ b/src/charts/chart.js
@@ -1,7 +1,7 @@
import {useChartOrderStore} from "@/orderbuild.js";
import {invokeCallbacks, prototype} from "@/common.js";
import {DataFeed, defaultSymbol, feelessTickerKey, getAllSymbols, lookupSymbol} from "@/charts/datafeed.js";
-import {intervalToSeconds, SingletonCoroutine, toHuman, toPrecision} from "@/misc.js";
+import {intervalToSeconds, secondsToInterval, SingletonCoroutine, toHuman, toPrecision} from "@/misc.js";
import {usePrefStore, useStore} from "@/store/store.js";
import {tvCustomThemes} from "../../theme.js";
@@ -58,12 +58,20 @@ export async function setSymbolTicker(ticker) {
function changeInterval(interval) {
- co.intervalSecs = intervalToSeconds(interval)
+ const secs = intervalToSeconds(interval)
+ co.intervalSecs = secs
prefs.selectedTimeframe = interval
- DataFeed.intervalChanged(co.intervalSecs)
+ DataFeed.intervalChanged(secs)
}
+export function changeIntervalSecs(secs) {
+ const interval = secondsToInterval(secs);
+ co.intervalSecs = secs
+ prefs.selectedTimeframe = interval
+ DataFeed.intervalChanged(secs)
+}
+
function dataLoaded() {
const range = chartMeanRange()
console.log('new mean range', range,)
@@ -164,8 +172,8 @@ export function initWidget(el) {
container: el,
datafeed: DataFeed, // use this for ohlc
locale: "en",
- disabled_features: ['main_series_scale_menu',],
- enabled_features: ['saveload_separate_drawings_storage',],
+ disabled_features: ['main_series_scale_menu','display_market_status',],
+ enabled_features: ['saveload_separate_drawings_storage','snapshot_trading_drawings','show_exchange_logos','show_symbol_logos',],
// drawings_access: {type: 'white', tools: [],}, // show no tools
custom_themes: tvCustomThemes,
theme: useStore().theme,
@@ -193,6 +201,16 @@ export function initWidget(el) {
}
+export function onChartReady(f) {
+ if (co.chartReady)
+ f(widget, chart)
+ else
+ chartInitCbs.push(f)
+}
+
+let chartInitCbs = []
+
+
function initChart() {
console.log('init chart')
chart = widget.activeChart()
@@ -217,6 +235,11 @@ function initChart() {
}
changeInterval(widget.symbolInterval().interval)
co.chartReady = true
+ setTimeout(()=>{
+ for (const cb of chartInitCbs)
+ cb(widget, chart)
+ chartInitCbs = []
+ }, 1)
console.log('chart ready')
}
diff --git a/src/charts/datafeed.js b/src/charts/datafeed.js
index f056f71..e964fe6 100644
--- a/src/charts/datafeed.js
+++ b/src/charts/datafeed.js
@@ -64,7 +64,7 @@ const configurationData = {
value: 'UNIv3',
name: 'Uniswap v3',
desc: 'Uniswap v3',
- logo: 'https://upload.wikimedia.org/wikipedia/commons/e/e7/Uniswap_Logo.svg',
+ logo: '/uniswap-logo.svg',
},
],
// The `symbols_types` arguments are used for the `searchSymbols` method if a user selects this symbol type
@@ -111,8 +111,10 @@ export function feelessTickerKey(ticker) {
function addSymbol(chainId, p, base, quote, inverted) {
const symbol = base.s + '/' + quote.s
- const fee = `${(p.f/10000).toFixed(2)}%`
- const exchange = ['Uniswap v2', 'Uniswap v3'][p.e] + ' ' + fee
+ // const fee = `${(p.f/10000).toFixed(2)}%`
+ // const exchange = ['Uniswap v2', 'Uniswap v3'][p.e] + ' ' + fee
+ const exchange = ['Uniswap v2', 'Uniswap v3'][p.e]
+ const exchange_logo = '/uniswap-logo.svg'
const full_name = exchange + ':' + symbol // + '%' + formatFee(fee)
const ticker = tickerKey(chainId, p.e, base.a, quote.a, p.f)
// add the search index only if this is the natural, noninverted base/quote pair
@@ -123,7 +125,7 @@ function addSymbol(chainId, p, base, quote, inverted) {
const symbolInfo = {
key: ticker, ticker,
chainId, address: p.a, exchangeId: p.e,
- full_name, symbol, description, exchange, type, inverted, base, quote, decimals, x:p.x, fee:p.f,
+ full_name, symbol, description, exchange, exchange_logo, type, inverted, base, quote, decimals, x:p.x, fee:p.f,
};
_symbols[ticker] = symbolInfo
const feelessKey = feelessTickerKey(ticker)
diff --git a/src/components/chart/ChartOrder.vue b/src/components/chart/ChartOrder.vue
index 51b3f41..6e53fde 100644
--- a/src/components/chart/ChartOrder.vue
+++ b/src/components/chart/ChartOrder.vue
@@ -77,6 +77,7 @@ const co = useChartOrderStore()
const marketBuilder = newBuilder('MarketBuilder')
+console.log('chart order', props.order)
const builders = computed(()=>props.order.builders.length > 0 ? props.order.builders : [marketBuilder])
const tokenIn = computed(()=>props.order.buy ? co.quoteToken : co.baseToken)
const tokenOut = computed(()=>props.order.buy ? co.baseToken : co.quoteToken)
diff --git a/src/components/chart/ChartPlaceOrder.vue b/src/components/chart/ChartPlaceOrder.vue
index 2952a9c..1b3c527 100644
--- a/src/components/chart/ChartPlaceOrder.vue
+++ b/src/components/chart/ChartPlaceOrder.vue
@@ -8,6 +8,12 @@