@ape.swap/bonds-sdk 2.6.11 → 2.6.12
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 +33 -40
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -71525,7 +71525,7 @@ const fetchUserOwnedBillsDataAsync = (chainId, account, bondData, tokenPrices) =
|
|
|
71525
71525
|
});
|
|
71526
71526
|
/* MODIFIED FUNCTION FROM FRONTEND SPECIFICALLY FOR THE SDK */
|
|
71527
71527
|
const fetchUserOwnedBills = (chainId, account, bonds, tokenPrices) => __awaiter$9(void 0, void 0, void 0, function* () {
|
|
71528
|
-
var _a, _b, _c, _d, _e, _f
|
|
71528
|
+
var _a, _b, _c, _d, _e, _f;
|
|
71529
71529
|
// Maps all the bills in the list repo to make a call to each of them to get Bills Id, meaning purchased bill ids
|
|
71530
71530
|
const billIdCalls = bonds.map((b) => {
|
|
71531
71531
|
var _a;
|
|
@@ -71536,10 +71536,8 @@ const fetchUserOwnedBills = (chainId, account, bonds, tokenPrices) => __awaiter$
|
|
|
71536
71536
|
});
|
|
71537
71537
|
});
|
|
71538
71538
|
const billIds = yield multicall(chainId, BOND_ABI, billIdCalls, true, 15);
|
|
71539
|
-
const billsPendingRewardCall = [];
|
|
71540
71539
|
const billDataCalls = [];
|
|
71541
71540
|
const billVersions = [];
|
|
71542
|
-
const billNFTCalls = [];
|
|
71543
71541
|
billIds.forEach((idArray, index) => idArray[0].forEach((id) => id.gt(0) &&
|
|
71544
71542
|
(billDataCalls.push({
|
|
71545
71543
|
address: bonds[index].contractAddress[bonds[index].chainId],
|
|
@@ -71547,13 +71545,7 @@ const fetchUserOwnedBills = (chainId, account, bonds, tokenPrices) => __awaiter$
|
|
|
71547
71545
|
params: [id],
|
|
71548
71546
|
bond: bonds[index],
|
|
71549
71547
|
}),
|
|
71550
|
-
billDataCalls.push({
|
|
71551
|
-
billNFTCalls.push({
|
|
71552
|
-
address: bonds[index].billNnftAddress[bonds[index].chainId],
|
|
71553
|
-
name: 'vestedPayout',
|
|
71554
|
-
params: [id],
|
|
71555
|
-
}),
|
|
71556
|
-
billsPendingRewardCall.push({
|
|
71548
|
+
billDataCalls.push({
|
|
71557
71549
|
address: bonds[index].contractAddress[bonds[index].chainId],
|
|
71558
71550
|
name: bonds[index].billVersion !== types.BillVersion.V1 ? 'claimablePayout' : 'pendingPayoutFor',
|
|
71559
71551
|
params: [id],
|
|
@@ -71561,43 +71553,44 @@ const fetchUserOwnedBills = (chainId, account, bonds, tokenPrices) => __awaiter$
|
|
|
71561
71553
|
}),
|
|
71562
71554
|
billVersions.push(bonds[index].billVersion))));
|
|
71563
71555
|
const billData = yield multicall(chainId, BOND_ABI, billDataCalls, true, 150);
|
|
71564
|
-
const pendingRewardsCall = yield multicall(chainId, BOND_ABI, billsPendingRewardCall);
|
|
71565
71556
|
const result = [];
|
|
71566
|
-
for (let i = 0; i <
|
|
71567
|
-
const
|
|
71568
|
-
let bond =
|
|
71569
|
-
|
|
71570
|
-
|
|
71571
|
-
|
|
71572
|
-
|
|
71573
|
-
|
|
71574
|
-
|
|
71575
|
-
|
|
71576
|
-
|
|
71577
|
-
|
|
71557
|
+
for (let i = 0; i < billVersions.length; i++) {
|
|
71558
|
+
const billPos = i === 0 ? 0 : i * 2;
|
|
71559
|
+
let bond = billDataCalls[billPos].bond;
|
|
71560
|
+
// const principalTokenPrice = tokenPrices.find(
|
|
71561
|
+
// (tokenPrice) =>
|
|
71562
|
+
// tokenPrice.address?.toLowerCase() === bond?.lpToken?.address?.[bond.chainId]?.toLowerCase() &&
|
|
71563
|
+
// tokenPrice.chainId === bond.chainId,
|
|
71564
|
+
// )?.price
|
|
71565
|
+
const payoutTokenPrice = (_a = tokenPrices.find((tokenPrice) => {
|
|
71566
|
+
var _a, _b, _c, _d;
|
|
71567
|
+
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()) &&
|
|
71568
|
+
tokenPrice.chainId === bond.chainId;
|
|
71569
|
+
})) === null || _a === void 0 ? void 0 : _a.price;
|
|
71570
|
+
bond = Object.assign(Object.assign({}, bond), { payoutTokenPrice: payoutTokenPrice });
|
|
71578
71571
|
const data = billVersions[i] !== types.BillVersion.V1
|
|
71579
71572
|
? {
|
|
71580
|
-
address:
|
|
71581
|
-
id:
|
|
71582
|
-
payout: new BigNumber$1((
|
|
71583
|
-
.minus((
|
|
71573
|
+
address: billDataCalls[billPos].address,
|
|
71574
|
+
id: billDataCalls[billPos].params[0].toString(),
|
|
71575
|
+
payout: new BigNumber$1((_b = billData[billPos][0]) === null || _b === void 0 ? void 0 : _b.payout.toString())
|
|
71576
|
+
.minus((_c = billData[billPos][0]) === null || _c === void 0 ? void 0 : _c.payoutClaimed.toString())
|
|
71584
71577
|
.toString(),
|
|
71585
|
-
billNftAddress:
|
|
71586
|
-
vesting: (
|
|
71587
|
-
lastBlockTimestamp: (
|
|
71588
|
-
truePricePaid: (
|
|
71589
|
-
pendingRewards:
|
|
71578
|
+
billNftAddress: bond.billNnftAddress[bond.chainId],
|
|
71579
|
+
vesting: (_d = billData[billPos][0]) === null || _d === void 0 ? void 0 : _d.vesting.toString(),
|
|
71580
|
+
lastBlockTimestamp: (_e = billData[billPos][0]) === null || _e === void 0 ? void 0 : _e.lastClaimTimestamp.toString(),
|
|
71581
|
+
truePricePaid: (_f = billData[billPos][0]) === null || _f === void 0 ? void 0 : _f.truePricePaid.toString(),
|
|
71582
|
+
pendingRewards: billData[billPos + 1][0].toString(),
|
|
71590
71583
|
bond,
|
|
71591
71584
|
}
|
|
71592
71585
|
: {
|
|
71593
|
-
address:
|
|
71594
|
-
id:
|
|
71595
|
-
payout: billData[
|
|
71596
|
-
billNftAddress:
|
|
71597
|
-
vesting: billData[
|
|
71598
|
-
lastBlockTimestamp: billData[
|
|
71599
|
-
truePricePaid: billData[
|
|
71600
|
-
pendingRewards:
|
|
71586
|
+
address: billDataCalls[billPos].address,
|
|
71587
|
+
id: billDataCalls[billPos].params[0].toString(),
|
|
71588
|
+
payout: billData[billPos][0].toString(),
|
|
71589
|
+
billNftAddress: bond.billNnftAddress[bond.chainId],
|
|
71590
|
+
vesting: billData[billPos][1].toString(),
|
|
71591
|
+
lastBlockTimestamp: billData[billPos][2].toString(),
|
|
71592
|
+
truePricePaid: billData[billPos][3].toString(),
|
|
71593
|
+
pendingRewards: billData[billPos + 1][0].toString(),
|
|
71601
71594
|
bond,
|
|
71602
71595
|
};
|
|
71603
71596
|
result.push(data);
|