@ape.swap/bonds-sdk 3.0.76 → 3.0.78
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
|
@@ -18883,7 +18883,6 @@ const TokenImage = ({ symbol, symbol2, size, chain, }) => {
|
|
|
18883
18883
|
|
|
18884
18884
|
const QUERY_KEYS = {
|
|
18885
18885
|
TIERS: 'tiers',
|
|
18886
|
-
AB_TEST_VALUE: 'ABTestValue',
|
|
18887
18886
|
// used values on SDK
|
|
18888
18887
|
BOND_API_STATS: 'ApeBond-SDK-bondApiStats',
|
|
18889
18888
|
SDK_CONFIG: 'ApeBond-SDK-sdkConfig',
|
|
@@ -58486,8 +58485,7 @@ function useTierPoints() {
|
|
|
58486
58485
|
return useQuery({
|
|
58487
58486
|
queryKey: [QUERY_KEYS.TIERS, account],
|
|
58488
58487
|
queryFn: () => fetchUserPoints(account, SDKConfig.useTiers, apiUrl),
|
|
58489
|
-
|
|
58490
|
-
refetchInterval: 30000, // i.e. 30 secs
|
|
58488
|
+
refetchInterval: 120000, // i.e. 2 mins
|
|
58491
58489
|
refetchOnWindowFocus: false,
|
|
58492
58490
|
});
|
|
58493
58491
|
}
|
|
@@ -61077,6 +61075,8 @@ const UserBillTooltipText = {
|
|
|
61077
61075
|
FullyVested: 'This is the time remaining until all tokens from the bond are available to claim.',
|
|
61078
61076
|
Pending: 'This is the amount of unvested tokens that cannot be claimed yet.',
|
|
61079
61077
|
Claimable: 'This is the amount of tokens that have vested and are available to claim.',
|
|
61078
|
+
YouSpent: 'This is the dollar amount you spent on the bond at the time of purchase.',
|
|
61079
|
+
Claimed: 'This is the amount of tokens that you have already claimed.',
|
|
61080
61080
|
};
|
|
61081
61081
|
|
|
61082
61082
|
// export const getBillNftData = async (billNftId: string, billNftAddress: string, chainId: number) => {
|
|
@@ -70058,13 +70058,198 @@ const SafeHTMLComponent = ({ html }) => {
|
|
|
70058
70058
|
return jsx$2("div", { dangerouslySetInnerHTML: { __html: sanitizedHTML } });
|
|
70059
70059
|
};
|
|
70060
70060
|
|
|
70061
|
-
|
|
70062
|
-
|
|
70061
|
+
function useBondsList() {
|
|
70062
|
+
const realTime = useURLByEnvironment('realTimeApi');
|
|
70063
|
+
const apiUrl = useURLByEnvironment('apiV2');
|
|
70064
|
+
return useQuery({
|
|
70065
|
+
queryKey: [QUERY_KEYS.BONDS_LIST],
|
|
70066
|
+
queryFn: () => getBondsList(realTime, apiUrl),
|
|
70067
|
+
staleTime: Infinity,
|
|
70068
|
+
refetchOnWindowFocus: false,
|
|
70069
|
+
});
|
|
70070
|
+
}
|
|
70071
|
+
const getBondsList = (realTimeapiURL, apiUrl) => __awaiter$9(void 0, void 0, void 0, function* () {
|
|
70072
|
+
try {
|
|
70073
|
+
const response = yield axios.get(`${realTimeapiURL}/utils/bonds`);
|
|
70074
|
+
return response.data;
|
|
70075
|
+
}
|
|
70076
|
+
catch (e) {
|
|
70077
|
+
reportError({
|
|
70078
|
+
apiUrl,
|
|
70079
|
+
error: e,
|
|
70080
|
+
extraInfo: { type: 'getBondsList', e },
|
|
70081
|
+
});
|
|
70082
|
+
return [];
|
|
70083
|
+
}
|
|
70084
|
+
});
|
|
70085
|
+
|
|
70086
|
+
/* MODIFIED FUNCTION FROM FRONTEND SPECIFICALLY FOR THE SDK */
|
|
70087
|
+
const fetchUserOwnedBillsDataAsync = (chainId, account, bondData, tokenPrices) => __awaiter$9(void 0, void 0, void 0, function* () {
|
|
70088
|
+
try {
|
|
70089
|
+
const bonds = bondData;
|
|
70090
|
+
// Fetch and set user owned bill data without NFT Data
|
|
70091
|
+
const userOwnedBills = yield fetchUserOwnedBills(chainId, account, bonds, tokenPrices);
|
|
70092
|
+
const mapUserOwnedBills = bonds.map((bill) => userOwnedBills.filter((b) => { var _a; return b.address.toLowerCase() === ((_a = bill.contractAddress[bill.chainId]) === null || _a === void 0 ? void 0 : _a.toLowerCase()); }));
|
|
70093
|
+
const userOwnedBillsData = bonds.map((bill, i) => ({
|
|
70094
|
+
index: bill.index,
|
|
70095
|
+
userOwnedBills: mapUserOwnedBills[i],
|
|
70096
|
+
}));
|
|
70097
|
+
const combinedData = userOwnedBillsData.map((data) => {
|
|
70098
|
+
const enrichedUserBills = data.userOwnedBills.map((bill) => {
|
|
70099
|
+
return Object.assign({}, bill);
|
|
70100
|
+
});
|
|
70101
|
+
return Object.assign(Object.assign({}, data), { userOwnedBills: enrichedUserBills });
|
|
70102
|
+
});
|
|
70103
|
+
return Promise.resolve(combinedData);
|
|
70104
|
+
}
|
|
70105
|
+
catch (error) {
|
|
70106
|
+
console.error('Error fetching user owned bills data:', error);
|
|
70107
|
+
return Promise.reject(error);
|
|
70108
|
+
}
|
|
70109
|
+
});
|
|
70110
|
+
/* MODIFIED FUNCTION FROM FRONTEND SPECIFICALLY FOR THE SDK */
|
|
70111
|
+
const fetchUserOwnedBills = (chainId, account, bonds, tokenPrices) => __awaiter$9(void 0, void 0, void 0, function* () {
|
|
70112
|
+
var _a, _b, _c, _d, _e, _f;
|
|
70113
|
+
// Maps all the bills in the list repo to make a call to each of them to get Bills Id, meaning purchased bill ids
|
|
70114
|
+
const billIdCalls = bonds.map((b) => {
|
|
70115
|
+
var _a;
|
|
70116
|
+
return ({
|
|
70117
|
+
address: (_a = b.contractAddress[b.chainId]) !== null && _a !== void 0 ? _a : '',
|
|
70118
|
+
name: 'getBillIds',
|
|
70119
|
+
params: [account],
|
|
70120
|
+
});
|
|
70121
|
+
});
|
|
70122
|
+
const billIds = yield multicall(chainId, BOND_ABI, billIdCalls, true, 15);
|
|
70123
|
+
const billDataCalls = [];
|
|
70124
|
+
const billVersions = [];
|
|
70125
|
+
billIds.forEach((idArray, index) => idArray[0].forEach((id) => id.gt(0) &&
|
|
70126
|
+
(billDataCalls.push({
|
|
70127
|
+
address: bonds[index].contractAddress[bonds[index].chainId],
|
|
70128
|
+
name: bonds[index].billVersion !== types.BillVersion.V1 ? 'getBillInfo' : 'billInfo',
|
|
70129
|
+
params: [id],
|
|
70130
|
+
bond: bonds[index],
|
|
70131
|
+
}),
|
|
70132
|
+
billDataCalls.push({
|
|
70133
|
+
address: bonds[index].contractAddress[bonds[index].chainId],
|
|
70134
|
+
name: bonds[index].billVersion !== types.BillVersion.V1 ? 'claimablePayout' : 'pendingPayoutFor',
|
|
70135
|
+
params: [id],
|
|
70136
|
+
bond: bonds[index],
|
|
70137
|
+
}),
|
|
70138
|
+
billVersions.push(bonds[index].billVersion))));
|
|
70139
|
+
const billData = yield multicall(chainId, BOND_ABI, billDataCalls, true, 150);
|
|
70140
|
+
const result = [];
|
|
70141
|
+
for (let i = 0; i < billVersions.length; i++) {
|
|
70142
|
+
const billPos = i === 0 ? 0 : i * 2;
|
|
70143
|
+
let bond = billDataCalls[billPos].bond;
|
|
70144
|
+
// const principalTokenPrice = tokenPrices.find(
|
|
70145
|
+
// (tokenPrice) =>
|
|
70146
|
+
// tokenPrice.address?.toLowerCase() === bond?.lpToken?.address?.[bond.chainId]?.toLowerCase() &&
|
|
70147
|
+
// tokenPrice.chainId === bond.chainId,
|
|
70148
|
+
// )?.price
|
|
70149
|
+
const payoutTokenPrice = (_a = tokenPrices.find((tokenPrice) => {
|
|
70150
|
+
var _a, _b, _c, _d;
|
|
70151
|
+
return ((_a = tokenPrice.address) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === ((_d = (_c = (_b = bond === null || bond === void 0 ? void 0 : bond.earnToken) === null || _b === void 0 ? void 0 : _b.address) === null || _c === void 0 ? void 0 : _c[bond.chainId]) === null || _d === void 0 ? void 0 : _d.toLowerCase()) &&
|
|
70152
|
+
tokenPrice.chainId === bond.chainId;
|
|
70153
|
+
})) === null || _a === void 0 ? void 0 : _a.price;
|
|
70154
|
+
bond = Object.assign(Object.assign({}, bond), { payoutTokenPrice: payoutTokenPrice });
|
|
70155
|
+
const data = billVersions[i] !== types.BillVersion.V1
|
|
70156
|
+
? {
|
|
70157
|
+
address: billDataCalls[billPos].address,
|
|
70158
|
+
id: billDataCalls[billPos].params[0].toString(),
|
|
70159
|
+
payout: new BigNumber$1((_b = billData[billPos][0]) === null || _b === void 0 ? void 0 : _b.payout.toString())
|
|
70160
|
+
.minus((_c = billData[billPos][0]) === null || _c === void 0 ? void 0 : _c.payoutClaimed.toString())
|
|
70161
|
+
.toString(),
|
|
70162
|
+
billNftAddress: bond.billNnftAddress[bond.chainId],
|
|
70163
|
+
vesting: (_d = billData[billPos][0]) === null || _d === void 0 ? void 0 : _d.vesting.toString(),
|
|
70164
|
+
lastBlockTimestamp: (_e = billData[billPos][0]) === null || _e === void 0 ? void 0 : _e.lastClaimTimestamp.toString(),
|
|
70165
|
+
truePricePaid: (_f = billData[billPos][0]) === null || _f === void 0 ? void 0 : _f.truePricePaid.toString(),
|
|
70166
|
+
pendingRewards: billData[billPos + 1][0].toString(),
|
|
70167
|
+
bond,
|
|
70168
|
+
}
|
|
70169
|
+
: {
|
|
70170
|
+
address: billDataCalls[billPos].address,
|
|
70171
|
+
id: billDataCalls[billPos].params[0].toString(),
|
|
70172
|
+
payout: billData[billPos][0].toString(),
|
|
70173
|
+
billNftAddress: bond.billNnftAddress[bond.chainId],
|
|
70174
|
+
vesting: billData[billPos][1].toString(),
|
|
70175
|
+
lastBlockTimestamp: billData[billPos][2].toString(),
|
|
70176
|
+
truePricePaid: billData[billPos][3].toString(),
|
|
70177
|
+
pendingRewards: billData[billPos + 1][0].toString(),
|
|
70178
|
+
bond,
|
|
70179
|
+
};
|
|
70180
|
+
result.push(data);
|
|
70181
|
+
}
|
|
70182
|
+
return result;
|
|
70183
|
+
});
|
|
70184
|
+
|
|
70185
|
+
function useUserBonds() {
|
|
70186
|
+
var _a;
|
|
70187
|
+
// First fetch the full list of bonds
|
|
70188
|
+
const { data: bondList } = useBondsList();
|
|
70189
|
+
const { address } = useAccount();
|
|
70190
|
+
const SDKConfig = useSDKConfig();
|
|
70191
|
+
const { data: tokenPrices } = useTokenPrices();
|
|
70192
|
+
const chains = SDKConfig === null || SDKConfig === void 0 ? void 0 : SDKConfig.chains;
|
|
70193
|
+
const apiUrl = (_a = SDKConfig === null || SDKConfig === void 0 ? void 0 : SDKConfig.urls) === null || _a === void 0 ? void 0 : _a.apiV2;
|
|
70194
|
+
// Once the full list is fetched, fetch user's purchased bonds
|
|
70195
|
+
return useQuery({
|
|
70196
|
+
queryKey: [QUERY_KEYS.USER_BONDS, address],
|
|
70197
|
+
queryFn: () => getUserBonds(address, bondList, chains, tokenPrices, apiUrl),
|
|
70198
|
+
refetchOnWindowFocus: false,
|
|
70199
|
+
refetchInterval: 60000,
|
|
70200
|
+
enabled: !!bondList && !!address && !!tokenPrices,
|
|
70201
|
+
});
|
|
70202
|
+
}
|
|
70203
|
+
const getUserBonds = (account, bondList, chains, tokenPrices, apiUrl) => __awaiter$9(void 0, void 0, void 0, function* () {
|
|
70204
|
+
try {
|
|
70205
|
+
const bondsByChain = bondList.reduce((acc, bond) => {
|
|
70206
|
+
var _a;
|
|
70207
|
+
// Exclude ACF to ABOND bonds, fixed price bonds, and migration bonds
|
|
70208
|
+
if (((_a = bond.contractAddress[bond.chainId]) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === ACF_TO_ABOND.toLowerCase() ||
|
|
70209
|
+
bond.billVersion === types.BillVersion.FixedPrice ||
|
|
70210
|
+
bond.billType === 'migration') {
|
|
70211
|
+
return acc; // Skip this bond
|
|
70212
|
+
}
|
|
70213
|
+
// Only process bonds that belong to the specified chains
|
|
70214
|
+
if (chains.includes(bond.chainId)) {
|
|
70215
|
+
// Initialize acc[bond.chainId] if it doesn't exist yet
|
|
70216
|
+
if (!acc[bond.chainId]) {
|
|
70217
|
+
acc[bond.chainId] = [];
|
|
70218
|
+
}
|
|
70219
|
+
// Safely push the bond to the array
|
|
70220
|
+
acc[bond.chainId].push(bond);
|
|
70221
|
+
}
|
|
70222
|
+
return acc;
|
|
70223
|
+
}, {});
|
|
70224
|
+
const results = yield Promise.allSettled(chains
|
|
70225
|
+
.filter((chain) => bondsByChain[chain])
|
|
70226
|
+
.map((chain) => fetchUserOwnedBillsDataAsync(chain, account, bondsByChain[chain], tokenPrices)));
|
|
70227
|
+
// Filter out only fulfilled promises
|
|
70228
|
+
const fulfilledResults = results
|
|
70229
|
+
.filter((result) => result.status === 'fulfilled')
|
|
70230
|
+
.map((result) => result.value);
|
|
70231
|
+
return fulfilledResults.flat().flatMap((result) => result.userOwnedBills);
|
|
70232
|
+
}
|
|
70233
|
+
catch (e) {
|
|
70234
|
+
reportError({
|
|
70235
|
+
apiUrl,
|
|
70236
|
+
error: e,
|
|
70237
|
+
extraInfo: { type: 'getUserBonds', bondList, chains, e },
|
|
70238
|
+
account,
|
|
70239
|
+
});
|
|
70240
|
+
return [];
|
|
70241
|
+
}
|
|
70242
|
+
});
|
|
70243
|
+
|
|
70244
|
+
const YourBondsModal = ({ onDismiss, bill }) => {
|
|
70245
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17;
|
|
70063
70246
|
// Hooks
|
|
70064
70247
|
const SDKConfig = useSDKConfig();
|
|
70065
70248
|
const chainId = useChainId();
|
|
70249
|
+
const { data: userBonds, refetch: refetchUserBonds } = useUserBonds();
|
|
70250
|
+
const userBill = useMemo(() => userBonds === null || userBonds === void 0 ? void 0 : userBonds.find((b) => b.address.toLowerCase() === (bill === null || bill === void 0 ? void 0 : bill.address.toLowerCase()) && b.id === bill.id), [userBonds, bill]);
|
|
70066
70251
|
const { switchChain } = useSwitchChain();
|
|
70067
|
-
const { data: bondNFTData } = useBondNFTData(userBill === null || userBill === void 0 ? void 0 : userBill.id, userBill === null || userBill === void 0 ? void 0 : userBill.billNftAddress, (_a = userBill === null || userBill === void 0 ? void 0 : userBill.bond) === null || _a === void 0 ? void 0 : _a.chainId);
|
|
70252
|
+
const { data: bondNFTData, refetch } = useBondNFTData(userBill === null || userBill === void 0 ? void 0 : userBill.id, userBill === null || userBill === void 0 ? void 0 : userBill.billNftAddress, (_a = userBill === null || userBill === void 0 ? void 0 : userBill.bond) === null || _a === void 0 ? void 0 : _a.chainId);
|
|
70068
70253
|
const { writeContractAsync } = useWriteContract();
|
|
70069
70254
|
const { address: account } = useAccount();
|
|
70070
70255
|
// State
|
|
@@ -70125,12 +70310,17 @@ const YourBondsModal = ({ onDismiss, userBill }) => {
|
|
|
70125
70310
|
// Functions to calculate display values for modal
|
|
70126
70311
|
const totalPending = (userBill) => {
|
|
70127
70312
|
var _a, _b, _c, _d, _e, _f;
|
|
70128
|
-
return getBalanceNumber(new BigNumber$1((_a = userBill === null || userBill === void 0 ? void 0 : userBill.payout) !== null && _a !== void 0 ? _a : 0), (_f = (_d = (_c = (_b = userBill === null || userBill === void 0 ? void 0 : userBill.bond) === null || _b === void 0 ? void 0 : _b.earnToken) === null || _c === void 0 ? void 0 : _c.decimals) === null || _d === void 0 ? void 0 : _d[(_e = userBill === null || userBill === void 0 ? void 0 : userBill.bond) === null || _e === void 0 ? void 0 : _e.chainId]) !== null && _f !== void 0 ? _f : 18);
|
|
70313
|
+
return (getBalanceNumber(new BigNumber$1((_a = userBill === null || userBill === void 0 ? void 0 : userBill.payout) !== null && _a !== void 0 ? _a : 0), (_f = (_d = (_c = (_b = userBill === null || userBill === void 0 ? void 0 : userBill.bond) === null || _b === void 0 ? void 0 : _b.earnToken) === null || _c === void 0 ? void 0 : _c.decimals) === null || _d === void 0 ? void 0 : _d[(_e = userBill === null || userBill === void 0 ? void 0 : userBill.bond) === null || _e === void 0 ? void 0 : _e.chainId]) !== null && _f !== void 0 ? _f : 18) - claimable(userBill));
|
|
70129
70314
|
};
|
|
70130
70315
|
const claimable = (userBill) => {
|
|
70131
70316
|
var _a, _b, _c, _d, _e, _f;
|
|
70132
70317
|
return getBalanceNumber(new BigNumber$1((_a = userBill === null || userBill === void 0 ? void 0 : userBill.pendingRewards) !== null && _a !== void 0 ? _a : '0'), (_f = (_d = (_c = (_b = userBill === null || userBill === void 0 ? void 0 : userBill.bond) === null || _b === void 0 ? void 0 : _b.earnToken) === null || _c === void 0 ? void 0 : _c.decimals) === null || _d === void 0 ? void 0 : _d[(_e = userBill === null || userBill === void 0 ? void 0 : userBill.bond) === null || _e === void 0 ? void 0 : _e.chainId]) !== null && _f !== void 0 ? _f : 18);
|
|
70133
70318
|
};
|
|
70319
|
+
const claimed = (userBill) => {
|
|
70320
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
70321
|
+
return (((_b = (_a = bondNFTData === null || bondNFTData === void 0 ? void 0 : bondNFTData.data) === null || _a === void 0 ? void 0 : _a.payout) !== null && _b !== void 0 ? _b : 0) -
|
|
70322
|
+
getBalanceNumber(new BigNumber$1((_c = userBill === null || userBill === void 0 ? void 0 : userBill.payout) !== null && _c !== void 0 ? _c : '0'), (_h = (_f = (_e = (_d = userBill === null || userBill === void 0 ? void 0 : userBill.bond) === null || _d === void 0 ? void 0 : _d.earnToken) === null || _e === void 0 ? void 0 : _e.decimals) === null || _f === void 0 ? void 0 : _f[(_g = userBill === null || userBill === void 0 ? void 0 : userBill.bond) === null || _g === void 0 ? void 0 : _g.chainId]) !== null && _h !== void 0 ? _h : 18));
|
|
70323
|
+
};
|
|
70134
70324
|
const earnTokenPrice = useCurrencyPrice((_e = userBill === null || userBill === void 0 ? void 0 : userBill.bond.earnToken) !== null && _e !== void 0 ? _e : null, (_g = (_f = userBill === null || userBill === void 0 ? void 0 : userBill.bond) === null || _f === void 0 ? void 0 : _f.chainId) !== null && _g !== void 0 ? _g : null);
|
|
70135
70325
|
const BILL_ATTRIBUTES = ['The Legend', 'The Location', 'The Moment', 'The Trend', 'The Innovation'];
|
|
70136
70326
|
const attributes = (_h = bondNFTData === null || bondNFTData === void 0 ? void 0 : bondNFTData.attributes) === null || _h === void 0 ? void 0 : _h.filter((attrib) => BILL_ATTRIBUTES.includes(attrib.trait_type));
|
|
@@ -70138,6 +70328,12 @@ const YourBondsModal = ({ onDismiss, userBill }) => {
|
|
|
70138
70328
|
setImgLoaded(true);
|
|
70139
70329
|
};
|
|
70140
70330
|
const [onTransferBondModal] = useModal(jsx$2(TransferBondModal, { userBill: userBill }), true, true, `transferModal${userBill === null || userBill === void 0 ? void 0 : userBill.id}}`);
|
|
70331
|
+
useEffect(() => {
|
|
70332
|
+
if (isConfirmed) {
|
|
70333
|
+
refetchUserBonds();
|
|
70334
|
+
refetch();
|
|
70335
|
+
}
|
|
70336
|
+
}, [isConfirmed]);
|
|
70141
70337
|
return (jsx$2(Modal, { className: "modal", children: jsxs(Flex$1, { className: "yourbondsmodal-content", children: [jsx$2(Flex$1, { className: "yourbondsmodal-header", children: jsx$2(Flex$1, { className: "svg-close", onClick: onDismiss, children: jsx$2(Svg, { icon: "close" }) }) }), jsxs(Flex$1, { className: "yourbondsmodal table-container", children: [jsxs(Flex$1, { className: "yourbondsmodal bondimage", children: [(bondNFTData === null || bondNFTData === void 0 ? void 0 : bondNFTData.image) && (jsx$2("img", { src: `${bondNFTData === null || bondNFTData === void 0 ? void 0 : bondNFTData.image}?img-width=720`, onLoad: handleImageLoad, style: { zIndex: 2 } })), !imgLoaded && (jsx$2(Flex$1, { sx: {
|
|
70142
70338
|
position: 'absolute',
|
|
70143
70339
|
top: 'calc(50% - 24px)',
|
|
@@ -70163,24 +70359,32 @@ const YourBondsModal = ({ onDismiss, userBill }) => {
|
|
|
70163
70359
|
? attributes.map((a) => (jsxs(Flex$1, { sx: { background: 'white4', width: '100%', padding: '2px 8px' }, children: [jsx$2(Text, { sx: { fontSize: '10px', fontWeight: 500 }, children: a === null || a === void 0 ? void 0 : a.trait_type }), jsx$2(Text, { sx: { fontSize: '10px', fontWeight: 500 }, children: a === null || a === void 0 ? void 0 : a.value })] }, a.value)))
|
|
70164
70360
|
: BILL_ATTRIBUTES.map((attrib) => {
|
|
70165
70361
|
return (jsxs(Flex$1, { sx: { background: 'white4', width: '100%', padding: '2px 8px' }, children: [jsx$2(Text, { sx: { fontSize: '10px', fontWeight: 500 }, children: attrib }), jsx$2(Skeleton, { width: "150px" })] }, attrib));
|
|
70166
|
-
}) }) })) })] }), jsxs(Flex$1, { className: "yourbondinfo-block row-vested", children: [jsxs(Flex$1, { className: "yourbondinfo-block header", children: [jsx$2(Flex$1, { className: "yourbondinfo-block header-title", children: "
|
|
70362
|
+
}) }) })) })] }), jsxs(Flex$1, { className: "yourbondinfo-block row-vested", children: [jsxs(Flex$1, { className: "yourbondinfo-block header", children: [jsx$2(Flex$1, { className: "yourbondinfo-block header-title", children: "You Spent" }), jsx$2(Flex$1, { className: "yourbondinfo-block header-tooltip", children: jsx$2(TooltipBubble, { className: "tooltip-bubble", body: jsx$2(Flex$1, { children: UserBillTooltipText.YouSpent }), width: "270px", placement: "bottomLeft", transformTip: "translate(-5%, 0%)", children: jsx$2(Flex$1, { className: "block-header icon", children: jsx$2(Svg, { icon: "questionCircle", width: "12px" }) }) }) })] }), jsxs(Flex$1, { className: "yourbondinfo-block info", children: [jsx$2(Flex$1, { className: "block-info icon", children: userBill && (jsx$2(TokenImage, { symbol: (_u = (_t = userBill === null || userBill === void 0 ? void 0 : userBill.bond) === null || _t === void 0 ? void 0 : _t.lpToken) === null || _u === void 0 ? void 0 : _u.symbol, size: 25, chain: (_v = userBill === null || userBill === void 0 ? void 0 : userBill.bond) === null || _v === void 0 ? void 0 : _v.chainId })) }), jsxs(Flex$1, { className: "block-info text", children: [jsx$2(Text, { sx: { fontSize: ['12px', '12px', '12px', '19px'], fontWeight: 700 }, children: bondNFTData ? formatNumberSI(bondNFTData.data.deposit.toFixed(4), 4) : '----' }), jsxs(Text, { sx: {
|
|
70167
70363
|
fontSize: ['10px', '10px', '10px', '12px'],
|
|
70168
70364
|
fontWeight: [500, 500, 500, 400],
|
|
70169
70365
|
paddingLeft: '10px',
|
|
70170
|
-
}, children:
|
|
70366
|
+
}, children: ["($", (_w = bondNFTData === null || bondNFTData === void 0 ? void 0 : bondNFTData.data) === null || _w === void 0 ? void 0 : _w.dollarValue.toFixed(2), ")"] })] })] })] }), jsxs(Flex$1, { className: "yourbondinfo-block row-vested", children: [jsxs(Flex$1, { className: "yourbondinfo-block header", children: [jsx$2(Flex$1, { className: "yourbondinfo-block header-title", children: "Fully Vested" }), jsx$2(Flex$1, { className: "yourbondinfo-block header-tooltip", children: jsx$2(TooltipBubble, { className: "tooltip-bubble", body: jsx$2(Flex$1, { children: UserBillTooltipText.FullyVested }), width: "230px", placement: "bottomLeft", transformTip: "translate(-5%, 0%)", children: jsx$2(Flex$1, { className: "block-header icon", children: jsx$2(Svg, { icon: "questionCircle", width: "12px" }) }) }) })] }), jsxs(Flex$1, { className: "yourbondinfo-block info", children: [jsx$2(Flex$1, { className: "block-info icon" }), jsx$2(Flex$1, { className: "block-info text", children: jsxs(Flex$1, { sx: { fontSize: ['12px', '12px', '12px', '19px'], fontWeight: 700 }, children: [vestingTimeRemainingString(userBill), isPendingCliff && (jsx$2(TooltipBubble, { className: "tooltip-bubble", body: jsxs(Flex$1, { children: ["Bond will be claimable in", ' ', `${cliffCountdown.days !== 0 ? `${cliffCountdown.days} days` : cliffCountdown.hours !== 0 ? `${cliffCountdown.hours} hours` : `${cliffCountdown.minutes} mins`}`, "."] }), width: "180px", placement: "bottomRight", transformTip: "translate(13%, 0%)", children: jsx$2(Flex$1, { sx: { opacity: 0.6, ml: '6px' }, children: jsx$2(Svg, { icon: "questionCircle", width: "12px" }) }) }))] }) })] })] }), jsxs(Flex$1, { className: "yourbondinfo-block row-pending", children: [jsxs(Flex$1, { className: "yourbondinfo-block header", children: [jsx$2(Flex$1, { className: "yourbondinfo-block header-title", children: "Pending" }), jsx$2(Flex$1, { className: "yourbondinfo-block header-tooltip", children: jsx$2(TooltipBubble, { className: "tooltip-bubble", body: jsx$2(Flex$1, { children: UserBillTooltipText.Pending }), width: "230px", placement: "bottomLeft", transformTip: "translate(-5%, 0%)", children: jsx$2(Flex$1, { className: "block-header icon", children: jsx$2(Svg, { icon: "questionCircle", width: "12px" }) }) }) })] }), jsxs(Flex$1, { className: "yourbondinfo-block info", children: [jsx$2(Flex$1, { className: "block-info icon", children: userBill && (jsx$2(TokenImage, { symbol: (_y = (_x = userBill === null || userBill === void 0 ? void 0 : userBill.bond) === null || _x === void 0 ? void 0 : _x.showcaseTokenName) !== null && _y !== void 0 ? _y : (_0 = (_z = userBill === null || userBill === void 0 ? void 0 : userBill.bond) === null || _z === void 0 ? void 0 : _z.earnToken) === null || _0 === void 0 ? void 0 : _0.symbol, size: 25, chain: (_1 = userBill === null || userBill === void 0 ? void 0 : userBill.bond) === null || _1 === void 0 ? void 0 : _1.chainId })) }), jsxs(Flex$1, { className: "block-info text", children: [jsx$2(Text, { sx: { fontSize: ['12px', '12px', '12px', '19px'], fontWeight: 700 }, children: formatNumberSI(parseFloat(totalPending(userBill).toFixed(4)), 4) }), jsx$2(Text, { sx: {
|
|
70171
70367
|
fontSize: ['10px', '10px', '10px', '12px'],
|
|
70172
70368
|
fontWeight: [500, 500, 500, 400],
|
|
70173
70369
|
paddingLeft: '10px',
|
|
70174
|
-
}, children: `($${(
|
|
70370
|
+
}, children: `($${(totalPending(userBill) * ((_2 = earnTokenPrice === null || earnTokenPrice === void 0 ? void 0 : earnTokenPrice.price) !== null && _2 !== void 0 ? _2 : 0)).toFixed(2)})` })] })] })] }), jsxs(Flex$1, { className: "yourbondinfo-block row-claimable", children: [jsxs(Flex$1, { className: "yourbondinfo-block header", children: [jsx$2(Flex$1, { className: "yourbondinfo-block header-title", children: "Claimable" }), jsx$2(Flex$1, { className: "yourbondinfo-block header-tooltip", children: jsx$2(TooltipBubble, { className: "tooltip-bubble", body: jsx$2(Flex$1, { children: UserBillTooltipText.Claimable }), width: "230px", placement: "bottomLeft", transformTip: "translate(-5%, 0%)", children: jsx$2(Flex$1, { className: "block-header icon", children: jsx$2(Svg, { icon: "questionCircle", width: "12px" }) }) }) })] }), jsxs(Flex$1, { className: "yourbondinfo-block info", children: [jsx$2(Flex$1, { className: "block-info icon", children: userBill && (jsx$2(TokenImage, { symbol: (_4 = (_3 = userBill === null || userBill === void 0 ? void 0 : userBill.bond) === null || _3 === void 0 ? void 0 : _3.showcaseTokenName) !== null && _4 !== void 0 ? _4 : (_6 = (_5 = userBill === null || userBill === void 0 ? void 0 : userBill.bond) === null || _5 === void 0 ? void 0 : _5.earnToken) === null || _6 === void 0 ? void 0 : _6.symbol, size: 25, chain: (_7 = userBill === null || userBill === void 0 ? void 0 : userBill.bond) === null || _7 === void 0 ? void 0 : _7.chainId })) }), jsxs(Flex$1, { className: "block-info text", children: [jsx$2(Text, { sx: { fontSize: ['12px', '12px', '12px', '19px'], fontWeight: 700 }, children: formatNumberSI(parseFloat(claimable(userBill).toFixed(4)), 4) }), jsx$2(Text, { sx: {
|
|
70371
|
+
fontSize: ['10px', '10px', '10px', '12px'],
|
|
70372
|
+
fontWeight: [500, 500, 500, 400],
|
|
70373
|
+
paddingLeft: '10px',
|
|
70374
|
+
}, children: `($${(claimable(userBill) * ((_8 = earnTokenPrice === null || earnTokenPrice === void 0 ? void 0 : earnTokenPrice.price) !== null && _8 !== void 0 ? _8 : 0)).toFixed(2)})` })] })] })] }), jsxs(Flex$1, { className: "yourbondinfo-block row-vested", children: [jsxs(Flex$1, { className: "yourbondinfo-block header", children: [jsx$2(Flex$1, { className: "yourbondinfo-block header-title", children: "Claimed" }), jsx$2(Flex$1, { className: "yourbondinfo-block header-tooltip", children: jsx$2(TooltipBubble, { className: "tooltip-bubble", body: jsx$2(Flex$1, { children: UserBillTooltipText.Claimed }), width: "250px", placement: "bottomLeft", transformTip: "translate(-5%, 0%)", children: jsx$2(Flex$1, { className: "block-header icon", children: jsx$2(Svg, { icon: "questionCircle", width: "12px" }) }) }) })] }), jsxs(Flex$1, { className: "yourbondinfo-block info", children: [jsx$2(Flex$1, { className: "block-info icon", children: userBill && (jsx$2(TokenImage, { symbol: (_10 = (_9 = userBill === null || userBill === void 0 ? void 0 : userBill.bond) === null || _9 === void 0 ? void 0 : _9.showcaseTokenName) !== null && _10 !== void 0 ? _10 : (_12 = (_11 = userBill === null || userBill === void 0 ? void 0 : userBill.bond) === null || _11 === void 0 ? void 0 : _11.earnToken) === null || _12 === void 0 ? void 0 : _12.symbol, size: 25, chain: (_13 = userBill === null || userBill === void 0 ? void 0 : userBill.bond) === null || _13 === void 0 ? void 0 : _13.chainId })) }), jsxs(Flex$1, { className: "block-info text", children: [jsx$2(Text, { sx: { fontSize: ['12px', '12px', '12px', '19px'], fontWeight: 700 }, children: formatNumberSI(parseFloat(claimed(userBill).toFixed(4)), 4) }), jsx$2(Text, { sx: {
|
|
70375
|
+
fontSize: ['10px', '10px', '10px', '12px'],
|
|
70376
|
+
fontWeight: [500, 500, 500, 400],
|
|
70377
|
+
paddingLeft: '10px',
|
|
70378
|
+
}, children: `($${(claimed(userBill) * ((_14 = earnTokenPrice === null || earnTokenPrice === void 0 ? void 0 : earnTokenPrice.price) !== null && _14 !== void 0 ? _14 : 0)).toFixed(2)})` })] })] })] })] }), ((_15 = userBill === null || userBill === void 0 ? void 0 : userBill.bond) === null || _15 === void 0 ? void 0 : _15.warningCard) && (jsx$2(Flex$1, { sx: {
|
|
70175
70379
|
width: '100%',
|
|
70176
70380
|
background: '#DE62F366',
|
|
70177
70381
|
justifyContent: 'center',
|
|
70178
70382
|
borderRadius: 'normal',
|
|
70179
|
-
}, children: jsx$2(Text, { sx: { fontSize: '12px', fontWeight: 400, p: '2px 10px' }, children: jsx$2(SafeHTMLComponent, { html: (
|
|
70383
|
+
}, children: jsx$2(Text, { sx: { fontSize: '12px', fontWeight: 400, p: '2px 10px' }, children: jsx$2(SafeHTMLComponent, { html: (_16 = userBill === null || userBill === void 0 ? void 0 : userBill.bond) === null || _16 === void 0 ? void 0 : _16.warningCard }) }) })), jsxs(Flex$1, { className: "yourbondinfo button-container", children: [jsx$2(Flex$1, { className: "button-container claim", children: userBill && chainId !== (userBill === null || userBill === void 0 ? void 0 : userBill.bond.chainId) ? (jsxs(Button, { className: "switch-button", disabled: claimable(userBill) === 0 || load, onClick: (event) => {
|
|
70180
70384
|
var _a;
|
|
70181
70385
|
event.stopPropagation();
|
|
70182
70386
|
switchChain({ chainId: (_a = userBill === null || userBill === void 0 ? void 0 : userBill.bond) === null || _a === void 0 ? void 0 : _a.chainId });
|
|
70183
|
-
}, children: ["Switch to ", NETWORK_LABEL[(
|
|
70387
|
+
}, children: ["Switch to ", NETWORK_LABEL[(_17 = userBill === null || userBill === void 0 ? void 0 : userBill.bond) === null || _17 === void 0 ? void 0 : _17.chainId]] })) : (jsx$2(Button, { className: "claim-button", disabled: claimable(userBill) === 0 || load || !userBill || isPendingCliff, load: load, onClick: (event) => {
|
|
70184
70388
|
event.stopPropagation();
|
|
70185
70389
|
handleClaim(userBill === null || userBill === void 0 ? void 0 : userBill.id, userBill === null || userBill === void 0 ? void 0 : userBill.address);
|
|
70186
70390
|
}, children: isPendingCliff
|
|
@@ -70283,7 +70487,7 @@ const UserBondRow = ({ bill }) => {
|
|
|
70283
70487
|
const { isLoading: isConfirming, isSuccess: isConfirmed } = useMonitorTxHash(claimTxHash, bill.bond.chainId);
|
|
70284
70488
|
const [loadingTx, setLoadingTx] = useState(false);
|
|
70285
70489
|
const load = loadingTx || (isConfirming && !isConfirmed);
|
|
70286
|
-
const [onOpenPurchasedBond] = useModal(jsx$2(YourBondsModal, {
|
|
70490
|
+
const [onOpenPurchasedBond] = useModal(jsx$2(YourBondsModal, { bill: bill }));
|
|
70287
70491
|
const handleClaim = (billId, billAddress) => __awaiter$9(void 0, void 0, void 0, function* () {
|
|
70288
70492
|
var _a;
|
|
70289
70493
|
const address = billAddress;
|
|
@@ -70346,189 +70550,6 @@ const UserBondRow = ({ bill }) => {
|
|
|
70346
70550
|
: 'Claim' })) })] })] }));
|
|
70347
70551
|
};
|
|
70348
70552
|
|
|
70349
|
-
function useBondsList() {
|
|
70350
|
-
const realTime = useURLByEnvironment('realTimeApi');
|
|
70351
|
-
const apiUrl = useURLByEnvironment('apiV2');
|
|
70352
|
-
return useQuery({
|
|
70353
|
-
queryKey: [QUERY_KEYS.BONDS_LIST],
|
|
70354
|
-
queryFn: () => getBondsList(realTime, apiUrl),
|
|
70355
|
-
staleTime: Infinity,
|
|
70356
|
-
refetchOnWindowFocus: false,
|
|
70357
|
-
});
|
|
70358
|
-
}
|
|
70359
|
-
const getBondsList = (realTimeapiURL, apiUrl) => __awaiter$9(void 0, void 0, void 0, function* () {
|
|
70360
|
-
try {
|
|
70361
|
-
const response = yield axios.get(`${realTimeapiURL}/utils/bonds`);
|
|
70362
|
-
return response.data;
|
|
70363
|
-
}
|
|
70364
|
-
catch (e) {
|
|
70365
|
-
reportError({
|
|
70366
|
-
apiUrl,
|
|
70367
|
-
error: e,
|
|
70368
|
-
extraInfo: { type: 'getBondsList', e },
|
|
70369
|
-
});
|
|
70370
|
-
return [];
|
|
70371
|
-
}
|
|
70372
|
-
});
|
|
70373
|
-
|
|
70374
|
-
/* MODIFIED FUNCTION FROM FRONTEND SPECIFICALLY FOR THE SDK */
|
|
70375
|
-
const fetchUserOwnedBillsDataAsync = (chainId, account, bondData, tokenPrices) => __awaiter$9(void 0, void 0, void 0, function* () {
|
|
70376
|
-
try {
|
|
70377
|
-
const bonds = bondData;
|
|
70378
|
-
// Fetch and set user owned bill data without NFT Data
|
|
70379
|
-
const userOwnedBills = yield fetchUserOwnedBills(chainId, account, bonds, tokenPrices);
|
|
70380
|
-
const mapUserOwnedBills = bonds.map((bill) => userOwnedBills.filter((b) => { var _a; return b.address.toLowerCase() === ((_a = bill.contractAddress[bill.chainId]) === null || _a === void 0 ? void 0 : _a.toLowerCase()); }));
|
|
70381
|
-
const userOwnedBillsData = bonds.map((bill, i) => ({
|
|
70382
|
-
index: bill.index,
|
|
70383
|
-
userOwnedBills: mapUserOwnedBills[i],
|
|
70384
|
-
}));
|
|
70385
|
-
const combinedData = userOwnedBillsData.map((data) => {
|
|
70386
|
-
const enrichedUserBills = data.userOwnedBills.map((bill) => {
|
|
70387
|
-
return Object.assign({}, bill);
|
|
70388
|
-
});
|
|
70389
|
-
return Object.assign(Object.assign({}, data), { userOwnedBills: enrichedUserBills });
|
|
70390
|
-
});
|
|
70391
|
-
return Promise.resolve(combinedData);
|
|
70392
|
-
}
|
|
70393
|
-
catch (error) {
|
|
70394
|
-
console.error('Error fetching user owned bills data:', error);
|
|
70395
|
-
return Promise.reject(error);
|
|
70396
|
-
}
|
|
70397
|
-
});
|
|
70398
|
-
/* MODIFIED FUNCTION FROM FRONTEND SPECIFICALLY FOR THE SDK */
|
|
70399
|
-
const fetchUserOwnedBills = (chainId, account, bonds, tokenPrices) => __awaiter$9(void 0, void 0, void 0, function* () {
|
|
70400
|
-
var _a, _b, _c, _d, _e, _f;
|
|
70401
|
-
// Maps all the bills in the list repo to make a call to each of them to get Bills Id, meaning purchased bill ids
|
|
70402
|
-
const billIdCalls = bonds.map((b) => {
|
|
70403
|
-
var _a;
|
|
70404
|
-
return ({
|
|
70405
|
-
address: (_a = b.contractAddress[b.chainId]) !== null && _a !== void 0 ? _a : '',
|
|
70406
|
-
name: 'getBillIds',
|
|
70407
|
-
params: [account],
|
|
70408
|
-
});
|
|
70409
|
-
});
|
|
70410
|
-
const billIds = yield multicall(chainId, BOND_ABI, billIdCalls, true, 15);
|
|
70411
|
-
const billDataCalls = [];
|
|
70412
|
-
const billVersions = [];
|
|
70413
|
-
billIds.forEach((idArray, index) => idArray[0].forEach((id) => id.gt(0) &&
|
|
70414
|
-
(billDataCalls.push({
|
|
70415
|
-
address: bonds[index].contractAddress[bonds[index].chainId],
|
|
70416
|
-
name: bonds[index].billVersion !== types.BillVersion.V1 ? 'getBillInfo' : 'billInfo',
|
|
70417
|
-
params: [id],
|
|
70418
|
-
bond: bonds[index],
|
|
70419
|
-
}),
|
|
70420
|
-
billDataCalls.push({
|
|
70421
|
-
address: bonds[index].contractAddress[bonds[index].chainId],
|
|
70422
|
-
name: bonds[index].billVersion !== types.BillVersion.V1 ? 'claimablePayout' : 'pendingPayoutFor',
|
|
70423
|
-
params: [id],
|
|
70424
|
-
bond: bonds[index],
|
|
70425
|
-
}),
|
|
70426
|
-
billVersions.push(bonds[index].billVersion))));
|
|
70427
|
-
const billData = yield multicall(chainId, BOND_ABI, billDataCalls, true, 150);
|
|
70428
|
-
const result = [];
|
|
70429
|
-
for (let i = 0; i < billVersions.length; i++) {
|
|
70430
|
-
const billPos = i === 0 ? 0 : i * 2;
|
|
70431
|
-
let bond = billDataCalls[billPos].bond;
|
|
70432
|
-
// const principalTokenPrice = tokenPrices.find(
|
|
70433
|
-
// (tokenPrice) =>
|
|
70434
|
-
// tokenPrice.address?.toLowerCase() === bond?.lpToken?.address?.[bond.chainId]?.toLowerCase() &&
|
|
70435
|
-
// tokenPrice.chainId === bond.chainId,
|
|
70436
|
-
// )?.price
|
|
70437
|
-
const payoutTokenPrice = (_a = tokenPrices.find((tokenPrice) => {
|
|
70438
|
-
var _a, _b, _c, _d;
|
|
70439
|
-
return ((_a = tokenPrice.address) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === ((_d = (_c = (_b = bond === null || bond === void 0 ? void 0 : bond.earnToken) === null || _b === void 0 ? void 0 : _b.address) === null || _c === void 0 ? void 0 : _c[bond.chainId]) === null || _d === void 0 ? void 0 : _d.toLowerCase()) &&
|
|
70440
|
-
tokenPrice.chainId === bond.chainId;
|
|
70441
|
-
})) === null || _a === void 0 ? void 0 : _a.price;
|
|
70442
|
-
bond = Object.assign(Object.assign({}, bond), { payoutTokenPrice: payoutTokenPrice });
|
|
70443
|
-
const data = billVersions[i] !== types.BillVersion.V1
|
|
70444
|
-
? {
|
|
70445
|
-
address: billDataCalls[billPos].address,
|
|
70446
|
-
id: billDataCalls[billPos].params[0].toString(),
|
|
70447
|
-
payout: new BigNumber$1((_b = billData[billPos][0]) === null || _b === void 0 ? void 0 : _b.payout.toString())
|
|
70448
|
-
.minus((_c = billData[billPos][0]) === null || _c === void 0 ? void 0 : _c.payoutClaimed.toString())
|
|
70449
|
-
.toString(),
|
|
70450
|
-
billNftAddress: bond.billNnftAddress[bond.chainId],
|
|
70451
|
-
vesting: (_d = billData[billPos][0]) === null || _d === void 0 ? void 0 : _d.vesting.toString(),
|
|
70452
|
-
lastBlockTimestamp: (_e = billData[billPos][0]) === null || _e === void 0 ? void 0 : _e.lastClaimTimestamp.toString(),
|
|
70453
|
-
truePricePaid: (_f = billData[billPos][0]) === null || _f === void 0 ? void 0 : _f.truePricePaid.toString(),
|
|
70454
|
-
pendingRewards: billData[billPos + 1][0].toString(),
|
|
70455
|
-
bond,
|
|
70456
|
-
}
|
|
70457
|
-
: {
|
|
70458
|
-
address: billDataCalls[billPos].address,
|
|
70459
|
-
id: billDataCalls[billPos].params[0].toString(),
|
|
70460
|
-
payout: billData[billPos][0].toString(),
|
|
70461
|
-
billNftAddress: bond.billNnftAddress[bond.chainId],
|
|
70462
|
-
vesting: billData[billPos][1].toString(),
|
|
70463
|
-
lastBlockTimestamp: billData[billPos][2].toString(),
|
|
70464
|
-
truePricePaid: billData[billPos][3].toString(),
|
|
70465
|
-
pendingRewards: billData[billPos + 1][0].toString(),
|
|
70466
|
-
bond,
|
|
70467
|
-
};
|
|
70468
|
-
result.push(data);
|
|
70469
|
-
}
|
|
70470
|
-
return result;
|
|
70471
|
-
});
|
|
70472
|
-
|
|
70473
|
-
function useUserBonds() {
|
|
70474
|
-
var _a;
|
|
70475
|
-
// First fetch the full list of bonds
|
|
70476
|
-
const { data: bondList } = useBondsList();
|
|
70477
|
-
const { address } = useAccount();
|
|
70478
|
-
const SDKConfig = useSDKConfig();
|
|
70479
|
-
const { data: tokenPrices } = useTokenPrices();
|
|
70480
|
-
const chains = SDKConfig === null || SDKConfig === void 0 ? void 0 : SDKConfig.chains;
|
|
70481
|
-
const apiUrl = (_a = SDKConfig === null || SDKConfig === void 0 ? void 0 : SDKConfig.urls) === null || _a === void 0 ? void 0 : _a.apiV2;
|
|
70482
|
-
// Once the full list is fetched, fetch user's purchased bonds
|
|
70483
|
-
return useQuery({
|
|
70484
|
-
queryKey: [QUERY_KEYS.USER_BONDS, address],
|
|
70485
|
-
queryFn: () => getUserBonds(address, bondList, chains, tokenPrices, apiUrl),
|
|
70486
|
-
refetchOnWindowFocus: false,
|
|
70487
|
-
refetchInterval: 60000,
|
|
70488
|
-
enabled: !!bondList && !!address && !!tokenPrices,
|
|
70489
|
-
});
|
|
70490
|
-
}
|
|
70491
|
-
const getUserBonds = (account, bondList, chains, tokenPrices, apiUrl) => __awaiter$9(void 0, void 0, void 0, function* () {
|
|
70492
|
-
try {
|
|
70493
|
-
const bondsByChain = bondList.reduce((acc, bond) => {
|
|
70494
|
-
var _a;
|
|
70495
|
-
// Exclude ACF to ABOND bonds, fixed price bonds, and migration bonds
|
|
70496
|
-
if (((_a = bond.contractAddress[bond.chainId]) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === ACF_TO_ABOND.toLowerCase() ||
|
|
70497
|
-
bond.billVersion === types.BillVersion.FixedPrice ||
|
|
70498
|
-
bond.billType === 'migration') {
|
|
70499
|
-
return acc; // Skip this bond
|
|
70500
|
-
}
|
|
70501
|
-
// Only process bonds that belong to the specified chains
|
|
70502
|
-
if (chains.includes(bond.chainId)) {
|
|
70503
|
-
// Initialize acc[bond.chainId] if it doesn't exist yet
|
|
70504
|
-
if (!acc[bond.chainId]) {
|
|
70505
|
-
acc[bond.chainId] = [];
|
|
70506
|
-
}
|
|
70507
|
-
// Safely push the bond to the array
|
|
70508
|
-
acc[bond.chainId].push(bond);
|
|
70509
|
-
}
|
|
70510
|
-
return acc;
|
|
70511
|
-
}, {});
|
|
70512
|
-
const results = yield Promise.allSettled(chains
|
|
70513
|
-
.filter((chain) => bondsByChain[chain])
|
|
70514
|
-
.map((chain) => fetchUserOwnedBillsDataAsync(chain, account, bondsByChain[chain], tokenPrices)));
|
|
70515
|
-
// Filter out only fulfilled promises
|
|
70516
|
-
const fulfilledResults = results
|
|
70517
|
-
.filter((result) => result.status === 'fulfilled')
|
|
70518
|
-
.map((result) => result.value);
|
|
70519
|
-
return fulfilledResults.flat().flatMap((result) => result.userOwnedBills);
|
|
70520
|
-
}
|
|
70521
|
-
catch (e) {
|
|
70522
|
-
reportError({
|
|
70523
|
-
apiUrl,
|
|
70524
|
-
error: e,
|
|
70525
|
-
extraInfo: { type: 'getUserBonds', bondList, chains, e },
|
|
70526
|
-
account,
|
|
70527
|
-
});
|
|
70528
|
-
return [];
|
|
70529
|
-
}
|
|
70530
|
-
});
|
|
70531
|
-
|
|
70532
70553
|
const RainbowKitButton = () => {
|
|
70533
70554
|
return (jsx$2(ConnectButton$1.Custom, { children: ({ openConnectModal }) => {
|
|
70534
70555
|
return (jsx$2(Button, { fullWidth: true, onClick: () => {
|
|
@@ -76622,7 +76643,6 @@ const fetchBills = (chainId, tokenPrices, bills) => __awaiter$9(void 0, void 0,
|
|
|
76622
76643
|
});
|
|
76623
76644
|
});
|
|
76624
76645
|
const treasuryBalances = yield multicall(chainId, ERC_20_ABI, treasuryBalanceCalls);
|
|
76625
|
-
console.log(vals);
|
|
76626
76646
|
const updatedVals = vals.reduce((acc, val, index) => {
|
|
76627
76647
|
acc.push(val);
|
|
76628
76648
|
if ((index + 1) % 5 === 0) {
|
|
@@ -78019,7 +78039,7 @@ const useApproval = (amount, currency, spender, account, chainId) => {
|
|
|
78019
78039
|
catch (error) {
|
|
78020
78040
|
setConfirmingTxOnWallet(false);
|
|
78021
78041
|
console.error('Approval failed:', error);
|
|
78022
|
-
addToastError(error.message);
|
|
78042
|
+
addToastError((error === null || error === void 0 ? void 0 : error.shortMessage) || (error === null || error === void 0 ? void 0 : error.details) || (error === null || error === void 0 ? void 0 : error.message));
|
|
78023
78043
|
reportError({
|
|
78024
78044
|
apiUrl,
|
|
78025
78045
|
error,
|
|
@@ -78692,30 +78712,6 @@ const useIsMobile = () => {
|
|
|
78692
78712
|
return isMobile;
|
|
78693
78713
|
};
|
|
78694
78714
|
|
|
78695
|
-
var ABTestKeys;
|
|
78696
|
-
(function (ABTestKeys) {
|
|
78697
|
-
ABTestKeys["BOND_DESCRIPTION"] = "bondDescription";
|
|
78698
|
-
ABTestKeys["BOND_BUY_BUTTON"] = "bondBuyButton";
|
|
78699
|
-
ABTestKeys["BOND_BUY_ARR"] = "bondBuyArr";
|
|
78700
|
-
})(ABTestKeys || (ABTestKeys = {}));
|
|
78701
|
-
function useABTesting({ key, defaultValue = (Math.random() < 0.5).toString(), }) {
|
|
78702
|
-
const { cookie, updateCookie } = useCookie(QUERY_KEYS.AB_TEST_VALUE, null);
|
|
78703
|
-
let abTestValue = '';
|
|
78704
|
-
let parseCookie = null;
|
|
78705
|
-
if (cookie === null || cookie === undefined || cookie[key] === undefined) {
|
|
78706
|
-
parseCookie = Object.assign(Object.assign({}, cookie), { [key]: defaultValue.toString() });
|
|
78707
|
-
abTestValue = defaultValue.toString();
|
|
78708
|
-
updateCookie(parseCookie);
|
|
78709
|
-
}
|
|
78710
|
-
if (cookie) {
|
|
78711
|
-
parseCookie = cookie;
|
|
78712
|
-
if (parseCookie && parseCookie[key]) {
|
|
78713
|
-
abTestValue = parseCookie[key].toString();
|
|
78714
|
-
}
|
|
78715
|
-
}
|
|
78716
|
-
return { abTestValue };
|
|
78717
|
-
}
|
|
78718
|
-
|
|
78719
78715
|
const ProgressBar = ({ value, color = 'text' }) => {
|
|
78720
78716
|
return (jsx$2(Flex$1, { sx: { width: ['100px', '100px', '100px', '100%'], alignItems: 'center', flexDirection: 'row', mt: '5px' }, children: jsx$2(Box$1, { className: "progressbar-background", children: jsx$2(Box$1, { className: "progressbar-completed", style: {
|
|
78721
78717
|
width: `${value <= 3 ? 3 : value}%`,
|
|
@@ -78741,10 +78737,9 @@ const ProgressBarWrapper = ({ title, value, style, showTooltip, toolTipPlacement
|
|
|
78741
78737
|
var ProgressBarWrapper$1 = React__default.memo(ProgressBarWrapper);
|
|
78742
78738
|
|
|
78743
78739
|
const BondCards$1 = ({ bondData }) => {
|
|
78744
|
-
var _a, _b
|
|
78740
|
+
var _a, _b;
|
|
78745
78741
|
const isMobile = useIsMobile();
|
|
78746
|
-
|
|
78747
|
-
const { abTestValue } = useABTesting({ key: ABTestKeys.BOND_BUY_ARR });
|
|
78742
|
+
useSDKConfig();
|
|
78748
78743
|
return (jsxs("div", { className: "bonds-cards", children: [jsxs("div", { className: "bond-card-block", sx: {
|
|
78749
78744
|
borderRadius: ['0px', '0px', '0px', 'normal'],
|
|
78750
78745
|
'&:first-of-type': {
|
|
@@ -78755,35 +78750,7 @@ const BondCards$1 = ({ bondData }) => {
|
|
|
78755
78750
|
borderBottomRightRadius: 'normal',
|
|
78756
78751
|
borderBottomLeftRadius: 'normal',
|
|
78757
78752
|
},
|
|
78758
|
-
}, children: [jsxs(Flex, { className: "bond-card-title", children: ["Bonus", jsx$2(TooltipBubble, { className: "tooltip-bubble", body: jsx$2(Flex, { children: TooltipText.Discount }), width: "230px", placement: "bottomLeft", transformTip: "translate(-5%, -5%)", children: jsx$2("div", { className: "bond-card-tooltip", children: jsx$2(Svg, { icon: "questionCircle", width: "12px" }) }) })] }), jsx$2(BonusComponent, { trueBondPrices: bondData.trueBondPrices, minTier: bondData.minTier, tooltipPosition: isMobile ? 'bottomRight' : 'bottomLeft' })] }),
|
|
78759
|
-
borderRadius: ['0px', '0px', '0px', 'normal'],
|
|
78760
|
-
'&:first-of-type': {
|
|
78761
|
-
borderTopRightRadius: 'normal',
|
|
78762
|
-
borderTopLeftRadius: 'normal',
|
|
78763
|
-
},
|
|
78764
|
-
'&:last-of-type': {
|
|
78765
|
-
borderBottomRightRadius: 'normal',
|
|
78766
|
-
borderBottomLeftRadius: 'normal',
|
|
78767
|
-
},
|
|
78768
|
-
}, children: [jsxs(Flex, { className: "bond-card-title", children: ["ARR", jsx$2(TooltipBubble, { className: "tooltip-bubble", body: jsx$2(Flex, { children: TooltipText.ARR }), width: "230px", placement: "bottomLeft", transformTip: "translate(-5%, -5%)", children: jsx$2("div", { className: "bond-card-tooltip", children: jsx$2(Svg, { icon: "questionCircle", width: "12px" }) }) })] }), (SDKConfig === null || SDKConfig === void 0 ? void 0 : SDKConfig.useTiers) &&
|
|
78769
|
-
bondData.billVersion === types.BillVersion.V4 &&
|
|
78770
|
-
((_a = findHighestTrueBondPrice(TIERS_WEIGHT[types.LaunchBondTiers.Legend], bondData)) === null || _a === void 0 ? void 0 : _a.bonusWithFee) > 0 ? (jsxs(Flex, { sx: {
|
|
78771
|
-
p: '3px 6px',
|
|
78772
|
-
border: '1px solid var(--theme-ui-colors-primaryButton)',
|
|
78773
|
-
borderRadius: 'normal',
|
|
78774
|
-
background: 'transparent',
|
|
78775
|
-
position: 'relative',
|
|
78776
|
-
overflow: 'hidden',
|
|
78777
|
-
}, children: [jsx$2(Flex, { sx: {
|
|
78778
|
-
position: 'absolute',
|
|
78779
|
-
width: '100%',
|
|
78780
|
-
height: '100%',
|
|
78781
|
-
top: 0,
|
|
78782
|
-
left: 0,
|
|
78783
|
-
zIndex: 1,
|
|
78784
|
-
background: 'primaryButton',
|
|
78785
|
-
opacity: 0.3,
|
|
78786
|
-
} }), jsxs(Flex, { sx: { width: '100%', zIndex: 2, alignItems: 'center' }, children: [jsx$2("img", { src: `/images/launch/legend.png`, alt: "minTier", style: { width: '21px', height: '21px', marginRight: '3px', zIndex: 1 } }), jsx$2(Flex, { children: calculateARR(bondData, (SDKConfig === null || SDKConfig === void 0 ? void 0 : SDKConfig.useTiers) && bondData.billVersion === types.BillVersion.V4) })] })] })) : (calculateARR(bondData, (SDKConfig === null || SDKConfig === void 0 ? void 0 : SDKConfig.useTiers) && bondData.billVersion === types.BillVersion.V4))] })), abTestValue === 'false' && (jsxs("div", { className: "bond-card-block", sx: {
|
|
78753
|
+
}, children: [jsxs(Flex, { className: "bond-card-title", children: ["Bonus", jsx$2(TooltipBubble, { className: "tooltip-bubble", body: jsx$2(Flex, { children: TooltipText.Discount }), width: "230px", placement: "bottomLeft", transformTip: "translate(-5%, -5%)", children: jsx$2("div", { className: "bond-card-tooltip", children: jsx$2(Svg, { icon: "questionCircle", width: "12px" }) }) })] }), jsx$2(BonusComponent, { trueBondPrices: bondData.trueBondPrices, minTier: bondData.minTier, tooltipPosition: isMobile ? 'bottomRight' : 'bottomLeft' })] }), jsxs("div", { className: "bond-card-block", sx: {
|
|
78787
78754
|
borderRadius: ['0px', '0px', '0px', 'normal'],
|
|
78788
78755
|
'&:first-of-type': {
|
|
78789
78756
|
borderTopRightRadius: 'normal',
|
|
@@ -78793,12 +78760,7 @@ const BondCards$1 = ({ bondData }) => {
|
|
|
78793
78760
|
borderBottomRightRadius: 'normal',
|
|
78794
78761
|
borderBottomLeftRadius: 'normal',
|
|
78795
78762
|
},
|
|
78796
|
-
}, children: [jsxs(
|
|
78797
|
-
width: '127px',
|
|
78798
|
-
height: '25px',
|
|
78799
|
-
flexDirection: 'column',
|
|
78800
|
-
justifyContent: 'center',
|
|
78801
|
-
}, showTooltip: true, toolTip: getRemainingTokensString(bondData) })] })), jsxs("div", { className: "bond-card-block", sx: {
|
|
78763
|
+
}, children: [jsxs("div", { className: "bond-card-title", children: ["Terms", jsx$2(TooltipBubble, { className: "tooltip-bubble", body: jsx$2(Flex, { children: TooltipText.Terms }), 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: [getVestingTermsString(bondData), bondData.vestingCliff && (jsx$2(TooltipBubble, { className: "tooltip-bubble", body: jsx$2(Flex, { children: getVestingTermsTooltipString(bondData) }), width: "180px", placement: "bottomRight", transformTip: "translate(13%, 0%)", children: jsx$2(Flex, { sx: { opacity: 0.6, ml: '6px' }, children: jsx$2(Svg, { icon: "questionCircle", width: "12px" }) }) }))] })] }), jsxs("div", { className: "bond-card-block", sx: {
|
|
78802
78764
|
borderRadius: ['0px', '0px', '0px', 'normal'],
|
|
78803
78765
|
'&:first-of-type': {
|
|
78804
78766
|
borderTopRightRadius: 'normal',
|
|
@@ -78808,7 +78770,7 @@ const BondCards$1 = ({ bondData }) => {
|
|
|
78808
78770
|
borderBottomRightRadius: 'normal',
|
|
78809
78771
|
borderBottomLeftRadius: 'normal',
|
|
78810
78772
|
},
|
|
78811
|
-
}, children: [jsxs("div", { className: "bond-card-title", children: ["
|
|
78773
|
+
}, children: [jsxs("div", { className: "bond-card-title", children: ["Max Buy", jsx$2(TooltipBubble, { className: "tooltip-bubble", body: jsx$2(Flex, { children: TooltipText.MaxBuy((_a = bondData === null || bondData === void 0 ? void 0 : bondData.earnToken) === null || _a === void 0 ? void 0 : _a.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: (_b = bondData.showcaseTokenName) !== null && _b !== void 0 ? _b : bondData.earnToken.symbol, size: 20 }) }), formatNumberSI(maxBuy(bondData).toFixed(0), 2)] })] }), jsxs("div", { className: "bond-card-block", sx: {
|
|
78812
78774
|
borderRadius: ['0px', '0px', '0px', 'normal'],
|
|
78813
78775
|
'&:first-of-type': {
|
|
78814
78776
|
borderTopRightRadius: 'normal',
|
|
@@ -78818,7 +78780,12 @@ const BondCards$1 = ({ bondData }) => {
|
|
|
78818
78780
|
borderBottomRightRadius: 'normal',
|
|
78819
78781
|
borderBottomLeftRadius: 'normal',
|
|
78820
78782
|
},
|
|
78821
|
-
}, children: [jsxs(
|
|
78783
|
+
}, children: [jsxs(Flex, { className: "bond-card-title", children: ["Tokens Remaining", jsx$2(TooltipBubble, { className: "tooltip-bubble", body: jsx$2(Flex, { children: TooltipText.TokensRemaining }), width: "230px", placement: "bottomLeft", transformTip: "translate(-5%, -5%)", children: jsx$2("div", { className: "bond-card-tooltip", children: jsx$2(Svg, { icon: "questionCircle", width: "12px" }) }) })] }), jsx$2(ProgressBarWrapper$1, { title: '', value: jsx$2(ProgressBar, { value: remainingPercentage(bondData) }), style: {
|
|
78784
|
+
width: '127px',
|
|
78785
|
+
height: '25px',
|
|
78786
|
+
flexDirection: 'column',
|
|
78787
|
+
justifyContent: 'center',
|
|
78788
|
+
}, showTooltip: true, toolTip: getRemainingTokensString(bondData) })] })] }));
|
|
78822
78789
|
};
|
|
78823
78790
|
|
|
78824
78791
|
const Estimations = ({ depositAmount, bondData, youSpendString, isZap, fetchingZapQuote, zapError, }) => {
|
|
@@ -79121,8 +79088,8 @@ const TransactionModal = ({ onDismiss, txChain, approvalState, approveCallback,
|
|
|
79121
79088
|
const hasTriggeredApproval = useRef(false);
|
|
79122
79089
|
useEffect(() => {
|
|
79123
79090
|
if (!hasToSwitchChain || !showSwitchChainFlow) {
|
|
79124
|
-
setApproveLoading(true);
|
|
79125
79091
|
if (approvalState === ApprovalState.APPROVED) {
|
|
79092
|
+
setApproveLoading(true);
|
|
79126
79093
|
const delay = setTimeout(() => {
|
|
79127
79094
|
setApproveLoading(false);
|
|
79128
79095
|
setHasToApprove(false);
|
|
@@ -79208,17 +79175,6 @@ const BuyBond = ({ onDismiss, bondAddress, bondChain, handlePurchasedBond, isPro
|
|
|
79208
79175
|
const { data: userPoints } = useTierPoints();
|
|
79209
79176
|
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()); });
|
|
79210
79177
|
const isMobile = useIsMobile();
|
|
79211
|
-
const { abTestValue } = useABTesting({ key: ABTestKeys.BOND_BUY_ARR });
|
|
79212
|
-
let reason = '';
|
|
79213
|
-
let trackOpenModal = '';
|
|
79214
|
-
if (isMobile) {
|
|
79215
|
-
reason = abTestValue === 'true' ? 'bondBuyMobile' : 'bondBuyRemainingMobile';
|
|
79216
|
-
trackOpenModal = abTestValue === 'true' ? 'openModalARRMobile' : 'openModalRemainingMobile';
|
|
79217
|
-
}
|
|
79218
|
-
else {
|
|
79219
|
-
reason = abTestValue === 'true' ? 'bondBuyARRDesktop' : 'bondBuyRemainingDesktop';
|
|
79220
|
-
trackOpenModal = abTestValue === 'true' ? 'openModalARRDesktop' : 'openModalRemainingDesktop';
|
|
79221
|
-
}
|
|
79222
79178
|
// Tier Gating
|
|
79223
79179
|
const userTier = getUserTier(userPoints !== null && userPoints !== void 0 ? userPoints : '0');
|
|
79224
79180
|
const minTier = (bondData === null || bondData === void 0 ? void 0 : bondData.minTier) !== undefined ? bondData.minTier : null;
|
|
@@ -79316,7 +79272,7 @@ const BuyBond = ({ onDismiss, bondAddress, bondChain, handlePurchasedBond, isPro
|
|
|
79316
79272
|
});
|
|
79317
79273
|
if (hash) {
|
|
79318
79274
|
setBuyTxHash(hash);
|
|
79319
|
-
yield sendReferenceId(billAddress, userChainId, hash
|
|
79275
|
+
yield sendReferenceId(billAddress, userChainId, hash);
|
|
79320
79276
|
handlePurchasedBond === null || handlePurchasedBond === void 0 ? void 0 : handlePurchasedBond(hash);
|
|
79321
79277
|
track({
|
|
79322
79278
|
event: 'bond',
|
|
@@ -79369,7 +79325,7 @@ const BuyBond = ({ onDismiss, bondAddress, bondChain, handlePurchasedBond, isPro
|
|
|
79369
79325
|
});
|
|
79370
79326
|
if (hash) {
|
|
79371
79327
|
setBuyTxHash(hash);
|
|
79372
|
-
yield sendReferenceId((_d = bondData === null || bondData === void 0 ? void 0 : bondData.billAddress) !== null && _d !== void 0 ? _d : '', userChainId, hash
|
|
79328
|
+
yield sendReferenceId((_d = bondData === null || bondData === void 0 ? void 0 : bondData.billAddress) !== null && _d !== void 0 ? _d : '', userChainId, hash);
|
|
79373
79329
|
handlePurchasedBond === null || handlePurchasedBond === void 0 ? void 0 : handlePurchasedBond(hash);
|
|
79374
79330
|
track({
|
|
79375
79331
|
event: 'zap',
|
|
@@ -79446,7 +79402,6 @@ const BuyBond = ({ onDismiss, bondAddress, bondChain, handlePurchasedBond, isPro
|
|
|
79446
79402
|
const [hasChecked, setHasChecked] = useState(false);
|
|
79447
79403
|
const [hasCheckedTrack, setHasCheckedTrack] = useState(false);
|
|
79448
79404
|
useEffect(() => {
|
|
79449
|
-
var _a;
|
|
79450
79405
|
if (inputCurrencyBalance !== undefined &&
|
|
79451
79406
|
inputCurrencyBalance === '0' &&
|
|
79452
79407
|
!hasChecked &&
|
|
@@ -79459,14 +79414,6 @@ const BuyBond = ({ onDismiss, bondAddress, bondChain, handlePurchasedBond, isPro
|
|
|
79459
79414
|
}
|
|
79460
79415
|
if (bondData && !hasCheckedTrack) {
|
|
79461
79416
|
setHasCheckedTrack(true);
|
|
79462
|
-
track({
|
|
79463
|
-
event: 'trackOpenModal',
|
|
79464
|
-
chain: bondData.chainId,
|
|
79465
|
-
data: {
|
|
79466
|
-
cat: trackOpenModal,
|
|
79467
|
-
bond: (_a = bondData === null || bondData === void 0 ? void 0 : bondData.earnToken.symbol) !== null && _a !== void 0 ? _a : '',
|
|
79468
|
-
},
|
|
79469
|
-
});
|
|
79470
79417
|
}
|
|
79471
79418
|
}, [inputCurrencyBalance, sortedZapList, bondData]);
|
|
79472
79419
|
// If rateChanged meaning the zap quote has a >1% difference from the true bond price, we let the user know and we update state
|
|
@@ -79552,7 +79499,7 @@ const ModalHandler = ({ onDismiss, bondAddress, bondChain, }) => {
|
|
|
79552
79499
|
refetch();
|
|
79553
79500
|
}
|
|
79554
79501
|
}, [billId]);
|
|
79555
|
-
return billId ? (jsx$2(YourBondsModal, {
|
|
79502
|
+
return billId ? (jsx$2(YourBondsModal, { bill: userBill, onDismiss: onDismiss })) : (jsx$2(BuyBondModal, { bondAddress: bondAddress, bondChain: bondChain, handlePurchasedBond: setBuyTxHash, onDismiss: () => {
|
|
79556
79503
|
window.history.pushState({}, '', `${locationPath !== '/bonds' ? locationPath : '/bonds'}`);
|
|
79557
79504
|
onDismiss === null || onDismiss === void 0 ? void 0 : onDismiss();
|
|
79558
79505
|
} }));
|
|
@@ -81221,6 +81168,13 @@ const Toast = ({ popIndex, popup }) => {
|
|
|
81221
81168
|
}, 500);
|
|
81222
81169
|
}, 10000);
|
|
81223
81170
|
}, []);
|
|
81171
|
+
const showSupportLink = variant === 'error' && !url && !popup.description.includes('User rejected the request');
|
|
81172
|
+
const isSlippageError = popup.description.includes('INSUFFICIENT') ||
|
|
81173
|
+
popup.description.includes('Slippage') ||
|
|
81174
|
+
popup.description.includes('Return amount is not enough');
|
|
81175
|
+
const parsedErrorString = isSlippageError
|
|
81176
|
+
? 'Slippage error. Try increasing Slippage in the cog icon ⚙️.'
|
|
81177
|
+
: popup.description;
|
|
81224
81178
|
return (jsx$2(AnimatePresence, { children: show && (jsxs(motion.div, { initial: { right: '-300px' }, animate: { right: '10px' }, transition: { duration: 0.5 }, exit: { right: '-300px' }, sx: Object.assign(Object.assign({}, styles$5.alert), { top: 108 * popIndex, zIndex: 103 }), children: [jsx$2(Flex, { children: jsx$2(Svg, { icon: variant, color: variant, width: "30px" }) }), jsxs(Flex, { sx: styles$5.content, children: [jsx$2(Text, { sx: { color: variant, fontSize: '14px', fontWeight: 500 }, children: title }), description && (jsx$2(Text, { sx: {
|
|
81225
81179
|
fontSize: '12px',
|
|
81226
81180
|
fontWeight: 400,
|
|
@@ -81232,12 +81186,13 @@ const Toast = ({ popIndex, popup }) => {
|
|
|
81232
81186
|
display: '-webkit-box',
|
|
81233
81187
|
WebkitBoxOrient: 'vertical',
|
|
81234
81188
|
WebkitLineClamp: 3, // Limit text to 3 lines
|
|
81235
|
-
}, children:
|
|
81189
|
+
}, children: parsedErrorString })), url && (jsxs(Link, { href: url, sx: styles$5.link, color: "text", target: "_blank", children: [jsx$2(Text, { mr: "5px", children: "View on Explorer" }), jsx$2(Svg, { icon: "external" })] })), showSupportLink && (jsxs(Link, { href: 'https://discord.com/channels/821817977917538375/1110438345701593088', sx: styles$5.link, color: "text", target: "_blank", children: [jsx$2(Text, { mr: "5px", children: "Having issues? Get support" }), jsx$2(Svg, { icon: "external" })] }))] }), jsx$2(Flex, { sx: { alignItems: 'flex-start', pt: '3px' }, onClick: () => removePopup(popup), children: jsx$2(IconButton, { icon: "close", color: "text", variant: "transparent" }) })] })) }));
|
|
81236
81190
|
};
|
|
81237
81191
|
|
|
81238
81192
|
const Popups = ({ children }) => {
|
|
81239
81193
|
const { data: activePopups } = usePopups();
|
|
81240
|
-
|
|
81194
|
+
const filteredPopups = activePopups === null || activePopups === void 0 ? void 0 : activePopups.filter((popup) => popup.timestamp > Date.now() - 10000);
|
|
81195
|
+
return (jsxs(Flex, { sx: { width: '100%', height: '100%', position: 'relative', flexDirection: 'column' }, children: [jsx$2(Flex, { sx: { position: 'absolute', top: 0, right: 0 }, children: filteredPopups === null || filteredPopups === void 0 ? void 0 : filteredPopups.map((popup, i) => {
|
|
81241
81196
|
return jsx$2(Toast, { popIndex: i + 1, popup: popup }, popup.timestamp);
|
|
81242
81197
|
}) }), children] }));
|
|
81243
81198
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { UserBill } from '../../types/yourbonds';
|
|
3
|
-
declare const YourBondsModal: ({ onDismiss,
|
|
3
|
+
declare const YourBondsModal: ({ onDismiss, bill }: {
|
|
4
4
|
onDismiss?: () => void;
|
|
5
|
-
|
|
5
|
+
bill?: UserBill;
|
|
6
6
|
}) => React.JSX.Element;
|
|
7
7
|
export default YourBondsModal;
|