@agentlayer.tech/wallet 0.1.44 → 0.1.48

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.
@@ -38,6 +38,11 @@ function normalizeErrorCode(errorCode, pathname, message) {
38
38
  code === "aave_approval_required" ||
39
39
  code === "aave_fee_unavailable" ||
40
40
  code === "aave_cleanup_failed" ||
41
+ code === "morpho_api_failed" ||
42
+ code === "morpho_quote_changed" ||
43
+ code === "morpho_requirements_unresolved" ||
44
+ code === "morpho_fee_unavailable" ||
45
+ code === "morpho_cleanup_failed" ||
41
46
  code === "token_transfer_failed" ||
42
47
  code === "fee_limit_exceeded" ||
43
48
  code === "token_read_failed" ||
@@ -122,6 +127,9 @@ function errorStatusCode(errorCode, fallback = 400) {
122
127
  if (errorCode === "aave_quote_changed") {
123
128
  return 409;
124
129
  }
130
+ if (errorCode === "morpho_quote_changed") {
131
+ return 409;
132
+ }
125
133
  if (
126
134
  errorCode === "swap_simulation_failed" ||
127
135
  errorCode === "swap_approval_required" ||
@@ -131,6 +139,10 @@ function errorStatusCode(errorCode, fallback = 400) {
131
139
  errorCode === "aave_approval_required" ||
132
140
  errorCode === "aave_fee_unavailable" ||
133
141
  errorCode === "aave_cleanup_failed" ||
142
+ errorCode === "morpho_api_failed" ||
143
+ errorCode === "morpho_requirements_unresolved" ||
144
+ errorCode === "morpho_fee_unavailable" ||
145
+ errorCode === "morpho_cleanup_failed" ||
134
146
  errorCode === "token_transfer_failed" ||
135
147
  errorCode === "fee_limit_exceeded" ||
136
148
  errorCode === "uniswap_api_key_missing"
@@ -445,6 +457,60 @@ async function handleRequest(request, response) {
445
457
  return sendJson(response, 200, { ok: true, data });
446
458
  }
447
459
 
460
+ if (method === "POST" && url.pathname === "/v1/evm/morpho/vaults/get") {
461
+ const body = await withResolvedNetwork(await readJsonBody(request));
462
+ const data = await service.getMorphoVaults(body);
463
+ return sendJson(response, 200, { ok: true, data });
464
+ }
465
+
466
+ if (method === "POST" && url.pathname === "/v1/evm/morpho/markets/get") {
467
+ const body = await withResolvedNetwork(await readJsonBody(request));
468
+ const data = await service.getMorphoMarkets(body);
469
+ return sendJson(response, 200, { ok: true, data });
470
+ }
471
+
472
+ if (method === "POST" && url.pathname === "/v1/evm/morpho/positions/get") {
473
+ const body = await withResolvedNetwork(await withResolvedSeedOrAddress(await readJsonBody(request)));
474
+ const data = await service.getMorphoPositions(body);
475
+ return sendJson(response, 200, { ok: true, data });
476
+ }
477
+
478
+ const morphoVaultOperationMatch = url.pathname.match(
479
+ /^\/v1\/evm\/morpho\/vault\/(supply|withdraw)\/(quote|send)$/
480
+ );
481
+ if (method === "POST" && morphoVaultOperationMatch) {
482
+ const operation = morphoVaultOperationMatch[1];
483
+ const action = morphoVaultOperationMatch[2];
484
+ const rawBody = await readJsonBody(request);
485
+ const body =
486
+ action === "quote"
487
+ ? await withResolvedNetwork(await withResolvedSeedOrAddress(rawBody))
488
+ : await withResolvedNetwork(await withResolvedSeed(rawBody));
489
+ const data =
490
+ action === "quote"
491
+ ? await service.quoteMorphoVaultOperation({ ...body, operation })
492
+ : await service.sendMorphoVaultOperation({ ...body, operation });
493
+ return sendJson(response, 200, { ok: true, data });
494
+ }
495
+
496
+ const morphoMarketOperationMatch = url.pathname.match(
497
+ /^\/v1\/evm\/morpho\/market\/(supply_collateral|borrow|repay|withdraw_collateral)\/(quote|send)$/
498
+ );
499
+ if (method === "POST" && morphoMarketOperationMatch) {
500
+ const operation = morphoMarketOperationMatch[1];
501
+ const action = morphoMarketOperationMatch[2];
502
+ const rawBody = await readJsonBody(request);
503
+ const body =
504
+ action === "quote"
505
+ ? await withResolvedNetwork(await withResolvedSeedOrAddress(rawBody))
506
+ : await withResolvedNetwork(await withResolvedSeed(rawBody));
507
+ const data =
508
+ action === "quote"
509
+ ? await service.quoteMorphoMarketOperation({ ...body, operation })
510
+ : await service.sendMorphoMarketOperation({ ...body, operation });
511
+ return sendJson(response, 200, { ok: true, data });
512
+ }
513
+
448
514
  if (method === "POST" && url.pathname === "/v1/evm/lido/overview/get") {
449
515
  const body = await withResolvedNetwork(await withResolvedSeedOrAddress(await readJsonBody(request)));
450
516
  const data = await service.getLidoOverview(body);