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
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
## [0.1.4] - 2025-06-09
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
- Version bump to 0.1.4
|
|
7
|
+
|
|
8
|
+
### Changed
|
|
9
|
+
- Package updates and improvements
|
|
10
|
+
|
|
11
|
+
### Fixed
|
|
12
|
+
- Bug fixes and stability improvements
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
## [0.1.3] - 2025-06-09
|
|
19
|
+
|
|
20
|
+
### Added
|
|
21
|
+
- Version bump to 0.1.3
|
|
22
|
+
|
|
23
|
+
### Changed
|
|
24
|
+
- Package updates and improvements
|
|
25
|
+
|
|
26
|
+
### Fixed
|
|
27
|
+
- Bug fixes and stability improvements
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
## [0.1.2] - 2025-06-09
|
|
33
|
+
|
|
34
|
+
### Added
|
|
35
|
+
- Version bump to 0.1.2
|
|
36
|
+
|
|
37
|
+
### Changed
|
|
38
|
+
- Package updates and improvements
|
|
39
|
+
|
|
40
|
+
### Fixed
|
|
41
|
+
- Bug fixes and stability improvements
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Samuel Videau and Genius Foundation
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,376 @@
|
|
|
1
|
+
# Genius Intents SDK
|
|
2
|
+
|
|
3
|
+
A unified TypeScript SDK for interacting with multiple DeFi protocols and intent-based trading across various blockchains.
|
|
4
|
+
|
|
5
|
+
## 🚀 Features
|
|
6
|
+
|
|
7
|
+
- **Multi-Protocol Support**: Seamlessly interact with Jupiter, Raydium, PumpFun, Odos, OKX, Kyberswap, OpenOcean, and Aftermath
|
|
8
|
+
- **Cross-Chain Compatible**: Support for Solana, Ethereum, and Sui networks
|
|
9
|
+
- **Intent-Based Trading**: Execute complex trading strategies with simple intent definitions
|
|
10
|
+
- **TypeScript First**: Full type safety and excellent developer experience
|
|
11
|
+
- **Unified API**: Single interface for multiple DeFi protocols
|
|
12
|
+
- **Price Discovery**: Get quotes and prices across multiple protocols simultaneously
|
|
13
|
+
|
|
14
|
+
## 📦 Installation
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm install genius-intents
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
yarn add genius-intents
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## 🏁 Quick Start
|
|
25
|
+
|
|
26
|
+
```typescript
|
|
27
|
+
import { IntentsProtocols, ChainIdEnum } from 'genius-intents';
|
|
28
|
+
|
|
29
|
+
// Initialize the SDK with configuration
|
|
30
|
+
const intentsSDK = new IntentsProtocols({
|
|
31
|
+
method: 'best', // 'best' or 'race'
|
|
32
|
+
debug: true,
|
|
33
|
+
logger: console,
|
|
34
|
+
solanaRpcUrl: 'https://api.mainnet-beta.solana.com',
|
|
35
|
+
suiRpcUrl: 'https://sui-mainnet.blockvision.org/v1/YOUR_API_KEY',
|
|
36
|
+
okxApiKey: 'your-okx-api-key',
|
|
37
|
+
okxSecretKey: 'your-okx-secret-key',
|
|
38
|
+
okxPassphrase: 'your-okx-passphrase',
|
|
39
|
+
okxProjectId: 'your-okx-project-id',
|
|
40
|
+
zeroXApiKey: 'your-0x-api-key',
|
|
41
|
+
kyberswapClientId: 'your-kyberswap-client-id',
|
|
42
|
+
timeout: 30000,
|
|
43
|
+
maxConcurrency: 10
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
// Get price quotes across multiple protocols
|
|
47
|
+
const priceParams = {
|
|
48
|
+
networkIn: ChainIdEnum.BASE,
|
|
49
|
+
networkOut: ChainIdEnum.BASE,
|
|
50
|
+
tokenIn: '0x940181a94A35A4569E4529A3CDfB74e38FD98631',
|
|
51
|
+
tokenOut: '0x0b3e328455c4059EEb9e3f84b5543F74E24e7E1b',
|
|
52
|
+
amountIn: '1000000000000000000', // 1 token (18 decimals)
|
|
53
|
+
slippage: 1, // 1%
|
|
54
|
+
from: '0x5B1a738cfF4c6064C9C211C611f171a1567D2b9b'
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const prices = await intentsSDK.fetchPrice(priceParams);
|
|
58
|
+
console.log('Best price:', prices.result);
|
|
59
|
+
|
|
60
|
+
// Execute a trade quote
|
|
61
|
+
const quoteParams = {
|
|
62
|
+
networkIn: ChainIdEnum.BASE,
|
|
63
|
+
networkOut: ChainIdEnum.BASE,
|
|
64
|
+
tokenIn: '0x940181a94A35A4569E4529A3CDfB74e38FD98631',
|
|
65
|
+
tokenOut: '0x0b3e328455c4059EEb9e3f84b5543F74E24e7E1b',
|
|
66
|
+
amountIn: '1000000000000000000',
|
|
67
|
+
slippage: 1,
|
|
68
|
+
from: '0x5B1a738cfF4c6064C9C211C611f171a1567D2b9b',
|
|
69
|
+
receiver: '0x5B1a738cfF4c6064C9C211C611f171a1567D2b9b'
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
const quote = await intentsSDK.fetchQuote(quoteParams);
|
|
73
|
+
console.log('Quote:', quote.result);
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## 🔧 Advanced Usage
|
|
77
|
+
|
|
78
|
+
### Using Individual Protocol Services
|
|
79
|
+
|
|
80
|
+
#### Option 1: Protocol Namespace Import (Recommended for Advanced Users)
|
|
81
|
+
```typescript
|
|
82
|
+
import { Jupiter, Raydium, Okx } from 'genius-intents';
|
|
83
|
+
|
|
84
|
+
// Access service and all protocol-specific types
|
|
85
|
+
const jupiter = new Jupiter.JupiterService(jupiterConfig);
|
|
86
|
+
const raydium = new Raydium.RaydiumV2Service(jupiterConfig);
|
|
87
|
+
|
|
88
|
+
// Access protocol-specific types for advanced usage
|
|
89
|
+
type JupiterConfig = Jupiter.JupiterConfig;
|
|
90
|
+
type JupiterPriceResponse = Jupiter.JupiterPriceResponse;
|
|
91
|
+
type RaydiumQuoteResponse = Raydium.RaydiumV2QuoteResponse;
|
|
92
|
+
|
|
93
|
+
// Use protocol-specific types for type-safe development
|
|
94
|
+
const jupiterParams: Jupiter.JupiterPriceUrlParams = {
|
|
95
|
+
inputMint: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v',
|
|
96
|
+
outputMint: 'So11111111111111111111111111111111111111112',
|
|
97
|
+
amount: '1000000',
|
|
98
|
+
slippageBps: 50
|
|
99
|
+
};
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
#### Option 2: Granular Protocol Import
|
|
103
|
+
```typescript
|
|
104
|
+
// Import only what you need for better tree shaking
|
|
105
|
+
import { JupiterService, type JupiterConfig, type JupiterPriceResponse } from 'genius-intents/protocols/jupiter';
|
|
106
|
+
import { OkxService, type OKXConfig } from 'genius-intents/protocols/okx';
|
|
107
|
+
|
|
108
|
+
const jupiter = new JupiterService({ solanaRpcUrl: 'https://api.mainnet-beta.solana.com' });
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### Protocol Filtering
|
|
112
|
+
|
|
113
|
+
```typescript
|
|
114
|
+
import { IntentsProtocols, ProtocolEnum } from 'genius-intents';
|
|
115
|
+
|
|
116
|
+
// Only use specific protocols
|
|
117
|
+
const intentsSDK = new IntentsProtocols({
|
|
118
|
+
method: 'best',
|
|
119
|
+
includeProtocols: [ProtocolEnum.JUPITER, ProtocolEnum.RAYDIUM_V2],
|
|
120
|
+
solanaRpcUrl: 'https://api.mainnet-beta.solana.com'
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
// Exclude specific protocols
|
|
124
|
+
const intentsSDKExclude = new IntentsProtocols({
|
|
125
|
+
method: 'race',
|
|
126
|
+
excludeProtocols: [ProtocolEnum.PUMPFUN],
|
|
127
|
+
timeout: 15000
|
|
128
|
+
});
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### Cross-Chain Operations
|
|
132
|
+
|
|
133
|
+
```typescript
|
|
134
|
+
import { IntentsProtocols, ChainIdEnum } from 'genius-intents';
|
|
135
|
+
|
|
136
|
+
// Configure for multiple chains
|
|
137
|
+
const multiChainSDK = new IntentsProtocols({
|
|
138
|
+
method: 'best',
|
|
139
|
+
solanaRpcUrl: 'https://api.mainnet-beta.solana.com',
|
|
140
|
+
suiRpcUrl: 'https://sui-mainnet.blockvision.org/v1/YOUR_API_KEY',
|
|
141
|
+
okxApiKey: 'your-okx-api-key',
|
|
142
|
+
okxSecretKey: 'your-okx-secret-key',
|
|
143
|
+
okxPassphrase: 'your-okx-passphrase',
|
|
144
|
+
okxProjectId: 'your-okx-project-id',
|
|
145
|
+
zeroXApiKey: 'your-0x-api-key'
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
// Ethereum Base chain operations
|
|
149
|
+
const baseParams = {
|
|
150
|
+
networkIn: ChainIdEnum.BASE,
|
|
151
|
+
networkOut: ChainIdEnum.BASE,
|
|
152
|
+
tokenIn: '0x940181a94A35A4569E4529A3CDfB74e38FD98631',
|
|
153
|
+
tokenOut: '0x0b3e328455c4059EEb9e3f84b5543F74E24e7E1b',
|
|
154
|
+
amountIn: '1000000000000000000',
|
|
155
|
+
slippage: 1,
|
|
156
|
+
from: '0x5B1a738cfF4c6064C9C211C611f171a1567D2b9b'
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
// Sui network operations
|
|
160
|
+
const suiParams = {
|
|
161
|
+
networkIn: ChainIdEnum.SUI_MAINNET,
|
|
162
|
+
networkOut: ChainIdEnum.SUI_MAINNET,
|
|
163
|
+
tokenIn: '0x2::sui::SUI',
|
|
164
|
+
tokenOut: '0x5d4b302506645c37ff133b98c4b50a5ae14841659738d6d733d59d0d217a93bf::coin::COIN',
|
|
165
|
+
amountIn: '1000000000', // 1 SUI (9 decimals)
|
|
166
|
+
slippage: 1,
|
|
167
|
+
from: '0x...' // Sui address
|
|
168
|
+
};
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
## 📚 API Reference
|
|
172
|
+
|
|
173
|
+
### IntentsProtocols
|
|
174
|
+
|
|
175
|
+
The main class for interacting with multiple protocols.
|
|
176
|
+
|
|
177
|
+
#### Constructor
|
|
178
|
+
|
|
179
|
+
```typescript
|
|
180
|
+
new IntentsProtocols(config?: IntentsProtocolsConfig)
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
**Configuration Options:**
|
|
184
|
+
- `method?: 'race' | 'best'` - Execution method ('race' returns fastest, 'best' returns optimal)
|
|
185
|
+
- `timeout?: number` - Timeout in milliseconds for individual protocol requests (default: 30000)
|
|
186
|
+
- `maxConcurrency?: number` - Maximum concurrent protocol requests (default: 10)
|
|
187
|
+
- `includeProtocols?: ProtocolEnum[]` - Specific protocols to include
|
|
188
|
+
- `excludeProtocols?: ProtocolEnum[]` - Specific protocols to exclude
|
|
189
|
+
- `logger?: ILogger` - Custom logger instance
|
|
190
|
+
- `debug?: boolean` - Enable debug logging
|
|
191
|
+
|
|
192
|
+
**Protocol-Specific Configuration:**
|
|
193
|
+
- `solanaRpcUrl?: string` - Solana RPC endpoint
|
|
194
|
+
- `suiRpcUrl?: string` - Sui RPC endpoint
|
|
195
|
+
- `okxApiKey?: string` - OKX API key
|
|
196
|
+
- `okxSecretKey?: string` - OKX secret key
|
|
197
|
+
- `okxPassphrase?: string` - OKX passphrase
|
|
198
|
+
- `okxProjectId?: string` - OKX project ID
|
|
199
|
+
- `zeroXApiKey?: string` - 0x API key
|
|
200
|
+
- `kyberswapClientId?: string` - Kyberswap client ID
|
|
201
|
+
|
|
202
|
+
#### Methods
|
|
203
|
+
|
|
204
|
+
##### `fetchPrice(params: IntentPriceParams): Promise<IntentsProtocolsResults<PriceResponse>>`
|
|
205
|
+
|
|
206
|
+
Get price quotes from multiple protocols.
|
|
207
|
+
|
|
208
|
+
**Parameters:**
|
|
209
|
+
- `networkIn: number` - Input network chain ID
|
|
210
|
+
- `networkOut: number` - Output network chain ID
|
|
211
|
+
- `tokenIn: string` - Input token address
|
|
212
|
+
- `tokenOut: string` - Output token address
|
|
213
|
+
- `amountIn: string` - Amount to trade (in token's smallest unit)
|
|
214
|
+
- `slippage: number` - Slippage tolerance as percentage (e.g., 1 for 1%)
|
|
215
|
+
- `from: string` - User's wallet address
|
|
216
|
+
|
|
217
|
+
##### `fetchQuote(params: IntentQuoteParams): Promise<IntentsProtocolsResults<QuoteResponse>>`
|
|
218
|
+
|
|
219
|
+
Get detailed quotes including transaction data.
|
|
220
|
+
|
|
221
|
+
**Parameters:**
|
|
222
|
+
- All parameters from `IntentPriceParams` plus:
|
|
223
|
+
- `receiver: string` - Recipient address for the trade
|
|
224
|
+
- `priceResponse?: PriceResponse` - Optional pre-fetched price response
|
|
225
|
+
|
|
226
|
+
#### Utility Methods
|
|
227
|
+
|
|
228
|
+
- `getInitializedProtocols(): ProtocolEnum[]` - Get list of successfully initialized protocols
|
|
229
|
+
- `getProtocol(protocol: ProtocolEnum): IIntentProtocol | undefined` - Get specific protocol instance
|
|
230
|
+
- `updateConfig(config: Partial<IntentsProtocolsConfig>): void` - Update configuration
|
|
231
|
+
|
|
232
|
+
### Supported Protocols
|
|
233
|
+
|
|
234
|
+
| Protocol | Namespace | Chains | Description |
|
|
235
|
+
|----------|-----------|--------|-------------|
|
|
236
|
+
| Jupiter | `Jupiter` | Solana | Leading Solana DEX aggregator |
|
|
237
|
+
| Raydium V2 | `Raydium` | Solana | Automated market maker |
|
|
238
|
+
| PumpFun | `PumpFun` | Solana | Meme token trading platform |
|
|
239
|
+
| Odos | `Odos` | Multi-chain | Multi-chain DEX aggregator |
|
|
240
|
+
| OKX | `Okx` | Multi-chain | Centralized exchange DEX |
|
|
241
|
+
| Kyberswap | `Kyberswap` | Multi-chain | Dynamic market maker |
|
|
242
|
+
| OpenOcean | `OpenOcean` | Multi-chain | DEX aggregator |
|
|
243
|
+
| 0x | `ZeroX` | Multi-chain | DEX aggregator protocol |
|
|
244
|
+
| Aftermath | `Aftermath` | Sui | Native Sui DEX |
|
|
245
|
+
| DeBridge | `DeBridge` | Multi-chain | Cross-chain bridge |
|
|
246
|
+
| Genius Bridge | `GeniusBridge` | Multi-chain | Custom bridge solution |
|
|
247
|
+
|
|
248
|
+
#### Protocol Namespace Exports
|
|
249
|
+
|
|
250
|
+
Each protocol namespace exports:
|
|
251
|
+
- **Service Class**: `[Protocol]Service` (e.g., `Jupiter.JupiterService`)
|
|
252
|
+
- **Configuration Types**: Protocol-specific config interfaces
|
|
253
|
+
- **Request/Response Types**: All API-related types
|
|
254
|
+
- **Internal Types**: Advanced types for protocol-specific development
|
|
255
|
+
|
|
256
|
+
```typescript
|
|
257
|
+
// Example: All available exports from Jupiter namespace
|
|
258
|
+
import {
|
|
259
|
+
JupiterService, // Service class
|
|
260
|
+
type JupiterConfig, // Configuration
|
|
261
|
+
type JupiterPriceResponse,// Response types
|
|
262
|
+
type JupiterSwapRoutePlan,// Internal types
|
|
263
|
+
// ... and more
|
|
264
|
+
} from 'genius-intents';
|
|
265
|
+
|
|
266
|
+
const { JupiterService } = Jupiter; // Alternative access
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
### Response Structure
|
|
270
|
+
|
|
271
|
+
Both `fetchPrice()` and `fetchQuote()` return an `IntentsProtocolsResults` object:
|
|
272
|
+
|
|
273
|
+
```typescript
|
|
274
|
+
type IntentsProtocolsResults<T> = {
|
|
275
|
+
result?: T; // Best/fastest result based on method
|
|
276
|
+
allResults: Array<{ // All protocol results
|
|
277
|
+
protocol: ProtocolEnum;
|
|
278
|
+
response?: T;
|
|
279
|
+
error?: Error;
|
|
280
|
+
duration: number;
|
|
281
|
+
}>;
|
|
282
|
+
method: 'race' | 'best'; // Execution method used
|
|
283
|
+
totalDuration: number; // Total execution time
|
|
284
|
+
};
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
### Supported Chains
|
|
288
|
+
|
|
289
|
+
The SDK supports multiple blockchain networks. Chain IDs are numeric values:
|
|
290
|
+
|
|
291
|
+
```typescript
|
|
292
|
+
enum ChainIdEnum {
|
|
293
|
+
SOLANA = 1399811149,
|
|
294
|
+
AVALANCHE = 43114,
|
|
295
|
+
SONIC = 146,
|
|
296
|
+
BSC = 56,
|
|
297
|
+
BASE = 8453,
|
|
298
|
+
SUI = 101,
|
|
299
|
+
ARBITRUM = 42161,
|
|
300
|
+
OPTIMISM = 10,
|
|
301
|
+
BLAST = 81457,
|
|
302
|
+
POLYGON = 137,
|
|
303
|
+
ETHEREUM = 1,
|
|
304
|
+
APTOS = 999,
|
|
305
|
+
}
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
## 🧪 Testing
|
|
309
|
+
|
|
310
|
+
```bash
|
|
311
|
+
# Run all tests
|
|
312
|
+
npm test
|
|
313
|
+
|
|
314
|
+
# Run specific test suites
|
|
315
|
+
npm run test:unit # Unit tests
|
|
316
|
+
npm run test:integration # Integration tests
|
|
317
|
+
npm run test:protocols # Protocol-specific tests
|
|
318
|
+
|
|
319
|
+
# Run with coverage
|
|
320
|
+
npm run test:coverage
|
|
321
|
+
|
|
322
|
+
# Watch mode
|
|
323
|
+
npm run test:watch
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
## 🛠️ Development
|
|
327
|
+
|
|
328
|
+
```bash
|
|
329
|
+
# Install dependencies
|
|
330
|
+
npm install
|
|
331
|
+
|
|
332
|
+
# Build the project
|
|
333
|
+
npm run build
|
|
334
|
+
|
|
335
|
+
# Run linting
|
|
336
|
+
npm run lint
|
|
337
|
+
|
|
338
|
+
# Format code
|
|
339
|
+
npm run format
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
## 📝 Examples
|
|
343
|
+
|
|
344
|
+
Check out the `/tests` directory for comprehensive examples of how to use each protocol service.
|
|
345
|
+
|
|
346
|
+
## 🤝 Contributing
|
|
347
|
+
|
|
348
|
+
1. Fork the repository
|
|
349
|
+
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
|
|
350
|
+
3. Commit your changes (`git commit -m 'Add some amazing feature'`)
|
|
351
|
+
4. Push to the branch (`git push origin feature/amazing-feature`)
|
|
352
|
+
5. Open a Pull Request
|
|
353
|
+
|
|
354
|
+
## 📄 License
|
|
355
|
+
|
|
356
|
+
This project is licensed under the ISC License - see the [LICENSE](LICENSE) file for details.
|
|
357
|
+
|
|
358
|
+
## 🔗 Links
|
|
359
|
+
|
|
360
|
+
- [GitHub Repository](https://github.com/Genius-Foundation/genius-intents)
|
|
361
|
+
- [Issues](https://github.com/Genius-Foundation/genius-intents/issues)
|
|
362
|
+
- [NPM Package](https://www.npmjs.com/package/genius-intents)
|
|
363
|
+
|
|
364
|
+
## ⚠️ Disclaimer
|
|
365
|
+
|
|
366
|
+
This SDK is provided as-is. Always verify transactions and test thoroughly before using in production. DeFi protocols carry inherent risks including but not limited to smart contract risks, impermanent loss, and market volatility.
|
|
367
|
+
|
|
368
|
+
## 📞 Support
|
|
369
|
+
|
|
370
|
+
For support, questions, or feature requests:
|
|
371
|
+
- Open an issue on [GitHub](https://github.com/Genius-Foundation/genius-intents/issues)
|
|
372
|
+
- Contact the development team
|
|
373
|
+
|
|
374
|
+
---
|
|
375
|
+
|
|
376
|
+
**Built with ❤️ by the Shuttle Labs team**
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export * as Jupiter from './protocols/jupiter';
|
|
2
|
+
export * as Okx from './protocols/okx';
|
|
3
|
+
export * as Raydium from './protocols/raydium';
|
|
4
|
+
export * as Odos from './protocols/odos';
|
|
5
|
+
export * as PumpFun from './protocols/pumpfun';
|
|
6
|
+
export * as Kyberswap from './protocols/kyberswap';
|
|
7
|
+
export * as OpenOcean from './protocols/openocean';
|
|
8
|
+
export * as Aftermath from './protocols/aftermath';
|
|
9
|
+
export * as ZeroX from './protocols/zeroX';
|
|
10
|
+
export * as DeBridge from './protocols/debridge';
|
|
11
|
+
export * as GeniusBridge from './protocols/genius-bridge';
|
|
12
|
+
import { ChainIdEnum, ProtocolEnum, SdkErrorEnum, ChainVmTypeEnum } from './types/enums';
|
|
13
|
+
import { IntentPriceParams } from './types/price-params';
|
|
14
|
+
import { PriceResponse, RawProtocolPriceResponse } from './types/price-response';
|
|
15
|
+
import { IntentQuoteParams } from './types/quote-params';
|
|
16
|
+
import { QuoteResponse, RawProtocolQuoteResponse } from './types/quote-response';
|
|
17
|
+
import { IntentsSDKConfig } from './types/sdk-config';
|
|
18
|
+
import { IntentsProtocols } from './intents-protocols';
|
|
19
|
+
import { IntentsProtocolsConfig, IntentsProtocolsResults, IntentPriceResult, IntentQuoteResult } from './types/intents-protocols';
|
|
20
|
+
import { IIntentProtocol } from './interfaces/intent-protocol';
|
|
21
|
+
import { QuoteExecutionPayload, EvmQuoteExecutionPayload, SolanaQuoteExecutionPayload } from './types/quote-execution-payload';
|
|
22
|
+
import { EvmTransactionData } from './types/evm-transaction-data';
|
|
23
|
+
import { SolanaTransactionData } from './types/solana-transaction-data';
|
|
24
|
+
import { Erc20Approval } from './types/erc20-approval';
|
|
25
|
+
import { ILogger, LogLevelEnum, LoggerFactory, ConsoleLogger, NoOpLogger } from './utils/logger';
|
|
26
|
+
export { IntentsProtocols, IntentsProtocolsConfig, IntentsSDKConfig, IntentsProtocolsResults, IntentPriceResult, IntentQuoteResult, PriceResponse, QuoteResponse, RawProtocolPriceResponse, RawProtocolQuoteResponse, IntentPriceParams, IntentQuoteParams, QuoteExecutionPayload, EvmQuoteExecutionPayload, SolanaQuoteExecutionPayload, EvmTransactionData, SolanaTransactionData, Erc20Approval, ChainIdEnum, ProtocolEnum, SdkErrorEnum, ChainVmTypeEnum, LogLevelEnum, IIntentProtocol, ILogger, LoggerFactory, ConsoleLogger, NoOpLogger, };
|
|
27
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,OAAO,MAAM,qBAAqB,CAAC;AAC/C,OAAO,KAAK,GAAG,MAAM,iBAAiB,CAAC;AACvC,OAAO,KAAK,OAAO,MAAM,qBAAqB,CAAC;AAC/C,OAAO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,EAAE,MAAM,gBAAgB,CAAC;AAEjG,OAAO,EAEL,gBAAgB,EAGhB,sBAAsB,EACtB,gBAAgB,EAGhB,uBAAuB,EACvB,iBAAiB,EACjB,iBAAiB,EACjB,aAAa,EACb,aAAa,EACb,wBAAwB,EACxB,wBAAwB,EAGxB,iBAAiB,EACjB,iBAAiB,EAGjB,qBAAqB,EACrB,wBAAwB,EACxB,2BAA2B,EAC3B,kBAAkB,EAClB,qBAAqB,EACrB,aAAa,EAGb,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,eAAe,EACf,YAAY,EAGZ,eAAe,EAGf,OAAO,EACP,aAAa,EACb,aAAa,EACb,UAAU,GACX,CAAC"}
|
|
@@ -0,0 +1,62 @@
|
|
|
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.NoOpLogger = exports.ConsoleLogger = exports.LoggerFactory = exports.LogLevelEnum = exports.ChainVmTypeEnum = exports.SdkErrorEnum = exports.ProtocolEnum = exports.ChainIdEnum = exports.IntentsProtocols = exports.GeniusBridge = exports.DeBridge = exports.ZeroX = exports.Aftermath = exports.OpenOcean = exports.Kyberswap = exports.PumpFun = exports.Odos = exports.Raydium = exports.Okx = exports.Jupiter = void 0;
|
|
37
|
+
// Protocol imports from their index files
|
|
38
|
+
exports.Jupiter = __importStar(require("./protocols/jupiter"));
|
|
39
|
+
exports.Okx = __importStar(require("./protocols/okx"));
|
|
40
|
+
exports.Raydium = __importStar(require("./protocols/raydium"));
|
|
41
|
+
exports.Odos = __importStar(require("./protocols/odos"));
|
|
42
|
+
exports.PumpFun = __importStar(require("./protocols/pumpfun"));
|
|
43
|
+
exports.Kyberswap = __importStar(require("./protocols/kyberswap"));
|
|
44
|
+
exports.OpenOcean = __importStar(require("./protocols/openocean"));
|
|
45
|
+
exports.Aftermath = __importStar(require("./protocols/aftermath"));
|
|
46
|
+
exports.ZeroX = __importStar(require("./protocols/zeroX"));
|
|
47
|
+
exports.DeBridge = __importStar(require("./protocols/debridge"));
|
|
48
|
+
exports.GeniusBridge = __importStar(require("./protocols/genius-bridge"));
|
|
49
|
+
// Core types and utilities
|
|
50
|
+
const enums_1 = require("./types/enums");
|
|
51
|
+
Object.defineProperty(exports, "ChainIdEnum", { enumerable: true, get: function () { return enums_1.ChainIdEnum; } });
|
|
52
|
+
Object.defineProperty(exports, "ProtocolEnum", { enumerable: true, get: function () { return enums_1.ProtocolEnum; } });
|
|
53
|
+
Object.defineProperty(exports, "SdkErrorEnum", { enumerable: true, get: function () { return enums_1.SdkErrorEnum; } });
|
|
54
|
+
Object.defineProperty(exports, "ChainVmTypeEnum", { enumerable: true, get: function () { return enums_1.ChainVmTypeEnum; } });
|
|
55
|
+
const intents_protocols_1 = require("./intents-protocols");
|
|
56
|
+
Object.defineProperty(exports, "IntentsProtocols", { enumerable: true, get: function () { return intents_protocols_1.IntentsProtocols; } });
|
|
57
|
+
const logger_1 = require("./utils/logger");
|
|
58
|
+
Object.defineProperty(exports, "LogLevelEnum", { enumerable: true, get: function () { return logger_1.LogLevelEnum; } });
|
|
59
|
+
Object.defineProperty(exports, "LoggerFactory", { enumerable: true, get: function () { return logger_1.LoggerFactory; } });
|
|
60
|
+
Object.defineProperty(exports, "ConsoleLogger", { enumerable: true, get: function () { return logger_1.ConsoleLogger; } });
|
|
61
|
+
Object.defineProperty(exports, "NoOpLogger", { enumerable: true, get: function () { return logger_1.NoOpLogger; } });
|
|
62
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0CAA0C;AAC1C,+DAA+C;AAC/C,uDAAuC;AACvC,+DAA+C;AAC/C,yDAAyC;AACzC,+DAA+C;AAC/C,mEAAmD;AACnD,mEAAmD;AACnD,mEAAmD;AACnD,2DAA2C;AAC3C,iEAAiD;AACjD,0EAA0D;AAE1D,2BAA2B;AAC3B,yCAAyF;AAsDvF,4FAtDO,mBAAW,OAsDP;AACX,6FAvDoB,oBAAY,OAuDpB;AACZ,6FAxDkC,oBAAY,OAwDlC;AACZ,gGAzDgD,uBAAe,OAyDhD;AAnDjB,2DAAuD;AAoBrD,iGApBO,oCAAgB,OAoBP;AAJlB,2CAAiG;AAoC/F,6FApCgB,qBAAY,OAoChB;AAOZ,8FA3C8B,sBAAa,OA2C9B;AACb,8FA5C6C,sBAAa,OA4C7C;AACb,2FA7C4D,mBAAU,OA6C5D"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { IIntentProtocol } from './interfaces/intent-protocol';
|
|
2
|
+
import { IntentPriceParams } from './types/price-params';
|
|
3
|
+
import { IntentQuoteParams } from './types/quote-params';
|
|
4
|
+
import { PriceResponse } from './types/price-response';
|
|
5
|
+
import { QuoteResponse } from './types/quote-response';
|
|
6
|
+
import { ProtocolEnum } from './types/enums';
|
|
7
|
+
import { IntentsProtocolsConfig, IntentPriceResult, IntentQuoteResult, IntentsProtocolsResults, IntentRaceExecutionResult } from './types/intents-protocols';
|
|
8
|
+
export declare class IntentsProtocols {
|
|
9
|
+
protected config: IntentsProtocolsConfig;
|
|
10
|
+
protected protocols: Map<ProtocolEnum, IIntentProtocol>;
|
|
11
|
+
constructor(config?: IntentsProtocolsConfig);
|
|
12
|
+
/**
|
|
13
|
+
* Initialize all available protocol instances
|
|
14
|
+
*/
|
|
15
|
+
protected initializeProtocols(): void;
|
|
16
|
+
/**
|
|
17
|
+
* Safely create a protocol instance, handling potential errors
|
|
18
|
+
*/
|
|
19
|
+
protected createProtocolSafely(factory: () => IIntentProtocol, protocolName: string): IIntentProtocol | null;
|
|
20
|
+
/**
|
|
21
|
+
* Get compatible protocols for the given parameters
|
|
22
|
+
*/
|
|
23
|
+
protected getCompatibleProtocols(params: IntentPriceParams | IntentQuoteParams): IIntentProtocol[];
|
|
24
|
+
/**
|
|
25
|
+
* Execute price requests across compatible protocols
|
|
26
|
+
*/
|
|
27
|
+
fetchPrice(params: IntentPriceParams): Promise<IntentsProtocolsResults<PriceResponse>>;
|
|
28
|
+
/**
|
|
29
|
+
* Execute quote requests across compatible protocols
|
|
30
|
+
*/
|
|
31
|
+
fetchQuote(params: IntentQuoteParams): Promise<IntentsProtocolsResults<QuoteResponse>>;
|
|
32
|
+
/**
|
|
33
|
+
* Execute a single price request with timeout and error handling
|
|
34
|
+
*/
|
|
35
|
+
protected executePriceRequest(protocol: IIntentProtocol, params: IntentPriceParams): Promise<IntentPriceResult>;
|
|
36
|
+
/**
|
|
37
|
+
* Execute a single quote request with timeout and error handling
|
|
38
|
+
*/
|
|
39
|
+
protected executeQuoteRequest(protocol: IIntentProtocol, params: IntentQuoteParams): Promise<IntentQuoteResult>;
|
|
40
|
+
/**
|
|
41
|
+
* Execute all promises and wait for completion
|
|
42
|
+
*/
|
|
43
|
+
protected executeAll<T>(promises: Promise<T>[]): Promise<T[]>;
|
|
44
|
+
/**
|
|
45
|
+
* Execute promises in race mode, but also collect all results
|
|
46
|
+
*/
|
|
47
|
+
protected executeRace<T extends IntentPriceResult | IntentQuoteResult>(promises: Promise<T>[]): Promise<IntentRaceExecutionResult<T>>;
|
|
48
|
+
/**
|
|
49
|
+
* Select the best price response based on output amount
|
|
50
|
+
*/
|
|
51
|
+
protected selectBestPriceResponse(results: IntentPriceResult[]): PriceResponse | undefined;
|
|
52
|
+
/**
|
|
53
|
+
* Select the best quote response based on output amount
|
|
54
|
+
*/
|
|
55
|
+
protected selectBestQuoteResponse(results: IntentQuoteResult[]): QuoteResponse | undefined;
|
|
56
|
+
/**
|
|
57
|
+
* Get list of initialized protocols
|
|
58
|
+
*/
|
|
59
|
+
getInitializedProtocols(): ProtocolEnum[];
|
|
60
|
+
/**
|
|
61
|
+
* Get a specific protocol instance
|
|
62
|
+
*/
|
|
63
|
+
getProtocol(protocol: ProtocolEnum): IIntentProtocol | undefined;
|
|
64
|
+
/**
|
|
65
|
+
* Update configuration
|
|
66
|
+
*/
|
|
67
|
+
updateConfig(config: Partial<IntentsProtocolsConfig>): void;
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=intents-protocols.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,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