@riocrypto/common-server 1.0.941 → 1.0.943
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.
|
@@ -16,15 +16,19 @@ const ccxt_client_1 = require("../clients/ccxt-client");
|
|
|
16
16
|
const getNetworkFees = (crypto, conversionRateToUSD) => __awaiter(void 0, void 0, void 0, function* () {
|
|
17
17
|
const address = crypto === common_1.Crypto.USDCSolana
|
|
18
18
|
? "HN7cABqLq46Es1jh92dQQisAq662SmxELLLsHHe4YWrH"
|
|
19
|
-
:
|
|
20
|
-
? "TDnvjqzjzBhjQp1b7SSQukAm71WusJeiej"
|
|
21
|
-
: "0x66ECBd38905CC32249ddd6f4f0B4A3DdDDCbd608";
|
|
19
|
+
: "0x66ECBd38905CC32249ddd6f4f0B4A3DdDDCbd608";
|
|
22
20
|
const fireblocksClient = yield (0, fireblocks_client_1.buildFireblocksClient)();
|
|
23
|
-
|
|
21
|
+
// Hacky way bc ccxt doesn't support TRON, so quote in MATIC
|
|
22
|
+
const cryptoToWithdraw = crypto === common_1.Crypto.USDTTron ? common_1.Crypto.USDCPolygon : crypto;
|
|
23
|
+
const withdrawFee = yield fireblocksClient.estimateWithdrawFee(cryptoToWithdraw, address, 100);
|
|
24
24
|
if (!withdrawFee) {
|
|
25
25
|
throw new common_1.GenericInternalError();
|
|
26
26
|
}
|
|
27
|
-
|
|
27
|
+
// Hacky way bc ccxt doesn't support TRON, so quote in MATIC
|
|
28
|
+
const gasSymbol = crypto === common_1.Crypto.USDTTron
|
|
29
|
+
? "MATIC"
|
|
30
|
+
: new common_1.CryptoAsset(crypto).getGasSymbol();
|
|
31
|
+
const withdrawFeeUSDResponse = yield ccxt_client_1.ccxtWrapper.getSellQuote(gasSymbol, common_1.Fiat.USD, undefined, Number(withdrawFee));
|
|
28
32
|
const withdrawFeeInBaseCrypto = withdrawFeeUSDResponse.amountFiat;
|
|
29
33
|
const withdrawFeeInBaseFiat = Number(withdrawFeeUSDResponse.amountFiat) * (1 / conversionRateToUSD);
|
|
30
34
|
return { withdrawFeeInBaseFiat, withdrawFeeInBaseCrypto };
|
package/build/index.d.ts
CHANGED
|
@@ -25,6 +25,7 @@ export * from "./models/user";
|
|
|
25
25
|
export * from "./models/ccxt-order";
|
|
26
26
|
export * from "./models/kushki-payment";
|
|
27
27
|
export * from "./models/kyc";
|
|
28
|
+
export * from "./models/deposit-address";
|
|
28
29
|
export * from "./models/checked-address";
|
|
29
30
|
export * from "./models/rio-settings";
|
|
30
31
|
export * from "./models/partner-auth";
|
package/build/index.js
CHANGED
|
@@ -41,6 +41,7 @@ __exportStar(require("./models/user"), exports);
|
|
|
41
41
|
__exportStar(require("./models/ccxt-order"), exports);
|
|
42
42
|
__exportStar(require("./models/kushki-payment"), exports);
|
|
43
43
|
__exportStar(require("./models/kyc"), exports);
|
|
44
|
+
__exportStar(require("./models/deposit-address"), exports);
|
|
44
45
|
__exportStar(require("./models/checked-address"), exports);
|
|
45
46
|
__exportStar(require("./models/rio-settings"), exports);
|
|
46
47
|
__exportStar(require("./models/partner-auth"), exports);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Crypto } from "@riocrypto/common";
|
|
2
|
+
import mongoose from "mongoose";
|
|
3
|
+
interface DepositAddressAttrs {
|
|
4
|
+
userId: string;
|
|
5
|
+
crypto: Crypto;
|
|
6
|
+
address: string;
|
|
7
|
+
provider: string;
|
|
8
|
+
}
|
|
9
|
+
interface DepositAddressDoc extends mongoose.Document {
|
|
10
|
+
userId: string;
|
|
11
|
+
crypto: Crypto;
|
|
12
|
+
address: string;
|
|
13
|
+
provider: string;
|
|
14
|
+
}
|
|
15
|
+
interface DepositAddressModel extends mongoose.Model<DepositAddressDoc> {
|
|
16
|
+
build(attrs: DepositAddressAttrs): DepositAddressDoc;
|
|
17
|
+
}
|
|
18
|
+
declare const buildDepositAddress: (mongoose: typeof mongoose) => DepositAddressModel;
|
|
19
|
+
export { buildDepositAddress, DepositAddressDoc };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildDepositAddress = void 0;
|
|
4
|
+
const buildDepositAddress = (mongoose) => {
|
|
5
|
+
// if model is already defined, return it
|
|
6
|
+
if (mongoose.models.DepositAddress) {
|
|
7
|
+
return mongoose.model("DepositAddress");
|
|
8
|
+
}
|
|
9
|
+
const DepositAddressSchema = new mongoose.Schema({
|
|
10
|
+
userId: {
|
|
11
|
+
type: String,
|
|
12
|
+
required: true,
|
|
13
|
+
},
|
|
14
|
+
crypto: {
|
|
15
|
+
type: String,
|
|
16
|
+
required: true,
|
|
17
|
+
},
|
|
18
|
+
address: {
|
|
19
|
+
type: String,
|
|
20
|
+
required: true,
|
|
21
|
+
},
|
|
22
|
+
provider: {
|
|
23
|
+
type: String,
|
|
24
|
+
required: true,
|
|
25
|
+
},
|
|
26
|
+
}, {
|
|
27
|
+
toJSON: {
|
|
28
|
+
transform(doc, ret) {
|
|
29
|
+
ret.id = ret._id;
|
|
30
|
+
delete ret._id;
|
|
31
|
+
delete ret.__v;
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
DepositAddressSchema.statics.build = (attrs) => {
|
|
36
|
+
return new DepositAddress(attrs);
|
|
37
|
+
};
|
|
38
|
+
const DepositAddress = mongoose.model("DepositAddress", DepositAddressSchema);
|
|
39
|
+
return DepositAddress;
|
|
40
|
+
};
|
|
41
|
+
exports.buildDepositAddress = buildDepositAddress;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@riocrypto/common-server",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.943",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./build/index.js",
|
|
6
6
|
"types": "./build/index.d.ts",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"@aws-sdk/client-s3": "^3.297.0",
|
|
25
25
|
"@everapi/currencyapi-js": "^1.0.6",
|
|
26
26
|
"@google-cloud/storage": "^6.9.5",
|
|
27
|
-
"@riocrypto/common": "^1.0.
|
|
27
|
+
"@riocrypto/common": "^1.0.811",
|
|
28
28
|
"@types/express": "^4.17.13",
|
|
29
29
|
"axios": "^0.27.2",
|
|
30
30
|
"ccxt": "^3.0.30",
|