@t2000/cli 10.8.0 → 10.9.0

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.
@@ -13004,6 +13004,49 @@ async function buildTokenizeTx(args) {
13004
13004
  tx.transferObjects([usdcRefund], tx.pure.address(args.launcher));
13005
13005
  return tx;
13006
13006
  }
13007
+ init_errors();
13008
+ init_token_registry();
13009
+ var CETUS_INTEGRATE_PUBLISHED_AT = process.env.CETUS_INTEGRATE_PUBLISHED_AT ?? "0xfbb32ac0fa89a3cb0c56c745b688c6d2a53ac8e43447119ad822763997ffb9c3";
13010
+ var MIN_SQRT_PRICE = 4295048016n;
13011
+ var MAX_SQRT_PRICE = 79226673515401279992447579055n;
13012
+ async function buildDirectPoolSwapTx(args) {
13013
+ if (args.amountIn <= 0n) {
13014
+ throw new T2000Error("INVALID_AMOUNT", "amountIn must be positive");
13015
+ }
13016
+ const pool = await args.client.core.getObject({ objectId: args.poolId }).catch(() => null);
13017
+ const m = pool?.object?.type?.match(/Pool<(.+),\s*(.+)>$/);
13018
+ if (!m) {
13019
+ throw new T2000Error("PROTOCOL_UNAVAILABLE", `not a Cetus pool: ${args.poolId}`);
13020
+ }
13021
+ const [typeA, typeB] = [m[1].trim(), m[2].trim()];
13022
+ const aIsUsdc = typeA === USDC_TYPE;
13023
+ if (!aIsUsdc && typeB !== USDC_TYPE) {
13024
+ throw new T2000Error("INVALID_ASSET", "pool is not USDC-quoted");
13025
+ }
13026
+ const a2b = args.direction === "buy" ? aIsUsdc : !aIsUsdc;
13027
+ const inputType = args.direction === "buy" ? USDC_TYPE : a2b ? typeA : typeB;
13028
+ const tx = new Transaction();
13029
+ tx.setSender(args.sender);
13030
+ const input = coinWithBalance({ type: inputType, balance: args.amountIn });
13031
+ const vec = tx.makeMoveVec({ elements: [input] });
13032
+ tx.moveCall({
13033
+ target: `${CETUS_INTEGRATE_PUBLISHED_AT}::pool_script::${a2b ? "swap_a2b" : "swap_b2a"}`,
13034
+ typeArguments: [typeA, typeB],
13035
+ arguments: [
13036
+ tx.object(CETUS_GLOBAL_CONFIG_ID),
13037
+ tx.object(args.poolId),
13038
+ vec,
13039
+ tx.pure.bool(true),
13040
+ // by_amount_in
13041
+ tx.pure.u64(args.amountIn),
13042
+ tx.pure.u64(args.minOut),
13043
+ // amount_limit = the slippage floor
13044
+ tx.pure.u128(a2b ? MIN_SQRT_PRICE : MAX_SQRT_PRICE),
13045
+ tx.object.clock()
13046
+ ]
13047
+ });
13048
+ return tx;
13049
+ }
13007
13050
 
13008
13051
  export {
13009
13052
  mapWalletError,
@@ -13195,7 +13238,9 @@ export {
13195
13238
  CAPITAL_REGISTRY_VERSION,
13196
13239
  MIN_LP_USDC,
13197
13240
  buildPublishAgentCoinTx,
13198
- buildTokenizeTx
13241
+ buildTokenizeTx,
13242
+ CETUS_INTEGRATE_PUBLISHED_AT,
13243
+ buildDirectPoolSwapTx
13199
13244
  };
13200
13245
  /*! Bundled license information:
13201
13246
 
@@ -13217,4 +13262,4 @@ export {
13217
13262
  @scure/bip39/index.js:
13218
13263
  (*! scure-bip39 - MIT License (c) 2022 Patricio Palladino, Paul Miller (paulmillr.com) *)
13219
13264
  */
13220
- //# sourceMappingURL=chunk-UJVDLYP3.js.map
13265
+ //# sourceMappingURL=chunk-GYI3QQGY.js.map