@minswap/noodles-sdk 0.0.11 → 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 +68 -78
- package/dist/index.d.ts +22 -24
- package/dist/index.js +68 -75
- package/package.json +7 -7
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
|
-
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
});
|
|
@@ -1534,13 +1526,13 @@ class DraftTransferTx {
|
|
|
1534
1526
|
transaction.setSender(sender);
|
|
1535
1527
|
const referenceGasPrice = await this.suiClient.getReferenceGasPrice();
|
|
1536
1528
|
transaction.setGasPrice(referenceGasPrice);
|
|
1537
|
-
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);
|
|
1538
1530
|
transaction = await addGasFee({
|
|
1539
1531
|
inheritTx: transaction,
|
|
1540
1532
|
sender,
|
|
1541
1533
|
feeAmount,
|
|
1542
1534
|
suiInputAmount: amountMIST
|
|
1543
|
-
});
|
|
1535
|
+
}, this.suiClient);
|
|
1544
1536
|
const txBytes = await transaction.build({
|
|
1545
1537
|
client: this.suiClient
|
|
1546
1538
|
});
|
|
@@ -1642,7 +1634,6 @@ exports.getMoveObjectContent = __webpack_exports__.getMoveObjectContent;
|
|
|
1642
1634
|
exports.getNeededGasFee = __webpack_exports__.getNeededGasFee;
|
|
1643
1635
|
exports.getSplitCoinForTx = __webpack_exports__.getSplitCoinForTx;
|
|
1644
1636
|
exports.getSplitCoinsAfterFee = __webpack_exports__.getSplitCoinsAfterFee;
|
|
1645
|
-
exports.getSuiClient = __webpack_exports__.getSuiClient;
|
|
1646
1637
|
exports.splitSuiCoinAfterFeeFromBuyTx = __webpack_exports__.splitSuiCoinAfterFeeFromBuyTx;
|
|
1647
1638
|
exports.splitSuiCoinAfterFeeFromSellTx = __webpack_exports__.splitSuiCoinAfterFeeFromSellTx;
|
|
1648
1639
|
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
@@ -1688,7 +1679,6 @@ for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
|
1688
1679
|
"getNeededGasFee",
|
|
1689
1680
|
"getSplitCoinForTx",
|
|
1690
1681
|
"getSplitCoinsAfterFee",
|
|
1691
|
-
"getSuiClient",
|
|
1692
1682
|
"splitSuiCoinAfterFeeFromBuyTx",
|
|
1693
1683
|
"splitSuiCoinAfterFeeFromSellTx"
|
|
1694
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
|
}
|
|
@@ -546,7 +546,7 @@ export declare type FlowXAggregatorConfig = {
|
|
|
546
546
|
|
|
547
547
|
export declare function getAmountAfterFee(amount: bigint | string, fee?: string | number): bigint;
|
|
548
548
|
|
|
549
|
-
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<{
|
|
550
550
|
objectIds: string[];
|
|
551
551
|
objectCoins: CoinStruct[];
|
|
552
552
|
balance: string;
|
|
@@ -560,11 +560,11 @@ export declare type GetCurveAmountAfterBuyParams = {
|
|
|
560
560
|
|
|
561
561
|
export declare function getMemezPumpSDK(): MemezPumpSDK;
|
|
562
562
|
|
|
563
|
-
export declare function getMoveObject(objectId: string): Promise<MoveObject>;
|
|
563
|
+
export declare function getMoveObject(suiClient: SuiClient, objectId: string): Promise<MoveObject>;
|
|
564
564
|
|
|
565
|
-
export declare function getMoveObjectContent(objectId: string): Promise<MoveStruct>;
|
|
565
|
+
export declare function getMoveObjectContent(suiClient: SuiClient, objectId: string): Promise<MoveStruct>;
|
|
566
566
|
|
|
567
|
-
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>;
|
|
568
568
|
|
|
569
569
|
declare type GetSplitCoinForTx = {
|
|
570
570
|
account: string;
|
|
@@ -576,7 +576,7 @@ declare type GetSplitCoinForTx = {
|
|
|
576
576
|
isSponsored?: boolean;
|
|
577
577
|
};
|
|
578
578
|
|
|
579
|
-
export declare function getSplitCoinForTx(params: GetSplitCoinForTx): Promise<{
|
|
579
|
+
export declare function getSplitCoinForTx(params: GetSplitCoinForTx, suiClient: SuiClient): Promise<{
|
|
580
580
|
tx: Transaction;
|
|
581
581
|
coinData: TransactionResult;
|
|
582
582
|
}>;
|
|
@@ -589,8 +589,6 @@ export declare type GetSuiAmountAfterSellParams = {
|
|
|
589
589
|
frontendFee?: number | string;
|
|
590
590
|
};
|
|
591
591
|
|
|
592
|
-
export declare function getSuiClient(): SuiClient;
|
|
593
|
-
|
|
594
592
|
/**
|
|
595
593
|
* Request parameters for getting a trade route
|
|
596
594
|
*/
|
|
@@ -755,12 +753,12 @@ export declare namespace MathUtils {
|
|
|
755
753
|
}
|
|
756
754
|
|
|
757
755
|
export declare namespace MoonbagsCalculation {
|
|
758
|
-
export function getCurveAmountAfterBuy(params: GetCurveAmountAfterBuyParams): Promise<bigint>;
|
|
759
|
-
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>;
|
|
760
758
|
export function getUsedSuiForTx(params: {
|
|
761
759
|
suiAmount: bigint;
|
|
762
760
|
frontendFee?: number | string;
|
|
763
|
-
}): Promise<bigint>;
|
|
761
|
+
}, suiClient: SuiClient): Promise<bigint>;
|
|
764
762
|
}
|
|
765
763
|
|
|
766
764
|
export declare namespace MoonbagsConstants {
|
|
@@ -799,7 +797,7 @@ export declare namespace MoonbagsPackage {
|
|
|
799
797
|
name: number[];
|
|
800
798
|
value: string;
|
|
801
799
|
};
|
|
802
|
-
export function getDynamicVirtualTokenReserves(poolId: string): Promise<bigint | undefined>;
|
|
800
|
+
export function getDynamicVirtualTokenReserves(suiClient: SuiClient, poolId: string): Promise<bigint | undefined>;
|
|
803
801
|
export function buyExactInReturnsWithLock(params: {
|
|
804
802
|
inputAmount: bigint;
|
|
805
803
|
amountIn: bigint;
|
|
@@ -822,8 +820,8 @@ export declare namespace MoonbagsPackage {
|
|
|
822
820
|
}
|
|
823
821
|
|
|
824
822
|
export declare namespace MoonbagsTransaction {
|
|
825
|
-
export function buildBuyTx(params: BuildSwapTxParams): Promise<BuildTxResult>;
|
|
826
|
-
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>;
|
|
827
825
|
export function getBuyTransaction({ coinInAmount, coinInType, coinOutType, poolId, slippage, walletAddress, tradeFee }: GetTradeTransactionRequest, suiClient: SuiClient): Promise<Uint8Array>;
|
|
828
826
|
export function getSellTransaction({ coinInAmount, coinInType, coinOutType, poolId, slippage, walletAddress, tradeFee }: GetTradeTransactionRequest, suiClient: SuiClient): Promise<Uint8Array>;
|
|
829
827
|
}
|
|
@@ -895,7 +893,7 @@ export declare type SevenKAggregatorConfig = {
|
|
|
895
893
|
sevenKApiKey?: string;
|
|
896
894
|
};
|
|
897
895
|
|
|
898
|
-
export declare function splitSuiCoinAfterFeeFromBuyTx(params: BuildSwapTxParams): Promise<BuildTxResult>;
|
|
896
|
+
export declare function splitSuiCoinAfterFeeFromBuyTx(params: BuildSwapTxParams, suiClient: SuiClient): Promise<BuildTxResult>;
|
|
899
897
|
|
|
900
898
|
export declare function splitSuiCoinAfterFeeFromSellTx(tx: Transaction, params: BuildSwapTxParams, suiCoin: TransactionObjectArgument): Promise<BuildTxResult>;
|
|
901
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
|
|
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
|
|
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
|
|
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
|
|
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
|
});
|
|
@@ -1450,13 +1443,13 @@ class DraftTransferTx {
|
|
|
1450
1443
|
transaction.setSender(sender);
|
|
1451
1444
|
const referenceGasPrice = await this.suiClient.getReferenceGasPrice();
|
|
1452
1445
|
transaction.setGasPrice(referenceGasPrice);
|
|
1453
|
-
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);
|
|
1454
1447
|
transaction = await addGasFee({
|
|
1455
1448
|
inheritTx: transaction,
|
|
1456
1449
|
sender,
|
|
1457
1450
|
feeAmount,
|
|
1458
1451
|
suiInputAmount: amountMIST
|
|
1459
|
-
});
|
|
1452
|
+
}, this.suiClient);
|
|
1460
1453
|
const txBytes = await transaction.build({
|
|
1461
1454
|
client: this.suiClient
|
|
1462
1455
|
});
|
|
@@ -1516,4 +1509,4 @@ class DraftTransferTx {
|
|
|
1516
1509
|
}
|
|
1517
1510
|
}
|
|
1518
1511
|
}
|
|
1519
|
-
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,
|
|
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.
|
|
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.
|
|
22
|
+
"@biomejs/biome": "2.2.5",
|
|
23
23
|
"@changesets/cli": "^2.29.7",
|
|
24
|
-
"@microsoft/api-extractor": "^7.
|
|
25
|
-
"@rslib/core": "^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.
|
|
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.
|
|
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.
|
|
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",
|