@riocrypto/common-server 1.0.2877 → 1.0.2879
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.
- package/build/clients/cluster-client.d.ts +36 -0
- package/build/clients/cluster-client.js +31 -1
- package/build/helpers/get-custom-rio-bank-account.d.ts +10 -0
- package/build/helpers/get-custom-rio-bank-account.js +37 -0
- package/build/helpers/get-processor.d.ts +7 -4
- package/build/helpers/get-processor.js +72 -55
- package/build/helpers/get-tax-rate.js +1 -0
- package/build/helpers/payin-destinations.d.ts +37 -0
- package/build/helpers/payin-destinations.js +286 -0
- package/build/helpers/payin-verification.d.ts +30 -0
- package/build/helpers/payin-verification.js +162 -0
- package/build/helpers/processor-enablement.d.ts +19 -0
- package/build/helpers/processor-enablement.js +87 -0
- package/build/helpers/record-observed-processor-readiness.d.ts +10 -0
- package/build/helpers/record-observed-processor-readiness.js +65 -0
- package/build/helpers/resolve-processor.d.ts +18 -0
- package/build/helpers/resolve-processor.js +122 -0
- package/build/index.d.ts +10 -0
- package/build/index.js +10 -0
- package/build/middlewares/get-order.js +1 -0
- package/build/models/bank-account-verification.d.ts +2 -2
- package/build/models/bulk-bank-payment.js +3 -0
- package/build/models/fintoc-deposit-CLABE.d.ts +28 -0
- package/build/models/fintoc-deposit-CLABE.js +56 -0
- package/build/models/fintoc-mxn-withdrawal.d.ts +51 -0
- package/build/models/fintoc-mxn-withdrawal.js +88 -0
- package/build/models/fireblocks-vault.d.ts +8 -0
- package/build/models/fireblocks-vault.js +8 -0
- package/build/models/internal-balances.d.ts +3 -0
- package/build/models/internal-balances.js +3 -0
- package/build/models/payment-address-verification.d.ts +49 -0
- package/build/models/payment-address-verification.js +77 -0
- package/build/models/processor-readiness.d.ts +44 -0
- package/build/models/processor-readiness.js +90 -0
- package/build/models/rio-bank-account.d.ts +3 -1
- package/build/models/rio-bank-account.js +3 -0
- package/build/models/rio-settings.d.ts +3 -11
- package/build/models/rio-settings.js +1 -2
- package/package.json +2 -2
|
@@ -2,6 +2,30 @@
|
|
|
2
2
|
/// <reference types="node" />
|
|
3
3
|
import { Quote, Fiat, Crypto, BitsoBankAccount, Side, Country, Order, CryptoAddress, BankAccount, AuthRole, Auth, ImportOrderData, TreasuryProvider, FXProvider, EmarketsFXTrade, ExternalTradingAlgorithm, ExternalTrade, ExternalTradeType, ExternalTradingProvider, ExternalTradingAlgorithmType, STPMXNWithdrawal, AuthPermission, DeferredPaymentType, TwoWaySettlementType, OrderType, EmarketsSettlementType, EmarketsOrderType, BulkBankPayout, BulkCryptoPayout, BulkBankPayment, BulkCryptoPayment, OrderStatus, TWAPSession, TransnetworkFXTrade, TransnetworkSettlementType, TransnetworkOrderType, AuthMethod, StonexFXTrade, CancelExternalTradeReason } from "@riocrypto/common";
|
|
4
4
|
import { STPMXNWithdrawalDoc } from "../models/STP-mxn-withdrawal";
|
|
5
|
+
import { FintocMXNWithdrawalDoc } from "../models/fintoc-mxn-withdrawal";
|
|
6
|
+
export interface FintocTransfer {
|
|
7
|
+
id: string;
|
|
8
|
+
amount: number;
|
|
9
|
+
currency?: string;
|
|
10
|
+
status?: string;
|
|
11
|
+
direction?: string;
|
|
12
|
+
comment?: string;
|
|
13
|
+
reference_id?: string;
|
|
14
|
+
tracking_key?: string;
|
|
15
|
+
receipt_url?: string;
|
|
16
|
+
created_at?: string;
|
|
17
|
+
account_number?: {
|
|
18
|
+
id?: string;
|
|
19
|
+
number?: string;
|
|
20
|
+
metadata?: Record<string, string>;
|
|
21
|
+
};
|
|
22
|
+
counterparty?: {
|
|
23
|
+
account_number?: string;
|
|
24
|
+
holder_name?: string;
|
|
25
|
+
holder_id?: string;
|
|
26
|
+
bank_name?: string;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
5
29
|
declare class ClusterClient {
|
|
6
30
|
private baseUrl;
|
|
7
31
|
private clusterApiKey;
|
|
@@ -218,6 +242,9 @@ declare class ClusterClient {
|
|
|
218
242
|
generateSTPDepositCLABE(userId: string): Promise<{
|
|
219
243
|
CLABE: string;
|
|
220
244
|
}>;
|
|
245
|
+
generateFintocDepositCLABE(userId: string): Promise<{
|
|
246
|
+
CLABE: string;
|
|
247
|
+
}>;
|
|
221
248
|
generateAlfinVirtualCci(userId: string, fiat: Fiat): Promise<{
|
|
222
249
|
CCIV: string;
|
|
223
250
|
codigoPagoCCIV?: string;
|
|
@@ -230,7 +257,16 @@ declare class ClusterClient {
|
|
|
230
257
|
}>;
|
|
231
258
|
getAlfinBalance(fiat: Fiat): Promise<number>;
|
|
232
259
|
getSTPMXNBalance(): Promise<number>;
|
|
260
|
+
getFintocMXNBalance(): Promise<number>;
|
|
233
261
|
createSTPMXNWithdrawal(amount: number, CLABE: string, concepto: string, beneficiaryName: string, internalTransferId?: string): Promise<STPMXNWithdrawalDoc>;
|
|
262
|
+
createFintocMXNWithdrawal(amount: number, CLABE: string, concepto: string, beneficiaryName: string, internalTransferId?: string): Promise<FintocMXNWithdrawalDoc>;
|
|
263
|
+
listFintocTransfers(params: {
|
|
264
|
+
since?: string;
|
|
265
|
+
startingAfter?: string;
|
|
266
|
+
limit?: number;
|
|
267
|
+
}): Promise<{
|
|
268
|
+
transfers: FintocTransfer[];
|
|
269
|
+
}>;
|
|
234
270
|
getSTPMXNWithdrawal(id: string): Promise<STPMXNWithdrawal>;
|
|
235
271
|
createBulkBankPayout(userId: string, payoutBankAccountId: string, deferredPaymentType: DeferredPaymentType): Promise<BulkBankPayout>;
|
|
236
272
|
createBulkCryptoPayout(userId: string, payoutAddressId: string, country: Country, deferredPaymentType: DeferredPaymentType): Promise<BulkCryptoPayout>;
|
|
@@ -711,6 +711,12 @@ class ClusterClient {
|
|
|
711
711
|
return response.data;
|
|
712
712
|
});
|
|
713
713
|
}
|
|
714
|
+
generateFintocDepositCLABE(userId) {
|
|
715
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
716
|
+
const response = yield this.axios.post(`${this.baseUrl}/api/bank/accounts/fintoc/CLABE`, { userId }, { headers: { "x-cluster-api-key": this.clusterApiKey } });
|
|
717
|
+
return response.data;
|
|
718
|
+
});
|
|
719
|
+
}
|
|
714
720
|
generateAlfinVirtualCci(userId, fiat) {
|
|
715
721
|
return __awaiter(this, void 0, void 0, function* () {
|
|
716
722
|
const response = yield this.axios.post(`${this.baseUrl}/api/bank/accounts/alfin/CCIV`, { userId, fiat }, { headers: { "x-cluster-api-key": this.clusterApiKey } });
|
|
@@ -735,12 +741,36 @@ class ClusterClient {
|
|
|
735
741
|
return response.data.balance;
|
|
736
742
|
});
|
|
737
743
|
}
|
|
744
|
+
getFintocMXNBalance() {
|
|
745
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
746
|
+
const response = yield this.axios.get(`${this.baseUrl}/api/bank/accounts/fintoc/MXN/balance`, { headers: { "x-cluster-api-key": this.clusterApiKey } });
|
|
747
|
+
return response.data.balance;
|
|
748
|
+
});
|
|
749
|
+
}
|
|
738
750
|
createSTPMXNWithdrawal(amount, CLABE, concepto, beneficiaryName, internalTransferId) {
|
|
739
751
|
return __awaiter(this, void 0, void 0, function* () {
|
|
740
752
|
const response = yield this.axios.post(`${this.baseUrl}/api/bank/accounts/STP/MXN/withdrawals`, { amount, CLABE, concepto, beneficiaryName, internalTransferId }, { headers: { "x-cluster-api-key": this.clusterApiKey } });
|
|
741
753
|
return response.data;
|
|
742
754
|
});
|
|
743
755
|
}
|
|
756
|
+
createFintocMXNWithdrawal(amount, CLABE, concepto, beneficiaryName, internalTransferId) {
|
|
757
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
758
|
+
const response = yield this.axios.post(`${this.baseUrl}/api/bank/accounts/fintoc/MXN/withdrawals`, { amount, CLABE, concepto, beneficiaryName, internalTransferId }, { headers: { "x-cluster-api-key": this.clusterApiKey } });
|
|
759
|
+
return response.data;
|
|
760
|
+
});
|
|
761
|
+
}
|
|
762
|
+
// Read-only listing of transfers on Rio's Fintoc treasury account, used by the
|
|
763
|
+
// liquidity-management treasury import. Paginate with `startingAfter` (the id
|
|
764
|
+
// of the last transfer from the previous page).
|
|
765
|
+
listFintocTransfers(params) {
|
|
766
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
767
|
+
const response = yield this.axios.get(`${this.baseUrl}/api/bank/accounts/fintoc/transfers`, {
|
|
768
|
+
params,
|
|
769
|
+
headers: { "x-cluster-api-key": this.clusterApiKey },
|
|
770
|
+
});
|
|
771
|
+
return response.data;
|
|
772
|
+
});
|
|
773
|
+
}
|
|
744
774
|
getSTPMXNWithdrawal(id) {
|
|
745
775
|
return __awaiter(this, void 0, void 0, function* () {
|
|
746
776
|
const response = yield this.axios.get(`${this.baseUrl}/api/bank/accounts/STP/MXN/withdrawals/${id}`, { headers: { "x-cluster-api-key": this.clusterApiKey } });
|
|
@@ -1005,7 +1035,7 @@ const buildClusterClient = () => __awaiter(void 0, void 0, void 0, function* ()
|
|
|
1005
1035
|
throw new common_1.SecretManagerError();
|
|
1006
1036
|
}
|
|
1007
1037
|
const baseUrl = process.env.RIO_ENV === common_1.RioEnv.Local
|
|
1008
|
-
? "https://app.local.rio.trade:3443"
|
|
1038
|
+
? process.env.API_URL || "https://app.local.rio.trade:3443"
|
|
1009
1039
|
: process.env.RIO_ENV === common_1.RioEnv.Development
|
|
1010
1040
|
? "https://app.dev.rio.trade"
|
|
1011
1041
|
: process.env.RIO_ENV === common_1.RioEnv.Production
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Country, Fiat, Processor, User } from "@riocrypto/common";
|
|
2
|
+
import { Mongoose } from "mongoose";
|
|
3
|
+
export declare const getCustomRioBankAccount: ({ mongoose, user, country, fiat, }: {
|
|
4
|
+
mongoose: Mongoose;
|
|
5
|
+
user: Pick<User, "rioBankAccount">;
|
|
6
|
+
country: Country;
|
|
7
|
+
fiat: Fiat;
|
|
8
|
+
}) => Promise<{
|
|
9
|
+
processor?: Processor;
|
|
10
|
+
} | undefined>;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.getCustomRioBankAccount = void 0;
|
|
13
|
+
const rio_bank_account_1 = require("../models/rio-bank-account");
|
|
14
|
+
// Looks up the custom Rio bank account assigned to a user for one corridor, if
|
|
15
|
+
// any. Returning an object with an undefined `processor` is meaningful and is
|
|
16
|
+
// not the same as returning undefined: it says the user does have a custom
|
|
17
|
+
// account but we do not know which rail it belongs to, which routing treats
|
|
18
|
+
// differently from having no custom account at all.
|
|
19
|
+
const getCustomRioBankAccount = ({ mongoose, user, country, fiat, }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
20
|
+
var _a, _b, _c;
|
|
21
|
+
const rioBankAccountId = (_c = (_b = (_a = user.rioBankAccount) === null || _a === void 0 ? void 0 : _a[country]) === null || _b === void 0 ? void 0 : _b[fiat]) === null || _c === void 0 ? void 0 : _c.id;
|
|
22
|
+
if (!rioBankAccountId) {
|
|
23
|
+
return undefined;
|
|
24
|
+
}
|
|
25
|
+
const RioBankAccount = (0, rio_bank_account_1.buildRioBankAccount)(mongoose);
|
|
26
|
+
const rioBankAccount = yield RioBankAccount.findById(rioBankAccountId)
|
|
27
|
+
.select({ processor: 1 })
|
|
28
|
+
.lean();
|
|
29
|
+
// A dangling reference still means the user is on a custom account as far as
|
|
30
|
+
// routing is concerned. getBankDetails throws on it, and that error is far
|
|
31
|
+
// easier to act on than a payin silently routed to a shared rail.
|
|
32
|
+
if (!rioBankAccount) {
|
|
33
|
+
return {};
|
|
34
|
+
}
|
|
35
|
+
return { processor: rioBankAccount.processor };
|
|
36
|
+
});
|
|
37
|
+
exports.getCustomRioBankAccount = getCustomRioBankAccount;
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
import { Country, Fiat, Processor,
|
|
2
|
-
export declare const getProcessor: ({ country, fiat,
|
|
1
|
+
import { Country, Fiat, Processor, ProcessorRoutingConfig, Side } from "@riocrypto/common";
|
|
2
|
+
export declare const getProcessor: ({ country, fiat, side, isBinanceRFQ, routingConfig, disabledProcessors, customRioBankAccount, }: {
|
|
3
3
|
country: Country;
|
|
4
4
|
fiat: Fiat;
|
|
5
|
-
user: User;
|
|
6
|
-
activeProcessors: Processor[];
|
|
7
5
|
side: Side;
|
|
8
6
|
isBinanceRFQ: boolean;
|
|
7
|
+
routingConfig?: ProcessorRoutingConfig | undefined;
|
|
8
|
+
disabledProcessors?: Processor[] | undefined;
|
|
9
|
+
customRioBankAccount?: {
|
|
10
|
+
processor?: Processor | undefined;
|
|
11
|
+
} | undefined;
|
|
9
12
|
}) => Processor;
|
|
@@ -2,18 +2,80 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getProcessor = void 0;
|
|
4
4
|
const common_1 = require("@riocrypto/common");
|
|
5
|
+
const resolve_processor_1 = require("./resolve-processor");
|
|
5
6
|
// Alfin takes effect only in Production (Alfin prod). In every other
|
|
6
|
-
// environment we never route to Alfin, regardless of
|
|
7
|
-
//
|
|
7
|
+
// environment we never route to Alfin, regardless of what the routing config
|
|
8
|
+
// says; non-prod Peru flows fall back to the mocked Interbank path.
|
|
8
9
|
const isAlfinEnabled = () => [common_1.RioEnv.Production].includes(process.env.RIO_ENV);
|
|
9
|
-
|
|
10
|
-
|
|
10
|
+
// How far STP reaches depends on the direction. Allocating a deposit CLABE runs
|
|
11
|
+
// in Production alone, so a buy routed to STP anywhere else has no account for
|
|
12
|
+
// the customer to pay into. Payouts run in Development too, alongside the payout
|
|
13
|
+
// retry cron and the treasury imports it depends on.
|
|
14
|
+
//
|
|
15
|
+
// Covers what the rio-settings validator cannot: it rejects an STP share outside
|
|
16
|
+
// Production and Development, but says nothing about the structural default.
|
|
17
|
+
// Mexican pesos name a second default rail for exactly this reason.
|
|
18
|
+
const isSTPAvailable = (purpose) => (purpose === common_1.ProcessorRoutingPurpose.Buy
|
|
19
|
+
? [common_1.RioEnv.Production]
|
|
20
|
+
: [common_1.RioEnv.Production, common_1.RioEnv.Development]).includes(process.env.RIO_ENV);
|
|
21
|
+
const getProcessor = ({ country, fiat, side, isBinanceRFQ, routingConfig, disabledProcessors, customRioBankAccount, }) => {
|
|
11
22
|
if (isBinanceRFQ === true) {
|
|
12
23
|
return common_1.Processor.BinanceRFQ;
|
|
13
24
|
}
|
|
25
|
+
const purpose = side === common_1.Side.Buy
|
|
26
|
+
? common_1.ProcessorRoutingPurpose.Buy
|
|
27
|
+
: common_1.ProcessorRoutingPurpose.Sell;
|
|
28
|
+
const excludedProcessors = [
|
|
29
|
+
...(isAlfinEnabled() ? [] : [common_1.Processor.Alfin]),
|
|
30
|
+
...(isSTPAvailable(purpose) ? [] : [common_1.Processor.SPEI_STP]),
|
|
31
|
+
];
|
|
32
|
+
// Applied only inside the branches that genuinely have more than one rail, so
|
|
33
|
+
// a stray rule cannot hijack structural routing (COP, USD in the US or Mexico)
|
|
34
|
+
// or bypass the country checks below. Returns undefined when no rule is
|
|
35
|
+
// configured, leaving the corridor's structural default in charge.
|
|
36
|
+
const trySplit = () => {
|
|
37
|
+
const routed = (0, resolve_processor_1.resolveProcessor)({
|
|
38
|
+
country,
|
|
39
|
+
fiat,
|
|
40
|
+
purpose,
|
|
41
|
+
routingConfig,
|
|
42
|
+
excludedProcessors,
|
|
43
|
+
disabledProcessors,
|
|
44
|
+
customRioBankAccount,
|
|
45
|
+
});
|
|
46
|
+
if (routed.processor) {
|
|
47
|
+
return routed.processor;
|
|
48
|
+
}
|
|
49
|
+
// Every rail in this corridor is switched off for this direction, so there is
|
|
50
|
+
// nowhere to send them - a rail at zero percent would still have taken the
|
|
51
|
+
// order. Says so specifically, and names where to fix it, since the fix is
|
|
52
|
+
// theirs to make rather than something support has to escalate.
|
|
53
|
+
if (routed.reason === "noEnabledCandidate") {
|
|
54
|
+
throw new common_1.GenericInputError(side === common_1.Side.Buy
|
|
55
|
+
? "You need to enable a payment account for this currency before you can buy. You can turn one back on from the payment accounts page."
|
|
56
|
+
: "You need to enable a payout account for this currency before you can sell. You can turn one back on from the payout accounts page.");
|
|
57
|
+
}
|
|
58
|
+
// No rail in the corridor can be reached in this environment at all, which is
|
|
59
|
+
// a deployment fact rather than anything the customer can act on.
|
|
60
|
+
if (routed.reason === "noEligibleCandidate") {
|
|
61
|
+
throw new common_1.GenericInputError("No payment processor is currently available for this order");
|
|
62
|
+
}
|
|
63
|
+
return undefined;
|
|
64
|
+
};
|
|
65
|
+
// The rail this corridor runs on when no split decides it, from the one table
|
|
66
|
+
// the routing editor reads as well - so the page can name the rail an empty
|
|
67
|
+
// split leaves in charge. Throwing on a missing entry keeps the two honest: a
|
|
68
|
+
// corridor that gets this far has to have a default.
|
|
69
|
+
const structural = () => {
|
|
70
|
+
const fallback = (0, common_1.getDefaultProcessor)(country, fiat, purpose, excludedProcessors);
|
|
71
|
+
if (!fallback) {
|
|
72
|
+
throw new common_1.GenericInputError("No payment processor is configured for this currency");
|
|
73
|
+
}
|
|
74
|
+
return fallback;
|
|
75
|
+
};
|
|
14
76
|
if (fiat === common_1.Fiat.COP) {
|
|
15
77
|
if (country === common_1.Country.Colombia) {
|
|
16
|
-
return
|
|
78
|
+
return structural();
|
|
17
79
|
}
|
|
18
80
|
else {
|
|
19
81
|
throw new common_1.GenericInputError("COP is not supported in your country");
|
|
@@ -21,19 +83,7 @@ const getProcessor = ({ country, fiat, user, activeProcessors, side, isBinanceRF
|
|
|
21
83
|
}
|
|
22
84
|
else if (fiat === common_1.Fiat.PEN) {
|
|
23
85
|
if (country === common_1.Country.Peru) {
|
|
24
|
-
|
|
25
|
-
isAlfinEnabled() &&
|
|
26
|
-
((_a = user.attributes) === null || _a === void 0 ? void 0 : _a.includes(common_1.UserAttribute.UseAlfinForPENDeposits)) &&
|
|
27
|
-
activeProcessors.includes(common_1.Processor.Alfin)) {
|
|
28
|
-
return common_1.Processor.Alfin;
|
|
29
|
-
}
|
|
30
|
-
if (side === common_1.Side.Sell &&
|
|
31
|
-
isAlfinEnabled() &&
|
|
32
|
-
((_b = user.attributes) === null || _b === void 0 ? void 0 : _b.includes(common_1.UserAttribute.UseAlfinForPENWithdrawals)) &&
|
|
33
|
-
activeProcessors.includes(common_1.Processor.Alfin)) {
|
|
34
|
-
return common_1.Processor.Alfin;
|
|
35
|
-
}
|
|
36
|
-
return common_1.Processor.Interbank;
|
|
86
|
+
return trySplit() || structural();
|
|
37
87
|
}
|
|
38
88
|
else {
|
|
39
89
|
throw new common_1.GenericInputError("PEN is not supported in your country");
|
|
@@ -41,28 +91,7 @@ const getProcessor = ({ country, fiat, user, activeProcessors, side, isBinanceRF
|
|
|
41
91
|
}
|
|
42
92
|
else if (fiat === common_1.Fiat.MXN) {
|
|
43
93
|
if (country === common_1.Country.Mexico) {
|
|
44
|
-
|
|
45
|
-
((_c = user.attributes) === null || _c === void 0 ? void 0 : _c.includes(common_1.UserAttribute.UseSTPForMXNWithdrawals))) ||
|
|
46
|
-
(side === common_1.Side.Buy &&
|
|
47
|
-
((_d = user.attributes) === null || _d === void 0 ? void 0 : _d.includes(common_1.UserAttribute.UseSTPForMXNDeposits)))) {
|
|
48
|
-
if (activeProcessors.includes(common_1.Processor.SPEI_STP)) {
|
|
49
|
-
return common_1.Processor.SPEI_STP;
|
|
50
|
-
}
|
|
51
|
-
else if (activeProcessors.includes(common_1.Processor.SPEI_NVIO)) {
|
|
52
|
-
return common_1.Processor.SPEI_NVIO;
|
|
53
|
-
}
|
|
54
|
-
else {
|
|
55
|
-
return common_1.Processor.SPEI;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
else {
|
|
59
|
-
if (activeProcessors.includes(common_1.Processor.SPEI_NVIO)) {
|
|
60
|
-
return common_1.Processor.SPEI_NVIO;
|
|
61
|
-
}
|
|
62
|
-
else {
|
|
63
|
-
return common_1.Processor.SPEI;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
94
|
+
return trySplit() || structural();
|
|
66
95
|
}
|
|
67
96
|
else {
|
|
68
97
|
throw new common_1.GenericInputError("MXN is not supported in your country");
|
|
@@ -70,25 +99,13 @@ const getProcessor = ({ country, fiat, user, activeProcessors, side, isBinanceRF
|
|
|
70
99
|
}
|
|
71
100
|
else if (fiat === common_1.Fiat.USD) {
|
|
72
101
|
if (country === common_1.Country.UnitedStates) {
|
|
73
|
-
return
|
|
102
|
+
return structural();
|
|
74
103
|
}
|
|
75
104
|
else if (country === common_1.Country.Mexico) {
|
|
76
|
-
return
|
|
105
|
+
return structural();
|
|
77
106
|
}
|
|
78
107
|
else if (country === common_1.Country.Peru) {
|
|
79
|
-
|
|
80
|
-
isAlfinEnabled() &&
|
|
81
|
-
((_e = user.attributes) === null || _e === void 0 ? void 0 : _e.includes(common_1.UserAttribute.UseAlfinForUSDDeposits)) &&
|
|
82
|
-
activeProcessors.includes(common_1.Processor.Alfin)) {
|
|
83
|
-
return common_1.Processor.Alfin;
|
|
84
|
-
}
|
|
85
|
-
if (side === common_1.Side.Sell &&
|
|
86
|
-
isAlfinEnabled() &&
|
|
87
|
-
((_f = user.attributes) === null || _f === void 0 ? void 0 : _f.includes(common_1.UserAttribute.UseAlfinForUSDWithdrawals)) &&
|
|
88
|
-
activeProcessors.includes(common_1.Processor.Alfin)) {
|
|
89
|
-
return common_1.Processor.Alfin;
|
|
90
|
-
}
|
|
91
|
-
return common_1.Processor.Interbank;
|
|
108
|
+
return trySplit() || structural();
|
|
92
109
|
}
|
|
93
110
|
else {
|
|
94
111
|
throw new common_1.GenericInputError("USD is not supported in your country");
|
|
@@ -8,6 +8,7 @@ const getTaxRate = (user, country, fiat, processor) => {
|
|
|
8
8
|
if ((fiat === common_1.Fiat.MXN && processor === common_1.Processor.SPEI) ||
|
|
9
9
|
(fiat === common_1.Fiat.MXN && processor === common_1.Processor.SPEI_NVIO) ||
|
|
10
10
|
(fiat === common_1.Fiat.MXN && processor === common_1.Processor.SPEI_STP) ||
|
|
11
|
+
(fiat === common_1.Fiat.MXN && processor === common_1.Processor.SPEI_FINTOC) ||
|
|
11
12
|
(fiat === common_1.Fiat.USD && processor === common_1.Processor.SPID)) {
|
|
12
13
|
if (country === common_1.Country.Mexico &&
|
|
13
14
|
((_a = user === null || user === void 0 ? void 0 : user.address) === null || _a === void 0 ? void 0 : _a.country) === common_1.CountryOfOrigin.Mexico) {
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Country, Fiat, Processor, ProcessorReadinessStatus, User } from "@riocrypto/common";
|
|
2
|
+
import { Mongoose } from "mongoose";
|
|
3
|
+
export interface PayinBankDetails {
|
|
4
|
+
bankName?: string;
|
|
5
|
+
companyName?: string;
|
|
6
|
+
companyAddress?: string;
|
|
7
|
+
accountNumber?: string;
|
|
8
|
+
CCI?: string;
|
|
9
|
+
RUC?: string;
|
|
10
|
+
CLABE?: string;
|
|
11
|
+
RFC?: string;
|
|
12
|
+
bankAddress?: string;
|
|
13
|
+
NIT?: string;
|
|
14
|
+
}
|
|
15
|
+
export declare const PER_USER_PAYIN_PROCESSORS: Processor[];
|
|
16
|
+
export declare const getPayinBankDetails: ({ mongoose, processor, fiat, country, user, }: {
|
|
17
|
+
mongoose: Mongoose;
|
|
18
|
+
processor: Processor;
|
|
19
|
+
fiat: Fiat;
|
|
20
|
+
country: Country;
|
|
21
|
+
user: User;
|
|
22
|
+
}) => Promise<PayinBankDetails>;
|
|
23
|
+
export interface PayinDestination {
|
|
24
|
+
processor: Processor;
|
|
25
|
+
bankDetails: PayinBankDetails;
|
|
26
|
+
isProvisioned: boolean;
|
|
27
|
+
isEnabled: boolean;
|
|
28
|
+
readinessStatus?: ProcessorReadinessStatus;
|
|
29
|
+
}
|
|
30
|
+
export declare const getPayinDestinations: ({ mongoose, user, country, fiat, processors, provision, }: {
|
|
31
|
+
mongoose: Mongoose;
|
|
32
|
+
user: User;
|
|
33
|
+
country: Country;
|
|
34
|
+
fiat: Fiat;
|
|
35
|
+
processors: Processor[];
|
|
36
|
+
provision?: boolean | undefined;
|
|
37
|
+
}) => Promise<PayinDestination[]>;
|