@bitflowlabs/core-sdk 2.0.2 → 2.1.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/src/BitflowSDK.d.ts +6 -4
- package/dist/src/BitflowSDK.js +439 -239
- package/dist/src/BitflowSDK.js.map +1 -1
- package/dist/src/helpers/callReadOnlyHelper.d.ts +7 -1
- package/dist/src/helpers/callReadOnlyHelper.js +201 -26
- package/dist/src/helpers/callReadOnlyHelper.js.map +1 -1
- package/dist/src/keeper/keeperAPI.js +3 -48
- package/dist/src/keeper/keeperAPI.js.map +1 -1
- package/dist/src/keeper/types.d.ts +27 -10
- package/dist/src/keeper/types.js.map +1 -1
- package/dist/src/test/testMethods.js +10 -0
- package/dist/src/test/testMethods.js.map +1 -1
- package/package.json +2 -1
- package/src/BitflowSDK.ts +532 -269
- package/src/helpers/callReadOnlyHelper.ts +258 -32
- package/src/keeper/keeperAPI.ts +5 -68
- package/src/keeper/types.ts +28 -11
- package/src/test/testMethods.ts +19 -0
- package/dist/src/test-get-user.d.ts +0 -1
- package/dist/src/test-get-user.js +0 -77
- package/dist/src/test-get-user.js.map +0 -1
- package/dist/src/test-keeper-routes.d.ts +0 -1
- package/dist/src/test-keeper-routes.js +0 -67
- package/dist/src/test-keeper-routes.js.map +0 -1
- package/dist/src/test-order.d.ts +0 -1
- package/dist/src/test-order.js +0 -71
- package/dist/src/test-order.js.map +0 -1
- package/dist/src/test-raw-token-response.d.ts +0 -1
- package/dist/src/test-raw-token-response.js +0 -79
- package/dist/src/test-raw-token-response.js.map +0 -1
- package/dist/src/test-sdk.d.ts +0 -1
- package/dist/src/test-sdk.js +0 -229
- package/dist/src/test-sdk.js.map +0 -1
- package/dist/src/test-token.fetch.d.ts +0 -1
- package/dist/src/test-token.fetch.js +0 -63
- package/dist/src/test-token.fetch.js.map +0 -1
- package/src/test-get-user.ts +0 -87
- package/src/test-keeper-routes.ts +0 -76
- package/src/test-order.ts +0 -81
- package/src/test-raw-token-response.ts +0 -124
- package/src/test-sdk.ts +0 -262
- package/src/test-token.fetch.ts +0 -72
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import { BitflowSDK } from "./BitflowSDK";
|
|
2
|
-
import dotenv from "dotenv";
|
|
3
|
-
|
|
4
|
-
dotenv.config();
|
|
5
|
-
|
|
6
|
-
async function testKeeperRoutes() {
|
|
7
|
-
const sdk = new BitflowSDK({
|
|
8
|
-
BITFLOW_API_HOST: process.env.BITFLOW_API_HOST!,
|
|
9
|
-
BITFLOW_API_KEY: process.env.BITFLOW_API_KEY!,
|
|
10
|
-
READONLY_CALL_API_HOST: process.env.READONLY_CALL_API_HOST!,
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
console.log("Testing Keeper Routes Functionality...\n");
|
|
14
|
-
|
|
15
|
-
// Test 1: Regular routes (without keeper parameter)
|
|
16
|
-
console.log("1. Testing regular routes for token-aeusdc...");
|
|
17
|
-
try {
|
|
18
|
-
const regularRoutes = await sdk.getPossibleSwaps("token-stx");
|
|
19
|
-
console.log("Regular routes count:", Object.keys(regularRoutes).length);
|
|
20
|
-
console.log(
|
|
21
|
-
"Sample of regular routes:",
|
|
22
|
-
JSON.stringify(Object.keys(regularRoutes).slice(0, 3), null, 2)
|
|
23
|
-
);
|
|
24
|
-
} catch (error) {
|
|
25
|
-
console.error("Error fetching regular routes:", error);
|
|
26
|
-
}
|
|
27
|
-
console.log("----------------------------------------\n");
|
|
28
|
-
|
|
29
|
-
// Test 2: Keeper routes
|
|
30
|
-
console.log("2. Testing keeper routes for token-aeusdc...");
|
|
31
|
-
try {
|
|
32
|
-
const keeperRoutes = await sdk.getKeeperPossibleSwaps("token-stx");
|
|
33
|
-
console.log("Keeper routes count:", Object.keys(keeperRoutes).length);
|
|
34
|
-
console.log(
|
|
35
|
-
"Sample of keeper routes:",
|
|
36
|
-
JSON.stringify(Object.keys(keeperRoutes).slice(0, 3), null, 2)
|
|
37
|
-
);
|
|
38
|
-
} catch (error) {
|
|
39
|
-
console.error("Error fetching keeper routes:", error);
|
|
40
|
-
}
|
|
41
|
-
console.log("----------------------------------------\n");
|
|
42
|
-
|
|
43
|
-
// Test 3: Compare routes
|
|
44
|
-
console.log("3. Comparing regular vs keeper routes...");
|
|
45
|
-
try {
|
|
46
|
-
const regularRoutes = await sdk.getPossibleSwaps("token-stx");
|
|
47
|
-
const keeperRoutes = await sdk.getKeeperPossibleSwaps("token-stx");
|
|
48
|
-
|
|
49
|
-
console.log("Regular routes count:", Object.keys(regularRoutes).length);
|
|
50
|
-
console.log("Keeper routes count:", Object.keys(keeperRoutes).length);
|
|
51
|
-
|
|
52
|
-
// Compare the first route's structure
|
|
53
|
-
const firstRegularTokenY = Object.keys(regularRoutes)[0];
|
|
54
|
-
const firstKeeperTokenY = Object.keys(keeperRoutes)[0];
|
|
55
|
-
|
|
56
|
-
if (firstRegularTokenY && firstKeeperTokenY) {
|
|
57
|
-
console.log("\nSample Regular Route Structure:", {
|
|
58
|
-
tokenY: firstRegularTokenY,
|
|
59
|
-
routeCount: regularRoutes[firstRegularTokenY].length,
|
|
60
|
-
firstRouteDexPath: regularRoutes[firstRegularTokenY][0]?.dex_path,
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
console.log("\nSample Keeper Route Structure:", {
|
|
64
|
-
tokenY: firstKeeperTokenY,
|
|
65
|
-
routeCount: keeperRoutes[firstKeeperTokenY].length,
|
|
66
|
-
firstRouteDexPath: keeperRoutes[firstKeeperTokenY][0]?.dex_path,
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
} catch (error) {
|
|
70
|
-
console.error("Error comparing routes:", error);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
testKeeperRoutes()
|
|
75
|
-
.then(() => console.log("\nAll tests completed"))
|
|
76
|
-
.catch(console.error);
|
package/src/test-order.ts
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import { BitflowSDK } from "./BitflowSDK";
|
|
2
|
-
import { CreateOrderParams, KeeperType, ActionType } from "./keeper/types";
|
|
3
|
-
import dotenv from "dotenv";
|
|
4
|
-
|
|
5
|
-
dotenv.config();
|
|
6
|
-
|
|
7
|
-
async function testCreateOrder() {
|
|
8
|
-
console.log("Starting Order Creation Test...\n");
|
|
9
|
-
|
|
10
|
-
const sdk = new BitflowSDK({
|
|
11
|
-
BITFLOW_API_HOST: process.env.BITFLOW_API_HOST!,
|
|
12
|
-
BITFLOW_API_KEY: process.env.BITFLOW_API_KEY!,
|
|
13
|
-
READONLY_CALL_API_HOST: process.env.READONLY_CALL_API_HOST!,
|
|
14
|
-
KEEPER_API_KEY: process.env.KEEPER_API_KEY!,
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
try {
|
|
18
|
-
// First get a keeper contract
|
|
19
|
-
console.log("Getting keeper contract...");
|
|
20
|
-
const keeperContractResponse = await sdk.getOrCreateKeeperContract({
|
|
21
|
-
stacksAddress: "SP228WEAEMYX21RW0TT5T38THPNDYPPGGVW2RP570",
|
|
22
|
-
keeperType: KeeperType.MULTI_ACTION_V1,
|
|
23
|
-
allActionsApproved: true,
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
if (!keeperContractResponse.keeperContract.contractIdentifier) {
|
|
27
|
-
throw new Error("Failed to get keeper contract identifier");
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
console.log("\nCreating order with the following parameters:");
|
|
31
|
-
const orderParams: CreateOrderParams = {
|
|
32
|
-
stacksAddress: "SP228WEAEMYX21RW0TT5T38THPNDYPPGGVW2RP570",
|
|
33
|
-
keeperType: KeeperType.MULTI_ACTION_V1,
|
|
34
|
-
contractIdentifier:
|
|
35
|
-
keeperContractResponse.keeperContract.contractIdentifier,
|
|
36
|
-
actionAmount: "100000000", // 1 BTC
|
|
37
|
-
feeRecipient: "SP16BPKS1DN5AYQ5MDHFEYXTSP352QG6JS2E0N8YP",
|
|
38
|
-
actionType: ActionType.SWAP_XYK_SWAP_HELPER,
|
|
39
|
-
bitcoinTxId:
|
|
40
|
-
"9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08",
|
|
41
|
-
minReceived: {
|
|
42
|
-
amount: "0",
|
|
43
|
-
autoAdjust: true,
|
|
44
|
-
},
|
|
45
|
-
actionAggregatorTokens: {
|
|
46
|
-
tokenXId: "token-pbtc",
|
|
47
|
-
tokenYId: "token-stx",
|
|
48
|
-
},
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
console.log("Order Parameters:", JSON.stringify(orderParams, null, 2));
|
|
52
|
-
|
|
53
|
-
console.log("\nSubmitting order...");
|
|
54
|
-
const createOrderResponse = await sdk.createOrder(orderParams);
|
|
55
|
-
|
|
56
|
-
console.log(
|
|
57
|
-
"\nOrder Creation Response:",
|
|
58
|
-
JSON.stringify(createOrderResponse, null, 2)
|
|
59
|
-
);
|
|
60
|
-
|
|
61
|
-
if (createOrderResponse.order) {
|
|
62
|
-
console.log("\n✅ Order created successfully!");
|
|
63
|
-
console.log(`Order ID: ${createOrderResponse.order.orderId}`);
|
|
64
|
-
console.log(`Status: ${createOrderResponse.order.status}`);
|
|
65
|
-
console.log(`Creation Date: ${createOrderResponse.order.creationDate}`);
|
|
66
|
-
} else {
|
|
67
|
-
console.log("\n❌ Failed to create order");
|
|
68
|
-
if (createOrderResponse.error) {
|
|
69
|
-
console.error("Error:", createOrderResponse.error);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
} catch (error) {
|
|
73
|
-
console.error("\n❌ Test failed with error:", error);
|
|
74
|
-
throw error;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
// Run the test
|
|
79
|
-
testCreateOrder()
|
|
80
|
-
.then(() => console.log("\nTest execution completed"))
|
|
81
|
-
.catch(console.error);
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
import { BitflowSDK } from "./BitflowSDK";
|
|
2
|
-
import dotenv from "dotenv";
|
|
3
|
-
|
|
4
|
-
dotenv.config();
|
|
5
|
-
|
|
6
|
-
async function testRawTokenResponse() {
|
|
7
|
-
const sdk = new BitflowSDK({
|
|
8
|
-
BITFLOW_API_HOST: process.env.BITFLOW_API_HOST!,
|
|
9
|
-
BITFLOW_API_KEY: process.env.BITFLOW_API_KEY!,
|
|
10
|
-
READONLY_CALL_API_HOST: process.env.READONLY_CALL_API_HOST!,
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
try {
|
|
14
|
-
console.log("\nFetching raw token data...");
|
|
15
|
-
|
|
16
|
-
const response = await fetch(
|
|
17
|
-
`${process.env.BITFLOW_API_HOST}/getAllTokensAndPools?key=${process.env.BITFLOW_API_KEY}`
|
|
18
|
-
);
|
|
19
|
-
|
|
20
|
-
if (!response.ok) {
|
|
21
|
-
throw new Error(`HTTP error! status: ${response.status}`);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
const data = await response.json();
|
|
25
|
-
|
|
26
|
-
// Log the shape of the response
|
|
27
|
-
console.log("\nResponse Structure:");
|
|
28
|
-
console.log(
|
|
29
|
-
JSON.stringify(
|
|
30
|
-
{
|
|
31
|
-
totalTokens: data.tokens.length,
|
|
32
|
-
sampleKeys: Object.keys(data.tokens[0]),
|
|
33
|
-
},
|
|
34
|
-
null,
|
|
35
|
-
2
|
|
36
|
-
)
|
|
37
|
-
);
|
|
38
|
-
|
|
39
|
-
// Find different types of tokens
|
|
40
|
-
const layerOneToken = data.tokens.find(
|
|
41
|
-
(t: any) => t.layerOneAsset !== null
|
|
42
|
-
);
|
|
43
|
-
const bridgeToken = data.tokens.find((t: any) => t.bridge === "TRUE");
|
|
44
|
-
const keeperToken = data.tokens.find((t: any) => t.isKeeperToken === true);
|
|
45
|
-
|
|
46
|
-
console.log("\nToken Examples:");
|
|
47
|
-
|
|
48
|
-
if (layerOneToken) {
|
|
49
|
-
console.log("\n1. Token with LayerOneAsset:");
|
|
50
|
-
console.log(
|
|
51
|
-
JSON.stringify(
|
|
52
|
-
{
|
|
53
|
-
name: layerOneToken.name,
|
|
54
|
-
tokenId: layerOneToken["token-id"],
|
|
55
|
-
layerOneAsset: layerOneToken.layerOneAsset,
|
|
56
|
-
bridge: layerOneToken.bridge,
|
|
57
|
-
isKeeperToken: layerOneToken.isKeeperToken,
|
|
58
|
-
},
|
|
59
|
-
null,
|
|
60
|
-
2
|
|
61
|
-
)
|
|
62
|
-
);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
if (bridgeToken) {
|
|
66
|
-
console.log("\n2. Bridge Token:");
|
|
67
|
-
console.log(
|
|
68
|
-
JSON.stringify(
|
|
69
|
-
{
|
|
70
|
-
name: bridgeToken.name,
|
|
71
|
-
tokenId: bridgeToken["token-id"],
|
|
72
|
-
layerOneAsset: bridgeToken.layerOneAsset,
|
|
73
|
-
bridge: bridgeToken.bridge,
|
|
74
|
-
isKeeperToken: bridgeToken.isKeeperToken,
|
|
75
|
-
},
|
|
76
|
-
null,
|
|
77
|
-
2
|
|
78
|
-
)
|
|
79
|
-
);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
if (keeperToken) {
|
|
83
|
-
console.log("\n3. Keeper Token:");
|
|
84
|
-
console.log(
|
|
85
|
-
JSON.stringify(
|
|
86
|
-
{
|
|
87
|
-
name: keeperToken.name,
|
|
88
|
-
tokenId: keeperToken["token-id"],
|
|
89
|
-
layerOneAsset: keeperToken.layerOneAsset,
|
|
90
|
-
bridge: keeperToken.bridge,
|
|
91
|
-
isKeeperToken: keeperToken.isKeeperToken,
|
|
92
|
-
},
|
|
93
|
-
null,
|
|
94
|
-
2
|
|
95
|
-
)
|
|
96
|
-
);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
// Statistics
|
|
100
|
-
console.log("\nStatistics:");
|
|
101
|
-
console.log(
|
|
102
|
-
JSON.stringify(
|
|
103
|
-
{
|
|
104
|
-
totalTokens: data.tokens.length,
|
|
105
|
-
layerOneTokens: data.tokens.filter(
|
|
106
|
-
(t: any) => t.layerOneAsset !== null
|
|
107
|
-
).length,
|
|
108
|
-
bridgeTokens: data.tokens.filter((t: any) => t.bridge === "TRUE")
|
|
109
|
-
.length,
|
|
110
|
-
keeperTokens: data.tokens.filter((t: any) => t.isKeeperToken === true)
|
|
111
|
-
.length,
|
|
112
|
-
},
|
|
113
|
-
null,
|
|
114
|
-
2
|
|
115
|
-
)
|
|
116
|
-
);
|
|
117
|
-
} catch (error) {
|
|
118
|
-
console.error("Error fetching raw token data:", error);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
testRawTokenResponse()
|
|
123
|
-
.then(() => console.log("\nTest completed"))
|
|
124
|
-
.catch(console.error);
|
package/src/test-sdk.ts
DELETED
|
@@ -1,262 +0,0 @@
|
|
|
1
|
-
import { BitflowSDK } from "./BitflowSDK";
|
|
2
|
-
import {
|
|
3
|
-
ActionType,
|
|
4
|
-
CreateGroupOrderParams,
|
|
5
|
-
CreateOrderParams,
|
|
6
|
-
GetQuoteParams,
|
|
7
|
-
KeeperType,
|
|
8
|
-
} from "./keeper/types";
|
|
9
|
-
import dotenv from "dotenv";
|
|
10
|
-
|
|
11
|
-
dotenv.config();
|
|
12
|
-
|
|
13
|
-
async function testBitflowSDK() {
|
|
14
|
-
const sdk = new BitflowSDK({
|
|
15
|
-
BITFLOW_API_HOST: process.env.BITFLOW_API_HOST!,
|
|
16
|
-
BITFLOW_API_KEY: process.env.BITFLOW_API_KEY!,
|
|
17
|
-
READONLY_CALL_API_HOST: process.env.READONLY_CALL_API_HOST!,
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
const stacksAddress = "SP228WEAEMYX21RW0TT5T38THPNDYPPGGVW2RP570";
|
|
21
|
-
const orderId = "cf4bb181-33e7-498a-9eb5-3d120abab9cf";
|
|
22
|
-
|
|
23
|
-
console.log("Starting BitflowSDK tests...\n");
|
|
24
|
-
|
|
25
|
-
// // 1) Test getUser
|
|
26
|
-
// console.log("1. Testing getUser...");
|
|
27
|
-
// try {
|
|
28
|
-
// const userResponse = await sdk.getUser(stacksAddress);
|
|
29
|
-
// console.log("User data:", JSON.stringify(userResponse, null, 2));
|
|
30
|
-
// } catch (error) {
|
|
31
|
-
// console.error("Error in getUser:", error);
|
|
32
|
-
// }
|
|
33
|
-
// console.log("----------------------------------------\n");
|
|
34
|
-
|
|
35
|
-
// // 2) Test getOrder
|
|
36
|
-
// console.log("2. Testing getOrder...");
|
|
37
|
-
// try {
|
|
38
|
-
// const orderResponse = await sdk.getOrder(orderId);
|
|
39
|
-
// console.log("Order data:", JSON.stringify(orderResponse, null, 2));
|
|
40
|
-
// } catch (error) {
|
|
41
|
-
// console.error("Error in getOrder:", error);
|
|
42
|
-
// }
|
|
43
|
-
// console.log("----------------------------------------\n");
|
|
44
|
-
|
|
45
|
-
// // 3) Test getOrCreateKeeperContract
|
|
46
|
-
// console.log("3. Testing getOrCreateKeeperContract...");
|
|
47
|
-
// try {
|
|
48
|
-
// const keeperContractResponse = await sdk.getOrCreateKeeperContract({
|
|
49
|
-
// stacksAddress,
|
|
50
|
-
// keeperType: KeeperType.MULTI_ACTION_V1,
|
|
51
|
-
// deployContract: true,
|
|
52
|
-
// allActionsApproved: true,
|
|
53
|
-
// });
|
|
54
|
-
// console.log(
|
|
55
|
-
// "Keeper contract data:",
|
|
56
|
-
// JSON.stringify(keeperContractResponse, null, 2)
|
|
57
|
-
// );
|
|
58
|
-
// } catch (error) {
|
|
59
|
-
// console.error("Error in getOrCreateKeeperContract:", error);
|
|
60
|
-
// }
|
|
61
|
-
// console.log("----------------------------------------\n");
|
|
62
|
-
|
|
63
|
-
// 4) Test getKeeperAggregatorRouteData
|
|
64
|
-
console.log("\n4. Testing getKeeperAggregatorRouteData (pBTC -> STX)...");
|
|
65
|
-
try {
|
|
66
|
-
const aggregatorData = await sdk.getKeeperAggregatorRouteData(
|
|
67
|
-
"token-pbtc",
|
|
68
|
-
"token-sbtc",
|
|
69
|
-
100000000
|
|
70
|
-
);
|
|
71
|
-
console.log(
|
|
72
|
-
"Aggregator route data:",
|
|
73
|
-
JSON.stringify(aggregatorData, null, 2)
|
|
74
|
-
);
|
|
75
|
-
} catch (error) {
|
|
76
|
-
console.error("Error getting keeper aggregator route data:", error);
|
|
77
|
-
}
|
|
78
|
-
console.log("----------------------------------------\n");
|
|
79
|
-
|
|
80
|
-
// 5) Test getQuote
|
|
81
|
-
console.log("\n5. Testing MULTI_ACTION_V1 quote...");
|
|
82
|
-
try {
|
|
83
|
-
const multiActionParams: GetQuoteParams = {
|
|
84
|
-
stacksAddress: "SP228WEAEMYX21RW0TT5T38THPNDYPPGGVW2RP570",
|
|
85
|
-
actionAmount: "100000000",
|
|
86
|
-
keeperType: KeeperType.MULTI_ACTION_V1,
|
|
87
|
-
actionType: ActionType.SWAP_XYK_SWAP_HELPER,
|
|
88
|
-
tokenXId: "token-pbtc",
|
|
89
|
-
tokenYId: "token-stx",
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
const quoteResponseMultiAction = await sdk.getQuote(multiActionParams);
|
|
93
|
-
console.log(
|
|
94
|
-
"MULTI_ACTION_V1 Quote Response:",
|
|
95
|
-
JSON.stringify(quoteResponseMultiAction, null, 2)
|
|
96
|
-
);
|
|
97
|
-
} catch (error) {
|
|
98
|
-
console.error("Error in getQuote:", error);
|
|
99
|
-
}
|
|
100
|
-
console.log("----------------------------------------\n");
|
|
101
|
-
|
|
102
|
-
// // 6) Test createOrder
|
|
103
|
-
// console.log("6. Testing createOrder...");
|
|
104
|
-
// let keeperContractIdentifier: string | undefined;
|
|
105
|
-
// try {
|
|
106
|
-
// const keeperContractResponse = await sdk.getOrCreateKeeperContract({
|
|
107
|
-
// stacksAddress,
|
|
108
|
-
// keeperType: KeeperType.MULTI_ACTION_V1,
|
|
109
|
-
// allActionsApproved: true,
|
|
110
|
-
// });
|
|
111
|
-
// keeperContractIdentifier =
|
|
112
|
-
// keeperContractResponse.keeperContract.contractIdentifier;
|
|
113
|
-
|
|
114
|
-
// const orderParams: CreateOrderParams = {
|
|
115
|
-
// stacksAddress,
|
|
116
|
-
// actionAmount: "5000",
|
|
117
|
-
// feeRecipient: "SP16BPKS1DN5AYQ5MDHFEYXTSP352QG6JS2E0N8YP",
|
|
118
|
-
// tokenOrder: ["BTC", "PBTC"],
|
|
119
|
-
// keeperType: KeeperType.MULTI_ACTION_V1,
|
|
120
|
-
// contractIdentifier: keeperContractIdentifier,
|
|
121
|
-
// actionType: "SWAP_XYK_STABLESWAP_SWAP_HELPER",
|
|
122
|
-
// bitcoinTxId:
|
|
123
|
-
// "73e7cd80138044f73b7f08c881c51e1818acba0a3afab763724e399f33f89975",
|
|
124
|
-
// minReceived: {
|
|
125
|
-
// amount: "1734",
|
|
126
|
-
// autoAdjust: true,
|
|
127
|
-
// },
|
|
128
|
-
// actionFunctionArgs: {
|
|
129
|
-
// tokenList: {
|
|
130
|
-
// a: "SM3VDXK3WZZSA84XXFKAFAF15NNZX32CTSG82JFQ4.sbtc-token",
|
|
131
|
-
// b: "SP14NS8MVBRHXMM96BQY0727AJ59SWPV7RMHC0NCG.pontis-bridge-pBTC",
|
|
132
|
-
// c: "SP14NS8MVBRHXMM96BQY0727AJ59SWPV7RMHC0NCG.pontis-bridge-pBTC",
|
|
133
|
-
// d: "SM1793C4R5PZ4NS4VQ4WMP7SKKYVH8JZEWSZ9HCCR.token-stx-v-1-2",
|
|
134
|
-
// },
|
|
135
|
-
// xykPoolList: {
|
|
136
|
-
// a: "SM1793C4R5PZ4NS4VQ4WMP7SKKYVH8JZEWSZ9HCCR.xyk-pool-pbtc-stx-v-1-1",
|
|
137
|
-
// },
|
|
138
|
-
// stableswapPoolList: {
|
|
139
|
-
// a: "SM1793C4R5PZ4NS4VQ4WMP7SKKYVH8JZEWSZ9HCCR.stableswap-pool-sbtc-pbtc-v-1-1",
|
|
140
|
-
// },
|
|
141
|
-
// boolList: {
|
|
142
|
-
// a: "true",
|
|
143
|
-
// },
|
|
144
|
-
// },
|
|
145
|
-
// };
|
|
146
|
-
// const createOrderResponse = await sdk.createOrder(orderParams);
|
|
147
|
-
// console.log(
|
|
148
|
-
// "Create order response:",
|
|
149
|
-
// JSON.stringify(createOrderResponse, null, 2)
|
|
150
|
-
// );
|
|
151
|
-
// } catch (error) {
|
|
152
|
-
// console.error("Error creating order:", error);
|
|
153
|
-
// }
|
|
154
|
-
// console.log("----------------------------------------\n");
|
|
155
|
-
|
|
156
|
-
// // 7) Test createGroupOrder
|
|
157
|
-
// console.log("\n7. Testing createGroupOrder...");
|
|
158
|
-
// try {
|
|
159
|
-
// const now = new Date();
|
|
160
|
-
// const tomorrow = new Date(now.getTime() + 24 * 60 * 60 * 1000);
|
|
161
|
-
// const createGroupOrderParams: CreateGroupOrderParams = {
|
|
162
|
-
// stacksAddress: "SP228WEAEMYX21RW0TT5T38THPNDYPPGGVW2RP570",
|
|
163
|
-
// amountPerOrder: 500000,
|
|
164
|
-
// numberOfOrders: 4,
|
|
165
|
-
// executionFrequency: 300000,
|
|
166
|
-
// feeRecipient: "SP16BPKS1DN5AYQ5MDHFEYXTSP352QG6JS2E0N8YP",
|
|
167
|
-
// fundingTokens: {
|
|
168
|
-
// STX: "1000000",
|
|
169
|
-
// },
|
|
170
|
-
// bitcoinTxId:
|
|
171
|
-
// "cbf1c87f2b81f6bcd6c83bcf512b6178edc0fcdf7a1595b174ecbad45660a3b7",
|
|
172
|
-
// keeperType: KeeperType.MULTI_ACTION_V1,
|
|
173
|
-
// actionType: "SWAP_XYK_SWAP_HELPER",
|
|
174
|
-
// actionFunctionArgs: {
|
|
175
|
-
// tokenList: {
|
|
176
|
-
// a: "SM1793C4R5PZ4NS4VQ4WMP7SKKYVH8JZEWSZ9HCCR.token-stx-v-1-2",
|
|
177
|
-
// b: "SM3VDXK3WZZSA84XXFKAFAF15NNZX32CTSG82JFQ4.sbtc-token",
|
|
178
|
-
// },
|
|
179
|
-
// xykPoolList: {
|
|
180
|
-
// a: "SM1793C4R5PZ4NS4VQ4WMP7SKKYVH8JZEWSZ9HCCR.xyk-pool-sbtc-stx-v-1-1",
|
|
181
|
-
// },
|
|
182
|
-
// },
|
|
183
|
-
// nextExecutionAfter: tomorrow,
|
|
184
|
-
// };
|
|
185
|
-
|
|
186
|
-
// const createGroupOrderResponse = await sdk.createGroupOrder(
|
|
187
|
-
// createGroupOrderParams
|
|
188
|
-
// );
|
|
189
|
-
// console.log(
|
|
190
|
-
// "Create Group Order Response:",
|
|
191
|
-
// JSON.stringify(createGroupOrderResponse, null, 2)
|
|
192
|
-
// );
|
|
193
|
-
// console.log("----------------------------------------\n");
|
|
194
|
-
// } catch (error) {
|
|
195
|
-
// console.error("Error creating group order:", error);
|
|
196
|
-
// }
|
|
197
|
-
|
|
198
|
-
// // 8) Test getGroupOrder (without includeOrders)
|
|
199
|
-
// console.log("\n8. Testing getGroupOrder without includeOrders...");
|
|
200
|
-
// try {
|
|
201
|
-
// const groupId = "e415a039-b1f1-4730-a66c-3d0c46f1f148";
|
|
202
|
-
// const getGroupOrderResponse = await sdk.getGroupOrder(groupId);
|
|
203
|
-
// console.log(
|
|
204
|
-
// "Get Group Order Response (without orders):",
|
|
205
|
-
// JSON.stringify(getGroupOrderResponse, null, 2)
|
|
206
|
-
// );
|
|
207
|
-
// } catch (error) {
|
|
208
|
-
// console.error("Error getting group order:", error);
|
|
209
|
-
// }
|
|
210
|
-
// console.log("----------------------------------------\n");
|
|
211
|
-
|
|
212
|
-
// // 9) Test getGroupOrder (with includeOrders)
|
|
213
|
-
// console.log("\n9. Testing getGroupOrder with includeOrders...");
|
|
214
|
-
// try {
|
|
215
|
-
// const groupId = "e415a039-b1f1-4730-a66c-3d0c46f1f148";
|
|
216
|
-
// const getGroupOrderWithOrdersResponse = await sdk.getGroupOrder(
|
|
217
|
-
// groupId,
|
|
218
|
-
// true
|
|
219
|
-
// );
|
|
220
|
-
// console.log(
|
|
221
|
-
// "Get Group Order Response (with orders):",
|
|
222
|
-
// JSON.stringify(getGroupOrderWithOrdersResponse, null, 2)
|
|
223
|
-
// );
|
|
224
|
-
// } catch (error) {
|
|
225
|
-
// console.error("Error getting group order (with orders):", error);
|
|
226
|
-
// }
|
|
227
|
-
// console.log("----------------------------------------\n");
|
|
228
|
-
|
|
229
|
-
// // 10) Test cancelOrder
|
|
230
|
-
// console.log("\n10. Testing cancelOrder...");
|
|
231
|
-
// try {
|
|
232
|
-
// const firstOrderId = "c50cee19-911c-4645-9562-cbf89f765687";
|
|
233
|
-
// const cancelOrderResponse = await sdk.cancelOrder(firstOrderId);
|
|
234
|
-
// console.log(
|
|
235
|
-
// "Cancel Order Response:",
|
|
236
|
-
// JSON.stringify(cancelOrderResponse, null, 2)
|
|
237
|
-
// );
|
|
238
|
-
// } catch (error) {
|
|
239
|
-
// console.error("Error cancelling order:", error);
|
|
240
|
-
// }
|
|
241
|
-
// console.log("----------------------------------------\n");
|
|
242
|
-
|
|
243
|
-
// 11) Test cancelGroupOrder
|
|
244
|
-
console.log("\n11. Testing cancelGroupOrder...");
|
|
245
|
-
try {
|
|
246
|
-
const groupIdToCancel = "dc277cd7-c3f9-472b-b607-3b6698f052f6";
|
|
247
|
-
const cancelGroupOrderResponse = await sdk.cancelGroupOrder(
|
|
248
|
-
groupIdToCancel
|
|
249
|
-
);
|
|
250
|
-
console.log(
|
|
251
|
-
"Cancel Group Order Response:",
|
|
252
|
-
JSON.stringify(cancelGroupOrderResponse, null, 2)
|
|
253
|
-
);
|
|
254
|
-
} catch (error) {
|
|
255
|
-
console.error("Error cancelling group order:", error);
|
|
256
|
-
}
|
|
257
|
-
console.log("----------------------------------------\n");
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
testBitflowSDK()
|
|
261
|
-
.then(() => console.log("All tests completed"))
|
|
262
|
-
.catch(console.error);
|
package/src/test-token.fetch.ts
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { BitflowSDK } from "./BitflowSDK";
|
|
2
|
-
import dotenv from "dotenv";
|
|
3
|
-
|
|
4
|
-
dotenv.config();
|
|
5
|
-
|
|
6
|
-
async function testGetKeeperTokens() {
|
|
7
|
-
console.log("Starting getKeeperTokens test...\n");
|
|
8
|
-
|
|
9
|
-
// Initialize SDK with environment variables
|
|
10
|
-
const sdk = new BitflowSDK({
|
|
11
|
-
BITFLOW_API_HOST: process.env.BITFLOW_API_HOST!,
|
|
12
|
-
BITFLOW_API_KEY: process.env.BITFLOW_API_KEY!,
|
|
13
|
-
READONLY_CALL_API_HOST: process.env.READONLY_CALL_API_HOST!,
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
try {
|
|
17
|
-
// Get all tokens for comparison
|
|
18
|
-
console.log("Fetching all available tokens...");
|
|
19
|
-
const allTokens = await sdk.getAvailableTokens();
|
|
20
|
-
console.log(`Total number of tokens: ${allTokens.length}`);
|
|
21
|
-
|
|
22
|
-
// Get keeper tokens
|
|
23
|
-
console.log("\nFetching keeper tokens...");
|
|
24
|
-
const keeperTokens = await sdk.getKeeperTokens();
|
|
25
|
-
console.log(`Number of keeper tokens: ${keeperTokens.length}`);
|
|
26
|
-
|
|
27
|
-
// Verify all returned tokens are actually keeper tokens
|
|
28
|
-
const allAreKeeperTokens = keeperTokens.every(
|
|
29
|
-
(token) => token.isKeeperToken
|
|
30
|
-
);
|
|
31
|
-
console.log("\nValidation:");
|
|
32
|
-
console.log(`All returned tokens are keeper tokens: ${allAreKeeperTokens}`);
|
|
33
|
-
|
|
34
|
-
// Compare with manual filtering
|
|
35
|
-
const manuallyFilteredKeeperTokens = allTokens.filter(
|
|
36
|
-
(token) => token.isKeeperToken
|
|
37
|
-
);
|
|
38
|
-
const countMatch =
|
|
39
|
-
keeperTokens.length === manuallyFilteredKeeperTokens.length;
|
|
40
|
-
console.log(`Count matches manual filtering: ${countMatch}`);
|
|
41
|
-
|
|
42
|
-
// Print some details about the keeper tokens
|
|
43
|
-
console.log("\nKeeper Tokens Details:");
|
|
44
|
-
keeperTokens.forEach((token) => {
|
|
45
|
-
console.log(`- ${token.name} (${token.symbol})`);
|
|
46
|
-
console.log(` Token ID: ${token.tokenId}`);
|
|
47
|
-
console.log(` Contract: ${token.tokenContract}`);
|
|
48
|
-
console.log(` Decimals: ${token.tokenDecimals}`);
|
|
49
|
-
console.log(" ---------------");
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
if (allAreKeeperTokens && countMatch) {
|
|
53
|
-
console.log("\n✅ getKeeperTokens test passed successfully!");
|
|
54
|
-
} else {
|
|
55
|
-
console.log("\n❌ getKeeperTokens test failed!");
|
|
56
|
-
if (!allAreKeeperTokens) {
|
|
57
|
-
console.error("Error: Some returned tokens are not keeper tokens");
|
|
58
|
-
}
|
|
59
|
-
if (!countMatch) {
|
|
60
|
-
console.error("Error: Token count doesn't match manual filtering");
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
} catch (error) {
|
|
64
|
-
console.error("\n❌ Test failed with error:", error);
|
|
65
|
-
throw error;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
// Run the test
|
|
70
|
-
testGetKeeperTokens()
|
|
71
|
-
.then(() => console.log("\nTest execution completed"))
|
|
72
|
-
.catch(console.error);
|