Hi All!
I'm proud to announce the days of Stellar not directly moving fiat currency or any other asset that requires a "settlement workflow" are officially numbered.
For this SBC, I'm presenting "WayStation", a Proof-Of-Concept server developed, for now, to move USD between registered US bank accounts directly from on-ledger payment operations. This project is partly an Anchor, partly an Escrow provider, and partly a smart contract like workflow engine.
I developed the server as part of a "Fiat Escrow Service" for GIVE (https://galactictalk.org/d/1131-give-distributed-donation-routing-platform) and along the way it became capable of doing most anything else with a "workflow" in the middle of the asset delivery, especially registered securities traded on public exchanges.
Currently, "WayStation" USD processing uses the Dwolla ACH and callback API but I plan on most likely changing this out and working directly with OpenACH as the payments processor. The "WayStation" architecture itself makes the "clearing networks" or "workflow modules" available "pluggable".
The "WayStation" server sits between two networks (Stellar, and the other one) and uses callback webhooks from each network to handle the workflow processing. As such, most of the "WayStation" code is not a daemon, it's a website reacting to event submissions from each side to update the workflow's state. A processing server listening to each network posts events of interest via HTTP to the "WayStation" website.
USD Transfers start with a user sending their own issued asset (in this case [User/USD]) to a "WayStation Agent" account to start the workflow (transferring USD to the Anchor). When the user initially registered their bank account and associated Stellar Account with the Anchor, the Anchor opened a trustline to their [User/USD].
The payment operation triggers a "debit" ACH transaction from the User's US bank account to the Anchor's US bank account. The User no longer goes "off-ledger" for this (like to a website); they can initiate transfers of their USD to the Anchor directly from Stellar.
Sending a payment of their own account's [User/USD] asset to the Anchor causes the "WayStation" service to mirror that action on the ACH network. The presence of the User's USD Asset in the agent's Stellar Account signals an "in-process" transaction. When the event on the other network completes (successfully or not) the Agent sends back the User's token closing out the process.
A day or two after initiating the ACH workflow, the ACH transaction completes and the event posts to "WayStation" by the ACH events processing server.
The transfer has either succeeded or failed; in either case, the Agent sends the [User/USD] it received back with a success or failure memo attached.
If it succeeded, "WayStation" also sends the [Anchor/USD] to the user's account, which the user can now use.
Redeeming [Anchor/USD] works similarly but in reverse.
The User sends [Anchor/USD] to the agent which initiates an ACH "credit" from the Anchor's US bank account to the User's US bank account. This takes a couple days and results in the user either getting the USD delivered to their US Bank Account or getting their [Anchor/USD] asset back into their Stellar Account.
The "WayStation" is creating a type of generic, workflow based, event driven, Escrow Service for clearing assets.
Event submissions to the "WayStation" service are idempotent (multiple submissions of the same ledger event do not initiate multiple workflows; the posting servers retry events until confirmed as received or give up).
Using GraphQL (https://galactictalk.org/d/885-graphql-interface-for-core-and-horizon-databases), "WayStation" can search for ledger transactions by memo_text (for detecting event repeats).
The pattern is generalized enough to be adapted to any clearing network, including other BlockChains.
Currently, this project is targeting routing USD between registered Stellar Accounts over ACH straight from ledger payment transactions. The pattern should generalize to any publicly traded asset/security.
Thanks!
Mike