genius-intents 0.1.4
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/CHANGELOG.md +45 -0
- package/LICENSE +21 -0
- package/README.md +376 -0
- package/dist/src/index.d.ts +27 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +62 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/intents-protocols.d.ts +69 -0
- package/dist/src/intents-protocols.d.ts.map +1 -0
- package/dist/src/intents-protocols.js +371 -0
- package/dist/src/intents-protocols.js.map +1 -0
- package/dist/src/interfaces/intent-protocol.d.ts +21 -0
- package/dist/src/interfaces/intent-protocol.d.ts.map +1 -0
- package/dist/src/interfaces/intent-protocol.js +3 -0
- package/dist/src/interfaces/intent-protocol.js.map +1 -0
- package/dist/src/protocols/aftermath/aftermath.service.d.ts +28 -0
- package/dist/src/protocols/aftermath/aftermath.service.d.ts.map +1 -0
- package/dist/src/protocols/aftermath/aftermath.service.js +162 -0
- package/dist/src/protocols/aftermath/aftermath.service.js.map +1 -0
- package/dist/src/protocols/aftermath/aftermath.types.d.ts +100 -0
- package/dist/src/protocols/aftermath/aftermath.types.d.ts.map +1 -0
- package/dist/src/protocols/aftermath/aftermath.types.js +3 -0
- package/dist/src/protocols/aftermath/aftermath.types.js.map +1 -0
- package/dist/src/protocols/aftermath/index.d.ts +3 -0
- package/dist/src/protocols/aftermath/index.d.ts.map +1 -0
- package/dist/src/protocols/aftermath/index.js +7 -0
- package/dist/src/protocols/aftermath/index.js.map +1 -0
- package/dist/src/protocols/debridge/debridge.service.d.ts +157 -0
- package/dist/src/protocols/debridge/debridge.service.d.ts.map +1 -0
- package/dist/src/protocols/debridge/debridge.service.js +462 -0
- package/dist/src/protocols/debridge/debridge.service.js.map +1 -0
- package/dist/src/protocols/debridge/debridge.types.d.ts +82 -0
- package/dist/src/protocols/debridge/debridge.types.d.ts.map +1 -0
- package/dist/src/protocols/debridge/debridge.types.js +3 -0
- package/dist/src/protocols/debridge/debridge.types.js.map +1 -0
- package/dist/src/protocols/debridge/index.d.ts +3 -0
- package/dist/src/protocols/debridge/index.d.ts.map +1 -0
- package/dist/src/protocols/debridge/index.js +7 -0
- package/dist/src/protocols/debridge/index.js.map +1 -0
- package/dist/src/protocols/genius-bridge/genius-bridge.service.d.ts +36 -0
- package/dist/src/protocols/genius-bridge/genius-bridge.service.d.ts.map +1 -0
- package/dist/src/protocols/genius-bridge/genius-bridge.service.js +312 -0
- package/dist/src/protocols/genius-bridge/genius-bridge.service.js.map +1 -0
- package/dist/src/protocols/genius-bridge/genius-bridge.types.d.ts +100 -0
- package/dist/src/protocols/genius-bridge/genius-bridge.types.d.ts.map +1 -0
- package/dist/src/protocols/genius-bridge/genius-bridge.types.js +3 -0
- package/dist/src/protocols/genius-bridge/genius-bridge.types.js.map +1 -0
- package/dist/src/protocols/genius-bridge/index.d.ts +3 -0
- package/dist/src/protocols/genius-bridge/index.d.ts.map +1 -0
- package/dist/src/protocols/genius-bridge/index.js +7 -0
- package/dist/src/protocols/genius-bridge/index.js.map +1 -0
- package/dist/src/protocols/jupiter/index.d.ts +3 -0
- package/dist/src/protocols/jupiter/index.d.ts.map +1 -0
- package/dist/src/protocols/jupiter/index.js +7 -0
- package/dist/src/protocols/jupiter/index.js.map +1 -0
- package/dist/src/protocols/jupiter/jupiter.service.d.ts +37 -0
- package/dist/src/protocols/jupiter/jupiter.service.d.ts.map +1 -0
- package/dist/src/protocols/jupiter/jupiter.service.js +188 -0
- package/dist/src/protocols/jupiter/jupiter.service.js.map +1 -0
- package/dist/src/protocols/jupiter/jupiter.types.d.ts +272 -0
- package/dist/src/protocols/jupiter/jupiter.types.d.ts.map +1 -0
- package/dist/src/protocols/jupiter/jupiter.types.js +3 -0
- package/dist/src/protocols/jupiter/jupiter.types.js.map +1 -0
- package/dist/src/protocols/kyberswap/index.d.ts +3 -0
- package/dist/src/protocols/kyberswap/index.d.ts.map +1 -0
- package/dist/src/protocols/kyberswap/index.js +7 -0
- package/dist/src/protocols/kyberswap/index.js.map +1 -0
- package/dist/src/protocols/kyberswap/kyberswap.service.d.ts +34 -0
- package/dist/src/protocols/kyberswap/kyberswap.service.d.ts.map +1 -0
- package/dist/src/protocols/kyberswap/kyberswap.service.js +218 -0
- package/dist/src/protocols/kyberswap/kyberswap.service.js.map +1 -0
- package/dist/src/protocols/kyberswap/kyberswap.types.d.ts +114 -0
- package/dist/src/protocols/kyberswap/kyberswap.types.d.ts.map +1 -0
- package/dist/src/protocols/kyberswap/kyberswap.types.js +3 -0
- package/dist/src/protocols/kyberswap/kyberswap.types.js.map +1 -0
- package/dist/src/protocols/odos/index.d.ts +3 -0
- package/dist/src/protocols/odos/index.d.ts.map +1 -0
- package/dist/src/protocols/odos/index.js +7 -0
- package/dist/src/protocols/odos/index.js.map +1 -0
- package/dist/src/protocols/odos/odos.service.d.ts +39 -0
- package/dist/src/protocols/odos/odos.service.d.ts.map +1 -0
- package/dist/src/protocols/odos/odos.service.js +207 -0
- package/dist/src/protocols/odos/odos.service.js.map +1 -0
- package/dist/src/protocols/odos/odos.types.d.ts +114 -0
- package/dist/src/protocols/odos/odos.types.d.ts.map +1 -0
- package/dist/src/protocols/odos/odos.types.js +3 -0
- package/dist/src/protocols/odos/odos.types.js.map +1 -0
- package/dist/src/protocols/okx/index.d.ts +3 -0
- package/dist/src/protocols/okx/index.d.ts.map +1 -0
- package/dist/src/protocols/okx/index.js +7 -0
- package/dist/src/protocols/okx/index.js.map +1 -0
- package/dist/src/protocols/okx/okx.service.d.ts +36 -0
- package/dist/src/protocols/okx/okx.service.d.ts.map +1 -0
- package/dist/src/protocols/okx/okx.service.js +281 -0
- package/dist/src/protocols/okx/okx.service.js.map +1 -0
- package/dist/src/protocols/okx/okx.types.d.ts +119 -0
- package/dist/src/protocols/okx/okx.types.d.ts.map +1 -0
- package/dist/src/protocols/okx/okx.types.js +4 -0
- package/dist/src/protocols/okx/okx.types.js.map +1 -0
- package/dist/src/protocols/okx-bridge/okx-bridge.service.d.ts +1 -0
- package/dist/src/protocols/okx-bridge/okx-bridge.service.d.ts.map +1 -0
- package/dist/src/protocols/okx-bridge/okx-bridge.service.js +2 -0
- package/dist/src/protocols/okx-bridge/okx-bridge.service.js.map +1 -0
- package/dist/src/protocols/okx-bridge/okx-bridge.types.d.ts +1 -0
- package/dist/src/protocols/okx-bridge/okx-bridge.types.d.ts.map +1 -0
- package/dist/src/protocols/okx-bridge/okx-bridge.types.js +2 -0
- package/dist/src/protocols/okx-bridge/okx-bridge.types.js.map +1 -0
- package/dist/src/protocols/openocean/index.d.ts +3 -0
- package/dist/src/protocols/openocean/index.d.ts.map +1 -0
- package/dist/src/protocols/openocean/index.js +7 -0
- package/dist/src/protocols/openocean/index.js.map +1 -0
- package/dist/src/protocols/openocean/openocean.service.d.ts +29 -0
- package/dist/src/protocols/openocean/openocean.service.d.ts.map +1 -0
- package/dist/src/protocols/openocean/openocean.service.js +181 -0
- package/dist/src/protocols/openocean/openocean.service.js.map +1 -0
- package/dist/src/protocols/openocean/openocean.types.d.ts +68 -0
- package/dist/src/protocols/openocean/openocean.types.d.ts.map +1 -0
- package/dist/src/protocols/openocean/openocean.types.js +3 -0
- package/dist/src/protocols/openocean/openocean.types.js.map +1 -0
- package/dist/src/protocols/pumpfun/index.d.ts +3 -0
- package/dist/src/protocols/pumpfun/index.d.ts.map +1 -0
- package/dist/src/protocols/pumpfun/index.js +7 -0
- package/dist/src/protocols/pumpfun/index.js.map +1 -0
- package/dist/src/protocols/pumpfun/pumpfun.service.d.ts +45 -0
- package/dist/src/protocols/pumpfun/pumpfun.service.d.ts.map +1 -0
- package/dist/src/protocols/pumpfun/pumpfun.service.js +217 -0
- package/dist/src/protocols/pumpfun/pumpfun.service.js.map +1 -0
- package/dist/src/protocols/pumpfun/pumpfun.types.d.ts +14 -0
- package/dist/src/protocols/pumpfun/pumpfun.types.d.ts.map +1 -0
- package/dist/src/protocols/pumpfun/pumpfun.types.js +3 -0
- package/dist/src/protocols/pumpfun/pumpfun.types.js.map +1 -0
- package/dist/src/protocols/raydium/index.d.ts +3 -0
- package/dist/src/protocols/raydium/index.d.ts.map +1 -0
- package/dist/src/protocols/raydium/index.js +7 -0
- package/dist/src/protocols/raydium/index.js.map +1 -0
- package/dist/src/protocols/raydium/raydium-v2.service.d.ts +35 -0
- package/dist/src/protocols/raydium/raydium-v2.service.d.ts.map +1 -0
- package/dist/src/protocols/raydium/raydium-v2.service.js +301 -0
- package/dist/src/protocols/raydium/raydium-v2.service.js.map +1 -0
- package/dist/src/protocols/raydium/raydium-v2.types.d.ts +96 -0
- package/dist/src/protocols/raydium/raydium-v2.types.d.ts.map +1 -0
- package/dist/src/protocols/raydium/raydium-v2.types.js +3 -0
- package/dist/src/protocols/raydium/raydium-v2.types.js.map +1 -0
- package/dist/src/protocols/zeroX/index.d.ts +3 -0
- package/dist/src/protocols/zeroX/index.d.ts.map +1 -0
- package/dist/src/protocols/zeroX/index.js +7 -0
- package/dist/src/protocols/zeroX/index.js.map +1 -0
- package/dist/src/protocols/zeroX/zeroX.service.d.ts +37 -0
- package/dist/src/protocols/zeroX/zeroX.service.d.ts.map +1 -0
- package/dist/src/protocols/zeroX/zeroX.service.js +209 -0
- package/dist/src/protocols/zeroX/zeroX.service.js.map +1 -0
- package/dist/src/protocols/zeroX/zeroX.types.d.ts +120 -0
- package/dist/src/protocols/zeroX/zeroX.types.d.ts.map +1 -0
- package/dist/src/protocols/zeroX/zeroX.types.js +3 -0
- package/dist/src/protocols/zeroX/zeroX.types.js.map +1 -0
- package/dist/src/types/enums.d.ts +42 -0
- package/dist/src/types/enums.d.ts.map +1 -0
- package/dist/src/types/enums.js +49 -0
- package/dist/src/types/enums.js.map +1 -0
- package/dist/src/types/intents-protocols.d.ts +89 -0
- package/dist/src/types/intents-protocols.d.ts.map +1 -0
- package/dist/src/types/intents-protocols.js +3 -0
- package/dist/src/types/intents-protocols.js.map +1 -0
- package/dist/src/types/price-response.d.ts +26 -0
- package/dist/src/types/price-response.d.ts.map +1 -0
- package/dist/src/types/price-response.js +3 -0
- package/dist/src/types/price-response.js.map +1 -0
- package/dist/src/types/quote-response.d.ts +31 -0
- package/dist/src/types/quote-response.d.ts.map +1 -0
- package/dist/src/types/quote-response.js +3 -0
- package/dist/src/types/quote-response.js.map +1 -0
- package/dist/src/utils/address-validation.d.ts +9 -0
- package/dist/src/utils/address-validation.d.ts.map +1 -0
- package/dist/src/utils/address-validation.js +42 -0
- package/dist/src/utils/address-validation.js.map +1 -0
- package/dist/src/utils/address.d.ts +9 -0
- package/dist/src/utils/address.d.ts.map +1 -0
- package/dist/src/utils/address.js +74 -0
- package/dist/src/utils/address.js.map +1 -0
- package/dist/src/utils/base64-to-base58.d.ts +2 -0
- package/dist/src/utils/base64-to-base58.d.ts.map +1 -0
- package/dist/src/utils/base64-to-base58.js +22 -0
- package/dist/src/utils/base64-to-base58.js.map +1 -0
- package/dist/src/utils/chain-id-name.d.ts +3 -0
- package/dist/src/utils/chain-id-name.d.ts.map +1 -0
- package/dist/src/utils/chain-id-name.js +23 -0
- package/dist/src/utils/chain-id-name.js.map +1 -0
- package/dist/src/utils/check-vm.d.ts +8 -0
- package/dist/src/utils/check-vm.d.ts.map +1 -0
- package/dist/src/utils/check-vm.js +39 -0
- package/dist/src/utils/check-vm.js.map +1 -0
- package/dist/src/utils/constants.d.ts +7 -0
- package/dist/src/utils/constants.d.ts.map +1 -0
- package/dist/src/utils/constants.js +10 -0
- package/dist/src/utils/constants.js.map +1 -0
- package/dist/src/utils/create-error-message.d.ts +5 -0
- package/dist/src/utils/create-error-message.d.ts.map +1 -0
- package/dist/src/utils/create-error-message.js +42 -0
- package/dist/src/utils/create-error-message.js.map +1 -0
- package/dist/src/utils/fetch-spl-metadata.d.ts +4 -0
- package/dist/src/utils/fetch-spl-metadata.d.ts.map +1 -0
- package/dist/src/utils/fetch-spl-metadata.js +108 -0
- package/dist/src/utils/fetch-spl-metadata.js.map +1 -0
- package/dist/src/utils/is-native.d.ts +2 -0
- package/dist/src/utils/is-native.d.ts.map +1 -0
- package/dist/src/utils/is-native.js +23 -0
- package/dist/src/utils/is-native.js.map +1 -0
- package/dist/src/utils/logger.d.ts +56 -0
- package/dist/src/utils/logger.d.ts.map +1 -0
- package/dist/src/utils/logger.js +108 -0
- package/dist/src/utils/logger.js.map +1 -0
- package/dist/src/utils/throw-error.d.ts +3 -0
- package/dist/src/utils/throw-error.d.ts.map +1 -0
- package/dist/src/utils/throw-error.js +8 -0
- package/dist/src/utils/throw-error.js.map +1 -0
- package/dist/tests/core/intent-protocol-suite.test.d.ts +2 -0
- package/dist/tests/core/intent-protocol-suite.test.d.ts.map +1 -0
- package/dist/tests/core/intent-protocol-suite.test.js +485 -0
- package/dist/tests/core/intent-protocol-suite.test.js.map +1 -0
- package/dist/tests/core/intents-protocols.test.d.ts +2 -0
- package/dist/tests/core/intents-protocols.test.d.ts.map +1 -0
- package/dist/tests/core/intents-protocols.test.js +307 -0
- package/dist/tests/core/intents-protocols.test.js.map +1 -0
- package/dist/tests/core/protocol-test-runner.d.ts +62 -0
- package/dist/tests/core/protocol-test-runner.d.ts.map +1 -0
- package/dist/tests/core/protocol-test-runner.js +260 -0
- package/dist/tests/core/protocol-test-runner.js.map +1 -0
- package/dist/tests/core/setup.test.d.ts +1 -0
- package/dist/tests/core/setup.test.d.ts.map +1 -0
- package/dist/tests/core/setup.test.js +13 -0
- package/dist/tests/core/setup.test.js.map +1 -0
- package/dist/tests/fixtures/test-data.d.ts +84 -0
- package/dist/tests/fixtures/test-data.d.ts.map +1 -0
- package/dist/tests/fixtures/test-data.js +142 -0
- package/dist/tests/fixtures/test-data.js.map +1 -0
- package/dist/tests/integration/cross-chain.test.d.ts +2 -0
- package/dist/tests/integration/cross-chain.test.d.ts.map +1 -0
- package/dist/tests/integration/cross-chain.test.js +44 -0
- package/dist/tests/integration/cross-chain.test.js.map +1 -0
- package/dist/tests/protocols/simple-protocol.test.d.ts +2 -0
- package/dist/tests/protocols/simple-protocol.test.d.ts.map +1 -0
- package/dist/tests/protocols/simple-protocol.test.js +77 -0
- package/dist/tests/protocols/simple-protocol.test.js.map +1 -0
- package/dist/tests/setup.d.ts +24 -0
- package/dist/tests/setup.d.ts.map +1 -0
- package/dist/tests/setup.js +48 -0
- package/dist/tests/setup.js.map +1 -0
- package/dist/tests/utils/test-generator.d.ts +30 -0
- package/dist/tests/utils/test-generator.d.ts.map +1 -0
- package/dist/tests/utils/test-generator.js +153 -0
- package/dist/tests/utils/test-generator.js.map +1 -0
- package/package.json +102 -0
|
@@ -0,0 +1,462 @@
|
|
|
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.DeBridgeService = void 0;
|
|
7
|
+
const axios_1 = __importDefault(require("axios"));
|
|
8
|
+
const web3_js_1 = require("@solana/web3.js");
|
|
9
|
+
const bs58_1 = __importDefault(require("bs58"));
|
|
10
|
+
const logger_1 = require("../../utils/logger");
|
|
11
|
+
const throw_error_1 = require("../../utils/throw-error");
|
|
12
|
+
const check_vm_1 = require("../../utils/check-vm");
|
|
13
|
+
const create_error_message_1 = require("../../utils/create-error-message");
|
|
14
|
+
const address_1 = require("../../utils/address");
|
|
15
|
+
const address_validation_1 = require("../../utils/address-validation");
|
|
16
|
+
const constants_1 = require("../../utils/constants");
|
|
17
|
+
const enums_1 = require("../../types/enums");
|
|
18
|
+
let logger;
|
|
19
|
+
/**
|
|
20
|
+
* The `DeBridgeService` class implements the IIntentProtocol interface for cross-chain
|
|
21
|
+
* token swaps using the DeBridge protocol. It provides functionality for fetching price
|
|
22
|
+
* quotes and generating transaction data for token transfers across multiple supported
|
|
23
|
+
* blockchains.
|
|
24
|
+
*
|
|
25
|
+
* @implements {IIntentProtocol}
|
|
26
|
+
*/
|
|
27
|
+
class DeBridgeService {
|
|
28
|
+
/**
|
|
29
|
+
* Creates a new instance of the DeBridgeService.
|
|
30
|
+
*
|
|
31
|
+
* @param {IntentsSDKConfig & DeBridgeConfig} config - Configuration parameters for the service.
|
|
32
|
+
*
|
|
33
|
+
* @throws {SdkError} If no RPC URLs are provided for the supported blockchains.
|
|
34
|
+
*/
|
|
35
|
+
constructor(config) {
|
|
36
|
+
/**
|
|
37
|
+
* RPC URLs for each supported blockchain network.
|
|
38
|
+
*/
|
|
39
|
+
this.rpcUrls = {};
|
|
40
|
+
/**
|
|
41
|
+
* The protocol identifier for DeBridge.
|
|
42
|
+
*/
|
|
43
|
+
this.protocol = enums_1.ProtocolEnum.DEBRIDGE;
|
|
44
|
+
/**
|
|
45
|
+
* The list of blockchain networks supported by the DeBridge service.
|
|
46
|
+
*/
|
|
47
|
+
this.chains = [
|
|
48
|
+
enums_1.ChainIdEnum.ETHEREUM,
|
|
49
|
+
enums_1.ChainIdEnum.ARBITRUM,
|
|
50
|
+
enums_1.ChainIdEnum.OPTIMISM,
|
|
51
|
+
enums_1.ChainIdEnum.POLYGON,
|
|
52
|
+
enums_1.ChainIdEnum.BSC,
|
|
53
|
+
enums_1.ChainIdEnum.AVALANCHE,
|
|
54
|
+
enums_1.ChainIdEnum.BASE,
|
|
55
|
+
enums_1.ChainIdEnum.SONIC,
|
|
56
|
+
enums_1.ChainIdEnum.SOLANA,
|
|
57
|
+
// Add other supported chains as needed
|
|
58
|
+
];
|
|
59
|
+
/**
|
|
60
|
+
* Indicates that the service does not operate only on a single blockchain.
|
|
61
|
+
*/
|
|
62
|
+
this.singleChain = false;
|
|
63
|
+
/**
|
|
64
|
+
* Indicates that the service supports cross-chain operations.
|
|
65
|
+
*/
|
|
66
|
+
this.multiChain = true;
|
|
67
|
+
/**
|
|
68
|
+
* The chain ID used for Solana in the DeBridge protocol.
|
|
69
|
+
*/
|
|
70
|
+
this.solanaChainIdEnum = 7565164;
|
|
71
|
+
/**
|
|
72
|
+
* The chain ID used for Sonic in the DeBridge protocol.
|
|
73
|
+
*/
|
|
74
|
+
this.sonicChainIdEnum = 100000014;
|
|
75
|
+
/**
|
|
76
|
+
* Optional access token for the DeBridge API.
|
|
77
|
+
*/
|
|
78
|
+
this.debridgeAccessToken = null;
|
|
79
|
+
if (config?.debug) {
|
|
80
|
+
logger_1.LoggerFactory.configure(logger_1.LoggerFactory.createConsoleLogger({ level: logger_1.LogLevelEnum.DEBUG }));
|
|
81
|
+
}
|
|
82
|
+
// Use custom logger if provided
|
|
83
|
+
else if (config?.logger) {
|
|
84
|
+
logger_1.LoggerFactory.configure(config.logger);
|
|
85
|
+
}
|
|
86
|
+
logger = logger_1.LoggerFactory.getLogger();
|
|
87
|
+
// Apply configuration with defaults
|
|
88
|
+
this.baseUrl =
|
|
89
|
+
config?.deBridgePrivateUrl || 'https://dln.debridge.finance/v1.0/dln/order/create-tx';
|
|
90
|
+
this.debridgeAccessToken = config?.debridgeAccessToken || null;
|
|
91
|
+
}
|
|
92
|
+
isCorrectConfig(config) {
|
|
93
|
+
// Simple validation - can be extended based on specific requirements
|
|
94
|
+
return config && typeof config === 'object';
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Fetches a price quote for a cross-chain token swap from the DeBridge API.
|
|
98
|
+
*
|
|
99
|
+
* @param {IntentPriceParams} params - The parameters required for the price quote.
|
|
100
|
+
*
|
|
101
|
+
* @returns {Promise<PriceResponse>} A promise that resolves to a `PriceResponse` object containing:
|
|
102
|
+
* - The amount of output tokens expected from the swap.
|
|
103
|
+
* - The raw response from the DeBridge API.
|
|
104
|
+
*
|
|
105
|
+
* @throws {SdkError} If the parameters are invalid or unsupported.
|
|
106
|
+
* @throws {SdkError} If there's an error fetching the price from DeBridge.
|
|
107
|
+
*/
|
|
108
|
+
async fetchPrice(params) {
|
|
109
|
+
try {
|
|
110
|
+
this.validatePriceParams(params);
|
|
111
|
+
const validatedParams = this.transformPriceParams(params);
|
|
112
|
+
const dlnQuote = await this.fetchDLNQuote(validatedParams);
|
|
113
|
+
logger.debug('Successfully received price info from DeBridge', {
|
|
114
|
+
amountOut: dlnQuote.estimation.dstChainTokenOut.amount,
|
|
115
|
+
orderId: dlnQuote.orderId,
|
|
116
|
+
});
|
|
117
|
+
return {
|
|
118
|
+
protocol: this.protocol,
|
|
119
|
+
networkIn: params.networkIn,
|
|
120
|
+
networkOut: params.networkOut,
|
|
121
|
+
tokenIn: params.tokenIn,
|
|
122
|
+
tokenOut: params.tokenOut,
|
|
123
|
+
amountIn: params.amountIn,
|
|
124
|
+
amountOut: dlnQuote.estimation.dstChainTokenOut.amount,
|
|
125
|
+
estimatedGas: '0', // DeBridge doesn't provide gas estimates directly
|
|
126
|
+
slippage: params.slippage,
|
|
127
|
+
priceImpact: undefined, // DeBridge doesn't provide price impact
|
|
128
|
+
protocolResponse: dlnQuote,
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
catch (error) {
|
|
132
|
+
const { errorMessage, errorMessageError } = (0, create_error_message_1.createErrorMessage)(error);
|
|
133
|
+
logger.error(`Failed to fetch price from ${this.protocol}`, errorMessageError);
|
|
134
|
+
throw (0, throw_error_1.sdkError)(enums_1.SdkErrorEnum.PRICE_NOT_FOUND, `Failed to fetch DeBridge price, error: ${errorMessage}`);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Fetches a swap quote from the DeBridge API and builds the transaction data
|
|
139
|
+
* needed to execute the cross-chain swap.
|
|
140
|
+
*
|
|
141
|
+
* @param {IntentQuoteParams} params - The parameters required for the swap quote.
|
|
142
|
+
*
|
|
143
|
+
* @returns {Promise<QuoteResponse>} A promise that resolves to a `QuoteResponse` object containing:
|
|
144
|
+
* - The expected amount of output tokens.
|
|
145
|
+
* - The transaction data needed to execute the swap.
|
|
146
|
+
*
|
|
147
|
+
* @throws {SdkError} If the parameters are invalid or unsupported.
|
|
148
|
+
* @throws {SdkError} If the DeBridge API returns an invalid response.
|
|
149
|
+
* @throws {SdkError} If there's an error fetching the quote.
|
|
150
|
+
*/
|
|
151
|
+
async fetchQuote(params) {
|
|
152
|
+
try {
|
|
153
|
+
this.validateQuoteParams(params);
|
|
154
|
+
const validatedParams = this.transformQuoteParams(params);
|
|
155
|
+
const dlnQuote = await this.fetchDLNQuote(validatedParams);
|
|
156
|
+
if (!dlnQuote.tx.data) {
|
|
157
|
+
throw (0, throw_error_1.sdkError)(enums_1.SdkErrorEnum.QUOTE_NOT_FOUND, 'Invalid DLN quote: Missing transaction data');
|
|
158
|
+
}
|
|
159
|
+
logger.debug('Successfully received quote info from DeBridge', {
|
|
160
|
+
dlnQuote,
|
|
161
|
+
amountOut: dlnQuote.estimation.dstChainTokenOut.amount,
|
|
162
|
+
to: dlnQuote.tx.to,
|
|
163
|
+
});
|
|
164
|
+
if (!dlnQuote.tx.to || !dlnQuote.tx.data) {
|
|
165
|
+
logger.error('Invalid DLN quote: Missing transaction "to" or "data" field');
|
|
166
|
+
throw (0, throw_error_1.sdkError)(enums_1.SdkErrorEnum.QUOTE_NOT_FOUND, 'Invalid DLN quote: Missing transaction "to" or "data" field');
|
|
167
|
+
}
|
|
168
|
+
const isSourceSolana = (0, check_vm_1.isSolanaNetwork)(params.networkIn);
|
|
169
|
+
const executionPayload = isSourceSolana
|
|
170
|
+
? { transactionData: [await this.formatSolanaTransaction(dlnQuote.tx.data)] }
|
|
171
|
+
: {
|
|
172
|
+
transactionData: {
|
|
173
|
+
data: dlnQuote.tx.data,
|
|
174
|
+
to: dlnQuote.tx.to,
|
|
175
|
+
value: dlnQuote.tx.value || '0',
|
|
176
|
+
},
|
|
177
|
+
approvalRequired: dlnQuote.tx.allowanceValue
|
|
178
|
+
? {
|
|
179
|
+
spender: dlnQuote.tx.to,
|
|
180
|
+
amount: dlnQuote.tx.allowanceValue,
|
|
181
|
+
}
|
|
182
|
+
: undefined,
|
|
183
|
+
};
|
|
184
|
+
const response = {
|
|
185
|
+
protocol: this.protocol,
|
|
186
|
+
networkIn: params.networkIn,
|
|
187
|
+
networkOut: params.networkOut,
|
|
188
|
+
tokenIn: params.tokenIn,
|
|
189
|
+
tokenOut: params.tokenOut,
|
|
190
|
+
amountIn: params.amountIn,
|
|
191
|
+
amountOut: dlnQuote.estimation.dstChainTokenOut.amount,
|
|
192
|
+
slippage: params.slippage,
|
|
193
|
+
from: params.from,
|
|
194
|
+
receiver: params.receiver || params.from,
|
|
195
|
+
executionPayload,
|
|
196
|
+
protocolResponse: dlnQuote,
|
|
197
|
+
};
|
|
198
|
+
return response;
|
|
199
|
+
}
|
|
200
|
+
catch (error) {
|
|
201
|
+
const { errorMessage, errorMessageError } = (0, create_error_message_1.createErrorMessage)(error);
|
|
202
|
+
logger.error(`Failed to fetch quote from ${this.protocol}`, errorMessageError);
|
|
203
|
+
throw (0, throw_error_1.sdkError)(enums_1.SdkErrorEnum.QUOTE_NOT_FOUND, `Failed to fetch DeBridge quote, error: ${errorMessage}`);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Converts a hexadecimal string representing a serialized transaction into a base58-encoded string.
|
|
208
|
+
*
|
|
209
|
+
* This method first decodes the input hex string into a buffer, deserializes it into a `VersionedTransaction`,
|
|
210
|
+
* then serializes the transaction and encodes the result using base58.
|
|
211
|
+
*
|
|
212
|
+
* @param hex - The hexadecimal string to convert. May optionally start with '0x'.
|
|
213
|
+
* @returns The base58-encoded string representation of the serialized transaction.
|
|
214
|
+
*/
|
|
215
|
+
async formatSolanaTransaction(hex) {
|
|
216
|
+
const versionedTx = web3_js_1.VersionedTransaction.deserialize(Buffer.from(hex.slice(2), 'hex'));
|
|
217
|
+
/**
|
|
218
|
+
* Add a recent blockhash to the transaction
|
|
219
|
+
* This is necessary for the transaction to be valid on the Solana network.
|
|
220
|
+
*/
|
|
221
|
+
const rpcUrl = this.rpcUrls[enums_1.ChainIdEnum.SOLANA];
|
|
222
|
+
const url = Array.isArray(rpcUrl) ? rpcUrl[0] : rpcUrl;
|
|
223
|
+
if (!url) {
|
|
224
|
+
throw (0, throw_error_1.sdkError)(enums_1.SdkErrorEnum.MISSING_RPC_URL, 'No RPC URL provided for Solana network');
|
|
225
|
+
}
|
|
226
|
+
const connection = new web3_js_1.Connection(url, 'confirmed');
|
|
227
|
+
const recentBlockhash = await connection.getLatestBlockhash('confirmed');
|
|
228
|
+
versionedTx.message.recentBlockhash = recentBlockhash.blockhash;
|
|
229
|
+
const serializedTx = versionedTx.serialize();
|
|
230
|
+
return bs58_1.default.encode(serializedTx);
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Fetches a quote from the DeBridge DLN (Decentralized Liquidity Network) API.
|
|
234
|
+
*
|
|
235
|
+
* @param {DeBridgePriceParams & { to?: string; authority?: { networkInAddress: string; networkOutAddress: string; }}} params -
|
|
236
|
+
* The parameters for the quote request, including network IDs, token addresses, amounts, and authority addresses.
|
|
237
|
+
*
|
|
238
|
+
* @returns {Promise<DeBridgeQuoteResponse>} A promise that resolves to the quote response from DeBridge.
|
|
239
|
+
*
|
|
240
|
+
* @throws {SdkError} If there's an error with the HTTP request to the DeBridge API.
|
|
241
|
+
* @throws {Error} If the DeBridge API returns an error message.
|
|
242
|
+
*/
|
|
243
|
+
async fetchDLNQuote(params) {
|
|
244
|
+
const isSourceSolana = (0, check_vm_1.isSolanaNetwork)(params.networkIn);
|
|
245
|
+
const isDestSolana = (0, check_vm_1.isSolanaNetwork)(params.networkOut);
|
|
246
|
+
const isSrcSonic = params.networkIn === enums_1.ChainIdEnum.SONIC;
|
|
247
|
+
const isDstSonic = params.networkOut === enums_1.ChainIdEnum.SONIC;
|
|
248
|
+
let srcChainId = isSourceSolana ? this.solanaChainIdEnum : params.networkIn;
|
|
249
|
+
let dstChainId = isDestSolana ? this.solanaChainIdEnum : params.networkOut;
|
|
250
|
+
// Handle Sonic chain IDs if needed
|
|
251
|
+
if (isSrcSonic) {
|
|
252
|
+
// Use appropriate Sonic chain ID if your implementation has a specific one
|
|
253
|
+
srcChainId = params.networkIn;
|
|
254
|
+
}
|
|
255
|
+
else if (isDstSonic) {
|
|
256
|
+
// Use appropriate Sonic chain ID if your implementation has a specific one
|
|
257
|
+
dstChainId = params.networkOut;
|
|
258
|
+
}
|
|
259
|
+
const request = {
|
|
260
|
+
srcChainId: srcChainId.toString(),
|
|
261
|
+
dstChainId: dstChainId.toString(),
|
|
262
|
+
srcChainTokenIn: params.tokenIn,
|
|
263
|
+
dstChainTokenOut: params.tokenOut,
|
|
264
|
+
srcChainTokenInAmount: params.amountIn,
|
|
265
|
+
dstChainTokenOutAmount: 'auto',
|
|
266
|
+
dstChainTokenOutRecipient: params.to,
|
|
267
|
+
srcChainOrderAuthorityAddress: params?.authority?.networkInAddress,
|
|
268
|
+
dstChainOrderAuthorityAddress: params?.authority?.networkOutAddress,
|
|
269
|
+
/**
|
|
270
|
+
* If the tokenIn is native, then the tx.value will be the amountIn + debridge fee
|
|
271
|
+
* The transfer fee will be taken out of the amountIn
|
|
272
|
+
*/
|
|
273
|
+
prependOperatingExpenses: false,
|
|
274
|
+
slippage: (params.slippage * 10).toString(),
|
|
275
|
+
senderAddress: params.from,
|
|
276
|
+
accessToken: this.debridgeAccessToken ? this.debridgeAccessToken : undefined,
|
|
277
|
+
};
|
|
278
|
+
logger.debug(`Making DeBridge quote request to: ${this.baseUrl}`, request);
|
|
279
|
+
try {
|
|
280
|
+
// Construct URL with access token if provided
|
|
281
|
+
let url = this.baseUrl;
|
|
282
|
+
const headers = {};
|
|
283
|
+
// Add access token to headers if available
|
|
284
|
+
if (this.debridgeAccessToken) {
|
|
285
|
+
headers['Authorization'] = `Bearer ${this.debridgeAccessToken}`;
|
|
286
|
+
}
|
|
287
|
+
const response = await axios_1.default.get(url, {
|
|
288
|
+
params: request,
|
|
289
|
+
headers,
|
|
290
|
+
});
|
|
291
|
+
if (response.data?.errorMessage) {
|
|
292
|
+
throw new Error(response.data.errorMessage);
|
|
293
|
+
}
|
|
294
|
+
return response.data;
|
|
295
|
+
}
|
|
296
|
+
catch (error) {
|
|
297
|
+
const { errorMessage, errorMessageError } = (0, create_error_message_1.createErrorMessage)(error);
|
|
298
|
+
logger.error(`Failed to fetch DLN quote`, errorMessageError);
|
|
299
|
+
throw (0, throw_error_1.sdkError)(enums_1.SdkErrorEnum.FAILED_HTTP_REQUEST, `Failed to fetch DLN quote, error: ${errorMessage}`);
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* Validates the parameters for a price quote request.
|
|
304
|
+
*
|
|
305
|
+
* @param {IntentPriceParams} params - The parameters to validate.
|
|
306
|
+
*
|
|
307
|
+
* @throws {SdkError} If any of the parameters are invalid or unsupported.
|
|
308
|
+
*/
|
|
309
|
+
validatePriceParams(params) {
|
|
310
|
+
const { networkIn, networkOut, tokenIn, tokenOut, amountIn } = params;
|
|
311
|
+
if (networkIn === networkOut) {
|
|
312
|
+
logger.error('Single chain swaps are not supported by DeBridge');
|
|
313
|
+
throw (0, throw_error_1.sdkError)(enums_1.SdkErrorEnum.INVALID_PARAMS, 'Single chain swaps are not supported by DeBridge');
|
|
314
|
+
}
|
|
315
|
+
if (!this.chains.includes(networkIn)) {
|
|
316
|
+
logger.error(`Network ${networkIn} not supported by DeBridge`);
|
|
317
|
+
throw (0, throw_error_1.sdkError)(enums_1.SdkErrorEnum.INVALID_PARAMS, `Network ${networkIn} not supported by DeBridge`);
|
|
318
|
+
}
|
|
319
|
+
if (!this.chains.includes(networkOut)) {
|
|
320
|
+
logger.error(`Network ${networkOut} not supported by DeBridge`);
|
|
321
|
+
throw (0, throw_error_1.sdkError)(enums_1.SdkErrorEnum.INVALID_PARAMS, `Network ${networkOut} not supported by DeBridge`);
|
|
322
|
+
}
|
|
323
|
+
if (amountIn === '0') {
|
|
324
|
+
logger.error('Amount in must be greater than 0');
|
|
325
|
+
throw (0, throw_error_1.sdkError)(enums_1.SdkErrorEnum.INVALID_PARAMS, 'Amount in must be greater than 0');
|
|
326
|
+
}
|
|
327
|
+
// Validate token addresses based on network type
|
|
328
|
+
if ((0, check_vm_1.isSolanaNetwork)(networkIn)) {
|
|
329
|
+
try {
|
|
330
|
+
(0, address_1.validateSolanaAddress)(tokenIn);
|
|
331
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
332
|
+
}
|
|
333
|
+
catch (error) {
|
|
334
|
+
logger.error(`Invalid Solana token address: ${tokenIn}`);
|
|
335
|
+
throw (0, throw_error_1.sdkError)(enums_1.SdkErrorEnum.INVALID_PARAMS, `Invalid Solana token address: ${tokenIn}`);
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
else if ((0, check_vm_1.isEVMNetwork)(networkIn) && tokenIn !== constants_1.NATIVE_ADDRESS) {
|
|
339
|
+
try {
|
|
340
|
+
(0, address_validation_1.validateAndChecksumEvmAddress)(tokenIn);
|
|
341
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
342
|
+
}
|
|
343
|
+
catch (error) {
|
|
344
|
+
logger.error(`Invalid EVM token address: ${tokenIn}`);
|
|
345
|
+
throw (0, throw_error_1.sdkError)(enums_1.SdkErrorEnum.INVALID_PARAMS, `Invalid EVM token address: ${tokenIn}`);
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
if ((0, check_vm_1.isSolanaNetwork)(networkOut)) {
|
|
349
|
+
try {
|
|
350
|
+
(0, address_1.validateSolanaAddress)(tokenOut);
|
|
351
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
352
|
+
}
|
|
353
|
+
catch (error) {
|
|
354
|
+
logger.error(`Invalid Solana token address: ${tokenOut}`);
|
|
355
|
+
throw (0, throw_error_1.sdkError)(enums_1.SdkErrorEnum.INVALID_PARAMS, `Invalid Solana token address: ${tokenOut}`);
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
else if ((0, check_vm_1.isEVMNetwork)(networkOut) && tokenOut !== constants_1.NATIVE_ADDRESS) {
|
|
359
|
+
try {
|
|
360
|
+
(0, address_validation_1.validateAndChecksumEvmAddress)(tokenOut);
|
|
361
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
362
|
+
}
|
|
363
|
+
catch (error) {
|
|
364
|
+
logger.error(`Invalid EVM token address: ${tokenOut}`);
|
|
365
|
+
throw (0, throw_error_1.sdkError)(enums_1.SdkErrorEnum.INVALID_PARAMS, `Invalid EVM token address: ${tokenOut}`);
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
/**
|
|
370
|
+
* Validates the parameters for a quote request, extending the price parameters validation.
|
|
371
|
+
*
|
|
372
|
+
* @param {IntentQuoteParams} params - The parameters to validate.
|
|
373
|
+
*
|
|
374
|
+
* @throws {SdkError} If any of the parameters are invalid or missing.
|
|
375
|
+
*/
|
|
376
|
+
validateQuoteParams(params) {
|
|
377
|
+
this.validatePriceParams(params);
|
|
378
|
+
if (!params.receiver) {
|
|
379
|
+
logger.error('To address is required for quote');
|
|
380
|
+
throw (0, throw_error_1.sdkError)(enums_1.SdkErrorEnum.INVALID_PARAMS, 'Receiver address is required for quote');
|
|
381
|
+
}
|
|
382
|
+
if (!params.from) {
|
|
383
|
+
logger.error('From address is required for quote');
|
|
384
|
+
throw (0, throw_error_1.sdkError)(enums_1.SdkErrorEnum.INVALID_PARAMS, 'From address is required for quote');
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
/**
|
|
388
|
+
* Transforms the price parameters to the format expected by the DeBridge API.
|
|
389
|
+
*
|
|
390
|
+
* @param {IntentPriceParams} params - The original price parameters.
|
|
391
|
+
*
|
|
392
|
+
* @returns {DeBridgePriceParams} The transformed parameters ready for the DeBridge API.
|
|
393
|
+
*/
|
|
394
|
+
transformPriceParams(params) {
|
|
395
|
+
let { networkIn, networkOut, tokenIn, tokenOut } = params;
|
|
396
|
+
const { amountIn, slippage, from } = params;
|
|
397
|
+
// Handle chainId transformation for Sonic
|
|
398
|
+
if (networkIn === enums_1.ChainIdEnum.SONIC) {
|
|
399
|
+
networkIn = this.sonicChainIdEnum; // or any other default chain for Sonic
|
|
400
|
+
}
|
|
401
|
+
if (networkOut === enums_1.ChainIdEnum.SONIC) {
|
|
402
|
+
networkOut = this.sonicChainIdEnum; // or any other default chain for Sonic
|
|
403
|
+
}
|
|
404
|
+
// Handle token address transformation
|
|
405
|
+
if ((0, check_vm_1.isSolanaNetwork)(networkIn)) {
|
|
406
|
+
networkIn = this.solanaChainIdEnum;
|
|
407
|
+
}
|
|
408
|
+
else if (tokenIn === constants_1.NATIVE_ADDRESS) {
|
|
409
|
+
tokenIn = constants_1.ZERO_ADDRESS;
|
|
410
|
+
}
|
|
411
|
+
else {
|
|
412
|
+
tokenIn = (0, address_validation_1.validateAndChecksumEvmAddress)(tokenIn);
|
|
413
|
+
}
|
|
414
|
+
if ((0, check_vm_1.isSolanaNetwork)(networkOut)) {
|
|
415
|
+
networkOut = this.solanaChainIdEnum;
|
|
416
|
+
}
|
|
417
|
+
else if (tokenOut === constants_1.NATIVE_ADDRESS) {
|
|
418
|
+
tokenOut = constants_1.ZERO_ADDRESS;
|
|
419
|
+
}
|
|
420
|
+
else {
|
|
421
|
+
tokenOut = (0, address_validation_1.validateAndChecksumEvmAddress)(tokenOut);
|
|
422
|
+
}
|
|
423
|
+
return {
|
|
424
|
+
networkIn,
|
|
425
|
+
networkOut,
|
|
426
|
+
tokenIn,
|
|
427
|
+
tokenOut,
|
|
428
|
+
amountIn,
|
|
429
|
+
slippage,
|
|
430
|
+
from,
|
|
431
|
+
};
|
|
432
|
+
}
|
|
433
|
+
/**
|
|
434
|
+
* Transforms the quote parameters to the format expected by the DeBridge API.
|
|
435
|
+
*
|
|
436
|
+
* @param {IntentQuoteParams} params - The original quote parameters.
|
|
437
|
+
*
|
|
438
|
+
* @returns {DeBridgeQuoteParams} The transformed parameters ready for the DeBridge API.
|
|
439
|
+
*/
|
|
440
|
+
transformQuoteParams(params) {
|
|
441
|
+
const transformedPriceParams = this.transformPriceParams(params);
|
|
442
|
+
// Create authority object from parameters or use the default from service instance
|
|
443
|
+
const authority = {
|
|
444
|
+
networkInAddress: params.from,
|
|
445
|
+
networkOutAddress: params.receiver || params.from,
|
|
446
|
+
};
|
|
447
|
+
let priceResponse = undefined;
|
|
448
|
+
if (params.priceResponse && this.isDeBridgePriceResponse(params.priceResponse.protocolResponse))
|
|
449
|
+
priceResponse = params.priceResponse.protocolResponse;
|
|
450
|
+
return {
|
|
451
|
+
...transformedPriceParams,
|
|
452
|
+
to: params.receiver,
|
|
453
|
+
authority,
|
|
454
|
+
priceResponse,
|
|
455
|
+
};
|
|
456
|
+
}
|
|
457
|
+
isDeBridgePriceResponse(response) {
|
|
458
|
+
return response && 'estimation' in response && 'tx' in response && 'order' in response;
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
exports.DeBridgeService = DeBridgeService;
|
|
462
|
+
//# sourceMappingURL=debridge.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"debridge.service.js","sourceRoot":"","sources":["../../../../src/protocols/debridge/debridge.service.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,6CAAmE;AACnE,gDAAwB;AAcxB,+CAA0E;AAC1E,yDAAmD;AACnD,mDAAqE;AACrE,2EAAsE;AACtE,iDAA4D;AAC5D,uEAA+E;AAC/E,qDAAqE;AAErE,6CAA4E;AAE5E,IAAI,MAAe,CAAC;AAEpB;;;;;;;GAOG;AACH,MAAa,eAAe;IAyD1B;;;;;;OAMG;IACH,YAAY,MAA0C;QA/DtD;;WAEG;QACgB,YAAO,GAAsC,EAAE,CAAC;QAEnE;;WAEG;QACa,aAAQ,GAAG,oBAAY,CAAC,QAAQ,CAAC;QAEjD;;WAEG;QACa,WAAM,GAAG;YACvB,mBAAW,CAAC,QAAQ;YACpB,mBAAW,CAAC,QAAQ;YACpB,mBAAW,CAAC,QAAQ;YACpB,mBAAW,CAAC,OAAO;YACnB,mBAAW,CAAC,GAAG;YACf,mBAAW,CAAC,SAAS;YACrB,mBAAW,CAAC,IAAI;YAChB,mBAAW,CAAC,KAAK;YACjB,mB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AsC,SAAS,CAAC;QACjE,IAAI,MAAM,CAAC,aAAa,IAAI,IAAI,CAAC,uBAAuB,CAAC,MAAM,CAAC,aAAa,CAAC,gBAAgB,CAAC;YAC7F,aAAa,GAAG,MAAM,CAAC,aAAa,CAAC,gBAAgB,CAAC;QAExD,OAAO;YACL,GAAG,sBAAsB;YACzB,EAAE,EAAE,MAAM,CAAC,QAAQ;YACnB,SAAS;YACT,aAAa;SACd,CAAC;IACJ,CAAC;IAES,uBAAuB,CAC/B,QAAkC;QAElC,OAAO,QAAQ,IAAI,YAAY,IAAI,QAAQ,IAAI,IAAI,IAAI,QAAQ,IAAI,OAAO,IAAI,QAAQ,CAAC;IACzF,CAAC;CACF;AA7fD,0CA6fC"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { ChainIdEnum } from '../../types/enums';
|
|
2
|
+
export type DeBridgeConfig = {
|
|
3
|
+
deBridgePrivateUrl?: string;
|
|
4
|
+
debridgeAccessToken?: string;
|
|
5
|
+
};
|
|
6
|
+
export type DeBridgePriceParams = {
|
|
7
|
+
networkIn: ChainIdEnum;
|
|
8
|
+
networkOut: ChainIdEnum;
|
|
9
|
+
tokenIn: string;
|
|
10
|
+
tokenOut: string;
|
|
11
|
+
amountIn: string;
|
|
12
|
+
slippage: number;
|
|
13
|
+
from: string;
|
|
14
|
+
};
|
|
15
|
+
export type DeBridgeQuoteParams = DeBridgePriceParams & {
|
|
16
|
+
to: string;
|
|
17
|
+
authority: {
|
|
18
|
+
networkInAddress: string;
|
|
19
|
+
networkOutAddress: string;
|
|
20
|
+
};
|
|
21
|
+
priceResponse?: DeBridgeQuoteResponse;
|
|
22
|
+
};
|
|
23
|
+
export type Token = {
|
|
24
|
+
address: string;
|
|
25
|
+
chainId: number;
|
|
26
|
+
decimals: number;
|
|
27
|
+
name: string;
|
|
28
|
+
symbol: string;
|
|
29
|
+
amount: string;
|
|
30
|
+
approximateUsdValue: number;
|
|
31
|
+
};
|
|
32
|
+
export type SrcChainTokenIn = Token & {
|
|
33
|
+
approximateOperatingExpense: string;
|
|
34
|
+
mutatedWithOperatingExpense: boolean;
|
|
35
|
+
originApproximateUsdValue: number;
|
|
36
|
+
};
|
|
37
|
+
export type SrcChainTokenOut = Token & {
|
|
38
|
+
maxRefundAmount: string;
|
|
39
|
+
};
|
|
40
|
+
export type DstChainTokenOut = Token & {
|
|
41
|
+
recommendedAmount: string;
|
|
42
|
+
maxTheoreticalAmount: string;
|
|
43
|
+
recommendedApproximateUsdValue: number;
|
|
44
|
+
maxTheoreticalApproximateUsdValue: number;
|
|
45
|
+
};
|
|
46
|
+
export type CostDetail = {
|
|
47
|
+
name: string;
|
|
48
|
+
amount: string;
|
|
49
|
+
token: {
|
|
50
|
+
symbol: string;
|
|
51
|
+
address: string;
|
|
52
|
+
};
|
|
53
|
+
amountUsd: number;
|
|
54
|
+
};
|
|
55
|
+
export type Transaction = {
|
|
56
|
+
allowanceTarget?: string;
|
|
57
|
+
allowanceValue?: string;
|
|
58
|
+
value?: string;
|
|
59
|
+
data?: string;
|
|
60
|
+
to?: string;
|
|
61
|
+
};
|
|
62
|
+
export type Order = {
|
|
63
|
+
approximateFulfillmentDelay: number;
|
|
64
|
+
salt?: number;
|
|
65
|
+
metadata?: string;
|
|
66
|
+
};
|
|
67
|
+
export type DeBridgeQuoteResponse = {
|
|
68
|
+
estimation: {
|
|
69
|
+
srcChainTokenIn: SrcChainTokenIn;
|
|
70
|
+
srcChainTokenOut: SrcChainTokenOut;
|
|
71
|
+
dstChainTokenOut: DstChainTokenOut;
|
|
72
|
+
costsDetails: CostDetail[];
|
|
73
|
+
recommendedSlippage: number;
|
|
74
|
+
};
|
|
75
|
+
tx: Transaction;
|
|
76
|
+
order: Order;
|
|
77
|
+
orderId?: string;
|
|
78
|
+
fixFee: string;
|
|
79
|
+
userPoints: number;
|
|
80
|
+
integratorPoints: number;
|
|
81
|
+
};
|
|
82
|
+
//# sourceMappingURL=debridge.types.d.ts.map
|
|
@@ -0,0 +1 @@
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1 @@
|
|
|
1
|
+
{"version":3,"file":"debridge.types.js","sourceRoot":"","sources":["../../../../src/protocols/debridge/debridge.types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { DeBridgeService } from './debridge.service';
|
|
2
|
+
export type { DeBridgeConfig, DeBridgePriceParams, DeBridgeQuoteParams, Token, SrcChainTokenIn, SrcChainTokenOut, DstChainTokenOut, CostDetail, Transaction, Order, DeBridgeQuoteResponse, } from './debridge.types';
|
|
3
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/protocols/debridge/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,YAAY,EACV,cAAc,EACd,mBAAmB,EACnB,mBAAmB,EACnB,KAAK,EACL,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,UAAU,EACV,WAAW,EACX,KAAK,EACL,qBAAqB,GACtB,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DeBridgeService = void 0;
|
|
4
|
+
// DeBridge Protocol - All exports
|
|
5
|
+
var debridge_service_1 = require("./debridge.service");
|
|
6
|
+
Object.defineProperty(exports, "DeBridgeService", { enumerable: true, get: function () { return debridge_service_1.DeBridgeService; } });
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/protocols/debridge/index.ts"],"names":[],"mappings":";;;AAAA,kCAAkC;AAClC,uDAAqD;AAA5C,mHAAA,eAAe,OAAA"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { IIntentProtocol } from '../../interfaces/intent-protocol';
|
|
2
|
+
import { ChainIdEnum, ProtocolEnum } from '../../types/enums';
|
|
3
|
+
import { IntentPriceParams } from '../../types/price-params';
|
|
4
|
+
import { PriceResponse } from '../../types/price-response';
|
|
5
|
+
import { IntentQuoteParams } from '../../types/quote-params';
|
|
6
|
+
import { QuoteResponse } from '../../types/quote-response';
|
|
7
|
+
import { IntentsSDKConfig } from '../../types/sdk-config';
|
|
8
|
+
import { GeniusBridgePriceResponse, GeniusBridgeQuoteResponse, GeniusBridgePriceParams, GeniusBridgeQuoteParams } from './genius-bridge.types';
|
|
9
|
+
export declare class GeniusBridgeService implements IIntentProtocol {
|
|
10
|
+
readonly protocol = ProtocolEnum.GENIUS_BRIDGE;
|
|
11
|
+
readonly chains: ChainIdEnum[];
|
|
12
|
+
readonly singleChain = false;
|
|
13
|
+
readonly multiChain = true;
|
|
14
|
+
readonly baseUrl: string;
|
|
15
|
+
readonly priceEndpoint: string;
|
|
16
|
+
readonly quoteEndpoint: string;
|
|
17
|
+
constructor(config?: IntentsSDKConfig & {
|
|
18
|
+
geniusBridgeBaseUrl?: string;
|
|
19
|
+
geniusBridgePriceEndpoint?: string;
|
|
20
|
+
geniusBridgeQuoteEndpoint?: string;
|
|
21
|
+
});
|
|
22
|
+
isCorrectConfig<T extends {
|
|
23
|
+
[key: string]: string;
|
|
24
|
+
}>(_config: {
|
|
25
|
+
[key: string]: string;
|
|
26
|
+
}): _config is T;
|
|
27
|
+
fetchPrice(params: IntentPriceParams): Promise<PriceResponse>;
|
|
28
|
+
fetchQuote(params: IntentQuoteParams): Promise<QuoteResponse>;
|
|
29
|
+
makeGeniusBridgePriceRequest(params: GeniusBridgePriceParams): Promise<GeniusBridgePriceResponse>;
|
|
30
|
+
makeGeniusBridgeQuoteRequest(params: GeniusBridgeQuoteParams): Promise<GeniusBridgeQuoteResponse>;
|
|
31
|
+
protected validatePriceParams(params: IntentPriceParams): void;
|
|
32
|
+
protected validateQuoteParams(params: IntentQuoteParams): void;
|
|
33
|
+
protected transformPriceParams(params: IntentPriceParams): GeniusBridgePriceParams;
|
|
34
|
+
protected transformQuoteParams(params: IntentQuoteParams): GeniusBridgeQuoteParams;
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=genius-bridge.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"genius-bridge.service.d.ts","sourceRoot":"","sources":["../../../../src/protocols/genius-bridge/genius-bridge.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,YAAY,EAAgB,MAAM,mBAAmB,CAAC;AAE5E,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAW1D,OAAO,EACL,yBAAyB,EACzB,yBAAyB,EAEzB,uBAAuB,EACvB,uBAAuB,EACxB,MAAM,uBAAuB,CAAC;AAK/B,qBAAa,mBAAoB,YAAW,eAAe;IACzD,SAAgB,QAAQ,8BAA8B;IACtD,SAAgB,MAAM,gBAUpB;IACF,SAAgB,WAAW,SAAS;IACpC,SAAgB,UAAU,QAAQ;IAClC,SAAgB,OAAO,EAAE,MAAM,CAAC;IAChC,SAAgB,aAAa,EAAE,MAAM,CAAC;IACtC,SAAgB,aAAa,EAAE,MAAM,CAAC;gBAGpC,MAAM,CAAC,EAAE,gBAAgB,GAAG;QAC1B,mBAAmB,CAAC,EAAE,MAAM,CAAC;QAC7B,yBAAyB,CAAC,EAAE,MAAM,CAAC;QACnC,yBAAyB,CAAC,EAAE,MAAM,CAAC;KACpC;IAmBH,eAAe,CAAC,CAAC,SAAS;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MA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