Agoric / agoric-sdk

monorepo for the Agoric Javascript smart contract platform
Apache License 2.0
327 stars 207 forks source link

Settler exo #10391

Open turadg opened 3 weeks ago

turadg commented 3 weeks ago

What is the Problem Being Solved?

Fast USDC needs a component to settle advances.

Description of the Design

A Settler exo that performs the advancement operations.

It looks them up from Status Manager and settles per product spec.

Security Considerations

Scaling Considerations

Test Plan

Exo test

Contract test is separate: https://github.com/Agoric/agoric-sdk/issues/10388

Upgrade Considerations

dckc commented 5 days ago

collecting details on the scope of this issue...

design sketch says:

An exo within FUC that handles settling transactions.

re "the SettlementAccount" - that presumes there is one. Does this exo make it?

dckc commented 5 days ago

re "settles per product spec" - this bit of the diagram seems particularly relevant:

sequenceDiagram
    rect rgb(255, 245, 230)
        Note over FUC,CFA: Settlement Process
        Note over FUC,SA: Tap on account reads MintAmount,<br/>parses EUD from virtual address recipient<br/>and looks up AdvanceAmount,PoolFee,ContractFee.<br/>Matches against an unsettled transaction (by EUD and approx amount).
        %% Treat starting the advance as an atomic action. Assume it will complete once started.
        alt Advance was started:
            FUC->>SA: Initiate transfers<br>out of settlement
            SA->>P: Deposit the AdvanceAmount + PoolFee<br>(= MintAmount - ContractFee)
            SA->>CFA: Deposit ContractFee
        else Advance for matched transaction that has not yet started:
            P->>NC: PFM transfer<br>(MintAmount of Agoric USDC denom) to EUD
            NC->>EUD: deliver MintAmount<br>as final USDC denom
        else Settlement for unknown transaction:
            %% Have not received notification of this Amount,EUD from the watcher
            Note over SA: Leave funds in SettlementAccount.
            Note over SA: Wait for observation from watcher
        end
    end