@panoptic-eng/sdk 1.0.74 → 1.0.75

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.
@@ -17326,6 +17326,55 @@ const multicallAbi$1 = [{
17326
17326
  }],
17327
17327
  stateMutability: "nonpayable"
17328
17328
  }, ...panopticErrorsAbi];
17329
+ const collateralTrackersByClient = new WeakMap();
17330
+ const readCollateralTrackers = (client, poolAddress) => {
17331
+ const collateralTrackersByPool = collateralTrackersByClient.get(client) ?? new Map();
17332
+ collateralTrackersByClient.set(client, collateralTrackersByPool);
17333
+ const cached = collateralTrackersByPool.get(poolAddress);
17334
+ if (cached) return cached;
17335
+ const trackers = client.multicall({
17336
+ contracts: [{
17337
+ address: poolAddress,
17338
+ abi: panopticPoolV2Abi,
17339
+ functionName: "collateralToken0"
17340
+ }, {
17341
+ address: poolAddress,
17342
+ abi: panopticPoolV2Abi,
17343
+ functionName: "collateralToken1"
17344
+ }],
17345
+ allowFailure: false
17346
+ });
17347
+ collateralTrackersByPool.set(poolAddress, trackers);
17348
+ trackers.catch(() => collateralTrackersByPool.delete(poolAddress));
17349
+ return trackers;
17350
+ };
17351
+ const readInterestOwed = async (client, poolAddress, user, blockNumber) => {
17352
+ try {
17353
+ const [tracker0, tracker1] = await readCollateralTrackers(client, poolAddress);
17354
+ const read = {
17355
+ abi: collateralTrackerV2Abi,
17356
+ functionName: "owedInterest",
17357
+ args: [user]
17358
+ };
17359
+ const [interestOwed0, interestOwed1] = await client.multicall({
17360
+ contracts: [{
17361
+ ...read,
17362
+ address: tracker0
17363
+ }, {
17364
+ ...read,
17365
+ address: tracker1
17366
+ }],
17367
+ allowFailure: false,
17368
+ blockNumber
17369
+ });
17370
+ return {
17371
+ interestOwed0,
17372
+ interestOwed1
17373
+ };
17374
+ } catch {
17375
+ return void 0;
17376
+ }
17377
+ };
17329
17378
  /**
17330
17379
  * Simulate a contract call and measure token flow using PanopticPool.multicall.
17331
17380
  *
@@ -17391,14 +17440,14 @@ async function simulateWithTokenFlow(params) {
17391
17440
  ...postCallData ?? []
17392
17441
  ];
17393
17442
  try {
17394
- const { result } = await client.simulateContract({
17443
+ const [{ result }, interestOwed] = await Promise.all([client.simulateContract({
17395
17444
  address: poolAddress,
17396
17445
  abi: multicallAbi$1,
17397
17446
  functionName: "multicall",
17398
17447
  args: [multicallData],
17399
17448
  account: user,
17400
17449
  blockNumber
17401
- });
17450
+ }), readInterestOwed(client, poolAddress, user, blockNumber)]);
17402
17451
  const decodeAssets = (data) => {
17403
17452
  const decoded = decodeFunctionResult({
17404
17453
  abi: getAssetsOfAbi,
@@ -17444,7 +17493,8 @@ async function simulateWithTokenFlow(params) {
17444
17493
  balanceAfter0: assetsAfter.assets0,
17445
17494
  balanceAfter1: assetsAfter.assets1,
17446
17495
  tickBefore,
17447
- tickAfter
17496
+ tickAfter,
17497
+ ...interestOwed
17448
17498
  },
17449
17499
  gasEstimate,
17450
17500
  postCallResults,