@ape.swap/bonds-sdk 3.0.67 → 3.0.68

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/main.js +259 -233
  2. package/package.json +1 -1
package/dist/main.js CHANGED
@@ -76226,6 +76226,233 @@ var BOND_2_4_0 = [
76226
76226
  }
76227
76227
  ];
76228
76228
 
76229
+ var ERC_20_ABI = [
76230
+ {
76231
+ constant: true,
76232
+ inputs: [
76233
+ ],
76234
+ name: "name",
76235
+ outputs: [
76236
+ {
76237
+ name: "",
76238
+ type: "string"
76239
+ }
76240
+ ],
76241
+ payable: false,
76242
+ stateMutability: "view",
76243
+ type: "function"
76244
+ },
76245
+ {
76246
+ constant: false,
76247
+ inputs: [
76248
+ {
76249
+ name: "_spender",
76250
+ type: "address"
76251
+ },
76252
+ {
76253
+ name: "_value",
76254
+ type: "uint256"
76255
+ }
76256
+ ],
76257
+ name: "approve",
76258
+ outputs: [
76259
+ {
76260
+ name: "",
76261
+ type: "bool"
76262
+ }
76263
+ ],
76264
+ payable: false,
76265
+ stateMutability: "nonpayable",
76266
+ type: "function"
76267
+ },
76268
+ {
76269
+ constant: true,
76270
+ inputs: [
76271
+ ],
76272
+ name: "totalSupply",
76273
+ outputs: [
76274
+ {
76275
+ name: "",
76276
+ type: "uint256"
76277
+ }
76278
+ ],
76279
+ payable: false,
76280
+ stateMutability: "view",
76281
+ type: "function"
76282
+ },
76283
+ {
76284
+ constant: false,
76285
+ inputs: [
76286
+ {
76287
+ name: "_from",
76288
+ type: "address"
76289
+ },
76290
+ {
76291
+ name: "_to",
76292
+ type: "address"
76293
+ },
76294
+ {
76295
+ name: "_value",
76296
+ type: "uint256"
76297
+ }
76298
+ ],
76299
+ name: "transferFrom",
76300
+ outputs: [
76301
+ {
76302
+ name: "",
76303
+ type: "bool"
76304
+ }
76305
+ ],
76306
+ payable: false,
76307
+ stateMutability: "nonpayable",
76308
+ type: "function"
76309
+ },
76310
+ {
76311
+ constant: true,
76312
+ inputs: [
76313
+ ],
76314
+ name: "decimals",
76315
+ outputs: [
76316
+ {
76317
+ name: "",
76318
+ type: "uint8"
76319
+ }
76320
+ ],
76321
+ payable: false,
76322
+ stateMutability: "view",
76323
+ type: "function"
76324
+ },
76325
+ {
76326
+ constant: true,
76327
+ inputs: [
76328
+ {
76329
+ name: "_owner",
76330
+ type: "address"
76331
+ }
76332
+ ],
76333
+ name: "balanceOf",
76334
+ outputs: [
76335
+ {
76336
+ name: "balance",
76337
+ type: "uint256"
76338
+ }
76339
+ ],
76340
+ payable: false,
76341
+ stateMutability: "view",
76342
+ type: "function"
76343
+ },
76344
+ {
76345
+ constant: true,
76346
+ inputs: [
76347
+ ],
76348
+ name: "symbol",
76349
+ outputs: [
76350
+ {
76351
+ name: "",
76352
+ type: "string"
76353
+ }
76354
+ ],
76355
+ payable: false,
76356
+ stateMutability: "view",
76357
+ type: "function"
76358
+ },
76359
+ {
76360
+ constant: false,
76361
+ inputs: [
76362
+ {
76363
+ name: "_to",
76364
+ type: "address"
76365
+ },
76366
+ {
76367
+ name: "_value",
76368
+ type: "uint256"
76369
+ }
76370
+ ],
76371
+ name: "transfer",
76372
+ outputs: [
76373
+ {
76374
+ name: "",
76375
+ type: "bool"
76376
+ }
76377
+ ],
76378
+ payable: false,
76379
+ stateMutability: "nonpayable",
76380
+ type: "function"
76381
+ },
76382
+ {
76383
+ constant: true,
76384
+ inputs: [
76385
+ {
76386
+ name: "_owner",
76387
+ type: "address"
76388
+ },
76389
+ {
76390
+ name: "_spender",
76391
+ type: "address"
76392
+ }
76393
+ ],
76394
+ name: "allowance",
76395
+ outputs: [
76396
+ {
76397
+ name: "",
76398
+ type: "uint256"
76399
+ }
76400
+ ],
76401
+ payable: false,
76402
+ stateMutability: "view",
76403
+ type: "function"
76404
+ },
76405
+ {
76406
+ payable: true,
76407
+ stateMutability: "payable",
76408
+ type: "fallback"
76409
+ },
76410
+ {
76411
+ anonymous: false,
76412
+ inputs: [
76413
+ {
76414
+ indexed: true,
76415
+ name: "owner",
76416
+ type: "address"
76417
+ },
76418
+ {
76419
+ indexed: true,
76420
+ name: "spender",
76421
+ type: "address"
76422
+ },
76423
+ {
76424
+ indexed: false,
76425
+ name: "value",
76426
+ type: "uint256"
76427
+ }
76428
+ ],
76429
+ name: "Approval",
76430
+ type: "event"
76431
+ },
76432
+ {
76433
+ anonymous: false,
76434
+ inputs: [
76435
+ {
76436
+ indexed: true,
76437
+ name: "from",
76438
+ type: "address"
76439
+ },
76440
+ {
76441
+ indexed: true,
76442
+ name: "to",
76443
+ type: "address"
76444
+ },
76445
+ {
76446
+ indexed: false,
76447
+ name: "value",
76448
+ type: "uint256"
76449
+ }
76450
+ ],
76451
+ name: "Transfer",
76452
+ type: "event"
76453
+ }
76454
+ ];
76455
+
76229
76456
  function useBondsData() {
76230
76457
  const { data: tokenPrices } = useTokenPrices();
76231
76458
  const { data: bondList } = useBondsList();
@@ -76275,7 +76502,7 @@ const getBondsData = (chains, realTimeApiURL, tokenPrices, bondList, apiUrl) =>
76275
76502
  const fetchBills = (chainId, tokenPrices, bills) => __awaiter$9(void 0, void 0, void 0, function* () {
76276
76503
  const billIds = [];
76277
76504
  const billCalls = bills.flatMap((bill) => {
76278
- var _a, _b, _c, _d;
76505
+ var _a, _b, _c, _d, _e;
76279
76506
  billIds.push(bill.index);
76280
76507
  return [
76281
76508
  // Get bill price with LP fees
@@ -76298,11 +76525,36 @@ const fetchBills = (chainId, tokenPrices, bills) => __awaiter$9(void 0, void 0,
76298
76525
  address: (_d = bill.contractAddress[bill.chainId]) !== null && _d !== void 0 ? _d : '',
76299
76526
  name: bill.billVersion !== types.BillVersion.V1 ? 'getMaxTotalPayout' : 'maxTotalPayout',
76300
76527
  },
76528
+ {
76529
+ address: (_e = bill.contractAddress[bill.chainId]) !== null && _e !== void 0 ? _e : '',
76530
+ name: 'customTreasury',
76531
+ },
76301
76532
  ];
76302
76533
  });
76303
76534
  const vals = yield multicall(chainId, BOND_2_4_0, billCalls);
76304
- const chunkSize = (vals === null || vals === void 0 ? void 0 : vals.length) / (bills === null || bills === void 0 ? void 0 : bills.length);
76305
- const chunkedBills = lodashExports.chunk(vals, chunkSize);
76535
+ // Prepare an additional multicall for `customTreasury` token balance
76536
+ const treasuryAddresses = vals
76537
+ .filter((_, i) => i % 5 === 4)
76538
+ .map((customTreasury) => customTreasury[0]); // Extract `customTreasury` from chunks
76539
+ const treasuryBalanceCalls = treasuryAddresses.map((treasuryAddress, i) => {
76540
+ var _a, _b, _c, _d;
76541
+ return ({
76542
+ address: (_d = (_c = (_b = (_a = bills === null || bills === void 0 ? void 0 : bills[i]) === null || _a === void 0 ? void 0 : _a.earnToken) === null || _b === void 0 ? void 0 : _b.address) === null || _c === void 0 ? void 0 : _c[chainId]) !== null && _d !== void 0 ? _d : '', // Use the earnToken's address as currency
76543
+ name: 'balanceOf',
76544
+ params: [treasuryAddress], // Fetch balance for the custom treasury
76545
+ });
76546
+ });
76547
+ const treasuryBalances = yield multicall(chainId, ERC_20_ABI, treasuryBalanceCalls);
76548
+ console.log(vals);
76549
+ const updatedVals = vals.reduce((acc, val, index) => {
76550
+ acc.push(val);
76551
+ if ((index + 1) % 5 === 0) {
76552
+ acc.push(treasuryBalances[(index + 1) / 5 - 1]); // Append the treasury balance after every set of bill values
76553
+ }
76554
+ return acc;
76555
+ }, []);
76556
+ const chunkSize = (updatedVals === null || updatedVals === void 0 ? void 0 : updatedVals.length) / (bills === null || bills === void 0 ? void 0 : bills.length);
76557
+ const chunkedBills = lodashExports.chunk(updatedVals, chunkSize);
76306
76558
  return cleanBillsData(billIds, chunkedBills, tokenPrices, chainId, bills);
76307
76559
  });
76308
76560
  const cleanBillsData = (billIds, chunkedBills, tokenPrices, chainId, bills) => {
@@ -76319,12 +76571,13 @@ const cleanBillsData = (billIds, chunkedBills, tokenPrices, chainId, bills) => {
76319
76571
  return ((_a = tokenPrice === null || tokenPrice === void 0 ? void 0 : tokenPrice.address) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === ((_d = (_c = (_b = bill === null || bill === void 0 ? void 0 : bill.earnToken) === null || _b === void 0 ? void 0 : _b.address) === null || _c === void 0 ? void 0 : _c[bill === null || bill === void 0 ? void 0 : bill.chainId]) === null || _d === void 0 ? void 0 : _d.toLowerCase()) &&
76320
76572
  (tokenPrice === null || tokenPrice === void 0 ? void 0 : tokenPrice.chainId) === chainId;
76321
76573
  })) === null || _c === void 0 ? void 0 : _c.price) !== null && _d !== void 0 ? _d : 0;
76322
- const [trueBillPrice, totalPayoutGiven, terms, maxTotalPayout] = chunk;
76574
+ const [trueBillPrice, totalPayoutGiven, terms, maxTotalPayout, , customTreasuryBalance] = chunk;
76323
76575
  const [, vestingTerm, , maxPayout] = terms;
76324
76576
  const tokensRemaining = new BigNumber$1(maxTotalPayout !== null && maxTotalPayout !== void 0 ? maxTotalPayout : '0')
76325
76577
  .minus(new BigNumber$1(totalPayoutGiven))
76326
76578
  .div(new BigNumber$1(10).pow((_e = bill === null || bill === void 0 ? void 0 : bill.earnToken.decimals[bill === null || bill === void 0 ? void 0 : bill.chainId]) !== null && _e !== void 0 ? _e : 18))
76327
- .toString();
76579
+ .toNumber();
76580
+ const treasuryBalance = getBalanceNumber(customTreasuryBalance);
76328
76581
  const bonus = getRawBonus(trueBillPrice, lpPrice, earnTokenPrice);
76329
76582
  const bonusWithFee = getBonusWithFee((_f = bill === null || bill === void 0 ? void 0 : bill.feeInPayout) !== null && _f !== void 0 ? _f : 0, trueBillPrice, lpPrice, earnTokenPrice);
76330
76583
  let trueBondPrices = [];
@@ -76351,7 +76604,7 @@ const cleanBillsData = (billIds, chunkedBills, tokenPrices, chainId, bills) => {
76351
76604
  }
76352
76605
  //I've added a ts ignore here due to some props marked as optional in the list repo which are actually not optional
76353
76606
  //@ts-ignore
76354
- const cleanedData = Object.assign(Object.assign({}, bill), { type: (_g = bill === null || bill === void 0 ? void 0 : bill.billType) !== null && _g !== void 0 ? _g : '', billAddress: (_h = bill === null || bill === void 0 ? void 0 : bill.contractAddress[bill === null || bill === void 0 ? void 0 : bill.chainId]) !== null && _h !== void 0 ? _h : '', billNftAddress: (_j = bill === null || bill === void 0 ? void 0 : bill.billNnftAddress[bill === null || bill === void 0 ? void 0 : bill.chainId]) !== null && _j !== void 0 ? _j : '', showcaseTokenName: (_m = (_l = (_k = bill === null || bill === void 0 ? void 0 : bill.showcaseToken) === null || _k === void 0 ? void 0 : _k.symbol) !== null && _l !== void 0 ? _l : bill === null || bill === void 0 ? void 0 : bill.earnToken.symbol) !== null && _m !== void 0 ? _m : '', trueBondPrices, principalTokenPrice: (_o = lpPrice === null || lpPrice === void 0 ? void 0 : lpPrice.toString()) !== null && _o !== void 0 ? _o : '0', payoutTokenPrice: (_p = earnTokenPrice === null || earnTokenPrice === void 0 ? void 0 : earnTokenPrice.toString()) !== null && _p !== void 0 ? _p : '0', tokensRemaining, maxTotalPayout: maxTotalPayout === null || maxTotalPayout === void 0 ? void 0 : maxTotalPayout.toString(), maxPayout: maxPayout === null || maxPayout === void 0 ? void 0 : maxPayout.toString(), totalPayoutGiven: totalPayoutGiven === null || totalPayoutGiven === void 0 ? void 0 : totalPayoutGiven.toString(), vestingTerm: vestingTerm.toNumber() });
76607
+ const cleanedData = Object.assign(Object.assign({}, bill), { type: (_g = bill === null || bill === void 0 ? void 0 : bill.billType) !== null && _g !== void 0 ? _g : '', billAddress: (_h = bill === null || bill === void 0 ? void 0 : bill.contractAddress[bill === null || bill === void 0 ? void 0 : bill.chainId]) !== null && _h !== void 0 ? _h : '', billNftAddress: (_j = bill === null || bill === void 0 ? void 0 : bill.billNnftAddress[bill === null || bill === void 0 ? void 0 : bill.chainId]) !== null && _j !== void 0 ? _j : '', showcaseTokenName: (_m = (_l = (_k = bill === null || bill === void 0 ? void 0 : bill.showcaseToken) === null || _k === void 0 ? void 0 : _k.symbol) !== null && _l !== void 0 ? _l : bill === null || bill === void 0 ? void 0 : bill.earnToken.symbol) !== null && _m !== void 0 ? _m : '', trueBondPrices, principalTokenPrice: (_o = lpPrice === null || lpPrice === void 0 ? void 0 : lpPrice.toString()) !== null && _o !== void 0 ? _o : '0', payoutTokenPrice: (_p = earnTokenPrice === null || earnTokenPrice === void 0 ? void 0 : earnTokenPrice.toString()) !== null && _p !== void 0 ? _p : '0', tokensRemaining: Math.min(treasuryBalance, tokensRemaining).toString(), maxTotalPayout: maxTotalPayout === null || maxTotalPayout === void 0 ? void 0 : maxTotalPayout.toString(), maxPayout: maxPayout === null || maxPayout === void 0 ? void 0 : maxPayout.toString(), totalPayoutGiven: totalPayoutGiven === null || totalPayoutGiven === void 0 ? void 0 : totalPayoutGiven.toString(), vestingTerm: vestingTerm.toNumber() });
76355
76608
  return cleanedData;
76356
76609
  });
76357
76610
  return data;
@@ -76493,233 +76746,6 @@ const TokenRow = ({ token, chainId, handleTokenSelect, tokenBalance, }) => {
76493
76746
  return (jsxs(Flex, { sx: { p: '8px', justifyContent: 'space-between', cursor: 'pointer', '&:hover': { background: 'white4' } }, onClick: () => handleTokenSelect(tokenAddress !== null && tokenAddress !== void 0 ? tokenAddress : ''), children: [jsxs(Flex, { children: [lodashExports.isArray(splited) ? (jsx$2(TokenImage, { symbol: splited[0], symbol2: splited[1], size: 28, chain: chainId })) : (jsx$2(TokenImage, { symbol: getSymbol(token, chainId), size: 28, chain: chainId })), jsx$2(Flex, { sx: { mx: '8px', lineHeight: '28px', fontSize: '14px' }, children: symbol })] }), address && (jsx$2(Flex, { sx: { fontSize: '14px' }, children: tokenBalance === '0' ? ('0') : !tokenBalance ? (jsx$2(Spinner, { size: 15 })) : (jsx$2(Fragment$1, { children: (_b = new BigNumber$1(tokenBalance !== null && tokenBalance !== void 0 ? tokenBalance : '0')) === null || _b === void 0 ? void 0 : _b.toPrecision(5) })) }))] }));
76494
76747
  };
76495
76748
 
76496
- var ERC_20_ABI = [
76497
- {
76498
- constant: true,
76499
- inputs: [
76500
- ],
76501
- name: "name",
76502
- outputs: [
76503
- {
76504
- name: "",
76505
- type: "string"
76506
- }
76507
- ],
76508
- payable: false,
76509
- stateMutability: "view",
76510
- type: "function"
76511
- },
76512
- {
76513
- constant: false,
76514
- inputs: [
76515
- {
76516
- name: "_spender",
76517
- type: "address"
76518
- },
76519
- {
76520
- name: "_value",
76521
- type: "uint256"
76522
- }
76523
- ],
76524
- name: "approve",
76525
- outputs: [
76526
- {
76527
- name: "",
76528
- type: "bool"
76529
- }
76530
- ],
76531
- payable: false,
76532
- stateMutability: "nonpayable",
76533
- type: "function"
76534
- },
76535
- {
76536
- constant: true,
76537
- inputs: [
76538
- ],
76539
- name: "totalSupply",
76540
- outputs: [
76541
- {
76542
- name: "",
76543
- type: "uint256"
76544
- }
76545
- ],
76546
- payable: false,
76547
- stateMutability: "view",
76548
- type: "function"
76549
- },
76550
- {
76551
- constant: false,
76552
- inputs: [
76553
- {
76554
- name: "_from",
76555
- type: "address"
76556
- },
76557
- {
76558
- name: "_to",
76559
- type: "address"
76560
- },
76561
- {
76562
- name: "_value",
76563
- type: "uint256"
76564
- }
76565
- ],
76566
- name: "transferFrom",
76567
- outputs: [
76568
- {
76569
- name: "",
76570
- type: "bool"
76571
- }
76572
- ],
76573
- payable: false,
76574
- stateMutability: "nonpayable",
76575
- type: "function"
76576
- },
76577
- {
76578
- constant: true,
76579
- inputs: [
76580
- ],
76581
- name: "decimals",
76582
- outputs: [
76583
- {
76584
- name: "",
76585
- type: "uint8"
76586
- }
76587
- ],
76588
- payable: false,
76589
- stateMutability: "view",
76590
- type: "function"
76591
- },
76592
- {
76593
- constant: true,
76594
- inputs: [
76595
- {
76596
- name: "_owner",
76597
- type: "address"
76598
- }
76599
- ],
76600
- name: "balanceOf",
76601
- outputs: [
76602
- {
76603
- name: "balance",
76604
- type: "uint256"
76605
- }
76606
- ],
76607
- payable: false,
76608
- stateMutability: "view",
76609
- type: "function"
76610
- },
76611
- {
76612
- constant: true,
76613
- inputs: [
76614
- ],
76615
- name: "symbol",
76616
- outputs: [
76617
- {
76618
- name: "",
76619
- type: "string"
76620
- }
76621
- ],
76622
- payable: false,
76623
- stateMutability: "view",
76624
- type: "function"
76625
- },
76626
- {
76627
- constant: false,
76628
- inputs: [
76629
- {
76630
- name: "_to",
76631
- type: "address"
76632
- },
76633
- {
76634
- name: "_value",
76635
- type: "uint256"
76636
- }
76637
- ],
76638
- name: "transfer",
76639
- outputs: [
76640
- {
76641
- name: "",
76642
- type: "bool"
76643
- }
76644
- ],
76645
- payable: false,
76646
- stateMutability: "nonpayable",
76647
- type: "function"
76648
- },
76649
- {
76650
- constant: true,
76651
- inputs: [
76652
- {
76653
- name: "_owner",
76654
- type: "address"
76655
- },
76656
- {
76657
- name: "_spender",
76658
- type: "address"
76659
- }
76660
- ],
76661
- name: "allowance",
76662
- outputs: [
76663
- {
76664
- name: "",
76665
- type: "uint256"
76666
- }
76667
- ],
76668
- payable: false,
76669
- stateMutability: "view",
76670
- type: "function"
76671
- },
76672
- {
76673
- payable: true,
76674
- stateMutability: "payable",
76675
- type: "fallback"
76676
- },
76677
- {
76678
- anonymous: false,
76679
- inputs: [
76680
- {
76681
- indexed: true,
76682
- name: "owner",
76683
- type: "address"
76684
- },
76685
- {
76686
- indexed: true,
76687
- name: "spender",
76688
- type: "address"
76689
- },
76690
- {
76691
- indexed: false,
76692
- name: "value",
76693
- type: "uint256"
76694
- }
76695
- ],
76696
- name: "Approval",
76697
- type: "event"
76698
- },
76699
- {
76700
- anonymous: false,
76701
- inputs: [
76702
- {
76703
- indexed: true,
76704
- name: "from",
76705
- type: "address"
76706
- },
76707
- {
76708
- indexed: true,
76709
- name: "to",
76710
- type: "address"
76711
- },
76712
- {
76713
- indexed: false,
76714
- name: "value",
76715
- type: "uint256"
76716
- }
76717
- ],
76718
- name: "Transfer",
76719
- type: "event"
76720
- }
76721
- ];
76722
-
76723
76749
  function useUserTokensBalance(tokens, chainId) {
76724
76750
  const keys = tokens.map((token) => (token === 'NATIVE' ? 'NATIVE' : token.address[chainId]));
76725
76751
  const { address: account } = useAccount();
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "Ape Bond SDK",
4
4
  "author": "Ape Bond",
5
5
  "license": "MIT",
6
- "version": "3.0.67",
6
+ "version": "3.0.68",
7
7
  "module": "dist/main.js",
8
8
  "type": "module",
9
9
  "types": "dist/main.d.ts",