@riocrypto/common-server 1.0.2879 → 1.0.2880
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -31,8 +31,11 @@ const getProcessor = ({ country, fiat, side, isBinanceRFQ, routingConfig, disabl
|
|
|
31
31
|
];
|
|
32
32
|
// Applied only inside the branches that genuinely have more than one rail, so
|
|
33
33
|
// a stray rule cannot hijack structural routing (COP, USD in the US or Mexico)
|
|
34
|
-
// or bypass the country checks below.
|
|
35
|
-
//
|
|
34
|
+
// or bypass the country checks below. Answers even when no rule is configured,
|
|
35
|
+
// because the corridor default is only safe to use once the rails the customer
|
|
36
|
+
// has switched off are out of the running. Undefined is left for the one case
|
|
37
|
+
// that genuinely belongs to structural routing: a custom Rio bank account whose
|
|
38
|
+
// rail we do not know.
|
|
36
39
|
const trySplit = () => {
|
|
37
40
|
const routed = (0, resolve_processor_1.resolveProcessor)({
|
|
38
41
|
country,
|
|
@@ -62,10 +65,11 @@ const getProcessor = ({ country, fiat, side, isBinanceRFQ, routingConfig, disabl
|
|
|
62
65
|
}
|
|
63
66
|
return undefined;
|
|
64
67
|
};
|
|
65
|
-
// The rail
|
|
66
|
-
//
|
|
67
|
-
//
|
|
68
|
-
// corridor that gets this far has to
|
|
68
|
+
// The rail a corridor with nothing to decide runs on, from the one table the
|
|
69
|
+
// routing editor reads as well, so the page can name it. Reached by corridors
|
|
70
|
+
// with a single rail, and by the unknown-rail custom account case. Throwing on
|
|
71
|
+
// a missing entry keeps the two honest: a corridor that gets this far has to
|
|
72
|
+
// have a default.
|
|
69
73
|
const structural = () => {
|
|
70
74
|
const fallback = (0, common_1.getDefaultProcessor)(country, fiat, purpose, excludedProcessors);
|
|
71
75
|
if (!fallback) {
|
|
@@ -13,6 +13,6 @@ export interface ResolveProcessorParams {
|
|
|
13
13
|
}
|
|
14
14
|
export interface ResolveProcessorResult {
|
|
15
15
|
processor?: Processor;
|
|
16
|
-
reason: "customRioBankAccount" | "customRioBankAccountWithoutRail" | "split" | "onlyCandidate" | "enabledRailWithoutShare" | "
|
|
16
|
+
reason: "customRioBankAccount" | "customRioBankAccountWithoutRail" | "split" | "onlyCandidate" | "enabledRailWithoutShare" | "noEligibleCandidate" | "noEnabledCandidate";
|
|
17
17
|
}
|
|
18
18
|
export declare const resolveProcessor: ({ country, fiat, purpose, routingConfig, excludedProcessors, disabledProcessors, customRioBankAccount, randomSeed, }: ResolveProcessorParams) => ResolveProcessorResult;
|
|
@@ -23,11 +23,11 @@ const pickByShare = (candidates, position) => {
|
|
|
23
23
|
// from the configured split.
|
|
24
24
|
//
|
|
25
25
|
// A percentage divides volume between the rails that are actually available to
|
|
26
|
-
// the customer; it is not a switch. A rail left at zero,
|
|
27
|
-
//
|
|
28
|
-
// enabled, which is why the candidate set comes from
|
|
29
|
-
// from the rule. Switching a rail off is the only way to
|
|
30
|
-
// it.
|
|
26
|
+
// the customer; it is not a switch. A rail left at zero, left out of the rule, or
|
|
27
|
+
// belonging to a corridor with no rule at all still takes their orders when it is
|
|
28
|
+
// the only one they have left enabled, which is why the candidate set comes from
|
|
29
|
+
// the corridor rather than from the rule. Switching a rail off is the only way to
|
|
30
|
+
// keep an order away from it.
|
|
31
31
|
//
|
|
32
32
|
// Does no IO of its own - the routing config and the user's readiness are passed
|
|
33
33
|
// in - and the only nondeterminism is the per-order roll, which a caller can
|
|
@@ -73,10 +73,12 @@ const resolveProcessor = ({ country, fiat, purpose, routingConfig, excludedProce
|
|
|
73
73
|
}
|
|
74
74
|
return { processor, reason: "customRioBankAccount" };
|
|
75
75
|
}
|
|
76
|
+
// An absent rule is read as every rail at zero rather than as a reason to stop.
|
|
77
|
+
// Bailing out here would hand the decision to the structural default, which
|
|
78
|
+
// knows nothing about which rails the customer accepts, and every corridor is
|
|
79
|
+
// ruleless until an admin first saves one - as is any corridor whose shares
|
|
80
|
+
// were all cleared, since the settings page stores that as no rule at all.
|
|
76
81
|
const rule = getRule(routingConfig, country, fiat, purpose);
|
|
77
|
-
if (!rule) {
|
|
78
|
-
return { reason: "noRuleConfigured" };
|
|
79
|
-
}
|
|
80
82
|
// Starts from the corridor's rails rather than from the rails the rule names,
|
|
81
83
|
// because a percentage decides how volume is divided between the rails a
|
|
82
84
|
// customer can use - it is not what makes a rail usable. Also drops any share
|
|
@@ -91,16 +93,20 @@ const resolveProcessor = ({ country, fiat, purpose, routingConfig, excludedProce
|
|
|
91
93
|
return { reason: "noEnabledCandidate" };
|
|
92
94
|
}
|
|
93
95
|
const shares = candidates
|
|
94
|
-
.map((processor) =>
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
96
|
+
.map((processor) => {
|
|
97
|
+
var _a;
|
|
98
|
+
return ({
|
|
99
|
+
processor,
|
|
100
|
+
percentage: Number((_a = rule === null || rule === void 0 ? void 0 : rule.percentages) === null || _a === void 0 ? void 0 : _a[processor]) || 0,
|
|
101
|
+
});
|
|
102
|
+
})
|
|
98
103
|
.filter((candidate) => candidate.percentage > 0);
|
|
99
|
-
// None of the rails this customer can use carries a share
|
|
100
|
-
//
|
|
101
|
-
//
|
|
102
|
-
//
|
|
103
|
-
//
|
|
104
|
+
// None of the rails this customer can use carries a share - or no rule is
|
|
105
|
+
// configured at all - so there is no split to draw from. Refusing the order
|
|
106
|
+
// would read a zero as "never use this rail", when all it says is where volume
|
|
107
|
+
// goes while there is somewhere else to send it. Prefers the corridor default
|
|
108
|
+
// and otherwise the corridor's own order, so the rail a customer in this
|
|
109
|
+
// position gets is predictable rather than rolled.
|
|
104
110
|
if (!shares.length) {
|
|
105
111
|
const fallback = (0, common_1.getDefaultProcessor)(country, fiat, purpose, excludedProcessors);
|
|
106
112
|
return {
|