ERC-8464: Agent Repay-First Payees

Credit that grows with an agent’s income has to be repaid from that income before it is spent. This draft is a revenue address for an agent identity (an x402 payTo, an ERC-8183 provider, an ERC-8004 payment wallet) that pays the agent’s registered creditors before its owner: whenever anyone sweeps it, each creditor is paid what it is owed, most senior first and up to its agreed share of the sweep, and the rest goes to the owner’s beneficiary. The owner cannot drop a creditor that is still owed, which is what makes the revenue worth lending against. A beneficiary holds only while the owner that set it holds the identity, so a seller cannot keep the buyer’s revenue.

An optional section, “Paying holders after creditors”, lets an agent pay the holders of an ERC-7254 revenue-sharing token from what its creditors leave: the token is the payee’s beneficiary, never a creditor, so lenders stay senior and holders come last.

Questions:

  1. Seniority by order of addition, with a per-creditor cap on each sweep: enough for revolving lenders, or should creditors be able to agree a different order?
  2. Should payees be discoverable from the identity (an ERC-8004 metadata key, or ERC-8278’s service payment route)?
  3. For the holders’ section: ERC-7254 books rewards only through updateReward; is the syncFromPayee approach acceptable, or should the profile build on a single-asset dividend token instead?

I tested a direct adapter to Agent Credit Lines: with 100 due, ten 10-unit sweeps all reach the beneficiary because partial repay reverts. One 100-unit sweep repays successfully (repro).

Is an accumulating reserve adapter intended here? Reserving funds and repaying the loan would need separate accounting.

@ted0x Your repro holds on both pinned commits. Agent Credit Lines’ repay takes the whole amount due or reverts (a loan opens once and closes once), and the payee treated a reverting collect as owed nothing and forwarded the sweep, so ten sweeps of 10 sent 100 to the owner and left 100 due.

An accumulating adapter isn’t intended. The reserve is now in the payee (GitHub - priors-agents/erc-repay-first-payees: Draft ERC (Agent Repay-First Payees): a revenue address for an agent identity that pays its creditors before its owner · GitHub, commit 29ff8e1): for each creditor and token it keeps what a sweep offered the creditor and the creditor did not take, and offers it again at every sweep with the creditor’s share of the new money. Your adapter, unchanged, against SimpleCreditLine at 546365a: the reserve goes 10, 20 … 90, the tenth sweep repays 100 and the loan is Repaid, and the sweep of 100 after it is forwarded in full. Your first test’s per-sweep check (forwarded == 10) now fails, as it should.

The separate accounting:

  • What is reserved: from each sweep at most the creditor’s share of it, and in all at most what it reports in amountOwed. It leaves the payee only through collect, so toCreditors in Swept still counts only what a creditor took.
  • When it is released: each sweep lowers the reserve to amountOwed, so a loan repaid from elsewhere releases it, as do a reverting amountOwed and the creditor’s removal. What is released counts as new revenue in that sweep: creditors in order, then the beneficiary.
  • Due date and default: the payee knows neither, only amountOwed. A short reserve stays held while the loan is late. With your adapter a default makes amountDue 0 and releases the reserve to the owner; a creditor that means to recover from it after a default SHOULD keep reporting what it can recover and apply what it takes as a recovery (Security Considerations).
  • What a reader sees: reserved(creditor, token) and a Reserved(creditor, token, amount) event on every change. The interface id changes.

The profile now says a creditor MUST NOT take what it cannot apply now in order to hold it for later. Agent Credit Lines is unchanged.

Nine tests fail on the previous reference and pass now (46 in all). Six are new: your case against a lender with the same full-only repay, a loan repaid from elsewhere, a default, a reverting amountOwed, a creditor that leaves and comes back, and a fuzz of what the lender got plus its reserve against its share of every sweep. In the other three, a creditor that takes half, a greedy one and a gas burner now leave what they don’t take in reserve instead of having it forwarded.

The draft suggests using the payee as the job’s provider, but ERC-8183 requires submit to come from that provider. The reference payee has no forwarding method to make that call. That appears to leave a job assigned to it unable to reach Submitted. A call from the agent owner’s wallet would fail the provider check. How is the ERC-8183 provider integration meant to submit work?

An integration test covering job creation, funding, submission, completion and sweeping would make this concrete. If a separate adapter is the provider, its payout routing should be fixed to the payee so the repayment path cannot be bypassed. Could the draft specify the intended adapter or add an authorized submission method?

1 Like

@Revinand You’re right. ERC-8183 takes submit only from the job’s provider (its reference implementation takes setBudget only from the provider too) and pays the provider on complete. The payee could make neither call, so a job assigned to it could only end in a rejection or a refund, and the owner’s own wallet fails the provider check.

The payee now makes those two calls itself, in a new optional part, “Acting as an ERC-8183 provider” (GitHub - priors-agents/erc-repay-first-payees: Draft ERC (Agent Repay-First Payees): a revenue address for an agent identity that pays its creditors before its owner · GitHub, commit a3a0d16):

  • setJobBudget(commerce, jobId, amount, optParams) and submitJob(commerce, jobId, deliverable, optParams) call setBudget and submit from the payee on the ERC-8183 contract named. The owner can call them, or an operator it names with setOperator, so the agent’s working key can submit without holding the identity. Like a beneficiary, the operator lapses once the owner that named it no longer holds the identity.
  • The payee makes no other call for them. A general forwarded call would let the owner call a token from the payee and move its balance outside a sweep; setBudget and submit move nothing out of it, since a token has neither function and outside a sweep the payee holds no approval.
  • What complete pays is a plain transfer to the payee, swept like any other revenue.

An adapter as the provider would be paid in the payee’s place and hold each payment until someone moved it on, so readers would have to check its routing too. With the payee as the provider there is nothing to route, and ERC-8183 sets a job’s provider once, before funding. The owner can still take new jobs under another provider, as with any advertised address, so Security Considerations ask creditors that count on job revenue to check that the jobs name the payee.

Your integration test is in: with a creditor owed 30, the owner proposes 50 through the payee, the client funds, the owner’s own address fails the provider check, the payee submits, the evaluator completes, the job pays the payee 50, and a sweep pays the creditor 30 and forwards 20. Three more cover the operator across a sale, who may call, and a token or an address with no code named as the job contract (50 tests in all). They don’t compile against the previous reference, whose payee has neither call.

The same reading applies to the third address the Motivation named. ERC-8004 sets an agentWallet only with the new wallet’s signature, ERC-1271 for a contract, and the payee validates none, so it can’t be set as one. Validating the owner’s signatures would be the wrong fix: Permit2 and some tokens accept ERC-1271 signatures for transfers, so the owner could sign the payee’s balance away. The draft now says so (commit 4aed089): the payee is a pay-to address and a job’s provider, not the payment wallet, a Rationale point gives the reason, and Security Considerations note that what payers send to agentWallet does not reach the payee. Would a payee that validates only an agentWallet digest it computes itself be worth specifying (ERC-8004’s text leaves that digest’s typed data to the registry), or is a pay-to address enough?