@hot-pot/hotpot-sdk-ts 0.0.1 → 0.0.3
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/dist/apiClient.d.ts +4 -3
- package/dist/apiClient.js +17 -3
- package/dist/types.d.ts +2 -0
- package/examples/intent/main.ts +4 -1
- package/package.json +1 -1
- package/src/apiClient.ts +18 -4
- package/src/types.ts +2 -0
package/dist/apiClient.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AxiosInstance, AxiosRequestConfig } from 'axios';
|
|
2
|
-
import type { CreateIntentData, IntentStatus, Network, PaginatedResponse, PublicSwapWithAdditionalInfo, Quote, SignedApproval, SwapType, Token } from './types';
|
|
2
|
+
import type { CreateIntentData, DepositType, IntentStatus, Network, PaginatedResponse, PublicSwapWithAdditionalInfo, Quote, SignedApproval, SwapType, Token } from './types';
|
|
3
3
|
export declare class HotPotApiClient {
|
|
4
4
|
private client;
|
|
5
5
|
constructor(apiUrl: string, apiKey: string, axiosInstance?: AxiosInstance, config?: AxiosRequestConfig);
|
|
@@ -13,9 +13,10 @@ export declare class HotPotApiClient {
|
|
|
13
13
|
* @param slippageBps The slippage in basis points
|
|
14
14
|
* @param swapType The type of swap
|
|
15
15
|
* @param retailUserId Optional retail user ID
|
|
16
|
+
* @param depositType The type of deposit to perform (escrowed/direct)
|
|
16
17
|
* @returns A promise that resolves to the Quote object
|
|
17
18
|
*/
|
|
18
|
-
getQuote(sourceChain: number, sourceToken: string, destChain: number, destToken: string, amount: number, slippageBps: bigint, swapType: SwapType, retailUserId
|
|
19
|
+
getQuote(sourceChain: number, sourceToken: string, destChain: number, destToken: string, amount: number, slippageBps: bigint, swapType: SwapType, retailUserId: string | null | undefined, depositType: DepositType): Promise<Quote>;
|
|
19
20
|
/**
|
|
20
21
|
* Creates a new swap intent with the provided details
|
|
21
22
|
* @param quoteId The quote ID to use for the intent
|
|
@@ -52,7 +53,7 @@ export declare class HotPotApiClient {
|
|
|
52
53
|
* @param active Whether to show only active swaps (default: false)
|
|
53
54
|
* @returns A promise that resolves to a paginated response of PublicSwapWithAdditionalInfo objects
|
|
54
55
|
*/
|
|
55
|
-
listRetailUserHistory(
|
|
56
|
+
listRetailUserHistory(walletAddresses: string[], retailId: string | null, limit?: number, offset?: number, active?: boolean): Promise<PaginatedResponse<PublicSwapWithAdditionalInfo>>;
|
|
56
57
|
/**
|
|
57
58
|
* Retrieves swap details by intent ID
|
|
58
59
|
* @param intentId The intent ID to retrieve swap details for
|
package/dist/apiClient.js
CHANGED
|
@@ -22,9 +22,10 @@ export class HotPotApiClient {
|
|
|
22
22
|
* @param slippageBps The slippage in basis points
|
|
23
23
|
* @param swapType The type of swap
|
|
24
24
|
* @param retailUserId Optional retail user ID
|
|
25
|
+
* @param depositType The type of deposit to perform (escrowed/direct)
|
|
25
26
|
* @returns A promise that resolves to the Quote object
|
|
26
27
|
*/
|
|
27
|
-
async getQuote(sourceChain, sourceToken, destChain, destToken, amount, slippageBps, swapType, retailUserId = null) {
|
|
28
|
+
async getQuote(sourceChain, sourceToken, destChain, destToken, amount, slippageBps, swapType, retailUserId = null, depositType) {
|
|
28
29
|
const response = await this.client.post('/quotes/best', {
|
|
29
30
|
source_chain: sourceChain,
|
|
30
31
|
source_token: sourceToken,
|
|
@@ -34,6 +35,7 @@ export class HotPotApiClient {
|
|
|
34
35
|
slippage_bps: slippageBps.toString(),
|
|
35
36
|
swap_type: swapType,
|
|
36
37
|
retail_user_id: retailUserId,
|
|
38
|
+
deposit_type: depositType,
|
|
37
39
|
});
|
|
38
40
|
return response.data;
|
|
39
41
|
}
|
|
@@ -90,8 +92,20 @@ export class HotPotApiClient {
|
|
|
90
92
|
* @param active Whether to show only active swaps (default: false)
|
|
91
93
|
* @returns A promise that resolves to a paginated response of PublicSwapWithAdditionalInfo objects
|
|
92
94
|
*/
|
|
93
|
-
async listRetailUserHistory(
|
|
94
|
-
|
|
95
|
+
async listRetailUserHistory(walletAddresses, retailId, limit = 20, offset = 0, active = false) {
|
|
96
|
+
let walletAddressesQuery;
|
|
97
|
+
if (walletAddresses.length > 0) {
|
|
98
|
+
walletAddressesQuery = 'wallet=' + walletAddresses.join('&wallet=');
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
walletAddressesQuery = '';
|
|
102
|
+
}
|
|
103
|
+
let url = '/swaps/history?';
|
|
104
|
+
url += walletAddressesQuery;
|
|
105
|
+
if (retailId) {
|
|
106
|
+
url += `&retail_id=${retailId}`;
|
|
107
|
+
}
|
|
108
|
+
const response = await this.client.get(`${url}&limit=${limit}&offset=${offset}&active=${active}`);
|
|
95
109
|
return response.data;
|
|
96
110
|
}
|
|
97
111
|
/**
|
package/dist/types.d.ts
CHANGED
|
@@ -40,6 +40,7 @@ export interface Quote {
|
|
|
40
40
|
slippage_bps: string;
|
|
41
41
|
expiry: number;
|
|
42
42
|
swap_type: SwapType;
|
|
43
|
+
deposit_type: DepositType;
|
|
43
44
|
}
|
|
44
45
|
export interface CreateIntentData {
|
|
45
46
|
intent_id: string;
|
|
@@ -49,6 +50,7 @@ export interface CreateIntentData {
|
|
|
49
50
|
params_to_sign: Permit2ApprovalToSign | HtlcApprovalToSign | CosignApprovalToSign;
|
|
50
51
|
}
|
|
51
52
|
export type ApprovalType = 'permit2' | 'psbt' | 'cosign';
|
|
53
|
+
export type DepositType = 'escrowed' | 'direct';
|
|
52
54
|
export interface CosignData {
|
|
53
55
|
transaction: string;
|
|
54
56
|
user_address: string;
|
package/examples/intent/main.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { HotPotApiClient } from '../../src/apiClient.js';
|
|
2
2
|
import { preparePermit2Approval } from '../../src/approvals.js';
|
|
3
|
-
import { SwapType } from '../../src/types.js';
|
|
3
|
+
import { type DepositType, SwapType } from '../../src/types.js';
|
|
4
4
|
|
|
5
5
|
async function main() {
|
|
6
6
|
// Initialize the HotPot API client with the API key from environment variables
|
|
@@ -19,6 +19,7 @@ async function main() {
|
|
|
19
19
|
const amount = 1_000_000; // Amount in USD (or base units depending on token)
|
|
20
20
|
const slippageBps = 50n; // 0.5% slippage
|
|
21
21
|
const swapType = SwapType.Optimized;
|
|
22
|
+
const depositType: DepositType = 'escrowed';
|
|
22
23
|
|
|
23
24
|
// Get a quote for the swap
|
|
24
25
|
console.log('Getting quote...');
|
|
@@ -30,6 +31,8 @@ async function main() {
|
|
|
30
31
|
amount,
|
|
31
32
|
slippageBps,
|
|
32
33
|
swapType,
|
|
34
|
+
null,
|
|
35
|
+
depositType,
|
|
33
36
|
);
|
|
34
37
|
console.log('Quote received:', quote);
|
|
35
38
|
|
package/package.json
CHANGED
package/src/apiClient.ts
CHANGED
|
@@ -3,6 +3,7 @@ import axios from 'axios';
|
|
|
3
3
|
|
|
4
4
|
import type {
|
|
5
5
|
CreateIntentData,
|
|
6
|
+
DepositType,
|
|
6
7
|
IntentStatus,
|
|
7
8
|
Network,
|
|
8
9
|
PaginatedResponse,
|
|
@@ -43,6 +44,7 @@ export class HotPotApiClient {
|
|
|
43
44
|
* @param slippageBps The slippage in basis points
|
|
44
45
|
* @param swapType The type of swap
|
|
45
46
|
* @param retailUserId Optional retail user ID
|
|
47
|
+
* @param depositType The type of deposit to perform (escrowed/direct)
|
|
46
48
|
* @returns A promise that resolves to the Quote object
|
|
47
49
|
*/
|
|
48
50
|
async getQuote(
|
|
@@ -54,6 +56,7 @@ export class HotPotApiClient {
|
|
|
54
56
|
slippageBps: bigint,
|
|
55
57
|
swapType: SwapType,
|
|
56
58
|
retailUserId: string | null = null,
|
|
59
|
+
depositType: DepositType,
|
|
57
60
|
): Promise<Quote> {
|
|
58
61
|
const response: AxiosResponse<Quote> = await this.client.post('/quotes/best', {
|
|
59
62
|
source_chain: sourceChain,
|
|
@@ -64,6 +67,7 @@ export class HotPotApiClient {
|
|
|
64
67
|
slippage_bps: slippageBps.toString(),
|
|
65
68
|
swap_type: swapType,
|
|
66
69
|
retail_user_id: retailUserId,
|
|
70
|
+
deposit_type: depositType,
|
|
67
71
|
});
|
|
68
72
|
|
|
69
73
|
return response.data;
|
|
@@ -140,15 +144,25 @@ export class HotPotApiClient {
|
|
|
140
144
|
* @returns A promise that resolves to a paginated response of PublicSwapWithAdditionalInfo objects
|
|
141
145
|
*/
|
|
142
146
|
async listRetailUserHistory(
|
|
143
|
-
|
|
147
|
+
walletAddresses: string[],
|
|
148
|
+
retailId: string | null,
|
|
144
149
|
limit: number = 20,
|
|
145
150
|
offset: number = 0,
|
|
146
151
|
active: boolean = false,
|
|
147
152
|
): Promise<PaginatedResponse<PublicSwapWithAdditionalInfo>> {
|
|
153
|
+
let walletAddressesQuery;
|
|
154
|
+
if (walletAddresses.length > 0) {
|
|
155
|
+
walletAddressesQuery = 'wallet=' + walletAddresses.join('&wallet=');
|
|
156
|
+
} else {
|
|
157
|
+
walletAddressesQuery = '';
|
|
158
|
+
}
|
|
159
|
+
let url = '/swaps/history?';
|
|
160
|
+
url += walletAddressesQuery;
|
|
161
|
+
if (retailId) {
|
|
162
|
+
url += `&retail_id=${retailId}`;
|
|
163
|
+
}
|
|
148
164
|
const response: AxiosResponse<PaginatedResponse<PublicSwapWithAdditionalInfo>> =
|
|
149
|
-
await this.client.get(
|
|
150
|
-
`/swaps/history/${walletAddressOrRetailId}?limit=${limit}&offset=${offset}&active=${active}`,
|
|
151
|
-
);
|
|
165
|
+
await this.client.get(`${url}&limit=${limit}&offset=${offset}&active=${active}`);
|
|
152
166
|
|
|
153
167
|
return response.data;
|
|
154
168
|
}
|
package/src/types.ts
CHANGED
|
@@ -43,6 +43,7 @@ export interface Quote {
|
|
|
43
43
|
slippage_bps: string;
|
|
44
44
|
expiry: number;
|
|
45
45
|
swap_type: SwapType;
|
|
46
|
+
deposit_type: DepositType;
|
|
46
47
|
}
|
|
47
48
|
|
|
48
49
|
export interface CreateIntentData {
|
|
@@ -54,6 +55,7 @@ export interface CreateIntentData {
|
|
|
54
55
|
}
|
|
55
56
|
|
|
56
57
|
export type ApprovalType = 'permit2' | 'psbt' | 'cosign';
|
|
58
|
+
export type DepositType = 'escrowed' | 'direct';
|
|
57
59
|
|
|
58
60
|
export interface CosignData {
|
|
59
61
|
transaction: string;
|