@ape.swap/bonds-sdk 3.0.29 → 3.0.31-test
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
CHANGED
|
@@ -18808,7 +18808,6 @@ const TokenImage = ({ symbol, symbol2, size, chain, }) => {
|
|
|
18808
18808
|
|
|
18809
18809
|
const QUERY_KEYS = {
|
|
18810
18810
|
TIERS: 'tiers',
|
|
18811
|
-
AB_TEST_VALUE: 'ABTestValue',
|
|
18812
18811
|
// used values on SDK
|
|
18813
18812
|
BOND_API_STATS: 'ApeBond-SDK-bondApiStats',
|
|
18814
18813
|
SDK_CONFIG: 'ApeBond-SDK-sdkConfig',
|
|
@@ -18830,6 +18829,7 @@ const QUERY_KEYS = {
|
|
|
18830
18829
|
POP_UPS: 'ApeBond-SDK-popUps',
|
|
18831
18830
|
GEO_FENCING: 'ApeBond-SDK-geoFencing',
|
|
18832
18831
|
TIER_PROOF_SIG: 'ApeBond-SDK-tierProofSig',
|
|
18832
|
+
ACTIVE_VIEW: 'ApeBond-SDK-activeView',
|
|
18833
18833
|
};
|
|
18834
18834
|
|
|
18835
18835
|
function useCookie(key, defaultValue) {
|
|
@@ -18989,7 +18989,8 @@ const formatNumber$3 = (number, minPrecision = 2, maxPrecision = 2) => {
|
|
|
18989
18989
|
return number.toLocaleString('en-US', options);
|
|
18990
18990
|
};
|
|
18991
18991
|
// Formats a number with SI (International System of Units) sufixes
|
|
18992
|
-
const formatNumberSI = (
|
|
18992
|
+
const formatNumberSI = (num, digits = 2) => {
|
|
18993
|
+
const number = typeof num === 'string' ? parseFloat(num) : num;
|
|
18993
18994
|
const lookupSI = [
|
|
18994
18995
|
{ value: 1, symbol: '' },
|
|
18995
18996
|
{ value: 1e6, symbol: 'M' },
|
|
@@ -76438,7 +76439,7 @@ const BondCards = ({ bondData }) => {
|
|
|
76438
76439
|
borderBottomRightRadius: 'normal',
|
|
76439
76440
|
borderBottomLeftRadius: 'normal',
|
|
76440
76441
|
},
|
|
76441
|
-
}, children: [jsxs("div", { className: "bond-card-title", children: ["Max Buy", jsx$2(TooltipBubble, { className: "tooltip-bubble", body: jsx$2(Flex, { children: TooltipText.MaxBuy((_b = bondData === null || bondData === void 0 ? void 0 : bondData.earnToken) === null || _b === void 0 ? void 0 : _b.symbol) }), width: "230px", placement: "bottomLeft", transformTip: "translate(-5%, -5%)", children: jsx$2("div", { className: "bond-card-tooltip", children: jsx$2(Svg, { icon: "questionCircle", width: "12px" }) }) })] }), jsxs("div", { className: "bond-card-content", children: [jsx$2("div", { style: { paddingRight: '3px' }, children: jsx$2(TokenImage, { symbol: (_c = bondData.showcaseTokenName) !== null && _c !== void 0 ? _c : bondData.earnToken.symbol, size: 20 }) }), formatNumberSI(maxBuy(bondData).
|
|
76442
|
+
}, children: [jsxs("div", { className: "bond-card-title", children: ["Max Buy", jsx$2(TooltipBubble, { className: "tooltip-bubble", body: jsx$2(Flex, { children: TooltipText.MaxBuy((_b = bondData === null || bondData === void 0 ? void 0 : bondData.earnToken) === null || _b === void 0 ? void 0 : _b.symbol) }), width: "230px", placement: "bottomLeft", transformTip: "translate(-5%, -5%)", children: jsx$2("div", { className: "bond-card-tooltip", children: jsx$2(Svg, { icon: "questionCircle", width: "12px" }) }) })] }), jsxs("div", { className: "bond-card-content", children: [jsx$2("div", { style: { paddingRight: '3px' }, children: jsx$2(TokenImage, { symbol: (_c = bondData.showcaseTokenName) !== null && _c !== void 0 ? _c : bondData.earnToken.symbol, size: 20 }) }), formatNumberSI(maxBuy(bondData).toFixed(0), 2)] })] })] }));
|
|
76442
76443
|
};
|
|
76443
76444
|
|
|
76444
76445
|
const Estimations = ({ depositAmount, bondData, youSpendString, isZap, fetchingZapQuote, zapError, }) => {
|
|
@@ -76475,32 +76476,9 @@ const Estimations = ({ depositAmount, bondData, youSpendString, isZap, fetchingZ
|
|
|
76475
76476
|
} }), jsxs(Flex, { className: "row-container premium", sx: { zIndex: 1 }, children: [jsx$2("img", { src: `/images/launch/${tierName === null || tierName === void 0 ? void 0 : tierName.toLowerCase()}.png`, alt: "minTier", style: { width: '21px', height: '21px', marginRight: '3px', zIndex: 1 } }), jsx$2(Flex, { sx: { color: 'success', mr: '3px', fontWeight: 700 }, children: boostMap[userTier] }), "Boost:", jsx$2(TooltipBubble, { className: "tooltip-bubble", body: jsx$2(Flex, { children: TooltipText.Boost }), width: "230px", placement: "bottomLeft", transformTip: "translate(-5%, 0%)", children: jsx$2(Flex, { className: "row-container premium-icon", children: jsx$2(Svg, { icon: "questionCircle", width: "12px" }) }) })] }), isZap && fetchingZapQuote ? (jsx$2(Dots, {})) : isZap && zapError ? ('-') : (jsxs(Flex, { className: `row-container premium-val premium-positive`, children: ["$ ", formatUSDNumber(boostAmount.toString())] }))] })), !!bondData.feeInPayout && (jsxs(Flex, { className: "text-container row", children: [jsxs(Flex, { className: "row-container premium", children: ["Fee:", jsx$2(TooltipBubble, { className: "tooltip-bubble", body: jsxs(Flex, { children: ["This is the platform fee (", bondData.feeInPayout, "%)."] }), width: "230px", placement: "bottomLeft", transformTip: "translate(-5%, -5%)", children: jsx$2(Flex, { className: "row-container premium-icon", children: jsx$2(Svg, { icon: "questionCircle", width: "12px" }) }) })] }), isZap && fetchingZapQuote ? (jsx$2(Dots, {})) : isZap && zapError ? ('-') : (jsxs(Flex, { className: `row-container premium-val`, children: ["$ ", formatUSDNumber(feeUSD.toString())] }))] })), jsxs(Flex, { className: "text-container row", children: [jsxs(Flex, { className: "row-container get", children: ["You Get (over ", vestingTime(((_c = bondData === null || bondData === void 0 ? void 0 : bondData.vestingTerm) !== null && _c !== void 0 ? _c : 0) - ((_d = bondData.vestingCliff) !== null && _d !== void 0 ? _d : 0)).days, " days):"] }), isZap && fetchingZapQuote ? (jsx$2(Dots, {})) : isZap && zapError ? ('-') : (jsxs(Flex, { className: "row-container get-val", children: [formatNumber$1(estimatedOutputAmount.toString()), " ", bondData === null || bondData === void 0 ? void 0 : bondData.showcaseTokenName, " = $", ' ', formatUSDNumber(estimatedOutputUSD.toString())] }))] })] }));
|
|
76476
76477
|
};
|
|
76477
76478
|
|
|
76478
|
-
var ABTestKeys;
|
|
76479
|
-
(function (ABTestKeys) {
|
|
76480
|
-
ABTestKeys["BOND_DESCRIPTION"] = "bondDescription";
|
|
76481
|
-
})(ABTestKeys || (ABTestKeys = {}));
|
|
76482
|
-
function useABTesting({ key, defaultValue = (Math.random() < 0.5).toString(), }) {
|
|
76483
|
-
const { cookie, updateCookie } = useCookie(QUERY_KEYS.AB_TEST_VALUE, null);
|
|
76484
|
-
let abTestValue = '';
|
|
76485
|
-
let parseCookie = null;
|
|
76486
|
-
if (cookie === null || cookie === undefined || cookie[key] === undefined) {
|
|
76487
|
-
parseCookie = Object.assign(Object.assign({}, cookie), { [key]: defaultValue.toString() });
|
|
76488
|
-
abTestValue = defaultValue.toString();
|
|
76489
|
-
updateCookie(parseCookie);
|
|
76490
|
-
}
|
|
76491
|
-
if (cookie) {
|
|
76492
|
-
parseCookie = cookie;
|
|
76493
|
-
if (parseCookie && parseCookie[key]) {
|
|
76494
|
-
abTestValue = parseCookie[key].toString();
|
|
76495
|
-
}
|
|
76496
|
-
}
|
|
76497
|
-
return { abTestValue };
|
|
76498
|
-
}
|
|
76499
|
-
|
|
76500
76479
|
const ProjectDescription = ({ description, isProjectView }) => {
|
|
76501
76480
|
const [isOpen, setIsOpen] = useState(false);
|
|
76502
|
-
|
|
76503
|
-
return (jsx$2(Flex, { className: "description-container", children: (abTestValue === 'true' || isProjectView) && (jsxs(Fragment$1, { children: [jsxs(Flex, { sx: { display: ['flex', 'flex', 'flex', 'none'], flexDirection: 'column' }, children: [jsx$2(Text, { sx: {
|
|
76481
|
+
return (jsx$2(Flex, { className: "description-container", children: isProjectView && (jsxs(Fragment$1, { children: [jsxs(Flex, { sx: { display: ['flex', 'flex', 'flex', 'none'], flexDirection: 'column' }, children: [jsx$2(Text, { sx: {
|
|
76504
76482
|
fontSize: ['12px', '12px', '12px', '14px'],
|
|
76505
76483
|
mt: '10px',
|
|
76506
76484
|
lineHeight: ['18px', '18px', '18px', '21px'],
|
|
@@ -76670,9 +76648,7 @@ const BuyBond = ({ onDismiss, bondAddress, bondChain, handlePurchasedBond, isPro
|
|
|
76670
76648
|
const sendReferenceId = useSendReferenceId();
|
|
76671
76649
|
const { data: userPoints } = useTierPoints();
|
|
76672
76650
|
const bondData = bonds === null || bonds === void 0 ? void 0 : bonds.find((bond) => { var _a; return ((_a = bond === null || bond === void 0 ? void 0 : bond.billAddress) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === (bondAddress === null || bondAddress === void 0 ? void 0 : bondAddress.toLowerCase()); });
|
|
76673
|
-
const
|
|
76674
|
-
const reason = abTestValue === 'true' ? 'bondDescription' : 'noBondDescription';
|
|
76675
|
-
const isGoldRush = 'billArt' in bondData ? bondData.billArt.collection === types.BillArtCollection.GoldenTicket_Collection1 : false;
|
|
76651
|
+
const isMobile = useIsMobile();
|
|
76676
76652
|
// Tier Gating
|
|
76677
76653
|
const userTier = getUserTier(userPoints !== null && userPoints !== void 0 ? userPoints : '0');
|
|
76678
76654
|
const minTier = (bondData === null || bondData === void 0 ? void 0 : bondData.minTier) !== undefined ? bondData.minTier : null;
|
|
@@ -76684,7 +76660,6 @@ const BuyBond = ({ onDismiss, bondAddress, bondChain, handlePurchasedBond, isPro
|
|
|
76684
76660
|
const [buyTxHash, setBuyTxHash] = useState();
|
|
76685
76661
|
const [inputValue, setInputValue] = useState('');
|
|
76686
76662
|
const [inputTokenString, setInputTokenString] = useState((_b = (_a = bondData === null || bondData === void 0 ? void 0 : bondData.lpToken) === null || _a === void 0 ? void 0 : _a.address) === null || _b === void 0 ? void 0 : _b[bondData.chainId]);
|
|
76687
|
-
const zapEnabled = supportedByLIFI.includes(bondData === null || bondData === void 0 ? void 0 : bondData.chainId);
|
|
76688
76663
|
// On-chain Data
|
|
76689
76664
|
const inputToken = useTokenFromZapList(inputTokenString, bondData === null || bondData === void 0 ? void 0 : bondData.chainId, bondData === null || bondData === void 0 ? void 0 : bondData.lpToken);
|
|
76690
76665
|
const isZap = (inputTokenString === null || inputTokenString === void 0 ? void 0 : inputTokenString.toLowerCase()) !== ((_e = (_d = (_c = bondData === null || bondData === void 0 ? void 0 : bondData.lpToken) === null || _c === void 0 ? void 0 : _c.address) === null || _d === void 0 ? void 0 : _d[bondData === null || bondData === void 0 ? void 0 : bondData.chainId]) === null || _e === void 0 ? void 0 : _e.toLowerCase());
|
|
@@ -76696,6 +76671,11 @@ const BuyBond = ({ onDismiss, bondAddress, bondChain, handlePurchasedBond, isPro
|
|
|
76696
76671
|
const depositAmount = isZap ? zapDepositAmount : inputValue;
|
|
76697
76672
|
const youSpendString = `${formatNumber$1(inputValue)} ${getSymbol(inputToken, bondData === null || bondData === void 0 ? void 0 : bondData.chainId)} =
|
|
76698
76673
|
$${formatUSDNumber((parseFloat(inputValue) * ((_g = inputTokenPrice === null || inputTokenPrice === void 0 ? void 0 : inputTokenPrice.price) !== null && _g !== void 0 ? _g : 0)).toString())}`;
|
|
76674
|
+
// Validations
|
|
76675
|
+
const isGoldRush = bondData.billArt.collection === types.BillArtCollection.GoldenTicket_Collection1;
|
|
76676
|
+
const zapEnabled = supportedByLIFI.includes(bondData === null || bondData === void 0 ? void 0 : bondData.chainId);
|
|
76677
|
+
const exceedsMaxBuy = maxBuy(bondData).lt(getPayoutAmount(bondData, depositAmount, userPoints !== null && userPoints !== void 0 ? userPoints : '0'));
|
|
76678
|
+
const exceedsBalance = new BigNumber$1(inputCurrencyBalance !== null && inputCurrencyBalance !== void 0 ? inputCurrencyBalance : '0').lt(inputValue);
|
|
76699
76679
|
// Loading State
|
|
76700
76680
|
const [loadingTx, setLoadingTx] = useState(false);
|
|
76701
76681
|
const { addToastError } = usePopups();
|
|
@@ -76762,7 +76742,7 @@ const BuyBond = ({ onDismiss, bondAddress, bondChain, handlePurchasedBond, isPro
|
|
|
76762
76742
|
});
|
|
76763
76743
|
if (hash) {
|
|
76764
76744
|
setBuyTxHash(hash);
|
|
76765
|
-
yield sendReferenceId(billAddress, userChainId, hash
|
|
76745
|
+
yield sendReferenceId(billAddress, userChainId, hash);
|
|
76766
76746
|
handlePurchasedBond === null || handlePurchasedBond === void 0 ? void 0 : handlePurchasedBond(hash);
|
|
76767
76747
|
track({
|
|
76768
76748
|
event: 'bond',
|
|
@@ -76809,7 +76789,7 @@ const BuyBond = ({ onDismiss, bondAddress, bondChain, handlePurchasedBond, isPro
|
|
|
76809
76789
|
});
|
|
76810
76790
|
if (hash) {
|
|
76811
76791
|
setBuyTxHash(hash);
|
|
76812
|
-
yield sendReferenceId((_d = bondData === null || bondData === void 0 ? void 0 : bondData.billAddress) !== null && _d !== void 0 ? _d : '', userChainId, hash
|
|
76792
|
+
yield sendReferenceId((_d = bondData === null || bondData === void 0 ? void 0 : bondData.billAddress) !== null && _d !== void 0 ? _d : '', userChainId, hash);
|
|
76813
76793
|
handlePurchasedBond === null || handlePurchasedBond === void 0 ? void 0 : handlePurchasedBond(hash);
|
|
76814
76794
|
track({
|
|
76815
76795
|
event: 'zap',
|
|
@@ -76908,18 +76888,18 @@ const BuyBond = ({ onDismiss, bondAddress, bondChain, handlePurchasedBond, isPro
|
|
|
76908
76888
|
console.log('change to native');
|
|
76909
76889
|
}
|
|
76910
76890
|
}, [inputCurrencyBalance]);
|
|
76911
|
-
return bondData ? (jsxs(Flex, { className: `modal-content ${isGoldRush ? 'gold-rush' : ''}`, children: [jsx$2("div", { className: "gold-ribbon" }), jsxs(Flex, { className: "modaltable-container", children: [jsx$2(BondModalHeader, { bondData: bondData, onDismiss: onDismiss, showProjectInfoButton: (SDKConfig === null || SDKConfig === void 0 ? void 0 : SDKConfig.referenceId) === 'apebond' }), jsx$2(ProjectDescription, { description: bondData.shortDescription, isProjectView: true }), jsx$2(Flex, { sx: { width: '100%', display: isProjectView ? ['flex', 'flex', 'flex', 'none'] : 'flex' }, children: jsx$2(BondCards, { bondData: bondData }) }), jsx$2(Estimations, { depositAmount: depositAmount, bondData: bondData, youSpendString: youSpendString, isZap: isZap, fetchingZapQuote: fetchingZapQuote, zapError: zapError }), jsx$2(TokenSelectorPanel, { typedValue: inputValue, setTypedValue: setInputValue, selectedToken: inputToken, handleValueBtn: () => { var _a; return setInputValue((_a = new BigNumber$1(inputCurrencyBalance !== null && inputCurrencyBalance !== void 0 ? inputCurrencyBalance : '0')) === null || _a === void 0 ? void 0 : _a.toString()); }, handleCurrencySelect: handleCurrencySelect, chainId: bondData === null || bondData === void 0 ? void 0 : bondData.chainId, enableZap: zapEnabled, bondPrincipalToken: bondData === null || bondData === void 0 ? void 0 : bondData.lpToken, tokenBalance: inputCurrencyBalance, selectedTokenPrice: inputTokenPrice === null || inputTokenPrice === void 0 ? void 0 : inputTokenPrice.price, inputDisabled: isUserRestricted }), SDKConfig.useTiers && jsx$2(GetUpToComponent, { bond: bondData, depositAmount: depositAmount }), (bondData === null || bondData === void 0 ? void 0 : bondData.warningCard) && (jsx$2(Flex, { sx: {
|
|
76891
|
+
return bondData ? (jsxs(Flex, { className: `modal-content ${isGoldRush ? 'gold-rush' : ''}`, children: [!isProjectView && jsx$2("div", { className: "gold-ribbon" }), jsxs(Flex, { className: "modaltable-container", children: [jsx$2(BondModalHeader, { bondData: bondData, onDismiss: onDismiss, showProjectInfoButton: (SDKConfig === null || SDKConfig === void 0 ? void 0 : SDKConfig.referenceId) === 'apebond' }), jsx$2(ProjectDescription, { description: bondData.shortDescription, isProjectView: true }), jsx$2(Flex, { sx: { width: '100%', display: isProjectView ? ['flex', 'flex', 'flex', 'none'] : 'flex' }, children: jsx$2(BondCards, { bondData: bondData }) }), jsx$2(Estimations, { depositAmount: depositAmount, bondData: bondData, youSpendString: youSpendString, isZap: isZap, fetchingZapQuote: fetchingZapQuote, zapError: zapError }), jsx$2(TokenSelectorPanel, { typedValue: inputValue, setTypedValue: setInputValue, selectedToken: inputToken, handleValueBtn: () => { var _a; return setInputValue((_a = new BigNumber$1(inputCurrencyBalance !== null && inputCurrencyBalance !== void 0 ? inputCurrencyBalance : '0')) === null || _a === void 0 ? void 0 : _a.toString()); }, handleCurrencySelect: handleCurrencySelect, chainId: bondData === null || bondData === void 0 ? void 0 : bondData.chainId, enableZap: zapEnabled, bondPrincipalToken: bondData === null || bondData === void 0 ? void 0 : bondData.lpToken, tokenBalance: inputCurrencyBalance, selectedTokenPrice: inputTokenPrice === null || inputTokenPrice === void 0 ? void 0 : inputTokenPrice.price, inputDisabled: isUserRestricted }), SDKConfig.useTiers && jsx$2(GetUpToComponent, { bond: bondData, depositAmount: depositAmount }), (bondData === null || bondData === void 0 ? void 0 : bondData.warningCard) && (jsx$2(Flex, { sx: {
|
|
76912
76892
|
width: '100%',
|
|
76913
76893
|
background: '#DE62F366',
|
|
76914
76894
|
justifyContent: 'center',
|
|
76915
|
-
mt: '
|
|
76895
|
+
mt: '10px',
|
|
76916
76896
|
borderRadius: 'normal',
|
|
76917
76897
|
}, children: jsx$2(Text, { sx: { fontSize: '12px', fontWeight: 400, p: '2px 10px' }, children: jsx$2(SafeHTMLComponent, { html: bondData === null || bondData === void 0 ? void 0 : bondData.warningCard }) }) })), jsxs(Flex, { className: "modaltable-container button-container", children: [account && (jsx$2(Flex, { className: "button-container get", children: jsx$2(Button, { className: "action-button", onClick: () => bondData.billVersion === types.BillVersion.V4 && SDKConfig.useTiers
|
|
76918
76898
|
? window.open('http://ape.bond/tier-staking', '_blank')
|
|
76919
76899
|
: zapEnabled
|
|
76920
76900
|
? handleOpenZapModal()
|
|
76921
76901
|
: openExternal(), variant: "secondary", fullWidth: true, children: bondData.billVersion === types.BillVersion.V4 && SDKConfig.useTiers
|
|
76922
|
-
? `Get your Tier`
|
|
76902
|
+
? `Get ${!isMobile ? 'your' : ''} Tier`
|
|
76923
76903
|
: `Get ${getSymbol(bondData === null || bondData === void 0 ? void 0 : bondData.lpToken)}` }) })), jsx$2(Flex, { className: "button-container buy", children: !account ? (jsx$2(ConnectButton, {})) : isUserRestricted ? (jsx$2(Button, { className: "action-button", disabled: true, children: "INSUFFICIENT TIER" })) : userChainId !== bondData.chainId ? (jsx$2(Button, { className: "action-button", disabled: loadingTx || isConfirming || (bondData === null || bondData === void 0 ? void 0 : bondData.soldOut), onClick: (event) => {
|
|
76924
76904
|
event.stopPropagation();
|
|
76925
76905
|
switchChain({ chainId: bondData.chainId });
|
|
@@ -76929,7 +76909,15 @@ const BuyBond = ({ onDismiss, bondAddress, bondChain, handlePurchasedBond, isPro
|
|
|
76929
76909
|
!inputValue ||
|
|
76930
76910
|
parseFloat(inputValue) === 0 ||
|
|
76931
76911
|
fetchingZapQuote ||
|
|
76932
|
-
zapError
|
|
76912
|
+
zapError ||
|
|
76913
|
+
exceedsMaxBuy ||
|
|
76914
|
+
exceedsBalance, onClick: handleOpenModal, children: exceedsMaxBuy
|
|
76915
|
+
? 'Exceeds Max Buy'
|
|
76916
|
+
: exceedsBalance
|
|
76917
|
+
? 'Exceeds balance'
|
|
76918
|
+
: zapError
|
|
76919
|
+
? 'something went wrong'
|
|
76920
|
+
: `buy` })) : (jsx$2(Button, { className: "action-button", load: approvalState === ApprovalState.PENDING, disabled: approvalState === ApprovalState.PENDING ||
|
|
76933
76921
|
(bondData === null || bondData === void 0 ? void 0 : bondData.soldOut) ||
|
|
76934
76922
|
!account ||
|
|
76935
76923
|
!inputValue ||
|
|
@@ -77142,9 +77130,10 @@ function useHotBondContracts() {
|
|
|
77142
77130
|
return useQuery({
|
|
77143
77131
|
queryKey: [QUERY_KEYS.HOT_BONDS_CONTRACTS],
|
|
77144
77132
|
queryFn: getHotBondsContracts,
|
|
77133
|
+
staleTime: Infinity,
|
|
77145
77134
|
refetchOnWindowFocus: false,
|
|
77135
|
+
refetchOnMount: false,
|
|
77146
77136
|
retry: 1,
|
|
77147
|
-
initialData: [],
|
|
77148
77137
|
});
|
|
77149
77138
|
}
|
|
77150
77139
|
function useHotBonds() {
|
|
@@ -77154,13 +77143,14 @@ function useHotBonds() {
|
|
|
77154
77143
|
queryKey: [QUERY_KEYS.HOT_BONDS, bondsData === null || bondsData === void 0 ? void 0 : bondsData.length, hotBondContracts === null || hotBondContracts === void 0 ? void 0 : hotBondContracts.length],
|
|
77155
77144
|
queryFn: () => getHotBonds(bondsData, hotBondContracts),
|
|
77156
77145
|
refetchOnWindowFocus: false,
|
|
77157
|
-
|
|
77158
|
-
|
|
77159
|
-
|
|
77146
|
+
refetchInterval: 30000,
|
|
77147
|
+
enabled: !!bondsData && bondsData.length > 0 && !!hotBondContracts && hotBondContracts.length > 0,
|
|
77148
|
+
retry: 0,
|
|
77160
77149
|
});
|
|
77161
77150
|
}
|
|
77162
77151
|
const getHotBondsContracts = () => __awaiter$9(void 0, void 0, void 0, function* () {
|
|
77163
77152
|
try {
|
|
77153
|
+
console.log('call!');
|
|
77164
77154
|
const response = yield axios.get(`${STRAPI_URL}/hot-bonds`);
|
|
77165
77155
|
return response.data.map((bond) => bond.BondAddress.toLowerCase());
|
|
77166
77156
|
}
|
|
@@ -77519,32 +77509,47 @@ const Bonds = () => {
|
|
|
77519
77509
|
}, children: [jsx$2(Svg, { icon: "StarFilled", width: 75, height: 75 }), jsx$2(Flex$1, { sx: { mt: '10px' }, children: `You don't have any Favorite Bonds yet!` }), jsx$2(Flex$1, { sx: { fontSize: '12px', fontWeight: 400, color: 'textDisabledButton', mt: '10px' }, children: `Click on the 'star' or 'fire' icon to add Bonds to the list.` })] })) : (jsx$2(Flex$1, { className: "bonds-spinner", children: jsx$2(Spinner, { size: 100 }) })), SDKConfig.useHotBonds && jsx$2(RecommendationCards$1, {}), jsx$2(Flex$1, { sx: { width: '100%', justifyContent: 'center', my: '15px' }, children: jsx$2("img", { src: "https://res.cloudinary.com/dswmrqgwy/image/upload/v1741643990/poweredbyapebondsdk_cxiouj.png", alt: "powered-by-apebond", style: { width: '200px', height: 'auto' } }) })] }));
|
|
77520
77510
|
};
|
|
77521
77511
|
|
|
77522
|
-
var BondsViewOptions;
|
|
77512
|
+
var BondsViewOptions$1;
|
|
77523
77513
|
(function (BondsViewOptions) {
|
|
77524
77514
|
BondsViewOptions["BONDSMARKET"] = "Bonds Market";
|
|
77525
77515
|
BondsViewOptions["YOURBONDS"] = "Your Bonds";
|
|
77526
|
-
})(BondsViewOptions || (BondsViewOptions = {}));
|
|
77527
|
-
const
|
|
77528
|
-
|
|
77529
|
-
const
|
|
77530
|
-
|
|
77516
|
+
})(BondsViewOptions$1 || (BondsViewOptions$1 = {}));
|
|
77517
|
+
const useActiveView = () => {
|
|
77518
|
+
// Query to fetch the activeView's current state
|
|
77519
|
+
const { data: activeView = BondsViewOptions$1.BONDSMARKET } = useQuery({
|
|
77520
|
+
queryKey: [QUERY_KEYS.ACTIVE_VIEW],
|
|
77521
|
+
queryFn: () => {
|
|
77522
|
+
// Initialize from the URL if on first load
|
|
77523
|
+
if (typeof window !== 'undefined') {
|
|
77524
|
+
const isYourBonds = window.location.search === '?yourBonds';
|
|
77525
|
+
return isYourBonds ? BondsViewOptions$1.YOURBONDS : BondsViewOptions$1.BONDSMARKET;
|
|
77526
|
+
}
|
|
77527
|
+
return BondsViewOptions$1.BONDSMARKET;
|
|
77528
|
+
},
|
|
77529
|
+
});
|
|
77530
|
+
const queryClient = useQueryClient();
|
|
77531
|
+
const handleToogle = (newView) => {
|
|
77532
|
+
queryClient.setQueryData([QUERY_KEYS.ACTIVE_VIEW], newView); // Update cache
|
|
77531
77533
|
if (typeof window !== 'undefined') {
|
|
77532
77534
|
const currentPath = window.location.pathname;
|
|
77533
|
-
if (
|
|
77534
|
-
// window.location.pathname = '/yourBonds'
|
|
77535
|
+
if (newView === BondsViewOptions$1.YOURBONDS) {
|
|
77535
77536
|
window.history.pushState({}, '', `${currentPath}?yourBonds`);
|
|
77536
77537
|
}
|
|
77537
77538
|
else {
|
|
77538
77539
|
window.history.pushState({}, '', `${currentPath}`);
|
|
77539
77540
|
}
|
|
77540
77541
|
}
|
|
77541
|
-
setActiveView(newOption);
|
|
77542
77542
|
};
|
|
77543
|
-
|
|
77544
|
-
|
|
77545
|
-
|
|
77546
|
-
|
|
77547
|
-
|
|
77543
|
+
return { activeView, handleToogle };
|
|
77544
|
+
};
|
|
77545
|
+
|
|
77546
|
+
var BondsViewOptions;
|
|
77547
|
+
(function (BondsViewOptions) {
|
|
77548
|
+
BondsViewOptions["BONDSMARKET"] = "Bonds Market";
|
|
77549
|
+
BondsViewOptions["YOURBONDS"] = "Your Bonds";
|
|
77550
|
+
})(BondsViewOptions || (BondsViewOptions = {}));
|
|
77551
|
+
const FullBondsView = () => {
|
|
77552
|
+
const { activeView, handleToogle } = useActiveView();
|
|
77548
77553
|
return (jsxs("div", { className: "full-bonds-view-container", children: [jsx$2("div", { className: "toggle-container", children: jsx$2(Toggle, { options: [BondsViewOptions.BONDSMARKET, BondsViewOptions.YOURBONDS], activeOption: activeView, handleToggle: handleToogle }) }), jsx$2(Flex, { sx: { width: '100%' }, children: activeView === BondsViewOptions.BONDSMARKET ? jsx$2(Bonds, {}) : jsx$2(YourBonds, {}) })] }));
|
|
77549
77554
|
};
|
|
77550
77555
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { UseQueryResult } from '@tanstack/react-query';
|
|
2
2
|
import { BondsData } from '../../types/bonds';
|
|
3
|
-
export declare function useHotBondContracts():
|
|
3
|
+
export declare function useHotBondContracts(): UseQueryResult<string[], Error>;
|
|
4
4
|
export default function useHotBonds(): UseQueryResult<BondsData[]>;
|
|
5
5
|
export declare const getHotBondsContracts: () => Promise<string[]>;
|
|
6
6
|
export declare const getHotBonds: (bondData: BondsData[], hotBondContracts: string[]) => Promise<BondsData[]>;
|
package/dist/styles.css
CHANGED
|
@@ -477,7 +477,7 @@
|
|
|
477
477
|
align-items: center;
|
|
478
478
|
cursor: pointer;
|
|
479
479
|
width: 45%;
|
|
480
|
-
min-width:
|
|
480
|
+
min-width: 110px;
|
|
481
481
|
}
|
|
482
482
|
.button-container.get .action-button {
|
|
483
483
|
margin-right: 10px;
|
|
@@ -1028,7 +1028,7 @@ span.flex-inline {
|
|
|
1028
1028
|
}
|
|
1029
1029
|
@media screen and (min-width: 1000px) {
|
|
1030
1030
|
.your-bonds .token-info-container {
|
|
1031
|
-
width:
|
|
1031
|
+
width: 45%;
|
|
1032
1032
|
}
|
|
1033
1033
|
}
|
|
1034
1034
|
.your-bonds .token-info-container .tooltip-column {
|
|
@@ -1051,7 +1051,7 @@ span.flex-inline {
|
|
|
1051
1051
|
}
|
|
1052
1052
|
@media screen and (min-width: 1000px) {
|
|
1053
1053
|
.your-bonds .your-bonds-columns-container {
|
|
1054
|
-
width:
|
|
1054
|
+
width: 55%;
|
|
1055
1055
|
justify-content: space-between;
|
|
1056
1056
|
flex-direction: row;
|
|
1057
1057
|
padding-right: 20px;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare const formatNumber: (number: number, minPrecision?: number, maxPrecision?: number) => string;
|
|
2
|
-
export declare const formatNumberSI: (
|
|
2
|
+
export declare const formatNumberSI: (num: number | string, digits?: number) => string;
|