@goodaofi/bonds-sdk 3.0.168 → 3.0.169
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/main.js +33 -7
- package/dist/state/useSDKConfig.d.ts +2 -0
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -70587,16 +70587,42 @@ function useCurrencyPrice(currency, chainId) {
|
|
|
70587
70587
|
}
|
|
70588
70588
|
return currency;
|
|
70589
70589
|
}, [currency, chainId]);
|
|
70590
|
+
// TEMPORARY: GOO/sGOO price override — controlled via SDKConfig.useGooPriceOverride
|
|
70591
|
+
const SDKConfig = useSDKConfig();
|
|
70592
|
+
const GOO_SATS_PRICE = 4;
|
|
70593
|
+
const isGooToken = (SDKConfig === null || SDKConfig === void 0 ? void 0 : SDKConfig.useGooPriceOverride) &&
|
|
70594
|
+
currency &&
|
|
70595
|
+
currency !== 'NATIVE' &&
|
|
70596
|
+
(currency.symbol === 'GOO' || currency.symbol === 'sGOO');
|
|
70597
|
+
const btcPrice = useMemo(() => {
|
|
70598
|
+
var _a, _b;
|
|
70599
|
+
if (!isGooToken || !tokenPrices)
|
|
70600
|
+
return undefined;
|
|
70601
|
+
const btcToken = BTC_TOKENS[chainId];
|
|
70602
|
+
const btcAddr = (_a = btcToken === null || btcToken === void 0 ? void 0 : btcToken.address) === null || _a === void 0 ? void 0 : _a[chainId];
|
|
70603
|
+
return (_b = tokenPrices.find((tp) => { var _a; return tp.chainId === chainId && ((_a = tp.address) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === (btcAddr === null || btcAddr === void 0 ? void 0 : btcAddr.toLowerCase()); })) === null || _b === void 0 ? void 0 : _b.price;
|
|
70604
|
+
}, [isGooToken, tokenPrices === null || tokenPrices === void 0 ? void 0 : tokenPrices.length, chainId]);
|
|
70590
70605
|
const token = currencyForPrice === 'NATIVE' && chainId ? WNATIVE[chainId] : currencyForPrice;
|
|
70591
70606
|
const tokenAddress = (_a = token === null || token === void 0 ? void 0 : token.address) === null || _a === void 0 ? void 0 : _a[chainId];
|
|
70592
|
-
return useMemo(() =>
|
|
70593
|
-
|
|
70594
|
-
|
|
70595
|
-
|
|
70596
|
-
|
|
70597
|
-
|
|
70607
|
+
return useMemo(() => {
|
|
70608
|
+
// TEMPORARY: Return synthetic price for GOO/sGOO
|
|
70609
|
+
if (isGooToken && btcPrice) {
|
|
70610
|
+
return {
|
|
70611
|
+
symbol: currency.symbol,
|
|
70612
|
+
address: tokenAddress,
|
|
70613
|
+
price: (GOO_SATS_PRICE / 100000000) * btcPrice,
|
|
70614
|
+
chainId: chainId,
|
|
70615
|
+
};
|
|
70616
|
+
}
|
|
70617
|
+
return tokenPrices === null || tokenPrices === void 0 ? void 0 : tokenPrices.find((tokenPrice) => {
|
|
70618
|
+
var _a;
|
|
70619
|
+
return chainId &&
|
|
70620
|
+
tokenPrice.chainId === chainId &&
|
|
70621
|
+
((_a = tokenPrice === null || tokenPrice === void 0 ? void 0 : tokenPrice.address) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === (tokenAddress === null || tokenAddress === void 0 ? void 0 : tokenAddress.toLowerCase());
|
|
70622
|
+
});
|
|
70623
|
+
},
|
|
70598
70624
|
/* eslint-disable react-hooks/exhaustive-deps */
|
|
70599
|
-
[tokenPrices === null || tokenPrices === void 0 ? void 0 : tokenPrices.length, tokenAddress, chainId]);
|
|
70625
|
+
[tokenPrices === null || tokenPrices === void 0 ? void 0 : tokenPrices.length, tokenAddress, chainId, isGooToken, btcPrice]);
|
|
70600
70626
|
}
|
|
70601
70627
|
|
|
70602
70628
|
const remove0xPrefix = (str) => {
|
|
@@ -14,6 +14,7 @@ export interface SDKPropsDTO {
|
|
|
14
14
|
highestCompatibleVersion?: string;
|
|
15
15
|
isFakeBTC?: boolean;
|
|
16
16
|
privatePartnerName?: string;
|
|
17
|
+
useGooPriceOverride?: boolean;
|
|
17
18
|
}
|
|
18
19
|
export interface SDKProps {
|
|
19
20
|
referenceId: string;
|
|
@@ -31,6 +32,7 @@ export interface SDKProps {
|
|
|
31
32
|
highestCompatibleVersion?: string;
|
|
32
33
|
isFakeBTC?: boolean;
|
|
33
34
|
privatePartnerName?: string;
|
|
35
|
+
useGooPriceOverride?: boolean;
|
|
34
36
|
}
|
|
35
37
|
export declare const useSDKConfig: (config?: SDKPropsDTO) => SDKProps;
|
|
36
38
|
export type URLKeys = 'apiV2' | 'realTimeApi' | 'mainUrl';
|