@ottochain/sdk 2.3.0 → 2.4.0
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/dist/cjs/apps/contracts/index.js +15 -8
- package/dist/cjs/apps/contracts/state-machines/contract-agreement.js +35 -40
- package/dist/cjs/apps/contracts/state-machines/contract-escrow.js +80 -37
- package/dist/cjs/apps/contracts/state-machines/contract-universal.js +4 -4
- package/dist/cjs/apps/corporate/index.js +2 -2
- package/dist/cjs/apps/corporate/state-machines/corp-board.js +169 -59
- package/dist/cjs/apps/corporate/state-machines/corp-entity.js +245 -47
- package/dist/cjs/apps/corporate/state-machines/corp-securities.js +407 -99
- package/dist/cjs/apps/corporate/state-machines/corp-shareholders.js +151 -37
- package/dist/cjs/apps/governance/index.js +14 -14
- package/dist/cjs/apps/governance/state-machines/dao-multisig.js +58 -40
- package/dist/cjs/apps/governance/state-machines/dao-reputation.js +46 -40
- package/dist/cjs/apps/governance/state-machines/dao-single.js +28 -11
- package/dist/cjs/apps/governance/state-machines/dao-token.js +67 -41
- package/dist/cjs/apps/governance/state-machines/governance-simple.js +93 -61
- package/dist/cjs/apps/governance/state-machines/governance-universal.js +2 -2
- package/dist/cjs/apps/identity/constants.js +55 -14
- package/dist/cjs/apps/identity/index.js +27 -11
- package/dist/cjs/apps/identity/state-machines/identity-agent.js +3 -3
- package/dist/cjs/apps/identity/state-machines/identity-oracle.js +25 -22
- package/dist/cjs/apps/identity/state-machines/identity-registry.js +288 -0
- package/dist/cjs/apps/identity/state-machines/identity-universal.js +3 -3
- package/dist/cjs/apps/identity/state-machines/index.js +3 -1
- package/dist/cjs/apps/index.js +19 -8
- package/dist/cjs/apps/lending/assets.js +223 -0
- package/dist/cjs/apps/lending/credit-scoring.js +87 -0
- package/dist/cjs/apps/lending/eligibility.js +121 -0
- package/dist/cjs/apps/lending/index.js +91 -0
- package/dist/cjs/apps/lending/state-machines/index.js +9 -0
- package/dist/cjs/apps/lending/state-machines/lending-zk-loan.js +412 -0
- package/dist/cjs/apps/markets/index.js +21 -11
- package/dist/cjs/apps/markets/state-machines/market-auction.js +14 -13
- package/dist/cjs/apps/markets/state-machines/market-crowdfund.js +29 -24
- package/dist/cjs/apps/markets/state-machines/market-group-buy.js +24 -26
- package/dist/cjs/apps/markets/state-machines/market-prediction.js +80 -53
- package/dist/cjs/apps/markets/state-machines/market-universal.js +5 -5
- package/dist/cjs/apps/oracles/index.js +2 -2
- package/dist/cjs/errors.js +3 -3
- package/dist/cjs/generated/google/protobuf/struct.js +4 -4
- package/dist/cjs/generated/index.js +11 -7
- package/dist/cjs/generated/openapi.js +6 -0
- package/dist/cjs/generated/ottochain/apps/contracts/v1/contract.js +50 -50
- package/dist/cjs/generated/ottochain/apps/corporate/v1/corporate.js +19 -20
- package/dist/cjs/generated/ottochain/apps/governance/v1/governance.js +13 -13
- package/dist/cjs/generated/ottochain/apps/identity/v1/attestation.js +4 -4
- package/dist/cjs/generated/ottochain/apps/identity/v1/identity.js +124 -130
- package/dist/cjs/generated/ottochain/apps/markets/v1/market.js +107 -107
- package/dist/cjs/generated/ottochain/v1/common.js +4 -4
- package/dist/cjs/generated/ottochain/v1/fiber.js +4 -4
- package/dist/cjs/index.js +41 -7
- package/dist/cjs/openapi.js +2 -0
- package/dist/cjs/ottochain/drop-nulls.js +1 -2
- package/dist/cjs/ottochain/genesis-manifest.js +11 -11
- package/dist/cjs/ottochain/index.js +23 -13
- package/dist/cjs/ottochain/metagraph-client.js +65 -8
- package/dist/cjs/ottochain/snapshot.js +11 -12
- package/dist/cjs/ottochain/transaction.js +57 -14
- package/dist/cjs/ottochain/types.js +16 -2
- package/dist/cjs/privacy/index.js +14 -0
- package/dist/cjs/privacy/sealed-bid.js +210 -0
- package/dist/cjs/privacy/shield-app.js +131 -0
- package/dist/cjs/schema/effects.js +40 -0
- package/dist/cjs/schema/fiber-app.js +19 -13
- package/dist/cjs/schema/guard-lint.js +352 -0
- package/dist/cjs/schema/guards.js +246 -0
- package/dist/cjs/signing.js +80 -0
- package/dist/cjs/types.js +2 -3
- package/dist/cjs/validation.js +8 -8
- package/dist/cjs/verify.js +9 -4
- package/dist/cjs/zk/commit.js +53 -0
- package/dist/cjs/zk/guard.js +107 -0
- package/dist/cjs/zk/index.js +48 -0
- package/dist/cjs/zk/preimage.js +37 -0
- package/dist/cjs/zk/prover.js +87 -0
- package/dist/cjs/zk/registry.js +62 -0
- package/dist/cjs/zk/types.js +28 -0
- package/dist/cjs/zk/witness.js +19 -0
- package/dist/esm/apps/contracts/index.js +7 -3
- package/dist/esm/apps/contracts/state-machines/contract-agreement.js +35 -40
- package/dist/esm/apps/contracts/state-machines/contract-escrow.js +80 -37
- package/dist/esm/apps/contracts/state-machines/contract-universal.js +4 -4
- package/dist/esm/apps/corporate/state-machines/corp-board.js +169 -59
- package/dist/esm/apps/corporate/state-machines/corp-entity.js +245 -47
- package/dist/esm/apps/corporate/state-machines/corp-securities.js +407 -99
- package/dist/esm/apps/corporate/state-machines/corp-shareholders.js +151 -37
- package/dist/esm/apps/governance/state-machines/dao-multisig.js +58 -40
- package/dist/esm/apps/governance/state-machines/dao-reputation.js +46 -40
- package/dist/esm/apps/governance/state-machines/dao-single.js +28 -11
- package/dist/esm/apps/governance/state-machines/dao-token.js +67 -41
- package/dist/esm/apps/governance/state-machines/governance-simple.js +93 -61
- package/dist/esm/apps/governance/state-machines/governance-universal.js +2 -2
- package/dist/esm/apps/identity/constants.js +51 -12
- package/dist/esm/apps/identity/index.js +12 -7
- package/dist/esm/apps/identity/state-machines/identity-agent.js +3 -3
- package/dist/esm/apps/identity/state-machines/identity-oracle.js +25 -22
- package/dist/esm/apps/identity/state-machines/identity-registry.js +285 -0
- package/dist/esm/apps/identity/state-machines/identity-universal.js +3 -3
- package/dist/esm/apps/identity/state-machines/index.js +1 -0
- package/dist/esm/apps/index.js +1 -0
- package/dist/esm/apps/lending/assets.js +207 -0
- package/dist/esm/apps/lending/credit-scoring.js +81 -0
- package/dist/esm/apps/lending/eligibility.js +115 -0
- package/dist/esm/apps/lending/index.js +69 -0
- package/dist/esm/apps/lending/state-machines/index.js +5 -0
- package/dist/esm/apps/lending/state-machines/lending-zk-loan.js +409 -0
- package/dist/esm/apps/markets/index.js +8 -4
- package/dist/esm/apps/markets/state-machines/market-auction.js +14 -13
- package/dist/esm/apps/markets/state-machines/market-crowdfund.js +29 -24
- package/dist/esm/apps/markets/state-machines/market-group-buy.js +24 -26
- package/dist/esm/apps/markets/state-machines/market-prediction.js +80 -53
- package/dist/esm/apps/markets/state-machines/market-universal.js +5 -5
- package/dist/esm/generated/index.js +9 -5
- package/dist/esm/generated/openapi.js +5 -0
- package/dist/esm/generated/ottochain/apps/contracts/v1/contract.js +46 -46
- package/dist/esm/generated/ottochain/apps/identity/v1/identity.js +114 -120
- package/dist/esm/generated/ottochain/apps/markets/v1/market.js +100 -100
- package/dist/esm/index.js +21 -2
- package/dist/esm/openapi.js +1 -0
- package/dist/esm/ottochain/genesis-manifest.js +9 -9
- package/dist/esm/ottochain/index.js +2 -3
- package/dist/esm/ottochain/metagraph-client.js +65 -8
- package/dist/esm/ottochain/snapshot.js +4 -4
- package/dist/esm/ottochain/transaction.js +43 -3
- package/dist/esm/ottochain/types.js +15 -1
- package/dist/esm/privacy/index.js +6 -0
- package/dist/esm/privacy/sealed-bid.js +206 -0
- package/dist/esm/privacy/shield-app.js +127 -0
- package/dist/esm/schema/effects.js +35 -0
- package/dist/esm/schema/fiber-app.js +13 -6
- package/dist/esm/schema/guard-lint.js +346 -0
- package/dist/esm/schema/guards.js +229 -0
- package/dist/esm/signing.js +74 -0
- package/dist/esm/verify.js +8 -2
- package/dist/esm/zk/commit.js +44 -0
- package/dist/esm/zk/guard.js +99 -0
- package/dist/esm/zk/index.js +19 -0
- package/dist/esm/zk/preimage.js +30 -0
- package/dist/esm/zk/prover.js +82 -0
- package/dist/esm/zk/registry.js +55 -0
- package/dist/esm/zk/types.js +25 -0
- package/dist/esm/zk/witness.js +15 -0
- package/dist/types/apps/contracts/index.d.ts +69 -209
- package/dist/types/apps/contracts/state-machines/contract-agreement.d.ts +20 -95
- package/dist/types/apps/contracts/state-machines/contract-escrow.d.ts +46 -112
- package/dist/types/apps/corporate/index.d.ts +1040 -304
- package/dist/types/apps/corporate/state-machines/corp-board.d.ts +188 -52
- package/dist/types/apps/corporate/state-machines/corp-entity.d.ts +267 -62
- package/dist/types/apps/corporate/state-machines/corp-securities.d.ts +355 -131
- package/dist/types/apps/corporate/state-machines/corp-shareholders.d.ts +225 -53
- package/dist/types/apps/governance/index.d.ts +296 -398
- package/dist/types/apps/governance/state-machines/dao-multisig.d.ts +77 -92
- package/dist/types/apps/governance/state-machines/dao-reputation.d.ts +42 -66
- package/dist/types/apps/governance/state-machines/dao-single.d.ts +25 -47
- package/dist/types/apps/governance/state-machines/dao-token.d.ts +60 -49
- package/dist/types/apps/governance/state-machines/governance-simple.d.ts +87 -117
- package/dist/types/apps/governance/state-machines/governance-universal.d.ts +2 -2
- package/dist/types/apps/identity/constants.d.ts +32 -4
- package/dist/types/apps/identity/index.d.ts +378 -94
- package/dist/types/apps/identity/state-machines/identity-oracle.d.ts +16 -87
- package/dist/types/apps/identity/state-machines/identity-registry.d.ts +379 -0
- package/dist/types/apps/identity/state-machines/index.d.ts +1 -0
- package/dist/types/apps/index.d.ts +1 -0
- package/dist/types/apps/lending/assets.d.ts +258 -0
- package/dist/types/apps/lending/credit-scoring.d.ts +80 -0
- package/dist/types/apps/lending/eligibility.d.ts +83 -0
- package/dist/types/apps/lending/index.d.ts +548 -0
- package/dist/types/apps/lending/state-machines/index.d.ts +5 -0
- package/dist/types/apps/lending/state-machines/lending-zk-loan.d.ts +528 -0
- package/dist/types/apps/markets/index.d.ts +108 -203
- package/dist/types/apps/markets/state-machines/market-auction.d.ts +13 -37
- package/dist/types/apps/markets/state-machines/market-crowdfund.d.ts +16 -34
- package/dist/types/apps/markets/state-machines/market-group-buy.d.ts +17 -43
- package/dist/types/apps/markets/state-machines/market-prediction.d.ts +51 -72
- package/dist/types/apps/markets/state-machines/market-universal.d.ts +5 -5
- package/dist/types/generated/index.d.ts +5 -5
- package/dist/types/generated/openapi.d.ts +1257 -0
- package/dist/types/generated/ottochain/apps/contracts/v1/contract.d.ts +5 -5
- package/dist/types/generated/ottochain/apps/identity/v1/identity.d.ts +12 -12
- package/dist/types/generated/ottochain/apps/markets/v1/market.d.ts +11 -11
- package/dist/types/index.d.ts +6 -2
- package/dist/types/openapi.d.ts +22 -0
- package/dist/types/ottochain/genesis-manifest.d.ts +5 -5
- package/dist/types/ottochain/index.d.ts +5 -6
- package/dist/types/ottochain/metagraph-client.d.ts +49 -7
- package/dist/types/ottochain/snapshot.d.ts +6 -6
- package/dist/types/ottochain/transaction.d.ts +33 -1
- package/dist/types/ottochain/types.d.ts +335 -30
- package/dist/types/privacy/index.d.ts +6 -0
- package/dist/types/privacy/sealed-bid.d.ts +348 -0
- package/dist/types/privacy/shield-app.d.ts +48 -0
- package/dist/types/schema/effects.d.ts +34 -0
- package/dist/types/schema/fiber-app.d.ts +1 -2
- package/dist/types/schema/guard-lint.d.ts +111 -0
- package/dist/types/schema/guards.d.ts +134 -0
- package/dist/types/signing.d.ts +45 -0
- package/dist/types/validation.d.ts +22 -217
- package/dist/types/verify.d.ts +4 -0
- package/dist/types/zk/commit.d.ts +28 -0
- package/dist/types/zk/guard.d.ts +46 -0
- package/dist/types/zk/index.d.ts +19 -0
- package/dist/types/zk/preimage.d.ts +10 -0
- package/dist/types/zk/prover.d.ts +34 -0
- package/dist/types/zk/registry.d.ts +34 -0
- package/dist/types/zk/types.d.ts +33 -0
- package/dist/types/zk/witness.d.ts +40 -0
- package/package.json +27 -13
- package/dist/cjs/ottochain/normalize.js +0 -186
- package/dist/esm/ottochain/normalize.js +0 -179
- package/dist/types/ottochain/normalize.d.ts +0 -79
|
@@ -0,0 +1,528 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Privacy-preserving zk-loan — a private-finance lending fiber modeled on Midnight's
|
|
3
|
+
* zkLoan example, integrated with OttoChain's asset subsystem.
|
|
4
|
+
*
|
|
5
|
+
* The borrower proves, in zero-knowledge, that their PRIVATE financials satisfy the
|
|
6
|
+
* PUBLIC lending rule (collateral coverage and/or a credit-score floor) WITHOUT
|
|
7
|
+
* revealing the financials. The lender originates the loan. The collateral, principal,
|
|
8
|
+
* and repayment are ASSETS, driven through typed morphisms by the loan lifecycle.
|
|
9
|
+
*
|
|
10
|
+
* Privacy boundary (see docs/design/zk-loan-app.md):
|
|
11
|
+
* - PRIVATE (witness only): collateralValue, credit/income financials (income, score),
|
|
12
|
+
* outstanding debt, and the blinding salts. Never on-chain, never in the event.
|
|
13
|
+
* - PUBLIC (revealed): the loan principal amount, the collateral asset id (a locked
|
|
14
|
+
* handle, not its private valuation), the lending-rule logicHash, loan status, and
|
|
15
|
+
* the boolean "eligible" outcome — the chain learns *whether* the borrower qualifies,
|
|
16
|
+
* never *why*.
|
|
17
|
+
*
|
|
18
|
+
* The ORIGINATION guard (`originate`, COLLATERAL_LOCKED -> ACTIVE) is the semi-private
|
|
19
|
+
* gate: it verifies an SP1-Groth16 eligibility proof over `witness.{publicValues,proof}`
|
|
20
|
+
* with the lender's pinned verifying key, AND binds the proof's committed public values
|
|
21
|
+
* (parsed out of the opaque `publicValues` blob with native JLVM `cat`/`substr`) to the
|
|
22
|
+
* PUBLIC lending rule — `exprHash == $lendingRuleLogicHash`, `outputHash == $keccakTrue`,
|
|
23
|
+
* and the `ok` bit — so a proof can only originate a loan if it proves THE pinned rule
|
|
24
|
+
* evaluated to `true` on the borrower's hidden data. A missing/garbage witness makes the
|
|
25
|
+
* guard false and the transition is gracefully rejected (state untouched).
|
|
26
|
+
*
|
|
27
|
+
* The pinned public constants ($lendingRuleVKey, $lendingRuleLogicHash, $keccakTrue) live
|
|
28
|
+
* on the loan's create-state so the guard is a closed expression. They are produced
|
|
29
|
+
* client-side by `src/apps/lending` helpers (`buildOriginationGuard`, `pinLendingRule`)
|
|
30
|
+
* over `src/zk` (`exprHash`, `KECCAK_TRUE`).
|
|
31
|
+
*/
|
|
32
|
+
export declare const lendingZkLoanDef: {
|
|
33
|
+
readonly metadata: {
|
|
34
|
+
readonly name: "LendingZkLoan";
|
|
35
|
+
readonly app: "lending";
|
|
36
|
+
readonly type: "zkLoan";
|
|
37
|
+
readonly version: "1.0.0";
|
|
38
|
+
readonly description: "Privacy-preserving collateralized loan: the borrower proves loan eligibility (collateral coverage / credit-score floor) in zero-knowledge without revealing the financials; collateral, principal and repayment are asset-subsystem tokens driven by the loan lifecycle.";
|
|
39
|
+
readonly crossReferences: {
|
|
40
|
+
readonly borrowerIdentityId: "Links to the borrower's IdentityAgent";
|
|
41
|
+
readonly lenderIdentityId: "Links to the lender's IdentityAgent (loan originator)";
|
|
42
|
+
readonly collateralAssetId: "Asset instance locked as collateral (held by the loan's escrow fiber)";
|
|
43
|
+
readonly debtAssetId: "Asset instance representing the outstanding loan principal/debt minted to the borrower";
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
readonly createSchema: {
|
|
47
|
+
readonly required: readonly ["borrower", "lender", "principalAmount", "collateralAssetId", "collateralPolicy", "debtPolicy", "lendingRuleVKey", "lendingRuleLogicHash", "keccakTrue"];
|
|
48
|
+
readonly properties: {
|
|
49
|
+
readonly borrower: {
|
|
50
|
+
readonly type: "address";
|
|
51
|
+
readonly description: "DAG address of the borrower";
|
|
52
|
+
readonly immutable: true;
|
|
53
|
+
};
|
|
54
|
+
readonly lender: {
|
|
55
|
+
readonly type: "address";
|
|
56
|
+
readonly description: "DAG address of the lender / loan originator";
|
|
57
|
+
readonly immutable: true;
|
|
58
|
+
};
|
|
59
|
+
readonly principalAmount: {
|
|
60
|
+
readonly type: "integer";
|
|
61
|
+
readonly description: "PUBLIC loan principal (asset minor-units). The financials backing eligibility stay private.";
|
|
62
|
+
readonly minimum: 1;
|
|
63
|
+
readonly immutable: true;
|
|
64
|
+
};
|
|
65
|
+
readonly collateralAssetId: {
|
|
66
|
+
readonly type: "uuid";
|
|
67
|
+
readonly description: "Asset instance id pledged as collateral (its private valuation is never revealed).";
|
|
68
|
+
readonly immutable: true;
|
|
69
|
+
};
|
|
70
|
+
readonly collateralPolicy: {
|
|
71
|
+
readonly type: "string";
|
|
72
|
+
readonly description: "Collateral asset policy name (e.g. 'collateral-vault-v1.asset').";
|
|
73
|
+
readonly immutable: true;
|
|
74
|
+
};
|
|
75
|
+
readonly debtPolicy: {
|
|
76
|
+
readonly type: "string";
|
|
77
|
+
readonly description: "Debt/loan-token asset policy name (e.g. 'loan-debt-v1.asset').";
|
|
78
|
+
readonly immutable: true;
|
|
79
|
+
};
|
|
80
|
+
readonly escrowFiberId: {
|
|
81
|
+
readonly type: "uuid";
|
|
82
|
+
readonly description: "Fiber that custodies the locked collateral (AssetHolder.Fiber). Defaults to this loan fiber.";
|
|
83
|
+
};
|
|
84
|
+
readonly lendingRuleVKey: {
|
|
85
|
+
readonly type: "hash";
|
|
86
|
+
readonly description: "PINNED SP1 program verifying key (bytes32, 0x-hex) for the eligibility circuit.";
|
|
87
|
+
readonly immutable: true;
|
|
88
|
+
};
|
|
89
|
+
readonly lendingRuleLogicHash: {
|
|
90
|
+
readonly type: "hash";
|
|
91
|
+
readonly description: "PINNED logicHash of the public lending rule = keccak256(canonicalize(rule)). The proof's committed exprHash must equal this.";
|
|
92
|
+
readonly immutable: true;
|
|
93
|
+
};
|
|
94
|
+
readonly keccakTrue: {
|
|
95
|
+
readonly type: "hash";
|
|
96
|
+
readonly description: "PINNED keccak256(canonicalize(true)) — the outputHash a 'rule returned true' proof must commit.";
|
|
97
|
+
readonly immutable: true;
|
|
98
|
+
};
|
|
99
|
+
readonly dueOrdinal: {
|
|
100
|
+
readonly type: "integer";
|
|
101
|
+
readonly description: "Optional snapshot ordinal by which repayment is due.";
|
|
102
|
+
readonly minimum: 0;
|
|
103
|
+
};
|
|
104
|
+
};
|
|
105
|
+
};
|
|
106
|
+
readonly stateSchema: {
|
|
107
|
+
readonly properties: {
|
|
108
|
+
readonly status: {
|
|
109
|
+
readonly type: "string";
|
|
110
|
+
readonly computed: true;
|
|
111
|
+
};
|
|
112
|
+
readonly borrower: {
|
|
113
|
+
readonly type: "address";
|
|
114
|
+
readonly immutable: true;
|
|
115
|
+
};
|
|
116
|
+
readonly lender: {
|
|
117
|
+
readonly type: "address";
|
|
118
|
+
readonly immutable: true;
|
|
119
|
+
};
|
|
120
|
+
readonly principalAmount: {
|
|
121
|
+
readonly type: "integer";
|
|
122
|
+
readonly immutable: true;
|
|
123
|
+
};
|
|
124
|
+
readonly collateralAssetId: {
|
|
125
|
+
readonly type: "uuid";
|
|
126
|
+
readonly immutable: true;
|
|
127
|
+
};
|
|
128
|
+
readonly collateralPolicy: {
|
|
129
|
+
readonly type: "string";
|
|
130
|
+
readonly immutable: true;
|
|
131
|
+
};
|
|
132
|
+
readonly debtPolicy: {
|
|
133
|
+
readonly type: "string";
|
|
134
|
+
readonly immutable: true;
|
|
135
|
+
};
|
|
136
|
+
readonly escrowFiberId: {
|
|
137
|
+
readonly type: "uuid";
|
|
138
|
+
};
|
|
139
|
+
readonly debtAssetId: {
|
|
140
|
+
readonly type: "uuid";
|
|
141
|
+
readonly computed: true;
|
|
142
|
+
};
|
|
143
|
+
readonly lendingRuleVKey: {
|
|
144
|
+
readonly type: "hash";
|
|
145
|
+
readonly immutable: true;
|
|
146
|
+
};
|
|
147
|
+
readonly lendingRuleLogicHash: {
|
|
148
|
+
readonly type: "hash";
|
|
149
|
+
readonly immutable: true;
|
|
150
|
+
};
|
|
151
|
+
readonly keccakTrue: {
|
|
152
|
+
readonly type: "hash";
|
|
153
|
+
readonly immutable: true;
|
|
154
|
+
};
|
|
155
|
+
readonly dueOrdinal: {
|
|
156
|
+
readonly type: "integer";
|
|
157
|
+
};
|
|
158
|
+
readonly lockedAt: {
|
|
159
|
+
readonly type: "integer";
|
|
160
|
+
readonly computed: true;
|
|
161
|
+
};
|
|
162
|
+
readonly originatedAt: {
|
|
163
|
+
readonly type: "integer";
|
|
164
|
+
readonly computed: true;
|
|
165
|
+
};
|
|
166
|
+
readonly repaidAt: {
|
|
167
|
+
readonly type: "integer";
|
|
168
|
+
readonly computed: true;
|
|
169
|
+
};
|
|
170
|
+
readonly defaultedAt: {
|
|
171
|
+
readonly type: "integer";
|
|
172
|
+
readonly computed: true;
|
|
173
|
+
};
|
|
174
|
+
readonly liquidatedAt: {
|
|
175
|
+
readonly type: "integer";
|
|
176
|
+
readonly computed: true;
|
|
177
|
+
};
|
|
178
|
+
};
|
|
179
|
+
};
|
|
180
|
+
readonly eventSchemas: {
|
|
181
|
+
readonly lock_collateral: {
|
|
182
|
+
readonly description: "Borrower locks the pledged collateral asset into the loan escrow fiber (drives an asset Transfer/Mint into AssetHolder.Fiber).";
|
|
183
|
+
};
|
|
184
|
+
readonly originate: {
|
|
185
|
+
readonly description: "Lender originates the loan after the borrower's zk eligibility proof verifies. The witness carries the SP1-Groth16 {publicValues, proof}; the guard binds them to the pinned public lending rule. The effect mints the debt/principal asset to the borrower.";
|
|
186
|
+
readonly required: readonly ["witness", "debtAssetId"];
|
|
187
|
+
readonly properties: {
|
|
188
|
+
readonly witness: {
|
|
189
|
+
readonly type: "object";
|
|
190
|
+
readonly description: "Eligibility-proof witness: { publicValues: 0x-hex, proof: 0x-hex }. Exposed to the guard under the reserved `witness` key.";
|
|
191
|
+
readonly properties: {
|
|
192
|
+
readonly publicValues: {
|
|
193
|
+
readonly type: "string";
|
|
194
|
+
readonly description: "abi_encode(JlvmPublicValues), 0x-hex.";
|
|
195
|
+
};
|
|
196
|
+
readonly proof: {
|
|
197
|
+
readonly type: "string";
|
|
198
|
+
readonly description: "SP1-Groth16 proof bytes, 0x-hex.";
|
|
199
|
+
};
|
|
200
|
+
};
|
|
201
|
+
readonly required: readonly ["publicValues", "proof"];
|
|
202
|
+
};
|
|
203
|
+
readonly debtAssetId: {
|
|
204
|
+
readonly type: "uuid";
|
|
205
|
+
readonly description: "Asset instance id for the debt/principal token minted to the borrower.";
|
|
206
|
+
};
|
|
207
|
+
};
|
|
208
|
+
};
|
|
209
|
+
readonly repay: {
|
|
210
|
+
readonly description: "Borrower repays the principal (drives a Burn of the debt token); on success the collateral is released back to the borrower via the escrow fiber.";
|
|
211
|
+
};
|
|
212
|
+
readonly default_loan: {
|
|
213
|
+
readonly description: "Mark the loan defaulted once past due (drives the collateral toward liquidation).";
|
|
214
|
+
};
|
|
215
|
+
readonly liquidate: {
|
|
216
|
+
readonly description: "Lender liquidates a defaulted loan: the locked collateral is transferred to the lender via the escrow fiber.";
|
|
217
|
+
};
|
|
218
|
+
readonly cancel: {
|
|
219
|
+
readonly description: "Cancel a loan request before collateral is locked.";
|
|
220
|
+
readonly properties: {
|
|
221
|
+
readonly reason: {
|
|
222
|
+
readonly type: "string";
|
|
223
|
+
};
|
|
224
|
+
};
|
|
225
|
+
};
|
|
226
|
+
};
|
|
227
|
+
readonly states: {
|
|
228
|
+
readonly REQUESTED: {
|
|
229
|
+
readonly id: "REQUESTED";
|
|
230
|
+
readonly isFinal: false;
|
|
231
|
+
readonly metadata: {
|
|
232
|
+
readonly label: "Requested";
|
|
233
|
+
readonly description: "Loan requested; collateral not yet locked, eligibility not yet proven.";
|
|
234
|
+
readonly category: "initial";
|
|
235
|
+
};
|
|
236
|
+
};
|
|
237
|
+
readonly COLLATERAL_LOCKED: {
|
|
238
|
+
readonly id: "COLLATERAL_LOCKED";
|
|
239
|
+
readonly isFinal: false;
|
|
240
|
+
readonly metadata: {
|
|
241
|
+
readonly label: "Collateral Locked";
|
|
242
|
+
readonly description: "Collateral asset escrowed in the loan fiber; awaiting the lender's zk-gated origination.";
|
|
243
|
+
readonly category: "pending";
|
|
244
|
+
};
|
|
245
|
+
};
|
|
246
|
+
readonly ACTIVE: {
|
|
247
|
+
readonly id: "ACTIVE";
|
|
248
|
+
readonly isFinal: false;
|
|
249
|
+
readonly metadata: {
|
|
250
|
+
readonly label: "Active";
|
|
251
|
+
readonly description: "Loan originated (eligibility proven in zk); principal minted to the borrower.";
|
|
252
|
+
readonly category: "active";
|
|
253
|
+
};
|
|
254
|
+
};
|
|
255
|
+
readonly DEFAULTED: {
|
|
256
|
+
readonly id: "DEFAULTED";
|
|
257
|
+
readonly isFinal: false;
|
|
258
|
+
readonly metadata: {
|
|
259
|
+
readonly label: "Defaulted";
|
|
260
|
+
readonly description: "Loan past due and unpaid; collateral pending liquidation.";
|
|
261
|
+
readonly category: "pending";
|
|
262
|
+
};
|
|
263
|
+
};
|
|
264
|
+
readonly REPAID: {
|
|
265
|
+
readonly id: "REPAID";
|
|
266
|
+
readonly isFinal: true;
|
|
267
|
+
readonly metadata: {
|
|
268
|
+
readonly label: "Repaid";
|
|
269
|
+
readonly description: "Principal repaid (debt burned) and collateral released to the borrower.";
|
|
270
|
+
readonly category: "terminal";
|
|
271
|
+
};
|
|
272
|
+
};
|
|
273
|
+
readonly LIQUIDATED: {
|
|
274
|
+
readonly id: "LIQUIDATED";
|
|
275
|
+
readonly isFinal: true;
|
|
276
|
+
readonly metadata: {
|
|
277
|
+
readonly label: "Liquidated";
|
|
278
|
+
readonly description: "Defaulted loan settled by transferring the collateral to the lender.";
|
|
279
|
+
readonly category: "terminal";
|
|
280
|
+
};
|
|
281
|
+
};
|
|
282
|
+
readonly CANCELLED: {
|
|
283
|
+
readonly id: "CANCELLED";
|
|
284
|
+
readonly isFinal: true;
|
|
285
|
+
readonly metadata: {
|
|
286
|
+
readonly label: "Cancelled";
|
|
287
|
+
readonly description: "Loan request cancelled before any collateral was locked.";
|
|
288
|
+
readonly category: "terminal";
|
|
289
|
+
};
|
|
290
|
+
};
|
|
291
|
+
};
|
|
292
|
+
readonly initialState: "REQUESTED";
|
|
293
|
+
readonly transitions: readonly [{
|
|
294
|
+
readonly from: "REQUESTED";
|
|
295
|
+
readonly to: "COLLATERAL_LOCKED";
|
|
296
|
+
readonly eventName: "lock_collateral";
|
|
297
|
+
readonly guard: {
|
|
298
|
+
readonly and: readonly [{
|
|
299
|
+
readonly in: readonly [{
|
|
300
|
+
readonly var: "state.borrower";
|
|
301
|
+
}, {
|
|
302
|
+
readonly map: readonly [{
|
|
303
|
+
readonly var: "proofs";
|
|
304
|
+
}, {
|
|
305
|
+
readonly var: "address";
|
|
306
|
+
}];
|
|
307
|
+
}];
|
|
308
|
+
}, {
|
|
309
|
+
readonly "===": readonly [{
|
|
310
|
+
readonly var: "event.assetId";
|
|
311
|
+
}, {
|
|
312
|
+
readonly var: "state.collateralAssetId";
|
|
313
|
+
}];
|
|
314
|
+
}];
|
|
315
|
+
};
|
|
316
|
+
readonly effect: {
|
|
317
|
+
readonly merge: readonly [{
|
|
318
|
+
readonly var: "state";
|
|
319
|
+
}, {
|
|
320
|
+
readonly status: "COLLATERAL_LOCKED";
|
|
321
|
+
readonly lockedAt: {
|
|
322
|
+
readonly var: "$ordinal";
|
|
323
|
+
};
|
|
324
|
+
}];
|
|
325
|
+
};
|
|
326
|
+
readonly dependencies: readonly [];
|
|
327
|
+
}, {
|
|
328
|
+
readonly from: "REQUESTED";
|
|
329
|
+
readonly to: "CANCELLED";
|
|
330
|
+
readonly eventName: "cancel";
|
|
331
|
+
readonly guard: {
|
|
332
|
+
readonly or: readonly [{
|
|
333
|
+
readonly in: readonly [{
|
|
334
|
+
readonly var: "state.borrower";
|
|
335
|
+
}, {
|
|
336
|
+
readonly map: readonly [{
|
|
337
|
+
readonly var: "proofs";
|
|
338
|
+
}, {
|
|
339
|
+
readonly var: "address";
|
|
340
|
+
}];
|
|
341
|
+
}];
|
|
342
|
+
}, {
|
|
343
|
+
readonly in: readonly [{
|
|
344
|
+
readonly var: "state.lender";
|
|
345
|
+
}, {
|
|
346
|
+
readonly map: readonly [{
|
|
347
|
+
readonly var: "proofs";
|
|
348
|
+
}, {
|
|
349
|
+
readonly var: "address";
|
|
350
|
+
}];
|
|
351
|
+
}];
|
|
352
|
+
}];
|
|
353
|
+
};
|
|
354
|
+
readonly effect: {
|
|
355
|
+
readonly merge: readonly [{
|
|
356
|
+
readonly var: "state";
|
|
357
|
+
}, {
|
|
358
|
+
readonly status: "CANCELLED";
|
|
359
|
+
readonly cancelledAt: {
|
|
360
|
+
readonly var: "$ordinal";
|
|
361
|
+
};
|
|
362
|
+
readonly reason: {
|
|
363
|
+
readonly var: "event.reason";
|
|
364
|
+
};
|
|
365
|
+
}];
|
|
366
|
+
};
|
|
367
|
+
readonly dependencies: readonly [];
|
|
368
|
+
}, {
|
|
369
|
+
readonly from: "COLLATERAL_LOCKED";
|
|
370
|
+
readonly to: "ACTIVE";
|
|
371
|
+
readonly eventName: "originate";
|
|
372
|
+
readonly guard: {
|
|
373
|
+
readonly and: readonly [{
|
|
374
|
+
readonly in: readonly [{
|
|
375
|
+
readonly var: "state.lender";
|
|
376
|
+
}, {
|
|
377
|
+
readonly map: readonly [{
|
|
378
|
+
readonly var: "proofs";
|
|
379
|
+
}, {
|
|
380
|
+
readonly var: "address";
|
|
381
|
+
}];
|
|
382
|
+
}];
|
|
383
|
+
}, {
|
|
384
|
+
readonly groth16_verify: readonly [{
|
|
385
|
+
readonly var: "state.lendingRuleVKey";
|
|
386
|
+
}, {
|
|
387
|
+
readonly var: "event.witness.publicValues";
|
|
388
|
+
}, {
|
|
389
|
+
readonly var: "event.witness.proof";
|
|
390
|
+
}];
|
|
391
|
+
}, {
|
|
392
|
+
readonly "===": readonly [{
|
|
393
|
+
readonly cat: readonly ["0x", {
|
|
394
|
+
readonly substr: readonly [{
|
|
395
|
+
readonly var: "event.witness.publicValues";
|
|
396
|
+
}, 2, 64];
|
|
397
|
+
}];
|
|
398
|
+
}, {
|
|
399
|
+
readonly var: "state.lendingRuleLogicHash";
|
|
400
|
+
}];
|
|
401
|
+
}, {
|
|
402
|
+
readonly "===": readonly [{
|
|
403
|
+
readonly cat: readonly ["0x", {
|
|
404
|
+
readonly substr: readonly [{
|
|
405
|
+
readonly var: "event.witness.publicValues";
|
|
406
|
+
}, 130, 64];
|
|
407
|
+
}];
|
|
408
|
+
}, {
|
|
409
|
+
readonly var: "state.keccakTrue";
|
|
410
|
+
}];
|
|
411
|
+
}, {
|
|
412
|
+
readonly "===": readonly [{
|
|
413
|
+
readonly substr: readonly [{
|
|
414
|
+
readonly var: "event.witness.publicValues";
|
|
415
|
+
}, 256, 2];
|
|
416
|
+
}, "01"];
|
|
417
|
+
}];
|
|
418
|
+
};
|
|
419
|
+
readonly effect: {
|
|
420
|
+
readonly merge: readonly [{
|
|
421
|
+
readonly var: "state";
|
|
422
|
+
}, {
|
|
423
|
+
readonly status: "ACTIVE";
|
|
424
|
+
readonly originatedAt: {
|
|
425
|
+
readonly var: "$ordinal";
|
|
426
|
+
};
|
|
427
|
+
readonly debtAssetId: {
|
|
428
|
+
readonly var: "event.debtAssetId";
|
|
429
|
+
};
|
|
430
|
+
}];
|
|
431
|
+
};
|
|
432
|
+
readonly dependencies: readonly [];
|
|
433
|
+
}, {
|
|
434
|
+
readonly from: "ACTIVE";
|
|
435
|
+
readonly to: "REPAID";
|
|
436
|
+
readonly eventName: "repay";
|
|
437
|
+
readonly guard: {
|
|
438
|
+
readonly in: readonly [{
|
|
439
|
+
readonly var: "state.borrower";
|
|
440
|
+
}, {
|
|
441
|
+
readonly map: readonly [{
|
|
442
|
+
readonly var: "proofs";
|
|
443
|
+
}, {
|
|
444
|
+
readonly var: "address";
|
|
445
|
+
}];
|
|
446
|
+
}];
|
|
447
|
+
};
|
|
448
|
+
readonly effect: {
|
|
449
|
+
readonly merge: readonly [{
|
|
450
|
+
readonly var: "state";
|
|
451
|
+
}, {
|
|
452
|
+
readonly status: "REPAID";
|
|
453
|
+
readonly repaidAt: {
|
|
454
|
+
readonly var: "$ordinal";
|
|
455
|
+
};
|
|
456
|
+
readonly _transferAsset: readonly [{
|
|
457
|
+
readonly assetId: {
|
|
458
|
+
readonly var: "state.collateralAssetId";
|
|
459
|
+
};
|
|
460
|
+
readonly recipient: {
|
|
461
|
+
readonly var: "state.borrower";
|
|
462
|
+
};
|
|
463
|
+
}];
|
|
464
|
+
}];
|
|
465
|
+
};
|
|
466
|
+
readonly dependencies: readonly [];
|
|
467
|
+
}, {
|
|
468
|
+
readonly from: "ACTIVE";
|
|
469
|
+
readonly to: "DEFAULTED";
|
|
470
|
+
readonly eventName: "default_loan";
|
|
471
|
+
readonly guard: {
|
|
472
|
+
readonly and: readonly [{
|
|
473
|
+
readonly var: "state.dueOrdinal";
|
|
474
|
+
}, {
|
|
475
|
+
readonly ">=": readonly [{
|
|
476
|
+
readonly var: "$ordinal";
|
|
477
|
+
}, {
|
|
478
|
+
readonly var: "state.dueOrdinal";
|
|
479
|
+
}];
|
|
480
|
+
}];
|
|
481
|
+
};
|
|
482
|
+
readonly effect: {
|
|
483
|
+
readonly merge: readonly [{
|
|
484
|
+
readonly var: "state";
|
|
485
|
+
}, {
|
|
486
|
+
readonly status: "DEFAULTED";
|
|
487
|
+
readonly defaultedAt: {
|
|
488
|
+
readonly var: "$ordinal";
|
|
489
|
+
};
|
|
490
|
+
}];
|
|
491
|
+
};
|
|
492
|
+
readonly dependencies: readonly [];
|
|
493
|
+
}, {
|
|
494
|
+
readonly from: "DEFAULTED";
|
|
495
|
+
readonly to: "LIQUIDATED";
|
|
496
|
+
readonly eventName: "liquidate";
|
|
497
|
+
readonly guard: {
|
|
498
|
+
readonly in: readonly [{
|
|
499
|
+
readonly var: "state.lender";
|
|
500
|
+
}, {
|
|
501
|
+
readonly map: readonly [{
|
|
502
|
+
readonly var: "proofs";
|
|
503
|
+
}, {
|
|
504
|
+
readonly var: "address";
|
|
505
|
+
}];
|
|
506
|
+
}];
|
|
507
|
+
};
|
|
508
|
+
readonly effect: {
|
|
509
|
+
readonly merge: readonly [{
|
|
510
|
+
readonly var: "state";
|
|
511
|
+
}, {
|
|
512
|
+
readonly status: "LIQUIDATED";
|
|
513
|
+
readonly liquidatedAt: {
|
|
514
|
+
readonly var: "$ordinal";
|
|
515
|
+
};
|
|
516
|
+
readonly _transferAsset: readonly [{
|
|
517
|
+
readonly assetId: {
|
|
518
|
+
readonly var: "state.collateralAssetId";
|
|
519
|
+
};
|
|
520
|
+
readonly recipient: {
|
|
521
|
+
readonly var: "state.lender";
|
|
522
|
+
};
|
|
523
|
+
}];
|
|
524
|
+
}];
|
|
525
|
+
};
|
|
526
|
+
readonly dependencies: readonly [];
|
|
527
|
+
}];
|
|
528
|
+
};
|