Settlement Process
Settlement is where an action that was agreed beforehand is effectively acted upon. It is a term often found in finance. In the case of Polymesh, the prior agreement is that of an exchange or transfer of securities between accounts. A settlement in Polymesh represents the contractual obligation to which the involved parties have agreed. Regulatory requirements and compliance are both important aspects of modern settlements.
When looking at current settlement processes, for example in case of post-trade security clearings, one can notice:
- a large number of entities is involved,
- feasible transaction time has its limits, especially in case of cross-border payments,
- transaction time and the speed of trade don't coincide,
- the number of intermediaries is quite high - each intermediary involved can make a process more expensive, and
- many regulatory requirements apply, which keep evolving.
As you can guess, there is potential for efficiency and cost-saving.
Deconstructing settlements
Let's introduce some important Polymesh terminology that we will use throughout:
- a leg is the smallest action of a settlement. This could be one transfer of securities from Alice to Bob or the recognition of an off-chain payment. Creating legs doesn't execute them immediately, but they describe what is meant to happen after compliance and other concerns are satisfied. Legs cannot exist by themselves. One or more legs of a settlement need to be part of:
- an instruction, which aggregates related legs to create an indivisible action, an atomic transaction in computer parlance. This means that when an instruction is executed, all its legs are executed concurrently. There is no situation where only some of an instruction's legs have executed. This also means that a single unconfirmed leg can hold up the whole instruction's execution. Additionally, an instruction cannot exist by itself. Instructions are created and executed when housed in:
- a venue, which is a logical object meant for the purpose of collecting instructions. It is also associated with certain access rights such as who can add an instruction to it.
Let's review these terms separately and in greater detail.
Legs
Alice sends 100 ACME shares from her trading portfolio to Bob's default portfolio.
This is a valid leg description. It should be evident that Alice's approval is necessary here for the action to eventually take place - We are talking about her shares here. It is also necessary for Bob's approval to be collected as, despite Alice's generosity, receiving securities has tax implications that he may not want to shoulder.
Bob sent 10 USD off-chain to Alice with reference
0x123bff
.
This is another valid leg description, called a signed receipt. Here again the approval of both parties is required, Bob may not want to give the impression that he has sent 10 USD off-chain, or 10 million, or that it was required of him. Alice may not want to let it be known that she has received cash, as she may be asked to return something she never received in the first place.
Affirmations
We just saw that, depending on the situation, legs require approvals from relevant accounts. These approvals are called affirmations. At the risk of repeating, it is a relevant account that affirms a leg. Affirming a leg is, in effect, placing a signature that is valid for the account concerned. So a key associated with an account indicates agreement by signing an affirmation for a leg. For a given leg to be affirmed, it needs to have received the required affirmations from all relevant accounts.
And yes, a secondary key, or a custodian (see below) entrusted with sufficient rights, can affirm on behalf of a relevant account.
When the account owning an asset has affirmed a leg, then the asset's relevant quantity is committed. This commitment prevents double-booking in another instruction's leg, by mistake or malice. Failing to do so would eventually cause one of the two competing instructions to fail much later, at execution.
If a leg mentions a signed receipt for an off-chain action, this signed receipt is committed too.
For the avoidance of doubt, a party can reject a leg, thereby cancelling the whole instruction, and releasing all previously committed assets and signed receipts. A party can also not affirm a leg, i.e. play for time, which would leave the instruction in limbo until some other resolution, like a cancellation or the instruction's expiry date being reached.
Instructions - Multiparty transactions
Sending shares to Bob or sending USD to Alice in isolation, as a gift for instance, is all well and good, but, in our world, the overwhelming majority of securities transactions are trades. For instance, imagine:
- Leg 1: Alice sends 100 of her ACME shares to Bob on the condition that she receives 10 USD in exchange;
- Leg 2: Bob sends 10 USD to Alice on the condition that he receives 100 ACME shares.
Explicit in this trade is that the two legs should happen in concert or none should happen at all. In computer jargon, this is called an atomic operation, a.k.a. a transaction. Because the word transaction is already used in Polymesh to describe the serialised bits of information added to the blockchain - itself an atomic operation - such an atomic securities trade is called an instruction.
An instruction cannot be created without legs, and legs cannot be created outside of instructions. Also, after it has been created, an instruction cannot be modified. It should be obvious once you imagine what would happen if the first party could modify the second leg after the second party has already affirmed the first leg.
Asset issuer requirements
In Polymesh, nothing material happens until the compliance rules have been met. This is true of instructions. So, in our two-legged instruction example, the KYC attestations attached to Alice's and Bob's accounts should comply with ACME's sending and receiving rules, respectively. The instruction will remain in a pending state until ACME's compliance rules are satisfied.
For the avoidance of doubt, an instruction may be affirmed by all parties and still be in a pending state while the KYC requirements remain unresolved. The reason for durability of the instruction is that it represents contractual committments. The compliance of parties is fluid and changeable. Failing to comply is merely a temporary setback. It can usually be resolved by addressing KYC requirements. Parties are compelled to resolve compliance issues by the contractual obligation represented by the instruction.
As a matter of detail, when an instruction has been fully affirmed but is still pending because of compliance, and it is finally possible for it to execute because the last compliance requirement has been satisfied, the instruction does not automagically execute. It still needs an account to explicitly send a transaction to execute it. Naturally, if an instruction is asked to be executed and it still fails because of compliance, then the instruction is not cancelled. It remains in a pending state.
As expected, it is also possible to cancel the whole instruction while compliance is pending.
Additionally, the securities token issuer can also restrict which accounts are allowed to create instructions transferring their token. Although it is expected that this facility will seldom be used.
Atomic execution
Instructions execute completely, or not at all - in technical parlance, "atomic". For example, the above-mentioned instruction has two legs to send shares from Alice to Bob and funds from Bob to Alice. Alice and Bob both need to affirm that the entire instruction is agreeable and properly represents their contractual agreement. Instructions contain other details such as when to actually execute, e.g. as soon as it's affirmed or at a scheduled point of time in the future. Alice and Bob's affirmations indicate their agreement with all such details.
The actual execution is atomic, meaning that the instructions are always either completely executed or not executed at all. There is no case in which one leg of an instruction has executed and the other has not.
With our example, after the instruction has executed:
- Alice has 100 fewer shares of ACME, and 10 more USD;
- Bob has 100 more shares of ACME, and 10 fewer USD.
And if the instruction had a signed receipt for an off-chain action, that receipt would be permanently marked as used.
Custody
Having to keep track and affirm instructions that are relevant to you can be a tedious business. It also doesn't map well with today's world of securities. Today, securities holders, or beneficiaries, are typically represented by other parties that broadly act in the beneficiaries' interest with some guidance. These other parties are called custodians. You may know them as brokers too.
Polymesh provides a way to mirror this off-chain world with the use of custody on-chain. In this setup, a beneficiary account can designate another account as their custodian in one or more of their portfolios. After the custodian account accepts the responsibility, they can act on behalf of the beneficiary for matters related to settlement.
Assumed in the foregoing is that the beneficiary and the custodian entered into a legally binding contract, whose Polymesh custodial relationship is just the on-chain expression of it.
Belabouring the point, a custodian doesn't own the securities on-chain, the beneficiary still does, and a custodial relationship can be revoked only by the custodian.
It is therefore incumbent on the beneficiary to partition their portfolios and assets, and designate their custodian(s), so as to reflect the desired mix of responsibilities.
We will look more closely at custodians at the end of this section.
Venue
Finally, an instruction is not created in a void, but instead it is created inside a venue. Ultimately, an account is responsible for its own venues, for access rights, and for who can create, cancel, and remove instructions within them. Once an instruction has been created inside a venue, it cannot be moved to another.
An advantage of this setup is that the account owning the venue lends its reputation to the instructions that are published in it. A concrete example might be a securities exchange platform, let's name it NextDaq. It publishes matched trades on its trade settlement venue. All brokers who have open positions with NextDaq can expect instructions relevant to themselves or their customers. What does a broker do when they see an instruction mentioning a customer of theirs sending funds or shares to an unknown account? Well, since it appeared in NextDaq's settlement venue, they assume that it is a valid matched trade and that the unknown recipient is the counterpart of the trade. As long as the broker can see that the price is right, according to their own records, they can reasonably proceed with the affirmations.
In fact, the venue creator can also restrict the list of accounts allowed to affirm instructions in its venue. You could for instance imagine that NextDaq would only allow known custodians from affirming instructions.
Synopsis
An instruction is the vehicle for a settlement on Polymesh. It has many moving parts, all of which have to align for the instruction to be executed. Namely, the securities holders, their potential custodians, the asset issuer's requirements, as well as the venue and its creator.
Lateral concerns
Pre-authorisation
Putting signature to an instruction is not the only way to affirm it. There is another construct, that of pre-authorisation. In effect, a signature that validates one, and only one, future instruction. Not unlike a blank cheque.
So if Bob signed a pre-authorisation, Alice can include it when creating the instruction. The pre-authorisation will be committed before execution, and marked as consumed when the instruction executes.
This could also be used by an exchange, which would collect pre-authorisations from the brokers that list on it. A new instruction would therefore be authorised as soon as it is created, potentially leading to instant settlement.
Netting process
Our trade example between Alice and Bob was simple, two legs and two parties. Now, we can imagine a busy exchange platform agreeing with its brokers that it will emit fewer instructions, which in effect batch trades, or express the net effect of a collection of trades that took place.
For instance, instead of three instructions that would see:
- Alice selling 100 ACME to Bob for 10 USD;
- Bob selling 40 ACME to Carol for 5 USD;
- Alice selling 20 ACME to Carol for 2 USD.
There could be a single instruction with four legs that would see:
- Alice sending 60 ACME to Bob;
- Alice sending 60 ACME to Carol;
- Bob sending 5 USD to Alice;
- Carol sending 7 USD to Alice.
In both situations, the net effect is that:
- Alice has 120 fewer ACME and 12 more USD;
- Bob has 60 more ACME and 5 fewer USD;
- Carol has 60 more ACME and 7 fewer USD.
So there is reason to believe that all three parties, or their respective custodians, would be agreeable to the single larger instruction. The instruction is still atomic so it would not be possible for Alice to send her shares without full compensation, for instance. A potential downside is that with more parties whose affirmations, and proper attestations, are required, there is a higher chance of a hold-up. Which is why an exchange would be expected to do this only with parties with higher trust or pre-authorisations.