@ape.swap/bonds-sdk 3.0.66 → 3.0.68
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/config/constants/queryKeys.d.ts +1 -0
- package/dist/main.js +469 -332
- package/dist/state/preTGEBonds/usePreTGEBondsData.d.ts +5 -0
- package/dist/state/preTGEBonds/usePreTGEUserBonds.d.ts +5 -0
- package/dist/utils/formatNumber.d.ts +1 -0
- package/dist/views/PreTGEBonds/components/PreTGERows/PreTGERows.d.ts +3 -1
- package/package.json +2 -2
package/dist/main.js
CHANGED
|
@@ -18130,6 +18130,7 @@ var types = {};
|
|
|
18130
18130
|
BillArtCollection['AITECH_Collection1'] = 'AITECH_Collection1';
|
|
18131
18131
|
BillArtCollection['GPT_Collection1'] = 'GPT_Collection1';
|
|
18132
18132
|
BillArtCollection['GoldenTicket_Collection1'] = 'GoldenTicket_Collection1';
|
|
18133
|
+
BillArtCollection['Berachain_Collection1'] = 'Berachain_Collection1';
|
|
18133
18134
|
})((BillArtCollection = exports.BillArtCollection || (exports.BillArtCollection = {})));
|
|
18134
18135
|
exports.defaultBillArtCollection = BillArtCollection.ApeBond_Collection1;
|
|
18135
18136
|
exports.MigrationVestingTerms = {
|
|
@@ -18889,6 +18890,7 @@ const QUERY_KEYS = {
|
|
|
18889
18890
|
ACTIVE_VIEW: 'ApeBond-SDK-activeView',
|
|
18890
18891
|
PRE_TGE_LIST: 'ApeBond-SDK-preTGEList',
|
|
18891
18892
|
PRE_TGE_BONDS: 'ApeBond-SDK-preTGEBonds',
|
|
18893
|
+
PRE_TGE_USER_BONDS: 'ApeBond-SDK-preTGEUserBonds',
|
|
18892
18894
|
USER_TOKENS_BALANCES: 'ApeBond-SDK-userTokensBalances',
|
|
18893
18895
|
};
|
|
18894
18896
|
|
|
@@ -19029,39 +19031,6 @@ const TokenInfoAndName = ({ tokenSymbol, chain, tag, vestEnds, isHotBond, }) =>
|
|
|
19029
19031
|
}, children: jsx$2(Flex, { sx: { display: isHotBond ? 'flex' : ['none', 'none', 'none', 'none', 'flex'] }, children: tag && jsx$2(ListTag, { text: tag === null || tag === void 0 ? void 0 : tag.toUpperCase() }) }) })] }));
|
|
19030
19032
|
};
|
|
19031
19033
|
|
|
19032
|
-
const formatNumber$3 = (number, minPrecision = 2, maxPrecision = 2) => {
|
|
19033
|
-
const options = {
|
|
19034
|
-
minimumFractionDigits: minPrecision,
|
|
19035
|
-
maximumFractionDigits: maxPrecision,
|
|
19036
|
-
};
|
|
19037
|
-
return number.toLocaleString('en-US', options);
|
|
19038
|
-
};
|
|
19039
|
-
// Formats a number with SI (International System of Units) sufixes
|
|
19040
|
-
const formatNumberSI = (num, digits = 2) => {
|
|
19041
|
-
const number = typeof num === 'string' ? parseFloat(num) : num;
|
|
19042
|
-
const lookupSI = [
|
|
19043
|
-
{ value: 1, symbol: '' },
|
|
19044
|
-
{ value: 1e6, symbol: 'M' },
|
|
19045
|
-
{ value: 1e9, symbol: 'B' },
|
|
19046
|
-
{ value: 1e12, symbol: 'T' },
|
|
19047
|
-
];
|
|
19048
|
-
const regEx = /\.0+$|(\.[0-9]*[1-9])0+$/;
|
|
19049
|
-
let formatted;
|
|
19050
|
-
if (number >= 1e18) {
|
|
19051
|
-
formatted = '∞';
|
|
19052
|
-
}
|
|
19053
|
-
else {
|
|
19054
|
-
let i;
|
|
19055
|
-
for (i = lookupSI.length - 1; i > 0; i--) {
|
|
19056
|
-
if (number >= lookupSI[i].value) {
|
|
19057
|
-
break;
|
|
19058
|
-
}
|
|
19059
|
-
}
|
|
19060
|
-
formatted = formatNumber$3(number / lookupSI[i].value, digits, digits).replace(regEx, '$1') + lookupSI[i].symbol;
|
|
19061
|
-
}
|
|
19062
|
-
return formatted;
|
|
19063
|
-
};
|
|
19064
|
-
|
|
19065
19034
|
/*
|
|
19066
19035
|
* bignumber.js v9.3.0
|
|
19067
19036
|
* A JavaScript library for arbitrary-precision arithmetic.
|
|
@@ -21968,6 +21937,55 @@ function toFixedPoint(str, e, z) {
|
|
|
21968
21937
|
|
|
21969
21938
|
var BigNumber$1 = clone$2();
|
|
21970
21939
|
|
|
21940
|
+
// Ideally let's keep all formating in this file and DO NOT CREATE MORE FILES
|
|
21941
|
+
const formatNumber$3 = (number, minPrecision = 2, maxPrecision = 2) => {
|
|
21942
|
+
const options = {
|
|
21943
|
+
minimumFractionDigits: minPrecision,
|
|
21944
|
+
maximumFractionDigits: maxPrecision,
|
|
21945
|
+
};
|
|
21946
|
+
return number.toLocaleString('en-US', options);
|
|
21947
|
+
};
|
|
21948
|
+
// Formats a number with SI (International System of Units) sufixes
|
|
21949
|
+
const formatNumberSI = (num, digits = 2) => {
|
|
21950
|
+
const number = typeof num === 'string' ? parseFloat(num) : num;
|
|
21951
|
+
const lookupSI = [
|
|
21952
|
+
{ value: 1, symbol: '' },
|
|
21953
|
+
{ value: 1e6, symbol: 'M' },
|
|
21954
|
+
{ value: 1e9, symbol: 'B' },
|
|
21955
|
+
{ value: 1e12, symbol: 'T' },
|
|
21956
|
+
];
|
|
21957
|
+
const regEx = /\.0+$|(\.[0-9]*[1-9])0+$/;
|
|
21958
|
+
let formatted;
|
|
21959
|
+
if (number >= 1e18) {
|
|
21960
|
+
formatted = '∞';
|
|
21961
|
+
}
|
|
21962
|
+
else {
|
|
21963
|
+
let i;
|
|
21964
|
+
for (i = lookupSI.length - 1; i > 0; i--) {
|
|
21965
|
+
if (number >= lookupSI[i].value) {
|
|
21966
|
+
break;
|
|
21967
|
+
}
|
|
21968
|
+
}
|
|
21969
|
+
formatted = formatNumber$3(number / lookupSI[i].value, digits, digits).replace(regEx, '$1') + lookupSI[i].symbol;
|
|
21970
|
+
}
|
|
21971
|
+
return formatted;
|
|
21972
|
+
};
|
|
21973
|
+
const formatUSDNumber$1 = (input) => {
|
|
21974
|
+
const number = new BigNumber$1(input);
|
|
21975
|
+
if (number.isNaN())
|
|
21976
|
+
return '0';
|
|
21977
|
+
// If the number is greater than 0 but less than 0.01
|
|
21978
|
+
if (number.gt(0) && number.lt(0.01)) {
|
|
21979
|
+
return '<0.01';
|
|
21980
|
+
}
|
|
21981
|
+
// If the number is greater than 1k, round to no decimals.
|
|
21982
|
+
if (number.gt(1000)) {
|
|
21983
|
+
return number.toNumber().toLocaleString('en-US', { maximumFractionDigits: 0 });
|
|
21984
|
+
}
|
|
21985
|
+
// Note: Between 1k and 0.01 show 2 decimals
|
|
21986
|
+
return parseFloat(number.toFixed(2)).toLocaleString('en-US');
|
|
21987
|
+
};
|
|
21988
|
+
|
|
21971
21989
|
const getBalanceNumber = (balance, decimals = 18) => {
|
|
21972
21990
|
// use with caution. JS can only safely represent up to 15-17 digits of precision
|
|
21973
21991
|
// so you will lose precision in decimals and really big numbers, for those cases use getBNWithDecimals
|
|
@@ -70239,7 +70257,7 @@ const UserBondRow = ({ bill }) => {
|
|
|
70239
70257
|
const cliffCountdown = getTimePeriods(lastBlockTimestamp + (vestingCliff !== null && vestingCliff !== void 0 ? vestingCliff : 0) - currentTime, true);
|
|
70240
70258
|
return (jsxs("div", { className: "your-bonds", onClick: onOpenPurchasedBond, children: [jsxs("div", { className: "token-info-container", children: [jsx$2(TokenInfoAndName, { tokenSymbol: bill.bond.earnToken.symbol, chain: bill.bond.chainId, tag: (_c = bill.bond.tags) === null || _c === void 0 ? void 0 : _c[0], vestEnds: `Ends in ${getPendingVestingString(bill)}`, isHotBond: true }), jsx$2("div", { className: "tooltip-column", children: jsx$2(TooltipBubble, { className: "tooltip-bubble", body: jsx$2(BondInfoTooltip, { earnTokenContract: ((_d = bill === null || bill === void 0 ? void 0 : bill.bond) === null || _d === void 0 ? void 0 : _d.earnToken.address[bill === null || bill === void 0 ? void 0 : bill.bond.chainId]) || '', earnTokenSymbol: ((_e = bill === null || bill === void 0 ? void 0 : bill.bond) === null || _e === void 0 ? void 0 : _e.earnToken.symbol) || '', bondContract: (_f = bill === null || bill === void 0 ? void 0 : bill.address) !== null && _f !== void 0 ? _f : '', projectLink: (_g = bill === null || bill === void 0 ? void 0 : bill.bond) === null || _g === void 0 ? void 0 : _g.projectLink, twitter: (_h = bill === null || bill === void 0 ? void 0 : bill.bond) === null || _h === void 0 ? void 0 : _h.twitter, audit: (_j = bill === null || bill === void 0 ? void 0 : bill.bond) === null || _j === void 0 ? void 0 : _j.audit, chain: (_k = bill === null || bill === void 0 ? void 0 : bill.bond) === null || _k === void 0 ? void 0 : _k.chainId }), width: "205px", placement: "bottomRight", transformTip: "translate(5%, 0%)", children: jsx$2(Flex$1, { sx: {
|
|
70241
70259
|
opacity: 0.8,
|
|
70242
|
-
}, children: jsx$2(Svg, { icon: "more", width: "25px" }) }) }) })] }), jsxs("div", { className: "your-bonds-columns-container", children: [jsxs("div", { className: "your-bonds-content", children: [jsx$2("div", { className: "your-bonds-content-title", children: "Claimable" }), jsxs("div", { className: "your-bonds-content-tokens-amount", children: [formatNumberSI(
|
|
70260
|
+
}, children: jsx$2(Svg, { icon: "more", width: "25px" }) }) }) })] }), jsxs("div", { className: "your-bonds-columns-container", children: [jsxs("div", { className: "your-bonds-content", children: [jsx$2("div", { className: "your-bonds-content-title", children: "Claimable" }), jsxs("div", { className: "your-bonds-content-tokens-amount", children: [formatNumberSI(claimable(bill), 3), jsx$2("div", { className: "your-bonds-content-tokens-usd-amount", children: `($${(claimable(bill) * ((_l = earnTokenPrice === null || earnTokenPrice === void 0 ? void 0 : earnTokenPrice.price) !== null && _l !== void 0 ? _l : 0)).toFixed(2)})` })] })] }), jsxs("div", { className: "your-bonds-content", children: [jsx$2("div", { className: "your-bonds-content-title", children: "Pending" }), jsxs("div", { className: "your-bonds-content-tokens-amount", children: [formatNumberSI(totalPending(bill), 3), jsx$2("div", { className: "your-bonds-content-tokens-usd-amount", children: `($${(totalPending(bill) * ((_m = earnTokenPrice === null || earnTokenPrice === void 0 ? void 0 : earnTokenPrice.price) !== null && _m !== void 0 ? _m : 0)).toFixed(2)})` })] })] }), jsx$2("div", { className: "your-bonds-content hide-mobile", children: vestingTimeRemainingString(bill) }), jsx$2("div", { className: "your-bonds-column-button", children: userChainId !== bill.bond.chainId ? (jsxs(Button, { className: "button", disabled: claimable(bill) === 0 || load, load: load, onClick: (event) => {
|
|
70243
70261
|
event.stopPropagation();
|
|
70244
70262
|
// Add your claim logic here
|
|
70245
70263
|
switchChain({ chainId: bill.bond.chainId });
|
|
@@ -73298,6 +73316,10 @@ const getLaunchBondsPublicData = (preTGEBonds, chains, apiUrl) => __awaiter$9(vo
|
|
|
73298
73316
|
address: bill.contractAddress,
|
|
73299
73317
|
name: 'maxPoints',
|
|
73300
73318
|
},
|
|
73319
|
+
{
|
|
73320
|
+
address: bill.contractAddress,
|
|
73321
|
+
name: 'startVestingTimestamp',
|
|
73322
|
+
},
|
|
73301
73323
|
];
|
|
73302
73324
|
});
|
|
73303
73325
|
const vals = yield multicall(chainId, launchBondsABI_V2_2_0, launchBondsCalls);
|
|
@@ -73306,10 +73328,11 @@ const getLaunchBondsPublicData = (preTGEBonds, chains, apiUrl) => __awaiter$9(vo
|
|
|
73306
73328
|
const returnedBills = chunkedBills === null || chunkedBills === void 0 ? void 0 : chunkedBills.map((chunk, index) => {
|
|
73307
73329
|
const bondConfig = filteredBonds === null || filteredBonds === void 0 ? void 0 : filteredBonds.find((bill) => (bill === null || bill === void 0 ? void 0 : bill.index) === preTGEBondsIds[index]);
|
|
73308
73330
|
const principalTokenPrice = 1;
|
|
73309
|
-
const
|
|
73310
|
-
const [trueBillPrice, terms, totalPrincipalBilled, finalized, minPoints, maxPoints] = chunk;
|
|
73331
|
+
const [trueBillPrice, terms, totalPrincipalBilled, finalized, minPoints, maxPoints, startVestingTimestamp] = chunk;
|
|
73311
73332
|
const [, , vestingTerm, , , initialRelease, totalRaise, maxTotalPayout] = terms;
|
|
73312
|
-
const
|
|
73333
|
+
const initPrice = getBalanceNumber(trueBillPrice, bondConfig.token.decimals[bondConfig.chainId]);
|
|
73334
|
+
const data = Object.assign(Object.assign({}, bondConfig), { initialRelease: initialRelease / 10000, vestingTerm: vestingTerm === null || vestingTerm === void 0 ? void 0 : vestingTerm.toString(), trueBillPrice: trueBillPrice === null || trueBillPrice === void 0 ? void 0 : trueBillPrice.toString(), maxTotalPayout: maxTotalPayout === null || maxTotalPayout === void 0 ? void 0 : maxTotalPayout.toString(), totalPrincipalBilled: totalPrincipalBilled === null || totalPrincipalBilled === void 0 ? void 0 : totalPrincipalBilled.toString(), earnTokenPrice: initPrice, // This should eventually be changed for the real market price?
|
|
73335
|
+
principalTokenPrice, totalRaise: totalRaise === null || totalRaise === void 0 ? void 0 : totalRaise.toString(), finalized: finalized[0], minPoints: minPoints.toString(), maxPoints: maxPoints.toString(), startVestingTimestamp: startVestingTimestamp === null || startVestingTimestamp === void 0 ? void 0 : startVestingTimestamp.toString(), initTime: terms.startTime.toString(), finishTime: terms.endTime.toString(), initPrice });
|
|
73313
73336
|
return data;
|
|
73314
73337
|
});
|
|
73315
73338
|
data.push(returnedBills);
|
|
@@ -73332,9 +73355,9 @@ function usePreTGEUserBonds() {
|
|
|
73332
73355
|
const { address } = useAccount();
|
|
73333
73356
|
const apiUrl = useURLByEnvironment('apiV2');
|
|
73334
73357
|
return useQuery({
|
|
73335
|
-
queryKey: [QUERY_KEYS.
|
|
73358
|
+
queryKey: [QUERY_KEYS.PRE_TGE_USER_BONDS, (_a = preTGEBonds === null || preTGEBonds === void 0 ? void 0 : preTGEBonds.length) !== null && _a !== void 0 ? _a : '', address],
|
|
73336
73359
|
queryFn: () => fetchPreTGEUserBonds(preTGEBonds, address, apiUrl),
|
|
73337
|
-
|
|
73360
|
+
refetchInterval: 30000,
|
|
73338
73361
|
refetchOnWindowFocus: false,
|
|
73339
73362
|
enabled: !!preTGEBonds && preTGEBonds.length > 0 && !!address,
|
|
73340
73363
|
});
|
|
@@ -73432,27 +73455,119 @@ const fetchPreTGEUserBonds = (preTGEBonds, account, apiUrl) => __awaiter$9(void
|
|
|
73432
73455
|
});
|
|
73433
73456
|
|
|
73434
73457
|
const PreTgeActions = ({ userBond }) => {
|
|
73435
|
-
var _a;
|
|
73458
|
+
var _a, _b;
|
|
73459
|
+
//Hooks
|
|
73460
|
+
const { writeContractAsync } = useWriteContract();
|
|
73461
|
+
const { address: account } = useAccount();
|
|
73462
|
+
const SDKConfig = useSDKConfig();
|
|
73463
|
+
const { addToastError } = usePopups();
|
|
73464
|
+
const { refetch } = usePreTGEUserBonds();
|
|
73465
|
+
//State
|
|
73466
|
+
const [loading, setLoading] = useState(false);
|
|
73467
|
+
const [hash, setHash] = useState('');
|
|
73468
|
+
// Data
|
|
73469
|
+
const { isLoading: isLoadingOnChain, isSuccess } = useMonitorTxHash(hash, userBond === null || userBond === void 0 ? void 0 : userBond.chainId);
|
|
73470
|
+
const hasRedeemed = (_a = userBond === null || userBond === void 0 ? void 0 : userBond.accountInfo) === null || _a === void 0 ? void 0 : _a.hasRedeemed;
|
|
73436
73471
|
const now = new Date().getTime();
|
|
73437
|
-
const redeemTime = ((
|
|
73438
|
-
// const isRedeemable = now > redeemTime
|
|
73472
|
+
const redeemTime = ((_b = userBond === null || userBond === void 0 ? void 0 : userBond.redeemTime) !== null && _b !== void 0 ? _b : 0) * 1000;
|
|
73439
73473
|
const timeDiff = Math.abs(redeemTime - now);
|
|
73440
73474
|
const hoursLeft = Math.floor((timeDiff - (timeDiff % (1000 * 60 * 60))) / (1000 * 60 * 60));
|
|
73441
73475
|
const minsLeft = Math.floor((timeDiff % (1000 * 60 * 60)) / (1000 * 60));
|
|
73442
|
-
|
|
73476
|
+
const saleFinalized = userBond === null || userBond === void 0 ? void 0 : userBond.finalized;
|
|
73477
|
+
const handleRedeem = () => __awaiter$9(void 0, void 0, void 0, function* () {
|
|
73478
|
+
setLoading(true);
|
|
73479
|
+
writeContractAsync({
|
|
73480
|
+
address: userBond.contractAddress,
|
|
73481
|
+
abi: launchBondsABI_V2_2_0,
|
|
73482
|
+
functionName: 'redeem',
|
|
73483
|
+
chain: userBond.chainId,
|
|
73484
|
+
account,
|
|
73485
|
+
})
|
|
73486
|
+
.then((r) => {
|
|
73487
|
+
setHash(r);
|
|
73488
|
+
})
|
|
73489
|
+
.catch((e) => {
|
|
73490
|
+
var _a;
|
|
73491
|
+
console.error(e.message);
|
|
73492
|
+
reportError({
|
|
73493
|
+
apiUrl: (_a = SDKConfig === null || SDKConfig === void 0 ? void 0 : SDKConfig.urls) === null || _a === void 0 ? void 0 : _a.apiV2,
|
|
73494
|
+
error: e.message,
|
|
73495
|
+
extraInfo: { type: 'redeemLaunchBond', error: e.message },
|
|
73496
|
+
chainId: userBond.chainId,
|
|
73497
|
+
account,
|
|
73498
|
+
});
|
|
73499
|
+
addToastError(e.shortMessage);
|
|
73500
|
+
})
|
|
73501
|
+
.finally(() => setLoading(false));
|
|
73502
|
+
});
|
|
73503
|
+
const handleClaim = () => __awaiter$9(void 0, void 0, void 0, function* () {
|
|
73504
|
+
var _a, _b;
|
|
73505
|
+
setLoading(true);
|
|
73506
|
+
setHash('');
|
|
73507
|
+
if (!((_a = userBond === null || userBond === void 0 ? void 0 : userBond.userOwnedBillsData) === null || _a === void 0 ? void 0 : _a.id))
|
|
73508
|
+
return;
|
|
73509
|
+
writeContractAsync({
|
|
73510
|
+
address: userBond.contractAddress,
|
|
73511
|
+
abi: launchBondsABI_V2_2_0,
|
|
73512
|
+
functionName: 'claim',
|
|
73513
|
+
args: [(_b = userBond === null || userBond === void 0 ? void 0 : userBond.userOwnedBillsData) === null || _b === void 0 ? void 0 : _b.id],
|
|
73514
|
+
chain: userBond.chainId,
|
|
73515
|
+
account,
|
|
73516
|
+
})
|
|
73517
|
+
.then((r) => {
|
|
73518
|
+
setHash(r);
|
|
73519
|
+
})
|
|
73520
|
+
.catch((e) => {
|
|
73521
|
+
var _a;
|
|
73522
|
+
console.error(e.message);
|
|
73523
|
+
reportError({
|
|
73524
|
+
apiUrl: (_a = SDKConfig === null || SDKConfig === void 0 ? void 0 : SDKConfig.urls) === null || _a === void 0 ? void 0 : _a.apiV2,
|
|
73525
|
+
error: e.message,
|
|
73526
|
+
extraInfo: { type: 'claimLaunchBond', error: e.message },
|
|
73527
|
+
chainId: userBond.chainId,
|
|
73528
|
+
account,
|
|
73529
|
+
});
|
|
73530
|
+
addToastError(e.shortMessage);
|
|
73531
|
+
})
|
|
73532
|
+
.finally(() => setLoading(false));
|
|
73533
|
+
});
|
|
73534
|
+
useEffect(() => {
|
|
73535
|
+
// trigger refetch user bonds once tx is confirmed
|
|
73536
|
+
if (!!hash && isSuccess && !isLoadingOnChain) {
|
|
73537
|
+
console.log('trigger user refetch');
|
|
73538
|
+
refetch();
|
|
73539
|
+
}
|
|
73540
|
+
}, [hash, isSuccess, isLoadingOnChain]);
|
|
73541
|
+
return (jsx$2(Button, { disabled: !saleFinalized || loading || isLoadingOnChain, load: loading || isLoadingOnChain, fullWidth: true, sx: {
|
|
73542
|
+
fontSize: '14px',
|
|
73543
|
+
height: '30px',
|
|
73544
|
+
background: !saleFinalized && 'var(--theme-ui-colors-white4) !important',
|
|
73545
|
+
}, onClick: hasRedeemed ? handleClaim : handleRedeem, children: saleFinalized ? 'Claim' : `Claimable in ${hoursLeft > 0 ? `${hoursLeft}h` : `${minsLeft}m`}` }));
|
|
73443
73546
|
};
|
|
73444
73547
|
|
|
73445
73548
|
const PreTgeUserRow = ({ userBond }) => {
|
|
73446
|
-
var _a, _b, _c, _d;
|
|
73549
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
73550
|
+
const saleFinalized = userBond.finalized;
|
|
73551
|
+
const hasRedeemed = userBond.accountInfo.hasRedeemed;
|
|
73447
73552
|
const depositAmount = getBalanceNumber(new BigNumber$1((_a = userBond.accountInfo.depositAmount) !== null && _a !== void 0 ? _a : '0'), userBond.token.decimals[userBond.chainId]);
|
|
73448
73553
|
const truePricePaid = getBalanceNumber(new BigNumber$1((_b = userBond.accountInfo.truePricePaid) !== null && _b !== void 0 ? _b : '0'), userBond.token.decimals[userBond.chainId]);
|
|
73449
|
-
const pendingAmount = depositAmount / truePricePaid;
|
|
73450
|
-
const pendingUSD = pendingAmount * userBond.earnTokenPrice;
|
|
73451
73554
|
const vestingTimePeriods = getTimePeriods(parseFloat(userBond.vestingTerm), false);
|
|
73452
|
-
const vestingString =
|
|
73453
|
-
|
|
73555
|
+
const vestingString = hasRedeemed
|
|
73556
|
+
? getPendingVestingString(userBond === null || userBond === void 0 ? void 0 : userBond.userOwnedBillsData)
|
|
73557
|
+
: `${vestingTimePeriods.months} Months`;
|
|
73558
|
+
const userAllocation = depositAmount / (userBond === null || userBond === void 0 ? void 0 : userBond.initPrice);
|
|
73559
|
+
const initialRelease = !hasRedeemed && saleFinalized ? userAllocation * (userBond === null || userBond === void 0 ? void 0 : userBond.initialRelease) : 0;
|
|
73560
|
+
// pendingRewards variable follows the naming of the SC, but it actually means currently claimable tokens
|
|
73561
|
+
const pendingRewards = getBalanceNumber(new BigNumber$1((_c = userBond === null || userBond === void 0 ? void 0 : userBond.userOwnedBillsData) === null || _c === void 0 ? void 0 : _c.pendingRewards), (_e = (_d = userBond === null || userBond === void 0 ? void 0 : userBond.earnToken) === null || _d === void 0 ? void 0 : _d.decimals) === null || _e === void 0 ? void 0 : _e[userBond.chainId]);
|
|
73562
|
+
// payout variable follows the naming of the SC, but it actually means total tokens vested
|
|
73563
|
+
const payout = getBalanceNumber(new BigNumber$1((_f = userBond === null || userBond === void 0 ? void 0 : userBond.userOwnedBillsData) === null || _f === void 0 ? void 0 : _f.payout), (_h = (_g = userBond === null || userBond === void 0 ? void 0 : userBond.earnToken) === null || _g === void 0 ? void 0 : _g.decimals) === null || _h === void 0 ? void 0 : _h[userBond.chainId]);
|
|
73564
|
+
const claimableAmount = hasRedeemed ? pendingRewards : initialRelease;
|
|
73565
|
+
const claimableUSD = claimableAmount * userBond.initPrice;
|
|
73566
|
+
const pendingAmount = hasRedeemed ? payout : depositAmount / truePricePaid;
|
|
73567
|
+
const pendingUSD = pendingAmount * userBond.earnTokenPrice;
|
|
73568
|
+
return (jsxs("div", { className: "your-bonds", onClick: () => null, children: [jsxs("div", { className: "token-info-container", children: [jsx$2(TokenInfoAndName, { tokenSymbol: userBond.earnToken.symbol, chain: userBond.chainId, tag: (_j = userBond.tags) === null || _j === void 0 ? void 0 : _j[0], vestEnds: `Ends in ${vestingString}`, isHotBond: true }), jsx$2("div", { className: "tooltip-column", children: jsx$2(TooltipBubble, { className: "tooltip-bubble", body: jsx$2(BondInfoTooltip, { earnTokenContract: (userBond === null || userBond === void 0 ? void 0 : userBond.earnToken.address[userBond === null || userBond === void 0 ? void 0 : userBond.chainId]) || '', earnTokenSymbol: (userBond === null || userBond === void 0 ? void 0 : userBond.earnToken.symbol) || '', bondContract: (_k = userBond.contractAddress) !== null && _k !== void 0 ? _k : '', projectLink: userBond === null || userBond === void 0 ? void 0 : userBond.projectLink, twitter: userBond === null || userBond === void 0 ? void 0 : userBond.twitter, audit: userBond === null || userBond === void 0 ? void 0 : userBond.audit, chain: userBond === null || userBond === void 0 ? void 0 : userBond.chainId }), width: "205px", placement: "bottomRight", transformTip: "translate(5%, 0%)", children: jsx$2(Flex$1, { sx: {
|
|
73454
73569
|
opacity: 0.8,
|
|
73455
|
-
}, children: jsx$2(Svg, { icon: "more", width: "25px" }) }) }) })] }), jsxs("div", { className: "your-bonds-columns-container", children: [jsxs("div", { className: "your-bonds-content", children: [jsx$2("div", { className: "your-bonds-content-title", children: "Claimable" }), jsxs("div", { className: "your-bonds-content-tokens-amount", children: [
|
|
73570
|
+
}, children: jsx$2(Svg, { icon: "more", width: "25px" }) }) }) })] }), jsxs("div", { className: "your-bonds-columns-container", children: [jsxs("div", { className: "your-bonds-content", children: [jsx$2("div", { className: "your-bonds-content-title", children: "Claimable" }), jsxs("div", { className: "your-bonds-content-tokens-amount", children: [formatNumberSI(claimableAmount, 3), jsxs("div", { className: "your-bonds-content-tokens-usd-amount", children: ["($", formatUSDNumber$1(claimableUSD), ")"] })] })] }), jsxs("div", { className: "your-bonds-content", children: [jsx$2("div", { className: "your-bonds-content-title", children: "Pending" }), jsxs("div", { className: "your-bonds-content-tokens-amount", children: [formatNumberSI(pendingAmount, 3), jsxs("div", { className: "your-bonds-content-tokens-usd-amount", children: ["($", formatUSDNumber$1(pendingUSD), ")"] })] })] }), jsx$2("div", { className: "your-bonds-content hide-mobile", children: vestingString }), jsx$2("div", { className: "your-bonds-column-button", children: jsx$2(PreTgeActions, { userBond: userBond }) })] })] }));
|
|
73456
73571
|
};
|
|
73457
73572
|
|
|
73458
73573
|
const YourBonds = ({ showOnly }) => {
|
|
@@ -76111,273 +76226,6 @@ var BOND_2_4_0 = [
|
|
|
76111
76226
|
}
|
|
76112
76227
|
];
|
|
76113
76228
|
|
|
76114
|
-
function useBondsData() {
|
|
76115
|
-
const { data: tokenPrices } = useTokenPrices();
|
|
76116
|
-
const { data: bondList } = useBondsList();
|
|
76117
|
-
const SDKConfig = useSDKConfig();
|
|
76118
|
-
const apiUrl = useURLByEnvironment('apiV2');
|
|
76119
|
-
const realTimeApiURL = useURLByEnvironment('realTimeApi');
|
|
76120
|
-
return useQuery({
|
|
76121
|
-
queryKey: [QUERY_KEYS.BONDS_DATA],
|
|
76122
|
-
queryFn: () => getBondsData(SDKConfig.chains, realTimeApiURL, tokenPrices, bondList, apiUrl),
|
|
76123
|
-
refetchInterval: 20000, // i.e. 20 sec
|
|
76124
|
-
refetchOnWindowFocus: false,
|
|
76125
|
-
retry: 0,
|
|
76126
|
-
initialData: [],
|
|
76127
|
-
enabled: !!SDKConfig.chains && SDKConfig.chains.length > 0,
|
|
76128
|
-
});
|
|
76129
|
-
}
|
|
76130
|
-
const getBondsData = (chains, realTimeApiURL, tokenPrices, bondList, apiUrl) => __awaiter$9(void 0, void 0, void 0, function* () {
|
|
76131
|
-
try {
|
|
76132
|
-
const response = yield axios.get(`${realTimeApiURL}/bonds`);
|
|
76133
|
-
return response.data.bonds;
|
|
76134
|
-
}
|
|
76135
|
-
catch (e) {
|
|
76136
|
-
console.time('Fallback'); // Start debug timer
|
|
76137
|
-
const billData = [];
|
|
76138
|
-
if (tokenPrices && bondList) {
|
|
76139
|
-
yield Promise.all(chains.map((chainId) => __awaiter$9(void 0, void 0, void 0, function* () {
|
|
76140
|
-
var _a;
|
|
76141
|
-
const bills = (_a = bondList === null || bondList === void 0 ? void 0 : bondList.filter((bill) => {
|
|
76142
|
-
var _a, _b;
|
|
76143
|
-
return ((_b = (_a = bill === null || bill === void 0 ? void 0 : bill.contractAddress) === null || _a === void 0 ? void 0 : _a[chainId]) === null || _b === void 0 ? void 0 : _b.toLowerCase()) !== ACF_TO_ABOND.toLowerCase() &&
|
|
76144
|
-
!bill.soldOut &&
|
|
76145
|
-
bill.chainId === chainId;
|
|
76146
|
-
})) !== null && _a !== void 0 ? _a : [];
|
|
76147
|
-
const returnedBills = yield fetchBills(chainId, tokenPrices, bills);
|
|
76148
|
-
billData.push(returnedBills);
|
|
76149
|
-
})));
|
|
76150
|
-
}
|
|
76151
|
-
console.timeEnd(`Fallback`); // End chain-specific timer
|
|
76152
|
-
reportError({
|
|
76153
|
-
apiUrl,
|
|
76154
|
-
error: e,
|
|
76155
|
-
extraInfo: { type: 'getBondsData', e },
|
|
76156
|
-
});
|
|
76157
|
-
return billData === null || billData === void 0 ? void 0 : billData.flat();
|
|
76158
|
-
}
|
|
76159
|
-
});
|
|
76160
|
-
const fetchBills = (chainId, tokenPrices, bills) => __awaiter$9(void 0, void 0, void 0, function* () {
|
|
76161
|
-
const billIds = [];
|
|
76162
|
-
const billCalls = bills.flatMap((bill) => {
|
|
76163
|
-
var _a, _b, _c, _d;
|
|
76164
|
-
billIds.push(bill.index);
|
|
76165
|
-
return [
|
|
76166
|
-
// Get bill price with LP fees
|
|
76167
|
-
{
|
|
76168
|
-
address: (_a = bill.contractAddress[bill.chainId]) !== null && _a !== void 0 ? _a : '',
|
|
76169
|
-
name: bill.billVersion === types.BillVersion.V4 ? 'trueBondPrices' : 'trueBillPrice()',
|
|
76170
|
-
},
|
|
76171
|
-
// Get bill debt ratio
|
|
76172
|
-
{
|
|
76173
|
-
address: (_b = bill.contractAddress[bill.chainId]) !== null && _b !== void 0 ? _b : '',
|
|
76174
|
-
name: 'totalPayoutGiven',
|
|
76175
|
-
},
|
|
76176
|
-
// Terms
|
|
76177
|
-
// (1) controlVariable (2) vestingTerm (3) minimumPrice (4) maxPayout (5) maxDebt
|
|
76178
|
-
{
|
|
76179
|
-
address: (_c = bill.contractAddress[bill.chainId]) !== null && _c !== void 0 ? _c : '',
|
|
76180
|
-
name: 'terms',
|
|
76181
|
-
},
|
|
76182
|
-
{
|
|
76183
|
-
address: (_d = bill.contractAddress[bill.chainId]) !== null && _d !== void 0 ? _d : '',
|
|
76184
|
-
name: bill.billVersion !== types.BillVersion.V1 ? 'getMaxTotalPayout' : 'maxTotalPayout',
|
|
76185
|
-
},
|
|
76186
|
-
];
|
|
76187
|
-
});
|
|
76188
|
-
const vals = yield multicall(chainId, BOND_2_4_0, billCalls);
|
|
76189
|
-
const chunkSize = (vals === null || vals === void 0 ? void 0 : vals.length) / (bills === null || bills === void 0 ? void 0 : bills.length);
|
|
76190
|
-
const chunkedBills = lodashExports.chunk(vals, chunkSize);
|
|
76191
|
-
return cleanBillsData(billIds, chunkedBills, tokenPrices, chainId, bills);
|
|
76192
|
-
});
|
|
76193
|
-
const cleanBillsData = (billIds, chunkedBills, tokenPrices, chainId, bills) => {
|
|
76194
|
-
const data = chunkedBills === null || chunkedBills === void 0 ? void 0 : chunkedBills.map((chunk, index) => {
|
|
76195
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
76196
|
-
const bill = bills === null || bills === void 0 ? void 0 : bills.find((bill) => (bill === null || bill === void 0 ? void 0 : bill.index) === billIds[index]);
|
|
76197
|
-
const lpPrice = (_b = (_a = tokenPrices === null || tokenPrices === void 0 ? void 0 : tokenPrices.find((tokenPrice) => {
|
|
76198
|
-
var _a, _b, _c, _d;
|
|
76199
|
-
return ((_a = tokenPrice === null || tokenPrice === void 0 ? void 0 : tokenPrice.address) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === ((_d = (_c = (_b = bill === null || bill === void 0 ? void 0 : bill.lpToken) === null || _b === void 0 ? void 0 : _b.address) === null || _c === void 0 ? void 0 : _c[bill === null || bill === void 0 ? void 0 : bill.chainId]) === null || _d === void 0 ? void 0 : _d.toLowerCase()) &&
|
|
76200
|
-
(tokenPrice === null || tokenPrice === void 0 ? void 0 : tokenPrice.chainId) === chainId;
|
|
76201
|
-
})) === null || _a === void 0 ? void 0 : _a.price) !== null && _b !== void 0 ? _b : 0;
|
|
76202
|
-
const earnTokenPrice = (_d = (_c = tokenPrices === null || tokenPrices === void 0 ? void 0 : tokenPrices.find((tokenPrice) => {
|
|
76203
|
-
var _a, _b, _c, _d;
|
|
76204
|
-
return ((_a = tokenPrice === null || tokenPrice === void 0 ? void 0 : tokenPrice.address) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === ((_d = (_c = (_b = bill === null || bill === void 0 ? void 0 : bill.earnToken) === null || _b === void 0 ? void 0 : _b.address) === null || _c === void 0 ? void 0 : _c[bill === null || bill === void 0 ? void 0 : bill.chainId]) === null || _d === void 0 ? void 0 : _d.toLowerCase()) &&
|
|
76205
|
-
(tokenPrice === null || tokenPrice === void 0 ? void 0 : tokenPrice.chainId) === chainId;
|
|
76206
|
-
})) === null || _c === void 0 ? void 0 : _c.price) !== null && _d !== void 0 ? _d : 0;
|
|
76207
|
-
const [trueBillPrice, totalPayoutGiven, terms, maxTotalPayout] = chunk;
|
|
76208
|
-
const [, vestingTerm, , maxPayout] = terms;
|
|
76209
|
-
const tokensRemaining = new BigNumber$1(maxTotalPayout !== null && maxTotalPayout !== void 0 ? maxTotalPayout : '0')
|
|
76210
|
-
.minus(new BigNumber$1(totalPayoutGiven))
|
|
76211
|
-
.div(new BigNumber$1(10).pow((_e = bill === null || bill === void 0 ? void 0 : bill.earnToken.decimals[bill === null || bill === void 0 ? void 0 : bill.chainId]) !== null && _e !== void 0 ? _e : 18))
|
|
76212
|
-
.toString();
|
|
76213
|
-
const bonus = getRawBonus(trueBillPrice, lpPrice, earnTokenPrice);
|
|
76214
|
-
const bonusWithFee = getBonusWithFee((_f = bill === null || bill === void 0 ? void 0 : bill.feeInPayout) !== null && _f !== void 0 ? _f : 0, trueBillPrice, lpPrice, earnTokenPrice);
|
|
76215
|
-
let trueBondPrices = [];
|
|
76216
|
-
if ((bill === null || bill === void 0 ? void 0 : bill.billVersion) === types.BillVersion.V4) {
|
|
76217
|
-
trueBondPrices = trueBillPrice[0].map((data) => {
|
|
76218
|
-
var _a;
|
|
76219
|
-
return {
|
|
76220
|
-
points: data[2].toString(),
|
|
76221
|
-
trueBondPrice: data[0].toString(),
|
|
76222
|
-
bonus: getRawBonus(data[0].toString(), lpPrice, earnTokenPrice),
|
|
76223
|
-
bonusWithFee: getBonusWithFee((_a = bill === null || bill === void 0 ? void 0 : bill.feeInPayout) !== null && _a !== void 0 ? _a : 0, data[0].toString(), lpPrice, earnTokenPrice),
|
|
76224
|
-
};
|
|
76225
|
-
});
|
|
76226
|
-
}
|
|
76227
|
-
else {
|
|
76228
|
-
trueBondPrices = [
|
|
76229
|
-
{
|
|
76230
|
-
points: '0',
|
|
76231
|
-
trueBondPrice: trueBillPrice.toString(),
|
|
76232
|
-
bonus,
|
|
76233
|
-
bonusWithFee,
|
|
76234
|
-
},
|
|
76235
|
-
];
|
|
76236
|
-
}
|
|
76237
|
-
//I've added a ts ignore here due to some props marked as optional in the list repo which are actually not optional
|
|
76238
|
-
//@ts-ignore
|
|
76239
|
-
const cleanedData = Object.assign(Object.assign({}, bill), { type: (_g = bill === null || bill === void 0 ? void 0 : bill.billType) !== null && _g !== void 0 ? _g : '', billAddress: (_h = bill === null || bill === void 0 ? void 0 : bill.contractAddress[bill === null || bill === void 0 ? void 0 : bill.chainId]) !== null && _h !== void 0 ? _h : '', billNftAddress: (_j = bill === null || bill === void 0 ? void 0 : bill.billNnftAddress[bill === null || bill === void 0 ? void 0 : bill.chainId]) !== null && _j !== void 0 ? _j : '', showcaseTokenName: (_m = (_l = (_k = bill === null || bill === void 0 ? void 0 : bill.showcaseToken) === null || _k === void 0 ? void 0 : _k.symbol) !== null && _l !== void 0 ? _l : bill === null || bill === void 0 ? void 0 : bill.earnToken.symbol) !== null && _m !== void 0 ? _m : '', trueBondPrices, principalTokenPrice: (_o = lpPrice === null || lpPrice === void 0 ? void 0 : lpPrice.toString()) !== null && _o !== void 0 ? _o : '0', payoutTokenPrice: (_p = earnTokenPrice === null || earnTokenPrice === void 0 ? void 0 : earnTokenPrice.toString()) !== null && _p !== void 0 ? _p : '0', tokensRemaining, maxTotalPayout: maxTotalPayout === null || maxTotalPayout === void 0 ? void 0 : maxTotalPayout.toString(), maxPayout: maxPayout === null || maxPayout === void 0 ? void 0 : maxPayout.toString(), totalPayoutGiven: totalPayoutGiven === null || totalPayoutGiven === void 0 ? void 0 : totalPayoutGiven.toString(), vestingTerm: vestingTerm.toNumber() });
|
|
76240
|
-
return cleanedData;
|
|
76241
|
-
});
|
|
76242
|
-
return data;
|
|
76243
|
-
};
|
|
76244
|
-
const getBonusWithFee = (feeInPayout, trueBillPrice, lpPrice, earnTokenPrice) => {
|
|
76245
|
-
const fee = feeInPayout !== null && feeInPayout !== void 0 ? feeInPayout : 0;
|
|
76246
|
-
const trueBillPriceMinusFee = new BigNumber$1(trueBillPrice !== null && trueBillPrice !== void 0 ? trueBillPrice : 0).times((100 + fee) / 100);
|
|
76247
|
-
const priceUSDMinusFee = getBalanceNumber(trueBillPriceMinusFee) * lpPrice;
|
|
76248
|
-
const discountWithoutFee = ((earnTokenPrice - priceUSDMinusFee) / earnTokenPrice) * 100;
|
|
76249
|
-
return discountWithoutFee > 0 ? (discountWithoutFee / (100 - discountWithoutFee)) * 100 : 0;
|
|
76250
|
-
};
|
|
76251
|
-
const getRawBonus = (trueBillPrice, lpPrice, earnTokenPrice) => {
|
|
76252
|
-
const priceUsd = getBalanceNumber(trueBillPrice.toString()) * lpPrice;
|
|
76253
|
-
const discount = ((earnTokenPrice - priceUsd) / earnTokenPrice) * 100;
|
|
76254
|
-
return discount > 0 ? (discount / (100 - discount)) * 100 : 0;
|
|
76255
|
-
};
|
|
76256
|
-
|
|
76257
|
-
function adjustDecimals(numStr) {
|
|
76258
|
-
const parts = numStr.split('.');
|
|
76259
|
-
if (parts.length < 2) {
|
|
76260
|
-
// This means the number doesn't have any decimals
|
|
76261
|
-
return numStr;
|
|
76262
|
-
}
|
|
76263
|
-
if (parts[1].length > 18) {
|
|
76264
|
-
parts[1] = parts[1].slice(0, 18); // Take the first 18 decimals
|
|
76265
|
-
return parts[0] + '.' + parts[1];
|
|
76266
|
-
}
|
|
76267
|
-
else {
|
|
76268
|
-
return numStr;
|
|
76269
|
-
}
|
|
76270
|
-
}
|
|
76271
|
-
const convertToTokenValue = (numberString, decimals) => {
|
|
76272
|
-
if (isNaN(parseFloat(numberString))) {
|
|
76273
|
-
console.error('Error: numberString to parse is not a number');
|
|
76274
|
-
return parseUnits$1('0', decimals);
|
|
76275
|
-
}
|
|
76276
|
-
const tokenValue = parseUnits$1(adjustDecimals(numberString), decimals);
|
|
76277
|
-
return tokenValue;
|
|
76278
|
-
};
|
|
76279
|
-
|
|
76280
|
-
var ABI_DEPOSIT = [
|
|
76281
|
-
{
|
|
76282
|
-
inputs: [
|
|
76283
|
-
{
|
|
76284
|
-
internalType: "uint256",
|
|
76285
|
-
name: "_amount",
|
|
76286
|
-
type: "uint256"
|
|
76287
|
-
},
|
|
76288
|
-
{
|
|
76289
|
-
internalType: "uint256",
|
|
76290
|
-
name: "_maxPrice",
|
|
76291
|
-
type: "uint256"
|
|
76292
|
-
},
|
|
76293
|
-
{
|
|
76294
|
-
internalType: "address",
|
|
76295
|
-
name: "_depositor",
|
|
76296
|
-
type: "address"
|
|
76297
|
-
}
|
|
76298
|
-
],
|
|
76299
|
-
name: "deposit",
|
|
76300
|
-
outputs: [
|
|
76301
|
-
],
|
|
76302
|
-
stateMutability: "nonpayable",
|
|
76303
|
-
type: "function"
|
|
76304
|
-
}
|
|
76305
|
-
];
|
|
76306
|
-
|
|
76307
|
-
var ABI_DEPOSIT_SIG = [
|
|
76308
|
-
{
|
|
76309
|
-
inputs: [
|
|
76310
|
-
{
|
|
76311
|
-
internalType: "uint256",
|
|
76312
|
-
name: "_amount",
|
|
76313
|
-
type: "uint256"
|
|
76314
|
-
},
|
|
76315
|
-
{
|
|
76316
|
-
internalType: "uint256",
|
|
76317
|
-
name: "_maxPrice",
|
|
76318
|
-
type: "uint256"
|
|
76319
|
-
},
|
|
76320
|
-
{
|
|
76321
|
-
internalType: "address",
|
|
76322
|
-
name: "_depositor",
|
|
76323
|
-
type: "address"
|
|
76324
|
-
},
|
|
76325
|
-
{
|
|
76326
|
-
internalType: "bytes",
|
|
76327
|
-
name: "_tierProofSignature",
|
|
76328
|
-
type: "bytes"
|
|
76329
|
-
}
|
|
76330
|
-
],
|
|
76331
|
-
name: "deposit",
|
|
76332
|
-
outputs: [
|
|
76333
|
-
{
|
|
76334
|
-
internalType: "uint256",
|
|
76335
|
-
name: "",
|
|
76336
|
-
type: "uint256"
|
|
76337
|
-
}
|
|
76338
|
-
],
|
|
76339
|
-
stateMutability: "nonpayable",
|
|
76340
|
-
type: "function"
|
|
76341
|
-
}
|
|
76342
|
-
];
|
|
76343
|
-
|
|
76344
|
-
// returns the checksummed address if the address is valid, otherwise returns false
|
|
76345
|
-
function isAddress(value) {
|
|
76346
|
-
try {
|
|
76347
|
-
// Alphabetical letters must be made lowercase for getAddress to work.
|
|
76348
|
-
// See documentation here: https://docs.ethers.io/v5/api/utils/address/
|
|
76349
|
-
return getAddress(value.toLowerCase());
|
|
76350
|
-
}
|
|
76351
|
-
catch (_a) {
|
|
76352
|
-
return false;
|
|
76353
|
-
}
|
|
76354
|
-
}
|
|
76355
|
-
|
|
76356
|
-
const getNativeTicker = (chain) => {
|
|
76357
|
-
var _a;
|
|
76358
|
-
if (!chain)
|
|
76359
|
-
return undefined;
|
|
76360
|
-
return (_a = WNATIVE[chain]) === null || _a === void 0 ? void 0 : _a.symbol.substring(1);
|
|
76361
|
-
};
|
|
76362
|
-
const getTokenSymbol = (token) => {
|
|
76363
|
-
const nativeSymbols = ['BNB', 'ETH', 'POL', 'IOTA'];
|
|
76364
|
-
return nativeSymbols.includes(token === null || token === void 0 ? void 0 : token.symbol) ? `w${token === null || token === void 0 ? void 0 : token.symbol}` : token === null || token === void 0 ? void 0 : token.symbol;
|
|
76365
|
-
};
|
|
76366
|
-
const getSymbol = (token, chainId) => {
|
|
76367
|
-
if (!token)
|
|
76368
|
-
return '';
|
|
76369
|
-
return token === 'NATIVE' ? getNativeTicker(chainId) : getTokenSymbol(token);
|
|
76370
|
-
};
|
|
76371
|
-
|
|
76372
|
-
const TokenRow = ({ token, chainId, handleTokenSelect, tokenBalance, }) => {
|
|
76373
|
-
var _a, _b;
|
|
76374
|
-
const symbol = getSymbol(token, chainId);
|
|
76375
|
-
const tokenAddress = token === 'NATIVE' ? 'NATIVE' : token.address[chainId];
|
|
76376
|
-
const { address } = useAccount();
|
|
76377
|
-
const splited = typeof token !== 'string' ? (_a = token === null || token === void 0 ? void 0 : token.symbol) === null || _a === void 0 ? void 0 : _a.split('-') : undefined;
|
|
76378
|
-
return (jsxs(Flex, { sx: { p: '8px', justifyContent: 'space-between', cursor: 'pointer', '&:hover': { background: 'white4' } }, onClick: () => handleTokenSelect(tokenAddress !== null && tokenAddress !== void 0 ? tokenAddress : ''), children: [jsxs(Flex, { children: [lodashExports.isArray(splited) ? (jsx$2(TokenImage, { symbol: splited[0], symbol2: splited[1], size: 28, chain: chainId })) : (jsx$2(TokenImage, { symbol: getSymbol(token, chainId), size: 28, chain: chainId })), jsx$2(Flex, { sx: { mx: '8px', lineHeight: '28px', fontSize: '14px' }, children: symbol })] }), address && (jsx$2(Flex, { sx: { fontSize: '14px' }, children: tokenBalance === '0' ? ('0') : !tokenBalance ? (jsx$2(Spinner, { size: 15 })) : (jsx$2(Fragment$1, { children: (_b = new BigNumber$1(tokenBalance !== null && tokenBalance !== void 0 ? tokenBalance : '0')) === null || _b === void 0 ? void 0 : _b.toPrecision(5) })) }))] }));
|
|
76379
|
-
};
|
|
76380
|
-
|
|
76381
76229
|
var ERC_20_ABI = [
|
|
76382
76230
|
{
|
|
76383
76231
|
constant: true,
|
|
@@ -76605,6 +76453,299 @@ var ERC_20_ABI = [
|
|
|
76605
76453
|
}
|
|
76606
76454
|
];
|
|
76607
76455
|
|
|
76456
|
+
function useBondsData() {
|
|
76457
|
+
const { data: tokenPrices } = useTokenPrices();
|
|
76458
|
+
const { data: bondList } = useBondsList();
|
|
76459
|
+
const SDKConfig = useSDKConfig();
|
|
76460
|
+
const apiUrl = useURLByEnvironment('apiV2');
|
|
76461
|
+
const realTimeApiURL = useURLByEnvironment('realTimeApi');
|
|
76462
|
+
return useQuery({
|
|
76463
|
+
queryKey: [QUERY_KEYS.BONDS_DATA],
|
|
76464
|
+
queryFn: () => getBondsData(SDKConfig.chains, realTimeApiURL, tokenPrices, bondList, apiUrl),
|
|
76465
|
+
refetchInterval: 20000, // i.e. 20 sec
|
|
76466
|
+
refetchOnWindowFocus: false,
|
|
76467
|
+
retry: 0,
|
|
76468
|
+
initialData: [],
|
|
76469
|
+
enabled: !!SDKConfig.chains && SDKConfig.chains.length > 0,
|
|
76470
|
+
});
|
|
76471
|
+
}
|
|
76472
|
+
const getBondsData = (chains, realTimeApiURL, tokenPrices, bondList, apiUrl) => __awaiter$9(void 0, void 0, void 0, function* () {
|
|
76473
|
+
try {
|
|
76474
|
+
const response = yield axios.get(`${realTimeApiURL}/bonds`);
|
|
76475
|
+
return response.data.bonds;
|
|
76476
|
+
}
|
|
76477
|
+
catch (e) {
|
|
76478
|
+
console.time('Fallback'); // Start debug timer
|
|
76479
|
+
const billData = [];
|
|
76480
|
+
if (tokenPrices && bondList) {
|
|
76481
|
+
yield Promise.all(chains.map((chainId) => __awaiter$9(void 0, void 0, void 0, function* () {
|
|
76482
|
+
var _a;
|
|
76483
|
+
const bills = (_a = bondList === null || bondList === void 0 ? void 0 : bondList.filter((bill) => {
|
|
76484
|
+
var _a, _b;
|
|
76485
|
+
return ((_b = (_a = bill === null || bill === void 0 ? void 0 : bill.contractAddress) === null || _a === void 0 ? void 0 : _a[chainId]) === null || _b === void 0 ? void 0 : _b.toLowerCase()) !== ACF_TO_ABOND.toLowerCase() &&
|
|
76486
|
+
!bill.soldOut &&
|
|
76487
|
+
bill.chainId === chainId;
|
|
76488
|
+
})) !== null && _a !== void 0 ? _a : [];
|
|
76489
|
+
const returnedBills = yield fetchBills(chainId, tokenPrices, bills);
|
|
76490
|
+
billData.push(returnedBills);
|
|
76491
|
+
})));
|
|
76492
|
+
}
|
|
76493
|
+
console.timeEnd(`Fallback`); // End chain-specific timer
|
|
76494
|
+
reportError({
|
|
76495
|
+
apiUrl,
|
|
76496
|
+
error: e,
|
|
76497
|
+
extraInfo: { type: 'getBondsData', e },
|
|
76498
|
+
});
|
|
76499
|
+
return billData === null || billData === void 0 ? void 0 : billData.flat();
|
|
76500
|
+
}
|
|
76501
|
+
});
|
|
76502
|
+
const fetchBills = (chainId, tokenPrices, bills) => __awaiter$9(void 0, void 0, void 0, function* () {
|
|
76503
|
+
const billIds = [];
|
|
76504
|
+
const billCalls = bills.flatMap((bill) => {
|
|
76505
|
+
var _a, _b, _c, _d, _e;
|
|
76506
|
+
billIds.push(bill.index);
|
|
76507
|
+
return [
|
|
76508
|
+
// Get bill price with LP fees
|
|
76509
|
+
{
|
|
76510
|
+
address: (_a = bill.contractAddress[bill.chainId]) !== null && _a !== void 0 ? _a : '',
|
|
76511
|
+
name: bill.billVersion === types.BillVersion.V4 ? 'trueBondPrices' : 'trueBillPrice()',
|
|
76512
|
+
},
|
|
76513
|
+
// Get bill debt ratio
|
|
76514
|
+
{
|
|
76515
|
+
address: (_b = bill.contractAddress[bill.chainId]) !== null && _b !== void 0 ? _b : '',
|
|
76516
|
+
name: 'totalPayoutGiven',
|
|
76517
|
+
},
|
|
76518
|
+
// Terms
|
|
76519
|
+
// (1) controlVariable (2) vestingTerm (3) minimumPrice (4) maxPayout (5) maxDebt
|
|
76520
|
+
{
|
|
76521
|
+
address: (_c = bill.contractAddress[bill.chainId]) !== null && _c !== void 0 ? _c : '',
|
|
76522
|
+
name: 'terms',
|
|
76523
|
+
},
|
|
76524
|
+
{
|
|
76525
|
+
address: (_d = bill.contractAddress[bill.chainId]) !== null && _d !== void 0 ? _d : '',
|
|
76526
|
+
name: bill.billVersion !== types.BillVersion.V1 ? 'getMaxTotalPayout' : 'maxTotalPayout',
|
|
76527
|
+
},
|
|
76528
|
+
{
|
|
76529
|
+
address: (_e = bill.contractAddress[bill.chainId]) !== null && _e !== void 0 ? _e : '',
|
|
76530
|
+
name: 'customTreasury',
|
|
76531
|
+
},
|
|
76532
|
+
];
|
|
76533
|
+
});
|
|
76534
|
+
const vals = yield multicall(chainId, BOND_2_4_0, billCalls);
|
|
76535
|
+
// Prepare an additional multicall for `customTreasury` token balance
|
|
76536
|
+
const treasuryAddresses = vals
|
|
76537
|
+
.filter((_, i) => i % 5 === 4)
|
|
76538
|
+
.map((customTreasury) => customTreasury[0]); // Extract `customTreasury` from chunks
|
|
76539
|
+
const treasuryBalanceCalls = treasuryAddresses.map((treasuryAddress, i) => {
|
|
76540
|
+
var _a, _b, _c, _d;
|
|
76541
|
+
return ({
|
|
76542
|
+
address: (_d = (_c = (_b = (_a = bills === null || bills === void 0 ? void 0 : bills[i]) === null || _a === void 0 ? void 0 : _a.earnToken) === null || _b === void 0 ? void 0 : _b.address) === null || _c === void 0 ? void 0 : _c[chainId]) !== null && _d !== void 0 ? _d : '', // Use the earnToken's address as currency
|
|
76543
|
+
name: 'balanceOf',
|
|
76544
|
+
params: [treasuryAddress], // Fetch balance for the custom treasury
|
|
76545
|
+
});
|
|
76546
|
+
});
|
|
76547
|
+
const treasuryBalances = yield multicall(chainId, ERC_20_ABI, treasuryBalanceCalls);
|
|
76548
|
+
console.log(vals);
|
|
76549
|
+
const updatedVals = vals.reduce((acc, val, index) => {
|
|
76550
|
+
acc.push(val);
|
|
76551
|
+
if ((index + 1) % 5 === 0) {
|
|
76552
|
+
acc.push(treasuryBalances[(index + 1) / 5 - 1]); // Append the treasury balance after every set of bill values
|
|
76553
|
+
}
|
|
76554
|
+
return acc;
|
|
76555
|
+
}, []);
|
|
76556
|
+
const chunkSize = (updatedVals === null || updatedVals === void 0 ? void 0 : updatedVals.length) / (bills === null || bills === void 0 ? void 0 : bills.length);
|
|
76557
|
+
const chunkedBills = lodashExports.chunk(updatedVals, chunkSize);
|
|
76558
|
+
return cleanBillsData(billIds, chunkedBills, tokenPrices, chainId, bills);
|
|
76559
|
+
});
|
|
76560
|
+
const cleanBillsData = (billIds, chunkedBills, tokenPrices, chainId, bills) => {
|
|
76561
|
+
const data = chunkedBills === null || chunkedBills === void 0 ? void 0 : chunkedBills.map((chunk, index) => {
|
|
76562
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
76563
|
+
const bill = bills === null || bills === void 0 ? void 0 : bills.find((bill) => (bill === null || bill === void 0 ? void 0 : bill.index) === billIds[index]);
|
|
76564
|
+
const lpPrice = (_b = (_a = tokenPrices === null || tokenPrices === void 0 ? void 0 : tokenPrices.find((tokenPrice) => {
|
|
76565
|
+
var _a, _b, _c, _d;
|
|
76566
|
+
return ((_a = tokenPrice === null || tokenPrice === void 0 ? void 0 : tokenPrice.address) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === ((_d = (_c = (_b = bill === null || bill === void 0 ? void 0 : bill.lpToken) === null || _b === void 0 ? void 0 : _b.address) === null || _c === void 0 ? void 0 : _c[bill === null || bill === void 0 ? void 0 : bill.chainId]) === null || _d === void 0 ? void 0 : _d.toLowerCase()) &&
|
|
76567
|
+
(tokenPrice === null || tokenPrice === void 0 ? void 0 : tokenPrice.chainId) === chainId;
|
|
76568
|
+
})) === null || _a === void 0 ? void 0 : _a.price) !== null && _b !== void 0 ? _b : 0;
|
|
76569
|
+
const earnTokenPrice = (_d = (_c = tokenPrices === null || tokenPrices === void 0 ? void 0 : tokenPrices.find((tokenPrice) => {
|
|
76570
|
+
var _a, _b, _c, _d;
|
|
76571
|
+
return ((_a = tokenPrice === null || tokenPrice === void 0 ? void 0 : tokenPrice.address) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === ((_d = (_c = (_b = bill === null || bill === void 0 ? void 0 : bill.earnToken) === null || _b === void 0 ? void 0 : _b.address) === null || _c === void 0 ? void 0 : _c[bill === null || bill === void 0 ? void 0 : bill.chainId]) === null || _d === void 0 ? void 0 : _d.toLowerCase()) &&
|
|
76572
|
+
(tokenPrice === null || tokenPrice === void 0 ? void 0 : tokenPrice.chainId) === chainId;
|
|
76573
|
+
})) === null || _c === void 0 ? void 0 : _c.price) !== null && _d !== void 0 ? _d : 0;
|
|
76574
|
+
const [trueBillPrice, totalPayoutGiven, terms, maxTotalPayout, , customTreasuryBalance] = chunk;
|
|
76575
|
+
const [, vestingTerm, , maxPayout] = terms;
|
|
76576
|
+
const tokensRemaining = new BigNumber$1(maxTotalPayout !== null && maxTotalPayout !== void 0 ? maxTotalPayout : '0')
|
|
76577
|
+
.minus(new BigNumber$1(totalPayoutGiven))
|
|
76578
|
+
.div(new BigNumber$1(10).pow((_e = bill === null || bill === void 0 ? void 0 : bill.earnToken.decimals[bill === null || bill === void 0 ? void 0 : bill.chainId]) !== null && _e !== void 0 ? _e : 18))
|
|
76579
|
+
.toNumber();
|
|
76580
|
+
const treasuryBalance = getBalanceNumber(customTreasuryBalance);
|
|
76581
|
+
const bonus = getRawBonus(trueBillPrice, lpPrice, earnTokenPrice);
|
|
76582
|
+
const bonusWithFee = getBonusWithFee((_f = bill === null || bill === void 0 ? void 0 : bill.feeInPayout) !== null && _f !== void 0 ? _f : 0, trueBillPrice, lpPrice, earnTokenPrice);
|
|
76583
|
+
let trueBondPrices = [];
|
|
76584
|
+
if ((bill === null || bill === void 0 ? void 0 : bill.billVersion) === types.BillVersion.V4) {
|
|
76585
|
+
trueBondPrices = trueBillPrice[0].map((data) => {
|
|
76586
|
+
var _a;
|
|
76587
|
+
return {
|
|
76588
|
+
points: data[2].toString(),
|
|
76589
|
+
trueBondPrice: data[0].toString(),
|
|
76590
|
+
bonus: getRawBonus(data[0].toString(), lpPrice, earnTokenPrice),
|
|
76591
|
+
bonusWithFee: getBonusWithFee((_a = bill === null || bill === void 0 ? void 0 : bill.feeInPayout) !== null && _a !== void 0 ? _a : 0, data[0].toString(), lpPrice, earnTokenPrice),
|
|
76592
|
+
};
|
|
76593
|
+
});
|
|
76594
|
+
}
|
|
76595
|
+
else {
|
|
76596
|
+
trueBondPrices = [
|
|
76597
|
+
{
|
|
76598
|
+
points: '0',
|
|
76599
|
+
trueBondPrice: trueBillPrice.toString(),
|
|
76600
|
+
bonus,
|
|
76601
|
+
bonusWithFee,
|
|
76602
|
+
},
|
|
76603
|
+
];
|
|
76604
|
+
}
|
|
76605
|
+
//I've added a ts ignore here due to some props marked as optional in the list repo which are actually not optional
|
|
76606
|
+
//@ts-ignore
|
|
76607
|
+
const cleanedData = Object.assign(Object.assign({}, bill), { type: (_g = bill === null || bill === void 0 ? void 0 : bill.billType) !== null && _g !== void 0 ? _g : '', billAddress: (_h = bill === null || bill === void 0 ? void 0 : bill.contractAddress[bill === null || bill === void 0 ? void 0 : bill.chainId]) !== null && _h !== void 0 ? _h : '', billNftAddress: (_j = bill === null || bill === void 0 ? void 0 : bill.billNnftAddress[bill === null || bill === void 0 ? void 0 : bill.chainId]) !== null && _j !== void 0 ? _j : '', showcaseTokenName: (_m = (_l = (_k = bill === null || bill === void 0 ? void 0 : bill.showcaseToken) === null || _k === void 0 ? void 0 : _k.symbol) !== null && _l !== void 0 ? _l : bill === null || bill === void 0 ? void 0 : bill.earnToken.symbol) !== null && _m !== void 0 ? _m : '', trueBondPrices, principalTokenPrice: (_o = lpPrice === null || lpPrice === void 0 ? void 0 : lpPrice.toString()) !== null && _o !== void 0 ? _o : '0', payoutTokenPrice: (_p = earnTokenPrice === null || earnTokenPrice === void 0 ? void 0 : earnTokenPrice.toString()) !== null && _p !== void 0 ? _p : '0', tokensRemaining: Math.min(treasuryBalance, tokensRemaining).toString(), maxTotalPayout: maxTotalPayout === null || maxTotalPayout === void 0 ? void 0 : maxTotalPayout.toString(), maxPayout: maxPayout === null || maxPayout === void 0 ? void 0 : maxPayout.toString(), totalPayoutGiven: totalPayoutGiven === null || totalPayoutGiven === void 0 ? void 0 : totalPayoutGiven.toString(), vestingTerm: vestingTerm.toNumber() });
|
|
76608
|
+
return cleanedData;
|
|
76609
|
+
});
|
|
76610
|
+
return data;
|
|
76611
|
+
};
|
|
76612
|
+
const getBonusWithFee = (feeInPayout, trueBillPrice, lpPrice, earnTokenPrice) => {
|
|
76613
|
+
const fee = feeInPayout !== null && feeInPayout !== void 0 ? feeInPayout : 0;
|
|
76614
|
+
const trueBillPriceMinusFee = new BigNumber$1(trueBillPrice !== null && trueBillPrice !== void 0 ? trueBillPrice : 0).times((100 + fee) / 100);
|
|
76615
|
+
const priceUSDMinusFee = getBalanceNumber(trueBillPriceMinusFee) * lpPrice;
|
|
76616
|
+
const discountWithoutFee = ((earnTokenPrice - priceUSDMinusFee) / earnTokenPrice) * 100;
|
|
76617
|
+
return discountWithoutFee > 0 ? (discountWithoutFee / (100 - discountWithoutFee)) * 100 : 0;
|
|
76618
|
+
};
|
|
76619
|
+
const getRawBonus = (trueBillPrice, lpPrice, earnTokenPrice) => {
|
|
76620
|
+
const priceUsd = getBalanceNumber(trueBillPrice.toString()) * lpPrice;
|
|
76621
|
+
const discount = ((earnTokenPrice - priceUsd) / earnTokenPrice) * 100;
|
|
76622
|
+
return discount > 0 ? (discount / (100 - discount)) * 100 : 0;
|
|
76623
|
+
};
|
|
76624
|
+
|
|
76625
|
+
function adjustDecimals(numStr) {
|
|
76626
|
+
const parts = numStr.split('.');
|
|
76627
|
+
if (parts.length < 2) {
|
|
76628
|
+
// This means the number doesn't have any decimals
|
|
76629
|
+
return numStr;
|
|
76630
|
+
}
|
|
76631
|
+
if (parts[1].length > 18) {
|
|
76632
|
+
parts[1] = parts[1].slice(0, 18); // Take the first 18 decimals
|
|
76633
|
+
return parts[0] + '.' + parts[1];
|
|
76634
|
+
}
|
|
76635
|
+
else {
|
|
76636
|
+
return numStr;
|
|
76637
|
+
}
|
|
76638
|
+
}
|
|
76639
|
+
const convertToTokenValue = (numberString, decimals) => {
|
|
76640
|
+
if (isNaN(parseFloat(numberString))) {
|
|
76641
|
+
console.error('Error: numberString to parse is not a number');
|
|
76642
|
+
return parseUnits$1('0', decimals);
|
|
76643
|
+
}
|
|
76644
|
+
const tokenValue = parseUnits$1(adjustDecimals(numberString), decimals);
|
|
76645
|
+
return tokenValue;
|
|
76646
|
+
};
|
|
76647
|
+
|
|
76648
|
+
var ABI_DEPOSIT = [
|
|
76649
|
+
{
|
|
76650
|
+
inputs: [
|
|
76651
|
+
{
|
|
76652
|
+
internalType: "uint256",
|
|
76653
|
+
name: "_amount",
|
|
76654
|
+
type: "uint256"
|
|
76655
|
+
},
|
|
76656
|
+
{
|
|
76657
|
+
internalType: "uint256",
|
|
76658
|
+
name: "_maxPrice",
|
|
76659
|
+
type: "uint256"
|
|
76660
|
+
},
|
|
76661
|
+
{
|
|
76662
|
+
internalType: "address",
|
|
76663
|
+
name: "_depositor",
|
|
76664
|
+
type: "address"
|
|
76665
|
+
}
|
|
76666
|
+
],
|
|
76667
|
+
name: "deposit",
|
|
76668
|
+
outputs: [
|
|
76669
|
+
],
|
|
76670
|
+
stateMutability: "nonpayable",
|
|
76671
|
+
type: "function"
|
|
76672
|
+
}
|
|
76673
|
+
];
|
|
76674
|
+
|
|
76675
|
+
var ABI_DEPOSIT_SIG = [
|
|
76676
|
+
{
|
|
76677
|
+
inputs: [
|
|
76678
|
+
{
|
|
76679
|
+
internalType: "uint256",
|
|
76680
|
+
name: "_amount",
|
|
76681
|
+
type: "uint256"
|
|
76682
|
+
},
|
|
76683
|
+
{
|
|
76684
|
+
internalType: "uint256",
|
|
76685
|
+
name: "_maxPrice",
|
|
76686
|
+
type: "uint256"
|
|
76687
|
+
},
|
|
76688
|
+
{
|
|
76689
|
+
internalType: "address",
|
|
76690
|
+
name: "_depositor",
|
|
76691
|
+
type: "address"
|
|
76692
|
+
},
|
|
76693
|
+
{
|
|
76694
|
+
internalType: "bytes",
|
|
76695
|
+
name: "_tierProofSignature",
|
|
76696
|
+
type: "bytes"
|
|
76697
|
+
}
|
|
76698
|
+
],
|
|
76699
|
+
name: "deposit",
|
|
76700
|
+
outputs: [
|
|
76701
|
+
{
|
|
76702
|
+
internalType: "uint256",
|
|
76703
|
+
name: "",
|
|
76704
|
+
type: "uint256"
|
|
76705
|
+
}
|
|
76706
|
+
],
|
|
76707
|
+
stateMutability: "nonpayable",
|
|
76708
|
+
type: "function"
|
|
76709
|
+
}
|
|
76710
|
+
];
|
|
76711
|
+
|
|
76712
|
+
// returns the checksummed address if the address is valid, otherwise returns false
|
|
76713
|
+
function isAddress(value) {
|
|
76714
|
+
try {
|
|
76715
|
+
// Alphabetical letters must be made lowercase for getAddress to work.
|
|
76716
|
+
// See documentation here: https://docs.ethers.io/v5/api/utils/address/
|
|
76717
|
+
return getAddress(value.toLowerCase());
|
|
76718
|
+
}
|
|
76719
|
+
catch (_a) {
|
|
76720
|
+
return false;
|
|
76721
|
+
}
|
|
76722
|
+
}
|
|
76723
|
+
|
|
76724
|
+
const getNativeTicker = (chain) => {
|
|
76725
|
+
var _a;
|
|
76726
|
+
if (!chain)
|
|
76727
|
+
return undefined;
|
|
76728
|
+
return (_a = WNATIVE[chain]) === null || _a === void 0 ? void 0 : _a.symbol.substring(1);
|
|
76729
|
+
};
|
|
76730
|
+
const getTokenSymbol = (token) => {
|
|
76731
|
+
const nativeSymbols = ['BNB', 'ETH', 'POL', 'IOTA'];
|
|
76732
|
+
return nativeSymbols.includes(token === null || token === void 0 ? void 0 : token.symbol) ? `w${token === null || token === void 0 ? void 0 : token.symbol}` : token === null || token === void 0 ? void 0 : token.symbol;
|
|
76733
|
+
};
|
|
76734
|
+
const getSymbol = (token, chainId) => {
|
|
76735
|
+
if (!token)
|
|
76736
|
+
return '';
|
|
76737
|
+
return token === 'NATIVE' ? getNativeTicker(chainId) : getTokenSymbol(token);
|
|
76738
|
+
};
|
|
76739
|
+
|
|
76740
|
+
const TokenRow = ({ token, chainId, handleTokenSelect, tokenBalance, }) => {
|
|
76741
|
+
var _a, _b;
|
|
76742
|
+
const symbol = getSymbol(token, chainId);
|
|
76743
|
+
const tokenAddress = token === 'NATIVE' ? 'NATIVE' : token.address[chainId];
|
|
76744
|
+
const { address } = useAccount();
|
|
76745
|
+
const splited = typeof token !== 'string' ? (_a = token === null || token === void 0 ? void 0 : token.symbol) === null || _a === void 0 ? void 0 : _a.split('-') : undefined;
|
|
76746
|
+
return (jsxs(Flex, { sx: { p: '8px', justifyContent: 'space-between', cursor: 'pointer', '&:hover': { background: 'white4' } }, onClick: () => handleTokenSelect(tokenAddress !== null && tokenAddress !== void 0 ? tokenAddress : ''), children: [jsxs(Flex, { children: [lodashExports.isArray(splited) ? (jsx$2(TokenImage, { symbol: splited[0], symbol2: splited[1], size: 28, chain: chainId })) : (jsx$2(TokenImage, { symbol: getSymbol(token, chainId), size: 28, chain: chainId })), jsx$2(Flex, { sx: { mx: '8px', lineHeight: '28px', fontSize: '14px' }, children: symbol })] }), address && (jsx$2(Flex, { sx: { fontSize: '14px' }, children: tokenBalance === '0' ? ('0') : !tokenBalance ? (jsx$2(Spinner, { size: 15 })) : (jsx$2(Fragment$1, { children: (_b = new BigNumber$1(tokenBalance !== null && tokenBalance !== void 0 ? tokenBalance : '0')) === null || _b === void 0 ? void 0 : _b.toPrecision(5) })) }))] }));
|
|
76747
|
+
};
|
|
76748
|
+
|
|
76608
76749
|
function useUserTokensBalance(tokens, chainId) {
|
|
76609
76750
|
const keys = tokens.map((token) => (token === 'NATIVE' ? 'NATIVE' : token.address[chainId]));
|
|
76610
76751
|
const { address: account } = useAccount();
|
|
@@ -79355,7 +79496,7 @@ const BondCards = ({ bond }) => {
|
|
|
79355
79496
|
borderBottomRightRadius: 'normal',
|
|
79356
79497
|
borderBottomLeftRadius: 'normal',
|
|
79357
79498
|
},
|
|
79358
|
-
}, children: [jsxs("div", { className: "bond-card-title", children: ["Initial Release", jsx$2(TooltipBubble, { className: "tooltip-bubble", body: jsxs(Flex, { children: ["This is the percentage of tokens you can claim immediately on ", bond.tgeString, ". The rest follows the vesting schedule."] }), width: "230px", placement: "bottomLeft", transformTip: "translate(-5%, -5%)", children: jsx$2("div", { className: "bond-card-tooltip", children: jsx$2(Svg, { icon: "questionCircle", width: "12px" }) }) })] }), "
|
|
79499
|
+
}, children: [jsxs("div", { className: "bond-card-title", children: ["Initial Release", jsx$2(TooltipBubble, { className: "tooltip-bubble", body: jsxs(Flex, { children: ["This is the percentage of tokens you can claim immediately on ", bond.tgeString, ". The rest follows the vesting schedule."] }), width: "230px", placement: "bottomLeft", transformTip: "translate(-5%, -5%)", children: jsx$2("div", { className: "bond-card-tooltip", children: jsx$2(Svg, { icon: "questionCircle", width: "12px" }) }) })] }), bond.initialRelease * 100, "%"] }), jsxs("div", { className: "bond-card-block", sx: {
|
|
79359
79500
|
borderRadius: ['0px', '0px', '0px', 'normal'],
|
|
79360
79501
|
'&:first-of-type': {
|
|
79361
79502
|
borderTopRightRadius: 'normal',
|
|
@@ -79369,12 +79510,10 @@ const BondCards = ({ bond }) => {
|
|
|
79369
79510
|
};
|
|
79370
79511
|
|
|
79371
79512
|
const BuyComponent = ({ bondAddress, bondChain, onDismiss, }) => {
|
|
79372
|
-
var _a, _b, _c, _d
|
|
79513
|
+
var _a, _b, _c, _d;
|
|
79373
79514
|
const { data: preTGEBonds } = usePreTGEBondsData();
|
|
79374
79515
|
const bond = preTGEBonds === null || preTGEBonds === void 0 ? void 0 : preTGEBonds.find((bond) => bond.contractAddress.toLowerCase() === bondAddress.toLowerCase() && bond.chainId === bondChain);
|
|
79375
79516
|
// Hooks
|
|
79376
|
-
const { data: userEscrowWeight } = useTierPoints();
|
|
79377
|
-
const userTier = getUserTier(userEscrowWeight);
|
|
79378
79517
|
const { address } = useAccount();
|
|
79379
79518
|
const { data: principalTokenBalance } = useCurrencyBalance(bond.token, address, bond.chainId);
|
|
79380
79519
|
// Local state
|
|
@@ -79388,19 +79527,13 @@ const BuyComponent = ({ bondAddress, bondChain, onDismiss, }) => {
|
|
|
79388
79527
|
const youGet = parseFloat(inputValue) / (bond === null || bond === void 0 ? void 0 : bond.initPrice);
|
|
79389
79528
|
const youGetUSD = youGet * (bond === null || bond === void 0 ? void 0 : bond.tgePrice);
|
|
79390
79529
|
const bonusUSD = youGetUSD - inputValueToDisplayUSD;
|
|
79391
|
-
const airdropBonus = (_c = bond === null || bond === void 0 ? void 0 : bond.tiersAirdrop) === null || _c === void 0 ? void 0 : _c[userTier !== null && userTier !== void 0 ? userTier : 'noTier'];
|
|
79392
|
-
(parseFloat(inputValue) * airdropBonus) / (bond === null || bond === void 0 ? void 0 : bond.initPrice);
|
|
79393
|
-
`${bond === null || bond === void 0 ? void 0 : bond.totalAllocation}`;
|
|
79394
|
-
new Date().getTime();
|
|
79395
|
-
((_d = bond === null || bond === void 0 ? void 0 : bond.initTime) !== null && _d !== void 0 ? _d : 0) * 1000;
|
|
79396
|
-
((_e = bond === null || bond === void 0 ? void 0 : bond.finishTime) !== null && _e !== void 0 ? _e : 0) * 1000;
|
|
79397
79530
|
const handleClose = () => {
|
|
79398
79531
|
if (typeof window !== 'undefined') {
|
|
79399
79532
|
window.history.pushState({}, '', `/bonds`);
|
|
79400
79533
|
}
|
|
79401
79534
|
onDismiss === null || onDismiss === void 0 ? void 0 : onDismiss();
|
|
79402
79535
|
};
|
|
79403
|
-
return (jsxs(Modal, { onDismiss: handleClose, sx: { width: '740px' }, children: [jsx$2(ModalHeader, { onDismiss: handleClose, hideDivider: true }), jsx$2(Flex, { sx: styles$8.buyContainer, children: jsxs(Flex, { sx: styles$8.cardContainer, children: [jsx$2(Flex, { sx: { width: '100%', justifyContent: 'space-between' }, children: jsxs(Flex, { children: [jsxs(Flex, { children: [jsx$2(Flex, { className: "title-container bondicon", children: jsx$2(TokenImage, { symbol: bond.earnToken.symbol, size: 50, chain: bond.chainId }) }), jsxs(Flex, { className: "title-container bondname", children: [bond.earnToken.symbol, jsx$2(ListTag, { text: (
|
|
79536
|
+
return (jsxs(Modal, { onDismiss: handleClose, sx: { width: '740px' }, children: [jsx$2(ModalHeader, { onDismiss: handleClose, hideDivider: true }), jsx$2(Flex, { sx: styles$8.buyContainer, children: jsxs(Flex, { sx: styles$8.cardContainer, children: [jsx$2(Flex, { sx: { width: '100%', justifyContent: 'space-between' }, children: jsxs(Flex, { children: [jsxs(Flex, { children: [jsx$2(Flex, { className: "title-container bondicon", children: jsx$2(TokenImage, { symbol: bond.earnToken.symbol, size: 50, chain: bond.chainId }) }), jsxs(Flex, { className: "title-container bondname", children: [bond.earnToken.symbol, jsx$2(ListTag, { text: (_c = bond === null || bond === void 0 ? void 0 : bond.tags) === null || _c === void 0 ? void 0 : _c[0] })] })] }), jsxs(Flex, { sx: { flexDirection: 'column', ml: '15px' }, children: [jsxs(Flex, { className: "price-container price", children: ["$", bond.tgePrice] }), jsxs(Flex, { sx: { fontSize: '24px', fontWeight: 700 }, children: ["$", bond.initPrice] })] })] }) }), jsx$2(ProjectDescription, { description: bond.shortDescription, isProjectView: true }), jsx$2(BondCards, { bond: bond }), jsxs(Flex, { sx: Object.assign(Object.assign({}, styles$8.infoRowsContainer), { mt: '10px' }), children: [jsxs(Flex, { sx: styles$8.infoRow, children: [jsx$2(Text, { sx: styles$8.infoTitle, children: "You Spend:" }), jsxs(Text, { sx: styles$8.infoData, children: [isNaN(parseFloat(inputValueToDisplay)) ? 0 : inputValueToDisplay, " ", bond === null || bond === void 0 ? void 0 : bond.token.symbol, " = $", isNaN(inputValueToDisplayUSD) ? '0' : inputValueToDisplayUSD.toFixed(2)] })] }), jsxs(Flex, { sx: styles$8.infoRow, children: [jsxs(Flex, { sx: Object.assign(Object.assign({}, styles$8.infoTitle), { alignItems: 'center' }), children: ["Bonus:", jsx$2(TooltipBubble, { className: "tooltip-bubble", body: jsx$2(Flex, { children: TooltipText.Premium }), 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" }) }) })] }), jsxs(Text, { sx: Object.assign(Object.assign({}, styles$8.infoData), { color: 'success' }), children: ["$", isNaN(bonusUSD) ? '0' : bonusUSD.toFixed(2)] })] }), jsxs(Flex, { sx: styles$8.infoRow, children: [jsx$2(Text, { sx: styles$8.infoTitle, children: "You Get:" }), jsxs(Text, { sx: styles$8.infoData, children: [isNaN(youGet) ? 0 : formatNumberSI(youGet, 0), " ", bond === null || bond === void 0 ? void 0 : bond.earnToken.symbol, " = $", isNaN(youGetUSD) ? '0' : youGetUSD.toFixed(2)] })] })] }), jsx$2(TokenSelectorPanel, { typedValue: inputValue, setTypedValue: setInputValue, selectedToken: bond === null || bond === void 0 ? void 0 : bond.token, handleValueBtn: () => { var _a; return setInputValue((_a = new BigNumber$1(principalTokenBalance !== null && principalTokenBalance !== void 0 ? principalTokenBalance : '0')) === null || _a === void 0 ? void 0 : _a.toString()); }, handleCurrencySelect: () => null, chainId: bond === null || bond === void 0 ? void 0 : bond.chainId, enableZap: false, bondPrincipalToken: bond === null || bond === void 0 ? void 0 : bond.token, tokenBalance: principalTokenBalance, selectedTokenPrice: bond.principalTokenPrice, inputDisabled: false }), jsxs(Flex, { sx: {
|
|
79404
79537
|
width: '100%',
|
|
79405
79538
|
background: '#DE62F366',
|
|
79406
79539
|
justifyContent: 'center',
|
|
@@ -79418,7 +79551,7 @@ const BuyComponent = ({ bondAddress, bondChain, onDismiss, }) => {
|
|
|
79418
79551
|
}, children: [jsx$2(Flex, { sx: { width: ['100%', '100%', '100%', '45%'], justifyContent: 'center' }, children: jsxs(Button, { variant: "secondary", onClick: () => {
|
|
79419
79552
|
var _a;
|
|
79420
79553
|
return window.open(`/swap?outputCurrency=${(_a = bond === null || bond === void 0 ? void 0 : bond.token) === null || _a === void 0 ? void 0 : _a.address[bond === null || bond === void 0 ? void 0 : bond.chainId]}&outputChain=${bond === null || bond === void 0 ? void 0 : bond.chainId}`, '_blank');
|
|
79421
|
-
}, fullWidth: true, children: ["Get ", (
|
|
79554
|
+
}, fullWidth: true, children: ["Get ", (_d = bond === null || bond === void 0 ? void 0 : bond.token) === null || _d === void 0 ? void 0 : _d.symbol] }) }), (bond === null || bond === void 0 ? void 0 : bond.contractAddress) ? (jsx$2(BuyAction, { launchBond: bond, inputValue: inputValue, selectedCurrency: bond === null || bond === void 0 ? void 0 : bond.token, soldout: (bond === null || bond === void 0 ? void 0 : bond.billType) === 'fcfs' && percentageSold === 100 })) : (jsx$2(Button, { disabled: true, fullWidth: true, sx: { ml: ['0', '0', '0', '10px'] }, children: `Sale hasn't started` }))] })] }) })] }));
|
|
79422
79555
|
};
|
|
79423
79556
|
|
|
79424
79557
|
/*
|
|
@@ -79828,10 +79961,14 @@ const BondsMenu = ({ searchQuery, setSearchQuery, setChainFilterOption, chainFil
|
|
|
79828
79961
|
}, placeholder: 'Search...' }), jsx$2(FavIcon, { filterOption: filterOption, setFilterOption: setFilterOption })] }) }), jsxs("div", { className: "headers-container", children: [jsxs("div", { className: "discount-header", onClick: () => onSort('bonus'), children: ["BONUS", jsx$2(Flex$1, { sx: { ml: '5px', mb: '3px' }, children: jsx$2(Svg, { icon: "sort", width: 10, color: "textDisabledButton" }) })] }), jsxs("div", { className: "terms-header", onClick: () => onSort('terms'), children: ["TERMS", jsx$2(Flex$1, { sx: { ml: '5px', mb: '3px' }, children: jsx$2(Svg, { icon: "sort", width: "12px", color: "textDisabledButton" }) })] }), jsxs("div", { className: "tokens-remaining-header", onClick: () => onSort('tokensRemaining'), children: ["TOKENS REMAINING", jsx$2(Flex$1, { sx: { ml: '5px', mb: '3px' }, children: jsx$2(Svg, { icon: "sort", width: "12px", color: "textDisabledButton" }) })] }), jsx$2("div", { className: "tooltip-header" })] })] })] }));
|
|
79829
79962
|
};
|
|
79830
79963
|
|
|
79831
|
-
const PreTGERows = () => {
|
|
79964
|
+
const PreTGERows = ({ showSoldout }) => {
|
|
79832
79965
|
usePreTGEUserBonds();
|
|
79833
79966
|
const { data: preTGEBondsData } = usePreTGEBondsData();
|
|
79834
|
-
|
|
79967
|
+
const activePreTGEBonds = preTGEBondsData === null || preTGEBondsData === void 0 ? void 0 : preTGEBondsData.filter((bond) => {
|
|
79968
|
+
const isActive = !bond.finalized && bond.finishTime > Date.now() / 1000 && !bond.soldOut;
|
|
79969
|
+
return showSoldout ? !isActive : isActive;
|
|
79970
|
+
});
|
|
79971
|
+
return (jsxs(Flex, { sx: { width: '100%', flexDirection: 'column' }, children: [(activePreTGEBonds === null || activePreTGEBonds === void 0 ? void 0 : activePreTGEBonds.length) > 0 && (jsx$2(Flex, { sx: {
|
|
79835
79972
|
pt: '5px',
|
|
79836
79973
|
pb: '10px',
|
|
79837
79974
|
color: 'textDisabledButton',
|
|
@@ -79842,7 +79979,7 @@ const PreTGERows = () => {
|
|
|
79842
79979
|
display: 'flex',
|
|
79843
79980
|
width: '300px',
|
|
79844
79981
|
alignItems: 'center',
|
|
79845
|
-
}, children: "Pre-TGE Bonds" })),
|
|
79982
|
+
}, children: "Pre-TGE Bonds" })), activePreTGEBonds === null || activePreTGEBonds === void 0 ? void 0 : activePreTGEBonds.map((bond, i) => {
|
|
79846
79983
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
79847
79984
|
const totalPrincipalBilled = Math.round(getBalanceNumber(new BigNumber$1((_a = bond === null || bond === void 0 ? void 0 : bond.totalPrincipalBilled) !== null && _a !== void 0 ? _a : '0'), (_c = (_b = bond === null || bond === void 0 ? void 0 : bond.token) === null || _b === void 0 ? void 0 : _b.decimals) === null || _c === void 0 ? void 0 : _c[bond === null || bond === void 0 ? void 0 : bond.chainId])) / bond.initPrice;
|
|
79848
79985
|
const raiseGoal = Math.round(getBalanceNumber(new BigNumber$1((_d = bond === null || bond === void 0 ? void 0 : bond.totalRaise) !== null && _d !== void 0 ? _d : '0'), (_f = (_e = bond === null || bond === void 0 ? void 0 : bond.token) === null || _e === void 0 ? void 0 : _e.decimals) === null || _f === void 0 ? void 0 : _f[bond === null || bond === void 0 ? void 0 : bond.chainId])) / bond.initPrice;
|
|
@@ -80019,7 +80156,7 @@ const Bonds = () => {
|
|
|
80019
80156
|
const handleChangeFilterOption = useCallback((newOption) => {
|
|
80020
80157
|
setFilterOption(newOption);
|
|
80021
80158
|
}, []);
|
|
80022
|
-
return (jsxs(Flex$1, { className: "bonds-container", children: [jsx$2(CheckUrl, {}), jsx$2(BondsMenu, { searchQuery: searchQuery, setSearchQuery: setSearchQuery, setChainFilterOption: setChainFilterOption, chainFilterOption: chainFilterOption !== null && chainFilterOption !== void 0 ? chainFilterOption : ['All Chains'], filterOptions: filterOptions, filterOption: filterOption, setFilterOption: handleChangeFilterOption, onSort: handleSortOptions }), SDKConfig.useHotBonds && jsx$2(BuyAgainRow, {}), SDKConfig.useTGEBonds && jsx$2(PreTGERows, {}), (billsToRender === null || billsToRender === void 0 ? void 0 : billsToRender.length) > 0 ? (jsx$2(BondRowsByChain, { bonds: billsToRender, hideTitles: searchQuery !== '' })) : searchQuery ? (jsx$2(PlaceholderMonkey, { text: 'No results' })) : filterOption === 'FAVORITES' ? (jsxs(Flex$1, { sx: {
|
|
80159
|
+
return (jsxs(Flex$1, { className: "bonds-container", children: [jsx$2(CheckUrl, {}), jsx$2(BondsMenu, { searchQuery: searchQuery, setSearchQuery: setSearchQuery, setChainFilterOption: setChainFilterOption, chainFilterOption: chainFilterOption !== null && chainFilterOption !== void 0 ? chainFilterOption : ['All Chains'], filterOptions: filterOptions, filterOption: filterOption, setFilterOption: handleChangeFilterOption, onSort: handleSortOptions }), SDKConfig.useHotBonds && jsx$2(BuyAgainRow, {}), SDKConfig.useTGEBonds && jsx$2(PreTGERows, { showSoldout: filterOption === 'SOLD OUT' }), (billsToRender === null || billsToRender === void 0 ? void 0 : billsToRender.length) > 0 ? (jsx$2(BondRowsByChain, { bonds: billsToRender, hideTitles: searchQuery !== '' })) : searchQuery ? (jsx$2(PlaceholderMonkey, { text: 'No results' })) : filterOption === 'FAVORITES' ? (jsxs(Flex$1, { sx: {
|
|
80023
80160
|
width: '100%',
|
|
80024
80161
|
height: '300px',
|
|
80025
80162
|
background: 'white2',
|
|
@@ -14,6 +14,11 @@ export interface PreTGEBondData extends PreTGEBond {
|
|
|
14
14
|
minPoints?: string;
|
|
15
15
|
maxPoints?: string;
|
|
16
16
|
vestingTerm: string;
|
|
17
|
+
initTime: number;
|
|
18
|
+
finishTime: number;
|
|
19
|
+
startVestingTimestamp: number;
|
|
20
|
+
initPrice: number;
|
|
21
|
+
initialRelease: number;
|
|
17
22
|
}
|
|
18
23
|
export default function usePreTGEBondsData(): UseQueryResult<PreTGEBondData[]>;
|
|
19
24
|
export declare const getLaunchBondsPublicData: (preTGEBonds: PreTGEBond[], chains?: number[], apiUrl?: string) => Promise<PreTGEBondData[]>;
|
|
@@ -28,6 +28,11 @@ export interface PreTGEUserBonds extends PreTGEBond {
|
|
|
28
28
|
minPoints?: string;
|
|
29
29
|
maxPoints?: string;
|
|
30
30
|
vestingTerm: string;
|
|
31
|
+
initTime: number;
|
|
32
|
+
finishTime: number;
|
|
33
|
+
startVestingTimestamp: number;
|
|
34
|
+
initPrice: number;
|
|
35
|
+
initialRelease: number;
|
|
31
36
|
}
|
|
32
37
|
export default function usePreTGEUserBonds(): UseQueryResult<PreTGEUserBonds[]>;
|
|
33
38
|
export declare const fetchPreTGEUserBonds: (preTGEBonds: PreTGEBondData[], account: string, apiUrl: string) => Promise<PreTGEUserBonds[]>;
|
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": "3.0.
|
|
6
|
+
"version": "3.0.68",
|
|
7
7
|
"module": "dist/main.js",
|
|
8
8
|
"type": "module",
|
|
9
9
|
"types": "dist/main.d.ts",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"yalc": "^1.0.0-pre.53"
|
|
58
58
|
},
|
|
59
59
|
"dependencies": {
|
|
60
|
-
"@ape.swap/apeswap-lists": "4.3.
|
|
60
|
+
"@ape.swap/apeswap-lists": "4.3.16",
|
|
61
61
|
"@emotion/react": "11.11.4",
|
|
62
62
|
"bignumber.js": "^9.1.2",
|
|
63
63
|
"chart.js": "4.2.0",
|