@renegade-fi/renegade-sdk 0.1.3 → 0.1.5
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/examples/basic.ts
CHANGED
|
@@ -42,7 +42,7 @@ const walletClient = createWalletClient({
|
|
|
42
42
|
|
|
43
43
|
// Create the external match client
|
|
44
44
|
console.log("API KEY", API_KEY);
|
|
45
|
-
const client = ExternalMatchClient.
|
|
45
|
+
const client = ExternalMatchClient.newArbitrumSepoliaClient(API_KEY, API_SECRET);
|
|
46
46
|
|
|
47
47
|
// Example order for USDC/WETH pair
|
|
48
48
|
const order: ExternalOrder = {
|
|
@@ -43,8 +43,7 @@ const walletClient = createWalletClient({
|
|
|
43
43
|
});
|
|
44
44
|
|
|
45
45
|
// Create the external match client
|
|
46
|
-
|
|
47
|
-
const client = ExternalMatchClient.newSepoliaClient(API_KEY, API_SECRET);
|
|
46
|
+
const client = ExternalMatchClient.newArbitrumSepoliaClient(API_KEY, API_SECRET);
|
|
48
47
|
|
|
49
48
|
// Example order for USDC/WETH pair
|
|
50
49
|
const order: ExternalOrder = {
|
|
@@ -20,7 +20,7 @@ if (!API_KEY || !API_SECRET) {
|
|
|
20
20
|
|
|
21
21
|
// Create the external match client
|
|
22
22
|
console.log("API KEY", API_KEY);
|
|
23
|
-
const client = ExternalMatchClient.
|
|
23
|
+
const client = ExternalMatchClient.newArbitrumSepoliaClient(API_KEY, API_SECRET);
|
|
24
24
|
|
|
25
25
|
// Example base token mint (USDC)
|
|
26
26
|
const WETH = "0xc3414a7ef14aaaa9c4522dfc00a4e66e74e9c25a";
|
|
@@ -42,7 +42,7 @@ const walletClient = createWalletClient({
|
|
|
42
42
|
|
|
43
43
|
// Create the external match client
|
|
44
44
|
console.log("API KEY", API_KEY);
|
|
45
|
-
const client = ExternalMatchClient.
|
|
45
|
+
const client = ExternalMatchClient.newArbitrumSepoliaClient(API_KEY, API_SECRET);
|
|
46
46
|
|
|
47
47
|
// Example order for USDC/WETH pair
|
|
48
48
|
const order: ExternalOrder = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@renegade-fi/renegade-sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"description": "A TypeScript client for interacting with the Renegade Darkpool API",
|
|
5
5
|
"module": "index.ts",
|
|
6
6
|
"type": "module",
|
|
@@ -41,4 +41,4 @@
|
|
|
41
41
|
"engines": {
|
|
42
42
|
"node": ">=18"
|
|
43
43
|
}
|
|
44
|
-
}
|
|
44
|
+
}
|
package/src/client.ts
CHANGED
|
@@ -7,21 +7,21 @@
|
|
|
7
7
|
|
|
8
8
|
import { RelayerHttpClient } from "./http";
|
|
9
9
|
import {
|
|
10
|
-
MalleableExternalMatchResponse,
|
|
11
10
|
type ApiSignedExternalQuote,
|
|
12
11
|
type AssembleExternalMatchRequest,
|
|
13
12
|
type ExternalMatchResponse,
|
|
14
13
|
type ExternalOrder,
|
|
15
14
|
type ExternalQuoteRequest,
|
|
16
15
|
type ExternalQuoteResponse,
|
|
16
|
+
MalleableExternalMatchResponse,
|
|
17
17
|
type OrderBookDepth,
|
|
18
18
|
type SignedExternalQuote,
|
|
19
19
|
} from "./types/index";
|
|
20
20
|
import { VERSION } from "./version";
|
|
21
21
|
|
|
22
22
|
// Constants for API URLs
|
|
23
|
-
const
|
|
24
|
-
const
|
|
23
|
+
const ARBITRUM_SEPOLIA_BASE_URL = "https://arbitrum-sepolia.auth-server.renegade.fi";
|
|
24
|
+
const ARBITRUM_ONE_BASE_URL = "https://arbitrum-one.auth-server.renegade.fi";
|
|
25
25
|
|
|
26
26
|
// Header constants
|
|
27
27
|
const RENEGADE_API_KEY_HEADER = "x-renegade-api-key";
|
|
@@ -271,25 +271,43 @@ export class ExternalMatchClient {
|
|
|
271
271
|
}
|
|
272
272
|
|
|
273
273
|
/**
|
|
274
|
-
* Create a new client configured for the Sepolia testnet.
|
|
274
|
+
* Create a new client configured for the Arbitrum Sepolia testnet.
|
|
275
|
+
*
|
|
276
|
+
* @deprecated Use {@link ExternalMatchClient.newArbitrumSepoliaClient} instead
|
|
277
|
+
*/
|
|
278
|
+
static newSepoliaClient(apiKey: string, apiSecret: string): ExternalMatchClient {
|
|
279
|
+
return ExternalMatchClient.newArbitrumSepoliaClient(apiKey, apiSecret);
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* Create a new client configured for the Arbitrum Sepolia testnet.
|
|
275
284
|
*
|
|
276
285
|
* @param apiKey The API key for authentication
|
|
277
286
|
* @param apiSecret The API secret for request signing
|
|
278
287
|
* @returns A new ExternalMatchClient configured for Sepolia
|
|
279
288
|
*/
|
|
280
|
-
static
|
|
281
|
-
return new ExternalMatchClient(apiKey, apiSecret,
|
|
289
|
+
static newArbitrumSepoliaClient(apiKey: string, apiSecret: string): ExternalMatchClient {
|
|
290
|
+
return new ExternalMatchClient(apiKey, apiSecret, ARBITRUM_SEPOLIA_BASE_URL);
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* Create a new client configured for the Arbitrum One mainnet.
|
|
295
|
+
*
|
|
296
|
+
* @deprecated Use {@link ExternalMatchClient.newArbitrumOneClient} instead
|
|
297
|
+
*/
|
|
298
|
+
static newMainnetClient(apiKey: string, apiSecret: string): ExternalMatchClient {
|
|
299
|
+
return ExternalMatchClient.newArbitrumOneClient(apiKey, apiSecret);
|
|
282
300
|
}
|
|
283
301
|
|
|
284
302
|
/**
|
|
285
|
-
* Create a new client configured for mainnet.
|
|
303
|
+
* Create a new client configured for the Arbitrum One mainnet.
|
|
286
304
|
*
|
|
287
305
|
* @param apiKey The API key for authentication
|
|
288
306
|
* @param apiSecret The API secret for request signing
|
|
289
307
|
* @returns A new ExternalMatchClient configured for mainnet
|
|
290
308
|
*/
|
|
291
|
-
static
|
|
292
|
-
return new ExternalMatchClient(apiKey, apiSecret,
|
|
309
|
+
static newArbitrumOneClient(apiKey: string, apiSecret: string): ExternalMatchClient {
|
|
310
|
+
return new ExternalMatchClient(apiKey, apiSecret, ARBITRUM_ONE_BASE_URL);
|
|
293
311
|
}
|
|
294
312
|
|
|
295
313
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { bytesToHex, concatBytes, hexToBytes, numberToBytes } from "viem/utils";
|
|
1
|
+
import { bytesToHex, concatBytes, hexToBytes, numberToBytes, numberToHex } from "viem/utils";
|
|
2
2
|
import { FixedPoint } from "./fixedPoint";
|
|
3
3
|
import {
|
|
4
4
|
type ApiExternalAssetTransfer,
|
|
@@ -12,6 +12,8 @@ import {
|
|
|
12
12
|
const BASE_AMOUNT_OFFSET = 4;
|
|
13
13
|
/** The length of the base amount in the calldata */
|
|
14
14
|
const BASE_AMOUNT_LENGTH = 32;
|
|
15
|
+
/** The address used to represent the native asset */
|
|
16
|
+
const NATIVE_ASSET_ADDR = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE";
|
|
15
17
|
|
|
16
18
|
/**
|
|
17
19
|
* The response type for requesting a malleable quote on an external order
|
|
@@ -84,11 +86,15 @@ export class MalleableExternalMatchResponse {
|
|
|
84
86
|
|
|
85
87
|
const newCalldataBytes = concatBytes([prefix, baseAmountBytes, suffix]);
|
|
86
88
|
const newCalladata = bytesToHex(newCalldataBytes);
|
|
89
|
+
const value = this.isNativeEthSell() ? baseAmount : 0n;
|
|
90
|
+
const valueHex = numberToHex(value);
|
|
91
|
+
|
|
87
92
|
const newMatchBundle = {
|
|
88
93
|
...this.match_bundle,
|
|
89
94
|
settlement_tx: {
|
|
90
95
|
...this.match_bundle.settlement_tx,
|
|
91
96
|
data: newCalladata,
|
|
97
|
+
value: valueHex,
|
|
92
98
|
},
|
|
93
99
|
};
|
|
94
100
|
|
|
@@ -135,6 +141,17 @@ export class MalleableExternalMatchResponse {
|
|
|
135
141
|
return this.computeSendAmount(baseAmount);
|
|
136
142
|
}
|
|
137
143
|
|
|
144
|
+
/**
|
|
145
|
+
* Return whether the trade is a native ETH sell
|
|
146
|
+
*/
|
|
147
|
+
public isNativeEthSell(): boolean {
|
|
148
|
+
const matchRes = this.match_bundle.match_result;
|
|
149
|
+
const isSell = matchRes.direction === OrderSide.SELL;
|
|
150
|
+
const isBaseEth = matchRes.base_mint.toLowerCase() === NATIVE_ASSET_ADDR.toLowerCase();
|
|
151
|
+
|
|
152
|
+
return isBaseEth && isSell;
|
|
153
|
+
}
|
|
154
|
+
|
|
138
155
|
/**
|
|
139
156
|
* Check a base amount is in the valid range
|
|
140
157
|
*/
|
package/src/version.ts
CHANGED