@emberai/onchain-actions-registry 4.5.2-next.2 → 4.6.0-next.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.
package/README.md CHANGED
@@ -236,7 +236,7 @@ The schema system provides comprehensive type safety with Zod validation:
236
236
 
237
237
  **Action-Specific Schemas**:
238
238
 
239
- - **Lending** (`schemas/lending.ts`): Supply, borrow, repay, withdraw operations with comprehensive position tracking
239
+ - **Lending** (`schemas/lending.ts`): Supply, borrow, repay, withdraw operations with comprehensive position tracking, optional `tokenAddress` targeting, and reserve quote fields for exact max-borrow resolution
240
240
  - **Liquidity** (`schemas/liquidity.ts`): Advanced liquidity provision with discriminated unions for full/limited range positions
241
241
  - **Swap** (`schemas/swap.ts`): Token exchange with slippage tolerance and price tracking
242
242
  - **Perpetuals** (`schemas/perpetuals.ts`): Integration with GMX SDK for complex derivatives trading
package/dist/index.cjs CHANGED
@@ -166,15 +166,24 @@ const GetWalletLendingPositionsRequestSchema = zod.z.object({
166
166
  });
167
167
  const LendTokenDetailSchema = zod.z.object({
168
168
  tokenUid: TokenIdentifierSchema,
169
+ symbol: zod.z.string().optional(),
170
+ name: zod.z.string().optional(),
171
+ decimals: zod.z.number().int().optional(),
169
172
  underlyingBalance: zod.z.string(),
170
173
  underlyingBalanceUsd: zod.z.string(),
171
174
  variableBorrows: zod.z.string(),
172
175
  variableBorrowsUsd: zod.z.string(),
173
176
  totalBorrows: zod.z.string(),
174
- totalBorrowsUsd: zod.z.string()
177
+ totalBorrowsUsd: zod.z.string(),
178
+ priceInUsd: zod.z.string(),
179
+ priceInMarketReferenceCurrency: zod.z.string(),
180
+ formattedPriceInMarketReferenceCurrency: zod.z.string(),
181
+ availableLiquidity: zod.z.string(),
182
+ availableLiquidityUsd: zod.z.string()
175
183
  });
176
184
  const GetWalletLendingPositionsResponseSchema = zod.z.object({
177
185
  userReserves: zod.z.array(LendTokenDetailSchema),
186
+ requestedReserve: LendTokenDetailSchema.optional(),
178
187
  totalLiquidityUsd: zod.z.string(),
179
188
  totalCollateralUsd: zod.z.string(),
180
189
  totalBorrowsUsd: zod.z.string(),
@@ -1240,13 +1249,14 @@ function formatNumeric(value) {
1240
1249
  }
1241
1250
  var UserSummary = class {
1242
1251
  reserves;
1252
+ formattedReserves;
1243
1253
  /**
1244
1254
  * @param userReservesResponse - The response from getUserReservesHumanized.
1245
1255
  * @param reservesResponse - The response from getReservesHumanized.
1246
1256
  */
1247
1257
  constructor(userReservesResponse, reservesResponse) {
1248
1258
  const currentTimestamp = Date.now() / 1e3;
1249
- const formattedReserves = (0, __aave_math_utils.formatReserves)({
1259
+ this.formattedReserves = (0, __aave_math_utils.formatReserves)({
1250
1260
  reserves: reservesResponse.reservesData,
1251
1261
  currentTimestamp,
1252
1262
  marketReferenceCurrencyDecimals: reservesResponse.baseCurrencyData.marketReferenceCurrencyDecimals,
@@ -1257,10 +1267,14 @@ var UserSummary = class {
1257
1267
  marketReferencePriceInUsd: reservesResponse.baseCurrencyData.marketReferenceCurrencyPriceInUsd,
1258
1268
  marketReferenceCurrencyDecimals: reservesResponse.baseCurrencyData.marketReferenceCurrencyDecimals,
1259
1269
  userReserves: userReservesResponse.userReserves,
1260
- formattedReserves,
1270
+ formattedReserves: this.formattedReserves,
1261
1271
  userEmodeCategoryId: userReservesResponse.userEmodeCategoryId
1262
1272
  });
1263
1273
  }
1274
+ getReserveByUnderlyingAsset(tokenAddress) {
1275
+ const normalizedTokenAddress = tokenAddress.toLowerCase();
1276
+ return this.formattedReserves.find((reserve) => reserve.underlyingAsset.toLowerCase() === normalizedTokenAddress);
1277
+ }
1264
1278
  toHumanReadable() {
1265
1279
  let output = "User Positions:\n";
1266
1280
  output += `Total Liquidity (USD): ${formatNumeric(this.reserves.totalLiquidityUSD)}\n`;
@@ -1289,6 +1303,31 @@ var UserSummary = class {
1289
1303
 
1290
1304
  //#endregion
1291
1305
  //#region src/aave-lending-plugin/adapter.ts
1306
+ function hasVisibleReservePosition({ underlyingBalance, totalBorrows }) {
1307
+ return underlyingBalance !== "0" || totalBorrows !== "0";
1308
+ }
1309
+ function toLendingReserveDetail(chainId, { reserve, underlyingBalance = "0", underlyingBalanceUSD = "0", variableBorrows = "0", variableBorrowsUSD = "0", totalBorrows = "0", totalBorrowsUSD = "0" }) {
1310
+ return {
1311
+ tokenUid: {
1312
+ address: reserve.underlyingAsset,
1313
+ chainId
1314
+ },
1315
+ ...reserve.symbol !== void 0 ? { symbol: reserve.symbol } : {},
1316
+ ...reserve.name !== void 0 ? { name: reserve.name } : {},
1317
+ ...reserve.decimals !== void 0 ? { decimals: reserve.decimals } : {},
1318
+ underlyingBalance,
1319
+ underlyingBalanceUsd: underlyingBalanceUSD,
1320
+ variableBorrows,
1321
+ variableBorrowsUsd: variableBorrowsUSD,
1322
+ totalBorrows,
1323
+ totalBorrowsUsd: totalBorrowsUSD,
1324
+ priceInUsd: reserve.priceInUSD,
1325
+ priceInMarketReferenceCurrency: reserve.priceInMarketReferenceCurrency,
1326
+ formattedPriceInMarketReferenceCurrency: reserve.formattedPriceInMarketReferenceCurrency,
1327
+ availableLiquidity: reserve.availableLiquidity,
1328
+ availableLiquidityUsd: reserve.availableLiquidityUSD
1329
+ };
1330
+ }
1292
1331
  const AAVE_ETH_PLACEHOLDER = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE";
1293
1332
  /**
1294
1333
  * AAVEAdapter is the primary class wrapping Aave V3 interactions.
@@ -1392,22 +1431,18 @@ var AAVEAdapter = class {
1392
1431
  return this.getPoolDataProvider().getReservesHumanized({ lendingPoolAddressProvider: this.market.POOL_ADDRESSES_PROVIDER });
1393
1432
  }
1394
1433
  async getUserSummary(params) {
1395
- const { totalLiquidityUSD, totalCollateralUSD, totalBorrowsUSD, netWorthUSD, availableBorrowsUSD, currentLoanToValue, currentLiquidationThreshold, healthFactor, userReservesData } = (await this._getUserSummary(params.walletAddress)).reserves;
1396
- const userReservesFormatted = [];
1397
- for (const { reserve, underlyingBalance, underlyingBalanceUSD, variableBorrows, variableBorrowsUSD, totalBorrows, totalBorrowsUSD: totalBorrowsUSD$1 } of userReservesData.filter((ur) => ur.underlyingBalanceUSD !== "0" || ur.totalBorrowsUSD !== "0")) userReservesFormatted.push({
1398
- tokenUid: {
1399
- address: reserve.underlyingAsset,
1400
- chainId: this.chain.id.toString()
1401
- },
1402
- underlyingBalance,
1403
- underlyingBalanceUsd: underlyingBalanceUSD,
1404
- variableBorrows,
1405
- variableBorrowsUsd: variableBorrowsUSD,
1406
- totalBorrows,
1407
- totalBorrowsUsd: totalBorrowsUSD$1
1408
- });
1434
+ const userSummaryResponse = await this._getUserSummary(params.walletAddress);
1435
+ const { totalLiquidityUSD, totalCollateralUSD, totalBorrowsUSD, netWorthUSD, availableBorrowsUSD, currentLoanToValue, currentLiquidationThreshold, healthFactor, userReservesData } = userSummaryResponse.reserves;
1436
+ const chainId = this.chain.id.toString();
1437
+ const userReservesFormatted = userReservesData.filter(hasVisibleReservePosition).map((reserve) => toLendingReserveDetail(chainId, reserve));
1438
+ const requestedReserveAddress = params.tokenAddress ? params.tokenAddress.toLowerCase() : void 0;
1409
1439
  return {
1410
1440
  userReserves: userReservesFormatted,
1441
+ requestedReserve: requestedReserveAddress ? userReservesFormatted.find(({ tokenUid }) => tokenUid.address.toLowerCase() === requestedReserveAddress) ?? (() => {
1442
+ const reserve = userSummaryResponse.getReserveByUnderlyingAsset(requestedReserveAddress);
1443
+ if (!reserve) return;
1444
+ return toLendingReserveDetail(chainId, { reserve });
1445
+ })() : void 0,
1411
1446
  totalLiquidityUsd: totalLiquidityUSD,
1412
1447
  totalCollateralUsd: totalCollateralUSD,
1413
1448
  totalBorrowsUsd: totalBorrowsUSD,
@@ -1674,6 +1709,13 @@ var PublicEmberPluginRegistry = class {
1674
1709
  return Array.from(this.lifecycleCapabilities.values());
1675
1710
  }
1676
1711
  /**
1712
+ * Returns the lifecycle capability registered for a provider id, if present.
1713
+ * @param providerId Provider/plugin id to look up.
1714
+ */
1715
+ getLifecycleCapability(providerId) {
1716
+ return this.lifecycleCapabilities.get(providerId);
1717
+ }
1718
+ /**
1677
1719
  * Iterator for the registered Ember plugins.
1678
1720
  */
1679
1721
  async *getPlugins() {
package/dist/index.d.cts CHANGED
@@ -610,12 +610,20 @@ declare const LendTokenDetailSchema: z.ZodObject<{
610
610
  chainId: string;
611
611
  address: string;
612
612
  }>;
613
+ symbol: z.ZodOptional<z.ZodString>;
614
+ name: z.ZodOptional<z.ZodString>;
615
+ decimals: z.ZodOptional<z.ZodNumber>;
613
616
  underlyingBalance: z.ZodString;
614
617
  underlyingBalanceUsd: z.ZodString;
615
618
  variableBorrows: z.ZodString;
616
619
  variableBorrowsUsd: z.ZodString;
617
620
  totalBorrows: z.ZodString;
618
621
  totalBorrowsUsd: z.ZodString;
622
+ priceInUsd: z.ZodString;
623
+ priceInMarketReferenceCurrency: z.ZodString;
624
+ formattedPriceInMarketReferenceCurrency: z.ZodString;
625
+ availableLiquidity: z.ZodString;
626
+ availableLiquidityUsd: z.ZodString;
619
627
  }, "strip", z.ZodTypeAny, {
620
628
  tokenUid: {
621
629
  chainId: string;
@@ -627,6 +635,14 @@ declare const LendTokenDetailSchema: z.ZodObject<{
627
635
  variableBorrowsUsd: string;
628
636
  totalBorrows: string;
629
637
  totalBorrowsUsd: string;
638
+ priceInUsd: string;
639
+ priceInMarketReferenceCurrency: string;
640
+ formattedPriceInMarketReferenceCurrency: string;
641
+ availableLiquidity: string;
642
+ availableLiquidityUsd: string;
643
+ symbol?: string | undefined;
644
+ name?: string | undefined;
645
+ decimals?: number | undefined;
630
646
  }, {
631
647
  tokenUid: {
632
648
  chainId: string;
@@ -638,6 +654,14 @@ declare const LendTokenDetailSchema: z.ZodObject<{
638
654
  variableBorrowsUsd: string;
639
655
  totalBorrows: string;
640
656
  totalBorrowsUsd: string;
657
+ priceInUsd: string;
658
+ priceInMarketReferenceCurrency: string;
659
+ formattedPriceInMarketReferenceCurrency: string;
660
+ availableLiquidity: string;
661
+ availableLiquidityUsd: string;
662
+ symbol?: string | undefined;
663
+ name?: string | undefined;
664
+ decimals?: number | undefined;
641
665
  }>;
642
666
  type LendTokenDetail = z.infer<typeof LendTokenDetailSchema>;
643
667
  declare const GetWalletLendingPositionsResponseSchema: z.ZodObject<{
@@ -652,12 +676,20 @@ declare const GetWalletLendingPositionsResponseSchema: z.ZodObject<{
652
676
  chainId: string;
653
677
  address: string;
654
678
  }>;
679
+ symbol: z.ZodOptional<z.ZodString>;
680
+ name: z.ZodOptional<z.ZodString>;
681
+ decimals: z.ZodOptional<z.ZodNumber>;
655
682
  underlyingBalance: z.ZodString;
656
683
  underlyingBalanceUsd: z.ZodString;
657
684
  variableBorrows: z.ZodString;
658
685
  variableBorrowsUsd: z.ZodString;
659
686
  totalBorrows: z.ZodString;
660
687
  totalBorrowsUsd: z.ZodString;
688
+ priceInUsd: z.ZodString;
689
+ priceInMarketReferenceCurrency: z.ZodString;
690
+ formattedPriceInMarketReferenceCurrency: z.ZodString;
691
+ availableLiquidity: z.ZodString;
692
+ availableLiquidityUsd: z.ZodString;
661
693
  }, "strip", z.ZodTypeAny, {
662
694
  tokenUid: {
663
695
  chainId: string;
@@ -669,6 +701,14 @@ declare const GetWalletLendingPositionsResponseSchema: z.ZodObject<{
669
701
  variableBorrowsUsd: string;
670
702
  totalBorrows: string;
671
703
  totalBorrowsUsd: string;
704
+ priceInUsd: string;
705
+ priceInMarketReferenceCurrency: string;
706
+ formattedPriceInMarketReferenceCurrency: string;
707
+ availableLiquidity: string;
708
+ availableLiquidityUsd: string;
709
+ symbol?: string | undefined;
710
+ name?: string | undefined;
711
+ decimals?: number | undefined;
672
712
  }, {
673
713
  tokenUid: {
674
714
  chainId: string;
@@ -680,7 +720,79 @@ declare const GetWalletLendingPositionsResponseSchema: z.ZodObject<{
680
720
  variableBorrowsUsd: string;
681
721
  totalBorrows: string;
682
722
  totalBorrowsUsd: string;
723
+ priceInUsd: string;
724
+ priceInMarketReferenceCurrency: string;
725
+ formattedPriceInMarketReferenceCurrency: string;
726
+ availableLiquidity: string;
727
+ availableLiquidityUsd: string;
728
+ symbol?: string | undefined;
729
+ name?: string | undefined;
730
+ decimals?: number | undefined;
683
731
  }>, "many">;
732
+ requestedReserve: z.ZodOptional<z.ZodObject<{
733
+ tokenUid: z.ZodObject<{
734
+ chainId: z.ZodString;
735
+ address: z.ZodString;
736
+ }, "strip", z.ZodTypeAny, {
737
+ chainId: string;
738
+ address: string;
739
+ }, {
740
+ chainId: string;
741
+ address: string;
742
+ }>;
743
+ symbol: z.ZodOptional<z.ZodString>;
744
+ name: z.ZodOptional<z.ZodString>;
745
+ decimals: z.ZodOptional<z.ZodNumber>;
746
+ underlyingBalance: z.ZodString;
747
+ underlyingBalanceUsd: z.ZodString;
748
+ variableBorrows: z.ZodString;
749
+ variableBorrowsUsd: z.ZodString;
750
+ totalBorrows: z.ZodString;
751
+ totalBorrowsUsd: z.ZodString;
752
+ priceInUsd: z.ZodString;
753
+ priceInMarketReferenceCurrency: z.ZodString;
754
+ formattedPriceInMarketReferenceCurrency: z.ZodString;
755
+ availableLiquidity: z.ZodString;
756
+ availableLiquidityUsd: z.ZodString;
757
+ }, "strip", z.ZodTypeAny, {
758
+ tokenUid: {
759
+ chainId: string;
760
+ address: string;
761
+ };
762
+ underlyingBalance: string;
763
+ underlyingBalanceUsd: string;
764
+ variableBorrows: string;
765
+ variableBorrowsUsd: string;
766
+ totalBorrows: string;
767
+ totalBorrowsUsd: string;
768
+ priceInUsd: string;
769
+ priceInMarketReferenceCurrency: string;
770
+ formattedPriceInMarketReferenceCurrency: string;
771
+ availableLiquidity: string;
772
+ availableLiquidityUsd: string;
773
+ symbol?: string | undefined;
774
+ name?: string | undefined;
775
+ decimals?: number | undefined;
776
+ }, {
777
+ tokenUid: {
778
+ chainId: string;
779
+ address: string;
780
+ };
781
+ underlyingBalance: string;
782
+ underlyingBalanceUsd: string;
783
+ variableBorrows: string;
784
+ variableBorrowsUsd: string;
785
+ totalBorrows: string;
786
+ totalBorrowsUsd: string;
787
+ priceInUsd: string;
788
+ priceInMarketReferenceCurrency: string;
789
+ formattedPriceInMarketReferenceCurrency: string;
790
+ availableLiquidity: string;
791
+ availableLiquidityUsd: string;
792
+ symbol?: string | undefined;
793
+ name?: string | undefined;
794
+ decimals?: number | undefined;
795
+ }>>;
684
796
  totalLiquidityUsd: z.ZodString;
685
797
  totalCollateralUsd: z.ZodString;
686
798
  totalBorrowsUsd: z.ZodString;
@@ -702,6 +814,14 @@ declare const GetWalletLendingPositionsResponseSchema: z.ZodObject<{
702
814
  variableBorrowsUsd: string;
703
815
  totalBorrows: string;
704
816
  totalBorrowsUsd: string;
817
+ priceInUsd: string;
818
+ priceInMarketReferenceCurrency: string;
819
+ formattedPriceInMarketReferenceCurrency: string;
820
+ availableLiquidity: string;
821
+ availableLiquidityUsd: string;
822
+ symbol?: string | undefined;
823
+ name?: string | undefined;
824
+ decimals?: number | undefined;
705
825
  }[];
706
826
  totalLiquidityUsd: string;
707
827
  totalCollateralUsd: string;
@@ -710,6 +830,26 @@ declare const GetWalletLendingPositionsResponseSchema: z.ZodObject<{
710
830
  currentLoanToValue: string;
711
831
  currentLiquidationThreshold: string;
712
832
  healthFactor: string;
833
+ requestedReserve?: {
834
+ tokenUid: {
835
+ chainId: string;
836
+ address: string;
837
+ };
838
+ underlyingBalance: string;
839
+ underlyingBalanceUsd: string;
840
+ variableBorrows: string;
841
+ variableBorrowsUsd: string;
842
+ totalBorrows: string;
843
+ totalBorrowsUsd: string;
844
+ priceInUsd: string;
845
+ priceInMarketReferenceCurrency: string;
846
+ formattedPriceInMarketReferenceCurrency: string;
847
+ availableLiquidity: string;
848
+ availableLiquidityUsd: string;
849
+ symbol?: string | undefined;
850
+ name?: string | undefined;
851
+ decimals?: number | undefined;
852
+ } | undefined;
713
853
  }, {
714
854
  totalBorrowsUsd: string;
715
855
  userReserves: {
@@ -723,6 +863,14 @@ declare const GetWalletLendingPositionsResponseSchema: z.ZodObject<{
723
863
  variableBorrowsUsd: string;
724
864
  totalBorrows: string;
725
865
  totalBorrowsUsd: string;
866
+ priceInUsd: string;
867
+ priceInMarketReferenceCurrency: string;
868
+ formattedPriceInMarketReferenceCurrency: string;
869
+ availableLiquidity: string;
870
+ availableLiquidityUsd: string;
871
+ symbol?: string | undefined;
872
+ name?: string | undefined;
873
+ decimals?: number | undefined;
726
874
  }[];
727
875
  totalLiquidityUsd: string;
728
876
  totalCollateralUsd: string;
@@ -731,6 +879,26 @@ declare const GetWalletLendingPositionsResponseSchema: z.ZodObject<{
731
879
  currentLoanToValue: string;
732
880
  currentLiquidationThreshold: string;
733
881
  healthFactor: string;
882
+ requestedReserve?: {
883
+ tokenUid: {
884
+ chainId: string;
885
+ address: string;
886
+ };
887
+ underlyingBalance: string;
888
+ underlyingBalanceUsd: string;
889
+ variableBorrows: string;
890
+ variableBorrowsUsd: string;
891
+ totalBorrows: string;
892
+ totalBorrowsUsd: string;
893
+ priceInUsd: string;
894
+ priceInMarketReferenceCurrency: string;
895
+ formattedPriceInMarketReferenceCurrency: string;
896
+ availableLiquidity: string;
897
+ availableLiquidityUsd: string;
898
+ symbol?: string | undefined;
899
+ name?: string | undefined;
900
+ decimals?: number | undefined;
901
+ } | undefined;
734
902
  }>;
735
903
  type GetWalletLendingPositionsResponse = z.infer<typeof GetWalletLendingPositionsResponseSchema>;
736
904
  //#endregion
@@ -6517,6 +6685,11 @@ declare class PublicEmberPluginRegistry {
6517
6685
  * Returns all lifecycle capabilities registered in the registry.
6518
6686
  */
6519
6687
  getLifecycleCapabilities(): LifecycleCapability[];
6688
+ /**
6689
+ * Returns the lifecycle capability registered for a provider id, if present.
6690
+ * @param providerId Provider/plugin id to look up.
6691
+ */
6692
+ getLifecycleCapability(providerId: string): LifecycleCapability | undefined;
6520
6693
  /**
6521
6694
  * Iterator for the registered Ember plugins.
6522
6695
  */