@debridge-finance/intents-client 1.0.0-dev.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,103 @@
1
+ # Intents Client SDK
2
+
3
+ SDK for working with the intents program in Solana. Allows creating, managing, and executing intents for cross-chain operations.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @debridge-finance/intents-client
9
+ ```
10
+
11
+ ## File Structure and Usage Flow
12
+
13
+ The examples folder contains a sequence of files that demonstrate the complete workflow for using the Intents Client SDK. Each file represents a specific step in the process:
14
+
15
+ ### 1. `01-init-intent-client.ts` - Client Initialization
16
+
17
+ **Purpose**: Sets up the basic client configuration
18
+ **Contains**:
19
+
20
+ - `new IntentsClient()` - Instantiates the intents client
21
+
22
+ ### 2. `02-init-intent.ts` - Intent Configuration
23
+
24
+ **Purpose**: Defines the intent structure and parameters
25
+ **Contains**:
26
+
27
+ - No client methods called
28
+
29
+ ### 3. `03-create-intent.ts` - Intent Creation and Deployment
30
+
31
+ **Purpose**: Creates and deploys the intent to the blockchain
32
+ **Contains**:
33
+
34
+ - `client.createAndUpdateIntentTxs()` - Creates single transaction (preferred)
35
+ - `client.createIntentTxs()` - Creates multiple transactions (fallback)
36
+
37
+ ### 4. `05-sandwich-swap.ts` - Swap Execution
38
+
39
+ **Purpose**: Performs token swaps using the created intent
40
+ **Contains**:
41
+
42
+ - `client.swapTxs()` - Generates swap transaction
43
+
44
+ ### 5. `06-intent-execution.ts` - Intent Execution
45
+
46
+ **Purpose**: Final step of executing the intent through DLN
47
+ **Contains**:
48
+
49
+ - `client.executeIntentIxs()` - Generates execution instructions
50
+
51
+ ## Call Sequence
52
+
53
+ ### Step-by-Step Execution Flow:
54
+
55
+ 1. **Initialize Client** (`01-init-intent-client.ts`)
56
+ - Create Solana connection
57
+ - Generate keypair
58
+ - Instantiate IntentsClient
59
+
60
+ 2. **Configure Intent** (`02-init-intent.ts`)
61
+ - Define Intent object with all parameters
62
+ - Set token addresses, amounts, and cross-chain details
63
+
64
+ 3. **Deploy Intent** (`03-create-intent.ts`)
65
+ - Serialize intent data
66
+ - Try single transaction creation
67
+ - Fall back to multi-transaction if needed
68
+ - Send transactions to blockchain
69
+
70
+ 4. **Authorize Tokens** (`04-give-token-approval.ts`)
71
+ - Generate approval instructions for protocol transfers
72
+
73
+ 5. **Execute Swap** (`05-sandwich-swap.ts`)
74
+ - Set up token accounts
75
+ - Create swap transaction with intent
76
+ - Execute the swap
77
+
78
+ 6. **Complete Intent** (`06-intent-execution.ts`)
79
+ - Initialize DLN client
80
+ - Create cross-chain order
81
+ - Generate final execution instructions
82
+
83
+ ## IntentsClient methods
84
+
85
+ - getState()
86
+ - getIntentStorage()
87
+ - executeIntentIxs()
88
+ - initIntentIxs()
89
+ - initIntentUsingSigIxs()
90
+ - setDelegateApprovedBudgetsIxs()
91
+ - swapBeginIxs()
92
+ - swapEndIxs()
93
+ - updateIntentIxs()
94
+ - closeRecordIxs()
95
+ - writeRecordIxs()
96
+ - reallocRecordIxs()
97
+ - initIntentTxs()
98
+ - writeIntentTxs()
99
+ - createIntentTxs()
100
+ - createAndUpdateIntentTxs()
101
+ - updateRecordTxs()
102
+ - closeIntentTxs()
103
+ - swapTxs()