otto-intel-mcp 0.1.2 → 0.1.4
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 +76 -18
- package/dist/account-userop-policy-definition.d.ts +14 -0
- package/dist/account-userop-policy-definition.js +12 -0
- package/dist/account-userop-policy-relation.d.ts +371 -0
- package/dist/account-userop-policy-relation.js +87 -0
- package/dist/adapter/cdp-signer.d.ts +76 -9
- package/dist/adapter/cdp-signer.js +274 -33
- package/dist/adapter/evm-call-failure.d.ts +29 -0
- package/dist/adapter/evm-call-failure.js +109 -0
- package/dist/adapter/refusal.d.ts +1 -1
- package/dist/adapter/refusal.js +13 -0
- package/dist/adapter/route-simulator.d.ts +91 -0
- package/dist/adapter/route-simulator.js +143 -0
- package/dist/adapter-cdp-index.d.ts +1 -1
- package/dist/executable-equities.d.ts +55 -0
- package/dist/executable-equities.js +116 -0
- package/dist/executable-yield-markets.d.ts +261 -0
- package/dist/executable-yield-markets.js +154 -0
- package/dist/execution-account-gas-quote.d.ts +141 -0
- package/dist/execution-account-gas-quote.js +443 -0
- package/dist/execution-account-gas-review.d.ts +123 -0
- package/dist/execution-account-gas-review.js +104 -0
- package/dist/execution-account-gas-runtime.d.ts +33 -0
- package/dist/execution-account-gas-runtime.js +131 -0
- package/dist/execution-account-gas-view.d.ts +936 -0
- package/dist/execution-account-gas-view.js +56 -0
- package/dist/execution-config.d.ts +3 -0
- package/dist/execution-config.js +4 -0
- package/dist/execution-delegated-definition.d.ts +7 -6
- package/dist/execution-delegated-definition.js +13 -2
- package/dist/execution-delegation-admin-definition.d.ts +127 -5
- package/dist/execution-delegation-admin-definition.js +155 -5
- package/dist/execution-delegation-admin.d.ts +48 -2
- package/dist/execution-delegation-admin.js +422 -12
- package/dist/execution-delegation-cap-store.d.ts +386 -0
- package/dist/execution-delegation-cap-store.js +1150 -0
- package/dist/execution-delegation-exit-definition.d.ts +309 -0
- package/dist/execution-delegation-exit-definition.js +204 -0
- package/dist/execution-delegation-exit-store.d.ts +114 -0
- package/dist/execution-delegation-exit-store.js +671 -0
- package/dist/execution-delegation-exit.d.ts +4 -0
- package/dist/execution-delegation-exit.js +614 -0
- package/dist/execution-delegation-finality.d.ts +22 -0
- package/dist/execution-delegation-finality.js +90 -0
- package/dist/execution-delegation-operation-store.d.ts +129 -0
- package/dist/execution-delegation-operation-store.js +1107 -0
- package/dist/execution-delegation-operations-definition.d.ts +282 -0
- package/dist/execution-delegation-operations-definition.js +117 -0
- package/dist/execution-delegation-operations.d.ts +6 -0
- package/dist/execution-delegation-operations.js +282 -0
- package/dist/execution-delegation-policy.d.ts +154 -8
- package/dist/execution-delegation-policy.js +273 -40
- package/dist/execution-delegation.d.ts +51 -0
- package/dist/execution-delegation.js +441 -31
- package/dist/execution-errors.d.ts +1 -1
- package/dist/execution-errors.js +122 -0
- package/dist/execution-index.d.ts +7 -2
- package/dist/execution-index.js +7 -2
- package/dist/execution-journal-schema.d.ts +96 -0
- package/dist/execution-journal-schema.js +368 -0
- package/dist/execution-journal-tables.d.ts +14 -0
- package/dist/execution-journal-tables.js +227 -0
- package/dist/execution-policy-compatibility.d.ts +34 -0
- package/dist/execution-policy-compatibility.js +76 -0
- package/dist/execution-registration.d.ts +54 -2
- package/dist/execution-registration.js +151 -5
- package/dist/execution-sponsored-account-profile.d.ts +32 -0
- package/dist/execution-sponsored-account-profile.js +59 -0
- package/dist/execution-sponsored-account.d.ts +1519 -0
- package/dist/execution-sponsored-account.js +222 -0
- package/dist/execution-sponsored-definition.d.ts +1713 -0
- package/dist/execution-sponsored-definition.js +185 -0
- package/dist/execution-sponsored-gas-policy.d.ts +27 -0
- package/dist/execution-sponsored-gas-policy.js +110 -0
- package/dist/execution-sponsored-hosted.d.ts +3 -0
- package/dist/execution-sponsored-hosted.js +71 -0
- package/dist/execution-sponsored-index.d.ts +1322 -0
- package/dist/execution-sponsored-index.js +102 -0
- package/dist/execution-sponsored-mcp-definition.d.ts +1662 -0
- package/dist/execution-sponsored-mcp-definition.js +94 -0
- package/dist/execution-sponsored-receipt.d.ts +47 -0
- package/dist/execution-sponsored-receipt.js +74 -0
- package/dist/execution-sponsored-registration.d.ts +14 -0
- package/dist/execution-sponsored-registration.js +77 -0
- package/dist/execution-sponsored-runtime.d.ts +84 -0
- package/dist/execution-sponsored-runtime.js +149 -0
- package/dist/execution-sponsored-settlement.d.ts +15 -0
- package/dist/execution-sponsored-settlement.js +88 -0
- package/dist/execution-sponsored-store.d.ts +67 -0
- package/dist/execution-sponsored-store.js +517 -0
- package/dist/execution-sponsored-transport.d.ts +90 -0
- package/dist/execution-sponsored-transport.js +180 -0
- package/dist/execution-tool-definitions.d.ts +21 -21
- package/dist/execution-tool-definitions.js +0 -7
- package/dist/execution-tools.d.ts +53 -1
- package/dist/execution-tools.js +171 -13
- package/dist/execution-worker-guard.d.ts +28 -0
- package/dist/execution-worker-guard.js +124 -0
- package/dist/hybrid-yield-index.d.ts +10 -0
- package/dist/hybrid-yield-index.js +11 -0
- package/dist/hybrid-yield-markets.d.ts +96 -0
- package/dist/hybrid-yield-markets.js +124 -0
- package/dist/hybrid-yield.d.ts +411 -0
- package/dist/hybrid-yield.js +155 -0
- package/dist/hyperliquid-order-builder.js +4 -0
- package/dist/lifi-execution-client.d.ts +6 -0
- package/dist/lifi-execution-client.js +3 -0
- package/dist/lp-userop-account.d.ts +461 -0
- package/dist/lp-userop-account.js +417 -0
- package/dist/lp-userop-authority.d.ts +49 -0
- package/dist/lp-userop-authority.js +211 -0
- package/dist/lp-userop-definition.d.ts +233 -0
- package/dist/lp-userop-definition.js +85 -0
- package/dist/lp-userop-hosted.d.ts +3 -0
- package/dist/lp-userop-hosted.js +73 -0
- package/dist/lp-userop-index.d.ts +1569 -0
- package/dist/lp-userop-index.js +112 -0
- package/dist/lp-userop-mcp-definition.d.ts +1220 -0
- package/dist/lp-userop-mcp-definition.js +46 -0
- package/dist/lp-userop-operation.d.ts +1230 -0
- package/dist/lp-userop-operation.js +140 -0
- package/dist/lp-userop-registration.d.ts +14 -0
- package/dist/lp-userop-registration.js +70 -0
- package/dist/lp-userop-settlement.d.ts +89 -0
- package/dist/lp-userop-settlement.js +184 -0
- package/dist/lp-userop.d.ts +643 -0
- package/dist/lp-userop.js +343 -0
- package/dist/native-yield-account-definition.d.ts +1192 -0
- package/dist/native-yield-account-definition.js +232 -0
- package/dist/native-yield-account-gas.d.ts +58 -0
- package/dist/native-yield-account-gas.js +228 -0
- package/dist/native-yield-account-index.d.ts +23 -0
- package/dist/native-yield-account-index.js +28 -0
- package/dist/native-yield-account-policy.d.ts +168 -0
- package/dist/native-yield-account-policy.js +525 -0
- package/dist/native-yield-account-rpc.d.ts +8 -0
- package/dist/native-yield-account-rpc.js +128 -0
- package/dist/native-yield-account-runtime.d.ts +71 -0
- package/dist/native-yield-account-runtime.js +125 -0
- package/dist/native-yield-account-store.d.ts +40 -0
- package/dist/native-yield-account-store.js +307 -0
- package/dist/native-yield-account.d.ts +662 -0
- package/dist/native-yield-account.js +371 -0
- package/dist/native-yield-consent-store.d.ts +20 -0
- package/dist/native-yield-consent-store.js +317 -0
- package/dist/native-yield-definition.d.ts +288 -0
- package/dist/native-yield-definition.js +105 -0
- package/dist/native-yield-reader.d.ts +4 -0
- package/dist/native-yield-reader.js +137 -0
- package/dist/native-yield-settlement.d.ts +48 -0
- package/dist/native-yield-settlement.js +167 -0
- package/dist/native-yield-simulation.d.ts +18 -0
- package/dist/native-yield-simulation.js +45 -0
- package/dist/native-yield-userop-account.d.ts +675 -0
- package/dist/native-yield-userop-account.js +357 -0
- package/dist/native-yield-userop-authority.d.ts +214 -0
- package/dist/native-yield-userop-authority.js +296 -0
- package/dist/native-yield-userop-definition.d.ts +331 -0
- package/dist/native-yield-userop-definition.js +105 -0
- package/dist/native-yield-userop-hosted.d.ts +3 -0
- package/dist/native-yield-userop-hosted.js +71 -0
- package/dist/native-yield-userop-index.d.ts +1522 -0
- package/dist/native-yield-userop-index.js +142 -0
- package/dist/native-yield-userop-mcp-definition.d.ts +1356 -0
- package/dist/native-yield-userop-mcp-definition.js +50 -0
- package/dist/native-yield-userop-operation.d.ts +845 -0
- package/dist/native-yield-userop-operation.js +127 -0
- package/dist/native-yield-userop-policy.d.ts +23 -0
- package/dist/native-yield-userop-policy.js +25 -0
- package/dist/native-yield-userop-registration.d.ts +17 -0
- package/dist/native-yield-userop-registration.js +76 -0
- package/dist/native-yield-userop-settlement.d.ts +8 -0
- package/dist/native-yield-userop-settlement.js +79 -0
- package/dist/native-yield-userop-simulation.d.ts +18 -0
- package/dist/native-yield-userop-simulation.js +34 -0
- package/dist/native-yield-userop.d.ts +35 -0
- package/dist/native-yield-userop.js +156 -0
- package/dist/native-yield-verify.d.ts +30 -0
- package/dist/native-yield-verify.js +141 -0
- package/dist/native-yield.d.ts +17 -0
- package/dist/native-yield.js +119 -0
- package/dist/stdio-main.js +0 -0
- package/dist/stock-buy-definition.d.ts +338 -0
- package/dist/stock-buy-definition.js +127 -0
- package/dist/stock-buy-oracle.d.ts +8 -0
- package/dist/stock-buy-oracle.js +22 -0
- package/dist/stock-buy.d.ts +17 -0
- package/dist/stock-buy.js +164 -0
- package/dist/tool-definitions.d.ts +3 -1
- package/dist/tool-definitions.js +55 -2
- package/dist/vendor/lp-v3/lp-v3-atomic-contract.d.ts +445 -0
- package/dist/vendor/lp-v3/lp-v3-atomic-contract.js +90 -0
- package/dist/vendor/lp-v3/lp-v3-atomic-evidence.d.ts +14 -0
- package/dist/vendor/lp-v3/lp-v3-atomic-evidence.js +82 -0
- package/dist/vendor/lp-v3/lp-v3-atomic-index.d.ts +80 -0
- package/dist/vendor/lp-v3/lp-v3-atomic-index.js +19 -0
- package/dist/vendor/lp-v3/lp-v3-atomic-plan.d.ts +43 -0
- package/dist/vendor/lp-v3/lp-v3-atomic-plan.js +112 -0
- package/dist/vendor/lp-v3/lp-v3-atomic-read-contract.d.ts +312 -0
- package/dist/vendor/lp-v3/lp-v3-atomic-read-contract.js +41 -0
- package/dist/vendor/lp-v3/lp-v3-atomic-read-index.d.ts +3 -0
- package/dist/vendor/lp-v3/lp-v3-atomic-read-index.js +3 -0
- package/dist/vendor/lp-v3/lp-v3-atomic-read-rpc.d.ts +49 -0
- package/dist/vendor/lp-v3/lp-v3-atomic-read-rpc.js +88 -0
- package/dist/vendor/lp-v3/lp-v3-atomic-read.d.ts +17 -0
- package/dist/vendor/lp-v3/lp-v3-atomic-read.js +232 -0
- package/dist/vendor/lp-v3/lp-v3-atomic-settlement.d.ts +105 -0
- package/dist/vendor/lp-v3/lp-v3-atomic-settlement.js +162 -0
- package/dist/vendor/lp-v3/lp-v3-collect-protocol-contract.d.ts +606 -0
- package/dist/vendor/lp-v3/lp-v3-collect-protocol-contract.js +59 -0
- package/dist/vendor/lp-v3/lp-v3-collect-protocol-index.d.ts +168 -0
- package/dist/vendor/lp-v3/lp-v3-collect-protocol-index.js +23 -0
- package/dist/vendor/lp-v3/lp-v3-collect-protocol-observation.d.ts +32 -0
- package/dist/vendor/lp-v3/lp-v3-collect-protocol-observation.js +228 -0
- package/dist/vendor/lp-v3/lp-v3-collect-protocol-plan.d.ts +11 -0
- package/dist/vendor/lp-v3/lp-v3-collect-protocol-plan.js +91 -0
- package/dist/vendor/lp-v3/lp-v3-collect-protocol-reconcile.d.ts +9 -0
- package/dist/vendor/lp-v3/lp-v3-collect-protocol-reconcile.js +124 -0
- package/dist/vendor/lp-v3/lp-v3-contract.d.ts +538 -0
- package/dist/vendor/lp-v3/lp-v3-contract.js +137 -0
- package/dist/vendor/lp-v3/lp-v3-evidence.d.ts +25 -0
- package/dist/vendor/lp-v3/lp-v3-evidence.js +168 -0
- package/dist/vendor/lp-v3/lp-v3-plan.d.ts +22 -0
- package/dist/vendor/lp-v3/lp-v3-plan.js +135 -0
- package/dist/vendor/lp-v3/types.d.ts +131 -0
- package/dist/vendor/lp-v3/types.js +6 -0
- package/dist/vendor/lp-v3/v4-math.d.ts +18 -0
- package/dist/vendor/lp-v3/v4-math.js +90 -0
- package/dist/yield-deposit-definition.d.ts +374 -0
- package/dist/yield-deposit-definition.js +123 -0
- package/dist/yield-deposit.d.ts +16 -0
- package/dist/yield-deposit.js +149 -0
- package/dist/yield-route-semantics.d.ts +27 -0
- package/dist/yield-route-semantics.js +71 -0
- package/dist/yield-withdraw-definition.d.ts +357 -0
- package/dist/yield-withdraw-definition.js +90 -0
- package/dist/yield-withdraw.d.ts +11 -0
- package/dist/yield-withdraw.js +122 -0
- package/package.json +239 -7
|
@@ -0,0 +1,371 @@
|
|
|
1
|
+
/** Manual, session-authenticated native account flow. No autonomous continuation and no ambiguous replay. */
|
|
2
|
+
import { randomUUID } from 'node:crypto';
|
|
3
|
+
import { getAddress, keccak256 } from 'viem';
|
|
4
|
+
import { hybridYieldCommitment } from './hybrid-yield-markets.js';
|
|
5
|
+
import { NATIVE_YIELD_ERC20_ABI, refuseNative } from './native-yield-definition.js';
|
|
6
|
+
import { prepareNativeYield } from './native-yield.js';
|
|
7
|
+
import { viemNativeYieldReader } from './native-yield-reader.js';
|
|
8
|
+
import { verifyNativeYieldPlan, nativeYieldAllowanceRevocation } from './native-yield-verify.js';
|
|
9
|
+
import { simulateNativeYieldPlan } from './native-yield-simulation.js';
|
|
10
|
+
import { readNativeYieldSettlement } from './native-yield-settlement.js';
|
|
11
|
+
import { createNativeYieldConsent, confirmNativeYieldConsent, readConfirmedNativeYieldConsent, revokeNativeYieldConsent, readNativeYieldConsent } from './native-yield-consent-store.js';
|
|
12
|
+
import { nativeAccountDigest, nativeAccountRevocationCommitment } from './native-yield-account-store.js';
|
|
13
|
+
import { deriveExactApprovedNativeMarketLimits, assertNativeDepositWithinOwnerUsdCap, assertNativeInputWithinApprovedAtomicCeiling, resolveNativeYieldAccountActivation, nativeYieldAccountActivationCommitment } from './native-yield-account-policy.js';
|
|
14
|
+
import { prepareNativeYieldAccountTransaction, revalidateNativeYieldAccountTransaction } from './native-yield-account-gas.js';
|
|
15
|
+
import { proveNativeYieldAccountTransaction } from './native-yield-account-rpc.js';
|
|
16
|
+
import { NATIVE_ACCOUNT_CONSENT_REVIEW_INPUT, NATIVE_ACCOUNT_CONSENT_CONFIRM_INPUT, NATIVE_ACCOUNT_PREPARE_INPUT, NATIVE_ACCOUNT_SUBMIT_INPUT, NATIVE_ACCOUNT_READ_INPUT, NATIVE_ACCOUNT_RECONCILE_INPUT, NATIVE_ACCOUNT_REVOKE_INPUT, NATIVE_ACCOUNT_COST_QUOTE_SCHEMA, NATIVE_YIELD_ACCOUNT_ACTIVATIONS, NATIVE_ACCOUNT_CONTINUE_INPUT, NATIVE_ACCOUNT_OPERATION_VIEW_SCHEMA } from './native-yield-account-definition.js';
|
|
17
|
+
function storedQuote(quote) {
|
|
18
|
+
return NATIVE_ACCOUNT_COST_QUOTE_SCHEMA.parse(JSON.parse(JSON.stringify(quote, (_key, value) => typeof value === 'bigint' ? value.toString() : value)));
|
|
19
|
+
}
|
|
20
|
+
function gasLimits(raw) {
|
|
21
|
+
return { maxGasLimit: BigInt(raw.maxGasLimit), maxFeePerGasWei: BigInt(raw.maxFeePerGasWei),
|
|
22
|
+
maxPriorityFeePerGasWei: BigInt(raw.maxPriorityFeePerGasWei), maxEstimatedTotalCostWei: BigInt(raw.maxEstimatedTotalCostWei),
|
|
23
|
+
gasLimitBufferBps: raw.gasLimitBufferBps };
|
|
24
|
+
}
|
|
25
|
+
function errorCode(error) {
|
|
26
|
+
const code = error?.code;
|
|
27
|
+
return typeof code === 'string' && /^[A-Z0-9_]{1,100}$/.test(code) ? code : 'NATIVE_ACTION_STOPPED';
|
|
28
|
+
}
|
|
29
|
+
function uncertain(step) { return ['prepared', 'submitted', 'unknown'].includes(step.state); }
|
|
30
|
+
export class NativeYieldAccountService {
|
|
31
|
+
runtime;
|
|
32
|
+
cdp;
|
|
33
|
+
store;
|
|
34
|
+
guards;
|
|
35
|
+
activations;
|
|
36
|
+
constructor(runtime, cdp, store, guards, activations = NATIVE_YIELD_ACCOUNT_ACTIVATIONS) {
|
|
37
|
+
this.runtime = runtime;
|
|
38
|
+
this.cdp = cdp;
|
|
39
|
+
this.store = store;
|
|
40
|
+
this.guards = guards;
|
|
41
|
+
this.activations = activations;
|
|
42
|
+
// One project policy, one explicit account scope. A manifest can cover both supported chains.
|
|
43
|
+
if (activations.length > 1)
|
|
44
|
+
throw new Error('NATIVE_ACTIVATION_AMBIGUOUS');
|
|
45
|
+
}
|
|
46
|
+
activation(chainId) {
|
|
47
|
+
return resolveNativeYieldAccountActivation(chainId ?? this.activations[0]?.deployments[0]?.chainId ?? 8453, this.activations);
|
|
48
|
+
}
|
|
49
|
+
protocol(activation) {
|
|
50
|
+
return { reader: viemNativeYieldReader(this.runtime.clients, this.runtime.now), deployments: activation.deployments, nowMs: this.runtime.now };
|
|
51
|
+
}
|
|
52
|
+
context(plan, maximumInputAtomic) {
|
|
53
|
+
return { account: { address: plan.owner, chainId: plan.chainId }, maximumInputAtomic: BigInt(maximumInputAtomic) };
|
|
54
|
+
}
|
|
55
|
+
async owned(accessToken, operationId) {
|
|
56
|
+
const who = await this.runtime.identity(accessToken), op = this.store.read(who.userId, operationId);
|
|
57
|
+
if (!who.accounts.includes(getAddress(op.account)))
|
|
58
|
+
return refuseNative('NATIVE_OWNER_MISMATCH', 'The current session does not own this operation account');
|
|
59
|
+
return op;
|
|
60
|
+
}
|
|
61
|
+
async reviewConsent(raw) {
|
|
62
|
+
const input = NATIVE_ACCOUNT_CONSENT_REVIEW_INPUT.parse(raw), activation = this.activation();
|
|
63
|
+
if (activation.mode !== 'enabled')
|
|
64
|
+
return refuseNative('NATIVE_EXECUTION_UNAVAILABLE', 'New native consent is unavailable');
|
|
65
|
+
const current = await this.runtime.authority(input.accessToken, input.account, activation, 'consent');
|
|
66
|
+
const consent = createNativeYieldConsent(this.store.db, current.authority, this.runtime.now());
|
|
67
|
+
return { schemaVersion: '1', consent, terms: activation, policyPhase: current.policyPhase,
|
|
68
|
+
requiresSeparateOperationReview: true, automaticExecutionEnabled: false };
|
|
69
|
+
}
|
|
70
|
+
async confirmConsent(raw) {
|
|
71
|
+
const input = NATIVE_ACCOUNT_CONSENT_CONFIRM_INPUT.parse(raw), who = await this.runtime.identity(input.accessToken);
|
|
72
|
+
// The store owns the challenge identity; no caller-supplied account or authority is accepted.
|
|
73
|
+
const challenge = readNativeYieldConsent(this.store.db, who.userId, input.consentId);
|
|
74
|
+
if (!challenge)
|
|
75
|
+
return refuseNative('NATIVE_CONSENT_NOT_FOUND', 'The consent review is unavailable');
|
|
76
|
+
const activation = this.activation();
|
|
77
|
+
if (activation.mode !== 'enabled')
|
|
78
|
+
return refuseNative('NATIVE_EXECUTION_UNAVAILABLE', 'New native consent is unavailable');
|
|
79
|
+
const current = await this.runtime.authority(input.accessToken, challenge.authority.account, activation, 'consent');
|
|
80
|
+
const consent = confirmNativeYieldConsent(this.store.db, { userId: who.userId, consentId: input.consentId, consentCommitment: input.consentCommitment }, current.authority, this.runtime.now());
|
|
81
|
+
return { schemaVersion: '1', consent, policyPhase: current.policyPhase, automaticExecutionEnabled: false };
|
|
82
|
+
}
|
|
83
|
+
async revokeConsent(raw) {
|
|
84
|
+
const input = NATIVE_ACCOUNT_CONSENT_REVIEW_INPUT.parse(raw), who = await this.runtime.identity(input.accessToken);
|
|
85
|
+
if (!who.accounts.includes(getAddress(input.account)))
|
|
86
|
+
return refuseNative('NATIVE_OWNER_MISMATCH', 'The session does not own this account');
|
|
87
|
+
revokeNativeYieldConsent(this.store.db, who.userId, input.account, this.runtime.now());
|
|
88
|
+
return { schemaVersion: '1', nativeConsentRevoked: true, existingOperationRequiresReconciliation: true };
|
|
89
|
+
}
|
|
90
|
+
async prepare(raw) {
|
|
91
|
+
const input = NATIVE_ACCOUNT_PREPARE_INPUT.parse(raw), request = input.input, activation = this.activation(request.accountProfile.chainId);
|
|
92
|
+
if (activation.mode !== 'enabled')
|
|
93
|
+
return refuseNative('NATIVE_EXECUTION_UNAVAILABLE', 'New native execution is unavailable');
|
|
94
|
+
const current = await this.runtime.authority(input.accessToken, request.accountProfile.address, activation, 'send');
|
|
95
|
+
const consent = readConfirmedNativeYieldConsent(this.store.db, current.authority.userId, current.authority.account, this.runtime.now());
|
|
96
|
+
if (!consent)
|
|
97
|
+
return refuseNative('NATIVE_CONSENT_REQUIRED', 'Review and confirm the native scope before preparing an operation');
|
|
98
|
+
const limits = deriveExactApprovedNativeMarketLimits(activation, { chainId: request.accountProfile.chainId,
|
|
99
|
+
marketId: request.marketId, registryCommitment: request.registryCommitment, action: request.action });
|
|
100
|
+
assertNativeInputWithinApprovedAtomicCeiling(BigInt(request.amount), limits);
|
|
101
|
+
if (request.action === 'deposit')
|
|
102
|
+
assertNativeDepositWithinOwnerUsdCap({ amountAtomic: BigInt(request.amount), authority: current.authority,
|
|
103
|
+
limits, priceObservation: await this.runtime.price(limits), nowMs: this.runtime.now() });
|
|
104
|
+
const plan = await prepareNativeYield(this.protocol(activation), request);
|
|
105
|
+
await verifyNativeYieldPlan(this.protocol(activation), plan, request, this.context(plan, limits.maximumInputAtomic.toString()));
|
|
106
|
+
const fresh = await this.runtime.authority(input.accessToken, plan.owner, activation, 'send');
|
|
107
|
+
if (hybridYieldCommitment(fresh.authority) !== hybridYieldCommitment(consent.authority))
|
|
108
|
+
return refuseNative('NATIVE_CONSENT_STALE', 'Account authority changed; review native scope again');
|
|
109
|
+
const op = this.store.create({ input: request, plan, consent, activation, maximumInputAtomic: limits.maximumInputAtomic.toString(),
|
|
110
|
+
maximumOperationEstimatedCostWei: limits.gasLimits.maxOperationEstimatedCostWei });
|
|
111
|
+
const preparedGuard = await this.guards.acquire('native', op.operationId, true);
|
|
112
|
+
preparedGuard.release();
|
|
113
|
+
return this.view(op);
|
|
114
|
+
}
|
|
115
|
+
async guard(op, token, recovery = false) {
|
|
116
|
+
const activation = this.activation(op.chainId);
|
|
117
|
+
if (!recovery && (activation.mode !== 'enabled' || nativeYieldAccountActivationCommitment(activation) !==
|
|
118
|
+
nativeYieldAccountActivationCommitment(op.context.activation)))
|
|
119
|
+
return refuseNative('NATIVE_ACTIVATION_CHANGED', 'The reviewed execution configuration changed');
|
|
120
|
+
const current = await this.runtime.authority(token, op.account, activation, 'send');
|
|
121
|
+
if (current.authority.userId !== op.userId)
|
|
122
|
+
return refuseNative('NATIVE_OWNER_MISMATCH', 'The session identity changed');
|
|
123
|
+
if (!recovery)
|
|
124
|
+
this.store.assertConsent(op, current.authority);
|
|
125
|
+
// Recovery proves its exact old spender against the CURRENT approved deployment, even if the plan expired.
|
|
126
|
+
if (recovery)
|
|
127
|
+
nativeYieldAllowanceRevocation(op.context.plan, this.context(op.context.plan, op.context.maximumInputAtomic), activation.deployments);
|
|
128
|
+
let limits = deriveExactApprovedNativeMarketLimits(recovery ? op.context.activation : activation, { chainId: op.chainId, marketId: op.context.plan.marketId,
|
|
129
|
+
registryCommitment: op.context.plan.registryCommitment, action: op.context.plan.action });
|
|
130
|
+
if (recovery) {
|
|
131
|
+
const currentGas = activation.gasLimits.find((gas) => gas.chainId === op.chainId);
|
|
132
|
+
if (!currentGas)
|
|
133
|
+
return refuseNative('NATIVE_GAS_UNAVAILABLE', 'Current recovery gas limits are unavailable');
|
|
134
|
+
limits = { ...limits, gasLimits: currentGas };
|
|
135
|
+
}
|
|
136
|
+
if (!recovery) {
|
|
137
|
+
assertNativeInputWithinApprovedAtomicCeiling(BigInt(op.context.plan.amount), limits);
|
|
138
|
+
if (op.context.plan.action === 'deposit')
|
|
139
|
+
assertNativeDepositWithinOwnerUsdCap({ amountAtomic: BigInt(op.context.plan.amount), authority: current.authority,
|
|
140
|
+
limits, priceObservation: await this.runtime.price(limits), nowMs: this.runtime.now() });
|
|
141
|
+
await verifyNativeYieldPlan(this.protocol(activation), op.context.plan, op.context.input, this.context(op.context.plan, limits.maximumInputAtomic.toString()));
|
|
142
|
+
}
|
|
143
|
+
return { activation, current, limits };
|
|
144
|
+
}
|
|
145
|
+
async submit(raw) {
|
|
146
|
+
const input = NATIVE_ACCOUNT_SUBMIT_INPUT.parse(raw), reviewed = await this.owned(input.accessToken, input.operationId);
|
|
147
|
+
if (reviewed.state !== 'review' || reviewed.reviewConsumed)
|
|
148
|
+
return refuseNative('NATIVE_REVIEW_REQUIRED', 'This operation review was already consumed');
|
|
149
|
+
const guard = await this.guards.acquire('native', reviewed.operationId);
|
|
150
|
+
try {
|
|
151
|
+
const activation = this.activation(reviewed.chainId);
|
|
152
|
+
if (activation.mode !== 'enabled' || nativeYieldAccountActivationCommitment(activation) !==
|
|
153
|
+
nativeYieldAccountActivationCommitment(reviewed.context.activation))
|
|
154
|
+
return refuseNative('NATIVE_ACTIVATION_CHANGED', 'The operation requires a fresh review');
|
|
155
|
+
const fresh = await this.runtime.authority(input.accessToken, reviewed.account, activation, 'send');
|
|
156
|
+
await verifyNativeYieldPlan(this.protocol(activation), reviewed.context.plan, reviewed.context.input, this.context(reviewed.context.plan, reviewed.context.maximumInputAtomic));
|
|
157
|
+
const op = this.store.begin(reviewed.userId, reviewed.operationId, input.planCommitment, input.reviewCommitment, fresh.authority);
|
|
158
|
+
return await this.advance(op, input.accessToken);
|
|
159
|
+
}
|
|
160
|
+
finally {
|
|
161
|
+
guard.release();
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
/** Separate explicit session action. It can only send a previously uncreated next step of this claimed review. */
|
|
165
|
+
async continueOperation(raw) {
|
|
166
|
+
const input = NATIVE_ACCOUNT_CONTINUE_INPUT.parse(raw), op = await this.owned(input.accessToken, input.operationId);
|
|
167
|
+
const guard = await this.guards.acquire('native', op.operationId);
|
|
168
|
+
try {
|
|
169
|
+
if (!op.reviewConsumed || ['completed', 'failed'].includes(op.state) || input.reviewCommitment !== op.context.reviewCommitment)
|
|
170
|
+
return refuseNative('NATIVE_REVIEW_REQUIRED', 'No current consumed review can be continued');
|
|
171
|
+
return await this.advance(op, input.accessToken);
|
|
172
|
+
}
|
|
173
|
+
finally {
|
|
174
|
+
guard.release();
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
async advance(initial, token) {
|
|
178
|
+
let op = initial;
|
|
179
|
+
try {
|
|
180
|
+
for (let index = 0; index < 3; index++) {
|
|
181
|
+
const existing = op.steps.find((s) => s.index === index);
|
|
182
|
+
if (existing) {
|
|
183
|
+
if (uncertain(existing) || existing.state === 'reverted' || existing.state === 'not-submitted')
|
|
184
|
+
return this.view(op); // Never regenerate a request, key or send for any existing step.
|
|
185
|
+
await proveNativeYieldAccountTransaction(this.runtime.client(op.chainId), existing.request, existing.transactionHash, 'mined');
|
|
186
|
+
continue;
|
|
187
|
+
}
|
|
188
|
+
if (op.steps.some((s) => s.index === 3))
|
|
189
|
+
return this.view(op);
|
|
190
|
+
op = await this.sendStep(op, token, index);
|
|
191
|
+
const step = op.steps.find((s) => s.index === index);
|
|
192
|
+
if (step.state !== 'mined' && step.state !== 'confirmed')
|
|
193
|
+
return this.view(op);
|
|
194
|
+
}
|
|
195
|
+
return this.view(await this.reconcileOwned(op));
|
|
196
|
+
}
|
|
197
|
+
catch (error) {
|
|
198
|
+
return this.view(this.store.attention(op.userId, op.operationId, errorCode(error)));
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
async sendStep(op, token, index) {
|
|
202
|
+
const recovery = index === 3, guarded = await this.guard(op, token, recovery), pub = this.runtime.client(op.chainId);
|
|
203
|
+
const step = recovery ? nativeYieldAllowanceRevocation(op.context.plan, this.context(op.context.plan, op.context.maximumInputAtomic), guarded.activation.deployments) : op.context.plan.steps[index];
|
|
204
|
+
const limits = gasLimits(guarded.limits.gasLimits);
|
|
205
|
+
const prepared = await prepareNativeYieldAccountTransaction(pub, { chainId: op.chainId, owner: getAddress(op.account),
|
|
206
|
+
step: { to: getAddress(step.to), data: step.data, value: '0' }, limits, nowMs: this.runtime.now });
|
|
207
|
+
const request = { userId: op.userId, address: op.account, network: prepared.network,
|
|
208
|
+
transaction: prepared.serializedTransaction, idempotencyKey: randomUUID() };
|
|
209
|
+
const priorCost = op.steps.filter((s) => s.state !== 'not-submitted').reduce((sum, s) => sum + BigInt(s.quote.estimatedTotalCostWei), 0n);
|
|
210
|
+
const operationBudget = BigInt(op.context.maximumOperationEstimatedCostWei) < BigInt(guarded.limits.gasLimits.maxOperationEstimatedCostWei)
|
|
211
|
+
? BigInt(op.context.maximumOperationEstimatedCostWei) : BigInt(guarded.limits.gasLimits.maxOperationEstimatedCostWei);
|
|
212
|
+
if (priorCost + prepared.quote.estimatedTotalCostWei > operationBudget)
|
|
213
|
+
return refuseNative('NATIVE_GAS_BUDGET_EXCEEDED', 'The operation gas estimate exceeds the reviewed budget');
|
|
214
|
+
op = this.store.append(op.userId, op.operationId, { index, kind: ['approve_reset', 'approve', 'call', 'allowance_clear'][index],
|
|
215
|
+
state: 'prepared', request, requestDigest: nativeAccountDigest(request), quote: storedQuote(prepared.quote) });
|
|
216
|
+
try {
|
|
217
|
+
// Every awaited journal operation is behind us. Repeat account, policy, consent, valuation and protocol checks.
|
|
218
|
+
const final = await this.guard(op, token, recovery);
|
|
219
|
+
if (index === 2)
|
|
220
|
+
await simulateNativeYieldPlan(pub, this.protocol(final.activation), op.context.plan, op.context.input, this.context(op.context.plan, final.limits.maximumInputAtomic.toString()));
|
|
221
|
+
const freshQuote = await revalidateNativeYieldAccountTransaction(pub, prepared, gasLimits(final.limits.gasLimits), this.runtime.now);
|
|
222
|
+
if (priorCost + freshQuote.estimatedTotalCostWei > operationBudget ||
|
|
223
|
+
freshQuote.estimatedTotalCostWei > prepared.quote.estimatedTotalCostWei)
|
|
224
|
+
return refuseNative('NATIVE_GAS_BUDGET_CHANGED', 'Gas costs increased; the prepared request is not sent');
|
|
225
|
+
await this.runtime.assertCurrentSession(token, final.current.authority);
|
|
226
|
+
if (this.runtime.now() >= freshQuote.expiresAtMs)
|
|
227
|
+
return refuseNative('NATIVE_GAS_STALE', 'Gas evidence expired during authority checks');
|
|
228
|
+
if (!recovery) {
|
|
229
|
+
if (this.runtime.now() >= op.context.plan.deadline * 1000)
|
|
230
|
+
return refuseNative('NATIVE_PLAN_EXPIRED', 'The reviewed plan expired before sending');
|
|
231
|
+
this.store.assertConsent(op, final.current.authority);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
catch (error) {
|
|
235
|
+
this.store.evidence(op.userId, op.operationId, index, { state: 'not-submitted' });
|
|
236
|
+
return this.store.attention(op.userId, op.operationId, errorCode(error));
|
|
237
|
+
}
|
|
238
|
+
let hash;
|
|
239
|
+
try {
|
|
240
|
+
// Sole native SDK send. A lost response consumes the durable request; there is no retry call path.
|
|
241
|
+
hash = (await this.cdp.endUser.sendEvmTransaction({ ...request, transaction: request.transaction })).transactionHash;
|
|
242
|
+
if (!/^0x[0-9a-fA-F]{64}$/.test(hash))
|
|
243
|
+
throw new Error('NATIVE_SEND_UNKNOWN');
|
|
244
|
+
}
|
|
245
|
+
catch {
|
|
246
|
+
return this.store.evidence(op.userId, op.operationId, index, { state: 'unknown' });
|
|
247
|
+
}
|
|
248
|
+
op = this.store.evidence(op.userId, op.operationId, index, { state: 'submitted', transactionHash: hash });
|
|
249
|
+
try {
|
|
250
|
+
// A bounded receipt wait is convenience only. Timeout returns the durable hash for explicit reconciliation.
|
|
251
|
+
await pub.waitForTransactionReceipt({ hash: hash, timeout: 25_000, pollingInterval: 750, confirmations: 1 });
|
|
252
|
+
const receipt = await proveNativeYieldAccountTransaction(pub, request, hash, 'mined');
|
|
253
|
+
return this.store.evidence(op.userId, op.operationId, index, { state: receipt.status === 'success' ? 'mined' : 'reverted', receipt, finality: 'mined' });
|
|
254
|
+
}
|
|
255
|
+
catch {
|
|
256
|
+
return op;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
async read(raw) {
|
|
260
|
+
const input = NATIVE_ACCOUNT_READ_INPUT.parse(raw), who = await this.runtime.identity(input.accessToken);
|
|
261
|
+
const ops = input.operationId ? [await this.owned(input.accessToken, input.operationId)] : this.store.list(who.userId);
|
|
262
|
+
return { schemaVersion: '1', operations: ops.filter((op) => who.accounts.includes(getAddress(op.account))).map((op) => this.view(op)) };
|
|
263
|
+
}
|
|
264
|
+
async reconcile(raw) {
|
|
265
|
+
const input = NATIVE_ACCOUNT_RECONCILE_INPUT.parse(raw), op = await this.owned(input.accessToken, input.operationId);
|
|
266
|
+
if (!op.reviewConsumed || ['completed', 'failed'].includes(op.state))
|
|
267
|
+
return this.view(op);
|
|
268
|
+
const guard = await this.guards.acquire('native', op.operationId);
|
|
269
|
+
try {
|
|
270
|
+
let current = this.store.read(op.userId, op.operationId);
|
|
271
|
+
for (const candidate of input.knownTransactions ?? []) {
|
|
272
|
+
const step = current.steps.find((s) => s.index === candidate.index);
|
|
273
|
+
if (!step || !['prepared', 'unknown', 'submitted'].includes(step.state))
|
|
274
|
+
return refuseNative('NATIVE_EVIDENCE_INVALID', 'No unresolved request matches this evidence candidate');
|
|
275
|
+
// Uncertain response candidates must be FINAL before recording their hash; a pending guess cannot bind recovery.
|
|
276
|
+
const receipt = await proveNativeYieldAccountTransaction(this.runtime.client(op.chainId), step.request, candidate.transactionHash, 'finalized');
|
|
277
|
+
current = this.store.evidence(op.userId, op.operationId, step.index, { state: receipt.status === 'success' ? 'confirmed' : 'reverted', receipt, finality: 'finalized' });
|
|
278
|
+
}
|
|
279
|
+
return this.view(await this.reconcileOwned(current));
|
|
280
|
+
}
|
|
281
|
+
finally {
|
|
282
|
+
guard.release();
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
async reconcileOwned(op) {
|
|
286
|
+
const pub = this.runtime.client(op.chainId);
|
|
287
|
+
let allFinal = true;
|
|
288
|
+
for (const step of op.steps) {
|
|
289
|
+
if (step.state === 'not-submitted')
|
|
290
|
+
continue;
|
|
291
|
+
if (!step.transactionHash) {
|
|
292
|
+
allFinal = false;
|
|
293
|
+
continue;
|
|
294
|
+
}
|
|
295
|
+
try {
|
|
296
|
+
const receipt = await proveNativeYieldAccountTransaction(pub, step.request, step.transactionHash, 'finalized');
|
|
297
|
+
op = this.store.evidence(op.userId, op.operationId, step.index, { state: receipt.status === 'success' ? 'confirmed' : 'reverted', receipt, finality: 'finalized' });
|
|
298
|
+
}
|
|
299
|
+
catch {
|
|
300
|
+
allFinal = false;
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
if (!allFinal || op.steps.some(uncertain))
|
|
304
|
+
return op;
|
|
305
|
+
const activation = this.activation(op.chainId), call = op.steps.find((s) => s.index === 2);
|
|
306
|
+
if (call?.state === 'confirmed') {
|
|
307
|
+
const settlement = await readNativeYieldSettlement(pub, op.context.plan, call.transactionHash, activation.deployments);
|
|
308
|
+
if (settlement.status === 'completed')
|
|
309
|
+
return this.store.finish(op.userId, op.operationId, { state: 'completed', result: settlement });
|
|
310
|
+
return this.store.attention(op.userId, op.operationId, 'NATIVE_SETTLEMENT_UNPROVEN');
|
|
311
|
+
}
|
|
312
|
+
// Before releasing a failed/cancelled action, all possible sends must be final and its approval must be cleared.
|
|
313
|
+
if (!op.steps.some((s) => s.state === 'reverted' || s.state === 'not-submitted' || s.index === 3) &&
|
|
314
|
+
op.context.plan.deadline * 1000 > this.runtime.now())
|
|
315
|
+
return op;
|
|
316
|
+
const deployment = activation.deployments.find((d) => d.chainId === op.chainId);
|
|
317
|
+
if (!deployment || hybridYieldCommitment(deployment) !== hybridYieldCommitment(op.context.plan.deployment))
|
|
318
|
+
return op;
|
|
319
|
+
const block = await pub.getBlock({ blockTag: 'finalized' });
|
|
320
|
+
if (block.number === null || !block.hash)
|
|
321
|
+
return op;
|
|
322
|
+
const [allowance, code, canonical] = await Promise.all([
|
|
323
|
+
pub.readContract({ address: getAddress(op.context.plan.inputToken), abi: NATIVE_YIELD_ERC20_ABI, functionName: 'allowance',
|
|
324
|
+
args: [getAddress(op.account), getAddress(deployment.address)], blockNumber: block.number }),
|
|
325
|
+
pub.getCode({ address: getAddress(deployment.address), blockNumber: block.number }), pub.getBlock({ blockNumber: block.number }),
|
|
326
|
+
]);
|
|
327
|
+
if (allowance !== 0n || !code || keccak256(code).toLowerCase() !== deployment.runtimeCodeHash.toLowerCase() ||
|
|
328
|
+
canonical.hash !== block.hash || await pub.getChainId() !== op.chainId)
|
|
329
|
+
return op;
|
|
330
|
+
return this.store.finish(op.userId, op.operationId, { state: 'failed', result: { status: 'closed-without-native-completion',
|
|
331
|
+
inputAllowance: '0', finalizedBlockNumber: block.number.toString(), retrySafe: false } });
|
|
332
|
+
}
|
|
333
|
+
async revokeAllowance(raw) {
|
|
334
|
+
const input = NATIVE_ACCOUNT_REVOKE_INPUT.parse(raw), op = await this.owned(input.accessToken, input.operationId);
|
|
335
|
+
if (!op.reviewConsumed || ['completed', 'failed'].includes(op.state) || input.revocationCommitment !== nativeAccountRevocationCommitment(op))
|
|
336
|
+
return refuseNative('NATIVE_REVOCATION_REVIEW_REQUIRED', 'Review the exact operation allowance clear');
|
|
337
|
+
const guard = await this.guards.acquire('native', op.operationId);
|
|
338
|
+
try {
|
|
339
|
+
const current = await this.reconcileOwned(op);
|
|
340
|
+
if (['completed', 'failed'].includes(current.state))
|
|
341
|
+
return this.view(current);
|
|
342
|
+
if (current.steps.some(uncertain) || current.steps.some((s) => s.index === 3))
|
|
343
|
+
return refuseNative('NATIVE_RECONCILIATION_REQUIRED', 'Resolve every uncertain send before changing this allowance');
|
|
344
|
+
for (const step of current.steps.filter((s) => s.transactionHash))
|
|
345
|
+
await proveNativeYieldAccountTransaction(this.runtime.client(op.chainId), step.request, step.transactionHash, 'finalized');
|
|
346
|
+
const result = await this.sendStep(current, input.accessToken, 3);
|
|
347
|
+
return this.view(await this.reconcileOwned(result));
|
|
348
|
+
}
|
|
349
|
+
finally {
|
|
350
|
+
guard.release();
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
view(op) {
|
|
354
|
+
const ambiguous = op.steps.some(uncertain), terminal = ['completed', 'failed'].includes(op.state);
|
|
355
|
+
return NATIVE_ACCOUNT_OPERATION_VIEW_SCHEMA.parse({ schemaVersion: '1', operationId: op.operationId, account: op.account, chainId: op.chainId,
|
|
356
|
+
marketId: op.context.plan.marketId, action: op.context.plan.action, state: op.state,
|
|
357
|
+
planCommitment: op.context.plan.planCommitment, reviewCommitment: op.context.reviewCommitment,
|
|
358
|
+
review: { amount: op.context.plan.amount, inputToken: op.context.plan.inputToken, minimumOutput: op.context.plan.minimumOutput,
|
|
359
|
+
outputToken: op.context.plan.outputToken, fee: op.context.plan.fee, deadline: op.context.plan.deadline,
|
|
360
|
+
maximumOperationEstimatedCostWei: op.context.maximumOperationEstimatedCostWei, isHardTotalGasCap: false },
|
|
361
|
+
steps: op.steps.map((s) => ({ index: s.index, kind: s.kind, state: s.state, ...(s.transactionHash ? { transactionHash: s.transactionHash } : {}),
|
|
362
|
+
costEstimate: s.quote, ...(s.receiptFinality ? { receiptFinality: s.receiptFinality } : {}), ...(s.receipt ? { receiptGasCostWei: (BigInt(s.receipt.gasUsed) * BigInt(s.receipt.effectiveGasPrice)).toString() } : {}) })),
|
|
363
|
+
continuationAvailable: !terminal && op.reviewConsumed && !ambiguous && op.context.plan.deadline * 1000 > this.runtime.now() &&
|
|
364
|
+
op.steps.length < 3 && op.steps.every((s) => ['mined', 'confirmed'].includes(s.state)),
|
|
365
|
+
allowanceRecovery: { reviewCommitment: nativeAccountRevocationCommitment(op), available: !terminal && op.reviewConsumed &&
|
|
366
|
+
!ambiguous && !op.steps.some((s) => s.index === 3), requiresFreshSession: true },
|
|
367
|
+
...(op.result !== undefined ? { actualSettlement: op.result } : {}), ...(op.failureCode ? { failureCode: op.failureCode } : {}),
|
|
368
|
+
automaticExecutionEnabled: false, retrySafe: false });
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
//# sourceMappingURL=native-yield-account.js.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { type NativeYieldAccountAuthority, type NativeYieldAccountConsent } from './native-yield-account-definition.js';
|
|
3
|
+
import { type ExecutionJournalDatabase } from './execution-journal-schema.js';
|
|
4
|
+
declare const CONFIRM_INPUT: z.ZodObject<{
|
|
5
|
+
userId: z.ZodString;
|
|
6
|
+
consentId: z.ZodString;
|
|
7
|
+
consentCommitment: z.ZodString;
|
|
8
|
+
}, z.core.$strict>;
|
|
9
|
+
export type ConfirmNativeYieldConsentInput = z.infer<typeof CONFIRM_INPUT>;
|
|
10
|
+
export declare function initializeNativeYieldConsents(db: ExecutionJournalDatabase): void;
|
|
11
|
+
/** Authenticated subject lookup for challenge review/confirmation. History is evidence, not authority. */
|
|
12
|
+
export declare function readNativeYieldConsent(db: ExecutionJournalDatabase, userId: string, consentId: string): NativeYieldAccountConsent | undefined;
|
|
13
|
+
export declare function createNativeYieldConsent(db: ExecutionJournalDatabase, inputAuthority: NativeYieldAccountAuthority, nowMs: number): NativeYieldAccountConsent;
|
|
14
|
+
export declare function confirmNativeYieldConsent(db: ExecutionJournalDatabase, rawInput: ConfirmNativeYieldConsentInput, inputAuthority: NativeYieldAccountAuthority, nowMs: number): NativeYieldAccountConsent;
|
|
15
|
+
export declare function readConfirmedNativeYieldConsent(db: ExecutionJournalDatabase, userId: string, account: string, nowMs: number): NativeYieldAccountConsent | undefined;
|
|
16
|
+
/** Read-only: safe inside the operation's claim transaction and again immediately before handoff. */
|
|
17
|
+
export declare function assertCurrentNativeYieldConsent(db: ExecutionJournalDatabase, inputRecord: NativeYieldAccountConsent, inputAuthority: NativeYieldAccountAuthority, nowMs: number): void;
|
|
18
|
+
/** Stop remains available while a money operation is unresolved; it never releases that operation's claim. */
|
|
19
|
+
export declare function revokeNativeYieldConsent(db: ExecutionJournalDatabase, userId: string, account: string, nowMs: number): void;
|
|
20
|
+
export {};
|