@dodoex/widgets 3.13.0 → 3.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/helper-Be3CWTCE.js +1 -0
- package/dist/{helper-BBc2ohzp.cjs → helper-C8uhoyg4.cjs} +1 -1
- package/dist/index-BGCyS0SM.cjs +40 -0
- package/dist/index-Cuk9X7Dh.cjs +12 -0
- package/dist/index-DvUw-lQF.js +78 -0
- package/dist/index-FHV08HYK.js +12 -0
- package/dist/index-GeVhabPO.cjs +78 -0
- package/dist/index-asOS-7Ot.js +40 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/types/components/chart/components/BaseButton.d.ts +1 -1
- package/dist/types/components/chart/components/Input.d.ts +1 -1
- package/dist/types/components/chart/depth-chart/index.styled.d.ts +11 -6
- package/dist/types/components/chart/depth-chart-v2/index.styled.d.ts +8 -3
- package/dist/types/components/chart/liquidity-chart/index.styled.d.ts +2 -2
- package/dist/types/hooks/Submission/spec.d.ts +0 -1
- package/dist/types/hooks/Swap/useForecastSlippageList.d.ts +49 -5
- package/dist/types/hooks/Swap/useSwapSlippage.d.ts +49 -5
- package/dist/types/hooks/Swap/useTradeSwapOrderList.d.ts +76 -5
- package/dist/types/hooks/Token/useTokenListFetchBalance.d.ts +2 -2
- package/dist/types/hooks/contract/useFetchETHBalance.d.ts +4 -4
- package/dist/types/utils/formatter.d.ts +0 -1
- package/dist/types/widgets/MiningWidget/MiningCreate/hooks/useRewardsStatus.d.ts +1 -1
- package/dist/types/widgets/MiningWidget/MiningList/hooks/useStatusAndStartBlockNumber.d.ts +3 -3
- package/dist/types/widgets/MiningWidget/hooks/useStatusAndStartBlockNumber.d.ts +3 -3
- package/dist/types/widgets/PoolWidget/PoolCreate/components/DepthAndLiquidityChart.d.ts +0 -1
- package/dist/types/widgets/PoolWidget/PoolCreate/hooks/useCreatePmm.d.ts +1 -1
- package/dist/types/widgets/PoolWidget/PoolDetail/hooks/useLiquidityProviders.d.ts +44 -5
- package/dist/types/widgets/PoolWidget/PoolDetail/hooks/usePoolDashboard.d.ts +79 -5
- package/dist/types/widgets/PoolWidget/PoolDetail/hooks/usePoolDayData.d.ts +49 -5
- package/dist/types/widgets/PoolWidget/PoolDetail/hooks/usePoolSwapList.d.ts +65 -5
- package/dist/types/widgets/PoolWidget/hooks/usePoolBalanceInfo.d.ts +0 -1
- package/dist/types/widgets/PoolWidget/hooks/usePoolDetail.d.ts +93 -5
- package/dist/types/widgets/PoolWidget/hooks/useUniV2CreatePairs.d.ts +3 -3
- package/package.json +1 -1
- package/dist/helper-FLUhm18E.js +0 -1
- package/dist/index-C6Oqw6zm.js +0 -78
- package/dist/index-CAQP8oNY.cjs +0 -12
- package/dist/index-CKZqMWBf.js +0 -40
- package/dist/index-CnenhEse.js +0 -12
- package/dist/index-DL-6149F.cjs +0 -40
- package/dist/index-vajkxsgg.cjs +0 -78
|
@@ -63,6 +63,7 @@ export declare function usePoolDetail({ id, chainId, }: {
|
|
|
63
63
|
isLoadingError: false;
|
|
64
64
|
isRefetchError: true;
|
|
65
65
|
isSuccess: false;
|
|
66
|
+
isPlaceholderData: false;
|
|
66
67
|
status: "error";
|
|
67
68
|
dataUpdatedAt: number;
|
|
68
69
|
errorUpdatedAt: number;
|
|
@@ -74,11 +75,12 @@ export declare function usePoolDetail({ id, chainId, }: {
|
|
|
74
75
|
isFetching: boolean;
|
|
75
76
|
isInitialLoading: boolean;
|
|
76
77
|
isPaused: boolean;
|
|
77
|
-
isPlaceholderData: boolean;
|
|
78
78
|
isRefetching: boolean;
|
|
79
79
|
isStale: boolean;
|
|
80
|
+
isEnabled: boolean;
|
|
80
81
|
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<import("@dodoex/api/dist/types/gql/graphql").FetchPoolQuery, Error>>;
|
|
81
82
|
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
83
|
+
promise: Promise<import("@dodoex/api/dist/types/gql/graphql").FetchPoolQuery>;
|
|
82
84
|
} | {
|
|
83
85
|
poolDetail: {
|
|
84
86
|
address: string;
|
|
@@ -139,6 +141,7 @@ export declare function usePoolDetail({ id, chainId, }: {
|
|
|
139
141
|
isLoadingError: false;
|
|
140
142
|
isRefetchError: false;
|
|
141
143
|
isSuccess: true;
|
|
144
|
+
isPlaceholderData: false;
|
|
142
145
|
status: "success";
|
|
143
146
|
dataUpdatedAt: number;
|
|
144
147
|
errorUpdatedAt: number;
|
|
@@ -150,11 +153,12 @@ export declare function usePoolDetail({ id, chainId, }: {
|
|
|
150
153
|
isFetching: boolean;
|
|
151
154
|
isInitialLoading: boolean;
|
|
152
155
|
isPaused: boolean;
|
|
153
|
-
isPlaceholderData: boolean;
|
|
154
156
|
isRefetching: boolean;
|
|
155
157
|
isStale: boolean;
|
|
158
|
+
isEnabled: boolean;
|
|
156
159
|
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<import("@dodoex/api/dist/types/gql/graphql").FetchPoolQuery, Error>>;
|
|
157
160
|
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
161
|
+
promise: Promise<import("@dodoex/api/dist/types/gql/graphql").FetchPoolQuery>;
|
|
158
162
|
} | {
|
|
159
163
|
poolDetail: {
|
|
160
164
|
address: string;
|
|
@@ -215,6 +219,7 @@ export declare function usePoolDetail({ id, chainId, }: {
|
|
|
215
219
|
isLoadingError: true;
|
|
216
220
|
isRefetchError: false;
|
|
217
221
|
isSuccess: false;
|
|
222
|
+
isPlaceholderData: false;
|
|
218
223
|
status: "error";
|
|
219
224
|
dataUpdatedAt: number;
|
|
220
225
|
errorUpdatedAt: number;
|
|
@@ -226,11 +231,12 @@ export declare function usePoolDetail({ id, chainId, }: {
|
|
|
226
231
|
isFetching: boolean;
|
|
227
232
|
isInitialLoading: boolean;
|
|
228
233
|
isPaused: boolean;
|
|
229
|
-
isPlaceholderData: boolean;
|
|
230
234
|
isRefetching: boolean;
|
|
231
235
|
isStale: boolean;
|
|
236
|
+
isEnabled: boolean;
|
|
232
237
|
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<import("@dodoex/api/dist/types/gql/graphql").FetchPoolQuery, Error>>;
|
|
233
238
|
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
239
|
+
promise: Promise<import("@dodoex/api/dist/types/gql/graphql").FetchPoolQuery>;
|
|
234
240
|
} | {
|
|
235
241
|
poolDetail: {
|
|
236
242
|
address: string;
|
|
@@ -291,6 +297,7 @@ export declare function usePoolDetail({ id, chainId, }: {
|
|
|
291
297
|
isLoadingError: false;
|
|
292
298
|
isRefetchError: false;
|
|
293
299
|
isSuccess: false;
|
|
300
|
+
isPlaceholderData: false;
|
|
294
301
|
status: "pending";
|
|
295
302
|
dataUpdatedAt: number;
|
|
296
303
|
errorUpdatedAt: number;
|
|
@@ -302,11 +309,12 @@ export declare function usePoolDetail({ id, chainId, }: {
|
|
|
302
309
|
isFetching: boolean;
|
|
303
310
|
isInitialLoading: boolean;
|
|
304
311
|
isPaused: boolean;
|
|
305
|
-
isPlaceholderData: boolean;
|
|
306
312
|
isRefetching: boolean;
|
|
307
313
|
isStale: boolean;
|
|
314
|
+
isEnabled: boolean;
|
|
308
315
|
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<import("@dodoex/api/dist/types/gql/graphql").FetchPoolQuery, Error>>;
|
|
309
316
|
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
317
|
+
promise: Promise<import("@dodoex/api/dist/types/gql/graphql").FetchPoolQuery>;
|
|
310
318
|
} | {
|
|
311
319
|
poolDetail: {
|
|
312
320
|
address: string;
|
|
@@ -366,6 +374,7 @@ export declare function usePoolDetail({ id, chainId, }: {
|
|
|
366
374
|
isLoadingError: false;
|
|
367
375
|
isRefetchError: false;
|
|
368
376
|
isSuccess: false;
|
|
377
|
+
isPlaceholderData: false;
|
|
369
378
|
status: "pending";
|
|
370
379
|
dataUpdatedAt: number;
|
|
371
380
|
errorUpdatedAt: number;
|
|
@@ -378,9 +387,88 @@ export declare function usePoolDetail({ id, chainId, }: {
|
|
|
378
387
|
isLoading: boolean;
|
|
379
388
|
isInitialLoading: boolean;
|
|
380
389
|
isPaused: boolean;
|
|
381
|
-
isPlaceholderData: boolean;
|
|
382
390
|
isRefetching: boolean;
|
|
383
391
|
isStale: boolean;
|
|
392
|
+
isEnabled: boolean;
|
|
384
393
|
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<import("@dodoex/api/dist/types/gql/graphql").FetchPoolQuery, Error>>;
|
|
385
394
|
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
395
|
+
promise: Promise<import("@dodoex/api/dist/types/gql/graphql").FetchPoolQuery>;
|
|
396
|
+
} | {
|
|
397
|
+
poolDetail: {
|
|
398
|
+
address: string;
|
|
399
|
+
type: PoolType;
|
|
400
|
+
chainId: ChainId;
|
|
401
|
+
baseToken: TokenInfo;
|
|
402
|
+
quoteToken: TokenInfo;
|
|
403
|
+
miningAddress: string;
|
|
404
|
+
apy: {
|
|
405
|
+
miningBaseApy?: any | null;
|
|
406
|
+
miningQuoteApy?: any | null;
|
|
407
|
+
transactionBaseApy?: any | null;
|
|
408
|
+
transactionQuoteApy?: any | null;
|
|
409
|
+
metromMiningApy?: any | null;
|
|
410
|
+
} | null | undefined;
|
|
411
|
+
baseApy: string | undefined;
|
|
412
|
+
quoteApy: string | undefined;
|
|
413
|
+
isCpPool: boolean;
|
|
414
|
+
cpAddress: string | undefined;
|
|
415
|
+
cpLiquidator: string | undefined;
|
|
416
|
+
cpCreator: string | undefined;
|
|
417
|
+
cpCreatedAtTimestamp: string | undefined;
|
|
418
|
+
id: string;
|
|
419
|
+
creator: any;
|
|
420
|
+
owner?: any | null;
|
|
421
|
+
traderCount: any;
|
|
422
|
+
volumeBaseToken: any;
|
|
423
|
+
volumeQuoteToken: any;
|
|
424
|
+
volumeUSD: any;
|
|
425
|
+
feeBase: any;
|
|
426
|
+
feeQuote: any;
|
|
427
|
+
mtFeeRate: any;
|
|
428
|
+
lpFeeRate: any;
|
|
429
|
+
i?: any | null;
|
|
430
|
+
k?: any | null;
|
|
431
|
+
baseReserve: any;
|
|
432
|
+
quoteReserve: any;
|
|
433
|
+
createdAtTimestamp: any;
|
|
434
|
+
lastTradePrice: any;
|
|
435
|
+
baseLpToken?: {
|
|
436
|
+
id: string;
|
|
437
|
+
symbol: string;
|
|
438
|
+
name: string;
|
|
439
|
+
decimals: any;
|
|
440
|
+
} | null;
|
|
441
|
+
quoteLpToken?: {
|
|
442
|
+
id: string;
|
|
443
|
+
symbol: string;
|
|
444
|
+
name: string;
|
|
445
|
+
decimals: any;
|
|
446
|
+
} | null;
|
|
447
|
+
} | null;
|
|
448
|
+
data: import("@dodoex/api/dist/types/gql/graphql").FetchPoolQuery;
|
|
449
|
+
isError: false;
|
|
450
|
+
error: null;
|
|
451
|
+
isPending: false;
|
|
452
|
+
isLoading: false;
|
|
453
|
+
isLoadingError: false;
|
|
454
|
+
isRefetchError: false;
|
|
455
|
+
isSuccess: true;
|
|
456
|
+
isPlaceholderData: true;
|
|
457
|
+
status: "success";
|
|
458
|
+
dataUpdatedAt: number;
|
|
459
|
+
errorUpdatedAt: number;
|
|
460
|
+
failureCount: number;
|
|
461
|
+
failureReason: Error | null;
|
|
462
|
+
errorUpdateCount: number;
|
|
463
|
+
isFetched: boolean;
|
|
464
|
+
isFetchedAfterMount: boolean;
|
|
465
|
+
isFetching: boolean;
|
|
466
|
+
isInitialLoading: boolean;
|
|
467
|
+
isPaused: boolean;
|
|
468
|
+
isRefetching: boolean;
|
|
469
|
+
isStale: boolean;
|
|
470
|
+
isEnabled: boolean;
|
|
471
|
+
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<import("@dodoex/api/dist/types/gql/graphql").FetchPoolQuery, Error>>;
|
|
472
|
+
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
473
|
+
promise: Promise<import("@dodoex/api/dist/types/gql/graphql").FetchPoolQuery>;
|
|
386
474
|
};
|
|
@@ -9,10 +9,10 @@ export declare function useUniV2CreatePairs({ baseToken, quoteToken, baseAmount,
|
|
|
9
9
|
pairAddress: string | undefined;
|
|
10
10
|
pair: import("@uniswap/v2-sdk").Pair | null;
|
|
11
11
|
isInvalidPair: boolean;
|
|
12
|
-
price:
|
|
13
|
-
invertedPrice:
|
|
12
|
+
price: BigNumber | undefined;
|
|
13
|
+
invertedPrice: BigNumber | undefined;
|
|
14
14
|
priceLoading: boolean;
|
|
15
|
-
liquidityMinted:
|
|
15
|
+
liquidityMinted: BigNumber | undefined;
|
|
16
16
|
shareOfPool: string;
|
|
17
17
|
isExists: boolean;
|
|
18
18
|
};
|
package/package.json
CHANGED
package/dist/helper-FLUhm18E.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i18n as e}from"@lingui/core";import t from"bignumber.js";import{f as i}from"./index-CKZqMWBf.js";function o(t,i){switch(t){case"depth-chart.tips.buy":return e._({id:"Es4ccw",message:"Users pay {0} {1} and receive {2} {3}\nPrice {4} ({5}%)",values:{0:i.amountText,1:i.baseTokenSymbol,2:i.oppositeAmountText,3:i.quoteTokenSymbol,4:i.priceText,5:i.slippageText}});case"depth-chart.tips.mid-price":return e._({id:"cnbRVW",message:"Initial Price {0} {1} = {2} {3}",values:{0:i.amountText,1:i.baseTokenSymbol,2:i.oppositeAmountText,3:i.quoteTokenSymbol}});case"depth-chart.tips.sell":return e._({id:"Es4ccw",message:"Users pay {0} {1} and receive {2} {3}\nPrice {4} ({5}%)",values:{0:i.oppositeAmountText,1:i.quoteTokenSymbol,2:i.amountText,3:i.baseTokenSymbol,4:i.priceText,5:i.slippageText}});case"pool.chart.buy-amount":return e._({id:"NjQ1e3",message:"Users sell {0} amount: ",values:{0:i.symbol}});case"pool.chart.price-impact":return e._({id:"I0LXan",message:"Price Impact: {0}",values:{0:i.amount}});case"pool.chart.sell-amount":return e._({id:"WJ94b8",message:"Users buy {0} amount: ",values:{0:i.symbol}});case"pool.create.disabled-token-amount":return e._({id:"5QDjef",message:"The token amount is calculated by initial price."});case"pool.create.set-pool.emulator.title":return e._({id:"FQfStS",message:"Emulator"});case"pool.create.set-pool.emulator.title.question":return e._({id:"9D2g7k",message:"The liquidity of DODO is continuous, which is different from the discrete liquidity of UniV3. The ticks shown in the illustration are for demonstration purposes only."});case"pool.chart.liquidity-chart-tip":return e._({id:"GhrVog",message:"The area of the chart indicates the buy/sell volume of {0} that can be carried by the market when the current price changes to the hover price. ",values:{0:i.baseTokenSymbol}});case"pool.chart.liquidity-chart-buy":return e._({id:"TvH4Ym",message:"Bought {0} {1}, price in the pool decreased to {2}",values:{0:i.amount,1:i.symbol,2:i.price}});case"pool.chart.liquidity-chart-sell":return e._({id:"0O1wzf",message:"Traders sold {0} {1}, price in the pool increased to {2}",values:{0:i.amount,1:i.symbol,2:i.price}});default:throw new Error(`Unknown key ${t}`)}}const l=12,n=18;function s(e){let t=e.toLowerCase();if(t&&/^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/.test(t)){if(4===t.length){let e="#";for(let i=1;i<4;i+=1)e+=t.slice(i,i+1).concat(t.slice(i,i+1));t=e}const e=[];for(let i=1;i<7;i+=2)e.push(parseInt(`0x${t.slice(i,i+2)}`));return e.join(",")}return t}function r({val:e,model:i}){let o=e;if(e.isNaN())return{side:"no-one",vert:new t(0),base:new t(0),quote:new t(0)};i.Q0.eq(0)&&e.lt(i.i)&&(o=i.i),i.B0.eq(0)&&e.gt(i.i)&&(o=i.i);const l=i.getPriceDepth(o),n=l.baseAmount,s=l.quoteAmount,{isBuy:r}=l;return{side:r?"ask":"bid",vert:r?n:s,base:n,quote:s}}function a({midPrice:e,q:i,q0:o,pmmModel:l}){let n=t.maximum(i,o,l.B.multipliedBy(e));return n.isNaN()&&(n=new t(10)),n.eq(0)&&(n=new t(1)),{buyBaseVert:n.multipliedBy(1.2),sellBaseVert:n.div(e).multipliedBy(1.2)}}function u(e,i=1){return new t(i).div(e/2)}function m({tooltip:e,x:o,chartWidth:l,chartHeight:n,buyBaseVert:a,sellBaseVert:m,pmmModel:p,midPrice:c,baseTokenSymbol:d,quoteTokenSymbol:h,t:b,baseMinAndZoomMultiples:f,isHover:g,color:y,leftColor:T,rightColor:x}){const{zoomMultiples:w,baseMin:v}=f,k=u(l,w),M=a.div(n),B=m.div(n),q=2*w,N=v.multipliedBy(10**k.multipliedBy(o).toNumber());let S=new t(Math.log(c.div(v).toNumber())/Math.log(10));S=t.minimum(q,S),S=t.maximum(0,S);const P=S.div(k),A=r({val:N,model:p,midPrice:c});if(A.vert.isNaN())return;const _=N.lt(c);let z=n-A.vert.div(M).toNumber();_||(z=n-A.vert.div(B).toNumber());const O=i(N),X=i(A.vert),$=N.minus(c).abs().div(c).multipliedBy(100).toFixed(2),D=P.toNumber(),L=e.findOne("#toolTipVertLine"),V=e.findOne("#toolTipHoriLine"),j=e.findOne("#joinCircle"),H=e.findOne("#toolTip"),W=e.findOne("#priceTextLabel"),U=e.findOne("#slippageTextLabel");if(!H)return;H.x(o),H.y(z-5-6);const I=H.getText(),Y=H.getTag();let C="ask"===A.side?i(A.quote):i(A.base);const E=p.k.lte(0);E&&(C=X);const F=i(c),Q={amountText:X,baseTokenSymbol:d,oppositeAmountText:C,quoteTokenSymbol:h,priceText:E?F:O,slippageText:`${_?"-":"+"}${$}`};if(P.minus(4).lte(o)&&P.plus(2).gte(o)&&g)I.text(b("depth-chart.tips.mid-price",{amountText:1,baseTokenSymbol:d,oppositeAmountText:F,quoteTokenSymbol:h})),H.x(D),H.y(n/2),null==L||L.hide(),null==V||V.hide(),null==j||j.hide(),null==W||W.hide(),null==U||U.hide();else{I.text(_?b("depth-chart.tips.buy",{amountText:C,baseTokenSymbol:d,oppositeAmountText:X,quoteTokenSymbol:h,priceText:E?F:O,slippageText:`${_?"-":"+"}${$}`}):b("depth-chart.tips.sell",Q));const e=y||(_?"#55f6db":"#ff4f73"),t=_?T||"#55f6db":x||"#ff4f73";I.fill(e),H.width()/2>o?(Y.pointerDirection("left"),Y.pointerHeight(15),Y.pointerWidth(8),H.offsetX(-11),H.offsetY(-11)):H.width()/2+o>l?(Y.pointerDirection("right"),Y.pointerHeight(15),Y.pointerWidth(8),H.offsetX(11),H.offsetY(-11)):(Y.pointerDirection("down"),Y.pointerHeight(8),Y.pointerWidth(15),H.offsetX(0),H.offsetY(0)),null==L||L.points([o,n,o,z]),null==L||L.stroke(t),null==V||V.points(_?[o,z,D,z]:[D,z,o,z]),null==V||V.stroke(t),null==j||j.x(o),null==j||j.y(z),null==j||j.fill(_?T||"rgb(86, 246, 218)":x||"#FF5072"),null==j||j.stroke(_?T?`rgba(${s(T)}, 0.4)`:"rgba(86, 246, 218, 0.3)":x?`rgba(${s(x)}, 0.4)`:"rgba(255, 80, 114, 0.3)"),W&&(W.x(o),W.y(n),W.offsetX(W.width()/2),W.x()-W.width()/2<0?W.x(W.width()/2):W.x()+W.width()/2>l?W.x(l-W.width()/2):W.x(o));const i=null==W?void 0:W.findOne("#priceTextLabel-text");i&&(i.fill(e),i.text(O)),U&&(U.x(_?o+(D-o)/2:o-(o-D)/2),U.y(z),U.offsetY(U.height()/2),U.offsetX(U.width()/2));const r=null==U?void 0:U.findOne("#slippageTextLabel-text");r&&(r.fill(e),r.text(`${_?"-":"+"}${$}%`)),null==L||L.show(),null==V||V.show(),null==j||j.show(),null==W||W.show(),null==U||U.show()}e.show()}function p({dragDistance:e,prevBaseMin:i,chartWidth:o,zoomMultiples:l}){const n=u(o,l);return e>0?i.multipliedBy(1-n.multipliedBy(e).toNumber()):i.multipliedBy(10**n.multipliedBy(new t(e).abs()).plus(0).toNumber())}const c=1;function d({prevZoomMultiples:e,zoomIn:t}){return!t&&e<=.1?e:t?e+.1:e-.1}function h({type:e,targetPrice:i,midPrice:o,width:l}){if("sell"===e){return{zoomMultiples:new t(Math.log10(i.div(o).toNumber())).minus(0).div(3/4).abs(),targetX:l/2*(3/4)+l/2}}const n=new t(Math.log10(i.div(o).toNumber()));return{zoomMultiples:new t(0).minus(n).div(3/4).abs(),targetX:l/2*(1/4)}}function b({currentBaseMinAndZoomMultiples:e,targetPrice:i,midPrice:o,width:l}){const{baseMin:n,zoomMultiples:s}=e,r=new t(Math.log10(n.div(o).toNumber())),a=r.plus(2*s),u=new t(o.multipliedBy(10**a.toNumber()));if(i.gte(n)&&i.lte(u)){return{isSkip:!0,targetX:new t(Math.log10(i.div(o).toNumber())).minus(r).div(2*s).multipliedBy(l).toNumber(),baseMin:new t(0),zoomMultiples:1}}const m=new t(o.multipliedBy(.1)),p=new t(o.multipliedBy(10));if(i.gte(m)&&i.lte(p)){return{isSkip:!1,targetX:new t(Math.log10(i.div(o).toNumber())).minus(-1).div(2).multipliedBy(l).toNumber(),baseMin:m,zoomMultiples:1}}return{isSkip:!1,targetX:-1,baseMin:new t(0),zoomMultiples:1}}function f({midPrice:e,zoomMultiples:t}){return e.multipliedBy(10**-t)}export{a,p as b,u as c,d,r as e,f,o as g,n as h,c as i,b as j,h as k,l,s as m,m as u};
|
package/dist/index-C6Oqw6zm.js
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import e from"bignumber.js";import{merge as t,throttle as i,debounce as o}from"lodash";import r,{useEffect as n,useMemo as l,useRef as s,useState as a}from"react";import d from"@emotion/styled";import{css as c}from"@emotion/react";import{Stage as u,Layer as p,Rect as m,Line as g,Text as h,Circle as b,Label as f,Tag as M}from"react-konva";import{c as x,e as v,a as y,b as P,d as j,f as w,u as z,g as L,h as k,l as B,i as C,j as S,k as N}from"./helper-FLUhm18E.js";import{f as O,j as X,a as T,b as A}from"./index-CKZqMWBf.js";import{solveQuadraticFunctionForTarget as q,PMMModel as W}from"@dodoex/api";import"@lingui/core";import"@dodoex/components";import"@dodoex/dodo-contract-request";import"@lingui/react";import"identicon.js";import"zustand";import"@web3-react/core";import"@web3-react/eip1193";import"@web3-react/walletconnect-v2";import"@web3-react/metamask";import"@web3-react/types";import"@tanstack/react-query";import"@ethersproject/bignumber";import"react-dom";import"react-window";import"dayjs";import"react-transition-group";import"@dodoex/contract-request";import"axios";import"recharts";import"jsbi";import"tiny-invariant";import"@uniswap/sdk-core";import"@uniswap/v2-sdk";import"react-infinite-scroller";import"d3";import"rmc-date-picker";var E={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},F=r.createContext&&r.createContext(E),H=["attr","size","title"];function Z(e,t){if(null==e)return{};var i,o,r=function(e,t){if(null==e)return{};var i,o,r={},n=Object.keys(e);for(o=0;o<n.length;o++)i=n[o],t.indexOf(i)>=0||(r[i]=e[i]);return r}(e,t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);for(o=0;o<n.length;o++)i=n[o],t.indexOf(i)>=0||Object.prototype.propertyIsEnumerable.call(e,i)&&(r[i]=e[i])}return r}function G(){return G=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var i=arguments[t];for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(e[o]=i[o])}return e},G.apply(this,arguments)}function D(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,o)}return i}function J(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?D(Object(i),!0).forEach((function(t){V(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):D(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}function V(e,t,i){return(t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var o=i.call(e,t||"default");if("object"!=typeof o)return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function Y(e){return e&&e.map(((e,t)=>r.createElement(e.tag,J({key:t},e.attr),Y(e.child))))}function I(e){return t=>r.createElement(R,G({attr:J({},e.attr)},t),Y(e.child))}function R(e){var t=t=>{var i,{attr:o,size:n,title:l}=e,s=Z(e,H),a=n||t.size||"1em";return t.className&&(i=t.className),e.className&&(i=(i?i+" ":"")+e.className),r.createElement("svg",G({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},t.attr,o,s,{className:i,style:J(J({color:e.color||t.color},t.style),e.style),height:a,width:a,xmlns:"http://www.w3.org/2000/svg"}),l&&r.createElement("title",null,l),e.children)};return void 0!==F?r.createElement(F.Consumer,null,(e=>t(e))):t(E)}function $(e){return I({tag:"svg",attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M13.293 6.293 7.586 12l5.707 5.707 1.414-1.414L10.414 12l4.293-4.293z"},child:[]}]})(e)}function Q(e){return I({tag:"svg",attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M10.707 17.707 16.414 12l-5.707-5.707-1.414 1.414L13.586 12l-4.293 4.293z"},child:[]}]})(e)}function K(e){return I({tag:"svg",attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M5 11h14v2H5z"},child:[]}]})(e)}function U(e){return I({tag:"svg",attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M19 11h-6V5h-2v6H5v2h6v6h2v-6h6z"},child:[]}]})(e)}const _=d.input`
|
|
2
|
-
margin: 4px 10px 4px 6px;
|
|
3
|
-
border-radius: 10px;
|
|
4
|
-
border: 1px solid #373739;
|
|
5
|
-
padding: 4px 9px;
|
|
6
|
-
background-color: #1a1a1b;
|
|
7
|
-
color: #ffffff;
|
|
8
|
-
font-size: 14px;
|
|
9
|
-
font-weight: 400;
|
|
10
|
-
line-height: 20px;
|
|
11
|
-
outline: none;
|
|
12
|
-
width: 96px;
|
|
13
|
-
&:focus {
|
|
14
|
-
border-color: #fff;
|
|
15
|
-
|
|
16
|
-
${({error:e})=>e&&c`
|
|
17
|
-
border-color: red;
|
|
18
|
-
`}
|
|
19
|
-
}
|
|
20
|
-
`;const ee="rgba(38, 39, 41, 0.3)";function te({width:o,height:r,midPrice:a,pmmModel:d,params:c,baseTokenSymbol:C,quoteTokenSymbol:S,baseMinAndZoomMultiples:N,colorMap:T,setBaseMinAndZoomMultiples:A}){const q=t({grid:"#2A2A2D",midPriceLine:"#313335",leftBg:[0,ee,1,"#31645d"],leftLine:"#55f6db",leftColor:"",rightBg:[0,ee,1,"#67303d"],rightLine:"#ff4f73",rightColor:"",tooltipBg:"#121212",tooltipColor:void 0},T),W=o,E=r-18,F=W/7,{buyBaseVert:H,sellBaseVert:Z}=y({midPrice:a,q:c.q,q0:c.q0,pmmModel:d}),G=H.div(E),D=Z.div(E),J=s(null),V=s(null),{current:Y}=J,I=s(0),R=s(),{horizontalGridLines:$,verticalGridLines:Q}=function({chartHeight:e,chartWidth:t,horizontalLineCount:i,verticalLineCount:o}){return l((()=>{const r=[],n=e/(i+1),l=[],s=t/o;for(let e=0;e<i;e++){const i=n*(e+1);r.push([0,i,t,i])}for(let t=0;t<o;t++){const i=s*t+s/2;l.push([i,0,i,e])}return{horizontalGridLines:r,verticalGridLines:l}}),[e,t,i,o])}({chartHeight:E,chartWidth:W,horizontalLineCount:9,verticalLineCount:7}),{horizontalLabelTickPoints:K,horizontalLabelTextPoints:U}=function({chartHeight:e,chartWidth:t,xAxisPoints:i,oneXPx:o,baseMinAndZoomMultiples:r}){return l((()=>{const n=x(t,r.zoomMultiples),l=[],s=[];for(let t=0;t<i;t++){l.push([t*o+o/2,e,t*o+o/2,e+4]);const i=n.multipliedBy(t).multipliedBy(o).plus(n.multipliedBy(o/2)).toNumber(),a=r.baseMin.multipliedBy(10**i),d=t*o,c=e+2+4,u=O(a);s.push({x:d,y:c,text:u})}return{horizontalLabelTickPoints:l,horizontalLabelTextPoints:s}}),[r.baseMin,r.zoomMultiples,e,t,o,i])}({chartHeight:E,chartWidth:W,xAxisPoints:7,oneXPx:F,baseMinAndZoomMultiples:N}),{quoteLinePoints:_,quoteLineAreaPoints:te,quoteLineAreaLinearGradientEndPointY:ie,baseLinePoints:oe,baseLineAreaPoints:re,baseLineAreaLinearGradientEndPointY:ne,midPriceLinePoints:le}=function({chartHeight:t,chartWidth:i,midPrice:o,xPoints:r,pmmModel:n,baseMinAndZoomMultiples:s,buyYPortion:a,sellYPortion:d}){return l((()=>{const l=[],c=[],u=[],{baseMin:p,zoomMultiples:m}=s,g=x(i,m),h=2*m,b=new e(h).div(r);let f=new e(Math.log(o.div(p).toNumber())/Math.log(10));f=e.minimum(h,f),f=e.maximum(0,f);for(let i=new e(0);i.lte(f);){const e=p.multipliedBy(10**i.toNumber()),r=v({val:e,model:n,midPrice:o});if(!r.vert.isNaN()){const e=i.div(g).toNumber(),o=t-r.vert.div(a).toNumber();l.push(e,o)}i=i.plus(b)}for(let e=f;e.lte(h);){const i=p.multipliedBy(10**e.toNumber()),r=v({val:i,model:n,midPrice:o});if(!r.vert.isNaN()){const i=e.div(g).toNumber(),o=t-r.vert.div(d).toNumber();c.push(i,o)}e=e.plus(b)}const M=f.div(g).toNumber(),[,y]=l,P=n.k.eq(0);P&&l.push(M,y||t),l.push(M,t),u.push(M,t,M,0);const j=v({val:p.multipliedBy(10**h),model:n,midPrice:o});let w=t;const z=new e(h).div(g).toNumber();return j.vert.isNaN()||(w=t-j.vert.div(d).toNumber()),P&&c.length>=2&&(c.unshift(M,w),c.unshift(M,t)),c.push(z,w),f.lte(0)&&c.unshift(0,t),{quoteLinePoints:l,quoteLineAreaPoints:[0,t,0,y,...l],quoteLineAreaLinearGradientEndPointY:y,baseLinePoints:c,baseLineAreaPoints:[...c,z,t],baseLineAreaLinearGradientEndPointY:w,midPriceLinePoints:u}}),[s,i,r,o,n,t,a,d])}({chartHeight:E,chartWidth:W,midPrice:a,xPoints:50,pmmModel:d,baseMinAndZoomMultiples:N,buyYPortion:G,sellYPortion:D}),se=e=>{var t;const i=e.target;if(i&&Y){const e=null===(t=i.getStage())||void 0===t?void 0:t.getPointerPosition();if(e){const{x:t}=e;if(t>W)return void Y.hide();z({x:t,tooltip:Y,buyBaseVert:H,sellBaseVert:Z,chartWidth:W,chartHeight:E,midPrice:a,pmmModel:d,baseTokenSymbol:C,quoteTokenSymbol:S,baseMinAndZoomMultiples:N,t:L,isHover:!0,color:q.tooltipColor,leftColor:q.leftLine,rightColor:q.rightLine})}}},ae=l((()=>i((e=>{const{target:t}=e,i=t.getStage();if(i){i.container().style.cursor="grabbing";const e=null==i?void 0:i.getPointerPosition();if(e){const t=e.x-I.current;I.current=e.x,R.current=e.x,A((e=>void 0===e.baseMin?e:{baseMin:P({dragDistance:t,prevBaseMin:e.baseMin,chartWidth:W,zoomMultiples:e.zoomMultiples}),zoomMultiples:e.zoomMultiples,targetMarginPriceX:0}))}}}),100)),[W,A]),de=l((()=>i((e=>{e.cancelBubble=!0,e.evt.preventDefault();const t=e.evt.deltaY<0;A((e=>{const i=j({zoomIn:t,prevZoomMultiples:e.zoomMultiples});return{baseMin:w({midPrice:a,zoomMultiples:i}),zoomMultiples:i,targetMarginPriceX:e.targetMarginPriceX}}))}),100)),[a,A]);return n((()=>{N.targetMarginPriceX>0&&null!==Y?z({x:N.targetMarginPriceX,tooltip:Y,buyBaseVert:H,sellBaseVert:Z,chartWidth:W,chartHeight:E,midPrice:a,pmmModel:d,baseTokenSymbol:C,quoteTokenSymbol:S,baseMinAndZoomMultiples:N,t:L,color:q.tooltipColor,leftColor:q.leftLine,rightColor:q.rightLine}):void 0!==R.current&&null!==Y&&z({x:R.current,tooltip:Y,buyBaseVert:H,sellBaseVert:Z,chartWidth:W,chartHeight:E,midPrice:a,pmmModel:d,baseTokenSymbol:C,quoteTokenSymbol:S,baseMinAndZoomMultiples:N,t:L,isHover:!0,color:q.tooltipColor,leftColor:q.leftLine,rightColor:q.rightLine})}),[N,C,H,E,W,q.leftLine,q.rightLine,q.tooltipColor,a,d,S,Z,Y]),X.jsxs(u,{ref:V,width:o,offsetY:-k,height:r+k,draggable:!0,dragBoundFunc:function(){return{x:this.absolutePosition().x,y:this.absolutePosition().y}},onMouseMove:se,onMouseOver:se,onMouseOut:()=>{Y&&Y.hide()},onDragStart:function(e){const{target:t}=e,i=t.getStage();if(i){const e=i.getPointerPosition();e&&(I.current=e.x)}},onDragMove:ae,onDragEnd:e=>{const{target:t}=e,i=t.getStage();i&&(i.container().style.cursor="pointer")},onWheel:de,children:[X.jsxs(p,{children:[X.jsx(m,{x:0,y:0,width:o,height:E,stroke:q.grid,strokeWidth:1}),$.map(((e,t)=>X.jsx(g,{points:e,stroke:q.grid,strokeWidth:1,lineCap:"round",lineJoin:"round",listening:!1},t))),Q.map(((e,t)=>X.jsx(g,{points:e,stroke:q.grid,strokeWidth:1,lineCap:"round",lineJoin:"round",listening:!1},t))),K.map(((e,t)=>X.jsx(g,{points:e,stroke:"#9d9d9d",strokeWidth:1,lineCap:"round",lineJoin:"round",listening:!1},t))),U.map(((e,t)=>X.jsx(h,{x:e.x,y:e.y,text:e.text,fontFamily:"Manrope",fontSize:12,fill:"#9d9d9d",width:F,padding:0,align:"center",verticalAlign:"bottom",listening:!1},t))),X.jsx(g,{points:te,closed:!0,listening:!1,lineCap:"round",lineJoin:"round",fillLinearGradientStartPoint:{x:0,y:E},fillLinearGradientEndPoint:{x:0,y:ie},fillLinearGradientColorStops:q.leftBg}),X.jsx(g,{points:_,stroke:q.leftLine,strokeWidth:2,lineCap:"round",lineJoin:"round",listening:!1}),X.jsx(g,{points:re,closed:!0,listening:!1,lineCap:"round",lineJoin:"round",fillLinearGradientStartPoint:{x:W,y:E},fillLinearGradientEndPoint:{x:W,y:ne},fillLinearGradientColorStops:q.rightBg}),X.jsx(g,{points:oe,stroke:q.rightLine,strokeWidth:2,lineCap:"round",lineJoin:"round",listening:!1}),X.jsx(g,{points:le,stroke:q.midPriceLine,strokeWidth:2,lineCap:"round",lineJoin:"round",listening:!1})]}),X.jsxs(p,{ref:J,visible:!1,listening:!1,children:[X.jsx(g,{points:[],stroke:"#ff4f73",strokeWidth:1,lineCap:"round",lineJoin:"round",dash:[4,6],id:"toolTipVertLine"}),X.jsx(g,{points:[],stroke:"ff4f73",strokeWidth:1,lineCap:"round",lineJoin:"round",dash:[4,6],id:"toolTipHoriLine"}),X.jsx(b,{x:0,y:0,radius:5,fill:"#FF5072",stroke:"rgba(255, 80, 114, 0.3)",strokeWidth:12,id:"joinCircle"}),X.jsxs(f,{x:0,y:0,id:"priceTextLabel",children:[X.jsx(M,{fill:q.tooltipBg,id:"priceTextLabel-tag"}),X.jsx(h,{text:"",fontSize:12,fontFamily:"Manrope",padding:4,fill:"#FF5072",id:"priceTextLabel-text"})]}),X.jsxs(f,{x:0,y:0,id:"slippageTextLabel",children:[X.jsx(M,{fill:q.tooltipBg,id:"slippageTextLabel-tag"}),X.jsx(h,{text:"",fontSize:12,fontFamily:"Manrope",padding:4,fill:"#FF5072",id:"slippageTextLabel-text"})]}),X.jsxs(f,{x:0,y:0,id:"toolTip",children:[X.jsx(M,{fill:q.tooltipBg,pointerDirection:"down",pointerWidth:15,pointerHeight:8,cornerRadius:8,lineJoin:"round",id:"toolTip-tag"}),X.jsx(h,{text:"-",fontSize:12,lineHeight:17/12,padding:B,fontFamily:"Manrope",fill:"#FFFFFF",id:"toolTip-text"})]})]})]})}const ie=d.button`
|
|
21
|
-
margin: 0;
|
|
22
|
-
border: none;
|
|
23
|
-
padding: 0;
|
|
24
|
-
background: none;
|
|
25
|
-
|
|
26
|
-
&:focus {
|
|
27
|
-
outline: none;
|
|
28
|
-
}
|
|
29
|
-
&:active {
|
|
30
|
-
outline: none;
|
|
31
|
-
}
|
|
32
|
-
`,oe=d.div`
|
|
33
|
-
height: 100%;
|
|
34
|
-
`,re=d.div`
|
|
35
|
-
display: flex;
|
|
36
|
-
align-items: center;
|
|
37
|
-
`,ne=d.div`
|
|
38
|
-
border: 1px solid ${({borderColor:e})=>e||"#2a2a2d"};
|
|
39
|
-
flex: 1 0 50%;
|
|
40
|
-
|
|
41
|
-
display: flex;
|
|
42
|
-
align-items: center;
|
|
43
|
-
justify-content: center;
|
|
44
|
-
font-size: 12px;
|
|
45
|
-
font-weight: 400;
|
|
46
|
-
line-height: 17px;
|
|
47
|
-
color: #606066;
|
|
48
|
-
|
|
49
|
-
& + & {
|
|
50
|
-
border-left: none;
|
|
51
|
-
}
|
|
52
|
-
`,le=d.span`
|
|
53
|
-
color: #85858d;
|
|
54
|
-
`,se=d.div`
|
|
55
|
-
margin-top: 20px;
|
|
56
|
-
display: flex;
|
|
57
|
-
justify-content: center;
|
|
58
|
-
margin-bottom: 9px;
|
|
59
|
-
`,ae=d(ie)`
|
|
60
|
-
border-radius: 13px;
|
|
61
|
-
background-color: #373739;
|
|
62
|
-
width: 24px;
|
|
63
|
-
height: 24px;
|
|
64
|
-
font-size: 18px;
|
|
65
|
-
color: #85858d;
|
|
66
|
-
line-height: 0;
|
|
67
|
-
& + & {
|
|
68
|
-
margin-left: 10px;
|
|
69
|
-
}
|
|
70
|
-
&:first-child,
|
|
71
|
-
&:last-child {
|
|
72
|
-
font-size: 20px;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
&:hover {
|
|
76
|
-
color: #fff;
|
|
77
|
-
}
|
|
78
|
-
`;function de({params:t,target:i,isBuy:o=!0}){const r=new e(t.b),n=new e(t.q);let l=new e(t.b0);const s=new e(t.q0),a=new e(t.i),d=new e(t.k),{R:c}=t;1===c&&l.eq(r)&&(l=q(r,n.minus(s),new e(1).div(a),d));const u=o?r.plus(i):r.minus(i);if(u.lt(l)||r.eq(l)){let t=l.multipliedBy(l).div(u).div(u);return t=new e(1).minus(d).plus(d.multipliedBy(t)),a.multipliedBy(t)}const p=new W;p.RStatus=c,p.B=r,p.B0=l,p.Q=n,p.Q0=s,p.i=a,p.k=d,p.mtFeeRate=new e(0),p.lpFeeRate=new e(0);let m=new e(0);m=o?p.querySellBase(i):p.queryBuyBase(i);const g=o?n.minus(m):n.plus(m);let h=s.multipliedBy(s).div(g).div(g);return h=new e(1).minus(d).plus(d.multipliedBy(h)),a.div(h)}const ce=({chartId:t,width:i=834,height:r=460,baseTokenSymbol:s,quoteTokenSymbol:d,pmmModel:c,pmmParams:u,midPrice:p=new e(0),colorMap:m,notShowAmountInput:g})=>{(({id:e})=>{n((()=>{function t(e){e.preventDefault()}let i=!1;try{const e={get passive(){return i=!0,!1}};window.addEventListener("test",(()=>{}),e),window.removeEventListener("test",(()=>{}))}catch(e){i=!1}const o=document.getElementById(e),r=!!i&&{passive:!1};return null==o||o.addEventListener("wheel",t,r),()=>{null==o||o.removeEventListener("wheel",t)}}),[e])})({id:t});const[h,b]=a(""),[f,M]=a(""),[x,v]=a("-"),[y,z]=a("-"),[k,B]=a({baseMin:new e(0),zoomMultiples:C,targetMarginPriceX:0});n((()=>{void 0!==p&&B((e=>({baseMin:w({midPrice:p,zoomMultiples:e.zoomMultiples}),zoomMultiples:e.zoomMultiples,targetMarginPriceX:e.targetMarginPriceX})))}),[p]);const O=l((()=>o((({type:t,amount:o})=>{""===o&&p&&(B({baseMin:w({midPrice:p,zoomMultiples:C}),zoomMultiples:C,targetMarginPriceX:0}),"buy"===t?v("-"):z("-"));const r=new e(o);if(!r.lte(0)&&!r.isNaN()&&(null==u?void 0:u.b)&&!r.gte(u.b)&&p)if("buy"===t){const e=de({params:u,target:r});B((o=>{const r=S({currentBaseMinAndZoomMultiples:o,targetPrice:e,midPrice:p,width:i});if(r.isSkip)return{baseMin:o.baseMin,zoomMultiples:o.zoomMultiples,targetMarginPriceX:r.targetX};if(r.targetX>0)return{baseMin:r.baseMin,zoomMultiples:r.zoomMultiples,targetMarginPriceX:r.targetX};const n=N({midPrice:p,width:i,type:t,targetPrice:e}),l=n.zoomMultiples.dp(6).toNumber();return{baseMin:w({midPrice:p,zoomMultiples:l}),zoomMultiples:l,targetMarginPriceX:n.targetX}})),v(`${T({input:e.minus(p).div(p)})}`)}else{const e=function({params:e,target:t}){return de({params:e,target:t,isBuy:!1})}({params:u,target:r});B((o=>{const r=S({currentBaseMinAndZoomMultiples:o,targetPrice:e,midPrice:p,width:i});if(r.isSkip)return{baseMin:o.baseMin,zoomMultiples:o.zoomMultiples,targetMarginPriceX:r.targetX};if(r.targetX>0)return{baseMin:r.baseMin,zoomMultiples:r.zoomMultiples,targetMarginPriceX:r.targetX};const n=N({midPrice:p,width:i,type:t,targetPrice:e}),l=n.zoomMultiples.dp(6).toNumber();return{baseMin:w({midPrice:p,zoomMultiples:l}),zoomMultiples:l,targetMarginPriceX:n.targetX}})),z(`+${T({input:e.minus(p).div(p)})}`)}}),300)),[u,p,i]);n((()=>{void 0!==h&&O({type:"buy",amount:h})}),[O,h]),n((()=>{void 0!==f&&O({type:"sell",amount:f})}),[O,f]);const q=e=>{let t=0;t=e?-.1*i:.1*i,B((e=>void 0===e.baseMin?e:{baseMin:P({dragDistance:t,prevBaseMin:e.baseMin,chartWidth:i,zoomMultiples:e.zoomMultiples}),zoomMultiples:e.zoomMultiples,targetMarginPriceX:e.targetMarginPriceX}))},W=e=>{B((t=>{const i=j({zoomIn:null!=e&&e,prevZoomMultiples:t.zoomMultiples});return{baseMin:w({midPrice:p,zoomMultiples:i}),zoomMultiples:i,targetMarginPriceX:t.targetMarginPriceX}}))},E=l((()=>{if(""===h)return!1;const t=new e(h);return!(!t.lte(0)&&!t.isNaN()&&(null==u?void 0:u.b)&&!t.gte(u.b))}),[h,u]),F=l((()=>{if(""===f)return!1;const t=new e(f);return!(!t.lte(0)&&!t.isNaN()&&(null==u?void 0:u.b)&&!t.gte(u.b))}),[f,u]);return X.jsxs(oe,{id:t,children:[g?"":X.jsxs(re,{children:[X.jsxs(ne,{borderColor:m&&m.grid,children:[L("pool.chart.buy-amount",{symbol:s}),X.jsx(_,{value:h,error:E,onChange:e=>{const t=A(e.target.value,2);null!==t&&b(t)}}),X.jsx(le,{children:L("pool.chart.price-impact",{amount:x})})]}),X.jsxs(ne,{borderColor:m&&m.grid,children:[L("pool.chart.sell-amount",{symbol:s}),X.jsx(_,{value:f,error:F,onChange:e=>{const t=A(e.target.value,2);null!==t&&M(t)}}),X.jsx(le,{children:L("pool.chart.price-impact",{amount:y})})]})]}),void 0!==u&&void 0!==p&&void 0!==c&&void 0!==k.baseMin&&void 0!==p&&X.jsx(te,{width:i,height:r,params:u,midPrice:p,pmmModel:c,baseTokenSymbol:s,quoteTokenSymbol:d,baseMinAndZoomMultiples:k,colorMap:m,setBaseMinAndZoomMultiples:B}),X.jsxs(se,{className:"operate-btn-wrapper",children:[X.jsx(ae,{onClick:()=>q(!0),children:X.jsx($,{})}),X.jsx(ae,{onClick:()=>W(!1),children:X.jsx(K,{})}),X.jsx(ae,{onClick:()=>W(!0),children:X.jsx(U,{})}),X.jsx(ae,{onClick:()=>q(!1),children:X.jsx(Q,{})})]})]})};export{ce as default};
|
package/dist/index-CAQP8oNY.cjs
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";var e=require("@emotion/styled"),t=require("lodash"),i=require("react"),r=require("./helper-BBc2ohzp.cjs"),n=require("react-konva"),o=require("./index-DL-6149F.cjs"),s=require("bignumber.js"),l=require("@dodoex/api");require("@lingui/core"),require("@dodoex/components"),require("@dodoex/dodo-contract-request"),require("@lingui/react"),require("identicon.js"),require("zustand"),require("@web3-react/core"),require("@web3-react/eip1193"),require("@web3-react/walletconnect-v2"),require("@web3-react/metamask"),require("@web3-react/types"),require("@tanstack/react-query"),require("@ethersproject/bignumber"),require("react-dom"),require("react-window"),require("dayjs"),require("react-transition-group"),require("@dodoex/contract-request"),require("axios"),require("recharts"),require("jsbi"),require("tiny-invariant"),require("@uniswap/sdk-core"),require("@uniswap/v2-sdk"),require("react-infinite-scroller"),require("d3"),require("rmc-date-picker");const a=e.div`
|
|
2
|
-
height: 100%;
|
|
3
|
-
position: relative;
|
|
4
|
-
`,u=e.div`
|
|
5
|
-
text-align: center;
|
|
6
|
-
margin-top: 17.1px;
|
|
7
|
-
margin-bottom: 88.41px;
|
|
8
|
-
color: #606066;
|
|
9
|
-
font-size: 12px;
|
|
10
|
-
line-height: 17px;
|
|
11
|
-
font-weight: 400;
|
|
12
|
-
`,d=36;function g({maxHeight:e,gridAreaHeight:t,value:i}){const r=new s(t).minus(d),n=r.div(e);return r.minus(i.multipliedBy(n)).plus(d).toNumber()}function m({targetPrice:e,areaPoints:t,isLeft:i}){for(let r=0;r<t.length;r++){const n=t[r],o=r<t.length-1?t[r+1]:null;if(!o)return{targetAreaStatPoint:n,targetAreaStatPoints:t};if(i){if(e.lte(n.middlePrice)&&e.gte(o.middlePrice))return{targetAreaStatPoint:n,targetAreaStatPoints:t.slice(0,r+1)}}else if(e.gte(n.middlePrice)&&e.lte(o.middlePrice))return{targetAreaStatPoint:n,targetAreaStatPoints:t.slice(0,r+1)}}return{targetAreaStatPoint:null,targetAreaStatPoints:[]}}function c({x:e,width:t,minXLN10:i,maxXLN10:r}){const n=new s(e).div(t).multipliedBy(r.minus(i)).plus(i);return new s(10**n.toNumber())}function p({width:e,targetLN10:t,minXLN10:i,maxXLN10:r}){return t.minus(i).div(r.minus(i)).multipliedBy(e).toNumber()}function h({target:e}){return new s(Math.log10(e.toNumber()))}const x="rgba(38, 39, 41, 0.3)";function f({width:e,height:a,params:u,baseTokenSymbol:d,quoteTokenSymbol:f,colorMap:L}){const{maxLeftHeight:b,maxRightHeight:j,leftStatAreaPoints:w,rightStatAreaPoints:A,minXLN10:N,maxXLN10:y}=function({params:e}){return i.useMemo((()=>{const t=new s(e.b),i=new s(e.q);let r=new s(e.b0);const n=new s(e.q0),o=new s(e.i),a=new s(e.k),{R:u}=e;1===u&&r.eq(t)&&(r=l.solveQuadraticFunctionForTarget(t,i.minus(n),new s(1).div(o),a));const d=new l.PMMState({i:o,K:a,B:t,Q:i,B0:r,Q0:n,R:u,mtFeeRate:new s(0),lpFeeRate:new s(0)}),g=new l.PMMHelper,m=new s(d.B),c=[],p=[];let h=new s(0),x=new s(0);const f=g.GetMidPrice(d),L=i.gt(0)?t.div(i):new s(1);for(let e=0;e<=250;e++){let t=m.multipliedBy(e/100).multipliedBy(f.multipliedBy(L).multipliedBy(4));0===e&&(t=m.multipliedBy(1e-11));const i=null==g?void 0:g.QuerySellBase(t,d);if(i.isNaN()||!i.gt(0))c.push({giveAmount:t,getAmount:new s(0),price:new s(0)});else{const e=i.div(t);c.push({giveAmount:t,getAmount:i,price:e})}}for(let e=0;e<=250;e++){let t=m.multipliedBy(e/100).multipliedBy(f.multipliedBy(4));0===e&&(t=m.multipliedBy(1e-11));const i=null==g?void 0:g.QuerySellQuote(t,d);if(i.isNaN()||!i.gt(0))p.push({giveAmount:t,getAmount:new s(0),price:new s(0)});else{const e=t.dividedBy(i);p.push({giveAmount:t,getAmount:i,price:e})}}if(c.length<2&&p.length<2)return{leftStatAreaPoints:[],rightStatAreaPoints:[],maxLeftHeight:new s(10).multipliedBy(1.2),maxRightHeight:new s(10).multipliedBy(1.2),middlePriceLN10:new s(0),minXLN10:new s(-1),maxXLN10:new s(1)};const b=[];for(let e=1;e<c.length;e++){const t=c[e],{giveAmount:i,getAmount:r,price:n}=t,o=c[e-1];if(!n.isNaN()&&n.gt(0)&&o){const t=n.minus(o.price).abs(),l=i.minus(o.giveAmount).abs(),a=r.minus(o.getAmount).abs().multipliedBy(l);1===e&&b.push({area:r,price:n,middlePrice:n.plus(t.div(1.1)),rectangleHeight:a.plus(a.multipliedBy(.03))}),b.push({area:r,price:n,middlePrice:n.plus(t.div(2)),rectangleHeight:a}),h=s.max(a,h)}}const j=[];for(let e=1;e<p.length;e++){const t=p[e],{giveAmount:i,getAmount:r,price:n}=t,o=p[e-1],l=o.price,a=o.giveAmount,u=o.getAmount;if(!n.isNaN()&&n.gt(0)&&o){const t=n.minus(l).abs(),o=i.minus(a).abs(),d=r.minus(u).abs().multipliedBy(o);1===e&&j.push({area:r,price:n,middlePrice:n.minus(t.div(1.1)),rectangleHeight:d.plus(d.multipliedBy(.03))}),j.push({area:r,price:n,middlePrice:n.minus(t.div(2)),rectangleHeight:d}),x=s.max(d,x)}}const w=c.length>0?c[c.length-1]:p[0],A=p.length>0?p[0]:c[0],N=p.length>0?p[p.length-1]:c[0],y=w.price,P=N.price,R=A.price,v=new s(Math.log10(R.toNumber()));let S=y.gt(0)?new s(Math.log10(y.toNumber())):new s(-Math.log10(P.toNumber())),q=P.gt(0)?new s(Math.log10(P.toNumber())):new s(-Math.log10(y.toNumber()));const H=s.max(v.minus(S).abs(),q.minus(v).abs());return S=v.minus(H),q=v.plus(H),{leftStatAreaPoints:b,rightStatAreaPoints:j,maxLeftHeight:h.multipliedBy(1.2),maxRightHeight:x.multipliedBy(1.2),minXLN10:S,maxXLN10:q,middlePriceLN10:v}}),[e])}({params:u}),P=a-30.13,R=i.useRef(null),v=t.merge({grid:"#2A2A2D",midPriceLine:"#313335",leftBg:[0,x,1,"#31645d"],leftLine:"#55f6db",leftColor:"",rightBg:[0,x,1,"#67303d"],rightLine:"#ff4f73",rightColor:"",tooltipBg:"#121212",tooltipColor:void 0,textColor:"#606066"},L),S=t=>{var i;const{current:n}=R,s=t.target;if(s&&n){const t=null===(i=s.getStage())||void 0===i?void 0:i.getPointerPosition();if(t){const{x:i}=t,s=e/2;if(Math.abs(i-s)<=2)return;if(i<=2||e-i<=2)return;const l=c({x:i,width:e,minXLN10:N,maxXLN10:y});let a=null,u=[];const x=i<s;if(x){const e=m({areaPoints:w,targetPrice:l,isLeft:x});a=e.targetAreaStatPoint,u=e.targetAreaStatPoints}else{const e=m({areaPoints:A,targetPrice:l,isLeft:x});a=e.targetAreaStatPoint,u=e.targetAreaStatPoints}if(a){const t=h({target:a.middlePrice}),s=p({minXLN10:N,maxXLN10:y,width:e,targetLN10:t}),l=g({maxHeight:x?b:j,gridAreaHeight:P,value:a.rectangleHeight}),m=n.findOne("#tooltip"),c=n.findOne("#toolTipVertLine"),L=n.findOne("#joinCircle"),w=n.findOne("#tooltip-Text"),A=n.findOne("#tooltip-tag"),R=n.findOne("#priceTextLabel"),S=null==R?void 0:R.findOne("#priceTextLabel-text"),q=n.findOne("#area");null==m||m.position({x:s,y:l-5-6}),null==w||w.fill(v.tooltipColor||(x?"#00FAD9":"#FF5072")),null==w||w.text(x?r.chartT("pool.chart.liquidity-chart-buy",{amount:o.formatShortNumber(a.area),symbol:d,price:o.formatShortNumber(a.price)}):r.chartT("pool.chart.liquidity-chart-sell",{amount:o.formatShortNumber(a.area),symbol:f,price:o.formatShortNumber(a.price)})),m&&A&&(m.width()/2>i?(A.pointerDirection("left"),A.pointerHeight(15),A.pointerWidth(8),m.offsetX(-11),m.offsetY(-11)):m.width()/2+i>e?(A.pointerDirection("right"),A.pointerHeight(15),A.pointerWidth(8),m.offsetX(11),m.offsetY(-11)):(A.pointerDirection("down"),A.pointerHeight(8),A.pointerWidth(15),m.offsetX(0),m.offsetY(0))),null==c||c.points([s,P,s,l]),null==c||c.stroke(x?"#55f6db":"#ff4f73");let H=x?"rgb(86, 246, 218)":"#FF5072",E=x?"rgba(86, 246, 218, 0.3)":"rgba(255, 80, 114, 0.3)";v.leftLine&&v.rightLine&&(H=x?v.leftLine:v.rightLine,E=x?`rgba(${r.colorRgb(v.leftLine)}, 0.4)`:`rgba(${r.colorRgb(v.rightLine)}, 0.4)`),L&&(L.x(s),L.y(l),L.fill(H),L.stroke(E)),R&&(R.x(s),R.y(P+8.08+1),R.offsetX(R.width()/2),R.x()-R.width()/2<0?R.x(R.width()/2):R.x()+R.width()/2>e?R.x(e-R.width()/2):R.x(i)),S&&(S.fill(v.tooltipColor||(x?"#00FAD9":"#FF5072")),S.text(o.formatShortNumber(a.price)));const k=[];for(const t of u){const{middlePrice:i,rectangleHeight:r}=t,n=h({target:i}),o=p({minXLN10:N,maxXLN10:y,width:e,targetLN10:n}),s=g({maxHeight:x?b:j,gridAreaHeight:P,value:r});k.push(o,s+1)}const X=k.slice(),[M,B]=X;x?(X.push(s,l),X.push(s,P),X.push(M,P),X.push(M,B)):(X.unshift(M,P),X.unshift(s,P),X.unshift(s,l)),q&&(q.points(X),q.fill(x?v.leftLine||"#2c5b56":v.rightLine||"#7b3a48")),n.show()}}}},q=function({gridAreaHeight:e,gridAreaWidth:t,horizontalLineCount:r,verticalLineCount:s,color:l="#2A2A2D"}){return i.useMemo((()=>{const i=[],a=e/(r+1),u=[],d=t/(s+1);for(let e=0;e<r;e++){const r=a*(e+1);i.push([0,r,t,r])}for(let t=0;t<s;t++){const i=d*(t+1);u.push([i,0,i,e])}return o.jsxRuntimeExports.jsxs(o.jsxRuntimeExports.Fragment,{children:[i.map(((e,t)=>o.jsxRuntimeExports.jsx(n.Line,{points:e,stroke:l,strokeWidth:1,lineCap:"round",lineJoin:"round",tension:1,listening:!1},t))),u.map(((e,t)=>o.jsxRuntimeExports.jsx(n.Line,{points:e,stroke:l,strokeWidth:1,lineCap:"round",lineJoin:"round",tension:1,listening:!1},t)))]})}),[e,t,r,s,l])}({gridAreaHeight:P,gridAreaWidth:e,horizontalLineCount:9,verticalLineCount:7,color:v.grid}),H=function({minXLN10:e,maxXLN10:t,labelCount:r,gridAreaHeight:s,gridAreaWidth:l,color:a="#606066"}){return i.useMemo((()=>{const i=l/(r+1),u=[],d=[];for(let n=0;n<r;n++){const r=i/2+i*n;u.push({x:r,y:s+10.08+1,text:o.formatShortNumber(c({x:i*(n+1),width:l,minXLN10:e,maxXLN10:t}))});const a=i*(n+1);d.push([a,s+1,a,s+4+1])}return o.jsxRuntimeExports.jsxs(o.jsxRuntimeExports.Fragment,{children:[u.map(((e,t)=>o.jsxRuntimeExports.jsx(n.Text,{x:e.x,y:e.y,text:e.text,fontSize:14,fontFamily:"Manrope",fill:a,width:i,padding:0,align:"center",verticalAlign:"bottom",listening:!1},t))),d.map(((e,t)=>o.jsxRuntimeExports.jsx(n.Line,{points:e,stroke:a,strokeWidth:1,lineCap:"butt",lineJoin:"miter",tension:1,listening:!1},t)))]})}),[e,t,s,l,r])}({gridAreaHeight:P,gridAreaWidth:e,labelCount:7,minXLN10:N,maxXLN10:y,color:v.textColor}),E=function({gridAreaHeight:e,gridAreaWidth:t,color:r="#606066"}){return i.useMemo((()=>{const i=t/2;return o.jsxRuntimeExports.jsx(n.Line,{points:[i,0,i,e-1],stroke:r,strokeWidth:1,lineCap:"round",lineJoin:"round",tension:1,listening:!1})}),[e,t,r])}({gridAreaHeight:P,gridAreaWidth:e,color:v.midPriceLine}),{leftLine:k,rightLine:X}=function({leftStatAreaPoints:e,rightStatAreaPoints:t,minXLN10:r,maxXLN10:s,maxLeftHeight:l,maxRightHeight:a,gridAreaWidth:u,gridAreaHeight:d,colorMap:m}){return{leftLine:i.useMemo((()=>{if(e.length<1)return o.jsxRuntimeExports.jsx(o.jsxRuntimeExports.Fragment,{});const t=[];let i=d;for(const n of e){const{middlePrice:e,rectangleHeight:o}=n,a=h({target:e}),m=p({minXLN10:r,maxXLN10:s,width:u,targetLN10:a}),c=g({maxHeight:l,gridAreaHeight:d,value:o});t.push(m,c),c<i&&(i=c)}const a=t.slice(),[c,x]=a,f=a[a.length-1],L=a[a.length-2];return a.push(L,f),a.push(L,d),a.push(c,d),a.push(c,x),o.jsxRuntimeExports.jsxs(o.jsxRuntimeExports.Fragment,{children:[o.jsxRuntimeExports.jsx(n.Line,{points:a,closed:!0,listening:!1,lineCap:"round",lineJoin:"round",fillLinearGradientStartPoint:{x:0,y:d},fillLinearGradientEndPoint:{x:0,y:i},fillLinearGradientColorStops:m.leftBg}),o.jsxRuntimeExports.jsx(n.Line,{points:t,stroke:m.leftLine,strokeWidth:2,lineCap:"round",lineJoin:"round",listening:!1})]})}),[e,u,r,s,d,l]),rightLine:i.useMemo((()=>{if(t.length<1)return o.jsxRuntimeExports.jsx(o.jsxRuntimeExports.Fragment,{});const e=[];let i=d;for(const n of t){const{middlePrice:t,rectangleHeight:o}=n,l=h({target:t}),m=p({minXLN10:r,maxXLN10:s,width:u,targetLN10:l}),c=g({maxHeight:a,gridAreaHeight:d,value:o});e.push(m,c),c<i&&(i=c)}const l=e.slice(),[c]=l;return l.unshift(c,d),l.unshift(u,d),o.jsxRuntimeExports.jsxs(o.jsxRuntimeExports.Fragment,{children:[o.jsxRuntimeExports.jsx(n.Line,{points:l,closed:!0,listening:!1,lineCap:"round",lineJoin:"round",fillLinearGradientStartPoint:{x:0,y:d},fillLinearGradientEndPoint:{x:0,y:i},fillLinearGradientColorStops:m.rightBg}),o.jsxRuntimeExports.jsx(n.Line,{points:e,stroke:m.rightLine,strokeWidth:2,lineCap:"round",lineJoin:"round",listening:!1})]})}),[t,u,r,s,d,a])}}({leftStatAreaPoints:w,rightStatAreaPoints:A,minXLN10:N,maxXLN10:y,maxLeftHeight:b,maxRightHeight:j,gridAreaWidth:e,gridAreaHeight:P,colorMap:v});return o.jsxRuntimeExports.jsxs(n.Stage,{width:e,height:a,onMouseMove:S,onMouseOver:S,onMouseEnter:S,onMouseOut:()=>{const{current:e}=R;e&&e.hide()},children:[o.jsxRuntimeExports.jsxs(n.Layer,{children:[o.jsxRuntimeExports.jsx(n.Rect,{x:0,y:0,width:e,height:P,stroke:v.grid,strokeWidth:1}),q,H,k,X,E]}),o.jsxRuntimeExports.jsxs(n.Layer,{ref:R,visible:!1,children:[o.jsxRuntimeExports.jsx(n.Line,{points:[],closed:!0,listening:!1,lineCap:"round",lineJoin:"round",id:"area"}),o.jsxRuntimeExports.jsx(n.Line,{points:[],strokeWidth:1,stroke:"#ff4f73",lineJoin:"round",lineCap:"round",dash:[4,6],id:"toolTipVertLine"}),o.jsxRuntimeExports.jsx(n.Circle,{x:0,y:0,radius:5,fill:"#FF5072",stroke:"rgba(255, 80, 114, 0.3)",strokeWidth:12,id:"joinCircle"}),o.jsxRuntimeExports.jsxs(n.Label,{listening:!1,x:0,y:0,id:"priceTextLabel",children:[o.jsxRuntimeExports.jsx(n.Tag,{fill:v.tooltipBg,id:"priceTextLabel-tag"}),o.jsxRuntimeExports.jsx(n.Text,{text:"-",fontSize:14,fontFamily:"Manrope",padding:2,fill:"#FF5072",id:"priceTextLabel-text"})]}),o.jsxRuntimeExports.jsxs(n.Label,{listening:!1,id:"tooltip",children:[o.jsxRuntimeExports.jsx(n.Tag,{fill:v.tooltipBg,pointerDirection:"down",pointerWidth:15,pointerHeight:8,cornerRadius:8,lineJoin:"round",id:"tooltip-tag"}),o.jsxRuntimeExports.jsx(n.Text,{text:"",fontFamily:"Manrope",fontSize:12,lineHeight:17/12,padding:r.labelPadding,fill:"#FF5072",id:"tooltip-Text"})]})]})]})}exports.default=({width:e=834,height:t=462,baseTokenSymbol:i,quoteTokenSymbol:n,pmmModel:s,pmmParams:l,midPrice:d,notShowTipText:g,colorMap:m})=>o.jsxRuntimeExports.jsxs(a,{children:[void 0!==l&&void 0!==d&&void 0!==s&&void 0!==d&&o.jsxRuntimeExports.jsx(f,{width:e,height:t,params:l,midPrice:d,pmmModel:s,baseTokenSymbol:i,quoteTokenSymbol:n,colorMap:m}),g?"":o.jsxRuntimeExports.jsxs(u,{children:["* ",r.chartT("pool.chart.liquidity-chart-tip",{baseTokenSymbol:i})]})]});
|