@gvnrdao/dh-lit-actions 0.0.331 → 0.0.333

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 (44) hide show
  1. package/dist/a_dev_address-probe-signer.meta.json +1 -1
  2. package/dist/a_dev_address-probe.meta.json +1 -1
  3. package/dist/a_dev_always-signer.meta.json +1 -1
  4. package/dist/a_dev_authorization-dummy-b.meta.json +1 -1
  5. package/dist/a_dev_authorization-dummy.meta.json +1 -1
  6. package/dist/a_dev_ethers-version-probe.meta.json +1 -1
  7. package/dist/a_dev_process-payment-sign-only.meta.json +1 -1
  8. package/dist/agent-module-executor.meta.json +1 -1
  9. package/dist/backing-attestation.meta.json +3 -3
  10. package/dist/btc-address-balance.meta.json +1 -1
  11. package/dist/btc-provider-probe.meta.json +1 -1
  12. package/dist/btc-transaction-signer.meta.json +1 -1
  13. package/dist/btc-utxo-invalidator.meta.json +1 -1
  14. package/dist/btc-withdrawal.meta.json +1 -1
  15. package/dist/carry-collateral-attestation.action.js +1 -1
  16. package/dist/carry-collateral-attestation.hash +1 -1
  17. package/dist/carry-collateral-attestation.meta.json +5 -5
  18. package/dist/carry-repay-validator.action.js +1 -0
  19. package/dist/carry-repay-validator.hash +1 -0
  20. package/dist/carry-repay-validator.meta.json +9 -0
  21. package/dist/encrypt-parameter.meta.json +1 -1
  22. package/dist/extend-position-validator.meta.json +1 -1
  23. package/dist/liquidation-validator.meta.json +1 -1
  24. package/dist/loan-vault-btc-balance.meta.json +1 -1
  25. package/dist/pkp-validator.meta.json +1 -1
  26. package/dist/price-oracle.meta.json +1 -1
  27. package/dist/process-payment-validator.meta.json +1 -1
  28. package/dist/stale-spend-recovery-validator.meta.json +1 -1
  29. package/dist/ucd-mint-validator.meta.json +1 -1
  30. package/package.json +1 -1
  31. package/pkg-dist/pkg-src/constants/chunks/lit-actions-registry.d.ts.map +1 -1
  32. package/pkg-dist/pkg-src/index.js +34 -21
  33. package/pkg-dist/pkg-src/index.js.map +3 -3
  34. package/pkg-dist/pkg-src/interfaces/chunks/diamond-hands-lit-actions.i.d.ts +2 -2
  35. package/pkg-dist/pkg-src/interfaces/chunks/diamond-hands-lit-actions.i.d.ts.map +1 -1
  36. package/pkg-dist/src/constants/chunks/carry.d.ts +5 -21
  37. package/pkg-dist/src/constants/chunks/carry.d.ts.map +1 -1
  38. package/pkg-dist/src/modules/carry-attestation.module.d.ts +73 -50
  39. package/pkg-dist/src/modules/carry-attestation.module.d.ts.map +1 -1
  40. package/pkg-dist/src/modules/carry-repay.module.d.ts +59 -0
  41. package/pkg-dist/src/modules/carry-repay.module.d.ts.map +1 -0
  42. package/dist/carry-funding-attestation.action.js +0 -1
  43. package/dist/carry-funding-attestation.hash +0 -1
  44. package/dist/carry-funding-attestation.meta.json +0 -9
@@ -40,8 +40,8 @@ export interface DiamondHandsLitActions {
40
40
  agentModuleExecutor: LitActionConfig;
41
41
  /** LoanCarryVault collateral attestation (carry-contracts D80) — testnet carry group only */
42
42
  carryCollateralAttestation: LitActionConfig;
43
- /** LoanCarryVault funding attestation (carry-contracts D80) — testnet carry group only */
44
- carryFundingAttestation: LitActionConfig;
43
+ /** PositionManager.makePaymentFrom validator for the carry loan receiver (capital lock plan Step 4) — testnet carry group only */
44
+ carryRepayValidator: LitActionConfig;
45
45
  /** BackingOracle report signer (specs Phase 4) — Sepolia backing group only */
46
46
  backingAttestation: LitActionConfig;
47
47
  }
@@ -1 +1 @@
1
- {"version":3,"file":"diamond-hands-lit-actions.i.d.ts","sourceRoot":"","sources":["../../../../pkg-src/interfaces/chunks/diamond-hands-lit-actions.i.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD;;;GAGG;AACH,MAAM,WAAW,sBAAsB;IACrC,6DAA6D;IAC7D,kBAAkB,EAAE,eAAe,CAAC;IACpC,mFAAmF;IACnF,mBAAmB,EAAE,eAAe,CAAC;IACrC,yDAAyD;IACzD,YAAY,EAAE,eAAe,CAAC;IAC9B,oFAAoF;IACpF,gBAAgB,EAAE,eAAe,CAAC;IAClC,2DAA2D;IAC3D,WAAW,EAAE,eAAe,CAAC;IAC7B,2EAA2E;IAC3E,mBAAmB,EAAE,eAAe,CAAC;IACrC,sHAAsH;IACtH,iBAAiB,EAAE,eAAe,CAAC;IACnC,8EAA8E;IAC9E,aAAa,EAAE,eAAe,CAAC;IAC/B,yEAAyE;IACzE,oBAAoB,EAAE,eAAe,CAAC;IACtC,yEAAyE;IACzE,uBAAuB,EAAE,eAAe,CAAC;IACzC,oFAAoF;IACpF,uBAAuB,EAAE,eAAe,CAAC;IACzC,0GAA0G;IAC1G,2BAA2B,EAAE,eAAe,CAAC;IAC7C,uJAAuJ;IACvJ,kBAAkB,EAAE,eAAe,CAAC;IACpC,2FAA2F;IAC3F,YAAY,EAAE,eAAe,CAAC;IAC9B,6GAA6G;IAC7G,oBAAoB,EAAE,eAAe,CAAC;IACtC,6FAA6F;IAC7F,kBAAkB,EAAE,eAAe,CAAC;IACpC,gGAAgG;IAChG,mBAAmB,EAAE,eAAe,CAAC;IACrC,6FAA6F;IAC7F,0BAA0B,EAAE,eAAe,CAAC;IAC5C,0FAA0F;IAC1F,uBAAuB,EAAE,eAAe,CAAC;IACzC,+EAA+E;IAC/E,kBAAkB,EAAE,eAAe,CAAC;CAIrC;AAED;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,MAAM,sBAAsB,CAAC"}
1
+ {"version":3,"file":"diamond-hands-lit-actions.i.d.ts","sourceRoot":"","sources":["../../../../pkg-src/interfaces/chunks/diamond-hands-lit-actions.i.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD;;;GAGG;AACH,MAAM,WAAW,sBAAsB;IACrC,6DAA6D;IAC7D,kBAAkB,EAAE,eAAe,CAAC;IACpC,mFAAmF;IACnF,mBAAmB,EAAE,eAAe,CAAC;IACrC,yDAAyD;IACzD,YAAY,EAAE,eAAe,CAAC;IAC9B,oFAAoF;IACpF,gBAAgB,EAAE,eAAe,CAAC;IAClC,2DAA2D;IAC3D,WAAW,EAAE,eAAe,CAAC;IAC7B,2EAA2E;IAC3E,mBAAmB,EAAE,eAAe,CAAC;IACrC,sHAAsH;IACtH,iBAAiB,EAAE,eAAe,CAAC;IACnC,8EAA8E;IAC9E,aAAa,EAAE,eAAe,CAAC;IAC/B,yEAAyE;IACzE,oBAAoB,EAAE,eAAe,CAAC;IACtC,yEAAyE;IACzE,uBAAuB,EAAE,eAAe,CAAC;IACzC,oFAAoF;IACpF,uBAAuB,EAAE,eAAe,CAAC;IACzC,0GAA0G;IAC1G,2BAA2B,EAAE,eAAe,CAAC;IAC7C,uJAAuJ;IACvJ,kBAAkB,EAAE,eAAe,CAAC;IACpC,2FAA2F;IAC3F,YAAY,EAAE,eAAe,CAAC;IAC9B,6GAA6G;IAC7G,oBAAoB,EAAE,eAAe,CAAC;IACtC,6FAA6F;IAC7F,kBAAkB,EAAE,eAAe,CAAC;IACpC,gGAAgG;IAChG,mBAAmB,EAAE,eAAe,CAAC;IACrC,6FAA6F;IAC7F,0BAA0B,EAAE,eAAe,CAAC;IAC5C,kIAAkI;IAClI,mBAAmB,EAAE,eAAe,CAAC;IACrC,+EAA+E;IAC/E,kBAAkB,EAAE,eAAe,CAAC;CAIrC;AAED;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,MAAM,sBAAsB,CAAC"}
@@ -8,34 +8,18 @@
8
8
  */
9
9
  /** keccak256 of these strings are the vault's action tags (D71 (1)). */
10
10
  export declare const CARRY_TAG_COLLATERAL = "carry-collateral";
11
- export declare const CARRY_TAG_FUNDING = "carry-funding";
12
- /** borrowerKind (D45). v1 attests EOAs only: the Lit Action refuses a borrower with contract code. */
11
+ /**
12
+ * borrowerKind (D45; CarrySignedTypes.KIND_*). A borrower with contract code is a Safe: the vault accepts it only
13
+ * behind `safeBorrowersEnabled` and lets it act solely through its attested actor.
14
+ */
13
15
  export declare const CARRY_BORROWER_KIND_EOA = 0;
16
+ export declare const CARRY_BORROWER_KIND_SAFE = 1;
14
17
  export declare const CARRY_COLLATERAL_TYPES: {
15
18
  CarryCollateralAttestation: {
16
19
  name: string;
17
20
  type: string;
18
21
  }[];
19
22
  };
20
- export declare const CARRY_FUNDING_TYPES: {
21
- CarryFundingAttestation: {
22
- name: string;
23
- type: string;
24
- }[];
25
- };
26
- /** Hourly funding rate × 1e8, signed (D60); the vault's |rate| cap is 4%/hour (CarryConfig.FUNDING_RATE_CAP). */
27
- export declare const CARRY_FUNDING_RATE_DECIMALS = 8;
28
- export declare const CARRY_FUNDING_RATE_CAP = 4000000n;
29
- export declare const CARRY_HOUR_MS = 3600000;
30
- /** The newest sample used is the last hour boundary at least this far in the past, so every node sees it published. */
31
- export declare const CARRY_FUNDING_PUBLICATION_LAG_MS: number;
32
- /** Hyperliquid's undocumented fundingHistory page size (notes *Funding history*). */
33
- export declare const HYPERLIQUID_FUNDING_PAGE_LIMIT = 500;
34
- export declare const CARRY_HTTP_TIMEOUT_MS = 15000;
35
- /** The vault's instrument (D22, D23): the BTC perp. */
36
- export declare const CARRY_PERP_COIN = "BTC";
37
- /** Hyperliquid Info API per HyperEVM chain — never caller-supplied outside hardhat. */
38
- export declare const HYPERLIQUID_INFO_URL: Record<number, string>;
39
23
  /**
40
24
  * D40: the pinned pairing per SOURCE (Ethereum) chain — the HyperEVM chain and vault proxy the attestations are for,
41
25
  * and the dedicated carry signer (never the loan validator key). The action refuses any other domain or signer and
@@ -1 +1 @@
1
- {"version":3,"file":"carry.d.ts","sourceRoot":"","sources":["../../../../src/constants/chunks/carry.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,wEAAwE;AACxE,eAAO,MAAM,oBAAoB,qBAAqB,CAAC;AACvD,eAAO,MAAM,iBAAiB,kBAAkB,CAAC;AAEjD,sGAAsG;AACtG,eAAO,MAAM,uBAAuB,IAAI,CAAC;AAEzC,eAAO,MAAM,sBAAsB;;;;;CAYlC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CAAC;CAChB;AAED,eAAO,MAAM,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAOvD,CAAC;AAEF,wBAAgB,eAAe,CAAC,aAAa,EAAE,MAAM,GAAG,YAAY,GAAG,IAAI,CAE1E"}
@@ -1,21 +1,20 @@
1
1
  /**
2
- * LoanCarryVault attestations (carry-contracts; D25, D40, D42, D45, D52, D56, D60, D71, D80) — the decisions both
3
- * carry actions take, as pure functions the unit suite exercises directly:
2
+ * LoanCarryVault collateral attestation (carry-contracts; D25, D40, D42, D45, D52, D56, D80, D81) — the decisions
3
+ * the carry-collateral Lit Action takes, as pure functions the unit suite exercises directly:
4
4
  *
5
- * - which vault domain and signer an attestation may be for (the D40 pinned pairing; hardhat takes the caller's);
6
- * - whether a loan is attestable (not liquidated; an EOA borrower — v1 has no Safe borrowers, D45);
7
- * - exact decimal → ×1e8 funding rates, the deterministic sample window, contiguity and the average (D60);
8
- * - the paginated Hyperliquid fundingHistory read;
5
+ * - which vault domain and signer an attestation may be for (the D40 pinned pairing; hardhat takes the caller's
6
+ * vault and signer, for the local chain only and never a pinned one);
7
+ * - that the RPC it reads from is the policy's chain;
8
+ * - the borrower's kind (EOA or Safe) and the actor attested for it: the borrower's registry agent, only while the
9
+ * registry's carry scope (AgentDelegationRegistry 3.1.0 `canCarry`) holds for this loan;
9
10
  * - signing with the pinned carry signer, over the vault's EIP-712 types (constants/chunks/carry.ts).
10
11
  *
11
- * The vault re-checks everything it can on-chain (CarryAuth): freshness, replay, binding, the funding shape. What
12
- * only this action can check — the loan's state on Ethereum, the vault's BTC, Hyperliquid's funding — it refuses to
12
+ * The vault re-checks everything it can on-chain (CarryAuth): freshness, replay, binding, the actor's expiry. What
13
+ * only this action can check — the loan's state on Ethereum, the vault's BTC, the registry's agent — it refuses to
13
14
  * sign rather than sign a flag (D21).
14
15
  */
15
16
  import { type CarryPairing } from "../constants/chunks/carry";
16
17
  import type { ChainPolicy } from "./chain-policy";
17
- /** LoanStatusLib.LoanStatus.LIQUIDATED — the only loan state a carry attestation refuses (D52, D56). */
18
- export declare const LOAN_STATUS_LIQUIDATED = 5;
19
18
  export interface CarryDomain {
20
19
  name: string;
21
20
  version: string;
@@ -30,16 +29,76 @@ export interface RequestedCarryDomain {
30
29
  }
31
30
  /**
32
31
  * D40: on enforced chains the requested (HyperEVM chain, vault) and the signer must equal the pinned pairing for this
33
- * source chain; a chain with no pairing refuses. On hardhat the caller's values are used (local, no funds) — the
34
- * same switch as the loan contracts' address pinning (`policy.pinContractAddresses`).
32
+ * source chain; a chain with no pairing refuses.
33
+ *
34
+ * On hardhat (`policy.pinContractAddresses` false — the same switch as the loan contracts' address pinning) the
35
+ * caller's vault and signer are used, but ONLY for a vault on the local chain. The loan validators can take the
36
+ * caller's addresses there because the domain they sign is the policy chain's: a signature obtained by claiming
37
+ * `chain: "hardhat"` is valid on that chain and nowhere else. This action's domain is a SECOND chain the caller names,
38
+ * so that argument does not carry over: without the checks below, `chain: "hardhat"` + the live vault's
39
+ * (HyperEVM chain, address) made any pinned signer of this action's group sign, for the live vault, facts read from
40
+ * the caller's own RPC (audit 2026-11-14, H-3). So, unpinned: the domain's chain must be the policy's own chain id,
41
+ * and neither the vault nor the signer may be one that is pinned for any chain.
35
42
  */
36
43
  export declare function resolveCarryDomain(policy: ChainPolicy, requested: RequestedCarryDomain, signer: string, pairing: CarryPairing | null, name: string, version: string): CarryDomain;
44
+ /** The one JSON-RPC call `assertRpcIsPolicyChain` makes (an ethers JsonRpcProvider satisfies it). */
45
+ export interface ChainIdRpc {
46
+ send(method: string, params: unknown[]): Promise<unknown>;
47
+ }
48
+ /**
49
+ * The RPC the action reads from must be the policy's chain. The chain policy vets the RPC's HOST; this vets what the
50
+ * node says it is, so an approved-domain URL for another network (or a mis-set caller) cannot feed another chain's
51
+ * state into a signature for this one. `eth_chainId` is asked explicitly: a static provider never probes it.
52
+ */
53
+ export declare function assertRpcIsPolicyChain(rpc: ChainIdRpc, policy: ChainPolicy, tag: string): Promise<void>;
37
54
  /**
38
55
  * The borrower's Ethereum code: none → an EOA; an EIP-7702 delegation designator (0xef0100 ‖ address, 23 bytes) →
39
- * still an EOA (it keeps its key and signs ECDSA). Anything else is a contract (a Safe), which v1 refuses (D45).
56
+ * still an EOA (it keeps its key and signs ECDSA). Anything else is a contract (a Safe).
40
57
  */
41
58
  export declare function isEoaCode(code: string): boolean;
42
- export declare function assertCollateralAttestable(loanId: string, status: number, borrower: string, borrowerCode: string): void;
59
+ /** borrowerKind for the attestation: EOA (including an EIP-7702 EOA) or Safe (any other contract code). */
60
+ export declare function borrowerKindOf(borrowerCode: string): number;
61
+ /** IAgentDelegationRegistry.DenyReason, in declaration order (AgentDelegationRegistry 3.1.0). */
62
+ export declare const AGENT_DENY_REASONS: readonly ["NONE", "PAUSED", "NO_GRANT", "SCOPE_DISABLED", "NO_AGENT", "AGENT_REVOKED", "AGENT_EXPIRED", "NOT_CALLER"];
63
+ /** The two AgentDelegationRegistry reads the actor decision needs (an ethers Contract satisfies it). */
64
+ export interface CarryAgentRegistry {
65
+ agentOf(user: string): Promise<{
66
+ agent: string;
67
+ validUntil: {
68
+ toString(): string;
69
+ };
70
+ }>;
71
+ canCarry(positionId: string, caller: string): Promise<{
72
+ ok: boolean;
73
+ reason: number;
74
+ }>;
75
+ }
76
+ /** Inline ABI of the registry reads (no shared constants chunk, so no other action's CID moves). */
77
+ export declare const CARRY_AGENT_REGISTRY_ABI: string[];
78
+ export interface CarryActor {
79
+ /** The registry agent, or the borrower itself when no agent is attested. */
80
+ actor: string;
81
+ /** The agent's `AgentRecord.validUntil` (unix seconds, as a decimal string); "0" when there is no agent. */
82
+ actorValidUntil: string;
83
+ /** Why no agent is attested — the registry's deny reason — or "NONE" when one is. */
84
+ denied: string;
85
+ }
86
+ /**
87
+ * Who acts for the borrower in the vault. The borrower's registered agent is attested, with its registry expiry,
88
+ * exactly when `canCarry(loanId, agent)` holds (an active, unexpired agent and the loan's carry scope). Otherwise
89
+ * the borrower is its own actor, expiry 0 (the vault then clears any earlier actor).
90
+ *
91
+ * `registry` is undefined only where the chain pins no AgentDelegationRegistry (resolveAgentPathAddresses): no
92
+ * agent can then be established, which is the same "no agent" answer. It is never taken from the caller on an
93
+ * enforced chain.
94
+ */
95
+ export declare function resolveCarryActor(registry: CarryAgentRegistry | undefined, loanId: string, borrower: string): Promise<CarryActor>;
96
+ /**
97
+ * Whether the borrower can be attested at all. An EOA always can (it signs for itself). A Safe signs ONLY through
98
+ * its attested actor (CarryAuth), so a Safe with no active carry-scoped agent is refused rather than attested into a
99
+ * loan nobody could act on. (Inert until the vault enables Safe borrowers, `safeBorrowersEnabled`.)
100
+ */
101
+ export declare function assertBorrowerAttestable(loanId: string, borrower: string, kind: number, actor: CarryActor): void;
43
102
  /** LoanOperationsManager.BALANCE_CONFIRMATION_TYPEHASH — field order normative (the loans' type, not carry's). */
44
103
  export declare const BALANCE_CONFIRMATION_TYPES: {
45
104
  BalanceConfirmation: {
@@ -79,42 +138,6 @@ export declare function verifyBalanceConfirmation(args: {
79
138
  };
80
139
  nowSeconds: number;
81
140
  }): bigint;
82
- /**
83
- * Hyperliquid's decimal-string rate → hourly rate × 1e8, exactly, rounded toward zero (D60). Accepts plain decimals
84
- * only ("-0.0000125"); anything else — exponent form, empty, junk — throws rather than being guessed at.
85
- */
86
- export declare function parseFundingRate(rate: string): bigint;
87
- export interface FundingWindow {
88
- /** ms, an hour boundary: the oldest sample. */
89
- firstTime: number;
90
- /** ms, an hour boundary: the newest sample — at least CARRY_FUNDING_PUBLICATION_LAG_MS before `atSeconds`. */
91
- lastTime: number;
92
- }
93
- /** The `windowHours` hourly samples ending at the newest hour boundary that is safely published at `atSeconds`. */
94
- export declare function fundingWindow(atSeconds: number, windowHours: number): FundingWindow;
95
- export interface FundingRecord {
96
- coin: string;
97
- fundingRate: string;
98
- time: number;
99
- }
100
- export interface FundingValues {
101
- windowHours: number;
102
- avgFundingRate: bigint;
103
- sampleCount: number;
104
- firstTime: number;
105
- lastTime: number;
106
- }
107
- /**
108
- * Exactly one sample per hour of the window (a record's time is taken to its hour — Hyperliquid stamps funding a
109
- * few ms after the boundary), each within the cap, averaged and rounded toward zero. A gap, a duplicate hour, another
110
- * coin or an out-of-cap sample refuses: the vault would accept the shape, so the data must be right here.
111
- */
112
- export declare function computeFundingValues(records: FundingRecord[], coin: string, window: FundingWindow): FundingValues;
113
- /**
114
- * Hyperliquid `fundingHistory` for `coin` over [startTime, endTime] (ms), following the forward 500-record page cap.
115
- * Throws on any HTTP or shape failure — never returns a partial history.
116
- */
117
- export declare function fetchFundingHistory(infoUrl: string, coin: string, startTime: number, endTime: number): Promise<FundingRecord[]>;
118
141
  /** Sign `value` as `types` under `domain` with the carry signer wallet (Chipotle `getPrivateKey` by wallet address). */
119
142
  export declare function signCarryAttestation(signerWallet: string, domain: CarryDomain, types: Record<string, Array<{
120
143
  name: string;
@@ -1 +1 @@
1
- {"version":3,"file":"carry-attestation.module.d.ts","sourceRoot":"","sources":["../../../src/modules/carry-attestation.module.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAOL,KAAK,YAAY,EAClB,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAKlD,wGAAwG;AACxG,eAAO,MAAM,sBAAsB,IAAI,CAAC;AAExC,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,iBAAiB,EAAE,MAAM,CAAC;CAC3B;AAED,MAAM,WAAW,oBAAoB;IACnC,2EAA2E;IAC3E,OAAO,EAAE,MAAM,CAAC;IAChB,4BAA4B;IAC5B,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,WAAW,EACnB,SAAS,EAAE,oBAAoB,EAC/B,MAAM,EAAE,MAAM,EACd,OAAO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AQ,EAAE,MAAM,CAAC;CAClB;AAED,mHAAmH;AACnH,wBAAgB,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,aAAa,CAOnF;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,aAAa;IAC5B,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,aAAa,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,GAAG,aAAa,CA4BjH;AAED;;;GAGG;AACH,wBAAsB,mBAAmB,CACvC,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,aAAa,EAAE,CAAC,CA4B1B;AAED,wHAAwH;AACxH,wBAAsB,oBAAoB,CACxC,YAAY,EAAE,MAAM,EACpB,MAAM,EAAE,WAAW,EACnB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC,EAC5D,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC7B,OAAO,CAAC;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC,CAQhD"}
1
+ {"version":3,"file":"carry-attestation.module.d.ts","sourceRoot":"","sources":["../../../src/modules/carry-attestation.module.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,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;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,sGAAsG;IACtG,SAAS,EAAE,MAAM,CAAC;IAClB,6GAA6G;IAC7G,MAAM,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,iBAAiB,EAAE,MAAM,CAAA;KAAE,CAAC;IACtF,UAAU,EAAE,MAAM,CAAC;CACpB,GAAG,MAAM,CA0BT;AAED,wHAAwH;AACxH,wBAAsB,oBAAoB,CACxC,YAAY,EAAE,MAAM,EACpB,MAAM,EAAE,WAAW,EACnB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC,EAC5D,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC7B,OAAO,CAAC;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC,CAQhD"}
@@ -0,0 +1,59 @@
1
+ /**
2
+ * Carry repayment signing (carry capital lock plan, Step 4): the decisions `carry-repay-validator` takes, as pure
3
+ * functions the unit suite exercises directly.
4
+ *
5
+ * The action signs `PositionManager.makePaymentFrom` for the ONE registered repayment payer (the carry loan
6
+ * receiver). What it signs is derived, never chosen by the caller:
7
+ *
8
+ * - the payer must be the receiver the caller named (read from PositionManager, not trusted from the caller);
9
+ * - the position must be able to take a payment, owe something, and the receiver must hold a credit for it;
10
+ * - amount = min(credit, debt). A caller-chosen amount would let a dust signature burn the (position, selector)
11
+ * replay lane for the quantum and block the keeper's real repayment.
12
+ *
13
+ * The typed data is the Solidity `PositionManagerViews.eip712DigestPayerPayment`, field for field
14
+ * (contracts/docs/EIP712_DOMAIN_SPEC.md §3.11).
15
+ */
16
+ /** `PositionManagerViews.PAYER_PAYMENT_TYPEHASH` — field order is normative. */
17
+ export declare const PAYER_PAYMENT_TYPES: {
18
+ PayerPayment: {
19
+ name: string;
20
+ type: string;
21
+ }[];
22
+ };
23
+ /** `PositionManager.repaymentPayer()` must be exactly the receiver the caller named. */
24
+ export declare function assertReceiverIsRepaymentPayer(onChainPayer: string, receiver: string): void;
25
+ /**
26
+ * The amount to repay: min(credit, debt). Refuses a position that cannot take a payment, one with no debt, and a
27
+ * receiver with no credit for it. Never takes an amount from the caller.
28
+ */
29
+ export declare function deriveRepayAmount(args: {
30
+ positionId: string;
31
+ status: number;
32
+ debt: bigint;
33
+ credit: bigint;
34
+ }): bigint;
35
+ export interface PayerPaymentInput {
36
+ positionId: string;
37
+ quantumTimestamp: number;
38
+ btcPrice: bigint;
39
+ amount: bigint;
40
+ borrower: string;
41
+ payer: string;
42
+ }
43
+ /** The `PayerPayment` message. Every integer is a decimal string, as `_signTypedData` and the wire format want. */
44
+ export declare function buildPayerPaymentValue(i: PayerPaymentInput): {
45
+ positionId: string;
46
+ quantumTimestamp: string;
47
+ btcPrice: string;
48
+ paymentAmount: string;
49
+ borrower: any;
50
+ payer: any;
51
+ };
52
+ /** The EIP-712 digest `PositionManagerViews.eip712DigestPayerPayment` returns for the same inputs. */
53
+ export declare function payerPaymentDigest(domain: {
54
+ name: string;
55
+ version: string;
56
+ chainId: number;
57
+ verifyingContract: string;
58
+ }, value: ReturnType<typeof buildPayerPaymentValue>): string;
59
+ //# sourceMappingURL=carry-repay.module.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"carry-repay.module.d.ts","sourceRoot":"","sources":["../../../src/modules/carry-repay.module.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAMH,gFAAgF;AAChF,eAAO,MAAM,mBAAmB;;;;;CAS/B,CAAC;AAUF,wFAAwF;AACxF,wBAAgB,8BAA8B,CAAC,YAAY,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,CAQ3F;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAYpH;AAED,MAAM,WAAW,iBAAiB;IAChC,UAAU,EAAE,MAAM,CAAC;IACnB,gBAAgB,EAAE,MAAM,CAAC;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,mHAAmH;AACnH,wBAAgB,sBAAsB,CAAC,CAAC,EAAE,iBAAiB;;;;;;;EAS1D;AAED,sGAAsG;AACtG,wBAAgB,kBAAkB,CAChC,MAAM,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,iBAAiB,EAAE,MAAM,CAAA;CAAE,EACrF,KAAK,EAAE,UAAU,CAAC,OAAO,sBAAsB,CAAC,GAC/C,MAAM,CAER"}
@@ -1 +0,0 @@
1
- var _LIT_ACTION_=(()=>{var r=Object.defineProperty,e=Object.getOwnPropertyDescriptor,n=Object.getOwnPropertyNames,t=Object.prototype.hasOwnProperty,i={};((e,n)=>{for(var t in n)r(e,t,{get:n[t],enumerable:!0})})(i,{main:()=>main});var o=60,a="DiamondHands.Protocol",s="1",c=(r=>(r.SEPOLIA="sepolia",r.ETHEREUM="ethereum",r.HARDHAT="hardhat",r))(c||{}),d={sepolia:"regtest",ethereum:"mainnet",hardhat:"regtest"},f={ethereum:1,sepolia:11155111,hardhat:1337};var u="carry-funding",l={CarryFundingAttestation:[{name:"actionTag",type:"bytes32"},{name:"windowHours",type:"uint32"},{name:"avgFundingRate",type:"int64"},{name:"sampleCount",type:"uint32"},{name:"firstTime",type:"uint64"},{name:"lastTime",type:"uint64"},{name:"quantumTimestamp",type:"uint256"}]},h=8,g=4000000n,m=36e5,y=6e5,p=500,w=15e3,v="BTC",T={998:"https://api.hyperliquid-testnet.xyz/info",999:"https://api.hyperliquid.xyz/info"},I={11155111:{hyperEvmChainId:998,vault:"0x5310AE7e24835cC6f7740db18ebbF9f3aB422554",signer:"0x1d2ff7E2fC89ead767b44F3aB2cAA6b18Fff3a67"}};function A(){const r=Math.floor(Date.now()/1e3);return e=r,Math.floor(e/o)*o;var e}var E,b={hardhat:{chain:"hardhat",chainId:f.hardhat,bitcoinNetwork:d.hardhat,allowArbitraryBitcoinProvider:!0,allowArbitraryEvmRpc:!0,pinContractAddresses:!1,allowDevSinglePriceProvider:!0,minBitcoinBalanceConfirmations:1,minBitcoinSpendConfirmations:1,minConsensusProviders:1},sepolia:{chain:"sepolia",chainId:f.sepolia,bitcoinNetwork:d.sepolia,allowArbitraryBitcoinProvider:!1,allowArbitraryEvmRpc:!1,pinContractAddresses:!0,allowDevSinglePriceProvider:!1,minBitcoinBalanceConfirmations:1,minBitcoinSpendConfirmations:1,minConsensusProviders:2},ethereum:{chain:"ethereum",chainId:f.ethereum,bitcoinNetwork:d.ethereum,allowArbitraryBitcoinProvider:!1,allowArbitraryEvmRpc:!1,pinContractAddresses:!0,allowDevSinglePriceProvider:!1,minBitcoinBalanceConfirmations:6,minBitcoinSpendConfirmations:6,minConsensusProviders:2}};function C(r){const e=function(r){const e=r.toLowerCase().trim();if("sepolia"===e)return"sepolia";if("ethereum"===e||"mainnet"===e)return"ethereum";if("hardhat"===e)return"hardhat";throw new Error(`Unsupported EVM chain: "${r}". Supported chains: ${Object.values(c).join(", ")}`)}(r),n=b[e];if(!n)throw new Error(`No chain policy registered for "${r}"`);return n}function $(r){const e=/^(-?)(\d+)(?:\.(\d+))?$/.exec(r);if(!e)throw new Error(`[carry] unparseable funding rate "${r}"`);const[,n,t,i=""]=e,o=(i+"0".repeat(h)).slice(0,h),a=BigInt(t)*10n**BigInt(h)+BigInt(o);return"-"===n?-a:a}async function main(r){if(!r||"object"!=typeof r)throw new Error("[carry-funding] missing args");for(const e of["chain","validatorWalletAddress"])if("string"!=typeof r[e]||0===r[e].length)throw new Error(`[carry-funding] missing "${e}"`);if(!r.carryVault||"object"!=typeof r.carryVault)throw new Error('[carry-funding] missing "carryVault"');const e=C(r.chain),n=function(r,e,n,t,i,o){if(!Number.isInteger(e.chainId)||e.chainId<=0)throw new Error(`[carry] invalid carryVault.chainId: ${e.chainId}`);const a=ethers.utils.getAddress(e.vault),s=ethers.utils.getAddress(n);if(r.pinContractAddresses){if(!t)throw new Error(`[carry] no pinned carry pairing for ${r.chain} (${r.chainId}) \u2014 the vault is not deployed/pinned there; refusing to sign`);if(e.chainId!==t.hyperEvmChainId||a!==ethers.utils.getAddress(t.vault))throw new Error(`[carry] requested domain (${e.chainId}, ${a}) is not the pinned pairing (${t.hyperEvmChainId}, ${t.vault}) for ${r.chain}; refusing to sign`);if(s!==ethers.utils.getAddress(t.signer))throw new Error(`[carry] signer ${s} is not the pinned carry signer ${t.signer}; refusing to sign`)}return{name:i,version:o,chainId:e.chainId,verifyingContract:a}}(e,r.carryVault,r.validatorWalletAddress,(t=e.chainId,I[t]??null),a,s);var t;let i;if(e.pinContractAddresses){const r=T[n.chainId];if(!r)throw new Error(`[carry-funding] no Hyperliquid Info API pinned for HyperEVM chain ${n.chainId}`);i=r}else{if(!r.devHyperliquidInfoUrl)throw new Error('[carry-funding] "devHyperliquidInfoUrl" is required on hardhat');i=r.devHyperliquidInfoUrl}const o=A(),c=function(r,e){if(!Number.isInteger(e)||e<1||e>8760)throw new Error(`[carry] invalid windowHours: ${e}`);const n=1e3*r-y,t=Math.floor(n/m)*m;return{firstTime:t-(e-1)*m,lastTime:t}}(o,r.windowHours),d=await async function(r,e,n,t){const i=[];let o=n;const a=Math.ceil((t-n)/m/p)+2;for(let n=0;n<a;n++){const n=new AbortController,a=setTimeout((()=>n.abort()),w),s=await fetch(r,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"fundingHistory",coin:e,startTime:o,endTime:t}),signal:n.signal});if(clearTimeout(a),!s.ok)throw new Error(`[carry] fundingHistory HTTP ${s.status} from ${r}`);const c=await s.json();if(!Array.isArray(c))throw new Error(`[carry] fundingHistory returned a non-array from ${r}`);for(const r of c){if("string"!=typeof r?.coin||"string"!=typeof r?.fundingRate||"number"!=typeof r?.time)throw new Error(`[carry] malformed fundingHistory record: ${JSON.stringify(r)}`);i.push({coin:r.coin,fundingRate:r.fundingRate,time:r.time})}if(c.length<p)return i;if(o=i[i.length-1].time+1,o>t)return i}throw new Error(`[carry] fundingHistory did not finish within ${a} pages`)}(i,v,c.firstTime,c.lastTime+3599999),f=function(r,e,n){const t=new Map;for(const i of r){if(i.coin!==e)throw new Error(`[carry] funding record for ${i.coin}, expected ${e}`);if(!Number.isInteger(i.time))throw new Error(`[carry] funding record with non-integer time ${i.time}`);const r=Math.floor(i.time/m)*m;if(r<n.firstTime||r>n.lastTime)continue;if(t.has(r))throw new Error(`[carry] two funding records for hour ${r}`);const o=$(i.fundingRate);if(o>g||o<-g)throw new Error(`[carry] funding sample ${i.fundingRate} at ${r} exceeds the 4%/hour cap`);t.set(r,o)}const i=(n.lastTime-n.firstTime)/m+1;let o=0n;for(let r=n.firstTime;r<=n.lastTime;r+=m){const e=t.get(r);if(void 0===e)throw new Error(`[carry] no funding record for hour ${r}; refusing to average a gap`);o+=e}return{windowHours:i,avgFundingRate:o/BigInt(i),sampleCount:i,firstTime:n.firstTime,lastTime:n.lastTime}}(d,v,c),h={actionTag:ethers.utils.keccak256(ethers.utils.toUtf8Bytes(u)),windowHours:f.windowHours,avgFundingRate:f.avgFundingRate.toString(),sampleCount:f.sampleCount,firstTime:f.firstTime.toString(),lastTime:f.lastTime.toString(),quantumTimestamp:o.toString()},{signature:E,signer:b}=await async function(r,e,n,t){const i=await Lit.Actions.getPrivateKey({pkpId:r}),o="string"==typeof i?i.startsWith("0x")?i:`0x${i}`:String(i),a=new ethers.Wallet(o);if(a.address!==ethers.utils.getAddress(r))throw new Error(`[carry] key for ${r} derives ${a.address}; refusing to sign`);return{signature:await a._signTypedData(e,n,t),signer:a.address}}(r.validatorWalletAddress,n,l,h);return{attestation:h,signature:E,signer:b,domain:n}}return E=i,((i,o,a,s)=>{if(o&&"object"==typeof o||"function"==typeof o)for(let c of n(o))t.call(i,c)||c===a||r(i,c,{get:()=>o[c],enumerable:!(s=e(o,c))||s.enumerable});return i})(r({},"__esModule",{value:!0}),E)})();if("object"==typeof _LIT_ACTION_)if("function"==typeof _LIT_ACTION_.main)var main=_LIT_ACTION_.main;else"function"==typeof _LIT_ACTION_.go&&_LIT_ACTION_.go();
@@ -1 +0,0 @@
1
- 4944ada61610cf64b32e33b5be62087088dcf5e821040c69e67942e643ce74c9
@@ -1,9 +0,0 @@
1
- {
2
- "actionName": "carry-funding-attestation",
3
- "originalSize": 14422,
4
- "minifiedSize": 7193,
5
- "compressionRatio": 0.5012480931909582,
6
- "hash": "4944ada61610cf64b32e33b5be62087088dcf5e821040c69e67942e643ce74c9",
7
- "buildTime": 1793955505969,
8
- "version": "0.1.0"
9
- }