@ape.swap/bonds-sdk 2.2.9 → 2.2.10
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
|
@@ -18326,6 +18326,7 @@ var types = {};
|
|
|
18326
18326
|
(_c[LiquidityDex.PancakeSwapV2] = {
|
|
18327
18327
|
factory: '0xcA143Ce32Fe78f1f7019d7d551a6402fC5350c73',
|
|
18328
18328
|
protocol: Protocols.V2,
|
|
18329
|
+
router: '0x10ED43C718714eb63d5aA57B78B54704E256024E',
|
|
18329
18330
|
}),
|
|
18330
18331
|
(_c[LiquidityDex.ApeSwapV3] = {
|
|
18331
18332
|
factory: '0x7Bc382DdC5928964D7af60e7e2f6299A1eA6F48d',
|
|
@@ -18841,6 +18842,7 @@ const QUERY_KEYS = {
|
|
|
18841
18842
|
CHAIN_FILTER_OPTION: 'ApeBond-SDK-chainFilterOption',
|
|
18842
18843
|
FAVORITE_TOKENS: 'ApeBond-SDK-favoriteTokens',
|
|
18843
18844
|
POP_UPS: 'ApeBond-SDK-popUps',
|
|
18845
|
+
GEO_FENCING: 'ApeBond-SDK-geoFencing',
|
|
18844
18846
|
};
|
|
18845
18847
|
|
|
18846
18848
|
function useCookie(key, defaultValue) {
|
|
@@ -39209,10 +39211,6 @@ const vestingTimeRemaining = (userBill) => {
|
|
|
39209
39211
|
const currentTime = new Date().getTime() / 1000;
|
|
39210
39212
|
return getTimePeriods(parseInt(userBill.lastBlockTimestamp) + parseInt(userBill.vesting) - currentTime, true);
|
|
39211
39213
|
};
|
|
39212
|
-
const vestingTimeRemainingYourBonds = (userBill) => {
|
|
39213
|
-
const currentTime = new Date().getTime() / 1000;
|
|
39214
|
-
return (parseInt(userBill.lastBlockTimestamp) + parseInt(userBill.vesting) - currentTime);
|
|
39215
|
-
};
|
|
39216
39214
|
const discountEarnTokenPrice = (bond) => {
|
|
39217
39215
|
var _a, _b;
|
|
39218
39216
|
const earnTokenPrice = parseFloat((_a = bond === null || bond === void 0 ? void 0 : bond.payoutTokenPrice) !== null && _a !== void 0 ? _a : '0');
|
|
@@ -49038,7 +49036,7 @@ const PRICE_GETTER_ADDRESSES = {
|
|
|
49038
49036
|
[types.ChainId.LINEA]: '0x35b1eadAbaDD0Edd26076247f3dEdF9E15De8D5D',
|
|
49039
49037
|
[types.ChainId.LIGHTLINK]: '0xC22Db8dDe3A3591fFB02be868Ce2901d30671FE4',
|
|
49040
49038
|
[types.ChainId.IOTA]: '0xC22Db8dDe3A3591fFB02be868Ce2901d30671FE4',
|
|
49041
|
-
[types.ChainId.BASE]: '
|
|
49039
|
+
[types.ChainId.BASE]: '0xE29C74B4DD05A268B5FFaadeF4fdbAa1de6FDe84',
|
|
49042
49040
|
[types.ChainId.AVAX]: '0x70005Da62E17041977f7F99f91098b125CcDE1a7',
|
|
49043
49041
|
};
|
|
49044
49042
|
const MULTICALL_V2 = {
|
|
@@ -71712,7 +71710,7 @@ const YourBonds = () => {
|
|
|
71712
71710
|
return;
|
|
71713
71711
|
if (sortConfig === null) {
|
|
71714
71712
|
const sortedBills = (_a = [...userBonds]) === null || _a === void 0 ? void 0 : _a.sort((a, b) => {
|
|
71715
|
-
const claimableDifference = parseFloat(
|
|
71713
|
+
const claimableDifference = parseFloat(claimable(b).toFixed(3)) - parseFloat(claimable(a).toFixed(3));
|
|
71716
71714
|
if (claimableDifference !== 0) {
|
|
71717
71715
|
return claimableDifference;
|
|
71718
71716
|
}
|
|
@@ -74115,7 +74113,6 @@ const ProjectDescription = ({ description }) => {
|
|
|
74115
74113
|
};
|
|
74116
74114
|
|
|
74117
74115
|
const BondModalHeaderAlt = ({ bondData, onDismiss, showProjectInfoButton, }) => {
|
|
74118
|
-
var _a, _b, _c, _d, _e, _f;
|
|
74119
74116
|
const [onOpenSlippageModal] = useModal(jsx$2(SlippageModal, {}));
|
|
74120
74117
|
const handleClose = () => {
|
|
74121
74118
|
if (typeof window !== 'undefined') {
|
|
@@ -74135,7 +74132,7 @@ const BondModalHeaderAlt = ({ bondData, onDismiss, showProjectInfoButton, }) =>
|
|
|
74135
74132
|
// },
|
|
74136
74133
|
// })
|
|
74137
74134
|
// }
|
|
74138
|
-
return (jsx$2(Flex, { className: "modaltable-container title-container", children: jsx$2(Flex, { className: "slipagge-close-icons", sx: { flexDirection: 'row' }, children: onDismiss ? (jsxs(Fragment$1, { children: [jsx$2(
|
|
74135
|
+
return (jsx$2(Flex, { className: "modaltable-container title-container", children: jsx$2(Flex, { className: "slipagge-close-icons", sx: { flexDirection: 'row' }, children: onDismiss ? (jsxs(Fragment$1, { children: [jsx$2(Flex, { sx: { pr: '10px' }, onClick: onOpenSlippageModal, children: jsx$2(Svg, { icon: "cog", width: "16px" }) }), jsx$2(IconButton, { icon: "close", color: "text", variant: "transparent", onClick: handleClose })] })) : (jsx$2(Flex, { sx: {}, onClick: onOpenSlippageModal, children: jsx$2(Svg, { icon: "cog", width: "16px" }) })) }) }));
|
|
74139
74136
|
};
|
|
74140
74137
|
|
|
74141
74138
|
const ImageAndShortDescription = ({ bondData, onDismiss }) => {
|
|
@@ -74176,9 +74173,32 @@ const ImageAndShortDescription = ({ bondData, onDismiss }) => {
|
|
|
74176
74173
|
}) })] }), jsxs(Flex, { sx: { alignItems: 'center', display: ['flex', 'flex', 'flex', 'none'], p: '10px', width: '100%' }, children: [jsxs(Flex, { sx: { width: ['50%', '50%', '50%', '100%'], alignItems: 'center' }, children: [jsx$2(Flex, { sx: { mr: '5px' }, children: jsx$2(TokenImage, { symbol: (_a = bondData.showcaseTokenName) !== null && _a !== void 0 ? _a : bondData.earnToken.symbol, size: 30, chain: bondData.chainId }) }), jsxs("h2", { className: "modal-tokenname-chainicon", sx: { margin: '0px' }, children: [bondData === null || bondData === void 0 ? void 0 : bondData.showcaseTokenName, ' '] })] }), jsx$2(Flex, { className: "modal-marketprice-header", sx: { justifyContent: 'flex-end', alignItems: 'center' }, children: jsxs("span", { className: "modal-marketprice", children: ["Market Price: $", earnTokenPrice(bondData)] }) }), jsx$2(Flex, { className: "bondmodal-header-alt", sx: { mb: '10px' }, children: jsx$2(BondModalHeaderAlt, { bondData: bondData, onDismiss: onDismiss, showProjectInfoButton: (SDKConfig === null || SDKConfig === void 0 ? void 0 : SDKConfig.referenceId) === 'apebond' }) })] }), jsx$2(Flex, { className: "description-container paragraph-spaced", sx: { px: '10px', opacity: 0.7, mt: ['0', '0', '0', '10px'] }, children: jsx$2(ProjectDescription, { description: bondData === null || bondData === void 0 ? void 0 : bondData.shortDescription }) })] }));
|
|
74177
74174
|
};
|
|
74178
74175
|
|
|
74176
|
+
// Fetch country code to check if the region is allowed
|
|
74177
|
+
const fetchLocation = (apiv2URL) => __awaiter$9(void 0, void 0, void 0, function* () {
|
|
74178
|
+
const resp = yield axios.get(`${apiv2URL}/check`);
|
|
74179
|
+
const { isRestrictedRegion, countryCode } = resp === null || resp === void 0 ? void 0 : resp.data;
|
|
74180
|
+
return { isRestrictedRegion, countryCode };
|
|
74181
|
+
});
|
|
74182
|
+
function useGeoFencing() {
|
|
74183
|
+
const apiv2URL = useURLByEnvironment('apiV2');
|
|
74184
|
+
return useQuery({
|
|
74185
|
+
queryKey: [QUERY_KEYS.GEO_FENCING],
|
|
74186
|
+
queryFn: () => fetchLocation(apiv2URL),
|
|
74187
|
+
staleTime: Infinity,
|
|
74188
|
+
refetchOnMount: false,
|
|
74189
|
+
refetchOnWindowFocus: false,
|
|
74190
|
+
});
|
|
74191
|
+
}
|
|
74192
|
+
|
|
74193
|
+
const RestrictedRegionModal = ({ onDismiss }) => {
|
|
74194
|
+
const { data: geoData } = useGeoFencing();
|
|
74195
|
+
return (jsxs(Modal, { className: "modal", title: "Notice", sx: { maxWidth: '200px' }, children: [jsxs(Flex, { sx: { my: '20px' }, children: ["Unfortunately, this bond is restricted for your region: ", geoData === null || geoData === void 0 ? void 0 : geoData.countryCode, "."] }), jsx$2(Button, { fullWidth: true, onClick: onDismiss, children: "Close" })] }));
|
|
74196
|
+
};
|
|
74197
|
+
|
|
74179
74198
|
const BondModal = ({ onDismiss, bondAddress, bondChain, handlePurchasedBond }) => {
|
|
74180
74199
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
74181
74200
|
const SDKConfig = useSDKConfig();
|
|
74201
|
+
const { data: geoData } = useGeoFencing();
|
|
74182
74202
|
// State
|
|
74183
74203
|
const [modalVariant, setModalVariant] = useState(SDKConfig === null || SDKConfig === void 0 ? void 0 : SDKConfig.modalVariant);
|
|
74184
74204
|
const [accordionVisible, setAccordionVisible] = useState(false);
|
|
@@ -74346,13 +74366,26 @@ const BondModal = ({ onDismiss, bondAddress, bondChain, handlePurchasedBond }) =
|
|
|
74346
74366
|
}
|
|
74347
74367
|
}
|
|
74348
74368
|
});
|
|
74369
|
+
const [openGeofencingModal] = useModal(jsx$2(RestrictedRegionModal, {}));
|
|
74370
|
+
const blockedBondsForAE = [
|
|
74371
|
+
'0x0719CCaF2f07f59b23DB7d80E3d2791A0836bdfD'.toLowerCase(),
|
|
74372
|
+
'0xBc48794a04777E7170bD5633E8b728f8a0945971'.toLowerCase(),
|
|
74373
|
+
'0x94A283756B70c2A77bc58Ae0E2615Caf14310186'.toLowerCase(),
|
|
74374
|
+
'0x6639D4acAe77967c253C75cBfEd7C612682E2704'.toLowerCase(),
|
|
74375
|
+
];
|
|
74349
74376
|
const handleBothPurchases = () => {
|
|
74350
|
-
|
|
74351
|
-
if (
|
|
74352
|
-
|
|
74377
|
+
var _a, _b;
|
|
74378
|
+
if ((geoData === null || geoData === void 0 ? void 0 : geoData.countryCode) === 'AE' && blockedBondsForAE.includes((_b = (_a = bondData === null || bondData === void 0 ? void 0 : bondData.billAddress) === null || _a === void 0 ? void 0 : _a.toLowerCase()) !== null && _b !== void 0 ? _b : '')) {
|
|
74379
|
+
openGeofencingModal();
|
|
74353
74380
|
}
|
|
74354
74381
|
else {
|
|
74355
|
-
|
|
74382
|
+
setLoadingTx(true);
|
|
74383
|
+
if (isZap) {
|
|
74384
|
+
handleZapCallback().finally(() => setLoadingTx(false));
|
|
74385
|
+
}
|
|
74386
|
+
else {
|
|
74387
|
+
handleBuyCallback().finally(() => setLoadingTx(false));
|
|
74388
|
+
}
|
|
74356
74389
|
}
|
|
74357
74390
|
};
|
|
74358
74391
|
const openExternal = () => {
|
|
@@ -74452,7 +74485,6 @@ const ModalHandler = ({ onDismiss, bondAddress, bondChain, }) => {
|
|
|
74452
74485
|
const { data: userBonds, refetch } = useUserBonds();
|
|
74453
74486
|
const userBill = userBonds === null || userBonds === void 0 ? void 0 : userBonds.find((bond) => bond.id === billId);
|
|
74454
74487
|
useEffect(() => {
|
|
74455
|
-
console.log(billId);
|
|
74456
74488
|
if (billId) {
|
|
74457
74489
|
console.log('BillId detected, Refetching user bonds');
|
|
74458
74490
|
refetch();
|
|
@@ -74779,7 +74811,7 @@ const BondRowsByChain = ({ bonds, hideTitles }) => {
|
|
|
74779
74811
|
const SDKConfig = useSDKConfig();
|
|
74780
74812
|
const validatedChains = (_a = SDKConfig === null || SDKConfig === void 0 ? void 0 : SDKConfig.chains) === null || _a === void 0 ? void 0 : _a.filter((chain) => MAINNET_CHAINS.includes(chain));
|
|
74781
74813
|
return (jsx$2(Flex$1, { className: "bondrowsbychain", children: validatedChains === null || validatedChains === void 0 ? void 0 : validatedChains.map((chain) => {
|
|
74782
|
-
return (jsx$2(BondRowsWithTitle, { chain: chain, bonds: bonds, hideTitles: hideTitles, showHotBonds: SDKConfig.useHotBonds ? chain === types.ChainId.BASE || chain === types.ChainId.MAINNET : false }, chain));
|
|
74814
|
+
return (jsx$2(BondRowsWithTitle, { chain: chain, bonds: bonds, hideTitles: hideTitles, showHotBonds: hideTitles ? false : SDKConfig.useHotBonds ? chain === types.ChainId.BASE || chain === types.ChainId.MAINNET : false }, chain));
|
|
74783
74815
|
}) }));
|
|
74784
74816
|
};
|
|
74785
74817
|
|
|
@@ -74953,6 +74985,7 @@ const BondsMenu = ({ searchQuery, setSearchQuery, setChainFilterOption, chainFil
|
|
|
74953
74985
|
const Bonds = () => {
|
|
74954
74986
|
// Fetch data
|
|
74955
74987
|
useHotBonds();
|
|
74988
|
+
useGeoFencing();
|
|
74956
74989
|
const { favTokens } = useFavoriteTokens();
|
|
74957
74990
|
const { data: bondData, refetch: refetchBondsData } = useBondsData();
|
|
74958
74991
|
const { data: allBonds } = useBondsList();
|
|
@@ -90721,6 +90754,7 @@ const SalesTable = ({ allSales }) => {
|
|
|
90721
90754
|
const receivedUsdAmount = ((_a = sale === null || sale === void 0 ? void 0 : sale.payout) !== null && _a !== void 0 ? _a : 0) * (sale === null || sale === void 0 ? void 0 : sale.payoutTokenPrice);
|
|
90722
90755
|
const discount = 100 - (sale.dollarValue * 100) / receivedUsdAmount;
|
|
90723
90756
|
const isUserTheBuyer = (buyer === null || buyer === void 0 ? void 0 : buyer.toLowerCase()) === (account === null || account === void 0 ? void 0 : account.toLowerCase());
|
|
90757
|
+
const payoutToken = sale.payoutToken === 'LL.e' ? 'LL' : sale.payoutToken;
|
|
90724
90758
|
return (jsxs(Flex, { sx: {
|
|
90725
90759
|
width: '100%',
|
|
90726
90760
|
background: 'white3',
|
|
@@ -90731,7 +90765,7 @@ const SalesTable = ({ allSales }) => {
|
|
|
90731
90765
|
alignItems: 'center',
|
|
90732
90766
|
justifyContent: 'space-between',
|
|
90733
90767
|
fontSize: '12px',
|
|
90734
|
-
}, children: [jsxs(Flex, { sx: { width: '170px', alignItems: 'center' }, children: [jsx$2(Flex, { sx: { width: '30px', justifyContent: 'center' }, children: index + 4 }), jsx$2(TokenImage, { symbol:
|
|
90768
|
+
}, children: [jsxs(Flex, { sx: { width: '170px', alignItems: 'center' }, children: [jsx$2(Flex, { sx: { width: '30px', justifyContent: 'center' }, children: index + 4 }), jsx$2(TokenImage, { symbol: payoutToken, chain: sale.chainId, size: 28 }), jsx$2(Flex, { sx: { ml: '10px' }, children: sale.payoutToken })] }), jsx$2(Flex, { sx: { width: '120px', justifyContent: 'center' }, children: formatUTCDate(new Date(sale.createdAt * 1000)) }), jsx$2(Flex, { sx: { width: '160px', justifyContent: 'center', position: 'relative' }, children: jsxs(Flex, { sx: { position: 'relative' }, children: [buyer === null || buyer === void 0 ? void 0 : buyer.slice(0, 4), "...", buyer === null || buyer === void 0 ? void 0 : buyer.slice((buyer === null || buyer === void 0 ? void 0 : buyer.length) - 4, buyer === null || buyer === void 0 ? void 0 : buyer.length), isUserTheBuyer && jsx$2(Flex, { sx: styles$1.youCard, children: "You" })] }) }), jsxs(Flex, { sx: { width: '110px', justifyContent: 'center' }, children: ["$", sale.dollarValue.toFixed(2)] }), jsxs(Flex, { sx: { width: '110px', justifyContent: 'center' }, children: ["$", receivedUsdAmount === null || receivedUsdAmount === void 0 ? void 0 : receivedUsdAmount.toFixed(2)] }), jsxs(Flex, { sx: { width: '85px', justifyContent: 'center', color: discount > 0 ? 'success' : 'error' }, children: [discount.toFixed(2), "%"] })] }, sale.transactionHash));
|
|
90735
90769
|
}) })] }));
|
|
90736
90770
|
};
|
|
90737
90771
|
|
|
@@ -12,7 +12,6 @@ export declare const vestingTimeRemaining: (userBill: UserBill) => {
|
|
|
12
12
|
minutes: number;
|
|
13
13
|
seconds: number;
|
|
14
14
|
};
|
|
15
|
-
export declare const vestingTimeRemainingYourBonds: (userBill: UserBill) => number;
|
|
16
15
|
export declare const discountEarnTokenPrice: (bond: BondsData) => string;
|
|
17
16
|
export declare const maxBuy: (bond: BondsData) => 0 | BigNumber;
|
|
18
17
|
export declare function formatNumber(input: string): string;
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "Ape Bond SDK",
|
|
4
4
|
"author": "Ape Bond",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"version": "2.2.
|
|
6
|
+
"version": "2.2.10",
|
|
7
7
|
"module": "dist/main.js",
|
|
8
8
|
"type": "module",
|
|
9
9
|
"types": "dist/main.d.ts",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"yalc": "^1.0.0-pre.53"
|
|
57
57
|
},
|
|
58
58
|
"dependencies": {
|
|
59
|
-
"@ape.swap/apeswap-lists": "3.71.
|
|
59
|
+
"@ape.swap/apeswap-lists": "3.71.0",
|
|
60
60
|
"@emotion/react": "11.11.4",
|
|
61
61
|
"bignumber.js": "^9.1.2",
|
|
62
62
|
"chart.js": "4.2.0",
|