Loading…
package goe_dtr_transfer import future.keywords # GOE × Newton · CFN Exporter Verification Rulebook (draft of 11 Nov 2026,# updated 19 and 20 Nov), Transfer flow: checked after the exporter accepts a# Funder's offer, before Custody moves the dTR to the Funder.## A Transfer request is allowed only when it follows Transfer v1 and passes# K8 and K10. If any rule fails, it is rejected, and `reasons` lists the code# of every rule that failed. Every rule fails closed.## This policy reads two things:# input the request CFN signed, transferDtr(...); `request` names its fields# data.params the limits GOE can change without changing this code## DtrTransferGate enforces the rest on-chain: the dTR was minted for this# invoice, to this exporter, with this Due Date, and is financed only once.## Keep the word for "who someone is" (it starts "ident") out of this file: the# Sepolia testnet gateway sends any policy containing it down an enclave path# that isn't available yet, and every evaluation fails. default allow := false allow if count(reasons) == 0 # ---- The request ------------------------------------------------------------ transfer_v1_signature := "function transferDtr(string requestId, string schemaVersion, bytes32 schemaHash, bytes32 invoiceKey, uint16 advanceRateBps, uint64 paymentTermStart, uint64 paymentTermEnd, uint64 dueDate, address exporterWallet, address funderWallet)" # Newton decodes the request's arguments into a list, in signature order.arguments := object.get(input, "decoded_function_arguments", []) # The same arguments, by name.request := { "request_id": arguments[0], "schema_version": arguments[1], "schema_hash": arguments[2], "invoice_key": arguments[3], "advance_rate_bps": to_number(arguments[4]), "payment_term_start": to_number(arguments[5]), "payment_term_end": to_number(arguments[6]), "due_date": to_number(arguments[7]), "exporter_wallet": arguments[8], "funder_wallet": arguments[9],} # CFN sends dates as unix seconds, and 0 when a date is missing. Rego compares# times in nanoseconds.one_second := 1000000000 one_day := 86400 * one_second as_time(unix_seconds) := unix_seconds * one_second if unix_seconds > 0 # ---- SCHEMA_MISMATCH: the request follows Transfer v1 ------------------------ # Not a rule in GOE's Transfer table. Newton checks it so a malformed request# is rejected, and reports it with K9's code.follows_transfer_v1 if { input.decoded_function_signature == transfer_v1_signature count(arguments) == 10 request.schema_version == data.params.schema_version lower(request.schema_hash) == lower(data.params.schema_hash)} reasons contains "SCHEMA_MISMATCH" if not follows_transfer_v1 # ---- K8 · ADVANCE_RATE_EXCEEDS: above 0, within the maximum rate ------------- # Rates are in basis points: 90% is 9000.advance_rate_is_valid if { request.advance_rate_bps > 0 request.advance_rate_bps <= data.params.max_advance_rate_bps} reasons contains "ADVANCE_RATE_EXCEEDS" if not advance_rate_is_valid # ---- K10 · DISBURSEMENT_PERIOD_INVALID: the Funder's disbursement period ----- # The period the Funder has to pay the advance to the exporter (Disburse Start# to Disbursement End; the request still names them paymentTermStart and# paymentTermEnd). It has a start and an end; it starts no later than it ends;# it ends no later than the Due Date; and it lasts no longer than the maximum.disbursement_period_is_valid if { start := as_time(request.payment_term_start) end := as_time(request.payment_term_end) due := as_time(request.due_date) start <= end end <= due end - start <= data.params.max_disbursement_days * one_day} reasons contains "DISBURSEMENT_PERIOD_INVALID" if not disbursement_period_is_valid| Client | Policy set | Revision | Slot |
|---|---|---|---|
| 0x2845…272a | 0xe4a8fc80…acfb | 1 | 0 |
| Chain | Policy address |
|---|---|
| Sepolia | 0x5855075b8d26404209d6ebbd3f73f1f33a2e6250 |
| Key | Type | Required |
|---|---|---|
| schema_hashThe frozen Transfer v1 schema hash, 0x hex | string | yes |
| schema_versionThe schema version requests must declare ("Transfer v1") | string | yes |
| max_advance_rate_bpsK8: the maximum advance rate, in basis points (90% is 9000) | integer | yes |
| max_disbursement_daysK10: the longest disbursement period, in days | integer | yes |