@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.
Files changed (2) hide show
  1. package/dist/main.js +33 -40
  2. 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, _g;
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({ address: bonds[index].contractAddress[bonds[index].chainId], name: 'billNft' }),
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 < billsPendingRewardCall.length; i++) {
71567
- const billDataPos = i === 0 ? 0 : i * 2;
71568
- let bond = billsPendingRewardCall[i].bond;
71569
- bond = Object.assign(Object.assign({}, bond), { payoutTokenPrice: (_a = tokenPrices.find((tokenPrice) => {
71570
- var _a, _b, _c, _d;
71571
- 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()) &&
71572
- tokenPrice.chainId === bond.chainId;
71573
- })) === null || _a === void 0 ? void 0 : _a.price, principalTokenPrice: (_b = tokenPrices.find((tokenPrice) => {
71574
- var _a, _b, _c, _d;
71575
- return ((_a = tokenPrice.address) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === ((_d = (_c = (_b = bond === null || bond === void 0 ? void 0 : bond.lpToken) === 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()) &&
71576
- tokenPrice.chainId === bond.chainId;
71577
- })) === null || _b === void 0 ? void 0 : _b.price });
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: billsPendingRewardCall[i].address,
71581
- id: billsPendingRewardCall[i].params[0].toString(),
71582
- payout: new BigNumber$1((_c = billData[billDataPos][0]) === null || _c === void 0 ? void 0 : _c.payout.toString())
71583
- .minus((_d = billData[billDataPos][0]) === null || _d === void 0 ? void 0 : _d.payoutClaimed.toString())
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: billData[billDataPos + 1][0].toString(),
71586
- vesting: (_e = billData[billDataPos][0]) === null || _e === void 0 ? void 0 : _e.vesting.toString(),
71587
- lastBlockTimestamp: (_f = billData[billDataPos][0]) === null || _f === void 0 ? void 0 : _f.lastClaimTimestamp.toString(),
71588
- truePricePaid: (_g = billData[billDataPos][0]) === null || _g === void 0 ? void 0 : _g.truePricePaid.toString(),
71589
- pendingRewards: pendingRewardsCall[i][0].toString(),
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: billsPendingRewardCall[i].address,
71594
- id: billsPendingRewardCall[i].params[0].toString(),
71595
- payout: billData[billDataPos][0].toString(),
71596
- billNftAddress: billData[billDataPos + 1][0].toString(),
71597
- vesting: billData[billDataPos][1].toString(),
71598
- lastBlockTimestamp: billData[billDataPos][2].toString(),
71599
- truePricePaid: billData[billDataPos][3].toString(),
71600
- pendingRewards: pendingRewardsCall[i][0].toString(),
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);
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "Ape Bond SDK",
4
4
  "author": "Ape Bond",
5
5
  "license": "MIT",
6
- "version": "2.6.11",
6
+ "version": "2.6.12",
7
7
  "module": "dist/main.js",
8
8
  "type": "module",
9
9
  "types": "dist/main.d.ts",