import { M as e, N as p } from "./types-iFgwQ7vG.mjs";
import { ac as T, a as k, i as C, ad as w, ae as M, af as D, W as m, u as N, ag as E, e as A, h as S } from "./platform-Cil_UtAQ.mjs";
import { M as x } from "./multiToken-Bm-K5dRJ.mjs";
import "./index-BXsTZ9x_.mjs";
class P extends T {
  static NATIVE_GAS_DROPOFF_SUPPORTED = !1;
  static IS_AUTOMATIC = !1;
  // @ts-ignore
  // Since we set the config on the static class, access it with this param
  // the MultiTokenNttManualRoute.config will always be empty
  staticConfig = this.constructor.config;
  static config = { contracts: [] };
  static meta = { name: "MultiTokenNttManualRoute" };
  static supportedNetworks() {
    return e.resolveSupportedNetworks(this.config.contracts);
  }
  static supportedChains(t) {
    return e.resolveSupportedChains(this.config.contracts, t);
  }
  static async supportedDestinationTokens(t, a, n) {
    return [await e.getDestinationTokenId(t, a, n, this.config.contracts)];
  }
  static isProtocolSupported(t) {
    return t.supportsProtocol("MultiTokenNtt");
  }
  getDefaultOptions() {
    return {};
  }
  async isWrappedToken(t) {
    return await e.isWrappedToken(this.wh.getChain(t.chain), t, this.staticConfig.contracts);
  }
  async getOriginalToken(t) {
    return await e.getOriginalToken(this.wh.getChain(t.chain), t, this.staticConfig.contracts);
  }
  async validate(t, a) {
    if (t.fromChain.chain === t.toChain.chain)
      return {
        valid: !1,
        error: new Error("Source and destination chains must differ"),
        params: a
      };
    const n = a.options ?? this.getDefaultOptions(), i = k(a.amount, t.source.decimals), o = p.trimAmount(i, t.destination.decimals), s = e.resolveContracts(this.staticConfig.contracts, t.fromChain.chain), c = e.resolveContracts(this.staticConfig.contracts, t.toChain.chain), d = await t.fromChain.getProtocol("MultiTokenNtt", {
      multiTokenNtt: s
    }), u = C(t.source.id.address) ? await d.getWrappedNativeToken() : t.source.id, l = await d.getOriginalToken(u), g = await d.getSendTransceivers(t.toChain.chain), h = await this.estimateGasLimit(t, l);
    return { valid: !0, params: {
      amount: a.amount,
      normalizedParams: {
        amount: o,
        sourceContracts: s,
        destinationContracts: c,
        sourceTokenId: t.source.id,
        destinationTokenId: t.destination.id,
        originalTokenId: l,
        sendTransceivers: g,
        gasLimit: h
      },
      options: n
    } };
  }
  async estimateGasLimit(t, a) {
    return e.estimateGasLimit(t, a, this.staticConfig.contracts, this.staticConfig.perTokenOverrides);
  }
  async quote(t, a) {
    const n = w(a.normalizedParams.amount, t.destination.decimals), i = {
      success: !0,
      params: a,
      sourceToken: {
        token: t.source.id,
        amount: a.normalizedParams.amount
      },
      destinationToken: {
        token: t.destination.id,
        amount: n
      },
      eta: M(t.fromChain.chain) + D * 1e3
    }, { fromChain: o, toChain: s } = t, c = await s.getProtocol("MultiTokenNtt", {
      multiTokenNtt: a.normalizedParams.destinationContracts
    }), d = await c.getRateLimitDuration(), u = await e.checkRateLimit(c, o.chain, a.normalizedParams.originalTokenId, n, d);
    return u && (i.warnings = u), i;
  }
  async initiate(t, a, n, i) {
    const { params: o } = n, { fromChain: s } = t, c = m.parseAddress(a.chain(), a.address()), u = (await s.getProtocol("MultiTokenNtt", {
      multiTokenNtt: o.normalizedParams.sourceContracts
    })).transfer(c, o.normalizedParams.sourceTokenId.address, N(o.normalizedParams.amount), i, o.normalizedParams.gasLimit, this.staticConfig.axelarGasMultiplier), l = await E(s, u, a);
    return {
      from: s.chain,
      to: i.chain,
      state: A.SourceInitiated,
      originTxs: l,
      params: o,
      trackingInfo: { transceiverAttested: {} }
    };
  }
  async complete(t, a) {
    return await e.complete(t, this.wh.getChain(a.to), a);
  }
  async resume(t) {
    return await e.resume(t, this.wh, this.staticConfig.contracts);
  }
  async finalize(t, a) {
    return await e.finalize(t, this.wh.getChain(a.to), a);
  }
  async *track(t, a) {
    return yield* e.track(this.wh, t, !0, a);
  }
}
const I = {
  Mainnet: [],
  Testnet: [
    // These tokens have Wormhole versions deployed, so let users to bridge those instead
    m.tokenId("Monad", "0xf817257fed379853cDe0fa4F97AB987181B1E5Ea"),
    // USDC
    m.tokenId("Monad", "0x88b8E2161DEDC77EF4ab7585569D2415a1C1055D"),
    // USDT
    m.tokenId("Monad", "0xcf5a6076cfa32686c0Df13aBaDa2b40dec133F1d"),
    // WBTC
    m.tokenId("Monad", "0xB5a30b0FDc5EA94A52fDc42e3E9760Cb8449Fb37")
    // WETH
  ]
}, y = {
  Mainnet: [],
  Testnet: [
    {
      chain: "Sepolia",
      manager: "0x6c5aAE4622B835058A41879bA5e128019B9047d6",
      gmpManager: "0xDaeE3A6B4196E3e46015b364F1DAe54CEAE74A91"
    },
    {
      chain: "Monad",
      manager: "0x600D3C45Cd002E7359D12597Bb8058a0C32A20Df",
      gmpManager: "0x641a6608e2959c0D7Fe2a5F267DFDA519ED43d98"
    }
  ]
};
function f(r, t) {
  return !(I[t.network] || []).some((n) => S(n, r));
}
function z(r) {
  const t = y[r];
  if (!t)
    throw new Error(`No Monad NTT contracts configured for network ${r}`);
  return t;
}
function O(r) {
  class t extends x {
    static meta = {
      name: "MonadBridgeExecutorRoute"
    };
    static config = r;
    static async supportedDestinationTokens(n, i, o) {
      return f(n, i) ? super.supportedDestinationTokens(n, i, o) : [];
    }
  }
  return t;
}
function L(r) {
  class t extends P {
    static meta = {
      name: "MonadBridgeManualRoute"
    };
    static config = r;
    static async supportedDestinationTokens(n, i, o) {
      return f(n, i) ? super.supportedDestinationTokens(n, i, o) : [];
    }
  }
  return t;
}
export {
  z as getContractsForNetwork,
  O as monadBridgeExecutorRoute,
  L as monadBridgeManualRoute
};
