@minswap/noodles-sdk 0.0.10 → 0.0.12

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.
package/dist/index.cjs CHANGED
@@ -45,11 +45,10 @@ __webpack_require__.d(__webpack_exports__, {
45
45
  BlastFunCustomTransaction: ()=>custom_transaction_BlastFunCustomTransaction,
46
46
  BASE_BPS: ()=>BASE_BPS,
47
47
  MoonbagsConstants: ()=>constants_MoonbagsConstants,
48
- getSuiClient: ()=>getSuiClient,
48
+ splitSuiCoinAfterFeeFromBuyTx: ()=>splitSuiCoinAfterFeeFromBuyTx,
49
49
  DraftTransferTx: ()=>DraftTransferTx,
50
50
  SUI_FULL_TYPE: ()=>SUI_FULL_TYPE,
51
51
  getSplitCoinForTx: ()=>getSplitCoinForTx,
52
- splitSuiCoinAfterFeeFromBuyTx: ()=>splitSuiCoinAfterFeeFromBuyTx,
53
52
  BlastFunSDKTransaction: ()=>sdk_transaction_BlastFunSDKTransaction,
54
53
  AstrosAggregator: ()=>astros_AstrosAggregator,
55
54
  SUI_TYPE: ()=>SUI_TYPE,
@@ -596,13 +595,6 @@ const USDC_TOKEN_TYPE = "0x5d4b302506645c37ff133b98c4b50a5ae14841659738d6d733d59
596
595
  const NATIVE_USDC_TOKEN_TYPE = "0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC";
597
596
  const SUI_METADATA_OBJECT_ID = "0x9258181f5ceac8dbffb7030890243caed69a9599d2886d957a9cb7656af3bdb3";
598
597
  const CLOCK_OBJECT_ID = "0x0000000000000000000000000000000000000000000000000000000000000006";
599
- const client_namespaceObject = require("@mysten/sui/client");
600
- const config_suiClient = new client_namespaceObject.SuiClient({
601
- url: (0, client_namespaceObject.getFullnodeUrl)("mainnet")
602
- });
603
- function getSuiClient() {
604
- return config_suiClient;
605
- }
606
598
  const orderByKey = (array, key, sortBy)=>{
607
599
  if (!array?.length) return;
608
600
  let swapped;
@@ -621,12 +613,12 @@ const orderByKey = (array, key, sortBy)=>{
621
613
  }while (swapped);
622
614
  return array;
623
615
  };
624
- const getCoinObjectIdsByAmount = async (address, amount, coinType)=>{
616
+ const getCoinObjectIdsByAmount = async (suiClient, address, amount, coinType)=>{
625
617
  let coinBalances = [];
626
618
  let hasNextPage = true;
627
619
  let nextCursor;
628
620
  while(hasNextPage)try {
629
- const coins = await getSuiClient().getCoins({
621
+ const coins = await suiClient.getCoins({
630
622
  owner: address,
631
623
  coinType,
632
624
  cursor: nextCursor
@@ -660,11 +652,11 @@ const getCoinObjectIdsByAmount = async (address, amount, coinType)=>{
660
652
  objectCoins
661
653
  };
662
654
  };
663
- async function addGasFee(params) {
655
+ async function addGasFee(params, suiClient) {
664
656
  const { inheritTx, sender, feeAmount, suiInputAmount } = params;
665
657
  const tx = inheritTx || new transactions_namespaceObject.Transaction();
666
658
  tx.setGasBudget(feeAmount);
667
- const { objectCoins } = await getCoinObjectIdsByAmount(sender, (BigInt(suiInputAmount || "0") + feeAmount).toString(), SUI_FULL_TYPE);
659
+ const { objectCoins } = await getCoinObjectIdsByAmount(suiClient, sender, (BigInt(suiInputAmount || "0") + feeAmount).toString(), SUI_FULL_TYPE);
668
660
  tx.setGasPayment(objectCoins.map((c)=>({
669
661
  objectId: c.coinObjectId,
670
662
  version: c.version,
@@ -690,10 +682,10 @@ const BLUEFIN_PACKAGE_ID = "0x62412b7268c35f3808336aee57a52836501f40b8ba5d936f8a
690
682
  })(bluefin_BluefinTx || (bluefin_BluefinTx = {}));
691
683
  var bluefin_BluefinTx;
692
684
  const utils_namespaceObject = require("@mysten/sui/utils");
693
- async function getSplitCoinForTx(params) {
685
+ async function getSplitCoinForTx(params, suiClient) {
694
686
  const { account, amount, splits, coinType, inheritTx, inspecTransaction, isSponsored = false } = params;
695
687
  const tx = inheritTx ?? new transactions_namespaceObject.Transaction();
696
- const { objectIds } = await getCoinObjectIdsByAmount(account, amount, coinType);
688
+ const { objectIds } = await getCoinObjectIdsByAmount(suiClient, account, amount, coinType);
697
689
  const coinObjectId = objectIds[0];
698
690
  if ((0, utils_namespaceObject.normalizeStructTag)(coinType) === (0, utils_namespaceObject.normalizeStructTag)(SUI_FULL_TYPE) && !isSponsored) {
699
691
  let coin;
@@ -735,8 +727,8 @@ function getAmountAfterFee(amount, fee) {
735
727
  const feeAmount = amountNum * feeNum / BigInt(BASE_BPS);
736
728
  return amountNum - feeAmount;
737
729
  }
738
- async function getNeededGasFee(tx, sender, bufferPercent) {
739
- const { effects: { gasUsed, status } } = await getSuiClient().devInspectTransactionBlock({
730
+ async function getNeededGasFee(suiClient, tx, sender, bufferPercent) {
731
+ const { effects: { gasUsed, status } } = await suiClient.devInspectTransactionBlock({
740
732
  sender,
741
733
  transactionBlock: tx
742
734
  });
@@ -747,13 +739,12 @@ async function getNeededGasFee(tx, sender, bufferPercent) {
747
739
  }
748
740
  const tiny_invariant_namespaceObject = require("@minswap/tiny-invariant");
749
741
  var tiny_invariant_default = /*#__PURE__*/ __webpack_require__.n(tiny_invariant_namespaceObject);
750
- async function getMoveObjectContent(objectId) {
751
- const moveObject = await getMoveObject(objectId);
742
+ async function getMoveObjectContent(suiClient, objectId) {
743
+ const moveObject = await getMoveObject(suiClient, objectId);
752
744
  return moveObject.fields;
753
745
  }
754
- async function getMoveObject(objectId) {
755
- const client = getSuiClient();
756
- const objRes = await client.getObject({
746
+ async function getMoveObject(suiClient, objectId) {
747
+ const objRes = await suiClient.getObject({
757
748
  id: objectId,
758
749
  options: {
759
750
  showContent: true
@@ -823,8 +814,8 @@ function createCompatibleSuiClient(client) {
823
814
  })(package_Bps || (package_Bps = {}));
824
815
  (function(BlastFunPackage) {
825
816
  (function(MemezFun) {
826
- async function isSniperProtectedMemezFun(poolId) {
827
- const memezFun = await getMoveObjectContent(poolId);
817
+ async function isSniperProtectedMemezFun(suiClient, poolId) {
818
+ const memezFun = await getMoveObjectContent(suiClient, poolId);
828
819
  return memezFun.public_key.length > 0;
829
820
  }
830
821
  MemezFun.isSniperProtectedMemezFun = isSniperProtectedMemezFun;
@@ -868,8 +859,8 @@ function createCompatibleSuiClient(client) {
868
859
  MemezBurner.calculate = calculate;
869
860
  })(BlastFunPackage.MemezBurner || (BlastFunPackage.MemezBurner = {}));
870
861
  (function(MemezPump) {
871
- async function getPumpState(memezFun) {
872
- return await getMoveObjectContent(memezFun.inner_state);
862
+ async function getPumpState(suiClient, memezFun) {
863
+ return await getMoveObjectContent(suiClient, memezFun.inner_state);
873
864
  }
874
865
  MemezPump.getPumpState = getPumpState;
875
866
  function pump(pumpState, quoteAmount) {
@@ -904,25 +895,25 @@ function createCompatibleSuiClient(client) {
904
895
  })(package_BlastFunPackage || (package_BlastFunPackage = {}));
905
896
  var package_MathUtils, package_Bps, package_BlastFunPackage;
906
897
  (function(BlastFunCustomCalculation) {
907
- async function getCurveAmountAfterBuy(params) {
898
+ async function getCurveAmountAfterBuy(params, suiClient) {
908
899
  let { suiAmount, poolId, frontendFee } = params;
909
- const memezFun = await getMoveObjectContent(poolId);
910
- const pumpState = await package_BlastFunPackage.MemezPump.getPumpState(memezFun);
900
+ const memezFun = await getMoveObjectContent(suiClient, poolId);
901
+ const pumpState = await package_BlastFunPackage.MemezPump.getPumpState(suiClient, memezFun);
911
902
  suiAmount = getAmountAfterFee(suiAmount, frontendFee);
912
903
  return package_BlastFunPackage.MemezPump.pump(pumpState, suiAmount);
913
904
  }
914
905
  BlastFunCustomCalculation.getCurveAmountAfterBuy = getCurveAmountAfterBuy;
915
- async function getSuiAmountAfterSell(params) {
906
+ async function getSuiAmountAfterSell(params, suiClient) {
916
907
  const { curveAmount, poolId, frontendFee } = params;
917
- const memezFun = await getMoveObjectContent(poolId);
918
- const pumpState = await package_BlastFunPackage.MemezPump.getPumpState(memezFun);
908
+ const memezFun = await getMoveObjectContent(suiClient, poolId);
909
+ const pumpState = await package_BlastFunPackage.MemezPump.getPumpState(suiClient, memezFun);
919
910
  const suiAmount = package_BlastFunPackage.MemezPump.dump(pumpState, curveAmount);
920
911
  return getAmountAfterFee(suiAmount, frontendFee);
921
912
  }
922
913
  BlastFunCustomCalculation.getSuiAmountAfterSell = getSuiAmountAfterSell;
923
914
  })(custom_calculation_BlastFunCustomCalculation || (custom_calculation_BlastFunCustomCalculation = {}));
924
915
  var custom_calculation_BlastFunCustomCalculation;
925
- async function splitSuiCoinAfterFeeFromBuyTx(params) {
916
+ async function splitSuiCoinAfterFeeFromBuyTx(params, suiClient) {
926
917
  const { inputAmount, accountAddress, frontendFee, frontendFeeRecipient, extendTx, isSponsored } = params;
927
918
  tiny_invariant_default()(params.inCoinType === SUI_FULL_TYPE || params.inCoinType === SUI_TYPE, "Input must be SUI");
928
919
  const { tx: _tx, coinIn } = extendTx || {};
@@ -940,7 +931,7 @@ async function splitSuiCoinAfterFeeFromBuyTx(params) {
940
931
  coinType: SUI_FULL_TYPE,
941
932
  inheritTx: tx,
942
933
  isSponsored: isSponsored || false
943
- });
934
+ }, suiClient);
944
935
  coinData = _data;
945
936
  }
946
937
  let inputSuiCoin;
@@ -1015,9 +1006,9 @@ var types_SupportedBondingCurve = /*#__PURE__*/ function(SupportedBondingCurve)
1015
1006
  });
1016
1007
  }
1017
1008
  BlastFunCustomTransaction.getAllowedVersions = getAllowedVersions;
1018
- async function buildBuyTx(params) {
1019
- tiny_invariant_default()(!await package_BlastFunPackage.MemezFun.isSniperProtectedMemezFun(params.poolId), "This coin is a sniper protected coin, please use the Blast Fun website to trade it.");
1020
- const { tx, coinOut: suiCoinIn } = await splitSuiCoinAfterFeeFromBuyTx(params);
1009
+ async function buildBuyTx(params, suiClient) {
1010
+ tiny_invariant_default()(!await package_BlastFunPackage.MemezFun.isSniperProtectedMemezFun(suiClient, params.poolId), "This coin is a sniper protected coin, please use the Blast Fun website to trade it.");
1011
+ const { tx, coinOut: suiCoinIn } = await splitSuiCoinAfterFeeFromBuyTx(params, suiClient);
1021
1012
  tiny_invariant_default()(suiCoinIn, "Coin out is required");
1022
1013
  const curveCoin = tx.moveCall({
1023
1014
  target: `${constants_BlastFunConstants.PACKAGE_ID_V4}::memez_pump::pump`,
@@ -1040,9 +1031,9 @@ var types_SupportedBondingCurve = /*#__PURE__*/ function(SupportedBondingCurve)
1040
1031
  };
1041
1032
  }
1042
1033
  BlastFunCustomTransaction.buildBuyTx = buildBuyTx;
1043
- async function buildSellTx(params) {
1034
+ async function buildSellTx(params, suiClient) {
1044
1035
  tiny_invariant_default()(params.outCoinType === SUI_FULL_TYPE || params.outCoinType === SUI_TYPE, "Output must be SUI");
1045
- const memezFun = await getMoveObjectContent(params.poolId);
1036
+ const memezFun = await getMoveObjectContent(suiClient, params.poolId);
1046
1037
  const { tx, coinData } = await getSplitCoinForTx({
1047
1038
  amount: params.inputAmount,
1048
1039
  coinType: params.inCoinType,
@@ -1051,7 +1042,7 @@ var types_SupportedBondingCurve = /*#__PURE__*/ function(SupportedBondingCurve)
1051
1042
  splits: [
1052
1043
  params.inputAmount
1053
1044
  ]
1054
- });
1045
+ }, suiClient);
1055
1046
  const [inputCoin] = coinData;
1056
1047
  const [suiCoin] = tx.moveCall({
1057
1048
  target: `${constants_BlastFunConstants.PACKAGE_ID_V4}::memez_pump::dump`,
@@ -1075,6 +1066,7 @@ var types_SupportedBondingCurve = /*#__PURE__*/ function(SupportedBondingCurve)
1075
1066
  var custom_transaction_BlastFunCustomTransaction;
1076
1067
  const memez_fun_sdk_namespaceObject = require("@interest-protocol/memez-fun-sdk");
1077
1068
  const sui_core_sdk_namespaceObject = require("@interest-protocol/sui-core-sdk");
1069
+ const client_namespaceObject = require("@mysten/sui/client");
1078
1070
  const payload = {
1079
1071
  network: sui_core_sdk_namespaceObject.Network.MAINNET,
1080
1072
  fullNodeUrl: (0, client_namespaceObject.getFullnodeUrl)("mainnet")
@@ -1106,8 +1098,8 @@ function getMemezPumpSDK() {
1106
1098
  })(sdk_calculation_BlastFunSDKCalculation || (sdk_calculation_BlastFunSDKCalculation = {}));
1107
1099
  var sdk_calculation_BlastFunSDKCalculation;
1108
1100
  (function(BlastFunSDKTransaction) {
1109
- async function buildBuyTx(params) {
1110
- const { tx, coinOut: suiCoinIn } = await splitSuiCoinAfterFeeFromBuyTx(params);
1101
+ async function buildBuyTx(params, suiClient) {
1102
+ const { tx, coinOut: suiCoinIn } = await splitSuiCoinAfterFeeFromBuyTx(params, suiClient);
1111
1103
  tiny_invariant_default()(suiCoinIn, "Coin out is required");
1112
1104
  const { memeCoin, tx: tx2 } = await getMemezPumpSDK().pump({
1113
1105
  pool: params.poolId,
@@ -1121,7 +1113,7 @@ var sdk_calculation_BlastFunSDKCalculation;
1121
1113
  };
1122
1114
  }
1123
1115
  BlastFunSDKTransaction.buildBuyTx = buildBuyTx;
1124
- async function buildSellTx(params) {
1116
+ async function buildSellTx(params, suiClient) {
1125
1117
  tiny_invariant_default()(params.outCoinType === SUI_FULL_TYPE || params.outCoinType === SUI_TYPE, "Output must be SUI");
1126
1118
  const { tx, coinData } = await getSplitCoinForTx({
1127
1119
  amount: params.inputAmount,
@@ -1131,7 +1123,7 @@ var sdk_calculation_BlastFunSDKCalculation;
1131
1123
  splits: [
1132
1124
  params.inputAmount
1133
1125
  ]
1134
- });
1126
+ }, suiClient);
1135
1127
  const [inputCoin] = coinData;
1136
1128
  const { quoteCoin, tx: tx2 } = await getMemezPumpSDK().dump({
1137
1129
  pool: params.poolId,
@@ -1165,19 +1157,19 @@ var sdk_calculation_BlastFunSDKCalculation;
1165
1157
  frontendFeeRecipient: tradeFee ? tradeFee.tradeFeeRecipientAddress : void 0,
1166
1158
  extendTx: void 0,
1167
1159
  isSponsored: false
1168
- });
1160
+ }, suiClient);
1169
1161
  tiny_invariant_default()(coinOut, "Coin out is required");
1170
1162
  tx.transferObjects([
1171
1163
  coinOut
1172
1164
  ], tx.pure.address(walletAddress));
1173
1165
  tx.setSender(walletAddress);
1174
- const feeAmount = await getNeededGasFee(tx, walletAddress, 0);
1166
+ const feeAmount = await getNeededGasFee(suiClient, tx, walletAddress, 0);
1175
1167
  tx = await addGasFee({
1176
1168
  inheritTx: tx,
1177
1169
  sender: walletAddress,
1178
1170
  feeAmount,
1179
1171
  suiInputAmount: inputAmount
1180
- });
1172
+ }, suiClient);
1181
1173
  return tx.build({
1182
1174
  client: suiClient
1183
1175
  });
@@ -1206,18 +1198,18 @@ var sdk_calculation_BlastFunSDKCalculation;
1206
1198
  frontendFeeRecipient: tradeFee ? tradeFee.tradeFeeRecipientAddress : void 0,
1207
1199
  extendTx: void 0,
1208
1200
  isSponsored: false
1209
- });
1201
+ }, suiClient);
1210
1202
  tiny_invariant_default()(coinOut, "Coin out is required");
1211
1203
  tx.transferObjects([
1212
1204
  coinOut
1213
1205
  ], tx.pure.address(walletAddress));
1214
1206
  tx.setSender(walletAddress);
1215
- const feeAmount = await getNeededGasFee(tx, walletAddress, 0);
1207
+ const feeAmount = await getNeededGasFee(suiClient, tx, walletAddress, 0);
1216
1208
  tx = await addGasFee({
1217
1209
  inheritTx: tx,
1218
1210
  sender: walletAddress,
1219
1211
  feeAmount
1220
- });
1212
+ }, suiClient);
1221
1213
  return tx.build({
1222
1214
  client: suiClient
1223
1215
  });
@@ -1258,8 +1250,8 @@ var constants_MoonbagsConstants;
1258
1250
  Curves.calculateTokenAmountReceived = calculateTokenAmountReceived;
1259
1251
  })(MoonbagsPackage.Curves || (MoonbagsPackage.Curves = {}));
1260
1252
  (function(Moonbags) {
1261
- async function getDynamicVirtualTokenReserves(poolId) {
1262
- const result = await getSuiClient().getDynamicFieldObject({
1253
+ async function getDynamicVirtualTokenReserves(suiClient, poolId) {
1254
+ const result = await suiClient.getDynamicFieldObject({
1263
1255
  parentId: poolId,
1264
1256
  name: {
1265
1257
  type: "vector<u8>",
@@ -1310,12 +1302,12 @@ var constants_MoonbagsConstants;
1310
1302
  })(package_MoonbagsPackage || (package_MoonbagsPackage = {}));
1311
1303
  var package_MoonbagsPackage;
1312
1304
  (function(MoonbagsCalculation) {
1313
- async function getCurveAmountAfterBuy(params) {
1305
+ async function getCurveAmountAfterBuy(params, suiClient) {
1314
1306
  let { suiAmount, poolId, frontendFee } = params;
1315
1307
  const [poolMoveStruct, configMoveStruct, dynamicVirtualTokenReserves] = await Promise.all([
1316
- getMoveObjectContent(poolId),
1317
- getMoveObjectContent(constants_MoonbagsConstants.CONFIG_OBJECT_ID),
1318
- package_MoonbagsPackage.Moonbags.getDynamicVirtualTokenReserves(poolId)
1308
+ getMoveObjectContent(suiClient, poolId),
1309
+ getMoveObjectContent(suiClient, constants_MoonbagsConstants.CONFIG_OBJECT_ID),
1310
+ package_MoonbagsPackage.Moonbags.getDynamicVirtualTokenReserves(suiClient, poolId)
1319
1311
  ]);
1320
1312
  const pool = poolMoveStruct;
1321
1313
  const config = configMoveStruct;
@@ -1331,11 +1323,11 @@ var package_MoonbagsPackage;
1331
1323
  return receivedCurve;
1332
1324
  }
1333
1325
  MoonbagsCalculation.getCurveAmountAfterBuy = getCurveAmountAfterBuy;
1334
- async function getSuiAmountAfterSell(params) {
1326
+ async function getSuiAmountAfterSell(params, suiClient) {
1335
1327
  const { curveAmount, poolId, frontendFee } = params;
1336
1328
  const [poolMoveStruct, configMoveStruct] = await Promise.all([
1337
- getMoveObjectContent(poolId),
1338
- getMoveObjectContent(constants_MoonbagsConstants.CONFIG_OBJECT_ID)
1329
+ getMoveObjectContent(suiClient, poolId),
1330
+ getMoveObjectContent(suiClient, constants_MoonbagsConstants.CONFIG_OBJECT_ID)
1339
1331
  ]);
1340
1332
  const pool = poolMoveStruct;
1341
1333
  const config = configMoveStruct;
@@ -1348,9 +1340,9 @@ var package_MoonbagsPackage;
1348
1340
  return receivedSui;
1349
1341
  }
1350
1342
  MoonbagsCalculation.getSuiAmountAfterSell = getSuiAmountAfterSell;
1351
- async function getUsedSuiForTx(params) {
1343
+ async function getUsedSuiForTx(params, suiClient) {
1352
1344
  let { suiAmount, frontendFee } = params;
1353
- const configMoveStruct = await getMoveObjectContent(constants_MoonbagsConstants.CONFIG_OBJECT_ID);
1345
+ const configMoveStruct = await getMoveObjectContent(suiClient, constants_MoonbagsConstants.CONFIG_OBJECT_ID);
1354
1346
  const config = configMoveStruct;
1355
1347
  if (void 0 !== frontendFee) suiAmount = getAmountAfterFee(suiAmount, frontendFee);
1356
1348
  return suiAmount * constants_MoonbagsConstants.FEE_DENOMINATOR / (constants_MoonbagsConstants.FEE_DENOMINATOR + BigInt(config.platform_fee));
@@ -1359,13 +1351,13 @@ var package_MoonbagsPackage;
1359
1351
  })(calculation_MoonbagsCalculation || (calculation_MoonbagsCalculation = {}));
1360
1352
  var calculation_MoonbagsCalculation;
1361
1353
  (function(MoonbagsTransaction) {
1362
- async function buildBuyTx(params) {
1363
- const { tx, coinOut } = await splitSuiCoinAfterFeeFromBuyTx(params);
1354
+ async function buildBuyTx(params, suiClient) {
1355
+ const { tx, coinOut } = await splitSuiCoinAfterFeeFromBuyTx(params, suiClient);
1364
1356
  tiny_invariant_default()(coinOut, "Coin out is required");
1365
1357
  const usedSui = await calculation_MoonbagsCalculation.getUsedSuiForTx({
1366
1358
  suiAmount: BigInt(params.inputAmount),
1367
1359
  frontendFee: params.frontendFee
1368
- });
1360
+ }, suiClient);
1369
1361
  const [suiCoin, curveCoin] = tx.moveCall({
1370
1362
  target: `${constants_MoonbagsConstants.PACKAGE_ID}::moonbags::buy_exact_in_returns_with_lock`,
1371
1363
  typeArguments: [
@@ -1391,7 +1383,7 @@ var calculation_MoonbagsCalculation;
1391
1383
  };
1392
1384
  }
1393
1385
  MoonbagsTransaction.buildBuyTx = buildBuyTx;
1394
- async function buildSellTx(params) {
1386
+ async function buildSellTx(params, suiClient) {
1395
1387
  tiny_invariant_default()(params.outCoinType === SUI_FULL_TYPE || params.outCoinType === SUI_TYPE, "Output must be SUI");
1396
1388
  const { tx, coinData } = await getSplitCoinForTx({
1397
1389
  amount: params.inputAmount,
@@ -1401,7 +1393,7 @@ var calculation_MoonbagsCalculation;
1401
1393
  splits: [
1402
1394
  params.inputAmount
1403
1395
  ]
1404
- });
1396
+ }, suiClient);
1405
1397
  const [inputCoin] = coinData;
1406
1398
  const [suiCoin, curveCoin] = tx.moveCall({
1407
1399
  target: `${constants_MoonbagsConstants.PACKAGE_ID}::moonbags::sell_returns`,
@@ -1429,7 +1421,7 @@ var calculation_MoonbagsCalculation;
1429
1421
  poolId: poolId,
1430
1422
  suiAmount: inputAmount,
1431
1423
  frontendFee: tradeFee ? tradeFee.tradeFeePercent : void 0
1432
- });
1424
+ }, suiClient);
1433
1425
  const minAmountOut = BigInt(new (external_bignumber_js_default())(outputAmount.toString()).multipliedBy(1 - slippage).toFixed(0, 3));
1434
1426
  let { tx, coinOut } = await buildBuyTx({
1435
1427
  accountAddress: walletAddress,
@@ -1442,19 +1434,19 @@ var calculation_MoonbagsCalculation;
1442
1434
  frontendFeeRecipient: tradeFee ? tradeFee.tradeFeeRecipientAddress : void 0,
1443
1435
  extendTx: void 0,
1444
1436
  isSponsored: false
1445
- });
1437
+ }, suiClient);
1446
1438
  tiny_invariant_default()(coinOut, "Coin out is required");
1447
1439
  tx.transferObjects([
1448
1440
  coinOut
1449
1441
  ], tx.pure.address(walletAddress));
1450
1442
  tx.setSender(walletAddress);
1451
- const feeAmount = await getNeededGasFee(tx, walletAddress, 0);
1443
+ const feeAmount = await getNeededGasFee(suiClient, tx, walletAddress, 0);
1452
1444
  tx = await addGasFee({
1453
1445
  inheritTx: tx,
1454
1446
  sender: walletAddress,
1455
1447
  feeAmount,
1456
1448
  suiInputAmount: inputAmount
1457
- });
1449
+ }, suiClient);
1458
1450
  return tx.build({
1459
1451
  client: suiClient
1460
1452
  });
@@ -1470,7 +1462,7 @@ var calculation_MoonbagsCalculation;
1470
1462
  poolId: poolId,
1471
1463
  curveAmount: inputAmount,
1472
1464
  frontendFee: tradeFee ? tradeFee.tradeFeePercent : void 0
1473
- });
1465
+ }, suiClient);
1474
1466
  const minAmountOut = BigInt(new (external_bignumber_js_default())(outputAmount.toString()).multipliedBy(1 - slippage).toFixed(0, 3));
1475
1467
  let { tx, coinOut } = await buildSellTx({
1476
1468
  accountAddress: walletAddress,
@@ -1483,18 +1475,18 @@ var calculation_MoonbagsCalculation;
1483
1475
  frontendFeeRecipient: tradeFee ? tradeFee.tradeFeeRecipientAddress : void 0,
1484
1476
  extendTx: void 0,
1485
1477
  isSponsored: false
1486
- });
1478
+ }, suiClient);
1487
1479
  tiny_invariant_default()(coinOut, "Coin out is required");
1488
1480
  tx.transferObjects([
1489
1481
  coinOut
1490
1482
  ], tx.pure.address(walletAddress));
1491
1483
  tx.setSender(walletAddress);
1492
- const feeAmount = await getNeededGasFee(tx, walletAddress, 0);
1484
+ const feeAmount = await getNeededGasFee(suiClient, tx, walletAddress, 0);
1493
1485
  tx = await addGasFee({
1494
1486
  inheritTx: tx,
1495
1487
  sender: walletAddress,
1496
1488
  feeAmount
1497
- });
1489
+ }, suiClient);
1498
1490
  return tx.build({
1499
1491
  client: suiClient
1500
1492
  });
@@ -1504,18 +1496,13 @@ var calculation_MoonbagsCalculation;
1504
1496
  var transaction_MoonbagsTransaction;
1505
1497
  const ed25519_namespaceObject = require("@mysten/sui/keypairs/ed25519");
1506
1498
  const CONSTANTS = {
1507
- SUI_DECIMALS: 9,
1508
- GAS_FEE_BUFFER_PERCENTAGE: 0.1,
1509
- MIN_TRANSFER_AMOUNT: 0.000000001
1499
+ GAS_FEE_BUFFER_PERCENTAGE: 0.1
1510
1500
  };
1511
1501
  class DraftTransferTx {
1512
1502
  suiClient;
1513
1503
  constructor(suiClient){
1514
1504
  this.suiClient = suiClient;
1515
1505
  }
1516
- suiToMist(suiAmount) {
1517
- return BigInt(Math.floor(suiAmount * 10 ** CONSTANTS.SUI_DECIMALS));
1518
- }
1519
1506
  validatePrivateKey(privateKey, expectedSender) {
1520
1507
  tiny_invariant_default()(privateKey?.trim(), "Private key is required");
1521
1508
  const keypair = ed25519_namespaceObject.Ed25519Keypair.fromSecretKey(privateKey);
@@ -1523,16 +1510,15 @@ class DraftTransferTx {
1523
1510
  if (derivedAddress !== expectedSender) throw new Error(`Private key mismatch. Expected: ${expectedSender}, Got: ${derivedAddress}`);
1524
1511
  return keypair;
1525
1512
  }
1526
- async createDraft(sender, recipient, suiAmount) {
1513
+ async createDraft(sender, recipient, amountMIST) {
1527
1514
  tiny_invariant_default()(sender?.trim(), "Sender address is required");
1528
1515
  tiny_invariant_default()(recipient?.trim(), "Recipient address is required");
1529
1516
  tiny_invariant_default()(sender !== recipient, "Sender and recipient cannot be the same");
1530
- tiny_invariant_default()(suiAmount > CONSTANTS.MIN_TRANSFER_AMOUNT, `Transfer amount must be greater than ${CONSTANTS.MIN_TRANSFER_AMOUNT} SUI`);
1531
- const suiAmountMist = this.suiToMist(suiAmount);
1517
+ tiny_invariant_default()(amountMIST > 0n, "Transfer amount must be at least 1 MIST");
1532
1518
  try {
1533
1519
  let transaction = new transactions_namespaceObject.Transaction();
1534
1520
  const [coin] = transaction.splitCoins(transaction.gas, [
1535
- suiAmountMist
1521
+ amountMIST
1536
1522
  ]);
1537
1523
  transaction.transferObjects([
1538
1524
  coin
@@ -1540,13 +1526,13 @@ class DraftTransferTx {
1540
1526
  transaction.setSender(sender);
1541
1527
  const referenceGasPrice = await this.suiClient.getReferenceGasPrice();
1542
1528
  transaction.setGasPrice(referenceGasPrice);
1543
- const feeAmount = await getNeededGasFee(transaction, sender, CONSTANTS.GAS_FEE_BUFFER_PERCENTAGE);
1529
+ const feeAmount = await getNeededGasFee(this.suiClient, transaction, sender, CONSTANTS.GAS_FEE_BUFFER_PERCENTAGE);
1544
1530
  transaction = await addGasFee({
1545
1531
  inheritTx: transaction,
1546
1532
  sender,
1547
1533
  feeAmount,
1548
- suiInputAmount: suiAmountMist
1549
- });
1534
+ suiInputAmount: amountMIST
1535
+ }, this.suiClient);
1550
1536
  const txBytes = await transaction.build({
1551
1537
  client: this.suiClient
1552
1538
  });
@@ -1555,7 +1541,7 @@ class DraftTransferTx {
1555
1541
  return {
1556
1542
  sender,
1557
1543
  recipient,
1558
- suiAmount,
1544
+ amountMIST,
1559
1545
  txDraftBase64,
1560
1546
  txDigest
1561
1547
  };
@@ -1648,7 +1634,6 @@ exports.getMoveObjectContent = __webpack_exports__.getMoveObjectContent;
1648
1634
  exports.getNeededGasFee = __webpack_exports__.getNeededGasFee;
1649
1635
  exports.getSplitCoinForTx = __webpack_exports__.getSplitCoinForTx;
1650
1636
  exports.getSplitCoinsAfterFee = __webpack_exports__.getSplitCoinsAfterFee;
1651
- exports.getSuiClient = __webpack_exports__.getSuiClient;
1652
1637
  exports.splitSuiCoinAfterFeeFromBuyTx = __webpack_exports__.splitSuiCoinAfterFeeFromBuyTx;
1653
1638
  exports.splitSuiCoinAfterFeeFromSellTx = __webpack_exports__.splitSuiCoinAfterFeeFromSellTx;
1654
1639
  for(var __webpack_i__ in __webpack_exports__)if (-1 === [
@@ -1694,7 +1679,6 @@ for(var __webpack_i__ in __webpack_exports__)if (-1 === [
1694
1679
  "getNeededGasFee",
1695
1680
  "getSplitCoinForTx",
1696
1681
  "getSplitCoinsAfterFee",
1697
- "getSuiClient",
1698
1682
  "splitSuiCoinAfterFeeFromBuyTx",
1699
1683
  "splitSuiCoinAfterFeeFromSellTx"
1700
1684
  ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
package/dist/index.d.ts CHANGED
@@ -7,7 +7,7 @@ import type { Quote } from '@naviprotocol/astros-aggregator-sdk';
7
7
  import type { QuoteResponse } from '@7kprotocol/sdk-ts';
8
8
  import type { RouterCompleteTradeRoute } from 'aftermath-ts-sdk';
9
9
  import type { RouterDataV3 } from '@cetusprotocol/aggregator-sdk';
10
- import { SuiClient } from '@mysten/sui/client';
10
+ import type { SuiClient } from '@mysten/sui/client';
11
11
  import { Transaction } from '@mysten/sui/transactions';
12
12
  import type { TransactionArgument } from '@mysten/sui/transactions';
13
13
  import { TransactionObjectArgument } from '@mysten/sui/transactions';
@@ -30,7 +30,7 @@ export declare function addGasFee(params: {
30
30
  sender: string;
31
31
  feeAmount: bigint;
32
32
  suiInputAmount?: bigint;
33
- }): Promise<Transaction>;
33
+ }, suiClient: SuiClient): Promise<Transaction>;
34
34
 
35
35
  /**
36
36
  * Aftermath DEX aggregator client for routing trades across multiple pools
@@ -208,8 +208,8 @@ export declare namespace BlastFunConstants {
208
208
  * @deprecated Use `BlastFunSDKCalculation` instead.
209
209
  */
210
210
  export declare namespace BlastFunCustomCalculation {
211
- export function getCurveAmountAfterBuy(params: GetCurveAmountAfterBuyParams): Promise<bigint>;
212
- export function getSuiAmountAfterSell(params: GetSuiAmountAfterSellParams): Promise<bigint>;
211
+ export function getCurveAmountAfterBuy(params: GetCurveAmountAfterBuyParams, suiClient: SuiClient): Promise<bigint>;
212
+ export function getSuiAmountAfterSell(params: GetSuiAmountAfterSellParams, suiClient: SuiClient): Promise<bigint>;
213
213
  }
214
214
 
215
215
  /**
@@ -217,8 +217,8 @@ export declare namespace BlastFunCustomCalculation {
217
217
  */
218
218
  export declare namespace BlastFunCustomTransaction {
219
219
  export function getAllowedVersions(_tx?: Transaction): Promise<TransactionResult>;
220
- export function buildBuyTx(params: BuildSwapTxParams): Promise<BuildTxResult>;
221
- export function buildSellTx(params: BuildSwapTxParams): Promise<BuildTxResult>;
220
+ export function buildBuyTx(params: BuildSwapTxParams, suiClient: SuiClient): Promise<BuildTxResult>;
221
+ export function buildSellTx(params: BuildSwapTxParams, suiClient: SuiClient): Promise<BuildTxResult>;
222
222
  }
223
223
 
224
224
  export declare namespace BlastFunPackage {
@@ -228,7 +228,7 @@ export declare namespace BlastFunPackage {
228
228
  public_key: number[];
229
229
  ipx_meme_coin_treasury: string;
230
230
  };
231
- export function isSniperProtectedMemezFun(poolId: string): Promise<boolean>;
231
+ export function isSniperProtectedMemezFun(suiClient: SuiClient, poolId: string): Promise<boolean>;
232
232
  }
233
233
  export namespace MemezDistributor {
234
234
  export type Recipient = {
@@ -275,7 +275,7 @@ export declare namespace BlastFunPackage {
275
275
  export type PumpState = {
276
276
  constant_product: MoveObjectStruct<MemezConstantProduct.MemezConstantProduct>;
277
277
  };
278
- export function getPumpState(memezFun: MemezFun.MemezFun): Promise<PumpState>;
278
+ export function getPumpState(suiClient: SuiClient, memezFun: MemezFun.MemezFun): Promise<PumpState>;
279
279
  export function pump(pumpState: PumpState, quoteAmount: bigint): bigint;
280
280
  export function dump(pumpState: PumpState, memeAmount: bigint): bigint;
281
281
  }
@@ -287,8 +287,8 @@ export declare namespace BlastFunSDKCalculation {
287
287
  }
288
288
 
289
289
  export declare namespace BlastFunSDKTransaction {
290
- export function buildBuyTx(params: BuildSwapTxParams): Promise<BuildTxResult>;
291
- export function buildSellTx(params: BuildSwapTxParams): Promise<BuildTxResult>;
290
+ export function buildBuyTx(params: BuildSwapTxParams, suiClient: SuiClient): Promise<BuildTxResult>;
291
+ export function buildSellTx(params: BuildSwapTxParams, suiClient: SuiClient): Promise<BuildTxResult>;
292
292
  export function getBuyTransaction({ coinInAmount, coinInType, coinOutType, poolId, slippage, walletAddress, tradeFee }: GetTradeTransactionRequest, suiClient: SuiClient): Promise<Uint8Array>;
293
293
  export function getSellTransaction({ coinInAmount, coinInType, coinOutType, poolId, slippage, walletAddress, tradeFee }: GetTradeTransactionRequest, suiClient: SuiClient): Promise<Uint8Array>;
294
294
  }
@@ -438,7 +438,7 @@ export declare function createCompatibleSuiClient(client: SuiClient): LegacySuiC
438
438
  export declare type DraftTransaction = {
439
439
  readonly sender: string;
440
440
  readonly recipient: string;
441
- readonly suiAmount: number;
441
+ readonly amountMIST: bigint;
442
442
  readonly txDigest: string;
443
443
  readonly txDraftBase64: string;
444
444
  };
@@ -446,11 +446,6 @@ export declare type DraftTransaction = {
446
446
  export declare class DraftTransferTx {
447
447
  private readonly suiClient;
448
448
  constructor(suiClient: SuiClient);
449
- /**
450
- * Converts SUI amount to MIST (smallest unit)
451
- * @private
452
- */
453
- private suiToMist;
454
449
  /**
455
450
  * Validates private key against expected sender address
456
451
  * @private
@@ -462,7 +457,7 @@ export declare class DraftTransferTx {
462
457
  * @returns Draft transaction object with encoded transaction data
463
458
  * @throws {Error} If validation fails or transaction building fails
464
459
  */
465
- createDraft(sender: string, recipient: string, suiAmount: number): Promise<DraftTransaction>;
460
+ createDraft(sender: string, recipient: string, amountMIST: bigint): Promise<DraftTransaction>;
466
461
  /**
467
462
  * Executes a draft transaction on the Sui network
468
463
  * @param draftTx - Draft transaction to execute
@@ -551,7 +546,7 @@ export declare type FlowXAggregatorConfig = {
551
546
 
552
547
  export declare function getAmountAfterFee(amount: bigint | string, fee?: string | number): bigint;
553
548
 
554
- export declare const getCoinObjectIdsByAmount: (address: string, amount: string, coinType: string) => Promise<{
549
+ export declare const getCoinObjectIdsByAmount: (suiClient: SuiClient, address: string, amount: string, coinType: string) => Promise<{
555
550
  objectIds: string[];
556
551
  objectCoins: CoinStruct[];
557
552
  balance: string;
@@ -565,11 +560,11 @@ export declare type GetCurveAmountAfterBuyParams = {
565
560
 
566
561
  export declare function getMemezPumpSDK(): MemezPumpSDK;
567
562
 
568
- export declare function getMoveObject(objectId: string): Promise<MoveObject>;
563
+ export declare function getMoveObject(suiClient: SuiClient, objectId: string): Promise<MoveObject>;
569
564
 
570
- export declare function getMoveObjectContent(objectId: string): Promise<MoveStruct>;
565
+ export declare function getMoveObjectContent(suiClient: SuiClient, objectId: string): Promise<MoveStruct>;
571
566
 
572
- export declare function getNeededGasFee(tx: Transaction, sender: string, bufferPercent: number): Promise<bigint>;
567
+ export declare function getNeededGasFee(suiClient: SuiClient, tx: Transaction, sender: string, bufferPercent: number): Promise<bigint>;
573
568
 
574
569
  declare type GetSplitCoinForTx = {
575
570
  account: string;
@@ -581,7 +576,7 @@ declare type GetSplitCoinForTx = {
581
576
  isSponsored?: boolean;
582
577
  };
583
578
 
584
- export declare function getSplitCoinForTx(params: GetSplitCoinForTx): Promise<{
579
+ export declare function getSplitCoinForTx(params: GetSplitCoinForTx, suiClient: SuiClient): Promise<{
585
580
  tx: Transaction;
586
581
  coinData: TransactionResult;
587
582
  }>;
@@ -594,8 +589,6 @@ export declare type GetSuiAmountAfterSellParams = {
594
589
  frontendFee?: number | string;
595
590
  };
596
591
 
597
- export declare function getSuiClient(): SuiClient;
598
-
599
592
  /**
600
593
  * Request parameters for getting a trade route
601
594
  */
@@ -760,12 +753,12 @@ export declare namespace MathUtils {
760
753
  }
761
754
 
762
755
  export declare namespace MoonbagsCalculation {
763
- export function getCurveAmountAfterBuy(params: GetCurveAmountAfterBuyParams): Promise<bigint>;
764
- export function getSuiAmountAfterSell(params: GetSuiAmountAfterSellParams): Promise<bigint>;
756
+ export function getCurveAmountAfterBuy(params: GetCurveAmountAfterBuyParams, suiClient: SuiClient): Promise<bigint>;
757
+ export function getSuiAmountAfterSell(params: GetSuiAmountAfterSellParams, suiClient: SuiClient): Promise<bigint>;
765
758
  export function getUsedSuiForTx(params: {
766
759
  suiAmount: bigint;
767
760
  frontendFee?: number | string;
768
- }): Promise<bigint>;
761
+ }, suiClient: SuiClient): Promise<bigint>;
769
762
  }
770
763
 
771
764
  export declare namespace MoonbagsConstants {
@@ -804,7 +797,7 @@ export declare namespace MoonbagsPackage {
804
797
  name: number[];
805
798
  value: string;
806
799
  };
807
- export function getDynamicVirtualTokenReserves(poolId: string): Promise<bigint | undefined>;
800
+ export function getDynamicVirtualTokenReserves(suiClient: SuiClient, poolId: string): Promise<bigint | undefined>;
808
801
  export function buyExactInReturnsWithLock(params: {
809
802
  inputAmount: bigint;
810
803
  amountIn: bigint;
@@ -827,8 +820,8 @@ export declare namespace MoonbagsPackage {
827
820
  }
828
821
 
829
822
  export declare namespace MoonbagsTransaction {
830
- export function buildBuyTx(params: BuildSwapTxParams): Promise<BuildTxResult>;
831
- export function buildSellTx(params: BuildSwapTxParams): Promise<BuildTxResult>;
823
+ export function buildBuyTx(params: BuildSwapTxParams, suiClient: SuiClient): Promise<BuildTxResult>;
824
+ export function buildSellTx(params: BuildSwapTxParams, suiClient: SuiClient): Promise<BuildTxResult>;
832
825
  export function getBuyTransaction({ coinInAmount, coinInType, coinOutType, poolId, slippage, walletAddress, tradeFee }: GetTradeTransactionRequest, suiClient: SuiClient): Promise<Uint8Array>;
833
826
  export function getSellTransaction({ coinInAmount, coinInType, coinOutType, poolId, slippage, walletAddress, tradeFee }: GetTradeTransactionRequest, suiClient: SuiClient): Promise<Uint8Array>;
834
827
  }
@@ -900,7 +893,7 @@ export declare type SevenKAggregatorConfig = {
900
893
  sevenKApiKey?: string;
901
894
  };
902
895
 
903
- export declare function splitSuiCoinAfterFeeFromBuyTx(params: BuildSwapTxParams): Promise<BuildTxResult>;
896
+ export declare function splitSuiCoinAfterFeeFromBuyTx(params: BuildSwapTxParams, suiClient: SuiClient): Promise<BuildTxResult>;
904
897
 
905
898
  export declare function splitSuiCoinAfterFeeFromSellTx(tx: Transaction, params: BuildSwapTxParams, suiCoin: TransactionObjectArgument): Promise<BuildTxResult>;
906
899
 
package/dist/index.js CHANGED
@@ -6,11 +6,11 @@ import { buildSwapPTBFromQuote, getCoins, getQuote as astros_aggregator_sdk_getQ
6
6
  import { AggregatorClient, Env } from "@cetusprotocol/aggregator-sdk";
7
7
  import bn from "bn.js";
8
8
  import { AggregatorQuoter, Coin, Commission, CommissionType, TradeBuilder } from "@flowx-finance/sdk";
9
- import { SuiClient, getFullnodeUrl } from "@mysten/sui/client";
10
9
  import { fromBase64, normalizeStructTag } from "@mysten/sui/utils";
11
10
  import tiny_invariant from "@minswap/tiny-invariant";
12
11
  import { MemezPumpSDK } from "@interest-protocol/memez-fun-sdk";
13
12
  import { Network } from "@interest-protocol/sui-core-sdk";
13
+ import { getFullnodeUrl } from "@mysten/sui/client";
14
14
  import { Ed25519Keypair } from "@mysten/sui/keypairs/ed25519";
15
15
  class _7k_SevenKAggregator {
16
16
  _config;
@@ -520,12 +520,6 @@ const USDC_TOKEN_TYPE = "0x5d4b302506645c37ff133b98c4b50a5ae14841659738d6d733d59
520
520
  const NATIVE_USDC_TOKEN_TYPE = "0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC";
521
521
  const SUI_METADATA_OBJECT_ID = "0x9258181f5ceac8dbffb7030890243caed69a9599d2886d957a9cb7656af3bdb3";
522
522
  const CLOCK_OBJECT_ID = "0x0000000000000000000000000000000000000000000000000000000000000006";
523
- const config_suiClient = new SuiClient({
524
- url: getFullnodeUrl("mainnet")
525
- });
526
- function getSuiClient() {
527
- return config_suiClient;
528
- }
529
523
  const orderByKey = (array, key, sortBy)=>{
530
524
  if (!array?.length) return;
531
525
  let swapped;
@@ -544,12 +538,12 @@ const orderByKey = (array, key, sortBy)=>{
544
538
  }while (swapped);
545
539
  return array;
546
540
  };
547
- const getCoinObjectIdsByAmount = async (address, amount, coinType)=>{
541
+ const getCoinObjectIdsByAmount = async (suiClient, address, amount, coinType)=>{
548
542
  let coinBalances = [];
549
543
  let hasNextPage = true;
550
544
  let nextCursor;
551
545
  while(hasNextPage)try {
552
- const coins = await getSuiClient().getCoins({
546
+ const coins = await suiClient.getCoins({
553
547
  owner: address,
554
548
  coinType,
555
549
  cursor: nextCursor
@@ -583,11 +577,11 @@ const getCoinObjectIdsByAmount = async (address, amount, coinType)=>{
583
577
  objectCoins
584
578
  };
585
579
  };
586
- async function addGasFee(params) {
580
+ async function addGasFee(params, suiClient) {
587
581
  const { inheritTx, sender, feeAmount, suiInputAmount } = params;
588
582
  const tx = inheritTx || new Transaction();
589
583
  tx.setGasBudget(feeAmount);
590
- const { objectCoins } = await getCoinObjectIdsByAmount(sender, (BigInt(suiInputAmount || "0") + feeAmount).toString(), SUI_FULL_TYPE);
584
+ const { objectCoins } = await getCoinObjectIdsByAmount(suiClient, sender, (BigInt(suiInputAmount || "0") + feeAmount).toString(), SUI_FULL_TYPE);
591
585
  tx.setGasPayment(objectCoins.map((c)=>({
592
586
  objectId: c.coinObjectId,
593
587
  version: c.version,
@@ -611,10 +605,10 @@ async function addGasFee(params) {
611
605
  BluefinTx.transferOrDestroyZeroCoin = transferOrDestroyZeroCoin;
612
606
  })(bluefin_BluefinTx || (bluefin_BluefinTx = {}));
613
607
  var bluefin_BluefinTx;
614
- async function getSplitCoinForTx(params) {
608
+ async function getSplitCoinForTx(params, suiClient) {
615
609
  const { account, amount, splits, coinType, inheritTx, inspecTransaction, isSponsored = false } = params;
616
610
  const tx = inheritTx ?? new Transaction();
617
- const { objectIds } = await getCoinObjectIdsByAmount(account, amount, coinType);
611
+ const { objectIds } = await getCoinObjectIdsByAmount(suiClient, account, amount, coinType);
618
612
  const coinObjectId = objectIds[0];
619
613
  if (normalizeStructTag(coinType) === normalizeStructTag(SUI_FULL_TYPE) && !isSponsored) {
620
614
  let coin;
@@ -656,8 +650,8 @@ function getAmountAfterFee(amount, fee) {
656
650
  const feeAmount = amountNum * feeNum / BigInt(BASE_BPS);
657
651
  return amountNum - feeAmount;
658
652
  }
659
- async function getNeededGasFee(tx, sender, bufferPercent) {
660
- const { effects: { gasUsed, status } } = await getSuiClient().devInspectTransactionBlock({
653
+ async function getNeededGasFee(suiClient, tx, sender, bufferPercent) {
654
+ const { effects: { gasUsed, status } } = await suiClient.devInspectTransactionBlock({
661
655
  sender,
662
656
  transactionBlock: tx
663
657
  });
@@ -666,13 +660,12 @@ async function getNeededGasFee(tx, sender, bufferPercent) {
666
660
  const feeNum = BigInt(Number(bufferPercent) * BASE_BPS);
667
661
  return fee * (BigInt(BASE_BPS) + feeNum) / BigInt(BASE_BPS);
668
662
  }
669
- async function getMoveObjectContent(objectId) {
670
- const moveObject = await getMoveObject(objectId);
663
+ async function getMoveObjectContent(suiClient, objectId) {
664
+ const moveObject = await getMoveObject(suiClient, objectId);
671
665
  return moveObject.fields;
672
666
  }
673
- async function getMoveObject(objectId) {
674
- const client = getSuiClient();
675
- const objRes = await client.getObject({
667
+ async function getMoveObject(suiClient, objectId) {
668
+ const objRes = await suiClient.getObject({
676
669
  id: objectId,
677
670
  options: {
678
671
  showContent: true
@@ -742,8 +735,8 @@ function createCompatibleSuiClient(client) {
742
735
  })(package_Bps || (package_Bps = {}));
743
736
  (function(BlastFunPackage) {
744
737
  (function(MemezFun) {
745
- async function isSniperProtectedMemezFun(poolId) {
746
- const memezFun = await getMoveObjectContent(poolId);
738
+ async function isSniperProtectedMemezFun(suiClient, poolId) {
739
+ const memezFun = await getMoveObjectContent(suiClient, poolId);
747
740
  return memezFun.public_key.length > 0;
748
741
  }
749
742
  MemezFun.isSniperProtectedMemezFun = isSniperProtectedMemezFun;
@@ -787,8 +780,8 @@ function createCompatibleSuiClient(client) {
787
780
  MemezBurner.calculate = calculate;
788
781
  })(BlastFunPackage.MemezBurner || (BlastFunPackage.MemezBurner = {}));
789
782
  (function(MemezPump) {
790
- async function getPumpState(memezFun) {
791
- return await getMoveObjectContent(memezFun.inner_state);
783
+ async function getPumpState(suiClient, memezFun) {
784
+ return await getMoveObjectContent(suiClient, memezFun.inner_state);
792
785
  }
793
786
  MemezPump.getPumpState = getPumpState;
794
787
  function pump(pumpState, quoteAmount) {
@@ -823,25 +816,25 @@ function createCompatibleSuiClient(client) {
823
816
  })(package_BlastFunPackage || (package_BlastFunPackage = {}));
824
817
  var package_MathUtils, package_Bps, package_BlastFunPackage;
825
818
  (function(BlastFunCustomCalculation) {
826
- async function getCurveAmountAfterBuy(params) {
819
+ async function getCurveAmountAfterBuy(params, suiClient) {
827
820
  let { suiAmount, poolId, frontendFee } = params;
828
- const memezFun = await getMoveObjectContent(poolId);
829
- const pumpState = await package_BlastFunPackage.MemezPump.getPumpState(memezFun);
821
+ const memezFun = await getMoveObjectContent(suiClient, poolId);
822
+ const pumpState = await package_BlastFunPackage.MemezPump.getPumpState(suiClient, memezFun);
830
823
  suiAmount = getAmountAfterFee(suiAmount, frontendFee);
831
824
  return package_BlastFunPackage.MemezPump.pump(pumpState, suiAmount);
832
825
  }
833
826
  BlastFunCustomCalculation.getCurveAmountAfterBuy = getCurveAmountAfterBuy;
834
- async function getSuiAmountAfterSell(params) {
827
+ async function getSuiAmountAfterSell(params, suiClient) {
835
828
  const { curveAmount, poolId, frontendFee } = params;
836
- const memezFun = await getMoveObjectContent(poolId);
837
- const pumpState = await package_BlastFunPackage.MemezPump.getPumpState(memezFun);
829
+ const memezFun = await getMoveObjectContent(suiClient, poolId);
830
+ const pumpState = await package_BlastFunPackage.MemezPump.getPumpState(suiClient, memezFun);
838
831
  const suiAmount = package_BlastFunPackage.MemezPump.dump(pumpState, curveAmount);
839
832
  return getAmountAfterFee(suiAmount, frontendFee);
840
833
  }
841
834
  BlastFunCustomCalculation.getSuiAmountAfterSell = getSuiAmountAfterSell;
842
835
  })(custom_calculation_BlastFunCustomCalculation || (custom_calculation_BlastFunCustomCalculation = {}));
843
836
  var custom_calculation_BlastFunCustomCalculation;
844
- async function splitSuiCoinAfterFeeFromBuyTx(params) {
837
+ async function splitSuiCoinAfterFeeFromBuyTx(params, suiClient) {
845
838
  const { inputAmount, accountAddress, frontendFee, frontendFeeRecipient, extendTx, isSponsored } = params;
846
839
  tiny_invariant(params.inCoinType === SUI_FULL_TYPE || params.inCoinType === SUI_TYPE, "Input must be SUI");
847
840
  const { tx: _tx, coinIn } = extendTx || {};
@@ -859,7 +852,7 @@ async function splitSuiCoinAfterFeeFromBuyTx(params) {
859
852
  coinType: SUI_FULL_TYPE,
860
853
  inheritTx: tx,
861
854
  isSponsored: isSponsored || false
862
- });
855
+ }, suiClient);
863
856
  coinData = _data;
864
857
  }
865
858
  let inputSuiCoin;
@@ -934,9 +927,9 @@ var types_SupportedBondingCurve = /*#__PURE__*/ function(SupportedBondingCurve)
934
927
  });
935
928
  }
936
929
  BlastFunCustomTransaction.getAllowedVersions = getAllowedVersions;
937
- async function buildBuyTx(params) {
938
- tiny_invariant(!await package_BlastFunPackage.MemezFun.isSniperProtectedMemezFun(params.poolId), "This coin is a sniper protected coin, please use the Blast Fun website to trade it.");
939
- const { tx, coinOut: suiCoinIn } = await splitSuiCoinAfterFeeFromBuyTx(params);
930
+ async function buildBuyTx(params, suiClient) {
931
+ tiny_invariant(!await package_BlastFunPackage.MemezFun.isSniperProtectedMemezFun(suiClient, params.poolId), "This coin is a sniper protected coin, please use the Blast Fun website to trade it.");
932
+ const { tx, coinOut: suiCoinIn } = await splitSuiCoinAfterFeeFromBuyTx(params, suiClient);
940
933
  tiny_invariant(suiCoinIn, "Coin out is required");
941
934
  const curveCoin = tx.moveCall({
942
935
  target: `${constants_BlastFunConstants.PACKAGE_ID_V4}::memez_pump::pump`,
@@ -959,9 +952,9 @@ var types_SupportedBondingCurve = /*#__PURE__*/ function(SupportedBondingCurve)
959
952
  };
960
953
  }
961
954
  BlastFunCustomTransaction.buildBuyTx = buildBuyTx;
962
- async function buildSellTx(params) {
955
+ async function buildSellTx(params, suiClient) {
963
956
  tiny_invariant(params.outCoinType === SUI_FULL_TYPE || params.outCoinType === SUI_TYPE, "Output must be SUI");
964
- const memezFun = await getMoveObjectContent(params.poolId);
957
+ const memezFun = await getMoveObjectContent(suiClient, params.poolId);
965
958
  const { tx, coinData } = await getSplitCoinForTx({
966
959
  amount: params.inputAmount,
967
960
  coinType: params.inCoinType,
@@ -970,7 +963,7 @@ var types_SupportedBondingCurve = /*#__PURE__*/ function(SupportedBondingCurve)
970
963
  splits: [
971
964
  params.inputAmount
972
965
  ]
973
- });
966
+ }, suiClient);
974
967
  const [inputCoin] = coinData;
975
968
  const [suiCoin] = tx.moveCall({
976
969
  target: `${constants_BlastFunConstants.PACKAGE_ID_V4}::memez_pump::dump`,
@@ -1023,8 +1016,8 @@ function getMemezPumpSDK() {
1023
1016
  })(sdk_calculation_BlastFunSDKCalculation || (sdk_calculation_BlastFunSDKCalculation = {}));
1024
1017
  var sdk_calculation_BlastFunSDKCalculation;
1025
1018
  (function(BlastFunSDKTransaction) {
1026
- async function buildBuyTx(params) {
1027
- const { tx, coinOut: suiCoinIn } = await splitSuiCoinAfterFeeFromBuyTx(params);
1019
+ async function buildBuyTx(params, suiClient) {
1020
+ const { tx, coinOut: suiCoinIn } = await splitSuiCoinAfterFeeFromBuyTx(params, suiClient);
1028
1021
  tiny_invariant(suiCoinIn, "Coin out is required");
1029
1022
  const { memeCoin, tx: tx2 } = await getMemezPumpSDK().pump({
1030
1023
  pool: params.poolId,
@@ -1038,7 +1031,7 @@ var sdk_calculation_BlastFunSDKCalculation;
1038
1031
  };
1039
1032
  }
1040
1033
  BlastFunSDKTransaction.buildBuyTx = buildBuyTx;
1041
- async function buildSellTx(params) {
1034
+ async function buildSellTx(params, suiClient) {
1042
1035
  tiny_invariant(params.outCoinType === SUI_FULL_TYPE || params.outCoinType === SUI_TYPE, "Output must be SUI");
1043
1036
  const { tx, coinData } = await getSplitCoinForTx({
1044
1037
  amount: params.inputAmount,
@@ -1048,7 +1041,7 @@ var sdk_calculation_BlastFunSDKCalculation;
1048
1041
  splits: [
1049
1042
  params.inputAmount
1050
1043
  ]
1051
- });
1044
+ }, suiClient);
1052
1045
  const [inputCoin] = coinData;
1053
1046
  const { quoteCoin, tx: tx2 } = await getMemezPumpSDK().dump({
1054
1047
  pool: params.poolId,
@@ -1082,19 +1075,19 @@ var sdk_calculation_BlastFunSDKCalculation;
1082
1075
  frontendFeeRecipient: tradeFee ? tradeFee.tradeFeeRecipientAddress : void 0,
1083
1076
  extendTx: void 0,
1084
1077
  isSponsored: false
1085
- });
1078
+ }, suiClient);
1086
1079
  tiny_invariant(coinOut, "Coin out is required");
1087
1080
  tx.transferObjects([
1088
1081
  coinOut
1089
1082
  ], tx.pure.address(walletAddress));
1090
1083
  tx.setSender(walletAddress);
1091
- const feeAmount = await getNeededGasFee(tx, walletAddress, 0);
1084
+ const feeAmount = await getNeededGasFee(suiClient, tx, walletAddress, 0);
1092
1085
  tx = await addGasFee({
1093
1086
  inheritTx: tx,
1094
1087
  sender: walletAddress,
1095
1088
  feeAmount,
1096
1089
  suiInputAmount: inputAmount
1097
- });
1090
+ }, suiClient);
1098
1091
  return tx.build({
1099
1092
  client: suiClient
1100
1093
  });
@@ -1123,18 +1116,18 @@ var sdk_calculation_BlastFunSDKCalculation;
1123
1116
  frontendFeeRecipient: tradeFee ? tradeFee.tradeFeeRecipientAddress : void 0,
1124
1117
  extendTx: void 0,
1125
1118
  isSponsored: false
1126
- });
1119
+ }, suiClient);
1127
1120
  tiny_invariant(coinOut, "Coin out is required");
1128
1121
  tx.transferObjects([
1129
1122
  coinOut
1130
1123
  ], tx.pure.address(walletAddress));
1131
1124
  tx.setSender(walletAddress);
1132
- const feeAmount = await getNeededGasFee(tx, walletAddress, 0);
1125
+ const feeAmount = await getNeededGasFee(suiClient, tx, walletAddress, 0);
1133
1126
  tx = await addGasFee({
1134
1127
  inheritTx: tx,
1135
1128
  sender: walletAddress,
1136
1129
  feeAmount
1137
- });
1130
+ }, suiClient);
1138
1131
  return tx.build({
1139
1132
  client: suiClient
1140
1133
  });
@@ -1175,8 +1168,8 @@ var constants_MoonbagsConstants;
1175
1168
  Curves.calculateTokenAmountReceived = calculateTokenAmountReceived;
1176
1169
  })(MoonbagsPackage.Curves || (MoonbagsPackage.Curves = {}));
1177
1170
  (function(Moonbags) {
1178
- async function getDynamicVirtualTokenReserves(poolId) {
1179
- const result = await getSuiClient().getDynamicFieldObject({
1171
+ async function getDynamicVirtualTokenReserves(suiClient, poolId) {
1172
+ const result = await suiClient.getDynamicFieldObject({
1180
1173
  parentId: poolId,
1181
1174
  name: {
1182
1175
  type: "vector<u8>",
@@ -1227,12 +1220,12 @@ var constants_MoonbagsConstants;
1227
1220
  })(package_MoonbagsPackage || (package_MoonbagsPackage = {}));
1228
1221
  var package_MoonbagsPackage;
1229
1222
  (function(MoonbagsCalculation) {
1230
- async function getCurveAmountAfterBuy(params) {
1223
+ async function getCurveAmountAfterBuy(params, suiClient) {
1231
1224
  let { suiAmount, poolId, frontendFee } = params;
1232
1225
  const [poolMoveStruct, configMoveStruct, dynamicVirtualTokenReserves] = await Promise.all([
1233
- getMoveObjectContent(poolId),
1234
- getMoveObjectContent(constants_MoonbagsConstants.CONFIG_OBJECT_ID),
1235
- package_MoonbagsPackage.Moonbags.getDynamicVirtualTokenReserves(poolId)
1226
+ getMoveObjectContent(suiClient, poolId),
1227
+ getMoveObjectContent(suiClient, constants_MoonbagsConstants.CONFIG_OBJECT_ID),
1228
+ package_MoonbagsPackage.Moonbags.getDynamicVirtualTokenReserves(suiClient, poolId)
1236
1229
  ]);
1237
1230
  const pool = poolMoveStruct;
1238
1231
  const config = configMoveStruct;
@@ -1248,11 +1241,11 @@ var package_MoonbagsPackage;
1248
1241
  return receivedCurve;
1249
1242
  }
1250
1243
  MoonbagsCalculation.getCurveAmountAfterBuy = getCurveAmountAfterBuy;
1251
- async function getSuiAmountAfterSell(params) {
1244
+ async function getSuiAmountAfterSell(params, suiClient) {
1252
1245
  const { curveAmount, poolId, frontendFee } = params;
1253
1246
  const [poolMoveStruct, configMoveStruct] = await Promise.all([
1254
- getMoveObjectContent(poolId),
1255
- getMoveObjectContent(constants_MoonbagsConstants.CONFIG_OBJECT_ID)
1247
+ getMoveObjectContent(suiClient, poolId),
1248
+ getMoveObjectContent(suiClient, constants_MoonbagsConstants.CONFIG_OBJECT_ID)
1256
1249
  ]);
1257
1250
  const pool = poolMoveStruct;
1258
1251
  const config = configMoveStruct;
@@ -1265,9 +1258,9 @@ var package_MoonbagsPackage;
1265
1258
  return receivedSui;
1266
1259
  }
1267
1260
  MoonbagsCalculation.getSuiAmountAfterSell = getSuiAmountAfterSell;
1268
- async function getUsedSuiForTx(params) {
1261
+ async function getUsedSuiForTx(params, suiClient) {
1269
1262
  let { suiAmount, frontendFee } = params;
1270
- const configMoveStruct = await getMoveObjectContent(constants_MoonbagsConstants.CONFIG_OBJECT_ID);
1263
+ const configMoveStruct = await getMoveObjectContent(suiClient, constants_MoonbagsConstants.CONFIG_OBJECT_ID);
1271
1264
  const config = configMoveStruct;
1272
1265
  if (void 0 !== frontendFee) suiAmount = getAmountAfterFee(suiAmount, frontendFee);
1273
1266
  return suiAmount * constants_MoonbagsConstants.FEE_DENOMINATOR / (constants_MoonbagsConstants.FEE_DENOMINATOR + BigInt(config.platform_fee));
@@ -1276,13 +1269,13 @@ var package_MoonbagsPackage;
1276
1269
  })(calculation_MoonbagsCalculation || (calculation_MoonbagsCalculation = {}));
1277
1270
  var calculation_MoonbagsCalculation;
1278
1271
  (function(MoonbagsTransaction) {
1279
- async function buildBuyTx(params) {
1280
- const { tx, coinOut } = await splitSuiCoinAfterFeeFromBuyTx(params);
1272
+ async function buildBuyTx(params, suiClient) {
1273
+ const { tx, coinOut } = await splitSuiCoinAfterFeeFromBuyTx(params, suiClient);
1281
1274
  tiny_invariant(coinOut, "Coin out is required");
1282
1275
  const usedSui = await calculation_MoonbagsCalculation.getUsedSuiForTx({
1283
1276
  suiAmount: BigInt(params.inputAmount),
1284
1277
  frontendFee: params.frontendFee
1285
- });
1278
+ }, suiClient);
1286
1279
  const [suiCoin, curveCoin] = tx.moveCall({
1287
1280
  target: `${constants_MoonbagsConstants.PACKAGE_ID}::moonbags::buy_exact_in_returns_with_lock`,
1288
1281
  typeArguments: [
@@ -1308,7 +1301,7 @@ var calculation_MoonbagsCalculation;
1308
1301
  };
1309
1302
  }
1310
1303
  MoonbagsTransaction.buildBuyTx = buildBuyTx;
1311
- async function buildSellTx(params) {
1304
+ async function buildSellTx(params, suiClient) {
1312
1305
  tiny_invariant(params.outCoinType === SUI_FULL_TYPE || params.outCoinType === SUI_TYPE, "Output must be SUI");
1313
1306
  const { tx, coinData } = await getSplitCoinForTx({
1314
1307
  amount: params.inputAmount,
@@ -1318,7 +1311,7 @@ var calculation_MoonbagsCalculation;
1318
1311
  splits: [
1319
1312
  params.inputAmount
1320
1313
  ]
1321
- });
1314
+ }, suiClient);
1322
1315
  const [inputCoin] = coinData;
1323
1316
  const [suiCoin, curveCoin] = tx.moveCall({
1324
1317
  target: `${constants_MoonbagsConstants.PACKAGE_ID}::moonbags::sell_returns`,
@@ -1346,7 +1339,7 @@ var calculation_MoonbagsCalculation;
1346
1339
  poolId: poolId,
1347
1340
  suiAmount: inputAmount,
1348
1341
  frontendFee: tradeFee ? tradeFee.tradeFeePercent : void 0
1349
- });
1342
+ }, suiClient);
1350
1343
  const minAmountOut = BigInt(new bignumber(outputAmount.toString()).multipliedBy(1 - slippage).toFixed(0, 3));
1351
1344
  let { tx, coinOut } = await buildBuyTx({
1352
1345
  accountAddress: walletAddress,
@@ -1359,19 +1352,19 @@ var calculation_MoonbagsCalculation;
1359
1352
  frontendFeeRecipient: tradeFee ? tradeFee.tradeFeeRecipientAddress : void 0,
1360
1353
  extendTx: void 0,
1361
1354
  isSponsored: false
1362
- });
1355
+ }, suiClient);
1363
1356
  tiny_invariant(coinOut, "Coin out is required");
1364
1357
  tx.transferObjects([
1365
1358
  coinOut
1366
1359
  ], tx.pure.address(walletAddress));
1367
1360
  tx.setSender(walletAddress);
1368
- const feeAmount = await getNeededGasFee(tx, walletAddress, 0);
1361
+ const feeAmount = await getNeededGasFee(suiClient, tx, walletAddress, 0);
1369
1362
  tx = await addGasFee({
1370
1363
  inheritTx: tx,
1371
1364
  sender: walletAddress,
1372
1365
  feeAmount,
1373
1366
  suiInputAmount: inputAmount
1374
- });
1367
+ }, suiClient);
1375
1368
  return tx.build({
1376
1369
  client: suiClient
1377
1370
  });
@@ -1387,7 +1380,7 @@ var calculation_MoonbagsCalculation;
1387
1380
  poolId: poolId,
1388
1381
  curveAmount: inputAmount,
1389
1382
  frontendFee: tradeFee ? tradeFee.tradeFeePercent : void 0
1390
- });
1383
+ }, suiClient);
1391
1384
  const minAmountOut = BigInt(new bignumber(outputAmount.toString()).multipliedBy(1 - slippage).toFixed(0, 3));
1392
1385
  let { tx, coinOut } = await buildSellTx({
1393
1386
  accountAddress: walletAddress,
@@ -1400,18 +1393,18 @@ var calculation_MoonbagsCalculation;
1400
1393
  frontendFeeRecipient: tradeFee ? tradeFee.tradeFeeRecipientAddress : void 0,
1401
1394
  extendTx: void 0,
1402
1395
  isSponsored: false
1403
- });
1396
+ }, suiClient);
1404
1397
  tiny_invariant(coinOut, "Coin out is required");
1405
1398
  tx.transferObjects([
1406
1399
  coinOut
1407
1400
  ], tx.pure.address(walletAddress));
1408
1401
  tx.setSender(walletAddress);
1409
- const feeAmount = await getNeededGasFee(tx, walletAddress, 0);
1402
+ const feeAmount = await getNeededGasFee(suiClient, tx, walletAddress, 0);
1410
1403
  tx = await addGasFee({
1411
1404
  inheritTx: tx,
1412
1405
  sender: walletAddress,
1413
1406
  feeAmount
1414
- });
1407
+ }, suiClient);
1415
1408
  return tx.build({
1416
1409
  client: suiClient
1417
1410
  });
@@ -1420,18 +1413,13 @@ var calculation_MoonbagsCalculation;
1420
1413
  })(transaction_MoonbagsTransaction || (transaction_MoonbagsTransaction = {}));
1421
1414
  var transaction_MoonbagsTransaction;
1422
1415
  const CONSTANTS = {
1423
- SUI_DECIMALS: 9,
1424
- GAS_FEE_BUFFER_PERCENTAGE: 0.1,
1425
- MIN_TRANSFER_AMOUNT: 0.000000001
1416
+ GAS_FEE_BUFFER_PERCENTAGE: 0.1
1426
1417
  };
1427
1418
  class DraftTransferTx {
1428
1419
  suiClient;
1429
1420
  constructor(suiClient){
1430
1421
  this.suiClient = suiClient;
1431
1422
  }
1432
- suiToMist(suiAmount) {
1433
- return BigInt(Math.floor(suiAmount * 10 ** CONSTANTS.SUI_DECIMALS));
1434
- }
1435
1423
  validatePrivateKey(privateKey, expectedSender) {
1436
1424
  tiny_invariant(privateKey?.trim(), "Private key is required");
1437
1425
  const keypair = Ed25519Keypair.fromSecretKey(privateKey);
@@ -1439,16 +1427,15 @@ class DraftTransferTx {
1439
1427
  if (derivedAddress !== expectedSender) throw new Error(`Private key mismatch. Expected: ${expectedSender}, Got: ${derivedAddress}`);
1440
1428
  return keypair;
1441
1429
  }
1442
- async createDraft(sender, recipient, suiAmount) {
1430
+ async createDraft(sender, recipient, amountMIST) {
1443
1431
  tiny_invariant(sender?.trim(), "Sender address is required");
1444
1432
  tiny_invariant(recipient?.trim(), "Recipient address is required");
1445
1433
  tiny_invariant(sender !== recipient, "Sender and recipient cannot be the same");
1446
- tiny_invariant(suiAmount > CONSTANTS.MIN_TRANSFER_AMOUNT, `Transfer amount must be greater than ${CONSTANTS.MIN_TRANSFER_AMOUNT} SUI`);
1447
- const suiAmountMist = this.suiToMist(suiAmount);
1434
+ tiny_invariant(amountMIST > 0n, "Transfer amount must be at least 1 MIST");
1448
1435
  try {
1449
1436
  let transaction = new Transaction();
1450
1437
  const [coin] = transaction.splitCoins(transaction.gas, [
1451
- suiAmountMist
1438
+ amountMIST
1452
1439
  ]);
1453
1440
  transaction.transferObjects([
1454
1441
  coin
@@ -1456,13 +1443,13 @@ class DraftTransferTx {
1456
1443
  transaction.setSender(sender);
1457
1444
  const referenceGasPrice = await this.suiClient.getReferenceGasPrice();
1458
1445
  transaction.setGasPrice(referenceGasPrice);
1459
- const feeAmount = await getNeededGasFee(transaction, sender, CONSTANTS.GAS_FEE_BUFFER_PERCENTAGE);
1446
+ const feeAmount = await getNeededGasFee(this.suiClient, transaction, sender, CONSTANTS.GAS_FEE_BUFFER_PERCENTAGE);
1460
1447
  transaction = await addGasFee({
1461
1448
  inheritTx: transaction,
1462
1449
  sender,
1463
1450
  feeAmount,
1464
- suiInputAmount: suiAmountMist
1465
- });
1451
+ suiInputAmount: amountMIST
1452
+ }, this.suiClient);
1466
1453
  const txBytes = await transaction.build({
1467
1454
  client: this.suiClient
1468
1455
  });
@@ -1471,7 +1458,7 @@ class DraftTransferTx {
1471
1458
  return {
1472
1459
  sender,
1473
1460
  recipient,
1474
- suiAmount,
1461
+ amountMIST,
1475
1462
  txDraftBase64,
1476
1463
  txDigest
1477
1464
  };
@@ -1522,4 +1509,4 @@ class DraftTransferTx {
1522
1509
  }
1523
1510
  }
1524
1511
  }
1525
- export { aftermath_AftermathAggregator as AftermathAggregator, astros_AstrosAggregator as AstrosAggregator, BASE_BPS, BLUEFIN_PACKAGE_ID, constants_BlastFunConstants as BlastFunConstants, custom_calculation_BlastFunCustomCalculation as BlastFunCustomCalculation, custom_transaction_BlastFunCustomTransaction as BlastFunCustomTransaction, package_BlastFunPackage as BlastFunPackage, sdk_calculation_BlastFunSDKCalculation as BlastFunSDKCalculation, sdk_transaction_BlastFunSDKTransaction as BlastFunSDKTransaction, bluefin_BluefinTx as BluefinTx, package_Bps as Bps, CLOCK_OBJECT_ID, cetus_CetusAggregator as CetusAggregator, DraftTransferTx, flowx_FlowXAggregator as FlowXAggregator, package_MathUtils as MathUtils, calculation_MoonbagsCalculation as MoonbagsCalculation, constants_MoonbagsConstants as MoonbagsConstants, package_MoonbagsPackage as MoonbagsPackage, transaction_MoonbagsTransaction as MoonbagsTransaction, NATIVE_USDC_TOKEN_TYPE, SUI_FULL_TYPE, SUI_METADATA_OBJECT_ID, SUI_TYPE, _7k_SevenKAggregator as SevenKAggregator, common_SupportedAggregator as SupportedAggregator, types_SupportedBondingCurve as SupportedBondingCurve, types_TradeFeeOptions as TradeFeeOptions, USDC_TOKEN_TYPE, adaptSuiClient, adaptTransaction, addGasFee, createCompatibleSuiClient, getAmountAfterFee, getCoinObjectIdsByAmount, getMemezPumpSDK, getMoveObject, getMoveObjectContent, getNeededGasFee, getSplitCoinForTx, getSplitCoinsAfterFee, getSuiClient, splitSuiCoinAfterFeeFromBuyTx, splitSuiCoinAfterFeeFromSellTx };
1512
+ export { aftermath_AftermathAggregator as AftermathAggregator, astros_AstrosAggregator as AstrosAggregator, BASE_BPS, BLUEFIN_PACKAGE_ID, constants_BlastFunConstants as BlastFunConstants, custom_calculation_BlastFunCustomCalculation as BlastFunCustomCalculation, custom_transaction_BlastFunCustomTransaction as BlastFunCustomTransaction, package_BlastFunPackage as BlastFunPackage, sdk_calculation_BlastFunSDKCalculation as BlastFunSDKCalculation, sdk_transaction_BlastFunSDKTransaction as BlastFunSDKTransaction, bluefin_BluefinTx as BluefinTx, package_Bps as Bps, CLOCK_OBJECT_ID, cetus_CetusAggregator as CetusAggregator, DraftTransferTx, flowx_FlowXAggregator as FlowXAggregator, package_MathUtils as MathUtils, calculation_MoonbagsCalculation as MoonbagsCalculation, constants_MoonbagsConstants as MoonbagsConstants, package_MoonbagsPackage as MoonbagsPackage, transaction_MoonbagsTransaction as MoonbagsTransaction, NATIVE_USDC_TOKEN_TYPE, SUI_FULL_TYPE, SUI_METADATA_OBJECT_ID, SUI_TYPE, _7k_SevenKAggregator as SevenKAggregator, common_SupportedAggregator as SupportedAggregator, types_SupportedBondingCurve as SupportedBondingCurve, types_TradeFeeOptions as TradeFeeOptions, USDC_TOKEN_TYPE, adaptSuiClient, adaptTransaction, addGasFee, createCompatibleSuiClient, getAmountAfterFee, getCoinObjectIdsByAmount, getMemezPumpSDK, getMoveObject, getMoveObjectContent, getNeededGasFee, getSplitCoinForTx, getSplitCoinsAfterFee, splitSuiCoinAfterFeeFromBuyTx, splitSuiCoinAfterFeeFromSellTx };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@minswap/noodles-sdk",
3
- "version": "0.0.10",
3
+ "version": "0.0.12",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -19,19 +19,19 @@
19
19
  "url": "git@github.com:minswap/noodles-sdk.git"
20
20
  },
21
21
  "devDependencies": {
22
- "@biomejs/biome": "2.2.4",
22
+ "@biomejs/biome": "2.2.5",
23
23
  "@changesets/cli": "^2.29.7",
24
- "@microsoft/api-extractor": "^7.52.13",
25
- "@rslib/core": "^0.14.0",
24
+ "@microsoft/api-extractor": "^7.53.0",
25
+ "@rslib/core": "^0.15.0",
26
26
  "@types/bn.js": "^5.2.0",
27
27
  "@types/node": "22",
28
28
  "tsx": "^4.20.6",
29
- "typescript": "^5.9.2"
29
+ "typescript": "^5.9.3"
30
30
  },
31
31
  "dependencies": {
32
32
  "@7kprotocol/sdk-ts": "3.4.1",
33
33
  "@alphafi/alphalend-sdk": "^1.1.20",
34
- "@cetusprotocol/aggregator-sdk": "1.2.0",
34
+ "@cetusprotocol/aggregator-sdk": "1.2.1",
35
35
  "@cetusprotocol/cetus-sui-clmm-sdk": "^5.4.0",
36
36
  "@flowx-finance/sdk": "1.13.4",
37
37
  "@interest-protocol/memez-fun-sdk": "^16.6.0",
@@ -40,7 +40,7 @@
40
40
  "@mysten/sui": "1.38.0",
41
41
  "@naviprotocol/astros-aggregator-sdk": "^1.7.0",
42
42
  "@scallop-io/sui-scallop-sdk": "^2.2.9",
43
- "@suilend/sdk": "^1.1.81",
43
+ "@suilend/sdk": "^1.1.84",
44
44
  "aftermath-ts-sdk": "1.3.22",
45
45
  "bignumber.js": "^9.3.1",
46
46
  "bn.js": "^5.2.2",
@@ -53,6 +53,7 @@
53
53
  "build": "rslib build",
54
54
  "lint": "biome check --write",
55
55
  "dev": "rslib build --watch",
56
- "format": "biome format --write"
56
+ "format": "biome check --write",
57
+ "typecheck": "tsc --noEmit"
57
58
  }
58
59
  }