Skip to content

Commit f675a6d

Browse files
authored
Merge branch 'develop' into add-isPage-fn-to-useLinkGen
2 parents 0cae07a + 87a5178 commit f675a6d

File tree

117 files changed

+1941
-1601
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

117 files changed

+1941
-1601
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ambient-ts-app",
3-
"version": "2.3.29",
3+
"version": "2.3.34",
44
"private": true,
55
"dependencies": {
66
"@crocswap-libs/sdk": "^0.3.2",

public/ambient-token-list.json

+8-8
Original file line numberDiff line numberDiff line change
@@ -186,22 +186,22 @@
186186
"logoURI": "https://blastscan.io/token/images/openleverageole_32.png"
187187
},
188188
{
189-
"address": "0x7217124c626f0b7077be91df939195c9a8184ecc",
189+
"address": "0x818a92bc81aad0053d72ba753fb5bc3d0c5c0923",
190190
"chainId": 81457,
191191
"decimals": 18,
192192
"fromList": "/ambient-token-list.json",
193-
"name": "Finger Blast",
194-
"symbol": "FINGER",
195-
"logoURI": "https://blastscan.io/token/images/fingerblast_32.png"
193+
"name": "JUICE",
194+
"symbol": "JUICE",
195+
"logoURI": ""
196196
},
197197
{
198-
"address": "0xd582879453337bd149ae53ec2092b0af5281d1d7",
198+
"address": "0x2416092f143378750bb29b79eD961ab195CcEea5",
199199
"chainId": 81457,
200200
"decimals": 18,
201201
"fromList": "/ambient-token-list.json",
202-
"name": "Sekai Glory",
203-
"symbol": "GLORY",
204-
"logoURI": "https://blastscan.io/token/images/sekaiglory_32.png"
202+
"name": "Renzo Restaked ETH",
203+
"symbol": "ezETH",
204+
"logoURI": "https://etherscan.io/token/images/ezETHv2_32.png"
205205
},
206206
{
207207
"address": "0xb9dfCd4CF589bB8090569cb52FaC1b88Dbe4981F",

public/scroll-badge/1.json

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"name": "Ambient Swapooor",
3+
"description": "Swapooor! You have made a swap on Ambient Finance for over $500. (Art by @ShizzyAizawa)",
4+
"attributes": [
5+
{ "trait_type": "Variant", "value": "Swap" },
6+
{ "trait_type": "Amount", "value": "500" },
7+
{ "trait_type": "Artist", "value": "@ShizzyAizawa" }
8+
],
9+
"image": "https://ambient.finance/scroll-badge/1.png"
10+
}

public/scroll-badge/1.png

2.37 MB
Loading

public/scroll-badge/2.json

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"name": "Ambient Providoor",
3+
"description": "Providoor! You have minted an LP position on Ambient Finance valued over $1000. (Art by @ShizzyAizawa)",
4+
"attributes": [
5+
{ "trait_type": "Variant", "value": "LP" },
6+
{ "trait_type": "Amount", "value": "1000" },
7+
{ "trait_type": "Artist", "value": "@ShizzyAizawa" }
8+
],
9+
"image": "https://ambient.finance/scroll-badge/2.png"
10+
}

public/scroll-badge/2.png

2.43 MB
Loading

public/scroll-badge/3.json

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"name": "Ambient Filloor",
3+
"description": "Filloor! You have filled a limit on Ambient Finance valued over $500. (Art by @ShizzyAizawa)",
4+
"attributes": [
5+
{ "trait_type": "Variant", "value": "Limit Order" },
6+
{ "trait_type": "Amount", "value": "500" },
7+
{ "trait_type": "Artist", "value": "@ShizzyAizawa" }
8+
],
9+
"image": "https://ambient.finance/scroll-badge/3.png"
10+
}

public/scroll-badge/3.png

2.32 MB
Loading

public/scroll-badge/4.json

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"name": "Ambient Yeet",
3+
"description": "Yeet! You are providing a modest amount of liquidity in a single position. You will be rewarded accordingly to the size! For now, enjoy having a differently colored croc. (Art by @ShizzyAizawa)",
4+
"attributes": [
5+
{ "trait_type": "Variant", "value": "Big LP" },
6+
{ "trait_type": "Amount", "value": "100000" },
7+
{ "trait_type": "Artist", "value": "@ShizzyAizawa" }
8+
],
9+
"image": "https://ambient.finance/scroll-badge/4.png"
10+
}

public/scroll-badge/4.png

2.46 MB
Loading

public/scroll-badge/unrevealed.png

1.77 MB
Loading

src/App/components/PageHeader/PageHeader.tsx

+8-4
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ const PageHeader = function () {
6767
const { resetTokenBalances } = useContext(TokenBalanceContext);
6868
const { resetUserGraphData } = useContext(GraphDataContext);
6969

70-
const { poolPriceDisplay } = useContext(PoolContext);
70+
const { poolPriceDisplay, isUsdConversionEnabled, usdPrice } =
71+
useContext(PoolContext);
7172
const { recentPools } = useContext(SidebarContext);
7273
const { setShowAllData } = useContext(TradeTableContext);
7374
const {
@@ -151,9 +152,12 @@ const PageHeader = function () {
151152
: poolPriceDisplay
152153
: undefined;
153154

154-
const truncatedPoolPrice = getFormattedNumber({
155-
value: poolPriceDisplayWithDenom,
156-
});
155+
const truncatedPoolPrice =
156+
usdPrice && isUsdConversionEnabled
157+
? getFormattedNumber({ value: usdPrice, prefix: '$' })
158+
: getFormattedNumber({
159+
value: poolPriceDisplayWithDenom,
160+
});
157161

158162
useEffect(() => {
159163
const path = location.pathname;

src/App/hooks/useFetchPoolStats.ts

+78-15
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
getUnicodeCharacter,
99
getMoneynessRank,
1010
getFormattedNumber,
11+
expandPoolStats,
1112
} from '../../ambient-utils/dataLayer';
1213
// import { estimateFrom24HrRangeApr } from '../../ambient-utils/api';
1314
import { sortBaseQuoteTokens, toDisplayPrice } from '@crocswap-libs/sdk';
@@ -194,6 +195,51 @@ const useFetchPoolStats = (pool: PoolIF, isTradePair = false): PoolStatIF => {
194195
resetPoolStats();
195196
}, [baseAddr + quoteAddr]);
196197

198+
const [basePrice, setBasePrice] = useState<number | undefined>();
199+
const [quotePrice, setQuotePrice] = useState<number | undefined>();
200+
201+
useEffect(() => {
202+
if (crocEnv) {
203+
const fetchTokenPrice = async () => {
204+
const baseTokenPrice =
205+
(await cachedFetchTokenPrice(baseAddr, chainId, crocEnv))
206+
?.usdPrice || 0.0;
207+
const quoteTokenPrice =
208+
(await cachedFetchTokenPrice(quoteAddr, chainId, crocEnv))
209+
?.usdPrice || 0.0;
210+
211+
if (baseTokenPrice) {
212+
setBasePrice(baseTokenPrice);
213+
} else if (poolPriceDisplayNum && quoteTokenPrice) {
214+
// calculation of estimated base price below may be backwards;
215+
// having a hard time finding an example of base missing a price
216+
const estimatedBasePrice =
217+
quoteTokenPrice / poolPriceDisplayNum;
218+
setBasePrice(estimatedBasePrice);
219+
} else {
220+
setBasePrice(undefined);
221+
}
222+
if (quoteTokenPrice) {
223+
setQuotePrice(quoteTokenPrice);
224+
} else if (poolPriceDisplayNum && baseTokenPrice) {
225+
const estimatedQuotePrice =
226+
baseTokenPrice * poolPriceDisplayNum;
227+
setQuotePrice(estimatedQuotePrice);
228+
} else {
229+
setQuotePrice(undefined);
230+
}
231+
};
232+
233+
fetchTokenPrice();
234+
}
235+
}, [
236+
baseAddr,
237+
quoteAddr,
238+
chainId,
239+
crocEnv !== undefined,
240+
poolPriceDisplayNum,
241+
]);
242+
197243
const fetchPoolStats = async () => {
198244
if (
199245
poolIndex &&
@@ -209,10 +255,18 @@ const useFetchPoolStats = (pool: PoolIF, isTradePair = false): PoolStatIF => {
209255
pool.quote.address,
210256
poolIndex,
211257
Math.floor(Date.now() / CACHE_UPDATE_FREQ_IN_MS),
212-
crocEnv,
213258
activeNetwork.graphCacheUrl,
259+
);
260+
261+
const expandedPoolStatsNow = await expandPoolStats(
262+
poolStatsNow,
263+
pool.base.address,
264+
pool.quote.address,
265+
chainId,
266+
crocEnv,
214267
cachedFetchTokenPrice,
215268
cachedTokenDetails,
269+
cachedQuerySpotPrice,
216270
tokens.tokenUniv,
217271
);
218272

@@ -224,21 +278,28 @@ const useFetchPoolStats = (pool: PoolIF, isTradePair = false): PoolStatIF => {
224278
pool.quote.address,
225279
poolIndex,
226280
Math.floor(Date.now() / CACHE_UPDATE_FREQ_IN_MS),
227-
crocEnv,
228281
activeNetwork.graphCacheUrl,
282+
ydayTime,
283+
);
284+
285+
const expandedPoolStats24hAgo = await expandPoolStats(
286+
poolStats24hAgo,
287+
pool.base.address,
288+
pool.quote.address,
289+
chainId,
290+
crocEnv,
229291
cachedFetchTokenPrice,
230292
cachedTokenDetails,
293+
cachedQuerySpotPrice,
231294
tokens.tokenUniv,
232-
ydayTime,
233295
);
234296

235-
const volumeTotalNow = poolStatsNow?.volumeTotalUsd;
236-
const volumeTotal24hAgo = poolStats24hAgo?.volumeTotalUsd;
237-
297+
const volumeTotalNow = expandedPoolStatsNow?.volumeTotalUsd;
298+
const volumeTotal24hAgo = expandedPoolStats24hAgo?.volumeTotalUsd;
238299
const volumeChange24h = volumeTotalNow - volumeTotal24hAgo;
239300

240-
const nowPrice = poolStatsNow?.lastPriceIndic;
241-
const ydayPrice = poolStats24hAgo?.lastPriceIndic;
301+
const nowPrice = expandedPoolStatsNow?.lastPriceIndic;
302+
const ydayPrice = expandedPoolStats24hAgo?.lastPriceIndic;
242303

243304
const priceChangeResult =
244305
ydayPrice && nowPrice && ydayPrice > 0 && nowPrice > 0
@@ -247,14 +308,14 @@ const useFetchPoolStats = (pool: PoolIF, isTradePair = false): PoolStatIF => {
247308
: nowPrice / ydayPrice - 1.0
248309
: 0.0;
249310

250-
const tvlResult = poolStatsNow?.tvlTotalUsd;
251-
const feesTotalResult = poolStatsNow?.feesTotalUsd;
252-
const volumeResult = poolStatsNow?.volumeTotalUsd;
311+
const tvlResult = expandedPoolStatsNow?.tvlTotalUsd;
312+
const feesTotalResult = expandedPoolStatsNow?.feesTotalUsd;
313+
const volumeResult = expandedPoolStatsNow?.volumeTotalUsd;
253314

254-
setQuoteTvlDecimal(poolStatsNow.quoteTvlDecimal);
255-
setBaseTvlDecimal(poolStatsNow.baseTvlDecimal);
256-
setQuoteTvlUsd(poolStatsNow.quoteTvlUsd);
257-
setBaseTvlUsd(poolStatsNow.baseTvlUsd);
315+
setQuoteTvlDecimal(expandedPoolStatsNow.quoteTvlDecimal);
316+
setBaseTvlDecimal(expandedPoolStatsNow.baseTvlDecimal);
317+
setQuoteTvlUsd(expandedPoolStatsNow.quoteTvlUsd);
318+
setBaseTvlUsd(expandedPoolStatsNow.baseTvlUsd);
258319

259320
if (tvlResult) {
260321
const tvlString = getFormattedNumber({
@@ -396,6 +457,8 @@ const useFetchPoolStats = (pool: PoolIF, isTradePair = false): PoolStatIF => {
396457
baseTvlUsd,
397458
quoteTvlDecimal,
398459
baseTvlDecimal,
460+
basePrice,
461+
quotePrice,
399462
};
400463
};
401464
export default useFetchPoolStats;

src/ambient-utils/api/fetchCandleSeries.ts

+35-8
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
import { ChainSpec, CrocEnv } from '@crocswap-libs/sdk';
2-
import { GCGO_OVERRIDE_URL } from '../constants';
1+
import { ChainSpec, CrocEnv, toDisplayPrice } from '@crocswap-libs/sdk';
2+
import { CACHE_UPDATE_FREQ_IN_MS, GCGO_OVERRIDE_URL } from '../constants';
33
import {
44
CandlesByPoolAndDurationIF,
55
CandleDataIF,
66
CandleDataServerIF,
77
} from '../types/candleData';
88
import { TokenPriceFn } from './fetchTokenPrice';
9+
import { SpotPriceFn } from '../dataLayer';
910

1011
export async function fetchCandleSeriesHybrid(
1112
isFetchEnabled: boolean,
@@ -18,6 +19,7 @@ export async function fetchCandleSeriesHybrid(
1819
nCandles: number,
1920
crocEnv: CrocEnv,
2021
cachedFetchTokenPrice: TokenPriceFn,
22+
cachedQuerySpotPrice: SpotPriceFn,
2123
signal?: AbortSignal,
2224
): Promise<CandlesByPoolAndDurationIF | undefined> {
2325
const candles = await fetchCandleSeriesCroc(
@@ -31,6 +33,7 @@ export async function fetchCandleSeriesHybrid(
3133
nCandles,
3234
crocEnv,
3335
cachedFetchTokenPrice,
36+
cachedQuerySpotPrice,
3437
signal,
3538
);
3639

@@ -101,6 +104,7 @@ export async function fetchCandleSeriesCroc(
101104
nCandles: number,
102105
crocEnv: CrocEnv,
103106
cachedFetchTokenPrice: TokenPriceFn,
107+
cachedQuerySpotPrice: SpotPriceFn,
104108
signal?: AbortSignal,
105109
): Promise<CandlesByPoolAndDurationIF | undefined> {
106110
if (!isFetchEnabled) {
@@ -144,6 +148,7 @@ export async function fetchCandleSeriesCroc(
144148
chainData.chainId,
145149
crocEnv,
146150
cachedFetchTokenPrice,
151+
cachedQuerySpotPrice,
147152
);
148153

149154
return {
@@ -193,20 +198,42 @@ async function expandPoolStats(
193198
chainId: string,
194199
crocEnv: CrocEnv,
195200
cachedFetchTokenPrice: TokenPriceFn,
201+
cachedQuerySpotPrice: SpotPriceFn,
196202
): Promise<CandleDataIF[]> {
197-
const baseDecimals = crocEnv.token(base).decimals;
198-
const quoteDecimals = crocEnv.token(quote).decimals;
203+
const baseDecimals = await crocEnv.token(base).decimals;
204+
const quoteDecimals = await crocEnv.token(quote).decimals;
199205

200206
const basePricePromise = cachedFetchTokenPrice(base, chainId, crocEnv);
201207
const quotePricePromise = cachedFetchTokenPrice(quote, chainId, crocEnv);
202208

203-
const basePrice = (await basePricePromise)?.usdPrice || 0.0;
204-
const quotePrice = (await quotePricePromise)?.usdPrice || 0.0;
209+
const baseUsdPrice = (await basePricePromise)?.usdPrice;
210+
const quoteUsdPrice = (await quotePricePromise)?.usdPrice;
211+
212+
const spotPrice = await cachedQuerySpotPrice(
213+
crocEnv,
214+
base,
215+
quote,
216+
chainId,
217+
Math.floor(Date.now() / CACHE_UPDATE_FREQ_IN_MS),
218+
);
219+
220+
const displayPrice = toDisplayPrice(spotPrice, baseDecimals, quoteDecimals);
221+
222+
const basePrice = baseUsdPrice
223+
? baseUsdPrice
224+
: displayPrice && quoteUsdPrice
225+
? quoteUsdPrice / displayPrice
226+
: 0.0;
227+
const quotePrice = quoteUsdPrice
228+
? quoteUsdPrice
229+
: displayPrice && baseUsdPrice
230+
? baseUsdPrice * displayPrice
231+
: 0.0;
205232

206233
return decorateCandleData(
207234
payload,
208-
await baseDecimals,
209-
await quoteDecimals,
235+
baseDecimals,
236+
quoteDecimals,
210237
basePrice,
211238
quotePrice,
212239
).reverse();

src/ambient-utils/constants/ambient-token-list.json

+8-8
Original file line numberDiff line numberDiff line change
@@ -186,22 +186,22 @@
186186
"logoURI": "https://blastscan.io/token/images/openleverageole_32.png"
187187
},
188188
{
189-
"address": "0x7217124c626f0b7077be91df939195c9a8184ecc",
189+
"address": "0x818a92bc81aad0053d72ba753fb5bc3d0c5c0923",
190190
"chainId": 81457,
191191
"decimals": 18,
192192
"fromList": "/ambient-token-list.json",
193-
"name": "Finger Blast",
194-
"symbol": "FINGER",
195-
"logoURI": "https://blastscan.io/token/images/fingerblast_32.png"
193+
"name": "JUICE",
194+
"symbol": "JUICE",
195+
"logoURI": ""
196196
},
197197
{
198-
"address": "0xd582879453337bd149ae53ec2092b0af5281d1d7",
198+
"address": "0x2416092f143378750bb29b79eD961ab195CcEea5",
199199
"chainId": 81457,
200200
"decimals": 18,
201201
"fromList": "/ambient-token-list.json",
202-
"name": "Sekai Glory",
203-
"symbol": "GLORY",
204-
"logoURI": "https://blastscan.io/token/images/sekaiglory_32.png"
202+
"name": "Renzo Restaked ETH",
203+
"symbol": "ezETH",
204+
"logoURI": "https://etherscan.io/token/images/ezETHv2_32.png"
205205
},
206206
{
207207
"address": "0xb9dfCd4CF589bB8090569cb52FaC1b88Dbe4981F",

0 commit comments

Comments
 (0)