@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.
Files changed (84) hide show
  1. package/README.md +1 -0
  2. package/dist/browser/index.js +53800 -0
  3. package/dist/browser/index.js.map +7 -0
  4. package/dist/cjs/index.js +66231 -0
  5. package/dist/cjs/index.js.map +7 -0
  6. package/dist/esm/index.js +66219 -0
  7. package/dist/esm/index.js.map +7 -0
  8. package/dist/src/bridge/evm/abi/Abi.json +694 -0
  9. package/dist/src/bridge/evm/index.d.ts +17 -0
  10. package/dist/src/bridge/evm/index.js +126 -0
  11. package/dist/src/bridge/evm/index.js.map +1 -0
  12. package/dist/src/bridge/evm/types/Abi.d.ts +85 -0
  13. package/dist/src/bridge/evm/types/Abi.js +6 -0
  14. package/dist/src/bridge/evm/types/Abi.js.map +1 -0
  15. package/dist/src/bridge/evm/types/index.d.ts +1 -0
  16. package/dist/src/bridge/evm/types/index.js +3 -0
  17. package/dist/src/bridge/evm/types/index.js.map +1 -0
  18. package/dist/src/bridge/evm/types/types.d.ts +44 -0
  19. package/dist/src/bridge/evm/types/types.js +3 -0
  20. package/dist/src/bridge/evm/types/types.js.map +1 -0
  21. package/dist/src/bridge/index.d.ts +10 -0
  22. package/dist/src/bridge/index.js +46 -0
  23. package/dist/src/bridge/index.js.map +1 -0
  24. package/dist/src/bridge/models/bridge.model.d.ts +86 -0
  25. package/dist/src/bridge/models/bridge.model.js +15 -0
  26. package/dist/src/bridge/models/bridge.model.js.map +1 -0
  27. package/dist/src/bridge/models/index.d.ts +1 -0
  28. package/dist/src/bridge/models/index.js +18 -0
  29. package/dist/src/bridge/models/index.js.map +1 -0
  30. package/dist/src/bridge/utils.d.ts +8 -0
  31. package/dist/src/bridge/utils.js +99 -0
  32. package/dist/src/bridge/utils.js.map +1 -0
  33. package/dist/src/chains/index.d.ts +38 -0
  34. package/dist/src/chains/index.js +98 -0
  35. package/dist/src/chains/index.js.map +1 -0
  36. package/dist/src/chains/models.d.ts +7 -0
  37. package/dist/src/chains/models.js +3 -0
  38. package/dist/src/chains/models.js.map +1 -0
  39. package/dist/src/client/core-api/core-api-mapper.d.ts +3 -0
  40. package/dist/src/client/core-api/core-api-mapper.js +61 -0
  41. package/dist/src/client/core-api/core-api-mapper.js.map +1 -0
  42. package/dist/src/client/core-api/core-api.model.d.ts +50 -0
  43. package/dist/src/client/core-api/core-api.model.js +14 -0
  44. package/dist/src/client/core-api/core-api.model.js.map +1 -0
  45. package/dist/src/client/core-api/index.d.ts +11 -0
  46. package/dist/src/client/core-api/index.js +33 -0
  47. package/dist/src/client/core-api/index.js.map +1 -0
  48. package/dist/src/configs/development.d.ts +3 -0
  49. package/dist/src/configs/development.js +7 -0
  50. package/dist/src/configs/development.js.map +1 -0
  51. package/dist/src/configs/index.d.ts +3 -0
  52. package/dist/src/configs/index.js +20 -0
  53. package/dist/src/configs/index.js.map +1 -0
  54. package/dist/src/configs/production.d.ts +3 -0
  55. package/dist/src/configs/production.js +7 -0
  56. package/dist/src/configs/production.js.map +1 -0
  57. package/dist/src/configs/staging.d.ts +3 -0
  58. package/dist/src/configs/staging.js +7 -0
  59. package/dist/src/configs/staging.js.map +1 -0
  60. package/dist/src/exceptions/index.d.ts +1 -0
  61. package/dist/src/exceptions/index.js +18 -0
  62. package/dist/src/exceptions/index.js.map +1 -0
  63. package/dist/src/exceptions/insufficient-pool-liquidity.d.ts +3 -0
  64. package/dist/src/exceptions/insufficient-pool-liquidity.js +11 -0
  65. package/dist/src/exceptions/insufficient-pool-liquidity.js.map +1 -0
  66. package/dist/src/index.d.ts +107 -0
  67. package/dist/src/index.js +183 -0
  68. package/dist/src/index.js.map +1 -0
  69. package/dist/src/models/index.d.ts +18 -0
  70. package/dist/src/models/index.js +8 -0
  71. package/dist/src/models/index.js.map +1 -0
  72. package/dist/src/tokens-info/index.d.ts +26 -0
  73. package/dist/src/tokens-info/index.js +47 -0
  74. package/dist/src/tokens-info/index.js.map +1 -0
  75. package/dist/src/tokens-info/tokens-info.model.d.ts +53 -0
  76. package/dist/src/tokens-info/tokens-info.model.js +3 -0
  77. package/dist/src/tokens-info/tokens-info.model.js.map +1 -0
  78. package/dist/src/utils/calculation/constants.d.ts +1 -0
  79. package/dist/src/utils/calculation/constants.js +5 -0
  80. package/dist/src/utils/calculation/constants.js.map +1 -0
  81. package/dist/src/utils/calculation/index.d.ts +11 -0
  82. package/dist/src/utils/calculation/index.js +88 -0
  83. package/dist/src/utils/calculation/index.js.map +1 -0
  84. package/package.json +100 -0
@@ -0,0 +1,98 @@
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.chainProperties = exports.ChainType = exports.ChainSymbol = void 0;
18
+ __exportStar(require("./models"), exports);
19
+ var ChainSymbol;
20
+ (function (ChainSymbol) {
21
+ /**
22
+ * The Kovan testnet.
23
+ */
24
+ ChainSymbol["KVN"] = "KVN";
25
+ /**
26
+ * The Ropsten testnet.
27
+ */
28
+ ChainSymbol["RPS"] = "RPS";
29
+ /**
30
+ * The Goerli testnet.
31
+ */
32
+ ChainSymbol["GRL"] = "GRL";
33
+ /**
34
+ * The BNB Smart Chain main network.
35
+ */
36
+ ChainSymbol["BSC"] = "BSC";
37
+ /**
38
+ * The Ethereum main network.
39
+ */
40
+ ChainSymbol["ETH"] = "ETH";
41
+ /**
42
+ * The Solana network.
43
+ */
44
+ ChainSymbol["SOL"] = "SOL";
45
+ /**
46
+ * The TRON network.
47
+ */
48
+ ChainSymbol["TRX"] = "TRX";
49
+ })(ChainSymbol = exports.ChainSymbol || (exports.ChainSymbol = {}));
50
+ var ChainType;
51
+ (function (ChainType) {
52
+ ChainType["EVM"] = "EVM";
53
+ ChainType["SOLANA"] = "SOLANA";
54
+ ChainType["TRX"] = "TRX";
55
+ })(ChainType = exports.ChainType || (exports.ChainType = {}));
56
+ exports.chainProperties = {
57
+ [ChainSymbol.KVN]: {
58
+ chainSymbol: ChainSymbol.KVN,
59
+ chainId: "0x2a",
60
+ name: "Kovan",
61
+ chainType: ChainType.EVM,
62
+ },
63
+ [ChainSymbol.RPS]: {
64
+ chainSymbol: ChainSymbol.RPS,
65
+ chainId: "0x3",
66
+ name: "Ropsten",
67
+ chainType: ChainType.EVM,
68
+ },
69
+ [ChainSymbol.GRL]: {
70
+ chainSymbol: ChainSymbol.GRL,
71
+ chainId: "0x5",
72
+ name: "Goerli",
73
+ chainType: ChainType.EVM,
74
+ },
75
+ [ChainSymbol.BSC]: {
76
+ chainSymbol: ChainSymbol.BSC,
77
+ chainId: "0x38",
78
+ name: "BNB Chain",
79
+ chainType: ChainType.EVM,
80
+ },
81
+ [ChainSymbol.ETH]: {
82
+ chainSymbol: ChainSymbol.ETH,
83
+ chainId: "0x1",
84
+ name: "Ethereum",
85
+ chainType: ChainType.EVM,
86
+ },
87
+ [ChainSymbol.SOL]: {
88
+ chainSymbol: ChainSymbol.SOL,
89
+ name: "Solana",
90
+ chainType: ChainType.SOLANA,
91
+ },
92
+ [ChainSymbol.TRX]: {
93
+ chainSymbol: ChainSymbol.TRX,
94
+ name: "Tron",
95
+ chainType: ChainType.TRX,
96
+ },
97
+ };
98
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/chains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CAAC,GAAG,CAAC,EAAE;QACjB,WAAW,EAAE,WAAW,CAAC,GAAG;QAC5B,OAAO,EAAE,KAAK;QACd,IAAI,EAAE,UAAU;QAChB,SAAS,EAAE,SAAS,CAAC,GAAG;KACzB;IACD,CAAC,WAAW,CAAC,GAAG,CAAC,EAAE;QACjB,WAAW,EAAE,WAAW,CAAC,GAAG;QAC5B,IAAI,EAAE,QAAQ;QACd,SAAS,EAAE,SAAS,CAAC,MAAM;KAC5B;IACD,CAAC,WAAW,CAAC,GAAG,CAAC,EAAE;QACjB,WAAW,EAAE,WAAW,CAAC,GAAG;QAC5B,IAAI,EAAE,MAAM;QACZ,SAAS,EAAE,SAAS,CAAC,GAAG;KACzB;CACF,CAAC"}
@@ -0,0 +1,7 @@
1
+ import { ChainSymbol, ChainType } from "./index";
2
+ export interface BasicChainProperties {
3
+ chainSymbol: ChainSymbol;
4
+ chainId?: string;
5
+ name: string;
6
+ chainType: ChainType;
7
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=models.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"models.js","sourceRoot":"","sources":["../../../src/chains/models.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ import { ChainDetailsMap } from "../../tokens-info";
2
+ import { ChainDetailsMapDTO } from "./core-api.model";
3
+ export declare function mapChainDetailsMapFromDTO(dto: ChainDetailsMapDTO): ChainDetailsMap;
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.mapChainDetailsMapFromDTO = void 0;
4
+ const chains_1 = require("../../chains");
5
+ const core_api_model_1 = require("./core-api.model");
6
+ function mapChainDetailsMapFromDTO(dto) {
7
+ return Object.entries(dto).reduce((map, entry) => {
8
+ const chainDetails = mapChainDetailsFromDto(...entry);
9
+ if (chainDetails) {
10
+ map[entry[0]] = chainDetails;
11
+ }
12
+ return map;
13
+ }, {});
14
+ }
15
+ exports.mapChainDetailsMapFromDTO = mapChainDetailsMapFromDTO;
16
+ function mapTokenInfoWithChainDetailsFromDto(chainDetails, dto) {
17
+ const { name: chainName, ...chainDetailsWithoutName } = chainDetails;
18
+ return {
19
+ ...dto,
20
+ ...chainDetailsWithoutName,
21
+ chainName,
22
+ };
23
+ }
24
+ function mapMessengerKeyDtoToMessenger(dto) {
25
+ switch (dto) {
26
+ case core_api_model_1.MessengerKeyDTO.ALLBRIDGE:
27
+ return core_api_model_1.Messenger.ALLBRIDGE;
28
+ case core_api_model_1.MessengerKeyDTO.WORMHOLE:
29
+ return core_api_model_1.Messenger.WORMHOLE;
30
+ default:
31
+ return null;
32
+ }
33
+ }
34
+ function mapTxTimeFromDto(dto) {
35
+ return Object.entries(dto).reduce((result, [key, value]) => {
36
+ const messenger = mapMessengerKeyDtoToMessenger(key);
37
+ if (messenger) {
38
+ result[messenger] = value;
39
+ }
40
+ return result;
41
+ }, {});
42
+ }
43
+ function mapChainDetailsFromDto(chainSymbol, dto) {
44
+ const basicChainProperties = chains_1.chainProperties[chainSymbol];
45
+ /* eslint-disable-next-line @typescript-eslint/no-unnecessary-condition */
46
+ if (!basicChainProperties) {
47
+ return null;
48
+ }
49
+ const chainDetails = {
50
+ ...basicChainProperties,
51
+ allbridgeChainId: dto.chainId,
52
+ bridgeAddress: dto.bridgeAddress,
53
+ txTime: mapTxTimeFromDto(dto.txTime),
54
+ confirmations: dto.confirmations,
55
+ };
56
+ return {
57
+ ...chainDetails,
58
+ tokens: dto.tokens.map((tokenDto) => mapTokenInfoWithChainDetailsFromDto(chainDetails, tokenDto)),
59
+ };
60
+ }
61
+ //# sourceMappingURL=core-api-mapper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"core-api-mapper.js","sourceRoot":"","sources":["../../../../src/client/core-api/core-api-mapper.ts"],"names":[],"mappings":";;;AAAA,yCAA+C;AAQ/C,qDAO0B;AAE1B,SAAgB,yBAAyB,CACvC,GAAuB;I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B,GAAG,wBAAe,CAAC,WAAW,CAAC,CAAC;IAC1D,0EAA0E;IAC1E,IAAI,CAAC,oBAAoB,EAAE;QACzB,OAAO,IAAI,CAAC;KACb;IACD,MAAM,YAAY,GAAiB;QACjC,GAAG,oBAAoB;QACvB,gBAAgB,EAAE,GAAG,CAAC,OAAO;QAC7B,aAAa,EAAE,GAAG,CAAC,aAAa;QAChC,MAAM,EAAE,gBAAgB,CAAC,GAAG,CAAC,MAAM,CAAC;QACpC,aAAa,EAAE,GAAG,CAAC,aAAa;KACjC,CAAC;IACF,OAAO;QACL,GAAG,YAAY;QACf,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAClC,mCAAmC,CAAC,YAAY,EAAE,QAAQ,CAAC,CAC5D;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,50 @@
1
+ export declare type ChainDetailsMapDTO = Record<string, ChainDetailsDTO>;
2
+ export interface ChainDetailsDTO {
3
+ tokens: TokenDTO[];
4
+ chainId: number;
5
+ bridgeAddress: string;
6
+ txTime: TxTimeDTO;
7
+ confirmations: number;
8
+ }
9
+ export interface TokenDTO {
10
+ symbol: string;
11
+ name: string;
12
+ decimals: number;
13
+ poolAddress: string;
14
+ tokenAddress: string;
15
+ poolInfo: PoolInfoDTO;
16
+ feeShare: string;
17
+ apr: number;
18
+ lpRate: number;
19
+ }
20
+ export interface PoolInfoDTO {
21
+ aValue: string;
22
+ dValue: string;
23
+ tokenBalance: string;
24
+ vUsdBalance: string;
25
+ totalLpAmount: string;
26
+ accRewardPerShareP: string;
27
+ }
28
+ export declare enum MessengerKeyDTO {
29
+ ALLBRIDGE = "allbridge",
30
+ WORMHOLE = "wormhole"
31
+ }
32
+ export declare type TxTimeDTO = {
33
+ [messenger in MessengerKeyDTO]: MessengerDTO;
34
+ };
35
+ export interface MessengerDTO {
36
+ in: number;
37
+ out: number;
38
+ }
39
+ export declare enum Messenger {
40
+ ALLBRIDGE = 1,
41
+ WORMHOLE = 2
42
+ }
43
+ export interface ReceiveTransactionCostRequest {
44
+ sourceChainId: number;
45
+ destinationChainId: number;
46
+ messenger: Messenger;
47
+ }
48
+ export interface ReceiveTransactionCostResponse {
49
+ fee: string;
50
+ }
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Messenger = exports.MessengerKeyDTO = void 0;
4
+ var MessengerKeyDTO;
5
+ (function (MessengerKeyDTO) {
6
+ MessengerKeyDTO["ALLBRIDGE"] = "allbridge";
7
+ MessengerKeyDTO["WORMHOLE"] = "wormhole";
8
+ })(MessengerKeyDTO = exports.MessengerKeyDTO || (exports.MessengerKeyDTO = {}));
9
+ var Messenger;
10
+ (function (Messenger) {
11
+ Messenger[Messenger["ALLBRIDGE"] = 1] = "ALLBRIDGE";
12
+ Messenger[Messenger["WORMHOLE"] = 2] = "WORMHOLE";
13
+ })(Messenger = exports.Messenger || (exports.Messenger = {}));
14
+ //# sourceMappingURL=core-api.model.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"core-api.model.js","sourceRoot":"","sources":["../../../../src/client/core-api/core-api.model.ts"],"names":[],"mappings":";;;AA+BA,IAAY,eAGX;AAHD,WAAY,eAAe;IACzB,0CAAuB,CAAA;IACvB,wCAAqB,CAAA;AACvB,CAAC,EAHW,eAAe,GAAf,uBAAe,KAAf,uBAAe,QAG1B;AAWD,IAAY,SAGX;AAHD,WAAY,SAAS;IACnB,mDAAa,CAAA;IACb,iDAAY,CAAA;AACd,CAAC,EAHW,SAAS,GAAT,iBAAS,KAAT,iBAAS,QAGpB"}
@@ -0,0 +1,11 @@
1
+ import { TokensInfo } from "../../tokens-info";
2
+ import { ReceiveTransactionCostRequest } from "./core-api.model";
3
+ export interface AllbridgeCoreClientParams {
4
+ apiUrl: string;
5
+ }
6
+ export declare class AllbridgeCoreClient {
7
+ private api;
8
+ constructor(params: AllbridgeCoreClientParams);
9
+ getTokensInfo(): Promise<TokensInfo>;
10
+ getReceiveTransactionCost(args: ReceiveTransactionCostRequest): Promise<string>;
11
+ }
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.AllbridgeCoreClient = void 0;
7
+ const axios_1 = __importDefault(require("axios"));
8
+ const tokens_info_1 = require("../../tokens-info");
9
+ const core_api_mapper_1 = require("./core-api-mapper");
10
+ class AllbridgeCoreClient {
11
+ constructor(params) {
12
+ this.api = axios_1.default.create({
13
+ baseURL: params.apiUrl,
14
+ headers: {
15
+ Accept: "application/json",
16
+ },
17
+ });
18
+ }
19
+ async getTokensInfo() {
20
+ const { data } = await this.api.get("/token-info");
21
+ return new tokens_info_1.TokensInfo((0, core_api_mapper_1.mapChainDetailsMapFromDTO)(data));
22
+ }
23
+ async getReceiveTransactionCost(args) {
24
+ const { data } = await this.api.post("/receive-fee", args, {
25
+ headers: {
26
+ "Content-Type": "application/json",
27
+ },
28
+ });
29
+ return data.fee;
30
+ }
31
+ }
32
+ exports.AllbridgeCoreClient = AllbridgeCoreClient;
33
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/client/core-api/index.ts"],"names":[],"mappings":";;;;;;AAAA,kDAAqC;AACrC,mDAA+C;AAC/C,uDAA8D;AAW9D,MAAa,mBAAmB;IAG9B,YAAY,MAAiC;QAC3C,IAAI,CAAC,GAAG,GAAG,eAAK,CAAC,MAAM,CAAC;YACtB,OAAO,EAAE,MAAM,CAAC,MAAM;YACtB,OAAO,EAAE;gBACP,MAAM,EAAE,kBAAkB;aAC3B;SACF,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,aAAa;QACjB,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,GAAG,CAAqB,aAAa,CAAC,CAAC;QACvE,OAAO,IAAI,wBAAU,CAAC,IAAA,2CAAyB,EAAC,IAAI,CAAC,CAAC,CAAC;IACzD,CAAC;IAED,KAAK,CAAC,yBAAyB,CAC7B,IAAmC;QAEnC,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,IAAI,CAClC,cAAc,EACd,IAAI,EACJ;YACE,OAAO,EAAE;gBACP,cAAc,EAAE,kBAAkB;aACnC;SACF,CACF,CAAC;QACF,OAAO,IAAI,CAAC,GAAG,CAAC;IAClB,CAAC;CACF;AA/BD,kDA+BC"}
@@ -0,0 +1,3 @@
1
+ export declare const development: {
2
+ apiUrl: string;
3
+ };
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.development = void 0;
4
+ exports.development = {
5
+ apiUrl: "https://core-dev.a11bd.net",
6
+ };
7
+ //# sourceMappingURL=development.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"development.js","sourceRoot":"","sources":["../../../src/configs/development.ts"],"names":[],"mappings":";;;AAAa,QAAA,WAAW,GAAG;IACzB,MAAM,EAAE,4BAA4B;CACrC,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from "./development";
2
+ export * from "./staging";
3
+ export * from "./production";
@@ -0,0 +1,20 @@
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
+ __exportStar(require("./development"), exports);
18
+ __exportStar(require("./staging"), exports);
19
+ __exportStar(require("./production"), exports);
20
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/configs/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gDAA8B;AAC9B,4CAA0B;AAC1B,+CAA6B"}
@@ -0,0 +1,3 @@
1
+ export declare const production: {
2
+ apiUrl: string;
3
+ };
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.production = void 0;
4
+ exports.production = {
5
+ apiUrl: "https://core.api.allbridgecoreapi.net",
6
+ };
7
+ //# sourceMappingURL=production.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"production.js","sourceRoot":"","sources":["../../../src/configs/production.ts"],"names":[],"mappings":";;;AAAa,QAAA,UAAU,GAAG;IACxB,MAAM,EAAE,uCAAuC;CAChD,CAAC"}
@@ -0,0 +1,3 @@
1
+ export declare const staging: {
2
+ apiUrl: string;
3
+ };
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.staging = void 0;
4
+ exports.staging = {
5
+ apiUrl: "https://core.api.allbridgecoreapi.net",
6
+ };
7
+ //# sourceMappingURL=staging.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"staging.js","sourceRoot":"","sources":["../../../src/configs/staging.ts"],"names":[],"mappings":";;;AAAa,QAAA,OAAO,GAAG;IACrB,MAAM,EAAE,uCAAuC;CAChD,CAAC"}
@@ -0,0 +1 @@
1
+ export * from "./insufficient-pool-liquidity";
@@ -0,0 +1,18 @@
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
+ __exportStar(require("./insufficient-pool-liquidity"), exports);
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/exceptions/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gEAA8C"}
@@ -0,0 +1,3 @@
1
+ export declare class InsufficientPoolLiquidity extends Error {
2
+ constructor();
3
+ }
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.InsufficientPoolLiquidity = void 0;
4
+ class InsufficientPoolLiquidity extends Error {
5
+ constructor() {
6
+ super("Insufficient pool liquidity");
7
+ this.name = "InsufficientPoolLiquidity";
8
+ }
9
+ }
10
+ exports.InsufficientPoolLiquidity = InsufficientPoolLiquidity;
11
+ //# sourceMappingURL=insufficient-pool-liquidity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"insufficient-pool-liquidity.js","sourceRoot":"","sources":["../../../src/exceptions/insufficient-pool-liquidity.ts"],"names":[],"mappings":";;;AAAA,MAAa,yBAA0B,SAAQ,KAAK;IAClD;QACE,KAAK,CAAC,6BAA6B,CAAC,CAAC;QACrC,IAAI,CAAC,IAAI,GAAG,2BAA2B,CAAC;IAC1C,CAAC;CACF;AALD,8DAKC"}
@@ -0,0 +1,107 @@
1
+ import { Big } from "big.js";
2
+ import Web3 from "web3";
3
+ import { ApproveData, SendParamsWithChainSymbols, SendParamsWithTokenInfos, TransactionResponse } from "./bridge/models";
4
+ import { AmountsAndTxCost, Messenger } from "./models";
5
+ import { TokenInfo, TokenInfoWithChainDetails, TokensInfo } from "./tokens-info";
6
+ export * from "./configs/production";
7
+ export * from "./configs/development";
8
+ export * from "./models";
9
+ export { TokenInfo, TokensInfo, ChainDetailsMap, ChainDetailsWithTokens, } from "./tokens-info";
10
+ export interface AllbridgeCoreSdkOptions {
11
+ apiUrl: string;
12
+ }
13
+ export declare class AllbridgeCoreSdk {
14
+ /**
15
+ * @internal
16
+ */
17
+ private readonly api;
18
+ /**
19
+ * @internal
20
+ */
21
+ private bridgeService;
22
+ /**
23
+ * Initializes the SDK object.
24
+ * @param params Preset parameters can be used. See {@link production | production preset}
25
+ */
26
+ constructor(params: AllbridgeCoreSdkOptions);
27
+ /**
28
+ * Fetches information about the supported tokens from the Allbridge Core API.
29
+ */
30
+ getTokensInfo(): Promise<TokensInfo>;
31
+ /**
32
+ * Approve tokens usage by another address on evm chains
33
+ * @param web3 - Web3 Provider
34
+ * @param approveData
35
+ */
36
+ evmApprove(web3: Web3, approveData: ApproveData): Promise<TransactionResponse>;
37
+ /**
38
+ * Send tokens through the Bridge
39
+ * @param web3 - Web3 Provider
40
+ * @param params
41
+ */
42
+ send(web3: Web3, params: SendParamsWithChainSymbols | SendParamsWithTokenInfos): Promise<TransactionResponse>;
43
+ /**
44
+ * Calculates the percentage of fee from the initial amount that is charged when swapping from the selected source chain.
45
+ * @param amountFloat initial amount of tokens to swap
46
+ * @param sourceChainToken selected token on the source chain
47
+ * @returns fee percent
48
+ */
49
+ calculateFeePercentOnSourceChain(amountFloat: number | string | Big, sourceChainToken: TokenInfo): number;
50
+ /**
51
+ * 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.
52
+ * @see {@link calculateFeePercentOnSourceChain}
53
+ * @param amountFloat initial amount of tokens to swap
54
+ * @param sourceChainToken selected token on the source chain
55
+ * @param destinationChainToken selected token on the destination chain
56
+ * @returns fee percent
57
+ */
58
+ calculateFeePercentOnDestinationChain(amountFloat: number | string | Big, sourceChainToken: TokenInfo, destinationChainToken: TokenInfo): number;
59
+ /**
60
+ * Calculates the amount of tokens the receiving party will get as a result of the swap
61
+ * and fetches the amount of units in source chain currency to pay for the swap.
62
+ * @param amountToSendFloat the amount of tokens that will be sent
63
+ * @param sourceChainToken selected token on the source chain
64
+ * @param destinationChainToken selected token on the destination chain
65
+ * @param messenger
66
+ */
67
+ getAmountToBeReceivedAndTxCost(amountToSendFloat: number | string | Big, sourceChainToken: TokenInfoWithChainDetails, destinationChainToken: TokenInfoWithChainDetails, messenger: Messenger): Promise<AmountsAndTxCost>;
68
+ /**
69
+ * 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
70
+ * and fetches the amount of units in source chain currency to pay for the swap.
71
+ * @param amountToBeReceivedFloat the amount of tokens that should be received
72
+ * @param sourceChainToken selected token on the source chain
73
+ * @param destinationChainToken selected token on the destination chain
74
+ * @param messenger
75
+ */
76
+ getAmountToSendAndTxCost(amountToBeReceivedFloat: number | string | Big, sourceChainToken: TokenInfoWithChainDetails, destinationChainToken: TokenInfoWithChainDetails, messenger: Messenger): Promise<AmountsAndTxCost>;
77
+ /**
78
+ * Calculates the amount of tokens the receiving party will get as a result of the swap.
79
+ * @param amountToSendFloat the amount of tokens that will be sent
80
+ * @param sourceChainToken selected token on the source chain
81
+ * @param destinationChainToken selected token on the destination chain
82
+ */
83
+ getAmountToBeReceived(amountToSendFloat: number | string | Big, sourceChainToken: TokenInfo, destinationChainToken: TokenInfo): string;
84
+ /**
85
+ * 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.
86
+ * @param amountToBeReceivedFloat the amount of tokens that should be received
87
+ * @param sourceChainToken selected token on the source chain
88
+ * @param destinationChainToken selected token on the destination chain
89
+ */
90
+ getAmountToSend(amountToBeReceivedFloat: number | string | Big, sourceChainToken: TokenInfo, destinationChainToken: TokenInfo): string;
91
+ /**
92
+ * Fetches the amount of units in source chain currency to pay for the swap.
93
+ * @param sourceChainToken selected token on the source chain
94
+ * @param destinationChainToken selected token on the destination chain
95
+ * @param messenger
96
+ * @returns The amount of gas fee to pay for transfer in the smallest denomination of the source chain currency.
97
+ */
98
+ getTxCost(sourceChainToken: TokenInfoWithChainDetails, destinationChainToken: TokenInfoWithChainDetails, messenger: Messenger): Promise<string>;
99
+ /**
100
+ * Gets the average time in ms to complete a transfer for given tokens and messenger.
101
+ * @param sourceChainToken selected token on the source chain.
102
+ * @param destinationChainToken selected token on the destination chain.
103
+ * @param messenger
104
+ * @returns Average transfer time in milliseconds or null if given combination of tokens and messenger is not supported.
105
+ */
106
+ getAverageTransferTime(sourceChainToken: TokenInfoWithChainDetails, destinationChainToken: TokenInfoWithChainDetails, messenger: Messenger): number | null;
107
+ }