@ape.swap/bonds-sdk 3.0.77 → 3.0.79
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',
|
|
@@ -58289,8 +58288,8 @@ const PUBLIC_RPC_URLS = {
|
|
|
58289
58288
|
'https://linea.decubate.com',
|
|
58290
58289
|
],
|
|
58291
58290
|
[types.ChainId.LIGHTLINK]: [
|
|
58292
|
-
'https://endpoints.omniatech.io/v1/lightlink/phoenix/public',
|
|
58293
58291
|
'https://replicator.phoenix.lightlink.io/rpc/v1',
|
|
58292
|
+
'https://endpoints.omniatech.io/v1/lightlink/phoenix/public',
|
|
58294
58293
|
],
|
|
58295
58294
|
[types.ChainId.IOTA]: ['https://json-rpc.evm.iotaledger.net/'],
|
|
58296
58295
|
[types.ChainId.IOTA_TESTNET]: ['https://json-rpc.evm.testnet.iotaledger.net/'],
|
|
@@ -61076,6 +61075,8 @@ const UserBillTooltipText = {
|
|
|
61076
61075
|
FullyVested: 'This is the time remaining until all tokens from the bond are available to claim.',
|
|
61077
61076
|
Pending: 'This is the amount of unvested tokens that cannot be claimed yet.',
|
|
61078
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.',
|
|
61079
61080
|
};
|
|
61080
61081
|
|
|
61081
61082
|
// export const getBillNftData = async (billNftId: string, billNftAddress: string, chainId: number) => {
|
|
@@ -70057,13 +70058,198 @@ const SafeHTMLComponent = ({ html }) => {
|
|
|
70057
70058
|
return jsx$2("div", { dangerouslySetInnerHTML: { __html: sanitizedHTML } });
|
|
70058
70059
|
};
|
|
70059
70060
|
|
|
70060
|
-
|
|
70061
|
-
|
|
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;
|
|
70062
70246
|
// Hooks
|
|
70063
70247
|
const SDKConfig = useSDKConfig();
|
|
70064
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]);
|
|
70065
70251
|
const { switchChain } = useSwitchChain();
|
|
70066
|
-
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);
|
|
70067
70253
|
const { writeContractAsync } = useWriteContract();
|
|
70068
70254
|
const { address: account } = useAccount();
|
|
70069
70255
|
// State
|
|
@@ -70124,12 +70310,17 @@ const YourBondsModal = ({ onDismiss, userBill }) => {
|
|
|
70124
70310
|
// Functions to calculate display values for modal
|
|
70125
70311
|
const totalPending = (userBill) => {
|
|
70126
70312
|
var _a, _b, _c, _d, _e, _f;
|
|
70127
|
-
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));
|
|
70128
70314
|
};
|
|
70129
70315
|
const claimable = (userBill) => {
|
|
70130
70316
|
var _a, _b, _c, _d, _e, _f;
|
|
70131
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);
|
|
70132
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
|
+
};
|
|
70133
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);
|
|
70134
70325
|
const BILL_ATTRIBUTES = ['The Legend', 'The Location', 'The Moment', 'The Trend', 'The Innovation'];
|
|
70135
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));
|
|
@@ -70137,6 +70328,12 @@ const YourBondsModal = ({ onDismiss, userBill }) => {
|
|
|
70137
70328
|
setImgLoaded(true);
|
|
70138
70329
|
};
|
|
70139
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]);
|
|
70140
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: {
|
|
70141
70338
|
position: 'absolute',
|
|
70142
70339
|
top: 'calc(50% - 24px)',
|
|
@@ -70162,24 +70359,32 @@ const YourBondsModal = ({ onDismiss, userBill }) => {
|
|
|
70162
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)))
|
|
70163
70360
|
: BILL_ATTRIBUTES.map((attrib) => {
|
|
70164
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));
|
|
70165
|
-
}) }) })) })] }), 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: {
|
|
70166
70363
|
fontSize: ['10px', '10px', '10px', '12px'],
|
|
70167
70364
|
fontWeight: [500, 500, 500, 400],
|
|
70168
70365
|
paddingLeft: '10px',
|
|
70169
|
-
}, 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: {
|
|
70170
70367
|
fontSize: ['10px', '10px', '10px', '12px'],
|
|
70171
70368
|
fontWeight: [500, 500, 500, 400],
|
|
70172
70369
|
paddingLeft: '10px',
|
|
70173
|
-
}, 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: {
|
|
70174
70379
|
width: '100%',
|
|
70175
70380
|
background: '#DE62F366',
|
|
70176
70381
|
justifyContent: 'center',
|
|
70177
70382
|
borderRadius: 'normal',
|
|
70178
|
-
}, 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) => {
|
|
70179
70384
|
var _a;
|
|
70180
70385
|
event.stopPropagation();
|
|
70181
70386
|
switchChain({ chainId: (_a = userBill === null || userBill === void 0 ? void 0 : userBill.bond) === null || _a === void 0 ? void 0 : _a.chainId });
|
|
70182
|
-
}, 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) => {
|
|
70183
70388
|
event.stopPropagation();
|
|
70184
70389
|
handleClaim(userBill === null || userBill === void 0 ? void 0 : userBill.id, userBill === null || userBill === void 0 ? void 0 : userBill.address);
|
|
70185
70390
|
}, children: isPendingCliff
|
|
@@ -70282,7 +70487,7 @@ const UserBondRow = ({ bill }) => {
|
|
|
70282
70487
|
const { isLoading: isConfirming, isSuccess: isConfirmed } = useMonitorTxHash(claimTxHash, bill.bond.chainId);
|
|
70283
70488
|
const [loadingTx, setLoadingTx] = useState(false);
|
|
70284
70489
|
const load = loadingTx || (isConfirming && !isConfirmed);
|
|
70285
|
-
const [onOpenPurchasedBond] = useModal(jsx$2(YourBondsModal, {
|
|
70490
|
+
const [onOpenPurchasedBond] = useModal(jsx$2(YourBondsModal, { bill: bill }));
|
|
70286
70491
|
const handleClaim = (billId, billAddress) => __awaiter$9(void 0, void 0, void 0, function* () {
|
|
70287
70492
|
var _a;
|
|
70288
70493
|
const address = billAddress;
|
|
@@ -70345,189 +70550,6 @@ const UserBondRow = ({ bill }) => {
|
|
|
70345
70550
|
: 'Claim' })) })] })] }));
|
|
70346
70551
|
};
|
|
70347
70552
|
|
|
70348
|
-
function useBondsList() {
|
|
70349
|
-
const realTime = useURLByEnvironment('realTimeApi');
|
|
70350
|
-
const apiUrl = useURLByEnvironment('apiV2');
|
|
70351
|
-
return useQuery({
|
|
70352
|
-
queryKey: [QUERY_KEYS.BONDS_LIST],
|
|
70353
|
-
queryFn: () => getBondsList(realTime, apiUrl),
|
|
70354
|
-
staleTime: Infinity,
|
|
70355
|
-
refetchOnWindowFocus: false,
|
|
70356
|
-
});
|
|
70357
|
-
}
|
|
70358
|
-
const getBondsList = (realTimeapiURL, apiUrl) => __awaiter$9(void 0, void 0, void 0, function* () {
|
|
70359
|
-
try {
|
|
70360
|
-
const response = yield axios.get(`${realTimeapiURL}/utils/bonds`);
|
|
70361
|
-
return response.data;
|
|
70362
|
-
}
|
|
70363
|
-
catch (e) {
|
|
70364
|
-
reportError({
|
|
70365
|
-
apiUrl,
|
|
70366
|
-
error: e,
|
|
70367
|
-
extraInfo: { type: 'getBondsList', e },
|
|
70368
|
-
});
|
|
70369
|
-
return [];
|
|
70370
|
-
}
|
|
70371
|
-
});
|
|
70372
|
-
|
|
70373
|
-
/* MODIFIED FUNCTION FROM FRONTEND SPECIFICALLY FOR THE SDK */
|
|
70374
|
-
const fetchUserOwnedBillsDataAsync = (chainId, account, bondData, tokenPrices) => __awaiter$9(void 0, void 0, void 0, function* () {
|
|
70375
|
-
try {
|
|
70376
|
-
const bonds = bondData;
|
|
70377
|
-
// Fetch and set user owned bill data without NFT Data
|
|
70378
|
-
const userOwnedBills = yield fetchUserOwnedBills(chainId, account, bonds, tokenPrices);
|
|
70379
|
-
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()); }));
|
|
70380
|
-
const userOwnedBillsData = bonds.map((bill, i) => ({
|
|
70381
|
-
index: bill.index,
|
|
70382
|
-
userOwnedBills: mapUserOwnedBills[i],
|
|
70383
|
-
}));
|
|
70384
|
-
const combinedData = userOwnedBillsData.map((data) => {
|
|
70385
|
-
const enrichedUserBills = data.userOwnedBills.map((bill) => {
|
|
70386
|
-
return Object.assign({}, bill);
|
|
70387
|
-
});
|
|
70388
|
-
return Object.assign(Object.assign({}, data), { userOwnedBills: enrichedUserBills });
|
|
70389
|
-
});
|
|
70390
|
-
return Promise.resolve(combinedData);
|
|
70391
|
-
}
|
|
70392
|
-
catch (error) {
|
|
70393
|
-
console.error('Error fetching user owned bills data:', error);
|
|
70394
|
-
return Promise.reject(error);
|
|
70395
|
-
}
|
|
70396
|
-
});
|
|
70397
|
-
/* MODIFIED FUNCTION FROM FRONTEND SPECIFICALLY FOR THE SDK */
|
|
70398
|
-
const fetchUserOwnedBills = (chainId, account, bonds, tokenPrices) => __awaiter$9(void 0, void 0, void 0, function* () {
|
|
70399
|
-
var _a, _b, _c, _d, _e, _f;
|
|
70400
|
-
// Maps all the bills in the list repo to make a call to each of them to get Bills Id, meaning purchased bill ids
|
|
70401
|
-
const billIdCalls = bonds.map((b) => {
|
|
70402
|
-
var _a;
|
|
70403
|
-
return ({
|
|
70404
|
-
address: (_a = b.contractAddress[b.chainId]) !== null && _a !== void 0 ? _a : '',
|
|
70405
|
-
name: 'getBillIds',
|
|
70406
|
-
params: [account],
|
|
70407
|
-
});
|
|
70408
|
-
});
|
|
70409
|
-
const billIds = yield multicall(chainId, BOND_ABI, billIdCalls, true, 15);
|
|
70410
|
-
const billDataCalls = [];
|
|
70411
|
-
const billVersions = [];
|
|
70412
|
-
billIds.forEach((idArray, index) => idArray[0].forEach((id) => id.gt(0) &&
|
|
70413
|
-
(billDataCalls.push({
|
|
70414
|
-
address: bonds[index].contractAddress[bonds[index].chainId],
|
|
70415
|
-
name: bonds[index].billVersion !== types.BillVersion.V1 ? 'getBillInfo' : 'billInfo',
|
|
70416
|
-
params: [id],
|
|
70417
|
-
bond: bonds[index],
|
|
70418
|
-
}),
|
|
70419
|
-
billDataCalls.push({
|
|
70420
|
-
address: bonds[index].contractAddress[bonds[index].chainId],
|
|
70421
|
-
name: bonds[index].billVersion !== types.BillVersion.V1 ? 'claimablePayout' : 'pendingPayoutFor',
|
|
70422
|
-
params: [id],
|
|
70423
|
-
bond: bonds[index],
|
|
70424
|
-
}),
|
|
70425
|
-
billVersions.push(bonds[index].billVersion))));
|
|
70426
|
-
const billData = yield multicall(chainId, BOND_ABI, billDataCalls, true, 150);
|
|
70427
|
-
const result = [];
|
|
70428
|
-
for (let i = 0; i < billVersions.length; i++) {
|
|
70429
|
-
const billPos = i === 0 ? 0 : i * 2;
|
|
70430
|
-
let bond = billDataCalls[billPos].bond;
|
|
70431
|
-
// const principalTokenPrice = tokenPrices.find(
|
|
70432
|
-
// (tokenPrice) =>
|
|
70433
|
-
// tokenPrice.address?.toLowerCase() === bond?.lpToken?.address?.[bond.chainId]?.toLowerCase() &&
|
|
70434
|
-
// tokenPrice.chainId === bond.chainId,
|
|
70435
|
-
// )?.price
|
|
70436
|
-
const payoutTokenPrice = (_a = tokenPrices.find((tokenPrice) => {
|
|
70437
|
-
var _a, _b, _c, _d;
|
|
70438
|
-
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()) &&
|
|
70439
|
-
tokenPrice.chainId === bond.chainId;
|
|
70440
|
-
})) === null || _a === void 0 ? void 0 : _a.price;
|
|
70441
|
-
bond = Object.assign(Object.assign({}, bond), { payoutTokenPrice: payoutTokenPrice });
|
|
70442
|
-
const data = billVersions[i] !== types.BillVersion.V1
|
|
70443
|
-
? {
|
|
70444
|
-
address: billDataCalls[billPos].address,
|
|
70445
|
-
id: billDataCalls[billPos].params[0].toString(),
|
|
70446
|
-
payout: new BigNumber$1((_b = billData[billPos][0]) === null || _b === void 0 ? void 0 : _b.payout.toString())
|
|
70447
|
-
.minus((_c = billData[billPos][0]) === null || _c === void 0 ? void 0 : _c.payoutClaimed.toString())
|
|
70448
|
-
.toString(),
|
|
70449
|
-
billNftAddress: bond.billNnftAddress[bond.chainId],
|
|
70450
|
-
vesting: (_d = billData[billPos][0]) === null || _d === void 0 ? void 0 : _d.vesting.toString(),
|
|
70451
|
-
lastBlockTimestamp: (_e = billData[billPos][0]) === null || _e === void 0 ? void 0 : _e.lastClaimTimestamp.toString(),
|
|
70452
|
-
truePricePaid: (_f = billData[billPos][0]) === null || _f === void 0 ? void 0 : _f.truePricePaid.toString(),
|
|
70453
|
-
pendingRewards: billData[billPos + 1][0].toString(),
|
|
70454
|
-
bond,
|
|
70455
|
-
}
|
|
70456
|
-
: {
|
|
70457
|
-
address: billDataCalls[billPos].address,
|
|
70458
|
-
id: billDataCalls[billPos].params[0].toString(),
|
|
70459
|
-
payout: billData[billPos][0].toString(),
|
|
70460
|
-
billNftAddress: bond.billNnftAddress[bond.chainId],
|
|
70461
|
-
vesting: billData[billPos][1].toString(),
|
|
70462
|
-
lastBlockTimestamp: billData[billPos][2].toString(),
|
|
70463
|
-
truePricePaid: billData[billPos][3].toString(),
|
|
70464
|
-
pendingRewards: billData[billPos + 1][0].toString(),
|
|
70465
|
-
bond,
|
|
70466
|
-
};
|
|
70467
|
-
result.push(data);
|
|
70468
|
-
}
|
|
70469
|
-
return result;
|
|
70470
|
-
});
|
|
70471
|
-
|
|
70472
|
-
function useUserBonds() {
|
|
70473
|
-
var _a;
|
|
70474
|
-
// First fetch the full list of bonds
|
|
70475
|
-
const { data: bondList } = useBondsList();
|
|
70476
|
-
const { address } = useAccount();
|
|
70477
|
-
const SDKConfig = useSDKConfig();
|
|
70478
|
-
const { data: tokenPrices } = useTokenPrices();
|
|
70479
|
-
const chains = SDKConfig === null || SDKConfig === void 0 ? void 0 : SDKConfig.chains;
|
|
70480
|
-
const apiUrl = (_a = SDKConfig === null || SDKConfig === void 0 ? void 0 : SDKConfig.urls) === null || _a === void 0 ? void 0 : _a.apiV2;
|
|
70481
|
-
// Once the full list is fetched, fetch user's purchased bonds
|
|
70482
|
-
return useQuery({
|
|
70483
|
-
queryKey: [QUERY_KEYS.USER_BONDS, address],
|
|
70484
|
-
queryFn: () => getUserBonds(address, bondList, chains, tokenPrices, apiUrl),
|
|
70485
|
-
refetchOnWindowFocus: false,
|
|
70486
|
-
refetchInterval: 60000,
|
|
70487
|
-
enabled: !!bondList && !!address && !!tokenPrices,
|
|
70488
|
-
});
|
|
70489
|
-
}
|
|
70490
|
-
const getUserBonds = (account, bondList, chains, tokenPrices, apiUrl) => __awaiter$9(void 0, void 0, void 0, function* () {
|
|
70491
|
-
try {
|
|
70492
|
-
const bondsByChain = bondList.reduce((acc, bond) => {
|
|
70493
|
-
var _a;
|
|
70494
|
-
// Exclude ACF to ABOND bonds, fixed price bonds, and migration bonds
|
|
70495
|
-
if (((_a = bond.contractAddress[bond.chainId]) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === ACF_TO_ABOND.toLowerCase() ||
|
|
70496
|
-
bond.billVersion === types.BillVersion.FixedPrice ||
|
|
70497
|
-
bond.billType === 'migration') {
|
|
70498
|
-
return acc; // Skip this bond
|
|
70499
|
-
}
|
|
70500
|
-
// Only process bonds that belong to the specified chains
|
|
70501
|
-
if (chains.includes(bond.chainId)) {
|
|
70502
|
-
// Initialize acc[bond.chainId] if it doesn't exist yet
|
|
70503
|
-
if (!acc[bond.chainId]) {
|
|
70504
|
-
acc[bond.chainId] = [];
|
|
70505
|
-
}
|
|
70506
|
-
// Safely push the bond to the array
|
|
70507
|
-
acc[bond.chainId].push(bond);
|
|
70508
|
-
}
|
|
70509
|
-
return acc;
|
|
70510
|
-
}, {});
|
|
70511
|
-
const results = yield Promise.allSettled(chains
|
|
70512
|
-
.filter((chain) => bondsByChain[chain])
|
|
70513
|
-
.map((chain) => fetchUserOwnedBillsDataAsync(chain, account, bondsByChain[chain], tokenPrices)));
|
|
70514
|
-
// Filter out only fulfilled promises
|
|
70515
|
-
const fulfilledResults = results
|
|
70516
|
-
.filter((result) => result.status === 'fulfilled')
|
|
70517
|
-
.map((result) => result.value);
|
|
70518
|
-
return fulfilledResults.flat().flatMap((result) => result.userOwnedBills);
|
|
70519
|
-
}
|
|
70520
|
-
catch (e) {
|
|
70521
|
-
reportError({
|
|
70522
|
-
apiUrl,
|
|
70523
|
-
error: e,
|
|
70524
|
-
extraInfo: { type: 'getUserBonds', bondList, chains, e },
|
|
70525
|
-
account,
|
|
70526
|
-
});
|
|
70527
|
-
return [];
|
|
70528
|
-
}
|
|
70529
|
-
});
|
|
70530
|
-
|
|
70531
70553
|
const RainbowKitButton = () => {
|
|
70532
70554
|
return (jsx$2(ConnectButton$1.Custom, { children: ({ openConnectModal }) => {
|
|
70533
70555
|
return (jsx$2(Button, { fullWidth: true, onClick: () => {
|
|
@@ -78690,30 +78712,6 @@ const useIsMobile = () => {
|
|
|
78690
78712
|
return isMobile;
|
|
78691
78713
|
};
|
|
78692
78714
|
|
|
78693
|
-
var ABTestKeys;
|
|
78694
|
-
(function (ABTestKeys) {
|
|
78695
|
-
ABTestKeys["BOND_DESCRIPTION"] = "bondDescription";
|
|
78696
|
-
ABTestKeys["BOND_BUY_BUTTON"] = "bondBuyButton";
|
|
78697
|
-
ABTestKeys["BOND_BUY_ARR"] = "bondBuyArr";
|
|
78698
|
-
})(ABTestKeys || (ABTestKeys = {}));
|
|
78699
|
-
function useABTesting({ key, defaultValue = (Math.random() < 0.5).toString(), }) {
|
|
78700
|
-
const { cookie, updateCookie } = useCookie(QUERY_KEYS.AB_TEST_VALUE, null);
|
|
78701
|
-
let abTestValue = '';
|
|
78702
|
-
let parseCookie = null;
|
|
78703
|
-
if (cookie === null || cookie === undefined || cookie[key] === undefined) {
|
|
78704
|
-
parseCookie = Object.assign(Object.assign({}, cookie), { [key]: defaultValue.toString() });
|
|
78705
|
-
abTestValue = defaultValue.toString();
|
|
78706
|
-
updateCookie(parseCookie);
|
|
78707
|
-
}
|
|
78708
|
-
if (cookie) {
|
|
78709
|
-
parseCookie = cookie;
|
|
78710
|
-
if (parseCookie && parseCookie[key]) {
|
|
78711
|
-
abTestValue = parseCookie[key].toString();
|
|
78712
|
-
}
|
|
78713
|
-
}
|
|
78714
|
-
return { abTestValue };
|
|
78715
|
-
}
|
|
78716
|
-
|
|
78717
78715
|
const ProgressBar = ({ value, color = 'text' }) => {
|
|
78718
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: {
|
|
78719
78717
|
width: `${value <= 3 ? 3 : value}%`,
|
|
@@ -78739,10 +78737,9 @@ const ProgressBarWrapper = ({ title, value, style, showTooltip, toolTipPlacement
|
|
|
78739
78737
|
var ProgressBarWrapper$1 = React__default.memo(ProgressBarWrapper);
|
|
78740
78738
|
|
|
78741
78739
|
const BondCards$1 = ({ bondData }) => {
|
|
78742
|
-
var _a, _b
|
|
78740
|
+
var _a, _b;
|
|
78743
78741
|
const isMobile = useIsMobile();
|
|
78744
|
-
|
|
78745
|
-
const { abTestValue } = useABTesting({ key: ABTestKeys.BOND_BUY_ARR });
|
|
78742
|
+
useSDKConfig();
|
|
78746
78743
|
return (jsxs("div", { className: "bonds-cards", children: [jsxs("div", { className: "bond-card-block", sx: {
|
|
78747
78744
|
borderRadius: ['0px', '0px', '0px', 'normal'],
|
|
78748
78745
|
'&:first-of-type': {
|
|
@@ -78753,35 +78750,7 @@ const BondCards$1 = ({ bondData }) => {
|
|
|
78753
78750
|
borderBottomRightRadius: 'normal',
|
|
78754
78751
|
borderBottomLeftRadius: 'normal',
|
|
78755
78752
|
},
|
|
78756
|
-
}, 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' })] }),
|
|
78757
|
-
borderRadius: ['0px', '0px', '0px', 'normal'],
|
|
78758
|
-
'&:first-of-type': {
|
|
78759
|
-
borderTopRightRadius: 'normal',
|
|
78760
|
-
borderTopLeftRadius: 'normal',
|
|
78761
|
-
},
|
|
78762
|
-
'&:last-of-type': {
|
|
78763
|
-
borderBottomRightRadius: 'normal',
|
|
78764
|
-
borderBottomLeftRadius: 'normal',
|
|
78765
|
-
},
|
|
78766
|
-
}, 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) &&
|
|
78767
|
-
bondData.billVersion === types.BillVersion.V4 &&
|
|
78768
|
-
((_a = findHighestTrueBondPrice(TIERS_WEIGHT[types.LaunchBondTiers.Legend], bondData)) === null || _a === void 0 ? void 0 : _a.bonusWithFee) > 0 ? (jsxs(Flex, { sx: {
|
|
78769
|
-
p: '3px 6px',
|
|
78770
|
-
border: '1px solid var(--theme-ui-colors-primaryButton)',
|
|
78771
|
-
borderRadius: 'normal',
|
|
78772
|
-
background: 'transparent',
|
|
78773
|
-
position: 'relative',
|
|
78774
|
-
overflow: 'hidden',
|
|
78775
|
-
}, children: [jsx$2(Flex, { sx: {
|
|
78776
|
-
position: 'absolute',
|
|
78777
|
-
width: '100%',
|
|
78778
|
-
height: '100%',
|
|
78779
|
-
top: 0,
|
|
78780
|
-
left: 0,
|
|
78781
|
-
zIndex: 1,
|
|
78782
|
-
background: 'primaryButton',
|
|
78783
|
-
opacity: 0.3,
|
|
78784
|
-
} }), 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: {
|
|
78785
78754
|
borderRadius: ['0px', '0px', '0px', 'normal'],
|
|
78786
78755
|
'&:first-of-type': {
|
|
78787
78756
|
borderTopRightRadius: 'normal',
|
|
@@ -78791,12 +78760,7 @@ const BondCards$1 = ({ bondData }) => {
|
|
|
78791
78760
|
borderBottomRightRadius: 'normal',
|
|
78792
78761
|
borderBottomLeftRadius: 'normal',
|
|
78793
78762
|
},
|
|
78794
|
-
}, children: [jsxs(
|
|
78795
|
-
width: '127px',
|
|
78796
|
-
height: '25px',
|
|
78797
|
-
flexDirection: 'column',
|
|
78798
|
-
justifyContent: 'center',
|
|
78799
|
-
}, 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: {
|
|
78800
78764
|
borderRadius: ['0px', '0px', '0px', 'normal'],
|
|
78801
78765
|
'&:first-of-type': {
|
|
78802
78766
|
borderTopRightRadius: 'normal',
|
|
@@ -78806,7 +78770,7 @@ const BondCards$1 = ({ bondData }) => {
|
|
|
78806
78770
|
borderBottomRightRadius: 'normal',
|
|
78807
78771
|
borderBottomLeftRadius: 'normal',
|
|
78808
78772
|
},
|
|
78809
|
-
}, 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: {
|
|
78810
78774
|
borderRadius: ['0px', '0px', '0px', 'normal'],
|
|
78811
78775
|
'&:first-of-type': {
|
|
78812
78776
|
borderTopRightRadius: 'normal',
|
|
@@ -78816,7 +78780,12 @@ const BondCards$1 = ({ bondData }) => {
|
|
|
78816
78780
|
borderBottomRightRadius: 'normal',
|
|
78817
78781
|
borderBottomLeftRadius: 'normal',
|
|
78818
78782
|
},
|
|
78819
|
-
}, 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) })] })] }));
|
|
78820
78789
|
};
|
|
78821
78790
|
|
|
78822
78791
|
const Estimations = ({ depositAmount, bondData, youSpendString, isZap, fetchingZapQuote, zapError, }) => {
|
|
@@ -79206,17 +79175,6 @@ const BuyBond = ({ onDismiss, bondAddress, bondChain, handlePurchasedBond, isPro
|
|
|
79206
79175
|
const { data: userPoints } = useTierPoints();
|
|
79207
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()); });
|
|
79208
79177
|
const isMobile = useIsMobile();
|
|
79209
|
-
const { abTestValue } = useABTesting({ key: ABTestKeys.BOND_BUY_ARR });
|
|
79210
|
-
let reason = '';
|
|
79211
|
-
let trackOpenModal = '';
|
|
79212
|
-
if (isMobile) {
|
|
79213
|
-
reason = abTestValue === 'true' ? 'bondBuyMobile' : 'bondBuyRemainingMobile';
|
|
79214
|
-
trackOpenModal = abTestValue === 'true' ? 'openModalARRMobile' : 'openModalRemainingMobile';
|
|
79215
|
-
}
|
|
79216
|
-
else {
|
|
79217
|
-
reason = abTestValue === 'true' ? 'bondBuyARRDesktop' : 'bondBuyRemainingDesktop';
|
|
79218
|
-
trackOpenModal = abTestValue === 'true' ? 'openModalARRDesktop' : 'openModalRemainingDesktop';
|
|
79219
|
-
}
|
|
79220
79178
|
// Tier Gating
|
|
79221
79179
|
const userTier = getUserTier(userPoints !== null && userPoints !== void 0 ? userPoints : '0');
|
|
79222
79180
|
const minTier = (bondData === null || bondData === void 0 ? void 0 : bondData.minTier) !== undefined ? bondData.minTier : null;
|
|
@@ -79314,7 +79272,7 @@ const BuyBond = ({ onDismiss, bondAddress, bondChain, handlePurchasedBond, isPro
|
|
|
79314
79272
|
});
|
|
79315
79273
|
if (hash) {
|
|
79316
79274
|
setBuyTxHash(hash);
|
|
79317
|
-
yield sendReferenceId(billAddress, userChainId, hash
|
|
79275
|
+
yield sendReferenceId(billAddress, userChainId, hash);
|
|
79318
79276
|
handlePurchasedBond === null || handlePurchasedBond === void 0 ? void 0 : handlePurchasedBond(hash);
|
|
79319
79277
|
track({
|
|
79320
79278
|
event: 'bond',
|
|
@@ -79367,7 +79325,7 @@ const BuyBond = ({ onDismiss, bondAddress, bondChain, handlePurchasedBond, isPro
|
|
|
79367
79325
|
});
|
|
79368
79326
|
if (hash) {
|
|
79369
79327
|
setBuyTxHash(hash);
|
|
79370
|
-
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);
|
|
79371
79329
|
handlePurchasedBond === null || handlePurchasedBond === void 0 ? void 0 : handlePurchasedBond(hash);
|
|
79372
79330
|
track({
|
|
79373
79331
|
event: 'zap',
|
|
@@ -79444,7 +79402,6 @@ const BuyBond = ({ onDismiss, bondAddress, bondChain, handlePurchasedBond, isPro
|
|
|
79444
79402
|
const [hasChecked, setHasChecked] = useState(false);
|
|
79445
79403
|
const [hasCheckedTrack, setHasCheckedTrack] = useState(false);
|
|
79446
79404
|
useEffect(() => {
|
|
79447
|
-
var _a;
|
|
79448
79405
|
if (inputCurrencyBalance !== undefined &&
|
|
79449
79406
|
inputCurrencyBalance === '0' &&
|
|
79450
79407
|
!hasChecked &&
|
|
@@ -79457,14 +79414,6 @@ const BuyBond = ({ onDismiss, bondAddress, bondChain, handlePurchasedBond, isPro
|
|
|
79457
79414
|
}
|
|
79458
79415
|
if (bondData && !hasCheckedTrack) {
|
|
79459
79416
|
setHasCheckedTrack(true);
|
|
79460
|
-
track({
|
|
79461
|
-
event: 'trackOpenModal',
|
|
79462
|
-
chain: bondData.chainId,
|
|
79463
|
-
data: {
|
|
79464
|
-
cat: trackOpenModal,
|
|
79465
|
-
bond: (_a = bondData === null || bondData === void 0 ? void 0 : bondData.earnToken.symbol) !== null && _a !== void 0 ? _a : '',
|
|
79466
|
-
},
|
|
79467
|
-
});
|
|
79468
79417
|
}
|
|
79469
79418
|
}, [inputCurrencyBalance, sortedZapList, bondData]);
|
|
79470
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
|
|
@@ -79550,7 +79499,7 @@ const ModalHandler = ({ onDismiss, bondAddress, bondChain, }) => {
|
|
|
79550
79499
|
refetch();
|
|
79551
79500
|
}
|
|
79552
79501
|
}, [billId]);
|
|
79553
|
-
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: () => {
|
|
79554
79503
|
window.history.pushState({}, '', `${locationPath !== '/bonds' ? locationPath : '/bonds'}`);
|
|
79555
79504
|
onDismiss === null || onDismiss === void 0 ? void 0 : onDismiss();
|
|
79556
79505
|
} }));
|
|
@@ -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;
|