@allbridge/bridge-core-sdk 0.3.0
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/README.md +1 -0
- package/dist/browser/index.js +53800 -0
- package/dist/browser/index.js.map +7 -0
- package/dist/cjs/index.js +66231 -0
- package/dist/cjs/index.js.map +7 -0
- package/dist/esm/index.js +66219 -0
- package/dist/esm/index.js.map +7 -0
- package/dist/src/bridge/evm/abi/Abi.json +694 -0
- package/dist/src/bridge/evm/index.d.ts +17 -0
- package/dist/src/bridge/evm/index.js +126 -0
- package/dist/src/bridge/evm/index.js.map +1 -0
- package/dist/src/bridge/evm/types/Abi.d.ts +85 -0
- package/dist/src/bridge/evm/types/Abi.js +6 -0
- package/dist/src/bridge/evm/types/Abi.js.map +1 -0
- package/dist/src/bridge/evm/types/index.d.ts +1 -0
- package/dist/src/bridge/evm/types/index.js +3 -0
- package/dist/src/bridge/evm/types/index.js.map +1 -0
- package/dist/src/bridge/evm/types/types.d.ts +44 -0
- package/dist/src/bridge/evm/types/types.js +3 -0
- package/dist/src/bridge/evm/types/types.js.map +1 -0
- package/dist/src/bridge/index.d.ts +10 -0
- package/dist/src/bridge/index.js +46 -0
- package/dist/src/bridge/index.js.map +1 -0
- package/dist/src/bridge/models/bridge.model.d.ts +86 -0
- package/dist/src/bridge/models/bridge.model.js +15 -0
- package/dist/src/bridge/models/bridge.model.js.map +1 -0
- package/dist/src/bridge/models/index.d.ts +1 -0
- package/dist/src/bridge/models/index.js +18 -0
- package/dist/src/bridge/models/index.js.map +1 -0
- package/dist/src/bridge/utils.d.ts +8 -0
- package/dist/src/bridge/utils.js +99 -0
- package/dist/src/bridge/utils.js.map +1 -0
- package/dist/src/chains/index.d.ts +38 -0
- package/dist/src/chains/index.js +98 -0
- package/dist/src/chains/index.js.map +1 -0
- package/dist/src/chains/models.d.ts +7 -0
- package/dist/src/chains/models.js +3 -0
- package/dist/src/chains/models.js.map +1 -0
- package/dist/src/client/core-api/core-api-mapper.d.ts +3 -0
- package/dist/src/client/core-api/core-api-mapper.js +61 -0
- package/dist/src/client/core-api/core-api-mapper.js.map +1 -0
- package/dist/src/client/core-api/core-api.model.d.ts +50 -0
- package/dist/src/client/core-api/core-api.model.js +14 -0
- package/dist/src/client/core-api/core-api.model.js.map +1 -0
- package/dist/src/client/core-api/index.d.ts +11 -0
- package/dist/src/client/core-api/index.js +33 -0
- package/dist/src/client/core-api/index.js.map +1 -0
- package/dist/src/configs/development.d.ts +3 -0
- package/dist/src/configs/development.js +7 -0
- package/dist/src/configs/development.js.map +1 -0
- package/dist/src/configs/index.d.ts +3 -0
- package/dist/src/configs/index.js +20 -0
- package/dist/src/configs/index.js.map +1 -0
- package/dist/src/configs/production.d.ts +3 -0
- package/dist/src/configs/production.js +7 -0
- package/dist/src/configs/production.js.map +1 -0
- package/dist/src/configs/staging.d.ts +3 -0
- package/dist/src/configs/staging.js +7 -0
- package/dist/src/configs/staging.js.map +1 -0
- package/dist/src/exceptions/index.d.ts +1 -0
- package/dist/src/exceptions/index.js +18 -0
- package/dist/src/exceptions/index.js.map +1 -0
- package/dist/src/exceptions/insufficient-pool-liquidity.d.ts +3 -0
- package/dist/src/exceptions/insufficient-pool-liquidity.js +11 -0
- package/dist/src/exceptions/insufficient-pool-liquidity.js.map +1 -0
- package/dist/src/index.d.ts +107 -0
- package/dist/src/index.js +183 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/models/index.d.ts +18 -0
- package/dist/src/models/index.js +8 -0
- package/dist/src/models/index.js.map +1 -0
- package/dist/src/tokens-info/index.d.ts +26 -0
- package/dist/src/tokens-info/index.js +47 -0
- package/dist/src/tokens-info/index.js.map +1 -0
- package/dist/src/tokens-info/tokens-info.model.d.ts +53 -0
- package/dist/src/tokens-info/tokens-info.model.js +3 -0
- package/dist/src/tokens-info/tokens-info.model.js.map +1 -0
- package/dist/src/utils/calculation/constants.d.ts +1 -0
- package/dist/src/utils/calculation/constants.js +5 -0
- package/dist/src/utils/calculation/constants.js.map +1 -0
- package/dist/src/utils/calculation/index.d.ts +11 -0
- package/dist/src/utils/calculation/index.js +88 -0
- package/dist/src/utils/calculation/index.js.map +1 -0
- package/package.json +100 -0
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.AllbridgeCoreSdk = exports.TokensInfo = void 0;
|
|
18
|
+
const big_js_1 = require("big.js");
|
|
19
|
+
const bridge_1 = require("./bridge");
|
|
20
|
+
const core_api_1 = require("./client/core-api");
|
|
21
|
+
const exceptions_1 = require("./exceptions");
|
|
22
|
+
const calculation_1 = require("./utils/calculation");
|
|
23
|
+
__exportStar(require("./configs/production"), exports);
|
|
24
|
+
__exportStar(require("./configs/development"), exports);
|
|
25
|
+
__exportStar(require("./models"), exports);
|
|
26
|
+
var tokens_info_1 = require("./tokens-info");
|
|
27
|
+
Object.defineProperty(exports, "TokensInfo", { enumerable: true, get: function () { return tokens_info_1.TokensInfo; } });
|
|
28
|
+
class AllbridgeCoreSdk {
|
|
29
|
+
/**
|
|
30
|
+
* Initializes the SDK object.
|
|
31
|
+
* @param params Preset parameters can be used. See {@link production | production preset}
|
|
32
|
+
*/
|
|
33
|
+
constructor(params) {
|
|
34
|
+
this.api = new core_api_1.AllbridgeCoreClient({ apiUrl: params.apiUrl });
|
|
35
|
+
this.bridgeService = new bridge_1.BridgeService(this.api);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Fetches information about the supported tokens from the Allbridge Core API.
|
|
39
|
+
*/
|
|
40
|
+
async getTokensInfo() {
|
|
41
|
+
return this.api.getTokensInfo();
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Approve tokens usage by another address on evm chains
|
|
45
|
+
* @param web3 - Web3 Provider
|
|
46
|
+
* @param approveData
|
|
47
|
+
*/
|
|
48
|
+
async evmApprove(web3, approveData) {
|
|
49
|
+
return this.bridgeService.evmApprove(web3, approveData);
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Send tokens through the Bridge
|
|
53
|
+
* @param web3 - Web3 Provider
|
|
54
|
+
* @param params
|
|
55
|
+
*/
|
|
56
|
+
async send(web3, params) {
|
|
57
|
+
return this.bridgeService.send(web3, params);
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Calculates the percentage of fee from the initial amount that is charged when swapping from the selected source chain.
|
|
61
|
+
* @param amountFloat initial amount of tokens to swap
|
|
62
|
+
* @param sourceChainToken selected token on the source chain
|
|
63
|
+
* @returns fee percent
|
|
64
|
+
*/
|
|
65
|
+
calculateFeePercentOnSourceChain(amountFloat, sourceChainToken) {
|
|
66
|
+
const amountInt = (0, calculation_1.convertFloatAmountToInt)(amountFloat, sourceChainToken.decimals);
|
|
67
|
+
if (amountInt.eq(0)) {
|
|
68
|
+
return 0;
|
|
69
|
+
}
|
|
70
|
+
const vUsdInSystemPrecision = (0, calculation_1.swapToVUsd)(amountInt, sourceChainToken);
|
|
71
|
+
const vUsdInSourcePrecision = (0, calculation_1.fromSystemPrecision)(vUsdInSystemPrecision, sourceChainToken.decimals);
|
|
72
|
+
return (0, calculation_1.getFeePercent)(amountInt, vUsdInSourcePrecision);
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Calculates the percentage of fee that is charged when swapping to the selected destination chain. The destination chain fee percent applies to the amount after the source chain fee.
|
|
76
|
+
* @see {@link calculateFeePercentOnSourceChain}
|
|
77
|
+
* @param amountFloat initial amount of tokens to swap
|
|
78
|
+
* @param sourceChainToken selected token on the source chain
|
|
79
|
+
* @param destinationChainToken selected token on the destination chain
|
|
80
|
+
* @returns fee percent
|
|
81
|
+
*/
|
|
82
|
+
calculateFeePercentOnDestinationChain(amountFloat, sourceChainToken, destinationChainToken) {
|
|
83
|
+
const amountInt = (0, calculation_1.convertFloatAmountToInt)(amountFloat, sourceChainToken.decimals);
|
|
84
|
+
if (amountInt.eq(0)) {
|
|
85
|
+
return 0;
|
|
86
|
+
}
|
|
87
|
+
const vUsdInSystemPrecision = (0, calculation_1.swapToVUsd)(amountInt, sourceChainToken);
|
|
88
|
+
const usd = (0, calculation_1.swapFromVUsd)(vUsdInSystemPrecision, destinationChainToken);
|
|
89
|
+
const vUsdInDestinationPrecision = (0, calculation_1.fromSystemPrecision)(vUsdInSystemPrecision, destinationChainToken.decimals);
|
|
90
|
+
return (0, calculation_1.getFeePercent)(vUsdInDestinationPrecision, usd);
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Calculates the amount of tokens the receiving party will get as a result of the swap
|
|
94
|
+
* and fetches the amount of units in source chain currency to pay for the swap.
|
|
95
|
+
* @param amountToSendFloat the amount of tokens that will be sent
|
|
96
|
+
* @param sourceChainToken selected token on the source chain
|
|
97
|
+
* @param destinationChainToken selected token on the destination chain
|
|
98
|
+
* @param messenger
|
|
99
|
+
*/
|
|
100
|
+
async getAmountToBeReceivedAndTxCost(amountToSendFloat, sourceChainToken, destinationChainToken, messenger) {
|
|
101
|
+
return {
|
|
102
|
+
fromAmount: (0, big_js_1.Big)(amountToSendFloat).toFixed(),
|
|
103
|
+
toAmount: this.getAmountToBeReceived(amountToSendFloat, sourceChainToken, destinationChainToken),
|
|
104
|
+
txCost: await this.getTxCost(sourceChainToken, destinationChainToken, messenger),
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Calculates the amount of tokens to send based on the required amount of tokens the receiving party should get as a result of the swap
|
|
109
|
+
* and fetches the amount of units in source chain currency to pay for the swap.
|
|
110
|
+
* @param amountToBeReceivedFloat the amount of tokens that should be received
|
|
111
|
+
* @param sourceChainToken selected token on the source chain
|
|
112
|
+
* @param destinationChainToken selected token on the destination chain
|
|
113
|
+
* @param messenger
|
|
114
|
+
*/
|
|
115
|
+
async getAmountToSendAndTxCost(amountToBeReceivedFloat, sourceChainToken, destinationChainToken, messenger) {
|
|
116
|
+
return {
|
|
117
|
+
fromAmount: this.getAmountToSend(amountToBeReceivedFloat, sourceChainToken, destinationChainToken),
|
|
118
|
+
toAmount: (0, big_js_1.Big)(amountToBeReceivedFloat).toFixed(),
|
|
119
|
+
txCost: await this.getTxCost(sourceChainToken, destinationChainToken, messenger),
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Calculates the amount of tokens the receiving party will get as a result of the swap.
|
|
124
|
+
* @param amountToSendFloat the amount of tokens that will be sent
|
|
125
|
+
* @param sourceChainToken selected token on the source chain
|
|
126
|
+
* @param destinationChainToken selected token on the destination chain
|
|
127
|
+
*/
|
|
128
|
+
getAmountToBeReceived(amountToSendFloat, sourceChainToken, destinationChainToken) {
|
|
129
|
+
const amountToSend = (0, calculation_1.convertFloatAmountToInt)(amountToSendFloat, sourceChainToken.decimals);
|
|
130
|
+
const vUsd = (0, calculation_1.swapToVUsd)(amountToSend, sourceChainToken);
|
|
131
|
+
const resultInt = (0, calculation_1.swapFromVUsd)(vUsd, destinationChainToken);
|
|
132
|
+
if (resultInt.lte(0)) {
|
|
133
|
+
throw new exceptions_1.InsufficientPoolLiquidity();
|
|
134
|
+
}
|
|
135
|
+
return (0, calculation_1.convertIntAmountToFloat)(resultInt, sourceChainToken.decimals).toFixed();
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Calculates the amount of tokens to send based on the required amount of tokens the receiving party should get as a result of the swap.
|
|
139
|
+
* @param amountToBeReceivedFloat the amount of tokens that should be received
|
|
140
|
+
* @param sourceChainToken selected token on the source chain
|
|
141
|
+
* @param destinationChainToken selected token on the destination chain
|
|
142
|
+
*/
|
|
143
|
+
getAmountToSend(amountToBeReceivedFloat, sourceChainToken, destinationChainToken) {
|
|
144
|
+
const amountToBeReceived = (0, calculation_1.convertFloatAmountToInt)(amountToBeReceivedFloat, destinationChainToken.decimals);
|
|
145
|
+
const usd = (0, calculation_1.swapFromVUsdReverse)(amountToBeReceived, destinationChainToken);
|
|
146
|
+
const resultInt = (0, calculation_1.swapToVUsdReverse)(usd, sourceChainToken);
|
|
147
|
+
if (resultInt.lte(0)) {
|
|
148
|
+
throw new exceptions_1.InsufficientPoolLiquidity();
|
|
149
|
+
}
|
|
150
|
+
return (0, calculation_1.convertIntAmountToFloat)(resultInt, sourceChainToken.decimals).toFixed();
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Fetches the amount of units in source chain currency to pay for the swap.
|
|
154
|
+
* @param sourceChainToken selected token on the source chain
|
|
155
|
+
* @param destinationChainToken selected token on the destination chain
|
|
156
|
+
* @param messenger
|
|
157
|
+
* @returns The amount of gas fee to pay for transfer in the smallest denomination of the source chain currency.
|
|
158
|
+
*/
|
|
159
|
+
async getTxCost(sourceChainToken, destinationChainToken, messenger) {
|
|
160
|
+
return this.api.getReceiveTransactionCost({
|
|
161
|
+
sourceChainId: sourceChainToken.allbridgeChainId,
|
|
162
|
+
destinationChainId: destinationChainToken.allbridgeChainId,
|
|
163
|
+
messenger,
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Gets the average time in ms to complete a transfer for given tokens and messenger.
|
|
168
|
+
* @param sourceChainToken selected token on the source chain.
|
|
169
|
+
* @param destinationChainToken selected token on the destination chain.
|
|
170
|
+
* @param messenger
|
|
171
|
+
* @returns Average transfer time in milliseconds or null if given combination of tokens and messenger is not supported.
|
|
172
|
+
*/
|
|
173
|
+
getAverageTransferTime(sourceChainToken, destinationChainToken, messenger) {
|
|
174
|
+
const sourceTxTime = sourceChainToken.txTime[messenger]?.in;
|
|
175
|
+
const destinationTxTime = destinationChainToken.txTime[messenger]?.out;
|
|
176
|
+
if (!sourceTxTime || !destinationTxTime) {
|
|
177
|
+
return null;
|
|
178
|
+
}
|
|
179
|
+
return sourceTxTime + destinationTxTime;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
exports.AllbridgeCoreSdk = AllbridgeCoreSdk;
|
|
183
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,mCAA6B;AAE7B,qCAAyC;AAOzC,gDAAwD;AACxD,6CAAyD;AAOzD,qDAS6B;AAE7B,uDAAqC;AACrC,wDAAsC;AACtC,2CAAyB;AACzB,6CAKuB;AAHrB,yGAAA,UAAU,OAAA;AASZ,MAAa,gBAAgB;IAU3B;;;OAGG;IACH,YAAY,MAA+B;QACzC,IAAI,CAAC,GAAG,GAAG,IAAI,8BAAmB,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;QAC9D,IAAI,CAAC,aAAa,GAAG,IAAI,sBAAa,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACnD,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,aAAa;QACjB,OAAO,IAAI,CAAC,GAAG,CAAC,aAAa,EAAE,CAAC;IAClC,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,UAAU,CACd,IAAU,EACV,WAAwB;QAExB,OAAO,IAAI,CAAC,aAAa,CAAC,UAAU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C;IAC1C,CAAC;CACF;AA9PD,4CA8PC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export { ApproveData, TransactionResponse, BaseSendParams, SendParamsWithChainSymbols, SendParamsWithTokenInfos, } from "../bridge/models/bridge.model";
|
|
2
|
+
export { Messenger } from "../client/core-api/core-api.model";
|
|
3
|
+
export { ChainSymbol } from "../chains/index";
|
|
4
|
+
export { TokenInfoWithChainDetails } from "../tokens-info/tokens-info.model";
|
|
5
|
+
export interface AmountsAndTxCost {
|
|
6
|
+
/**
|
|
7
|
+
* The amount of tokens to be sent.
|
|
8
|
+
*/
|
|
9
|
+
fromAmount: string;
|
|
10
|
+
/**
|
|
11
|
+
* The amount of tokens to be received.
|
|
12
|
+
*/
|
|
13
|
+
toAmount: string;
|
|
14
|
+
/**
|
|
15
|
+
* The amount of gas fee to pay for the transfer in the smallest denomination of the source chain currency.
|
|
16
|
+
*/
|
|
17
|
+
txCost: string;
|
|
18
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ChainSymbol = exports.Messenger = void 0;
|
|
4
|
+
var core_api_model_1 = require("../client/core-api/core-api.model");
|
|
5
|
+
Object.defineProperty(exports, "Messenger", { enumerable: true, get: function () { return core_api_model_1.Messenger; } });
|
|
6
|
+
var index_1 = require("../chains/index");
|
|
7
|
+
Object.defineProperty(exports, "ChainSymbol", { enumerable: true, get: function () { return index_1.ChainSymbol; } });
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/models/index.ts"],"names":[],"mappings":";;;AAOA,oEAA8D;AAArD,2GAAA,SAAS,OAAA;AAClB,yCAA8C;AAArC,oGAAA,WAAW,OAAA"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ChainSymbol } from "../chains";
|
|
2
|
+
import { ChainDetailsMap, TokenInfoWithChainDetails } from "./tokens-info.model";
|
|
3
|
+
export * from "./tokens-info.model";
|
|
4
|
+
export declare class TokensInfo {
|
|
5
|
+
/**
|
|
6
|
+
* @internal
|
|
7
|
+
*/
|
|
8
|
+
private readonly _map;
|
|
9
|
+
/**
|
|
10
|
+
* @internal
|
|
11
|
+
* @param map
|
|
12
|
+
*/
|
|
13
|
+
constructor(map: ChainDetailsMap);
|
|
14
|
+
/**
|
|
15
|
+
* Returns {@link ChainDetailsMap} containing a list of supported tokens groped by chain.
|
|
16
|
+
*/
|
|
17
|
+
chainDetailsMap(): ChainDetailsMap;
|
|
18
|
+
/**
|
|
19
|
+
* Returns a list of supported {@link TokenInfoWithChainDetails | tokens}.
|
|
20
|
+
*/
|
|
21
|
+
tokens(): TokenInfoWithChainDetails[];
|
|
22
|
+
/**
|
|
23
|
+
* Returns a list of supported {@link TokenInfoWithChainDetails | tokens} on the selected chain.
|
|
24
|
+
*/
|
|
25
|
+
tokensByChain(chainSymbol: ChainSymbol): TokenInfoWithChainDetails[];
|
|
26
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.TokensInfo = void 0;
|
|
18
|
+
__exportStar(require("./tokens-info.model"), exports);
|
|
19
|
+
class TokensInfo {
|
|
20
|
+
/**
|
|
21
|
+
* @internal
|
|
22
|
+
* @param map
|
|
23
|
+
*/
|
|
24
|
+
constructor(map) {
|
|
25
|
+
this._map = map;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Returns {@link ChainDetailsMap} containing a list of supported tokens groped by chain.
|
|
29
|
+
*/
|
|
30
|
+
chainDetailsMap() {
|
|
31
|
+
return this._map;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Returns a list of supported {@link TokenInfoWithChainDetails | tokens}.
|
|
35
|
+
*/
|
|
36
|
+
tokens() {
|
|
37
|
+
return Object.values(this._map).flatMap((chainDetails) => chainDetails.tokens);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Returns a list of supported {@link TokenInfoWithChainDetails | tokens} on the selected chain.
|
|
41
|
+
*/
|
|
42
|
+
tokensByChain(chainSymbol) {
|
|
43
|
+
return this._map[chainSymbol].tokens;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
exports.TokensInfo = TokensInfo;
|
|
47
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/tokens-info/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAMA,sDAAoC;AAEpC,MAAa,UAAU;IAMrB;;;OAGG;IACH,YAAY,GAAoB;QAC9B,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC;IAClB,CAAC;IAED;;OAEG;IACH,eAAe;QACb,OAAO,IAAI,CAAC,IAAI,CAAC;IACnB,CAAC;IAED;;OAEG;IACH,MAAM;QACJ,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,OAAO,CACrC,CAAC,YAAY,EAAE,EAAE,CAAC,YAAY,CAAC,MAAM,CACtC,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,aAAa,CAAC,WAAwB;QACpC,OAAO,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,MAAM,CAAC;IACvC,CAAC;CACF;AApCD,gCAoCC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { BasicChainProperties } from "../chains";
|
|
2
|
+
import { Messenger } from "../client/core-api/core-api.model";
|
|
3
|
+
/**
|
|
4
|
+
* Contains mapping of {@link ChainSymbol} and chain details.
|
|
5
|
+
*/
|
|
6
|
+
export declare type ChainDetailsMap = Record<string, ChainDetailsWithTokens>;
|
|
7
|
+
export interface ChainDetails extends BasicChainProperties {
|
|
8
|
+
allbridgeChainId: number;
|
|
9
|
+
bridgeAddress: string;
|
|
10
|
+
txTime: TxTime;
|
|
11
|
+
confirmations: number;
|
|
12
|
+
}
|
|
13
|
+
export interface ChainDetailsWithTokens extends ChainDetails {
|
|
14
|
+
tokens: TokenInfoWithChainDetails[];
|
|
15
|
+
}
|
|
16
|
+
export interface TokenInfo {
|
|
17
|
+
symbol: string;
|
|
18
|
+
name: string;
|
|
19
|
+
decimals: number;
|
|
20
|
+
poolAddress: string;
|
|
21
|
+
tokenAddress: string;
|
|
22
|
+
poolInfo: PoolInfo;
|
|
23
|
+
feeShare: string;
|
|
24
|
+
apr: number;
|
|
25
|
+
lpRate: number;
|
|
26
|
+
}
|
|
27
|
+
export interface TokenInfoWithChainDetails extends TokenInfo {
|
|
28
|
+
chainSymbol: string;
|
|
29
|
+
chainId?: string;
|
|
30
|
+
chainName: string;
|
|
31
|
+
allbridgeChainId: number;
|
|
32
|
+
bridgeAddress: string;
|
|
33
|
+
txTime: TxTime;
|
|
34
|
+
confirmations: number;
|
|
35
|
+
}
|
|
36
|
+
export interface PoolInfo {
|
|
37
|
+
aValue: string;
|
|
38
|
+
dValue: string;
|
|
39
|
+
tokenBalance: string;
|
|
40
|
+
vUsdBalance: string;
|
|
41
|
+
totalLpAmount: string;
|
|
42
|
+
accRewardPerShareP: string;
|
|
43
|
+
}
|
|
44
|
+
export interface MessengerTxTime {
|
|
45
|
+
in: number;
|
|
46
|
+
out: number;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Contains average transaction times per messenger.
|
|
50
|
+
*/
|
|
51
|
+
export declare type TxTime = {
|
|
52
|
+
[messenger in Messenger]?: MessengerTxTime;
|
|
53
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tokens-info.model.js","sourceRoot":"","sources":["../../../src/tokens-info/tokens-info.model.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const SYSTEM_PRECISION = 3;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../src/utils/calculation/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,gBAAgB,GAAG,CAAC,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Big, BigSource } from "big.js";
|
|
2
|
+
import { TokenInfo } from "../../tokens-info";
|
|
3
|
+
export declare function getFeePercent(input: BigSource, output: BigSource): number;
|
|
4
|
+
export declare function toSystemPrecision(amount: BigSource, decimals: number): Big;
|
|
5
|
+
export declare function fromSystemPrecision(amount: BigSource, decimals: number): Big;
|
|
6
|
+
export declare function swapToVUsd(amount: BigSource, tokenInfo: TokenInfo): Big;
|
|
7
|
+
export declare function swapFromVUsd(amount: BigSource, tokenInfo: TokenInfo): Big;
|
|
8
|
+
export declare function swapToVUsdReverse(amount: BigSource, tokenInfo: TokenInfo): Big;
|
|
9
|
+
export declare function swapFromVUsdReverse(amount: BigSource, tokenInfo: TokenInfo): Big;
|
|
10
|
+
export declare function convertFloatAmountToInt(amountFloat: BigSource, decimals: number): Big;
|
|
11
|
+
export declare function convertIntAmountToFloat(amountInt: BigSource, decimals: number): Big;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.convertIntAmountToFloat = exports.convertFloatAmountToInt = exports.swapFromVUsdReverse = exports.swapToVUsdReverse = exports.swapFromVUsd = exports.swapToVUsd = exports.fromSystemPrecision = exports.toSystemPrecision = exports.getFeePercent = void 0;
|
|
4
|
+
const big_js_1 = require("big.js");
|
|
5
|
+
const constants_1 = require("./constants");
|
|
6
|
+
function getFeePercent(input, output) {
|
|
7
|
+
return (0, big_js_1.Big)(100).minus((0, big_js_1.Big)(100).times(output).div(input)).toNumber();
|
|
8
|
+
}
|
|
9
|
+
exports.getFeePercent = getFeePercent;
|
|
10
|
+
function toSystemPrecision(amount, decimals) {
|
|
11
|
+
return convertAmountPrecision(amount, decimals, constants_1.SYSTEM_PRECISION);
|
|
12
|
+
}
|
|
13
|
+
exports.toSystemPrecision = toSystemPrecision;
|
|
14
|
+
function fromSystemPrecision(amount, decimals) {
|
|
15
|
+
return convertAmountPrecision(amount, constants_1.SYSTEM_PRECISION, decimals);
|
|
16
|
+
}
|
|
17
|
+
exports.fromSystemPrecision = fromSystemPrecision;
|
|
18
|
+
function swapToVUsd(amount, tokenInfo) {
|
|
19
|
+
const fee = (0, big_js_1.Big)(amount).times(tokenInfo.feeShare);
|
|
20
|
+
const amountWithoutFee = (0, big_js_1.Big)(amount).minus(fee);
|
|
21
|
+
const inSystemPrecision = toSystemPrecision(amountWithoutFee, tokenInfo.decimals);
|
|
22
|
+
const poolInfo = tokenInfo.poolInfo;
|
|
23
|
+
const tokenBalance = (0, big_js_1.Big)(poolInfo.tokenBalance).plus(inSystemPrecision);
|
|
24
|
+
const vUsdNewAmount = getY(tokenBalance, poolInfo.aValue, poolInfo.dValue);
|
|
25
|
+
return (0, big_js_1.Big)(poolInfo.vUsdBalance).minus(vUsdNewAmount).round(0, 0);
|
|
26
|
+
}
|
|
27
|
+
exports.swapToVUsd = swapToVUsd;
|
|
28
|
+
function swapFromVUsd(amount, tokenInfo) {
|
|
29
|
+
const poolInfo = tokenInfo.poolInfo;
|
|
30
|
+
const vUsdBalance = (0, big_js_1.Big)(amount).plus(poolInfo.vUsdBalance);
|
|
31
|
+
const newAmount = getY(vUsdBalance, poolInfo.aValue, poolInfo.dValue);
|
|
32
|
+
const result = fromSystemPrecision((0, big_js_1.Big)(poolInfo.tokenBalance).minus(newAmount), tokenInfo.decimals);
|
|
33
|
+
const fee = (0, big_js_1.Big)(result).times(tokenInfo.feeShare);
|
|
34
|
+
return (0, big_js_1.Big)(result).minus(fee).round(0, 0);
|
|
35
|
+
}
|
|
36
|
+
exports.swapFromVUsd = swapFromVUsd;
|
|
37
|
+
function swapToVUsdReverse(amount, tokenInfo) {
|
|
38
|
+
const poolInfo = tokenInfo.poolInfo;
|
|
39
|
+
const vUsdNewAmount = (0, big_js_1.Big)(poolInfo.vUsdBalance).minus(amount);
|
|
40
|
+
const tokenBalance = getY(vUsdNewAmount, poolInfo.aValue, poolInfo.dValue);
|
|
41
|
+
const inSystemPrecision = (0, big_js_1.Big)(tokenBalance).minus(poolInfo.tokenBalance);
|
|
42
|
+
const amountWithoutFee = fromSystemPrecision(inSystemPrecision, tokenInfo.decimals);
|
|
43
|
+
const reversedFeeShare = (0, big_js_1.Big)(tokenInfo.feeShare).div((0, big_js_1.Big)(1).minus(tokenInfo.feeShare));
|
|
44
|
+
const fee = (0, big_js_1.Big)(amountWithoutFee).times(reversedFeeShare);
|
|
45
|
+
return (0, big_js_1.Big)(amountWithoutFee).plus(fee).round(0, 0);
|
|
46
|
+
}
|
|
47
|
+
exports.swapToVUsdReverse = swapToVUsdReverse;
|
|
48
|
+
function swapFromVUsdReverse(amount, tokenInfo) {
|
|
49
|
+
const reversedFeeShare = (0, big_js_1.Big)(tokenInfo.feeShare).div((0, big_js_1.Big)(1).minus(tokenInfo.feeShare));
|
|
50
|
+
const fee = (0, big_js_1.Big)(amount).times(reversedFeeShare);
|
|
51
|
+
const amountWithFee = (0, big_js_1.Big)(amount).plus(fee);
|
|
52
|
+
const inSystemPrecision = toSystemPrecision(amountWithFee, tokenInfo.decimals);
|
|
53
|
+
const poolInfo = tokenInfo.poolInfo;
|
|
54
|
+
const tokenBalance = (0, big_js_1.Big)(poolInfo.tokenBalance).minus(inSystemPrecision);
|
|
55
|
+
const vUsdNewAmount = getY(tokenBalance, poolInfo.aValue, poolInfo.dValue);
|
|
56
|
+
return (0, big_js_1.Big)(vUsdNewAmount).minus(poolInfo.vUsdBalance).round(0, 0);
|
|
57
|
+
}
|
|
58
|
+
exports.swapFromVUsdReverse = swapFromVUsdReverse;
|
|
59
|
+
function convertAmountPrecision(amount, decimalsFrom, decimalsTo) {
|
|
60
|
+
const dif = (0, big_js_1.Big)(decimalsTo).minus(decimalsFrom).toNumber();
|
|
61
|
+
return (0, big_js_1.Big)(amount).times(toPowBase10(dif)).round(0, 0);
|
|
62
|
+
}
|
|
63
|
+
function toPowBase10(decimals) {
|
|
64
|
+
return (0, big_js_1.Big)(10).pow(decimals);
|
|
65
|
+
}
|
|
66
|
+
function convertFloatAmountToInt(amountFloat, decimals) {
|
|
67
|
+
return (0, big_js_1.Big)(amountFloat).times(toPowBase10(decimals));
|
|
68
|
+
}
|
|
69
|
+
exports.convertFloatAmountToInt = convertFloatAmountToInt;
|
|
70
|
+
function convertIntAmountToFloat(amountInt, decimals) {
|
|
71
|
+
return (0, big_js_1.Big)(amountInt).div(toPowBase10(decimals));
|
|
72
|
+
}
|
|
73
|
+
exports.convertIntAmountToFloat = convertIntAmountToFloat;
|
|
74
|
+
// y = (sqrt(x(4ad³ + x (4a(d - x) - d )²)) + x (4a(d - x) - d ))/8ax
|
|
75
|
+
// commonPart = 4a(d - x) - d
|
|
76
|
+
// sqrt = sqrt(x * (4ad³ + x * commonPart²)
|
|
77
|
+
// y = (sqrt + x * commonPart) / divider
|
|
78
|
+
function getY(x, a, d) {
|
|
79
|
+
const commonPartBig = (0, big_js_1.Big)(4).times(a).times((0, big_js_1.Big)(d).minus(x)).minus(d);
|
|
80
|
+
const dCubed = (0, big_js_1.Big)(d).pow(3);
|
|
81
|
+
const commonPartSquared = commonPartBig.pow(2);
|
|
82
|
+
const sqrtBig = (0, big_js_1.Big)(x)
|
|
83
|
+
.times((0, big_js_1.Big)(x).times(commonPartSquared).plus((0, big_js_1.Big)(4).times(a).times(dCubed)))
|
|
84
|
+
.sqrt();
|
|
85
|
+
const dividerBig = (0, big_js_1.Big)(8).times(a).times(x);
|
|
86
|
+
return commonPartBig.times(x).plus(sqrtBig).div(dividerBig);
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/utils/calculation/index.ts"],"names":[],"mappings":";;;AAAA,mCAAwC;AAExC,2CAA+C;AAE/C,SAAgB,aAAa,CAAC,KAAgB,EAAE,MAAiB;IAC/D,OAAO,IAAA,YAAG,EAAC,GAAG,CAAC,CAAC,KAAK,CAAC,IAAA,YAAG,EAAC,GAAG,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC;AACtE,CAAC;AAFD,sCAEC;AAED,SAAgB,iBAAiB,CAAC,MAAiB,EAAE,QAAgB;IACnE,OAAO,sBAAsB,CAAC,MAAM,EAAE,QAAQ,EAAE,4BAAgB,CAAC,CAAC;AACpE,CAAC;AAFD,8CAEC;AAED,SAAgB,mBAAmB,CAAC,MAAiB,EAAE,QAAgB;IACrE,OAAO,sBAAsB,CAAC,MAAM,EAAE,4BAAgB,EAAE,QAAQ,CAAC,CAAC;AACpE,CAAC;AAFD,kDAEC;AAED,SAAgB,UAAU,CAAC,MAAiB,EAAE,SAAoB;IAChE,MAAM,GAAG,GAAG,IAAA,YAAG,EAAC,MAAM,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC,QAAQ,CAA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CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@allbridge/bridge-core-sdk",
|
|
3
|
+
"version": "0.3.0",
|
|
4
|
+
"main": "./dist/cjs/index.js",
|
|
5
|
+
"module": "./dist/esm/index.js",
|
|
6
|
+
"types": "./dist/src/index.d.ts",
|
|
7
|
+
"browser": "./dist/browser/index.js",
|
|
8
|
+
"license": "MIT",
|
|
9
|
+
"files": [
|
|
10
|
+
"/dist"
|
|
11
|
+
],
|
|
12
|
+
"engines": {
|
|
13
|
+
"node": "^18.7.0 || >= 16",
|
|
14
|
+
"npm": "^8.16.0 || >= 8"
|
|
15
|
+
},
|
|
16
|
+
"volta": {
|
|
17
|
+
"node": "18.7.0",
|
|
18
|
+
"npm": "8.16.0"
|
|
19
|
+
},
|
|
20
|
+
"publishConfig": {
|
|
21
|
+
"access": "public"
|
|
22
|
+
},
|
|
23
|
+
"scripts": {
|
|
24
|
+
"build": "npm run clean && npm run type:dts && tsc && npm run build:main",
|
|
25
|
+
"build:main": "node -r ./esbuild-hook ./scripts/build",
|
|
26
|
+
"clean": "node -r ./esbuild-hook ./scripts/clean",
|
|
27
|
+
"type:dts": "tsc --emitDeclarationOnly",
|
|
28
|
+
"type:check": "tsc --noEmit",
|
|
29
|
+
"format": "prettier \"src/**/*.ts\" \"examples/**/*.js\" --write",
|
|
30
|
+
"format:check": "prettier \"src/**/*.ts\" \"examples/**/*.js\" --check",
|
|
31
|
+
"lint": "eslint src --ext .ts --fix",
|
|
32
|
+
"lint:check": "eslint src --ext .ts",
|
|
33
|
+
"test": "vitest run",
|
|
34
|
+
"test:watch": "vitest watch",
|
|
35
|
+
"test:coverage": "vitest run --coverage",
|
|
36
|
+
"test:setup": "node -r ./esbuild-hook ./scripts/testSetup",
|
|
37
|
+
"spell:check": "cspell \"{README.md,CODE_OF_CONDUCT.md,CONTRIBUTING.md,.github/*.md,src/**/*.ts}\"",
|
|
38
|
+
"cz": "cz",
|
|
39
|
+
"semantic-release": "semantic-release",
|
|
40
|
+
"webstorm-integration": "vitest --watch --reporter=dot --reporter=json --outputFile=.vitest-result.json",
|
|
41
|
+
"tsdoc": "typedoc --excludeInternal src/index.ts"
|
|
42
|
+
},
|
|
43
|
+
"repository": {
|
|
44
|
+
"type": "git",
|
|
45
|
+
"url": "https://github.com/allbridge-io/allbridge-core-js-sdk"
|
|
46
|
+
},
|
|
47
|
+
"keywords": [],
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"@ryansonshine/commitizen": "^4.2.8",
|
|
50
|
+
"@ryansonshine/cz-conventional-changelog": "^3.3.4",
|
|
51
|
+
"@semantic-release/changelog": "^6.0.1",
|
|
52
|
+
"@semantic-release/commit-analyzer": "^9.0.2",
|
|
53
|
+
"@semantic-release/github": "^8.0.6",
|
|
54
|
+
"@semantic-release/npm": "^9.0.1",
|
|
55
|
+
"@semantic-release/release-notes-generator": "^10.0.3",
|
|
56
|
+
"@types/bn.js": "^5.1.1",
|
|
57
|
+
"@types/node": "^18.8.2",
|
|
58
|
+
"@types/prompts": "^2.4.1",
|
|
59
|
+
"@types/randombytes": "^2.0.0",
|
|
60
|
+
"@typescript-eslint/eslint-plugin": "^5.39.0",
|
|
61
|
+
"@typescript-eslint/parser": "^5.39.0",
|
|
62
|
+
"@vitest/coverage-c8": "^0.23.4",
|
|
63
|
+
"c8": "^7.12.0",
|
|
64
|
+
"cspell": "^6.12.0",
|
|
65
|
+
"dotenv": "^16.0.3",
|
|
66
|
+
"esbuild": "^0.15.10",
|
|
67
|
+
"eslint": "^8.24.0",
|
|
68
|
+
"eslint-config-prettier": "^8.5.0",
|
|
69
|
+
"eslint-import-resolver-typescript": "^3.5.1",
|
|
70
|
+
"eslint-plugin-eslint-comments": "^3.2.0",
|
|
71
|
+
"eslint-plugin-import": "^2.26.0",
|
|
72
|
+
"nock": "^13.2.9",
|
|
73
|
+
"nyc": "^15.1.0",
|
|
74
|
+
"prettier": "^2.7.1",
|
|
75
|
+
"semantic-release": "^19.0.5",
|
|
76
|
+
"source-map-support": "^0.5.21",
|
|
77
|
+
"tronweb-typings": "^1.0.1",
|
|
78
|
+
"typechain": "^8.1.0",
|
|
79
|
+
"typedoc": "^0.23.15",
|
|
80
|
+
"typescript": "^4.8.4",
|
|
81
|
+
"vitest": "^0.23.4"
|
|
82
|
+
},
|
|
83
|
+
"overrides": {
|
|
84
|
+
"semver-regex": "3.1.4"
|
|
85
|
+
},
|
|
86
|
+
"dependencies": {
|
|
87
|
+
"@types/big.js": "^6.1.6",
|
|
88
|
+
"axios": "^1.0.0",
|
|
89
|
+
"big.js": "^6.2.1",
|
|
90
|
+
"bn.js": "^5.2.1",
|
|
91
|
+
"erc-20-abi": "^1.0.0",
|
|
92
|
+
"querystring": "^0.2.1",
|
|
93
|
+
"randombytes": "^2.1.0",
|
|
94
|
+
"tronweb": "^4.4.0",
|
|
95
|
+
"web3": "^1.8.0",
|
|
96
|
+
"web3-core": "^1.8.0",
|
|
97
|
+
"web3-eth-contract": "^1.8.0",
|
|
98
|
+
"web3-utils": "^1.8.0"
|
|
99
|
+
}
|
|
100
|
+
}
|