@funkit/fun-relay 0.1.6 → 0.1.8
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 +13 -0
- package/dist/index.d.ts +4 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +153 -54
- package/dist/index.js.map +4 -4
- package/dist/index.mjs +152 -53
- package/dist/index.mjs.map +4 -4
- package/dist/src/client.d.ts.map +1 -1
- package/dist/src/constants.d.ts +7 -0
- package/dist/src/constants.d.ts.map +1 -1
- package/dist/src/currency.d.ts +18 -0
- package/dist/src/currency.d.ts.map +1 -0
- package/dist/src/execution.d.ts +27 -7
- package/dist/src/execution.d.ts.map +1 -1
- package/dist/src/fees.d.ts.map +1 -1
- package/dist/src/quote.d.ts +18 -14
- package/dist/src/quote.d.ts.map +1 -1
- package/dist/src/solana.d.ts +11 -0
- package/dist/src/solana.d.ts.map +1 -0
- package/dist/src/utils.d.ts +2 -2
- package/dist/src/utils.d.ts.map +1 -1
- package/package.json +5 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @funkit/fun-relay
|
|
2
2
|
|
|
3
|
+
## 0.1.8
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 881f069: feat(relay): add solana support
|
|
8
|
+
- 915c4de: fix(relay): deduplicate relay fees
|
|
9
|
+
|
|
10
|
+
## 0.1.7
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- 9cc9c7f: refactor: reduce latency of usd estimation
|
|
15
|
+
|
|
3
16
|
## 0.1.6
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
export { getRelayClient, initializeRelayClient, type InitializeRelayClientParams, } from './src/client';
|
|
2
|
-
export { FUN_RELAY_REFERRER, FUN_RELAY_REVENUE_WALLET, RELAY_TERMINAL_STATUSES, } from './src/constants';
|
|
3
|
-
export { type ExecuteRelayQuoteParams, executeRelayQuote, getRelayExecutionInfo, } from './src/execution';
|
|
2
|
+
export { FUN_RELAY_REFERRER, FUN_RELAY_REVENUE_WALLET, RELAY_SOLANA_CHAIN_ID, RELAY_SOLANA_CHAIN_ID_NUMBER, RELAY_TERMINAL_STATUSES, } from './src/constants';
|
|
3
|
+
export { type ExecuteRelayQuoteParams, type RelayAddress, type RelayChainId, type RelayExecutionStep, type RelayTxHash, type RelayVmType, type RelayWallet, executeRelayQuote, getRelayExecutionInfo, } from './src/execution';
|
|
4
4
|
export { parseRelayFees } from './src/fees';
|
|
5
5
|
export { getRelayAssetPriceInfo } from './src/price';
|
|
6
|
-
export { type GetRelayQuoteParams,
|
|
6
|
+
export { type GetRelayQuoteParams, type RelayQuote, getRelayQuote, } from './src/quote';
|
|
7
|
+
export { type SolanaAddress, type SolanaTxHash, type SolanaWallet, getSolanaWallet, } from './src/solana';
|
|
7
8
|
export { getRelayExecutionRefundState, getRelayExecutionState, isRelayExecutionTerminalStatus, convertFunToRelayTokenAddress, } from './src/utils';
|
|
8
9
|
export { LogLevel, type RelayExecutionInfo, type RelayExecutionStatus, type RelayTokenPriceInfo, } from './src/types';
|
|
9
10
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,qBAAqB,EACrB,KAAK,2BAA2B,GACjC,MAAM,cAAc,CAAA;AACrB,OAAO,EACL,kBAAkB,EAClB,wBAAwB,EACxB,uBAAuB,GACxB,MAAM,iBAAiB,CAAA;AACxB,OAAO,EACL,KAAK,uBAAuB,EAC5B,iBAAiB,EACjB,qBAAqB,GACtB,MAAM,iBAAiB,CAAA;AACxB,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAC3C,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;AACpD,OAAO,EACL,KAAK,mBAAmB,EACxB,aAAa,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,qBAAqB,EACrB,KAAK,2BAA2B,GACjC,MAAM,cAAc,CAAA;AACrB,OAAO,EACL,kBAAkB,EAClB,wBAAwB,EACxB,qBAAqB,EACrB,4BAA4B,EAC5B,uBAAuB,GACxB,MAAM,iBAAiB,CAAA;AACxB,OAAO,EACL,KAAK,uBAAuB,EAC5B,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,KAAK,kBAAkB,EACvB,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,iBAAiB,EACjB,qBAAqB,GACtB,MAAM,iBAAiB,CAAA;AACxB,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAC3C,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;AACpD,OAAO,EACL,KAAK,mBAAmB,EACxB,KAAK,UAAU,EACf,aAAa,GACd,MAAM,aAAa,CAAA;AACpB,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,eAAe,GAChB,MAAM,cAAc,CAAA;AACrB,OAAO,EACL,4BAA4B,EAC5B,sBAAsB,EACtB,8BAA8B,EAC9B,6BAA6B,GAC9B,MAAM,aAAa,CAAA;AACpB,OAAO,EACL,QAAQ,EACR,KAAK,kBAAkB,EACvB,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,GACzB,MAAM,aAAa,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -22,7 +22,9 @@ var index_exports = {};
|
|
|
22
22
|
__export(index_exports, {
|
|
23
23
|
FUN_RELAY_REFERRER: () => FUN_RELAY_REFERRER,
|
|
24
24
|
FUN_RELAY_REVENUE_WALLET: () => FUN_RELAY_REVENUE_WALLET,
|
|
25
|
-
LogLevel: () =>
|
|
25
|
+
LogLevel: () => import_relay_sdk.LogLevel,
|
|
26
|
+
RELAY_SOLANA_CHAIN_ID: () => RELAY_SOLANA_CHAIN_ID,
|
|
27
|
+
RELAY_SOLANA_CHAIN_ID_NUMBER: () => RELAY_SOLANA_CHAIN_ID_NUMBER,
|
|
26
28
|
RELAY_TERMINAL_STATUSES: () => RELAY_TERMINAL_STATUSES,
|
|
27
29
|
convertFunToRelayTokenAddress: () => convertFunToRelayTokenAddress,
|
|
28
30
|
executeRelayQuote: () => executeRelayQuote,
|
|
@@ -32,6 +34,7 @@ __export(index_exports, {
|
|
|
32
34
|
getRelayExecutionRefundState: () => getRelayExecutionRefundState,
|
|
33
35
|
getRelayExecutionState: () => getRelayExecutionState,
|
|
34
36
|
getRelayQuote: () => getRelayQuote,
|
|
37
|
+
getSolanaWallet: () => getSolanaWallet,
|
|
35
38
|
initializeRelayClient: () => initializeRelayClient,
|
|
36
39
|
isRelayExecutionTerminalStatus: () => isRelayExecutionTerminalStatus,
|
|
37
40
|
parseRelayFees: () => parseRelayFees
|
|
@@ -39,44 +42,55 @@ __export(index_exports, {
|
|
|
39
42
|
module.exports = __toCommonJS(index_exports);
|
|
40
43
|
|
|
41
44
|
// src/client.ts
|
|
45
|
+
var import_relay_sdk2 = require("@reservoir0x/relay-sdk");
|
|
46
|
+
|
|
47
|
+
// src/types.ts
|
|
42
48
|
var import_relay_sdk = require("@reservoir0x/relay-sdk");
|
|
49
|
+
|
|
50
|
+
// src/constants.ts
|
|
51
|
+
var RELAY_SOLANA_CHAIN_ID_NUMBER = 792703809;
|
|
52
|
+
var RELAY_SOLANA_CHAIN_ID = `${RELAY_SOLANA_CHAIN_ID_NUMBER}`;
|
|
53
|
+
var FUNKIT_NATIVE_TOKEN = "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee";
|
|
54
|
+
var RELAY_NATIVE_TOKEN = "0x0000000000000000000000000000000000000000";
|
|
55
|
+
var FUN_RELAY_REVENUE_WALLET = "0xb61562d83aEC43a050A06BED12Ac2bD8f9BFfd5E";
|
|
56
|
+
var FUN_RELAY_REFERRER = "funxyz";
|
|
57
|
+
var RELAY_QUOTE_CHECKOUT_TIME_BUFFER_MS = 25e3;
|
|
58
|
+
var RELAY_TERMINAL_STATUSES = [
|
|
59
|
+
"refund" /* REFUND */,
|
|
60
|
+
"failure" /* FAILURE */,
|
|
61
|
+
"success" /* SUCCESS */
|
|
62
|
+
];
|
|
63
|
+
|
|
64
|
+
// src/client.ts
|
|
43
65
|
function initializeRelayClient({
|
|
44
66
|
chains,
|
|
45
67
|
logger,
|
|
46
68
|
...options
|
|
47
69
|
}) {
|
|
48
|
-
return (0,
|
|
70
|
+
return (0, import_relay_sdk2.createClient)({
|
|
49
71
|
...options,
|
|
50
|
-
baseApiUrl:
|
|
51
|
-
chains:
|
|
72
|
+
baseApiUrl: import_relay_sdk2.MAINNET_RELAY_API,
|
|
73
|
+
chains: [
|
|
74
|
+
...chains.map(import_relay_sdk2.convertViemChainToRelayChain),
|
|
75
|
+
{
|
|
76
|
+
id: RELAY_SOLANA_CHAIN_ID_NUMBER,
|
|
77
|
+
name: "Solana",
|
|
78
|
+
displayName: "Solana"
|
|
79
|
+
}
|
|
80
|
+
],
|
|
52
81
|
logger: (message) => {
|
|
53
82
|
logger.info("[RelayClient]:", message);
|
|
54
83
|
}
|
|
55
84
|
});
|
|
56
85
|
}
|
|
57
86
|
function getRelayClient() {
|
|
58
|
-
const client = (0,
|
|
87
|
+
const client = (0, import_relay_sdk2.getClient)();
|
|
59
88
|
if (!client) {
|
|
60
89
|
throw new Error("Relay client is not defined");
|
|
61
90
|
}
|
|
62
91
|
return client;
|
|
63
92
|
}
|
|
64
93
|
|
|
65
|
-
// src/types.ts
|
|
66
|
-
var import_relay_sdk2 = require("@reservoir0x/relay-sdk");
|
|
67
|
-
|
|
68
|
-
// src/constants.ts
|
|
69
|
-
var FUNKIT_NATIVE_TOKEN = "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee";
|
|
70
|
-
var RELAY_NATIVE_TOKEN = "0x0000000000000000000000000000000000000000";
|
|
71
|
-
var FUN_RELAY_REVENUE_WALLET = "0xb61562d83aEC43a050A06BED12Ac2bD8f9BFfd5E";
|
|
72
|
-
var FUN_RELAY_REFERRER = "funxyz";
|
|
73
|
-
var RELAY_QUOTE_CHECKOUT_TIME_BUFFER_MS = 25e3;
|
|
74
|
-
var RELAY_TERMINAL_STATUSES = [
|
|
75
|
-
"refund" /* REFUND */,
|
|
76
|
-
"failure" /* FAILURE */,
|
|
77
|
-
"success" /* SUCCESS */
|
|
78
|
-
];
|
|
79
|
-
|
|
80
94
|
// src/execution.ts
|
|
81
95
|
var import_relay_sdk3 = require("@reservoir0x/relay-sdk");
|
|
82
96
|
async function executeRelayQuote({
|
|
@@ -123,7 +137,8 @@ async function executeRelayQuote({
|
|
|
123
137
|
txHashes && txHashes.length > 0 && txHashes.length === steps.length
|
|
124
138
|
) {
|
|
125
139
|
logger.info(`${logPrefix}:completed`, txHashes);
|
|
126
|
-
|
|
140
|
+
const txHash = txHashes[0].txHash;
|
|
141
|
+
await onConfirmed(txHash).catch((e) => {
|
|
127
142
|
logger.error(`${logPrefix}:onConfirmedFailed`, e);
|
|
128
143
|
});
|
|
129
144
|
}
|
|
@@ -167,9 +182,11 @@ function parseRelayFees({
|
|
|
167
182
|
fees?.app?.amountFormatted || "0"
|
|
168
183
|
);
|
|
169
184
|
const funLpFeesFromAmountBaseUnit = BigInt(fees?.app?.amount || "0");
|
|
170
|
-
const relayLpFeesUsd = Number.parseFloat(fees?.relayer?.amountUsd || "0")
|
|
171
|
-
const relayLpFeesFromAmount = Number.parseFloat(
|
|
172
|
-
|
|
185
|
+
const relayLpFeesUsd = Number.parseFloat(fees?.relayer?.amountUsd || "0");
|
|
186
|
+
const relayLpFeesFromAmount = Number.parseFloat(
|
|
187
|
+
fees?.relayer?.amountFormatted || "0"
|
|
188
|
+
);
|
|
189
|
+
const relayLpFeesFromAmountBaseUnit = BigInt(fees?.relayer?.amount || "0");
|
|
173
190
|
const totalLpFeesUsd = funLpFeesUsd + relayLpFeesUsd;
|
|
174
191
|
const totalLpFeesFromAmount = funLpFeesFromAmount + relayLpFeesFromAmount;
|
|
175
192
|
const totalLpFeesFromAmountBaseUnit = funLpFeesFromAmountBaseUnit + relayLpFeesFromAmountBaseUnit;
|
|
@@ -212,6 +229,29 @@ async function getRelayAssetPriceInfo({
|
|
|
212
229
|
// src/quote.ts
|
|
213
230
|
var import_viem = require("viem");
|
|
214
231
|
|
|
232
|
+
// src/currency.ts
|
|
233
|
+
var import_relay_sdk5 = require("@reservoir0x/relay-sdk");
|
|
234
|
+
async function getRelayAssetInfo({
|
|
235
|
+
chainId,
|
|
236
|
+
address
|
|
237
|
+
}) {
|
|
238
|
+
const url = `${import_relay_sdk5.MAINNET_RELAY_API}/currencies/v2`;
|
|
239
|
+
const body = {
|
|
240
|
+
chainIds: [chainId],
|
|
241
|
+
address
|
|
242
|
+
};
|
|
243
|
+
const response = await fetch(url, {
|
|
244
|
+
method: "POST",
|
|
245
|
+
headers: { "Content-Type": "application/json" },
|
|
246
|
+
body: JSON.stringify(body)
|
|
247
|
+
});
|
|
248
|
+
if (!response.ok) {
|
|
249
|
+
throw Error(response.statusText);
|
|
250
|
+
}
|
|
251
|
+
const data = await response.json();
|
|
252
|
+
return data?.[0];
|
|
253
|
+
}
|
|
254
|
+
|
|
215
255
|
// src/utils.ts
|
|
216
256
|
function convertFunToRelayTokenAddress(address) {
|
|
217
257
|
if (address.toLowerCase() === FUNKIT_NATIVE_TOKEN.toLowerCase()) {
|
|
@@ -243,25 +283,52 @@ function isRelayExecutionTerminalStatus(info) {
|
|
|
243
283
|
}
|
|
244
284
|
|
|
245
285
|
// src/quote.ts
|
|
286
|
+
async function getQuoteEstUsdValue({
|
|
287
|
+
tokenChainId,
|
|
288
|
+
tokenAddress,
|
|
289
|
+
tokenAmountBaseUnit,
|
|
290
|
+
logger
|
|
291
|
+
}) {
|
|
292
|
+
try {
|
|
293
|
+
const [tokenPriceRes, tokenInfoRes] = await Promise.all([
|
|
294
|
+
getRelayAssetPriceInfo({
|
|
295
|
+
chainId: tokenChainId,
|
|
296
|
+
address: convertFunToRelayTokenAddress(tokenAddress)
|
|
297
|
+
}),
|
|
298
|
+
getRelayAssetInfo({
|
|
299
|
+
chainId: tokenChainId,
|
|
300
|
+
address: convertFunToRelayTokenAddress(tokenAddress)
|
|
301
|
+
})
|
|
302
|
+
]);
|
|
303
|
+
const price = tokenPriceRes.price;
|
|
304
|
+
const decimals = tokenInfoRes.decimals;
|
|
305
|
+
const absoluteAmount = BigInt(tokenAmountBaseUnit) / BigInt(10 ** decimals);
|
|
306
|
+
return Number(price) * Number(absoluteAmount);
|
|
307
|
+
} catch (err) {
|
|
308
|
+
logger.error("getQuoteEstUsdValueError", {
|
|
309
|
+
message: `Failed to get USD value for token ${tokenAddress} on chain ${tokenChainId}: ${err instanceof Error ? err.message : JSON.stringify(err)}. Falling back to 0 USD.`
|
|
310
|
+
});
|
|
311
|
+
return 0;
|
|
312
|
+
}
|
|
313
|
+
}
|
|
246
314
|
async function getRelayQuote({
|
|
247
315
|
logger,
|
|
316
|
+
walletClient,
|
|
248
317
|
...params
|
|
249
318
|
}) {
|
|
250
319
|
const {
|
|
251
320
|
actionParams,
|
|
321
|
+
clientId,
|
|
252
322
|
fromChainId,
|
|
253
323
|
fromTokenAddress,
|
|
254
324
|
options,
|
|
255
325
|
recipientAddress,
|
|
256
326
|
toChainId,
|
|
257
327
|
toTokenAddress,
|
|
258
|
-
userAddress
|
|
259
|
-
clientId
|
|
328
|
+
userAddress
|
|
260
329
|
} = params;
|
|
261
330
|
try {
|
|
262
331
|
const relayClient = getRelayClient();
|
|
263
|
-
const isExactIn = params.tradeType === "EXACT_INPUT";
|
|
264
|
-
const tokenAmountBaseUnit = isExactIn ? params.fromTokenAmountBaseUnit : params.toTokenAmountBaseUnit;
|
|
265
332
|
const txs = actionParams?.map((action) => {
|
|
266
333
|
const data = (0, import_viem.encodeFunctionData)({
|
|
267
334
|
abi: action.contractAbi,
|
|
@@ -274,25 +341,16 @@ async function getRelayQuote({
|
|
|
274
341
|
value: String(action.value ?? 0n)
|
|
275
342
|
};
|
|
276
343
|
});
|
|
277
|
-
const
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
options: {
|
|
288
|
-
referrer: clientId ? `${FUN_RELAY_REFERRER}|${clientId}` : FUN_RELAY_REFERRER,
|
|
289
|
-
...options
|
|
290
|
-
}
|
|
291
|
-
};
|
|
292
|
-
const quoteWithoutFees = await relayClient.actions.getQuote(
|
|
293
|
-
quoteParamsWithoutAppFees
|
|
294
|
-
);
|
|
295
|
-
const estUsdValue = quoteWithoutFees.details?.currencyIn?.amountUsd;
|
|
344
|
+
const isExactIn = params.tradeType === "EXACT_INPUT";
|
|
345
|
+
const queryTokenAmountBaseUnit = isExactIn ? params.fromTokenAmountBaseUnit : params.toTokenAmountBaseUnit;
|
|
346
|
+
const queryTokenAddress = isExactIn ? fromTokenAddress : toTokenAddress;
|
|
347
|
+
const queryTokenChainId = isExactIn ? fromChainId : toChainId;
|
|
348
|
+
const estUsdValue = await getQuoteEstUsdValue({
|
|
349
|
+
tokenChainId: queryTokenChainId,
|
|
350
|
+
tokenAddress: queryTokenAddress,
|
|
351
|
+
tokenAmountBaseUnit: queryTokenAmountBaseUnit.toString(),
|
|
352
|
+
logger
|
|
353
|
+
});
|
|
296
354
|
const feeInfo = await getFunRelayFees({
|
|
297
355
|
fromTokenAddress,
|
|
298
356
|
fromChainId,
|
|
@@ -304,22 +362,32 @@ async function getRelayQuote({
|
|
|
304
362
|
const appFeeBp = feeInfo.b + feeInfo.v;
|
|
305
363
|
logger.info("getRelayQuoteParams", {
|
|
306
364
|
...params,
|
|
307
|
-
|
|
365
|
+
queryTokenAmountBaseUnit,
|
|
308
366
|
txs,
|
|
309
|
-
|
|
367
|
+
estUsdValue,
|
|
310
368
|
feeInfo,
|
|
311
369
|
appFeeBp
|
|
312
370
|
});
|
|
313
371
|
const relayQuote = await relayClient.actions.getQuote({
|
|
314
|
-
|
|
372
|
+
chainId: Number(fromChainId),
|
|
373
|
+
toChainId: Number(toChainId),
|
|
374
|
+
currency: convertFunToRelayTokenAddress(fromTokenAddress),
|
|
375
|
+
toCurrency: convertFunToRelayTokenAddress(toTokenAddress),
|
|
376
|
+
amount: queryTokenAmountBaseUnit.toString(),
|
|
377
|
+
recipient: recipientAddress,
|
|
378
|
+
tradeType: params.tradeType,
|
|
379
|
+
user: userAddress,
|
|
380
|
+
wallet: walletClient,
|
|
381
|
+
...txs && { txs },
|
|
315
382
|
options: {
|
|
316
|
-
|
|
383
|
+
referrer: clientId ? `${FUN_RELAY_REFERRER}|${clientId}` : FUN_RELAY_REFERRER,
|
|
317
384
|
appFees: [
|
|
318
385
|
{
|
|
319
386
|
fee: appFeeBp.toString(),
|
|
320
387
|
recipient: FUN_RELAY_REVENUE_WALLET
|
|
321
388
|
}
|
|
322
|
-
]
|
|
389
|
+
],
|
|
390
|
+
...options
|
|
323
391
|
}
|
|
324
392
|
});
|
|
325
393
|
logger.info("relayQuote", relayQuote);
|
|
@@ -361,13 +429,14 @@ async function getRelayQuote({
|
|
|
361
429
|
finalToAmountBaseUnit: relayQuote.details.currencyOut.amount ?? "0",
|
|
362
430
|
// TODO: Or do we want 'minimumAmount'?
|
|
363
431
|
fromTokenAddress,
|
|
432
|
+
// TODO: fromTokenAddress is typed as `0x${string}` why does not accept SolanaAddress
|
|
364
433
|
lpFeePercentage: 0,
|
|
365
434
|
// TODO: ?
|
|
366
435
|
lpFeeUsd: totalLpFeesUsd,
|
|
367
436
|
metadata: {
|
|
368
|
-
fromAmountBaseUnit:
|
|
437
|
+
fromAmountBaseUnit: isExactIn ? queryTokenAmountBaseUnit.toString() : relayQuote.details.currencyIn.amount ?? "0",
|
|
369
438
|
relayQuote,
|
|
370
|
-
toAmountBaseUnit:
|
|
439
|
+
toAmountBaseUnit: isExactIn ? relayQuote.details.currencyOut.amount ?? "0" : queryTokenAmountBaseUnit.toString()
|
|
371
440
|
}
|
|
372
441
|
};
|
|
373
442
|
} catch (err) {
|
|
@@ -376,4 +445,34 @@ async function getRelayQuote({
|
|
|
376
445
|
);
|
|
377
446
|
}
|
|
378
447
|
}
|
|
448
|
+
|
|
449
|
+
// src/solana.ts
|
|
450
|
+
var import_relay_svm_wallet_adapter = require("@reservoir0x/relay-svm-wallet-adapter");
|
|
451
|
+
var import_web3 = require("@solana/web3.js");
|
|
452
|
+
function getSolanaWallet(walletAddress, connection, signTransaction) {
|
|
453
|
+
return (0, import_relay_svm_wallet_adapter.adaptSolanaWallet)(
|
|
454
|
+
walletAddress,
|
|
455
|
+
RELAY_SOLANA_CHAIN_ID_NUMBER,
|
|
456
|
+
connection,
|
|
457
|
+
async (transaction, options) => {
|
|
458
|
+
const signed = await signTransaction(transaction);
|
|
459
|
+
try {
|
|
460
|
+
const signature = await connection.sendTransaction(signed, {
|
|
461
|
+
...options,
|
|
462
|
+
maxRetries: 5
|
|
463
|
+
});
|
|
464
|
+
return { signature };
|
|
465
|
+
} catch (error) {
|
|
466
|
+
if (error instanceof import_web3.SendTransactionError) {
|
|
467
|
+
console.error(
|
|
468
|
+
"Failed transaction logs:",
|
|
469
|
+
error,
|
|
470
|
+
await error.getLogs(connection)
|
|
471
|
+
);
|
|
472
|
+
}
|
|
473
|
+
throw error;
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
);
|
|
477
|
+
}
|
|
379
478
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../index.ts", "../src/client.ts", "../src/types.ts", "../src/constants.ts", "../src/execution.ts", "../src/fees.ts", "../src/price.ts", "../src/quote.ts", "../src/utils.ts"],
|
|
4
|
-
"sourcesContent": ["export {\n getRelayClient,\n initializeRelayClient,\n type InitializeRelayClientParams,\n} from './src/client'\nexport {\n FUN_RELAY_REFERRER,\n FUN_RELAY_REVENUE_WALLET,\n RELAY_TERMINAL_STATUSES,\n} from './src/constants'\nexport {\n type ExecuteRelayQuoteParams,\n executeRelayQuote,\n getRelayExecutionInfo,\n} from './src/execution'\nexport { parseRelayFees } from './src/fees'\nexport { getRelayAssetPriceInfo } from './src/price'\nexport {\n type GetRelayQuoteParams,\n getRelayQuote,\n type RelayQuote,\n} from './src/quote'\nexport {\n getRelayExecutionRefundState,\n getRelayExecutionState,\n isRelayExecutionTerminalStatus,\n convertFunToRelayTokenAddress,\n} from './src/utils'\nexport {\n LogLevel,\n type RelayExecutionInfo,\n type RelayExecutionStatus,\n type RelayTokenPriceInfo,\n} from './src/types'\n", "import {\n MAINNET_RELAY_API,\n type RelayClient,\n type RelayClientOptions,\n convertViemChainToRelayChain,\n createClient,\n getClient,\n} from '@reservoir0x/relay-sdk'\nimport type { Chain } from 'viem'\nimport type { Logger } from './types'\n\nexport type InitializeRelayClientParams = Omit<\n RelayClientOptions,\n 'baseApiUrl' | 'chains' | 'logger'\n> & {\n chains: Chain[]\n logger: Logger\n}\n\n/**\n * Initializes a global instance of the RelayClient\n * https://docs.relay.link/references/sdk/createClient\n */\nexport function initializeRelayClient({\n chains,\n logger,\n ...options\n}: InitializeRelayClientParams): RelayClient {\n return createClient({\n ...options,\n baseApiUrl: MAINNET_RELAY_API,\n chains: chains.map(convertViemChainToRelayChain),\n logger: (message) => {\n logger.info('[RelayClient]:', message)\n },\n })\n}\n\n/**\n * Gets the global instance of the RelayClient\n */\nexport function getRelayClient(): RelayClient {\n const client = getClient()\n\n if (!client) {\n throw new Error('Relay client is not defined')\n }\n\n return client\n}\n", "import { LogLevel } from '@reservoir0x/relay-sdk'\nimport type { Abi, Address } from 'viem'\n\nexport { LogLevel }\n\n// https://docs.relay.link/references/api/get-intents-status-v2\nexport interface RelayExecutionInfo {\n status: RelayExecutionStatus\n details: string\n /** Incoming transaction hashes */\n inTxHashes: string[]\n /** Outgoing transaction hashes */\n txHashes: string[]\n /** The last timestamp the data was updated in milliseconds */\n time: number\n originChainId: number\n destinationChainId: number\n}\n\n// https://docs.relay.link/references/api/get-token-price\nexport interface RelayTokenPriceInfo {\n price: number\n}\n\n//// The types below are duplicated from @funkit/api-base atm, but this package should be used in BE as well\n//// TODO: Are we fine with BE importing @funkit/api-base and (by extension) @funkit/utils?\n//// See https://linear.app/funxyz/issue/PE-1342/sdk-extract-domainsrelayts-to-a-new-package#comment-d487d533\n\nexport interface Logger {\n error(message: string, data?: object): void\n info(message: string, data?: object): void\n}\n\n// Reference: https://github.com/reservoirprotocol/relay-kit/blob/211c645f9702a3b459ff545aa4e2e9d536c38455/packages/sdk/src/types/Execute.ts#L54-L61\nexport enum RelayExecutionStatus {\n DELAYED = 'delayed',\n FAILURE = 'failure',\n PENDING = 'pending',\n REFUND = 'refund',\n SUCCESS = 'success',\n WAITING = 'waiting',\n UNKNOWN = 'unknown',\n}\n\nexport interface ApiFunkitCheckoutActionParams {\n contractAbi: Abi\n contractAddress: Address\n functionName: string\n functionArgs: unknown[]\n value?: bigint\n}\n\nexport enum CheckoutRefundState {\n INITIATED = 'INITIATED',\n ERROR = 'ERROR',\n REFUNDED = 'REFUNDED',\n PROCEEDED = 'PROCEEDED',\n WAITING_FOR_FULFILLMENT = 'WAITING_FOR_FULFILLMENT',\n FULFILLED = 'FULFILLED',\n}\n\n// Reference from api server: https://github.com/fun-xyz/fun-api-server/blob/main/src/tables/FunWalletCheckout.ts#L11C1-L21C2\nexport enum CheckoutState {\n // In-progress States\n FROM_UNFUNDED = 'FROM_UNFUNDED',\n FROM_FUNDED = 'FROM_FUNDED',\n FROM_POOLED = 'FROM_POOLED',\n TO_UNFUNDED = 'TO_UNFUNDED',\n TO_FUNDED = 'TO_FUNDED',\n TO_POOLED = 'TO_POOLED',\n TO_READY = 'TO_READY',\n PENDING_RECEIVAL = 'PENDING_RECEIVAL',\n // Terminal States\n COMPLETED = 'COMPLETED',\n CHECKOUT_ERROR = 'CHECKOUT_ERROR',\n EXPIRED = 'EXPIRED',\n CANCELLED = 'CANCELLED',\n}\n\n// The response of the actual /checkout/quote api\nexport type CheckoutApiQuoteResponse = {\n quoteId: string\n estTotalFromAmountBaseUnit: string\n estSubtotalFromAmountBaseUnit: string\n estFeesFromAmountBaseUnit: string\n fromTokenAddress: Address\n estFeesUsd: number\n estSubtotalUsd: number\n estTotalUsd: number\n estCheckoutTimeMs: number\n estMarketMakerGasUsd: number\n lpFeePercentage: number\n lpFeeUsd: number\n}\n\n// The formatted response quote interface from the core sdk\nexport type CheckoutQuoteResponse = CheckoutApiQuoteResponse & {\n estTotalFromAmount: string\n estSubtotalFromAmount: string\n estFeesFromAmount: string\n\n // Any additional fields purely for frontend use\n metadata?: { [key: string]: unknown }\n}\n", "import type { Address } from 'viem'\nimport { RelayExecutionStatus } from './types'\n\n/**\n * Fake address for a chain's native currency used by Funkit\n */\nexport const FUNKIT_NATIVE_TOKEN =\n '0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee' satisfies Address\n\n/**\n * Fake address for a chain's native currency used by Relay\n */\nexport const RELAY_NATIVE_TOKEN =\n '0x0000000000000000000000000000000000000000' satisfies Address\n\n/**\n * Wallet that receives the app fees collected by Relay\n */\nexport const FUN_RELAY_REVENUE_WALLET =\n '0xb61562d83aEC43a050A06BED12Ac2bD8f9BFfd5E' satisfies Address\n\n/**\n * Referred field in Relay quote\n */\nexport const FUN_RELAY_REFERRER = 'funxyz'\n\n/**\n * Buffer added to Relay's time estimate (which sometimes is 0)\n */\nexport const RELAY_QUOTE_CHECKOUT_TIME_BUFFER_MS = 25_000 // 25 seconds\n\nexport const RELAY_TERMINAL_STATUSES: RelayExecutionStatus[] = [\n RelayExecutionStatus.REFUND,\n RelayExecutionStatus.FAILURE,\n RelayExecutionStatus.SUCCESS,\n]\n", "import {\n type Execute,\n MAINNET_RELAY_API,\n type ProgressData,\n} from '@reservoir0x/relay-sdk'\nimport type { Hex, WalletClient } from 'viem'\nimport { getRelayClient } from './client'\nimport type { Logger, RelayExecutionInfo } from './types'\n\nexport type RelayExecutionStep = ProgressData['currentStep'] & {}\n\nexport interface ExecuteRelayQuoteParams {\n logger: Logger\n onConfirmed: (txHash: Hex) => Promise<void>\n onError: (error: Error) => Promise<void>\n onProgress?: (step: RelayExecutionStep | null) => void\n relayQuote: Execute\n walletClient: WalletClient\n}\n\nexport async function executeRelayQuote({\n logger,\n onConfirmed,\n onError,\n onProgress,\n relayQuote,\n walletClient,\n}: ExecuteRelayQuoteParams) {\n await getRelayClient().actions.execute({\n quote: relayQuote,\n wallet: walletClient,\n onProgress: async ({\n steps,\n fees,\n breakdown,\n currentStep,\n currentStepItem,\n txHashes,\n details,\n error,\n }) => {\n const logPrefix = 'onRelayProgress'\n logger.info(`${logPrefix}:params`, {\n steps,\n currentStep,\n fees,\n breakdown,\n currentStepItem,\n txHashes,\n details,\n error,\n })\n\n onProgress?.(currentStep ?? null)\n\n if (error) {\n logger.info(`${logPrefix}:errorDetected`, error)\n await onError(error).catch((e) => {\n logger.error(`${logPrefix}:onErrorFailed`, e)\n })\n } else if (\n // We can redirect as soon as all the required user steps are done\n // https://fun-xyz.slack.com/archives/C08MQ85QB2N/p1748381169792379\n txHashes &&\n txHashes.length > 0 &&\n txHashes.length === steps.length\n ) {\n logger.info(`${logPrefix}:completed`, txHashes)\n // Can we assume its completed here?\n // Use first txHash as the main txHash in fun DE table\n await onConfirmed(txHashes[0].txHash as Hex).catch((e) => {\n logger.error(`${logPrefix}:onConfirmedFailed`, e)\n })\n }\n },\n })\n}\n\nexport async function getRelayExecutionInfo(\n requestId: string,\n): Promise<RelayExecutionInfo> {\n const url = `${MAINNET_RELAY_API}/intents/status/v2?requestId=${requestId}`\n const response = await fetch(url)\n if (!response.ok) {\n throw Error(response.statusText)\n }\n\n const data = await response.json()\n return data as RelayExecutionInfo\n}\n", "import type { CallFees } from '@reservoir0x/relay-sdk'\nimport type { Logger } from './types'\n\nexport interface FunRelayFeeItem {\n b: number\n v: number\n}\n\nexport async function getFunRelayFees({\n fromTokenAddress,\n fromChainId,\n toTokenAddress,\n toChainId,\n estUsdValue,\n clientId,\n}: {\n fromTokenAddress: string\n fromChainId: string\n toTokenAddress: string\n toChainId: string\n estUsdValue: number\n clientId: string\n}): Promise<FunRelayFeeItem> {\n const url = `https://frog.fun.xyz/api/fee?fromTokenAddress=${fromTokenAddress}&fromChainId=${fromChainId}&toTokenAddress=${toTokenAddress}&toChainId=${toChainId}&estUsdValue=${estUsdValue}&clientId=${clientId}`\n const response = await fetch(url)\n if (!response.ok) {\n throw Error(response.statusText)\n }\n\n const data = await response.json()\n return data\n}\n\nexport function parseRelayFees({\n fees,\n logger,\n}: {\n fees: CallFees | undefined\n logger: Logger\n}) {\n // Gas fees, denominated in source chain native token\n const relayGasFeesUsd = Number.parseFloat(fees?.gas?.amountUsd || '0')\n\n // App fees, denominated in source chain token\n const funLpFeesUsd = Number.parseFloat(fees?.app?.amountUsd || '0')\n const funLpFeesFromAmount = Number.parseFloat(\n fees?.app?.amountFormatted || '0',\n )\n const funLpFeesFromAmountBaseUnit = BigInt(fees?.app?.amount || '0')\n\n // Relay fees, denominated in source chain token\n const relayLpFeesUsd =\n Number.parseFloat(fees?.relayer?.amountUsd || '0') +\n Number.parseFloat(fees?.relayerGas?.amountUsd || '0') +\n Number.parseFloat(fees?.relayerService?.amountUsd || '0')\n const relayLpFeesFromAmount =\n Number.parseFloat(fees?.relayer?.amountFormatted || '0') +\n Number.parseFloat(fees?.relayerGas?.amountFormatted || '0') +\n Number.parseFloat(fees?.relayerService?.amountFormatted || '0')\n const relayLpFeesFromAmountBaseUnit =\n BigInt(fees?.relayer?.amount || '0') +\n BigInt(fees?.relayerGas?.amount || '0') +\n BigInt(fees?.relayerService?.amount || '0')\n\n const totalLpFeesUsd = funLpFeesUsd + relayLpFeesUsd\n const totalLpFeesFromAmount = funLpFeesFromAmount + relayLpFeesFromAmount\n const totalLpFeesFromAmountBaseUnit =\n funLpFeesFromAmountBaseUnit + relayLpFeesFromAmountBaseUnit\n\n logger.info('parseRelayFees', {\n relayGasFeesUsd,\n funLpFeesUsd,\n funLpFeesFromAmount,\n funLpFeesFromAmountBaseUnit,\n relayLpFeesUsd,\n relayLpFeesFromAmount,\n relayLpFeesFromAmountBaseUnit,\n totalLpFeesUsd,\n totalLpFeesFromAmount,\n totalLpFeesFromAmountBaseUnit,\n })\n\n return {\n relayGasFeesUsd,\n totalLpFeesUsd,\n totalFeesUsd: relayGasFeesUsd + totalLpFeesUsd,\n totalFeesFromAmount: totalLpFeesFromAmount,\n totalFeesFromAmountBaseUnit: totalLpFeesFromAmountBaseUnit,\n }\n}\n", "import { MAINNET_RELAY_API } from '@reservoir0x/relay-sdk'\nimport type { RelayTokenPriceInfo } from './types'\n\nexport async function getRelayAssetPriceInfo({\n chainId,\n address,\n}: {\n chainId: string\n address: string\n}): Promise<RelayTokenPriceInfo> {\n const url = `${MAINNET_RELAY_API}/currencies/token/price?chainId=${chainId}&address=${address}`\n const response = await fetch(url)\n if (!response.ok) {\n throw Error(response.statusText)\n }\n\n const data = await response.json()\n return data as RelayTokenPriceInfo\n}\n", "import type { Execute, GetQuoteParameters } from '@reservoir0x/relay-sdk'\nimport { type Address, encodeFunctionData } from 'viem'\nimport { getRelayClient } from './client'\nimport {\n FUN_RELAY_REFERRER,\n FUN_RELAY_REVENUE_WALLET,\n RELAY_QUOTE_CHECKOUT_TIME_BUFFER_MS,\n} from './constants'\nimport { getFunRelayFees, parseRelayFees } from './fees'\nimport type {\n ApiFunkitCheckoutActionParams,\n CheckoutQuoteResponse,\n Logger,\n} from './types'\nimport { convertFunToRelayTokenAddress } from './utils'\n\ntype RelayQuoteOptions = GetQuoteParameters['options'] & {}\n\nexport type GetRelayQuoteParams = {\n actionParams?: ApiFunkitCheckoutActionParams[]\n fromChainId: string\n fromTokenAddress: Address\n logger: Logger\n /**\n * {@link getRelayQuote} already sets {@link RelayQuoteOptions.appFees|appFees} and {@link RelayQuoteOptions.referrer|referrer}.\n * Only include them if you wish to override.\n */\n options?: RelayQuoteOptions\n recipientAddress: Address | undefined\n toChainId: string\n toTokenAddress: Address\n tradeType: 'EXACT_INPUT' | 'EXACT_OUTPUT'\n userAddress: Address | undefined\n clientId: string\n} & (\n | {\n fromTokenAmountBaseUnit: bigint | string\n tradeType: 'EXACT_INPUT'\n }\n | {\n toTokenAmountBaseUnit: bigint | string\n tradeType: 'EXACT_OUTPUT'\n }\n)\n\nexport type RelayQuote = CheckoutQuoteResponse & {\n /** Required for EXACT_INPUT checkouts */\n finalToAmountBaseUnit: string\n metadata: {\n fromAmountBaseUnit: string\n relayQuote: Execute\n toAmountBaseUnit: string\n }\n}\n\nexport async function getRelayQuote({\n logger,\n ...params\n}: GetRelayQuoteParams): Promise<RelayQuote> {\n const {\n actionParams,\n fromChainId,\n fromTokenAddress,\n options,\n recipientAddress,\n toChainId,\n toTokenAddress,\n userAddress,\n clientId,\n } = params\n\n try {\n const relayClient = getRelayClient()\n\n const isExactIn = params.tradeType === 'EXACT_INPUT'\n const tokenAmountBaseUnit = isExactIn\n ? params.fromTokenAmountBaseUnit\n : params.toTokenAmountBaseUnit\n\n const txs = actionParams?.map((action) => {\n const data = encodeFunctionData({\n abi: action.contractAbi,\n args: action.functionArgs,\n functionName: action.functionName,\n })\n\n return {\n data,\n to: action.contractAddress,\n value: String(action.value ?? 0n),\n }\n })\n\n const quoteParamsWithoutAppFees = {\n chainId: Number(fromChainId),\n toChainId: Number(toChainId),\n currency: convertFunToRelayTokenAddress(fromTokenAddress),\n toCurrency: convertFunToRelayTokenAddress(toTokenAddress),\n amount: tokenAmountBaseUnit.toString(),\n recipient: recipientAddress,\n tradeType: params.tradeType,\n user: userAddress,\n ...(txs && { txs }),\n options: {\n referrer: clientId\n ? `${FUN_RELAY_REFERRER}|${clientId}`\n : FUN_RELAY_REFERRER,\n ...options,\n },\n }\n\n const quoteWithoutFees = await relayClient.actions.getQuote(\n quoteParamsWithoutAppFees,\n )\n\n const estUsdValue = quoteWithoutFees.details?.currencyIn?.amountUsd\n\n const feeInfo = await getFunRelayFees({\n fromTokenAddress,\n fromChainId,\n toTokenAddress,\n toChainId,\n estUsdValue: Number(estUsdValue) || 0,\n clientId,\n })\n const appFeeBp = feeInfo.b + feeInfo.v\n\n logger.info('getRelayQuoteParams', {\n ...params,\n tokenAmountBaseUnit,\n txs,\n quoteWithoutFees,\n feeInfo,\n appFeeBp,\n })\n\n // Get the full quote with fees\n const relayQuote = await relayClient.actions.getQuote({\n ...quoteParamsWithoutAppFees,\n options: {\n ...quoteParamsWithoutAppFees.options,\n appFees: [\n {\n fee: appFeeBp.toString(),\n recipient: FUN_RELAY_REVENUE_WALLET,\n },\n ],\n },\n })\n\n // TODO: Handling for no route response\n\n logger.info('relayQuote', relayQuote)\n\n const estSubtotalUsd = Number(\n relayQuote.details?.currencyOut?.amountUsd || 0,\n )\n const estTotalUsd = Number(relayQuote.details?.currencyIn?.amountUsd || 0)\n // Get how much fromAmount is needed for the quote\n const fromAmountString =\n relayQuote.details?.currencyIn?.amountFormatted || '0'\n const fromAmountBaseUnitString =\n relayQuote.details?.currencyIn?.amount || '0'\n\n // RequestID will be consistent across steps in the quote\n // https://fun-xyz.slack.com/archives/C08MQ85QB2N/p1747774944603209\n const relayRequestId = relayQuote.steps[0]?.requestId\n\n // TODO: Verify with relay team if this is possible?\n if (!relayRequestId) {\n throw new Error('Relay quote does not contain a requestId')\n }\n\n // TODO: Verify with relay team if this is possible?\n if (!relayQuote.details?.currencyIn || !relayQuote.details?.currencyOut) {\n throw new Error('Relay quote does not contain trade details')\n }\n\n const {\n relayGasFeesUsd,\n totalLpFeesUsd,\n totalFeesUsd,\n totalFeesFromAmount,\n totalFeesFromAmountBaseUnit,\n } = parseRelayFees({ fees: relayQuote.fees, logger })\n\n const estSubtotalFromAmount = (\n Number.parseFloat(fromAmountString) - totalFeesFromAmount\n ).toString()\n\n const estSubtotalFromAmountBaseUnit = (\n BigInt(fromAmountBaseUnitString) - totalFeesFromAmountBaseUnit\n ).toString()\n\n return {\n quoteId: relayRequestId,\n estCheckoutTimeMs:\n (relayQuote.details.timeEstimate || 0) * 1000 +\n RELAY_QUOTE_CHECKOUT_TIME_BUFFER_MS,\n estFeesFromAmount: totalFeesFromAmount.toString(),\n estFeesFromAmountBaseUnit: totalFeesFromAmountBaseUnit.toString(),\n estFeesUsd: totalFeesUsd,\n estMarketMakerGasUsd: relayGasFeesUsd,\n estSubtotalFromAmount,\n estSubtotalFromAmountBaseUnit,\n estSubtotalUsd,\n estTotalFromAmount: fromAmountString,\n estTotalFromAmountBaseUnit: fromAmountBaseUnitString,\n estTotalUsd,\n finalToAmountBaseUnit: relayQuote.details.currencyOut.amount ?? '0', // TODO: Or do we want 'minimumAmount'?\n fromTokenAddress,\n lpFeePercentage: 0, // TODO: ?\n lpFeeUsd: totalLpFeesUsd,\n metadata: {\n fromAmountBaseUnit:\n params.tradeType === 'EXACT_INPUT'\n ? tokenAmountBaseUnit.toString()\n : (relayQuote.details.currencyIn.amount ?? '0'),\n relayQuote,\n toAmountBaseUnit:\n params.tradeType === 'EXACT_INPUT'\n ? (relayQuote.details.currencyOut.amount ?? '0')\n : tokenAmountBaseUnit.toString(),\n },\n }\n } catch (err) {\n throw new Error(\n `An error occurred trying to generate a relay quote: ${\n err instanceof Error ? err.message : JSON.stringify(err)\n }`,\n )\n }\n}\n", "import type { Address } from 'viem'\nimport {\n FUNKIT_NATIVE_TOKEN,\n RELAY_NATIVE_TOKEN,\n RELAY_TERMINAL_STATUSES,\n} from './constants'\nimport {\n CheckoutRefundState,\n CheckoutState,\n type RelayExecutionInfo,\n} from './types'\n\n/**\n * Converts a token address within Funkit the corresponding Relay token address.\n */\nexport function convertFunToRelayTokenAddress(address: Address): Address {\n if (address.toLowerCase() === FUNKIT_NATIVE_TOKEN.toLowerCase()) {\n return RELAY_NATIVE_TOKEN\n }\n\n return address\n}\n\nexport function getRelayExecutionRefundState(\n info: RelayExecutionInfo,\n): CheckoutRefundState | undefined {\n switch (info.status) {\n case 'refund':\n return CheckoutRefundState.REFUNDED\n default:\n return undefined\n }\n}\n\nexport function getRelayExecutionState(\n info: RelayExecutionInfo,\n): CheckoutState {\n switch (info.status) {\n case 'success':\n return CheckoutState.COMPLETED\n case 'failure':\n case 'refund':\n return CheckoutState.CHECKOUT_ERROR\n default:\n return CheckoutState.PENDING_RECEIVAL\n }\n}\n\n/**\n * Checks whether the Relay execution has reached a terminal status.\n */\nexport function isRelayExecutionTerminalStatus(\n info: RelayExecutionInfo,\n): boolean {\n return RELAY_TERMINAL_STATUSES.includes(info.status)\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,
|
|
6
|
-
"names": ["import_relay_sdk", "import_relay_sdk", "import_relay_sdk"]
|
|
3
|
+
"sources": ["../index.ts", "../src/client.ts", "../src/types.ts", "../src/constants.ts", "../src/execution.ts", "../src/fees.ts", "../src/price.ts", "../src/quote.ts", "../src/currency.ts", "../src/utils.ts", "../src/solana.ts"],
|
|
4
|
+
"sourcesContent": ["export {\n getRelayClient,\n initializeRelayClient,\n type InitializeRelayClientParams,\n} from './src/client'\nexport {\n FUN_RELAY_REFERRER,\n FUN_RELAY_REVENUE_WALLET,\n RELAY_SOLANA_CHAIN_ID,\n RELAY_SOLANA_CHAIN_ID_NUMBER,\n RELAY_TERMINAL_STATUSES,\n} from './src/constants'\nexport {\n type ExecuteRelayQuoteParams,\n type RelayAddress,\n type RelayChainId,\n type RelayExecutionStep,\n type RelayTxHash,\n type RelayVmType,\n type RelayWallet,\n executeRelayQuote,\n getRelayExecutionInfo,\n} from './src/execution'\nexport { parseRelayFees } from './src/fees'\nexport { getRelayAssetPriceInfo } from './src/price'\nexport {\n type GetRelayQuoteParams,\n type RelayQuote,\n getRelayQuote,\n} from './src/quote'\nexport {\n type SolanaAddress,\n type SolanaTxHash,\n type SolanaWallet,\n getSolanaWallet,\n} from './src/solana'\nexport {\n getRelayExecutionRefundState,\n getRelayExecutionState,\n isRelayExecutionTerminalStatus,\n convertFunToRelayTokenAddress,\n} from './src/utils'\nexport {\n LogLevel,\n type RelayExecutionInfo,\n type RelayExecutionStatus,\n type RelayTokenPriceInfo,\n} from './src/types'\n", "import {\n MAINNET_RELAY_API,\n type RelayClient,\n type RelayClientOptions,\n convertViemChainToRelayChain,\n createClient,\n getClient,\n} from '@reservoir0x/relay-sdk'\nimport type { Chain } from 'viem'\nimport { RELAY_SOLANA_CHAIN_ID_NUMBER } from './constants'\nimport type { Logger } from './types'\n\nexport type InitializeRelayClientParams = Omit<\n RelayClientOptions,\n 'baseApiUrl' | 'chains' | 'logger'\n> & {\n chains: Chain[]\n logger: Logger\n}\n\n/**\n * Initializes a global instance of the RelayClient\n * https://docs.relay.link/references/sdk/createClient\n */\nexport function initializeRelayClient({\n chains,\n logger,\n ...options\n}: InitializeRelayClientParams): RelayClient {\n return createClient({\n ...options,\n baseApiUrl: MAINNET_RELAY_API,\n chains: [\n ...chains.map(convertViemChainToRelayChain),\n {\n id: RELAY_SOLANA_CHAIN_ID_NUMBER,\n name: 'Solana',\n displayName: 'Solana',\n },\n ],\n logger: (message) => {\n logger.info('[RelayClient]:', message)\n },\n })\n}\n\n/**\n * Gets the global instance of the RelayClient\n */\nexport function getRelayClient(): RelayClient {\n const client = getClient()\n\n if (!client) {\n throw new Error('Relay client is not defined')\n }\n\n return client\n}\n", "import { LogLevel } from '@reservoir0x/relay-sdk'\nimport type { Abi, Address } from 'viem'\n\nexport { LogLevel }\n\n// https://docs.relay.link/references/api/get-intents-status-v2\nexport interface RelayExecutionInfo {\n status: RelayExecutionStatus\n details: string\n /** Incoming transaction hashes */\n inTxHashes: string[]\n /** Outgoing transaction hashes */\n txHashes: string[]\n /** The last timestamp the data was updated in milliseconds */\n time: number\n originChainId: number\n destinationChainId: number\n}\n\n// https://docs.relay.link/references/api/get-token-price\nexport interface RelayTokenPriceInfo {\n price: number\n}\n\n//// The types below are duplicated from @funkit/api-base atm, but this package should be used in BE as well\n//// TODO: Are we fine with BE importing @funkit/api-base and (by extension) @funkit/utils?\n//// See https://linear.app/funxyz/issue/PE-1342/sdk-extract-domainsrelayts-to-a-new-package#comment-d487d533\n\nexport interface Logger {\n error(message: string, data?: object): void\n info(message: string, data?: object): void\n}\n\n// Reference: https://github.com/reservoirprotocol/relay-kit/blob/211c645f9702a3b459ff545aa4e2e9d536c38455/packages/sdk/src/types/Execute.ts#L54-L61\nexport enum RelayExecutionStatus {\n DELAYED = 'delayed',\n FAILURE = 'failure',\n PENDING = 'pending',\n REFUND = 'refund',\n SUCCESS = 'success',\n WAITING = 'waiting',\n UNKNOWN = 'unknown',\n}\n\nexport interface ApiFunkitCheckoutActionParams {\n contractAbi: Abi\n contractAddress: Address\n functionName: string\n functionArgs: unknown[]\n value?: bigint\n}\n\nexport enum CheckoutRefundState {\n INITIATED = 'INITIATED',\n ERROR = 'ERROR',\n REFUNDED = 'REFUNDED',\n PROCEEDED = 'PROCEEDED',\n WAITING_FOR_FULFILLMENT = 'WAITING_FOR_FULFILLMENT',\n FULFILLED = 'FULFILLED',\n}\n\n// Reference from api server: https://github.com/fun-xyz/fun-api-server/blob/main/src/tables/FunWalletCheckout.ts#L11C1-L21C2\nexport enum CheckoutState {\n // In-progress States\n FROM_UNFUNDED = 'FROM_UNFUNDED',\n FROM_FUNDED = 'FROM_FUNDED',\n FROM_POOLED = 'FROM_POOLED',\n TO_UNFUNDED = 'TO_UNFUNDED',\n TO_FUNDED = 'TO_FUNDED',\n TO_POOLED = 'TO_POOLED',\n TO_READY = 'TO_READY',\n PENDING_RECEIVAL = 'PENDING_RECEIVAL',\n // Terminal States\n COMPLETED = 'COMPLETED',\n CHECKOUT_ERROR = 'CHECKOUT_ERROR',\n EXPIRED = 'EXPIRED',\n CANCELLED = 'CANCELLED',\n}\n\n// The response of the actual /checkout/quote api\nexport type CheckoutApiQuoteResponse = {\n quoteId: string\n estTotalFromAmountBaseUnit: string\n estSubtotalFromAmountBaseUnit: string\n estFeesFromAmountBaseUnit: string\n fromTokenAddress: Address\n estFeesUsd: number\n estSubtotalUsd: number\n estTotalUsd: number\n estCheckoutTimeMs: number\n estMarketMakerGasUsd: number\n lpFeePercentage: number\n lpFeeUsd: number\n}\n\n// The formatted response quote interface from the core sdk\nexport type CheckoutQuoteResponse = CheckoutApiQuoteResponse & {\n estTotalFromAmount: string\n estSubtotalFromAmount: string\n estFeesFromAmount: string\n\n // Any additional fields purely for frontend use\n metadata?: { [key: string]: unknown }\n}\n", "import type { Address } from 'viem'\nimport { RelayExecutionStatus } from './types'\n\n/**\n * Chain id that Relay uses to identify Solana\n *\n * See https://docs.relay.link/references/sdk/adapters#how-can-i-use-an-adapter%3F\n */\nexport const RELAY_SOLANA_CHAIN_ID_NUMBER = 792703809 // Why cannot Relay export this themselves... -.-\nexport const RELAY_SOLANA_CHAIN_ID = `${RELAY_SOLANA_CHAIN_ID_NUMBER}`\n\n/**\n * Fake address for a chain's native currency used by Funkit\n */\nexport const FUNKIT_NATIVE_TOKEN =\n '0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee' satisfies Address\n\n/**\n * Fake address for a chain's native currency used by Relay\n */\nexport const RELAY_NATIVE_TOKEN =\n '0x0000000000000000000000000000000000000000' satisfies Address\n\n/**\n * Wallet that receives the app fees collected by Relay\n */\nexport const FUN_RELAY_REVENUE_WALLET =\n '0xb61562d83aEC43a050A06BED12Ac2bD8f9BFfd5E' satisfies Address\n\n/**\n * Referred field in Relay quote\n */\nexport const FUN_RELAY_REFERRER = 'funxyz'\n\n/**\n * Buffer added to Relay's time estimate (which sometimes is 0)\n */\nexport const RELAY_QUOTE_CHECKOUT_TIME_BUFFER_MS = 25_000 // 25 seconds\n\nexport const RELAY_TERMINAL_STATUSES: RelayExecutionStatus[] = [\n RelayExecutionStatus.REFUND,\n RelayExecutionStatus.FAILURE,\n RelayExecutionStatus.SUCCESS,\n]\n", "import { MAINNET_RELAY_API, type ProgressData } from '@reservoir0x/relay-sdk'\nimport type { Address, Hex, WalletClient } from 'viem'\nimport { getRelayClient } from './client'\nimport type { RELAY_SOLANA_CHAIN_ID } from './constants'\nimport type { RelayQuoteResult } from './quote'\nimport type { SolanaAddress, SolanaTxHash, SolanaWallet } from './solana'\nimport type { Logger, RelayExecutionInfo } from './types'\n\nexport type RelayExecutionStep = ProgressData['currentStep'] & {}\n\nexport type RelayVmType = 'evm' | 'solana'\n\nexport type RelayAddress<VmType extends RelayVmType = RelayVmType> = {\n evm: Address\n solana: SolanaAddress\n}[VmType]\n\nexport type RelayChainId<VmType extends RelayVmType = RelayVmType> = {\n evm: string\n solana: typeof RELAY_SOLANA_CHAIN_ID\n}[VmType]\n\nexport type RelayTxHash<VmType extends RelayVmType = RelayVmType> = {\n evm: Hex\n solana: SolanaTxHash\n}[VmType]\n\nexport type RelayWallet<VmType extends RelayVmType = RelayVmType> = {\n evm: WalletClient\n solana: SolanaWallet\n}[VmType]\n\nexport interface ExecuteRelayQuoteParams<VmType extends RelayVmType> {\n logger: Logger\n onConfirmed: (txHash: RelayTxHash<VmType>) => Promise<void>\n onError: (error: Error) => Promise<void>\n onProgress?: (step: RelayExecutionStep | null) => void\n relayQuote: RelayQuoteResult<VmType>\n walletClient: RelayWallet<VmType>\n}\n\nexport async function executeRelayQuote<VmType extends RelayVmType>({\n logger,\n onConfirmed,\n onError,\n onProgress,\n relayQuote,\n walletClient,\n}: ExecuteRelayQuoteParams<VmType>): Promise<void> {\n await getRelayClient().actions.execute({\n quote: relayQuote,\n wallet: walletClient,\n onProgress: async ({\n steps,\n fees,\n breakdown,\n currentStep,\n currentStepItem,\n txHashes,\n details,\n error,\n }) => {\n const logPrefix = 'onRelayProgress'\n logger.info(`${logPrefix}:params`, {\n steps,\n currentStep,\n fees,\n breakdown,\n currentStepItem,\n txHashes,\n details,\n error,\n })\n\n onProgress?.(currentStep ?? null)\n\n if (error) {\n logger.info(`${logPrefix}:errorDetected`, error)\n await onError(error).catch((e) => {\n logger.error(`${logPrefix}:onErrorFailed`, e)\n })\n } else if (\n // We can redirect as soon as all the required user steps are done\n // https://fun-xyz.slack.com/archives/C08MQ85QB2N/p1748381169792379\n txHashes &&\n txHashes.length > 0 &&\n txHashes.length === steps.length\n ) {\n logger.info(`${logPrefix}:completed`, txHashes)\n // Can we assume its completed here?\n // Use first txHash as the main txHash in fun DE table\n const txHash = txHashes[0].txHash as RelayTxHash<VmType>\n await onConfirmed(txHash).catch((e) => {\n logger.error(`${logPrefix}:onConfirmedFailed`, e)\n })\n }\n },\n })\n}\n\nexport async function getRelayExecutionInfo(\n requestId: string,\n): Promise<RelayExecutionInfo> {\n const url = `${MAINNET_RELAY_API}/intents/status/v2?requestId=${requestId}`\n const response = await fetch(url)\n if (!response.ok) {\n throw Error(response.statusText)\n }\n\n const data = await response.json()\n return data as RelayExecutionInfo\n}\n", "import type { CallFees } from '@reservoir0x/relay-sdk'\nimport type { Logger } from './types'\n\nexport interface FunRelayFeeItem {\n b: number\n v: number\n}\n\nexport async function getFunRelayFees({\n fromTokenAddress,\n fromChainId,\n toTokenAddress,\n toChainId,\n estUsdValue,\n clientId,\n}: {\n fromTokenAddress: string\n fromChainId: string\n toTokenAddress: string\n toChainId: string\n estUsdValue: number\n clientId: string\n}): Promise<FunRelayFeeItem> {\n const url = `https://frog.fun.xyz/api/fee?fromTokenAddress=${fromTokenAddress}&fromChainId=${fromChainId}&toTokenAddress=${toTokenAddress}&toChainId=${toChainId}&estUsdValue=${estUsdValue}&clientId=${clientId}`\n const response = await fetch(url)\n if (!response.ok) {\n throw Error(response.statusText)\n }\n\n const data = await response.json()\n return data\n}\n\nexport function parseRelayFees({\n fees,\n logger,\n}: {\n fees: CallFees | undefined\n logger: Logger\n}) {\n // Gas fees, denominated in source chain native token\n const relayGasFeesUsd = Number.parseFloat(fees?.gas?.amountUsd || '0')\n\n // App fees, denominated in source chain token\n const funLpFeesUsd = Number.parseFloat(fees?.app?.amountUsd || '0')\n const funLpFeesFromAmount = Number.parseFloat(\n fees?.app?.amountFormatted || '0',\n )\n const funLpFeesFromAmountBaseUnit = BigInt(fees?.app?.amount || '0')\n\n // Relay fees, denominated in source chain token\n const relayLpFeesUsd = Number.parseFloat(fees?.relayer?.amountUsd || '0')\n const relayLpFeesFromAmount = Number.parseFloat(\n fees?.relayer?.amountFormatted || '0',\n )\n const relayLpFeesFromAmountBaseUnit = BigInt(fees?.relayer?.amount || '0')\n\n const totalLpFeesUsd = funLpFeesUsd + relayLpFeesUsd\n const totalLpFeesFromAmount = funLpFeesFromAmount + relayLpFeesFromAmount\n const totalLpFeesFromAmountBaseUnit =\n funLpFeesFromAmountBaseUnit + relayLpFeesFromAmountBaseUnit\n\n logger.info('parseRelayFees', {\n relayGasFeesUsd,\n funLpFeesUsd,\n funLpFeesFromAmount,\n funLpFeesFromAmountBaseUnit,\n relayLpFeesUsd,\n relayLpFeesFromAmount,\n relayLpFeesFromAmountBaseUnit,\n totalLpFeesUsd,\n totalLpFeesFromAmount,\n totalLpFeesFromAmountBaseUnit,\n })\n\n return {\n relayGasFeesUsd,\n totalLpFeesUsd,\n totalFeesUsd: relayGasFeesUsd + totalLpFeesUsd,\n totalFeesFromAmount: totalLpFeesFromAmount,\n totalFeesFromAmountBaseUnit: totalLpFeesFromAmountBaseUnit,\n }\n}\n", "import { MAINNET_RELAY_API } from '@reservoir0x/relay-sdk'\nimport type { RelayTokenPriceInfo } from './types'\n\nexport async function getRelayAssetPriceInfo({\n chainId,\n address,\n}: {\n chainId: string\n address: string\n}): Promise<RelayTokenPriceInfo> {\n const url = `${MAINNET_RELAY_API}/currencies/token/price?chainId=${chainId}&address=${address}`\n const response = await fetch(url)\n if (!response.ok) {\n throw Error(response.statusText)\n }\n\n const data = await response.json()\n return data as RelayTokenPriceInfo\n}\n", "import type { Execute, GetQuoteParameters } from '@reservoir0x/relay-sdk'\nimport { type Address, encodeFunctionData } from 'viem'\nimport { getRelayClient } from './client'\nimport {\n FUN_RELAY_REFERRER,\n FUN_RELAY_REVENUE_WALLET,\n RELAY_QUOTE_CHECKOUT_TIME_BUFFER_MS,\n} from './constants'\nimport { getRelayAssetInfo } from './currency'\nimport type {\n RelayAddress,\n RelayChainId,\n RelayVmType,\n RelayWallet,\n} from './execution'\nimport { getFunRelayFees, parseRelayFees } from './fees'\nimport { getRelayAssetPriceInfo } from './price'\nimport type {\n ApiFunkitCheckoutActionParams,\n CheckoutQuoteResponse,\n Logger,\n} from './types'\nimport { convertFunToRelayTokenAddress } from './utils'\n\ntype RelayQuoteOptions = GetQuoteParameters['options'] & {}\n\nexport type RelayQuoteResult<VmType extends RelayVmType> = Execute & {\n __vm: VmType\n}\n\nexport type GetRelayQuoteParams<\n SourceVmType extends RelayVmType = RelayVmType,\n TargetVmType extends RelayVmType = RelayVmType,\n> = {\n actionParams?: ApiFunkitCheckoutActionParams[]\n clientId: string\n fromChainId: RelayChainId<SourceVmType>\n fromTokenAddress: RelayAddress<SourceVmType>\n logger: Logger\n /**\n * {@link getRelayQuote} already sets {@link RelayQuoteOptions.appFees|appFees} and {@link RelayQuoteOptions.referrer|referrer}.\n * Only include them if you wish to override.\n */\n options?: RelayQuoteOptions\n recipientAddress: RelayAddress<TargetVmType> | undefined\n toChainId: RelayChainId<TargetVmType>\n toTokenAddress: RelayAddress<TargetVmType>\n tradeType: 'EXACT_INPUT' | 'EXACT_OUTPUT' | 'EXPECTED_OUTPUT'\n userAddress: RelayAddress<SourceVmType> | undefined\n walletClient?: RelayWallet<SourceVmType>\n} & (\n | {\n fromTokenAmountBaseUnit: bigint | string\n tradeType: 'EXACT_INPUT'\n }\n | {\n toTokenAmountBaseUnit: bigint | string\n tradeType: 'EXACT_OUTPUT' | 'EXPECTED_OUTPUT'\n }\n)\n\nexport type RelayQuote<VmType extends RelayVmType = RelayVmType> =\n CheckoutQuoteResponse & {\n /** Required for EXACT_INPUT checkouts */\n finalToAmountBaseUnit: string\n metadata: {\n fromAmountBaseUnit: string\n relayQuote: RelayQuoteResult<VmType>\n toAmountBaseUnit: string\n }\n }\n\nasync function getQuoteEstUsdValue({\n tokenChainId,\n tokenAddress,\n tokenAmountBaseUnit,\n logger,\n}: {\n tokenChainId: string\n tokenAddress: string\n tokenAmountBaseUnit: string\n logger: Logger\n}) {\n try {\n const [tokenPriceRes, tokenInfoRes] = await Promise.all([\n getRelayAssetPriceInfo({\n chainId: tokenChainId,\n address: convertFunToRelayTokenAddress(tokenAddress as Address),\n }),\n getRelayAssetInfo({\n chainId: tokenChainId,\n address: convertFunToRelayTokenAddress(tokenAddress as Address),\n }),\n ])\n\n const price = tokenPriceRes.price\n const decimals = tokenInfoRes.decimals\n\n const absoluteAmount = BigInt(tokenAmountBaseUnit) / BigInt(10 ** decimals)\n return Number(price) * Number(absoluteAmount)\n } catch (err) {\n logger.error('getQuoteEstUsdValueError', {\n message: `Failed to get USD value for token ${tokenAddress} on chain ${tokenChainId}: ${\n err instanceof Error ? err.message : JSON.stringify(err)\n }. Falling back to 0 USD.`,\n })\n // If any part fails, just fallback to 0 USD so that we do not block quote\n return 0\n }\n}\n\nexport async function getRelayQuote<\n SourceVmType extends RelayVmType,\n TargetVmType extends RelayVmType = RelayVmType,\n>({\n logger,\n walletClient,\n ...params\n}: GetRelayQuoteParams<SourceVmType, TargetVmType>): Promise<\n RelayQuote<SourceVmType>\n> {\n const {\n actionParams,\n clientId,\n fromChainId,\n fromTokenAddress,\n options,\n recipientAddress,\n toChainId,\n toTokenAddress,\n userAddress,\n } = params\n\n try {\n const relayClient = getRelayClient()\n\n const txs = actionParams?.map((action) => {\n const data = encodeFunctionData({\n abi: action.contractAbi,\n args: action.functionArgs,\n functionName: action.functionName,\n })\n\n return {\n data,\n to: action.contractAddress,\n value: String(action.value ?? 0n),\n }\n })\n\n const isExactIn = params.tradeType === 'EXACT_INPUT'\n const queryTokenAmountBaseUnit = isExactIn\n ? params.fromTokenAmountBaseUnit\n : params.toTokenAmountBaseUnit\n const queryTokenAddress = isExactIn ? fromTokenAddress : toTokenAddress\n const queryTokenChainId = isExactIn ? fromChainId : toChainId\n\n const estUsdValue = await getQuoteEstUsdValue({\n tokenChainId: queryTokenChainId,\n tokenAddress: queryTokenAddress,\n tokenAmountBaseUnit: queryTokenAmountBaseUnit.toString(),\n logger,\n })\n\n const feeInfo = await getFunRelayFees({\n fromTokenAddress,\n fromChainId,\n toTokenAddress,\n toChainId,\n estUsdValue: Number(estUsdValue) || 0,\n clientId,\n })\n\n const appFeeBp = feeInfo.b + feeInfo.v\n\n logger.info('getRelayQuoteParams', {\n ...params,\n queryTokenAmountBaseUnit,\n txs,\n estUsdValue,\n feeInfo,\n appFeeBp,\n })\n\n // Get the full quote with fees\n const relayQuote = await relayClient.actions.getQuote({\n chainId: Number(fromChainId),\n toChainId: Number(toChainId),\n currency: convertFunToRelayTokenAddress(fromTokenAddress),\n toCurrency: convertFunToRelayTokenAddress(toTokenAddress),\n amount: queryTokenAmountBaseUnit.toString(),\n recipient: recipientAddress,\n tradeType: params.tradeType,\n user: userAddress,\n wallet: walletClient,\n ...(txs && { txs }),\n options: {\n referrer: clientId\n ? `${FUN_RELAY_REFERRER}|${clientId}`\n : FUN_RELAY_REFERRER,\n appFees: [\n {\n fee: appFeeBp.toString(),\n recipient: FUN_RELAY_REVENUE_WALLET,\n },\n ],\n ...options,\n },\n })\n\n logger.info('relayQuote', relayQuote)\n\n const estSubtotalUsd = Number(\n relayQuote.details?.currencyOut?.amountUsd || 0,\n )\n const estTotalUsd = Number(relayQuote.details?.currencyIn?.amountUsd || 0)\n // Get how much fromAmount is needed for the quote\n const fromAmountString =\n relayQuote.details?.currencyIn?.amountFormatted || '0'\n const fromAmountBaseUnitString =\n relayQuote.details?.currencyIn?.amount || '0'\n\n // RequestID will be consistent across steps in the quote\n // https://fun-xyz.slack.com/archives/C08MQ85QB2N/p1747774944603209\n const relayRequestId = relayQuote.steps[0]?.requestId\n\n // TODO: Verify with relay team if this is possible?\n if (!relayRequestId) {\n throw new Error('Relay quote does not contain a requestId')\n }\n\n // TODO: Verify with relay team if this is possible?\n if (!relayQuote.details?.currencyIn || !relayQuote.details?.currencyOut) {\n throw new Error('Relay quote does not contain trade details')\n }\n\n const {\n relayGasFeesUsd,\n totalLpFeesUsd,\n totalFeesUsd,\n totalFeesFromAmount,\n totalFeesFromAmountBaseUnit,\n } = parseRelayFees({ fees: relayQuote.fees, logger })\n\n const estSubtotalFromAmount = (\n Number.parseFloat(fromAmountString) - totalFeesFromAmount\n ).toString()\n\n const estSubtotalFromAmountBaseUnit = (\n BigInt(fromAmountBaseUnitString) - totalFeesFromAmountBaseUnit\n ).toString()\n\n return {\n quoteId: relayRequestId,\n estCheckoutTimeMs:\n (relayQuote.details.timeEstimate || 0) * 1000 +\n RELAY_QUOTE_CHECKOUT_TIME_BUFFER_MS,\n estFeesFromAmount: totalFeesFromAmount.toString(),\n estFeesFromAmountBaseUnit: totalFeesFromAmountBaseUnit.toString(),\n estFeesUsd: totalFeesUsd,\n estMarketMakerGasUsd: relayGasFeesUsd,\n estSubtotalFromAmount,\n estSubtotalFromAmountBaseUnit,\n estSubtotalUsd,\n estTotalFromAmount: fromAmountString,\n estTotalFromAmountBaseUnit: fromAmountBaseUnitString,\n estTotalUsd,\n finalToAmountBaseUnit: relayQuote.details.currencyOut.amount ?? '0', // TODO: Or do we want 'minimumAmount'?\n fromTokenAddress: fromTokenAddress as Address, // TODO: fromTokenAddress is typed as `0x${string}` why does not accept SolanaAddress\n lpFeePercentage: 0, // TODO: ?\n lpFeeUsd: totalLpFeesUsd,\n metadata: {\n fromAmountBaseUnit: isExactIn\n ? queryTokenAmountBaseUnit.toString()\n : (relayQuote.details.currencyIn.amount ?? '0'),\n relayQuote: relayQuote as RelayQuoteResult<SourceVmType>,\n toAmountBaseUnit: isExactIn\n ? (relayQuote.details.currencyOut.amount ?? '0')\n : queryTokenAmountBaseUnit.toString(),\n },\n }\n } catch (err) {\n throw new Error(\n `An error occurred trying to generate a relay quote: ${\n err instanceof Error ? err.message : JSON.stringify(err)\n }`,\n )\n }\n}\n", "import { MAINNET_RELAY_API } from '@reservoir0x/relay-sdk'\n\nexport interface RelayTokenInfo {\n chainId: number\n address: string\n symbol: string\n name: string\n decimals: number\n vmType: string\n metadata: {\n logoURI: string\n verified: boolean\n isNative: boolean\n }\n}\n\nexport async function getRelayAssetInfo({\n chainId,\n address,\n}: {\n chainId: string\n address: string\n}): Promise<RelayTokenInfo> {\n const url = `${MAINNET_RELAY_API}/currencies/v2`\n const body = {\n chainIds: [chainId],\n address,\n }\n const response = await fetch(url, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify(body),\n })\n if (!response.ok) {\n throw Error(response.statusText)\n }\n\n const data = await response.json()\n return data?.[0] as RelayTokenInfo\n}\n", "import {\n FUNKIT_NATIVE_TOKEN,\n RELAY_NATIVE_TOKEN,\n RELAY_TERMINAL_STATUSES,\n} from './constants'\nimport type { RelayAddress, RelayVmType } from './execution'\nimport {\n CheckoutRefundState,\n CheckoutState,\n type RelayExecutionInfo,\n} from './types'\n\n/**\n * Converts a token address within Funkit the corresponding Relay token address.\n */\nexport function convertFunToRelayTokenAddress<T extends RelayVmType>(\n address: RelayAddress<T>,\n): RelayAddress<T> {\n if (address.toLowerCase() === FUNKIT_NATIVE_TOKEN.toLowerCase()) {\n return RELAY_NATIVE_TOKEN as RelayAddress<T>\n }\n\n return address\n}\n\nexport function getRelayExecutionRefundState(\n info: RelayExecutionInfo,\n): CheckoutRefundState | undefined {\n switch (info.status) {\n case 'refund':\n return CheckoutRefundState.REFUNDED\n default:\n return undefined\n }\n}\n\nexport function getRelayExecutionState(\n info: RelayExecutionInfo,\n): CheckoutState {\n switch (info.status) {\n case 'success':\n return CheckoutState.COMPLETED\n case 'failure':\n case 'refund':\n return CheckoutState.CHECKOUT_ERROR\n default:\n return CheckoutState.PENDING_RECEIVAL\n }\n}\n\n/**\n * Checks whether the Relay execution has reached a terminal status.\n */\nexport function isRelayExecutionTerminalStatus(\n info: RelayExecutionInfo,\n): boolean {\n return RELAY_TERMINAL_STATUSES.includes(info.status)\n}\n", "import type { AdaptedWallet } from '@reservoir0x/relay-sdk'\nimport { adaptSolanaWallet } from '@reservoir0x/relay-svm-wallet-adapter'\nimport {\n type Connection,\n SendTransactionError,\n type VersionedTransaction,\n} from '@solana/web3.js'\nimport { RELAY_SOLANA_CHAIN_ID_NUMBER } from './constants'\n\ntype Base58 =\n | '1'\n | '2'\n | '3'\n | '4'\n | '5'\n | '6'\n | '7'\n | '8'\n | '9'\n | 'A'\n | 'B'\n | 'C'\n | 'D'\n | 'E'\n | 'F'\n | 'G'\n | 'H'\n | 'J'\n | 'K'\n | 'L'\n | 'M'\n | 'N'\n | 'P'\n | 'Q'\n | 'R'\n | 'S'\n | 'T'\n | 'U'\n | 'V'\n | 'W'\n | 'X'\n | 'Y'\n | 'Z'\n | 'a'\n | 'b'\n | 'c'\n | 'd'\n | 'e'\n | 'f'\n | 'g'\n | 'h'\n | 'i'\n | 'j'\n | 'k'\n | 'm'\n | 'n'\n | 'o'\n | 'p'\n | 'q'\n | 'r'\n | 's'\n | 't'\n | 'u'\n | 'v'\n | 'w'\n | 'x'\n | 'y'\n | 'z'\n\nexport type SolanaAddress = `${Base58}${string}`\n\nexport type SolanaTxHash = `${Base58}${string}`\n\nexport type SolanaWallet = AdaptedWallet & {\n address(): Promise<SolanaAddress>\n}\n\nexport function getSolanaWallet(\n walletAddress: SolanaAddress,\n connection: Connection,\n signTransaction: (\n transaction: VersionedTransaction,\n ) => Promise<VersionedTransaction>,\n): SolanaWallet {\n return adaptSolanaWallet(\n walletAddress,\n RELAY_SOLANA_CHAIN_ID_NUMBER,\n connection,\n async (transaction, options) => {\n const signed = await signTransaction(transaction)\n try {\n const signature = await connection.sendTransaction(signed, {\n ...options,\n maxRetries: 5,\n })\n\n return { signature }\n } catch (error) {\n if (error instanceof SendTransactionError) {\n console.error(\n 'Failed transaction logs:',\n error,\n await error.getLogs(connection),\n )\n }\n\n throw error\n }\n },\n ) as SolanaWallet\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,oBAOO;;;ACPP,uBAAyB;;;ACQlB,IAAM,+BAA+B;AACrC,IAAM,wBAAwB,GAAG,4BAA4B;AAK7D,IAAM,sBACX;AAKK,IAAM,qBACX;AAKK,IAAM,2BACX;AAKK,IAAM,qBAAqB;AAK3B,IAAM,sCAAsC;AAE5C,IAAM,0BAAkD;AAAA;AAAA;AAAA;AAI/D;;;AFnBO,SAAS,sBAAsB;AAAA,EACpC;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAA6C;AAC3C,aAAO,gCAAa;AAAA,IAClB,GAAG;AAAA,IACH,YAAY;AAAA,IACZ,QAAQ;AAAA,MACN,GAAG,OAAO,IAAI,8CAA4B;AAAA,MAC1C;AAAA,QACE,IAAI;AAAA,QACJ,MAAM;AAAA,QACN,aAAa;AAAA,MACf;AAAA,IACF;AAAA,IACA,QAAQ,CAAC,YAAY;AACnB,aAAO,KAAK,kBAAkB,OAAO;AAAA,IACvC;AAAA,EACF,CAAC;AACH;AAKO,SAAS,iBAA8B;AAC5C,QAAM,aAAS,6BAAU;AAEzB,MAAI,CAAC,QAAQ;AACX,UAAM,IAAI,MAAM,6BAA6B;AAAA,EAC/C;AAEA,SAAO;AACT;;;AGzDA,IAAAC,oBAAqD;AAyCrD,eAAsB,kBAA8C;AAAA,EAClE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAAmD;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