-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathFXNext Version 2.7 - Payer conversion.puml
472 lines (408 loc) · 13.9 KB
/
FXNext Version 2.7 - Payer conversion.puml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
@startuml
title Transferring with Currency Conversion\nPayer DFSP requests conversion
actor "Upile Chisala" as A1
participant "NBS\nBank" as D1
participant "FDH FX" as FXP
participant "Switch" as S1
participant "Zoona" as D2
participant ALS
participant "Mulengwa\nKapwepwe" as A1
autonumber
A1->D1:I'd like to send 5000 MWK\nto Mulenga Kapwepwe, please
== Discovery Phase ==
activate D1
D1->S1:I want to send to MSISDN 260795390415\n**GET /parties/MSISDN/260795390415**
activate S1
S1-->D1:202 I'll get back to you
deactivate D1
S1->ALS:Who owns MSISDN 260795390415?
activate ALS
ALS-->S1:It's Zoona
deactivate ALS
S1->D2:Do you own MSISDN 260795390415?
activate D2
D2-->S1:202 I'll get back to you
deactivate S1
D2->S1:Yes, it's Mulenga Kapwepwe. She can receive in ZMW\n**PUT /parties/MSISDN/260795390415**
note over D2
PUT /parties
"party": {
"partyIdInfo": {
"partyIdType": "MSISDN",
"partyIdentifier": "260795390415"
},
"name": "Mulenga Kapwepwe",
"supportedCurrencies":[
"ZMW"
]
}
end note
activate S1
S1-->D2:200 Gotcha
deactivate D2
S1->D1:Yes, it's Mulenga Kapwepwe. She can receive in ZMW\n**PUT /parties/MSISDN/260795390415**
activate D1
D1-->S1:200 Gotcha
deactivate S1
== Currency conversion ==
D1->D1:Hmmm. Upile can only send in MWK.\nI need to get some currency conversion
D1->S1:What FXPs do you know about?\n**GET /services/FXP**
activate S1
S1-->D1:202 I'll get back to you
deactivate D1
S1->ALS:What FXPs do you know about?
activate ALS
ALS-->S1:FDH FX
deactivate ALS
S1->D1:Here are the available FXPs:FDH FX
note over S1
PUT /services/FXP
"fxpProviders": [
"FDH_FX"
]
end note
activate D1
D1-->S1:200 Gotcha
deactivate S1
D1->D1:I'll ask FDH FX to perform my conversion
D1->S1:Here is the initial version of the transfer.\nPlease quote me for the currency conversion.
note over D1
**post /fxQuotes**
{
"conversionRequestId": "828cc75f-1654-415e-8fcd-df76cc9329b9"
, "conversionTerms": {
"conversionId": "581f68ef-b54f-416f-9161-ac34e889a84b",
, "counterPartyFsp": "FDH_FX"
, "amountType": "SEND"
, "sourceAmount": {
"currency": "MWK"
, "amount": "5000"
}
, "targetAmount": {
"currency": "ZMW"
}
, "validity": "2021-08-25T14:17:09.663+01:00"
}
}
end note
activate S1
S1-->D1:202 I'll get back to you
deactivate D1
S1->FXP:Here is the initial version of the transfer.\nPlease quote me for the currency conversion.\n**POST /fxQuote**
activate FXP
FXP-->S1:202 I'll get back to you
deactivate S1
FXP->FXP:OK, so I need to figure this out...
note over FXP
I will add a 150 MWK fee for undertaking the conversion.
Now I'll set an expiry time, sign the quotation object,
create an ILPV4 prepare packet and return it in the intermediary object.
NOTE: the ILPV4 prepare packet contains the following items, all encoded:
- The amount being sent (i.e. in the source currency)
- An expiry time
- The condition
- The name of the FXP
- The content of the conversion terms
** PUT /fxQuotes/828cc75f-1654-415e-8fcd-df76cc9329b9**
{
"condition": "bdbcf517cfc7e474392935781cc14043602e53dc2e8e8452826c5241dfd5e7ab"
, "conversionTerms": {
"conversionId": "581f68ef-b54f-416f-9161-ac34e889a84b"
, "initiatingFsp": "NBS_Bank"
"sourceAmount": {
"currency": "MWK",
"amount": "5000"
}
, "targetAmount": {
"currency": "ZMW",
"amount": "97"
}
, "charges": [
{
"chargeType": "Conversion fee"
, "sourceAmount": {
"currency": "MWK"
, "amount": "150"
}
, "targetAmount": {
"currency": "ZMW"
, "amount": "3"
}
}
]
, "validity": "2021-08-25T14:17:09.663+01:00"
}
}
end note
FXP->S1:Here's the signed conversion object
activate S1
S1-->FXP:200 Gotcha
deactivate FXP
S1->D1:Here's the signed conversion object\n**PUT /fxQuotes/828cc75f-1654-415e-8fcd-df76cc9329b9**
activate D1
D1-->S1:Gotcha
deactivate S1
== Agreement Phase ==
D1->S1:Please quote for a transfer which sends 97 ZMW.\n(5000 MWK converted to ZMW, less 3 ZMW in FXP fees.\n**POST /quotes**
note over D1
Fees will be taken out of the amount sent by the FXP.
So the total which will be received by Zoona will be:
Sent amount - FXP fees
POST /quotes
{
"quoteId": "382987a8-75ce-4037-b500-c475e08c1727"
,"transactionId": "d9ce59d4-3598-4396-8630-581bb0551451"
, "payee": {
"partyIdInfo": {
"partyIdType": "MSISDN"
, "partyIdentifier": "260795390415"
}
}
, "payer": {
"partyIdInfo": {
"partyIdType": "MSISDN"
, "partyIdentifier": "265314118010"
}
},
"amountType": "SEND"
, "amount": {
"currency": "ZMW"
, "amount": "97"
}
, "validity": "2021-08-25T14:17:09.663+01:00"
}
MW.\n**POST /quotes**
activate D2
D2-->S1:202 I'll get back to you
deactivate S1
D2->D2:OK, so I will charge 2 ZMW for this.\nNow I sign the transaction object\nand return it to the Debtor DFSP
D2->S1:Here's the signed quote
note over D2
**put /quotes/382987a8-75ce-4037-b500-c475e08c1727**
{
"transferAmount": {
"currency": "ZMW"
, "amount": "97"
}
, "payeeReceiveAmount": {
"currency": "ZMW"
, "amount": "95"
},
"payeeFspFee": {
"currency": "ZMW"
, "amount": "2"
}
, "expiration": "2021-08-25T14:17:09.663+01:00
, "transaction": {
, "transactionId": "d9ce59d4-3598-4396-8630-581bb0551451"
, "quoteId": "382987a8-75ce-4037-b500-c475e08c1727"
, "payee": {
"fspId": "Zoona"
, "partyIdInfo": {
"partyIdType": "MSISDN"
, "partyIdentifier": "260795390415"
}
}
, "payer": {
"fspId": "NBS_Bank"
, "partyIdInfo": {
"partyIdType": "MSISDN"
, "partyIdentifier": "265314118010"
}
}
, "amount": {
"currency": "MWK"
"amount": "5000"
}
, "payeeReceiveAmount": {
"currency": "ZMW"
, "amount": "95"
}
, "converter": "PAYER"
}
, "condition": "BfNFPRgfKF8Ke9kpoNAagmcI4/Hya5o/rq9/fq97ZiA="
}
end note
activate S1
S1-->D2:200 Gotcha
deactivate D2
S1->D1:Here's the signed quote\n**PUT /quotes/382987a8-75ce-4037-b500-c475e08c1727**
activate D1
D1-->S1:200 Gotcha
deactivate S1
D1->D1:OK, I can see that there are going to be 5 ZMW in charges.\nThis is derived from the source and target amounts in the quotation.\nLooking at the conversion quotation,\nthat must be 250 MWK
D1->A1:Hi, Upile: I can do the transfer.\nIt'll cost you 250 MWK in fees\nand Mulenga Kapwepwe will receive\n95 ZMW.\nLet me know if you want to go ahead
A1-->D1:Great! Yes please, go ahead
== Transfer Phase ==
D1->D1:First, activate the conversion
D1->S1:Please confirm your part of the transfer
note over D1
**POST /fxTransfers**
{
"commitRequestId": "77c9d78d-c26a-4474-8b3c-99b96a814bfc"
, "determiningTransactionId": "d9ce59d4-3598-4396-8630-581bb0551451"
, "requestingFsp": "NBS_Bank"
, "respondingFxp": "FDH_FX"
, "sourceAmount": {
"currency": "MWK",
"amount": "5000"
}
, "targetAmount": {
"currency": "ZMW",
"amount": "97"
}
, "condition": "bdbcf517cfc7e474392935781cc14043602e53dc2e8e8452826c5241dfd5e7ab"
}
end note
activate S1
S1-->D1:202 I'll get back to you
deactivate D2
S1->S1:OK, so this is an FX confirmation.
S1->S1: Is there a transfer request for the determining transfer?\nNo, there isn't.\nSo this must be for payer conversion
S1->S1: Liquidity check and reserve on Debtor DFSP's account
note over S1
Reservations:
NBS_Bank has a reservation of 5000 MWK
end note
S1->FXP:Please confirm the currency conversion part of the transfer\n** POST /fxTransfers**
activate FXP
FXP-->S1:202 I'll get back to you
deactivate S1
FXP->FXP:Is all this OK?\nIf so, send the fulfilment back
FXP->S1:Confirmed. Here's the fulfilment
note over FXP
**PUT /fxTransfers/77c9d78d-c26a-4474-8b3c-99b96a814bfc**
{
"fulfilment": "188909ceb6cd5c35d5c6b394f0a9e5a0571199c332fbd013dc1e6b8a2d5fff42"
, "completedTimeStamp": "2021-08-25T14:17:08.175+01:00"
, "conversionState": "RESERVED"
}
end note
activate S1
S1-->FXP:200 Gotcha
deactivate FXP
S1->S1:Check fulfilment matches and cancel if not.
alt Conversion failed
S1->FXP:Sorry. Conversion failed
note over FXP
**PATCH /fxTransfers/77c9d78d-c26a-4474-8b3c-99b96a814bfc**
{
"fulfilment": "188909ceb6cd5c35d5c6b394f0a9e5a0571199c332fbd013dc1e6b8a2d5fff42"
, "completedTimeStamp": "2021-08-25T14:17:08.175+01:00"
, "conversionState": "ABORTED"
}
end note
activate FXP
FXP-->S1:Acknowledged
FXP->FXP:Remove any reservations\nor obligations
deactivate FXP
S1->D1:Sorry. Conversion failed
note over S1
**PUT /fxTransfers/77c9d78d-c26a-4474-8b3c-99b96a814bfc/error**
{
"errorCode": "9999"
, "errorDescription": "Whatever the error was"
}
end note
else Conversion succeeded
S1->D1:Conversion succeeded subject to transfer success\n**PUT /fxTransfers/77c9d78d-c26a-4474-8b3c-99b96a814bfc**
note over S1
end note
end
activate D1
D1-->S1:200 Gotcha
deactivate S1
D1->D1:OK, so that's all right\nNow I can send the transfer itself
D1->S1:Please do the transfer
note over D1
POST /transfers
{
"transferId": "c720ae14-fc72-4acd-9113-8b601b34ba4d"
, "payeeFsp": "Zoona"
, "payerFsp": "NBS_Bank"
, "amount": {
"currency": "ZMW"
, "amount": "97"
}
, "transaction": {
, "transactionId": "d9ce59d4-3598-4396-8630-581bb0551451"
, "quoteId": "382987a8-75ce-4037-b500-c475e08c1727"
, "payee": {
"fspId": "Zoona"
, "partyIdInfo": {
"partyIdType": "MSISDN"
, "partyIdentifier": "260795390415"
}
}
, "payer": {
"fspId": "NBS_Bank"
, "partyIdInfo": {
"partyIdType": "MSISDN"
, "partyIdentifier": "265314118010"
}
}
}
}
end note
activate S1
S1-->D1:202 I'll get back to you
deactivate D1
S1->S1:Is there a dependent transfer? Yes
S1->S1:Perform liquidity check and reserve funds\nagainst creditor party to dependent transfer
note over S1
Reservations:
NBS_Bank has a reservation of 5000 MWK
FDH_FX has a reservation of 97 ZMW
end note
S1->D2:Please do the transfer\n**POST /transfers**
activate D2
D2-->S1:202 I'll get back to you
deactivate S1
D2->D2:Let me check that the terms of the dependent transfer\nare the same as the ones I agreed to\nand that the fulfilment and condition match
D2->D2:Yes, they do. I approve the transfer
D2->S1:Transfer is confirmed, here's the fulfilment
note over D2
**PUT /transfers/c720ae14-fc72-4acd-9113-8b601b34ba4d**
{
"fulfilment": "mhPUT9ZAwd-BXLfeSd7-YPh46rBWRNBiTCSWjpku90s"
, "completedTimestamp": "2021-08-25T14:17:08.227+01:00"
, "transferState": "COMMITTED"
}
end note
activate S1
S1-->D2:200 Gotcha
deactivate D2
S1->S1:Is there a dependent transfer?\nYes, there is.
S1->S1:Is this dependency against the debtor party to the transfer?\nYes, it is.
S1->S1:Create an obligation from the debtor party to the party named in the dependency (the FXP)
S1->S1:Is the transfer denominated in the currency of the payee receive amount?\nYes, it is.
S1->S1:Create an obligation from the party named in the dependency\nto the creditor party for the transfer
S1->FXP:The transfer succeeded.\nYou can clear it in your ledgers
note over S1
**PATCH /fxTransfers/77c9d78d-c26a-4474-8b3c-99b96a814bfc**
{
"fulfilment": "2e6870fb4eda9c2a29ecf376ceb5b05c"
, "completedTimeStamp": "2021-08-25T14:17:08.175+01:00"
, "conversionState": "COMMITTED"
}
end note
activate FXP
FXP->FXP:Let's just check: does this match the stuff I sent?
FXP->FXP:It does. Great. I'll clear the conversion
FXP->S1:200 Gotcha
deactivate FXP
note over S1
Ledger positions:
NBS_Bank has a debit of 5000 MWK
FDH_FX has a credit of 5000 MWK
FDH_FX has a debit of 97 ZMW
Zoona has a credit of 97 ZMW
end note
S1->D1:Transfer is complete\n**PUT /transfers/c720ae14-fc72-4acd-9113-8b601b34ba4d**
activate D1
D1-->S1:200 Gotcha
deactivate S1
D1->D1:Commit the funds in my ledgers
D1->A1:Transfer was completed successfully
deactivate D1
@enduml