UNPKG

@bluefin-exchange/bluefin7k-aggregator-sdk

Version:
31 lines (30 loc) 981 B
import { API_ENDPOINTS } from "../../../constants/apiEndpoints"; const request = async (path, body) => { const res = await fetch(`${API_ENDPOINTS.MAIN}/${path}`, { method: "POST", body: JSON.stringify(body), headers: { "Content-Type": "application/json", }, }); return res.json(); }; export const sponsorBluefinX = async (body) => { return await request("bluefinx/sponsor", body); }; /** * Request BluefinX for signing sponsored tx and execute it * * @Warning * User must use this function to execute BluefinX tx, otherwise the tx will be rejected by BluefinX contract * @param tx - BluefinX tx which is generated by `buildTx` * @param signature - user signature after signing the transaction * @returns `SwapResponse` */ export const executeBluefinTx = async (tx, signature) => { return await request("bluefinx/swap", { quoteId: tx.quoteId, txBytes: tx.txBytes, signature, }); };