Enable Instant Actions

import { AvailableSolvers, SupportedChainId } from "@intentx/core";
import { TradingSDK } from "@intentx/trading-sdk";
import * as dotenv from "dotenv";

dotenv.config();

async function enableInstantActionsExample() {
  const tradingSDK = new TradingSDK({
    apiKey: process.env.API_KEY,
    baseUrl: process.env.API_BASE_URL ?? undefined,
  });

  const chainId = SupportedChainId.BASE;
  const targetSolver = AvailableSolvers.PERPS_HUB;
  const subaccountAddress = "0x52D953159a9a636944C9d96E14CB5DF0948323E9";

  await tradingSDK.authManager.loginWithPrivateKey(process.env.PRIVATE_KEY!);
  await tradingSDK.authManager.allowInstantAction({
    subaccountAddress,
    chainId,
    solver: targetSolver,
  });

  const isEnabled = await tradingSDK.authManager.verifyInstantActionAccess(
    subaccountAddress,
    targetSolver
  );
  console.log("Instant action enabled", isEnabled);
}

enableInstantActionsExample()
  .then(() => {
    console.log("Instant actions enabled");
  })
  .catch((error) => {
    console.error("Error opening position", error);
  });

Last updated