@moonwell-fi/moonwell-sdk 0.20.0 → 0.20.1

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.
@@ -1372,11 +1372,8 @@ export async function getMorphoVaultsRewards(
1372
1372
  }
1373
1373
  id
1374
1374
  address
1375
- asset {
1376
- priceUsd
1377
- }
1378
1375
  state {
1379
- rewards {
1376
+ allRewards {
1380
1377
  asset {
1381
1378
  address
1382
1379
  symbol
@@ -1387,7 +1384,6 @@ export async function getMorphoVaultsRewards(
1387
1384
  }
1388
1385
  }
1389
1386
  supplyApr
1390
- amountPerSuppliedToken
1391
1387
  }
1392
1388
  }
1393
1389
  }
@@ -1405,10 +1401,7 @@ export async function getMorphoVaultsRewards(
1405
1401
  id
1406
1402
  }
1407
1403
  }
1408
- uniqueKey
1409
- loanAsset {
1410
- priceUsd
1411
- }
1404
+ marketId
1412
1405
  state {
1413
1406
  rewards {
1414
1407
  asset {
@@ -1421,7 +1414,6 @@ export async function getMorphoVaultsRewards(
1421
1414
  }
1422
1415
  }
1423
1416
  supplyApr
1424
- amountPerSuppliedToken
1425
1417
  }
1426
1418
  }
1427
1419
  }
@@ -1437,11 +1429,8 @@ export async function getMorphoVaultsRewards(
1437
1429
  };
1438
1430
  id: string;
1439
1431
  address: Address;
1440
- asset: {
1441
- priceUsd: number;
1442
- };
1443
1432
  state: {
1444
- rewards: {
1433
+ allRewards: {
1445
1434
  asset: {
1446
1435
  address: Address;
1447
1436
  symbol: string;
@@ -1452,7 +1441,6 @@ export async function getMorphoVaultsRewards(
1452
1441
  };
1453
1442
  };
1454
1443
  supplyApr: number;
1455
- amountPerSuppliedToken: string;
1456
1444
  }[];
1457
1445
  };
1458
1446
  }[];
@@ -1468,10 +1456,7 @@ export async function getMorphoVaultsRewards(
1468
1456
  id: number;
1469
1457
  };
1470
1458
  };
1471
- uniqueKey: string;
1472
- loanAsset: {
1473
- priceUsd: number;
1474
- };
1459
+ marketId: string;
1475
1460
  state: {
1476
1461
  rewards: {
1477
1462
  asset: {
@@ -1484,7 +1469,6 @@ export async function getMorphoVaultsRewards(
1484
1469
  };
1485
1470
  };
1486
1471
  supplyApr: number;
1487
- amountPerSuppliedToken: string;
1488
1472
  }[];
1489
1473
  };
1490
1474
  };
@@ -1494,22 +1478,18 @@ export async function getMorphoVaultsRewards(
1494
1478
 
1495
1479
  if (result) {
1496
1480
  try {
1481
+ // Morpho removed the per-supplied-token amount fields from the API
1482
+ // (VaultStateReward.amountPerSuppliedToken et al.), so reward amounts
1483
+ // can no longer be computed and are reported as 0.
1497
1484
  const marketsRewards = result.marketPositions.items.flatMap((item) => {
1498
1485
  const rewards = (item.market.state?.rewards || []).map((reward) => {
1499
- const tokenAmountPer1000 =
1500
- (Number.parseFloat(reward.amountPerSuppliedToken) /
1501
- item.market.loanAsset.priceUsd) *
1502
- 1000;
1503
- const tokenDecimals = 10 ** reward.asset.decimals;
1504
- const amount = Number(tokenAmountPer1000) / tokenDecimals;
1505
-
1506
1486
  return {
1507
1487
  chainId: reward.asset.chain.id,
1508
1488
  vaultId: item.user.address,
1509
- marketId: item.market.uniqueKey,
1489
+ marketId: item.market.marketId,
1510
1490
  asset: reward.asset,
1511
1491
  supplyApr: (reward.supplyApr || 0) * 100,
1512
- supplyAmount: amount,
1492
+ supplyAmount: 0,
1513
1493
  borrowApr: 0,
1514
1494
  borrowAmount: 0,
1515
1495
  };
@@ -1518,21 +1498,14 @@ export async function getMorphoVaultsRewards(
1518
1498
  });
1519
1499
 
1520
1500
  const vaultsRewards = result.vaults.items.flatMap((item) => {
1521
- return (item.state?.rewards || []).map((reward) => {
1522
- const tokenAmountPer1000 =
1523
- (Number.parseFloat(reward.amountPerSuppliedToken) /
1524
- item.asset.priceUsd) *
1525
- 1000;
1526
- const tokenDecimals = 10 ** reward.asset.decimals;
1527
- const amount = Number(tokenAmountPer1000) / tokenDecimals;
1528
-
1501
+ return (item.state?.allRewards || []).map((reward) => {
1529
1502
  return {
1530
1503
  chainId: reward.asset.chain.id,
1531
1504
  vaultId: item.address,
1532
1505
  marketId: undefined,
1533
1506
  asset: reward.asset,
1534
1507
  supplyApr: (reward.supplyApr || 0) * 100,
1535
- supplyAmount: amount,
1508
+ supplyAmount: 0,
1536
1509
  borrowApr: 0,
1537
1510
  borrowAmount: 0,
1538
1511
  };
package/errors/version.ts CHANGED
@@ -1 +1 @@
1
- export const version = '0.20.0'
1
+ export const version = '0.20.1'
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@moonwell-fi/moonwell-sdk",
3
3
  "description": "TypeScript Interface for Moonwell",
4
- "version": "0.20.0",
4
+ "version": "0.20.1",
5
5
  "main": "./_cjs/index.js",
6
6
  "module": "./_esm/index.js",
7
7
  "types": "./_types/index.d.ts",