@wormhole-foundation/sdk-evm-portico
Version:
SDK for EVM chains, used in conjunction with @wormhole-foundation/sdk
24 lines • 1.06 kB
JavaScript
import { encoding, isNative, toChainId, } from '@wormhole-foundation/sdk-connect';
import axios from 'axios';
export const RELAYER_FEE_API_URL = 'https://gfx.relayers.xlabs.xyz/api/v1/swap/quote';
export class PorticoApi {
static async quoteRelayer(chain, from, to) {
if (isNative(from) || isNative(to))
throw new Error('how did you get here tho?');
const sourceToken = encoding.hex.encode(from.toUniversalAddress().toUint8Array(), false);
const targetToken = encoding.hex.encode(to.toUniversalAddress().toUint8Array(), false);
const targetChain = toChainId(chain);
const request = { targetChain, sourceToken, targetToken };
try {
const response = await axios.post(RELAYER_FEE_API_URL, request);
return BigInt(response.data.fee);
}
catch (e) {
if (axios.isAxiosError(e)) {
throw new Error(`Error getting relayer fee: ${e.response?.statusText}`);
}
throw e;
}
}
}
//# sourceMappingURL=api.js.map