@riocrypto/common-server 1.0.665 → 1.0.667
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.
|
@@ -32,10 +32,10 @@ declare class CCXTClient {
|
|
|
32
32
|
private getOptimalExchange;
|
|
33
33
|
private round;
|
|
34
34
|
private getExchange;
|
|
35
|
-
getSellQuote(
|
|
35
|
+
getSellQuote(crypto: Crypto, fiat: Fiat, amountFiat?: number, amountCrypto?: number): Promise<{
|
|
36
36
|
price: number;
|
|
37
37
|
amountCrypto: number;
|
|
38
|
-
amountFiat: number;
|
|
38
|
+
amountFiat: number | undefined;
|
|
39
39
|
crypto: Crypto;
|
|
40
40
|
fiat: Fiat;
|
|
41
41
|
}>;
|
|
@@ -189,8 +189,14 @@ class CCXTClient {
|
|
|
189
189
|
return exchange;
|
|
190
190
|
});
|
|
191
191
|
}
|
|
192
|
-
getSellQuote(
|
|
192
|
+
getSellQuote(crypto, fiat, amountFiat, amountCrypto) {
|
|
193
193
|
return __awaiter(this, void 0, void 0, function* () {
|
|
194
|
+
if (amountFiat && amountCrypto) {
|
|
195
|
+
throw new Error("Can only specify either amountFiat or amountCrypto");
|
|
196
|
+
}
|
|
197
|
+
if (!amountCrypto && !amountFiat) {
|
|
198
|
+
throw new Error("Must specify either amountFiat or amountCrypto");
|
|
199
|
+
}
|
|
194
200
|
if (this.env === "production") {
|
|
195
201
|
const exchange = yield this.getOptimalExchange(crypto);
|
|
196
202
|
if (!exchange)
|
|
@@ -200,13 +206,24 @@ class CCXTClient {
|
|
|
200
206
|
if (!ticker.vwap)
|
|
201
207
|
throw new Error("Unable to get ticker vwap");
|
|
202
208
|
const exchangeFee = exchange.id === "bitstamp" ? 0.002 : 0.002;
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
209
|
+
if (amountCrypto) {
|
|
210
|
+
return {
|
|
211
|
+
price: ticker.vwap * (1 - exchangeFee),
|
|
212
|
+
amountCrypto: amountCrypto,
|
|
213
|
+
amountFiat: amountCrypto * (ticker.vwap * (1 - exchangeFee)),
|
|
214
|
+
crypto,
|
|
215
|
+
fiat,
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
else {
|
|
219
|
+
return {
|
|
220
|
+
price: ticker.vwap * (1 - exchangeFee),
|
|
221
|
+
amountCrypto: amountFiat / (ticker.vwap * (1 - exchangeFee)),
|
|
222
|
+
amountFiat,
|
|
223
|
+
crypto,
|
|
224
|
+
fiat,
|
|
225
|
+
};
|
|
226
|
+
}
|
|
210
227
|
}
|
|
211
228
|
else {
|
|
212
229
|
return {
|
|
@@ -37,7 +37,7 @@ const getNetworkFees = (crypto, cryptoPrice, conversionRateToUSD) => __awaiter(v
|
|
|
37
37
|
let withdrawFeeInBaseFiat;
|
|
38
38
|
const cryptoAsset = new common_1.CryptoAsset(crypto);
|
|
39
39
|
if (cryptoAsset.getSymbol() !== cryptoAsset.getGasSymbol()) {
|
|
40
|
-
const withdrawFeeUSDResponse = yield ccxt_client_1.ccxtWrapper.getSellQuote(
|
|
40
|
+
const withdrawFeeUSDResponse = yield ccxt_client_1.ccxtWrapper.getSellQuote(new common_1.CryptoAsset(crypto).getGasSymbol(), common_1.Fiat.USD, undefined, Number(withdrawFee));
|
|
41
41
|
if (cryptoAsset.getSymbol().includes("USDC")) {
|
|
42
42
|
withdrawFeeInBaseCrypto = withdrawFeeUSDResponse.amountFiat;
|
|
43
43
|
}
|
package/build/models/user.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Country, KYCStatus, Language, USState, UserAttribute, UserType } from "@riocrypto/common";
|
|
1
|
+
import { Country, KYCStatus, Language, PlatformFeeRange, USState, UserAttribute, UserType } from "@riocrypto/common";
|
|
2
2
|
import { Mongoose, Model, Document } from "mongoose";
|
|
3
3
|
interface UserAttrs {
|
|
4
4
|
authId: string;
|
|
@@ -19,6 +19,8 @@ interface UserAttrs {
|
|
|
19
19
|
language?: Language;
|
|
20
20
|
attributes?: UserAttribute[];
|
|
21
21
|
partnerId?: string;
|
|
22
|
+
brokerId?: string;
|
|
23
|
+
platformFeeRanges?: PlatformFeeRange[];
|
|
22
24
|
}
|
|
23
25
|
interface UserModel extends Model<UserDoc> {
|
|
24
26
|
build(attrs: UserAttrs): UserDoc;
|
|
@@ -43,6 +45,8 @@ interface UserDoc extends Document {
|
|
|
43
45
|
language?: Language;
|
|
44
46
|
attributes?: UserAttribute[];
|
|
45
47
|
partnerId?: string;
|
|
48
|
+
brokerId?: string;
|
|
49
|
+
platformFeeRanges?: PlatformFeeRange[];
|
|
46
50
|
}
|
|
47
51
|
declare const buildUser: (mongoose: Mongoose) => UserModel;
|
|
48
52
|
export { buildUser, UserDoc };
|
package/build/models/user.js
CHANGED
|
@@ -76,6 +76,25 @@ const buildUser = (mongoose) => {
|
|
|
76
76
|
partnerId: {
|
|
77
77
|
type: String,
|
|
78
78
|
},
|
|
79
|
+
brokerId: {
|
|
80
|
+
type: String,
|
|
81
|
+
},
|
|
82
|
+
platformFeeRanges: [
|
|
83
|
+
{
|
|
84
|
+
min: {
|
|
85
|
+
type: Number,
|
|
86
|
+
required: true,
|
|
87
|
+
},
|
|
88
|
+
max: {
|
|
89
|
+
type: Number,
|
|
90
|
+
required: true,
|
|
91
|
+
},
|
|
92
|
+
fee: {
|
|
93
|
+
type: Number,
|
|
94
|
+
required: true,
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
],
|
|
79
98
|
}, {
|
|
80
99
|
toJSON: {
|
|
81
100
|
transform(doc, ret) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@riocrypto/common-server",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.667",
|
|
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.604",
|
|
28
28
|
"@types/express": "^4.17.13",
|
|
29
29
|
"axios": "^0.27.2",
|
|
30
30
|
"ccxt": "^3.0.30",
|