@goodaofi/bonds-sdk 3.0.167 → 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 +99 -13
- 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) => {
|
|
@@ -70808,8 +70834,32 @@ const VESTING_NFT_ABI = [
|
|
|
70808
70834
|
type: 'function',
|
|
70809
70835
|
},
|
|
70810
70836
|
];
|
|
70837
|
+
// Minimal ERC20 ABI for fetching token metadata
|
|
70838
|
+
const ERC20_ABI = [
|
|
70839
|
+
{
|
|
70840
|
+
inputs: [],
|
|
70841
|
+
name: 'name',
|
|
70842
|
+
outputs: [{ internalType: 'string', name: '', type: 'string' }],
|
|
70843
|
+
stateMutability: 'view',
|
|
70844
|
+
type: 'function',
|
|
70845
|
+
},
|
|
70846
|
+
{
|
|
70847
|
+
inputs: [],
|
|
70848
|
+
name: 'symbol',
|
|
70849
|
+
outputs: [{ internalType: 'string', name: '', type: 'string' }],
|
|
70850
|
+
stateMutability: 'view',
|
|
70851
|
+
type: 'function',
|
|
70852
|
+
},
|
|
70853
|
+
{
|
|
70854
|
+
inputs: [],
|
|
70855
|
+
name: 'decimals',
|
|
70856
|
+
outputs: [{ internalType: 'uint8', name: '', type: 'uint8' }],
|
|
70857
|
+
stateMutability: 'view',
|
|
70858
|
+
type: 'function',
|
|
70859
|
+
},
|
|
70860
|
+
];
|
|
70811
70861
|
// Hardcoded vesting NFT contract address
|
|
70812
|
-
const VESTING_NFT_ADDRESS$1 = '
|
|
70862
|
+
const VESTING_NFT_ADDRESS$1 = '0x1d792892823306D15C9c65938f9385fC2dA97271';
|
|
70813
70863
|
const VESTING_NFT_CHAIN_ID = main.ChainId.BASE;
|
|
70814
70864
|
const fetchVestingNftBills = (account) => __awaiter$9(void 0, void 0, void 0, function* () {
|
|
70815
70865
|
try {
|
|
@@ -70848,6 +70898,33 @@ const fetchVestingNftBills = (account) => __awaiter$9(void 0, void 0, void 0, fu
|
|
|
70848
70898
|
]);
|
|
70849
70899
|
const detailResults = yield multicall(VESTING_NFT_CHAIN_ID, VESTING_NFT_ABI, detailCalls);
|
|
70850
70900
|
const result = [];
|
|
70901
|
+
// Collect unique payout token addresses to fetch their metadata
|
|
70902
|
+
const payoutTokenAddresses = new Set();
|
|
70903
|
+
for (let i = 0; i < tokenIds.length; i++) {
|
|
70904
|
+
const schedule = detailResults[i * 2][0];
|
|
70905
|
+
payoutTokenAddresses.add(schedule.payoutToken);
|
|
70906
|
+
}
|
|
70907
|
+
// Fetch ERC20 metadata (name, symbol, decimals) for each unique payout token
|
|
70908
|
+
const tokenMetadata = {};
|
|
70909
|
+
for (const tokenAddress of payoutTokenAddresses) {
|
|
70910
|
+
try {
|
|
70911
|
+
const erc20Calls = [
|
|
70912
|
+
{ address: tokenAddress, name: 'name', params: [] },
|
|
70913
|
+
{ address: tokenAddress, name: 'symbol', params: [] },
|
|
70914
|
+
{ address: tokenAddress, name: 'decimals', params: [] },
|
|
70915
|
+
];
|
|
70916
|
+
const erc20Results = yield multicall(VESTING_NFT_CHAIN_ID, ERC20_ABI, erc20Calls);
|
|
70917
|
+
tokenMetadata[tokenAddress] = {
|
|
70918
|
+
name: erc20Results[0][0],
|
|
70919
|
+
symbol: erc20Results[1][0],
|
|
70920
|
+
decimals: Number(erc20Results[2][0]),
|
|
70921
|
+
};
|
|
70922
|
+
}
|
|
70923
|
+
catch (e) {
|
|
70924
|
+
console.error(`Error fetching ERC20 metadata for ${tokenAddress}:`, e);
|
|
70925
|
+
tokenMetadata[tokenAddress] = { name: 'Unknown', symbol: 'UNKNOWN', decimals: 18 };
|
|
70926
|
+
}
|
|
70927
|
+
}
|
|
70851
70928
|
for (let i = 0; i < tokenIds.length; i++) {
|
|
70852
70929
|
const scheduleResult = detailResults[i * 2];
|
|
70853
70930
|
const claimableResult = detailResults[i * 2 + 1];
|
|
@@ -70861,6 +70938,8 @@ const fetchVestingNftBills = (account) => __awaiter$9(void 0, void 0, void 0, fu
|
|
|
70861
70938
|
// Calculate durations in seconds (expected by displayHelpers)
|
|
70862
70939
|
const vestingDuration = vestingEnd - vestingStart;
|
|
70863
70940
|
const vestingCliff = cliffEnd - vestingStart;
|
|
70941
|
+
const payoutTokenAddress = schedule.payoutToken;
|
|
70942
|
+
const tokenMeta = tokenMetadata[payoutTokenAddress];
|
|
70864
70943
|
// Map to UserBill format
|
|
70865
70944
|
result.push({
|
|
70866
70945
|
address: VESTING_NFT_ADDRESS$1,
|
|
@@ -70880,10 +70959,10 @@ const fetchVestingNftBills = (account) => __awaiter$9(void 0, void 0, void 0, fu
|
|
|
70880
70959
|
billNnftAddress: { [VESTING_NFT_CHAIN_ID]: VESTING_NFT_ADDRESS$1 },
|
|
70881
70960
|
vestingCliff: vestingCliff > 0 ? vestingCliff : undefined,
|
|
70882
70961
|
earnToken: {
|
|
70883
|
-
symbol:
|
|
70884
|
-
name:
|
|
70885
|
-
address: { [VESTING_NFT_CHAIN_ID]:
|
|
70886
|
-
decimals: { [VESTING_NFT_CHAIN_ID]:
|
|
70962
|
+
symbol: tokenMeta.symbol,
|
|
70963
|
+
name: tokenMeta.name,
|
|
70964
|
+
address: { [VESTING_NFT_CHAIN_ID]: payoutTokenAddress },
|
|
70965
|
+
decimals: { [VESTING_NFT_CHAIN_ID]: tokenMeta.decimals },
|
|
70887
70966
|
},
|
|
70888
70967
|
},
|
|
70889
70968
|
});
|
|
@@ -100876,7 +100955,14 @@ const GooSale = () => {
|
|
|
100876
100955
|
p: '20px',
|
|
100877
100956
|
m: '20px',
|
|
100878
100957
|
borderRadius: 'normal',
|
|
100879
|
-
}, children: cbBTCBalanceChecked && (jsx$2(Flex, { sx: { flexDirection: 'column', alignItems: 'center', gap: '10px', mt: '10px' }, children: isCbBTCBalanceLoading ? (jsx$2(Text, { sx: { fontSize: '12px', fontWeight: 400 }, children: "Checking BTC balance across all chains..." })) : cbBTCBalance ? (jsxs(Fragment$1, { children: [cbBTCBalance.isEligible ? (addToWhitelistSuccess ? (jsx$2(Text, { color: "primaryButton", sx: { fontSize: '12px', fontWeight: 700 }, children: "\u2713 Successfully added to whitelist! Please refresh to see your tier." })) : addToWhitelistError ? (jsx$2(Text, { sx: { fontSize: '12px', fontWeight: 400, color: 'error' }, children: "Failed to add to whitelist. Please try again." })) : (jsx$2(Fragment$1, { children: jsx$2(Flex, { sx: { flexDirection: 'row', alignItems: 'center' }, children: jsxs(Text, { sx: { fontSize: '12px', fontWeight: 400 }, children: ["You ", jsx$2("span", { sx: { fontWeight: 700 }, children: "ARE" }), " eligible for the sale"] }) }) }))) : (jsxs(Flex, { sx: { flexDirection: 'column', alignItems: 'center', gap: '10px' }, children: [jsxs(Text, { sx: { fontSize: '12px', fontWeight: 400 }, children: ["You are ", jsx$2("span", { sx: { fontWeight: 700 }, children: "NOT" }), " eligible for the sale"] }), jsx$2(Text, { sx: { fontSize: '12px', fontWeight: 400, color: 'error' }, children: "You need at least 0.001 BTC to be whitelisted" })] })), jsxs(Text, { sx: { fontSize: '12px', fontWeight: 400 }, children: ["Total BTC Balance: ", cbBTCBalance.balance] }), cbBTCBalance.chainsWithBalance && cbBTCBalance.chainsWithBalance.length > 0 && (jsx$2(Flex, { sx: { flexDirection: 'column', gap: '5px', mt: '5px' }, children: cbBTCBalance.chainsWithBalance.map((chain) => (jsxs(Flex, { sx: { flexDirection: 'row', alignItems: 'center', gap: '10px' }, children: [jsx$2(TokenImage, { symbol: chain.symbol, size: 25, chain: chain.chainId }), jsxs(Text, { sx: { fontSize: '10px', fontWeight: 400, opacity: 0.7 }, children: [chain.balance, " ", chain.symbol] })] }, chain.chainId))) })), cbBTCBalance.isEligible && (jsx$2(Button, { sx: { width: '100%' }, onClick: () => addToWhitelist(), disabled: isAddingToWhitelist, children: isAddingToWhitelist ? 'ADDING TO WHITELIST...' : 'ADD ME TO WHITELIST' }))] })) : (jsx$2(Text, { sx: { fontSize: '12px', fontWeight: 400 }, children: "Unable to fetch BTC balance. Please try again." })) })) }))] })) : (jsx$2(Fragment$1, {}))] })),
|
|
100958
|
+
}, children: cbBTCBalanceChecked && (jsx$2(Flex, { sx: { flexDirection: 'column', alignItems: 'center', gap: '10px', mt: '10px' }, children: isCbBTCBalanceLoading ? (jsx$2(Text, { sx: { fontSize: '12px', fontWeight: 400 }, children: "Checking BTC balance across all chains..." })) : cbBTCBalance ? (jsxs(Fragment$1, { children: [cbBTCBalance.isEligible ? (addToWhitelistSuccess ? (jsx$2(Text, { color: "primaryButton", sx: { fontSize: '12px', fontWeight: 700 }, children: "\u2713 Successfully added to whitelist! Please refresh to see your tier." })) : addToWhitelistError ? (jsx$2(Text, { sx: { fontSize: '12px', fontWeight: 400, color: 'error' }, children: "Failed to add to whitelist. Please try again." })) : (jsx$2(Fragment$1, { children: jsx$2(Flex, { sx: { flexDirection: 'row', alignItems: 'center' }, children: jsxs(Text, { sx: { fontSize: '12px', fontWeight: 400 }, children: ["You ", jsx$2("span", { sx: { fontWeight: 700 }, children: "ARE" }), " eligible for the sale"] }) }) }))) : (jsxs(Flex, { sx: { flexDirection: 'column', alignItems: 'center', gap: '10px' }, children: [jsxs(Text, { sx: { fontSize: '12px', fontWeight: 400 }, children: ["You are ", jsx$2("span", { sx: { fontWeight: 700 }, children: "NOT" }), " eligible for the sale"] }), jsx$2(Text, { sx: { fontSize: '12px', fontWeight: 400, color: 'error' }, children: "You need at least 0.001 BTC to be whitelisted" })] })), jsxs(Text, { sx: { fontSize: '12px', fontWeight: 400 }, children: ["Total BTC Balance: ", cbBTCBalance.balance] }), cbBTCBalance.chainsWithBalance && cbBTCBalance.chainsWithBalance.length > 0 && (jsx$2(Flex, { sx: { flexDirection: 'column', gap: '5px', mt: '5px' }, children: cbBTCBalance.chainsWithBalance.map((chain) => (jsxs(Flex, { sx: { flexDirection: 'row', alignItems: 'center', gap: '10px' }, children: [jsx$2(TokenImage, { symbol: chain.symbol, size: 25, chain: chain.chainId }), jsxs(Text, { sx: { fontSize: '10px', fontWeight: 400, opacity: 0.7 }, children: [chain.balance, " ", chain.symbol] })] }, chain.chainId))) })), cbBTCBalance.isEligible && (jsx$2(Button, { sx: { width: '100%' }, onClick: () => addToWhitelist(), disabled: isAddingToWhitelist, children: isAddingToWhitelist ? 'ADDING TO WHITELIST...' : 'ADD ME TO WHITELIST' }))] })) : (jsx$2(Text, { sx: { fontSize: '12px', fontWeight: 400 }, children: "Unable to fetch BTC balance. Please try again." })) })) }))] })) : (jsx$2(Fragment$1, {}))] })), (saleInfo === null || saleInfo === void 0 ? void 0 : saleInfo.isSaleEnded) && (jsx$2(Flex, { sx: {
|
|
100959
|
+
display: 'flex',
|
|
100960
|
+
flexDirection: 'column',
|
|
100961
|
+
alignItems: 'center',
|
|
100962
|
+
justifyContent: 'center',
|
|
100963
|
+
width: '100%',
|
|
100964
|
+
p: '6%',
|
|
100965
|
+
}, children: jsx$2(Button, { sx: { width: '230px' }, onClick: () => (window.location.href = `${window.location.origin}/bonds`), children: "Start Bonding" }) })), jsxs(Flex, { sx: {
|
|
100880
100966
|
width: '100%',
|
|
100881
100967
|
alignItems: 'center',
|
|
100882
100968
|
px: '12%',
|
|
@@ -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';
|