damm-sdk 1.4.32 → 1.4.34

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 (27) hide show
  1. package/dist/index.cjs +24984 -31772
  2. package/dist/index.cjs.map +72 -120
  3. package/dist/index.js +44372 -39922
  4. package/dist/index.js.map +137 -93
  5. package/dist/integrations/etherfi/etherfi.abi.d.ts +75 -0
  6. package/dist/integrations/etherfi/etherfi.abi.d.ts.map +1 -0
  7. package/dist/integrations/etherfi/etherfi.d.ts +45 -0
  8. package/dist/integrations/etherfi/etherfi.d.ts.map +1 -0
  9. package/dist/integrations/etherfi/index.d.ts +2 -0
  10. package/dist/integrations/etherfi/index.d.ts.map +1 -0
  11. package/dist/integrations/index.d.ts +2 -0
  12. package/dist/integrations/index.d.ts.map +1 -1
  13. package/dist/integrations/morphoPublicAllocator/index.d.ts +3 -0
  14. package/dist/integrations/morphoPublicAllocator/index.d.ts.map +1 -0
  15. package/dist/integrations/morphoPublicAllocator/morpho.public.allocator.abi.d.ts +76 -0
  16. package/dist/integrations/morphoPublicAllocator/morpho.public.allocator.abi.d.ts.map +1 -0
  17. package/dist/integrations/morphoPublicAllocator/morpho.public.allocator.d.ts +76 -0
  18. package/dist/integrations/morphoPublicAllocator/morpho.public.allocator.d.ts.map +1 -0
  19. package/package.json +1 -1
  20. package/src/integrations/etherfi/etherfi.abi.ts +55 -0
  21. package/src/integrations/etherfi/etherfi.ts +153 -0
  22. package/src/integrations/etherfi/index.ts +1 -0
  23. package/src/integrations/index.ts +2 -0
  24. package/src/integrations/morphoPublicAllocator/index.ts +2 -0
  25. package/src/integrations/morphoPublicAllocator/morpho.public.allocator.abi.ts +25 -0
  26. package/src/integrations/morphoPublicAllocator/morpho.public.allocator.ts +113 -0
  27. package/src/lib/contractsRegistry.json +23 -8
@@ -0,0 +1,113 @@
1
+ import { encodeFunctionData, type Address } from "viem";
2
+ import { getAddressOrThrow } from "../../lib/addresses";
3
+ import type { MorphoBlueMarketParams } from "../morphoBlue/morpho.blue";
4
+ import { PublicAllocatorReallocateToAbi } from "./morpho.public.allocator.abi";
5
+
6
+ // -----------------------------------------------------------------------------
7
+ // Types
8
+ // -----------------------------------------------------------------------------
9
+
10
+ /**
11
+ * Mirrors the on-chain `PublicAllocator.Withdrawal` struct.
12
+ *
13
+ * struct Withdrawal {
14
+ * MarketParams marketParams;
15
+ * uint128 amount;
16
+ * }
17
+ *
18
+ * `marketParams` reuses `MorphoBlueMarketParams` from `../morphoBlue` —
19
+ * the SDK exposes a single canonical Morpho Blue market struct, no
20
+ * duplicate definition.
21
+ *
22
+ * `amount` is `uint128` on-chain; we accept `bigint` here for ergonomics.
23
+ * The caller is responsible for ensuring `amount` fits in `uint128`. The
24
+ * Guardian Relay already bounds amounts via per-market `flowCaps.maxOut`,
25
+ * which is itself `uint128`, so this constraint is satisfied upstream.
26
+ */
27
+ export type Withdrawal = Readonly<{
28
+ marketParams: MorphoBlueMarketParams;
29
+ amount: bigint;
30
+ }>;
31
+
32
+ // -----------------------------------------------------------------------------
33
+ // Address resolution
34
+ // -----------------------------------------------------------------------------
35
+
36
+ /**
37
+ * Resolves the canonical Morpho `PublicAllocator` contract address for the
38
+ * given chain. Throws if no deployment is registered for that chain.
39
+ *
40
+ * Source of truth: `src/lib/contractsRegistry.json` under
41
+ * `<chain>.morpho.publicAllocator`.
42
+ */
43
+ export const getMorphoPublicAllocatorAddress = (chainId: number): Address => {
44
+ return getAddressOrThrow(chainId, "morpho.publicAllocator");
45
+ };
46
+
47
+ // -----------------------------------------------------------------------------
48
+ // Encoding
49
+ // -----------------------------------------------------------------------------
50
+
51
+ /**
52
+ * Encodes calldata for `PublicAllocator.reallocateTo(vault, withdrawals, supplyMarketParams)`.
53
+ *
54
+ * Two on-chain invariants the helper does NOT enforce — they are validated
55
+ * by the contract itself, but callers should be aware:
56
+ *
57
+ * 1. `withdrawals` MUST be sorted strictly ascending by Morpho market id
58
+ * (i.e. `keccak256(abi.encode(MarketParams))`). The PublicAllocator
59
+ * reverts (`InconsistentWithdrawals`) if this ordering is violated or
60
+ * if any market id is duplicated.
61
+ *
62
+ * 2. `supplyMarketParams` MUST NOT appear in `withdrawals`. The destination
63
+ * market cannot also be a source. The PublicAllocator reverts
64
+ * (`DepositMarketInWithdrawals`) otherwise.
65
+ *
66
+ * The Guardian Relay's action-builder enforces (1) and (2) before calling
67
+ * this helper; downstream callers should do the same.
68
+ */
69
+ export const encodeReallocateTo = (params: {
70
+ vault: Address;
71
+ withdrawals: ReadonlyArray<Withdrawal>;
72
+ supplyMarketParams: MorphoBlueMarketParams;
73
+ }): `0x${string}` => {
74
+ const { vault, withdrawals, supplyMarketParams } = params;
75
+ return encodeFunctionData({
76
+ abi: PublicAllocatorReallocateToAbi,
77
+ functionName: "reallocateTo",
78
+ args: [vault, withdrawals, supplyMarketParams],
79
+ });
80
+ };
81
+
82
+ // -----------------------------------------------------------------------------
83
+ // Call envelope
84
+ // -----------------------------------------------------------------------------
85
+
86
+ /**
87
+ * Returns a `{ to, data, value }` envelope ready to be plugged into a
88
+ * multicall, Safe `execTransaction`, or `Roles.execTransactionWithRole`.
89
+ *
90
+ * `feeWei` MUST equal the per-vault ETH fee returned by
91
+ * `PublicAllocator.fee(vault)` at the time of execution. Sending more or
92
+ * less makes the contract revert (`msg.value != fee`). Fetch the fee
93
+ * immediately before building the call to avoid races with operator
94
+ * fee changes.
95
+ */
96
+ export const buildReallocateToCall = (params: {
97
+ chainId: number;
98
+ vault: Address;
99
+ withdrawals: ReadonlyArray<Withdrawal>;
100
+ supplyMarketParams: MorphoBlueMarketParams;
101
+ feeWei: bigint;
102
+ }): {
103
+ to: Address;
104
+ data: `0x${string}`;
105
+ value: bigint;
106
+ } => {
107
+ const { chainId, vault, withdrawals, supplyMarketParams, feeWei } = params;
108
+ return {
109
+ to: getMorphoPublicAllocatorAddress(chainId),
110
+ data: encodeReallocateTo({ vault, withdrawals, supplyMarketParams }),
111
+ value: feeWei,
112
+ };
113
+ };
@@ -96,7 +96,8 @@
96
96
  "wrappedNativeToken": "0x82af49447d8a07e3bd95bd0d56f35241523fbab1",
97
97
  "morpho": {
98
98
  "morphoBlue": "0x6c247b1F6182318877311737BaC0844bAa518F5e",
99
- "vaultV1_0": "0x7c574174DA4b2be3f705c6244B4BfA0815a8B3Ed"
99
+ "vaultV1_0": "0x7c574174DA4b2be3f705c6244B4BfA0815a8B3Ed",
100
+ "publicAllocator": "0x769583Af5e9D03589F159EbEC31Cc2c23E8C355E"
100
101
  },
101
102
  "poster": "0x000000000000cd17345801aa8147b8D3950260FF",
102
103
  "cctp": {
@@ -168,7 +169,8 @@
168
169
  "wrappedNativeToken": "0x4200000000000000000000000000000000000006",
169
170
  "morpho": {
170
171
  "morphoBlue": "0xBBBBBbbBBb9cC5e90e3b3Af64bdAF62C37EEFFCb",
171
- "vaultV1_0": "0xBEEFE94c8aD530842bfE7d8B397938fFc1cb83b2"
172
+ "vaultV1_0": "0xBEEFE94c8aD530842bfE7d8B397938fFc1cb83b2",
173
+ "publicAllocator": "0xA090dD1a701408Df1d4d0B85b716c87565f90467"
172
174
  },
173
175
  "cctp": {
174
176
  "tokenMessengerV2": "0x28b5a0e9C621a5BadaA536219b3a228C8168cf5d",
@@ -262,7 +264,8 @@
262
264
  "wrappedNativeToken": "0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270",
263
265
  "morpho": {
264
266
  "morphoBlue": "0x1bF0c2541F820E775182832f06c0B7Fc27A25f67",
265
- "vaultV1_0": "0x781FB7F6d845E3bE129289833b04d43Aa8558c42"
267
+ "vaultV1_0": "0x781FB7F6d845E3bE129289833b04d43Aa8558c42",
268
+ "publicAllocator": "0xfac15aff53ADd2ff80C2962127C434E8615Df0d3"
266
269
  },
267
270
  "cctp": {
268
271
  "tokenMessengerV2": "0x28b5a0e9C621a5BadaA536219b3a228C8168cf5d",
@@ -341,6 +344,10 @@
341
344
  },
342
345
  "ccip": {
343
346
  "router": "0x34B03Cb9086d7D758AC55af71584F81A598759FE"
347
+ },
348
+ "morpho": {
349
+ "morphoBlue": "0x01b0Bd309AA75547f7a37Ad7B1219A898E67a83a",
350
+ "publicAllocator": "0x842bEccF8eBC11006c4bE96DEfE09b60326D0495"
344
351
  }
345
352
  },
346
353
  "optimism": {
@@ -396,7 +403,8 @@
396
403
  "aggregatorV6": "0x111111125421cA6dc452d289314280a0f8842A65"
397
404
  },
398
405
  "morpho": {
399
- "morphoBlue": "0xce95AfbB8EA029495c66020883F87aaE8864AF92"
406
+ "morphoBlue": "0xce95AfbB8EA029495c66020883F87aaE8864AF92",
407
+ "publicAllocator": "0x0d68a97324E602E02799CD83B42D337207B40658"
400
408
  },
401
409
  "cctp": {
402
410
  "tokenMessengerV2": "0x28b5a0e9C621a5BadaA536219b3a228C8168cf5d",
@@ -532,7 +540,8 @@
532
540
  },
533
541
  "morpho": {
534
542
  "morphoBlue": "0xBBBBBbbBBb9cC5e90e3b3Af64bdAF62C37EEFFCb",
535
- "vaultV1_0": "0xBEEFFF7e4EedD83A4a4aB53A68D03eC77C9a57a8"
543
+ "vaultV1_0": "0xBEEFFF7e4EedD83A4a4aB53A68D03eC77C9a57a8",
544
+ "publicAllocator": "0xfd32fA2ca22c76dD6E550706Ad913FC6CE91c75D"
536
545
  },
537
546
  "lido": {
538
547
  "steth": "0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84",
@@ -672,7 +681,8 @@
672
681
  },
673
682
  "permit2": "0x000000000022D473030F116dDEE9F6B43aC78BA3",
674
683
  "morpho": {
675
- "morphoBlue": "0x8f5ae9CddB9f68de460C77730b018Ae7E04a140A"
684
+ "morphoBlue": "0x8f5ae9CddB9f68de460C77730b018Ae7E04a140A",
685
+ "publicAllocator": "0xB0c9a107fA17c779B3378210A7a593e88938C7C9"
676
686
  },
677
687
  "cctp": {
678
688
  "tokenMessengerV2": "0x28b5a0e9C621a5BadaA536219b3a228C8168cf5d",
@@ -781,7 +791,8 @@
781
791
  "multisendUnwrapper": "0xB4Cd4bb764C089f20DA18700CE8bc5e49F369efD"
782
792
  },
783
793
  "morpho": {
784
- "morphoBlue": "0xE741BC7c34758b4caE05062794E8Ae24978AF432"
794
+ "morphoBlue": "0xE741BC7c34758b4caE05062794E8Ae24978AF432",
795
+ "publicAllocator": "0xef9889B4e443DEd35FA0Bd060f2104Cca94e6A43"
785
796
  },
786
797
  "cctp": {
787
798
  "tokenMessengerV2": "0x28b5a0e9C621a5BadaA536219b3a228C8168cf5d",
@@ -888,7 +899,11 @@
888
899
  },
889
900
  "multicall3": "0xcA11bde05977b3631167028862bE2a173976CA11",
890
901
  "permit2": "0x000000000022D473030F116dDEE9F6B43aC78BA3",
891
- "poster": "0x000000000000cd17345801aa8147b8D3950260FF"
902
+ "poster": "0x000000000000cd17345801aa8147b8D3950260FF",
903
+ "morpho": {
904
+ "morphoBlue": "0xd24ECdD8C1e0E57a4E26B1a7bbeAa3e95466A569",
905
+ "publicAllocator": "0x3Fe12193D178B76BaF4e23a083A64e49ACDE3188"
906
+ }
892
907
  },
893
908
  "monad": {
894
909
  "merkl": {