@minswap/noodles-sdk 0.0.37 → 0.0.38-next.1

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
@@ -1 +1,3317 @@
1
- "use strict";const __rslib_import_meta_url__="u"<typeof document?new(require("url".replace("",""))).URL("file:"+__filename).href:document.currentScript&&document.currentScript.src||new URL("main.js",document.baseURI).href;var types_TradeFeeOptions,constants_BlastFunConstants,package_MathUtils,package_Bps,package_BlastFunPackage,custom_calculation_BlastFunCustomCalculation,bluefin_BluefinTx,custom_transaction_BlastFunCustomTransaction,sdk_calculation_BlastFunSDKCalculation,sdk_transaction_BlastFunSDKTransaction,constants_MoonbagsConstants,package_MoonbagsPackage,calculation_MoonbagsCalculation,transaction_MoonbagsTransaction,__webpack_require__={};__webpack_require__.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return __webpack_require__.d(t,{a:t}),t},__webpack_require__.d=(e,t)=>{for(var n in t)__webpack_require__.o(t,n)&&!__webpack_require__.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},__webpack_require__.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),__webpack_require__.r=e=>{"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var __webpack_exports__={};__webpack_require__.r(__webpack_exports__),__webpack_require__.d(__webpack_exports__,{addGasFee:()=>addGasFee,TradeFeeOptions:()=>types_TradeFeeOptions,SUBSCRIPTION_CONFIG_ID:()=>SUBSCRIPTION_CONFIG_ID,getMemezPumpSDK:()=>getMemezPumpSDK,DraftTransferTx:()=>DraftTransferTx,BlastFunSDKCalculation:()=>sdk_calculation_BlastFunSDKCalculation,MoonbagsConstants:()=>constants_MoonbagsConstants,NoodlesPaySdk:()=>NoodlesPaySdk,Bps:()=>package_Bps,ADMIN_CAP_ID:()=>ADMIN_CAP_ID,splitSuiCoinAfterFeeFromBuyTx:()=>splitSuiCoinAfterFeeFromBuyTx,getMoveObject:()=>getMoveObject,SUBSCRIPTION_PACKAGE_ID:()=>SUBSCRIPTION_PACKAGE_ID,MoonbagsCalculation:()=>calculation_MoonbagsCalculation,SUBSCRIPTION_ADMIN_CAP_ID:()=>SUBSCRIPTION_ADMIN_CAP_ID,getSplitCoinsAfterFee:()=>getSplitCoinsAfterFee,AstrosAggregator:()=>astros_AstrosAggregator,BlastFunSDKTransaction:()=>sdk_transaction_BlastFunSDKTransaction,CONFIG_ID:()=>CONFIG_ID,AftermathAggregator:()=>aftermath_AftermathAggregator,FlowXAggregator:()=>flowx_FlowXAggregator,adaptSuiClient:()=>adaptSuiClient,getNeededGasFee:()=>getNeededGasFee,AggregatorModule:()=>AggregatorModule,adaptTransaction:()=>adaptTransaction,createCompatibleSuiClient:()=>createCompatibleSuiClient,splitSuiCoinAfterFeeFromSellTx:()=>splitSuiCoinAfterFeeFromSellTx,SupportedAggregator:()=>common_SupportedAggregator,NATIVE_USDC_TOKEN_TYPE:()=>NATIVE_USDC_TOKEN_TYPE,BOOSTING_PACKAGE_ID:()=>BOOSTING_PACKAGE_ID,SUI_TYPE:()=>SUI_TYPE,USDC_TOKEN_TYPE:()=>USDC_TOKEN_TYPE,isSuiCoinType:()=>isSuiCoinType,MoonbagsPackage:()=>package_MoonbagsPackage,getCoinObjectIdsByAmount:()=>getCoinObjectIdsByAmount,SUI_FULL_TYPE:()=>SUI_FULL_TYPE,getAmountAfterFee:()=>getAmountAfterFee,BLUEFIN_PACKAGE_ID:()=>BLUEFIN_PACKAGE_ID,SubscriptionModule:()=>SubscriptionModule,MathUtils:()=>package_MathUtils,CLOCK_OBJECT_ID:()=>CLOCK_OBJECT_ID,CurveModule:()=>CurveModule,MoonbagsTransaction:()=>transaction_MoonbagsTransaction,BlastFunPackage:()=>package_BlastFunPackage,CetusAggregator:()=>cetus_CetusAggregator,DEFAULT_TRADE_FEE:()=>DEFAULT_TRADE_FEE,BlastFunCustomTransaction:()=>custom_transaction_BlastFunCustomTransaction,NoodlesSdk:()=>NoodlesSdk,BoostingModule:()=>BoostingModule,getMoveObjectContent:()=>getMoveObjectContent,getSplitCoinForTx:()=>getSplitCoinForTx,BlastFunCustomCalculation:()=>custom_calculation_BlastFunCustomCalculation,SupportedBondingCurve:()=>types_SupportedBondingCurve,PAYMENT_COIN_TYPE:()=>PAYMENT_COIN_TYPE,BASE_BPS:()=>1e4,BluefinTx:()=>bluefin_BluefinTx,SUI_METADATA_OBJECT_ID:()=>SUI_METADATA_OBJECT_ID,SevenKAggregator:()=>_7k_SevenKAggregator,BlastFunConstants:()=>constants_BlastFunConstants});const sdk_ts_namespaceObject=require("@7kprotocol/sdk-ts"),transactions_namespaceObject=require("@mysten/sui/transactions"),external_bignumber_js_namespaceObject=require("bignumber.js");var external_bignumber_js_default=__webpack_require__.n(external_bignumber_js_namespaceObject);class _7k_SevenKAggregator{_config;_suiClient;constructor(e,t){this._config=e,this._suiClient=t}async getTradeRoute({coinInAmount:e,coinInType:t,coinOutType:n,tradeFee:a}){try{this._config.sevenKApiKey&&sdk_ts_namespaceObject.Config.setApiKey(this._config.sevenKApiKey);let i=a?a.tradeFeePercent:this._config.defaultTradeFee.tradeFeePercent;return await (0,sdk_ts_namespaceObject.getQuote)({tokenIn:t,tokenOut:n,amountIn:e.toString(),commissionBps:1e4*i})}catch(e){return null}}async getTransaction({walletAddress:e,completeRoute:t,slippage:n,tradeFee:a}){let i,o;a?(i=a.tradeFeePercent,o=a.tradeFeeRecipientAddress):(i=this._config.defaultTradeFee.tradeFeePercent,o=this._config.defaultTradeFee.tradeFeeRecipientAddress);let r=await (0,sdk_ts_namespaceObject.buildTx)({quoteResponse:t,slippage:n,accountAddress:e,commission:{partner:o,commissionBps:1e4*i}});return r.tx instanceof sdk_ts_namespaceObject.BluefinXTx?transactions_namespaceObject.Transaction.from(r.tx.txBytes).build({client:this._suiClient}):(r.tx.setSender(e),r.tx.build({client:this._suiClient}))}}(_7k_SevenKAggregator||(_7k_SevenKAggregator={})).toCommonTradeRoutes=function(e){let t=[];if(!e.routes||0===e.routes.length)return null;for(let n of e.routes){let e=[],a={};for(let t of n.hops){for(let e of t.pool.allTokens)a[e.address]=e.decimal;let n=a[t.tokenIn]??0,i=a[t.tokenOut]??0,o=BigInt(new(external_bignumber_js_default())(t.tokenInAmount).multipliedBy(10**n).toFixed(0,3)),r=BigInt(new(external_bignumber_js_default())(t.tokenOutAmount).multipliedBy(10**i).toFixed(0,3));e.push({poolAddress:t.poolId,coinIn:t.tokenIn,coinOut:t.tokenOut,amountIn:o,amountOut:r})}if(0===e.length)continue;let i=a[n.tokenIn]??0,o=a[n.tokenOut]??0,r=BigInt(new(external_bignumber_js_default())(n.tokenInAmount).multipliedBy(10**i).toFixed(0,3)),s=BigInt(new(external_bignumber_js_default())(n.tokenOutAmount).multipliedBy(10**o).toFixed(0,3));t.push({paths:e,coinIn:n.tokenIn,coinOut:n.tokenOut,amountIn:r,amountOut:s})}return 0===t.length?null:{coinIn:e.tokenIn,coinOut:e.tokenOut,amountIn:BigInt(e.swapAmountWithDecimal),amountOut:BigInt(e.returnAmountWithDecimal),routes:t}};const external_aftermath_ts_sdk_namespaceObject=require("aftermath-ts-sdk");class aftermath_AftermathAggregator{_config;_aftermathClient;_suiClient;constructor(e,t){this._config=e,this._suiClient=t}async aftermathClient(){if(this._aftermathClient)return this._aftermathClient;if(this._config.aftermathApiEndpoint?this._aftermathClient=new external_aftermath_ts_sdk_namespaceObject.Aftermath(this._config.aftermathApiEndpoint):this._aftermathClient=new external_aftermath_ts_sdk_namespaceObject.Aftermath("MAINNET"),await this._aftermathClient.init(),this._config.aftermathApiKey){let e=external_aftermath_ts_sdk_namespaceObject.Helpers.keypairFromPrivateKey(this._config.aftermathApiKey);await this._aftermathClient.Auth().init({async signMessageCallback({message:t}){let{signature:n}=await e.signPersonalMessage(t);return{signature:n}},walletAddress:e.toSuiAddress()})}return this._aftermathClient}async getTradeRoute({coinInAmount:e,coinInType:t,coinOutType:n,tradeFee:a}){try{let i;i=a?{recipient:a.tradeFeeRecipientAddress,feePercentage:a.tradeFeePercent}:{recipient:this._config.defaultTradeFee.tradeFeeRecipientAddress,feePercentage:this._config.defaultTradeFee.tradeFeePercent};let o=await this.aftermathClient();return await o.Router().getCompleteTradeRouteGivenAmountIn({coinInAmount:e,coinInType:t,coinOutType:n,externalFee:i})}catch(e){return null}}async getTransaction({completeRoute:e,walletAddress:t,slippage:n}){let a=await this.aftermathClient(),i=await a.Router().getTransactionForCompleteTradeRoute({completeRoute:e,walletAddress:t,slippage:n,isSponsoredTx:!1});return i.setSender(t),i.build({client:this._suiClient})}}(aftermath_AftermathAggregator||(aftermath_AftermathAggregator={})).toCommonTradeRoutes=function(e){if(0===e.routes.length)return null;let t=[];for(let n of e.routes){let e=[];for(let t of n.paths)e.push({poolAddress:t.poolId,coinIn:t.coinIn.type,coinOut:t.coinOut.type,amountIn:BigInt(t.coinIn.amount),amountOut:BigInt(t.coinOut.amount)});0!==e.length&&t.push({paths:e,coinIn:n.coinIn.type,coinOut:n.coinOut.type,amountIn:n.coinIn.amount,amountOut:n.coinOut.amount})}return 0===t.length?null:{coinIn:e.coinIn.type,coinOut:e.coinOut.type,amountIn:e.coinIn.amount,amountOut:e.coinOut.amount,routes:t}};const astros_aggregator_sdk_namespaceObject=require("@naviprotocol/astros-aggregator-sdk");function isSuiCoin(e){return"0x2::sui::SUI"===e||"0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI"===e}class astros_AstrosAggregator{_config;_suiClient;constructor(e,t){this._config=e,this._suiClient=t}async getTradeRoute({coinInAmount:e,coinInType:t,coinOutType:n,tradeFee:a}){try{let i;return i=a?{fee:a.tradeFeePercent,receiverAddress:a.tradeFeeRecipientAddress}:{fee:this._config.defaultTradeFee.tradeFeePercent,receiverAddress:this._config.defaultTradeFee.tradeFeeRecipientAddress},await (0,astros_aggregator_sdk_namespaceObject.getQuote)(t,n,e,this._config.astrosApiKey,{byAmountIn:!0,serviceFee:i})}catch(e){return null}}returnMergedCoins(e,t,n){if(t.length<2)return e.object(t[0].coinObjectId);let a=0,i=[];t.sort((e,t)=>Number(t.balance)-Number(e.balance)).slice(1).forEach(e=>{a>=n||(a+=Number(e.balance),i.push(e.coinObjectId))});let o=t[0].coinObjectId;return e.mergeCoins(o,i),e.object(o)}async getTransaction({completeRoute:e,walletAddress:t,slippage:n,tradeFee:a}){let i,o;i=a?{fee:a.tradeFeePercent,receiverAddress:a.tradeFeeRecipientAddress}:{fee:this._config.defaultTradeFee.tradeFeePercent,receiverAddress:this._config.defaultTradeFee.tradeFeeRecipientAddress};let r=new(external_bignumber_js_default())(e.amount_out).multipliedBy(1-n-i.fee).toNumber(),s=new transactions_namespaceObject.Transaction;if(isSuiCoin(e.from))o=s.splitCoins(s.gas,[s.pure.u64(e.amount_in)]);else{let n=await (0,astros_aggregator_sdk_namespaceObject.getCoins)(this._suiClient,t,e.from),a=this.returnMergedCoins(s,n.data,Number.parseFloat(e.amount_in));o=s.splitCoins(a,[s.pure.u64(e.amount_in)])}let u=await (0,astros_aggregator_sdk_namespaceObject.buildSwapPTBFromQuote)(t,s,r,o,e,void 0,!1,this._config.astrosApiKey,{serviceFee:i});return s.transferObjects([u],t),s.setSender(t),s.build({client:this._suiClient})}}(astros_AstrosAggregator||(astros_AstrosAggregator={})).toCommonTradeRoutes=function(e,t,n){if(0===e.routes.length)return null;let a=[];for(let t of e.routes){let e=[];for(let n of t.path)e.push({poolAddress:n.id,coinIn:n.from,coinOut:n.target,amountIn:BigInt(n.amount_in),amountOut:BigInt(n.amount_out)});0!==e.length&&a.push({amountIn:BigInt(t.amount_in),amountOut:BigInt(t.amount_out),coinIn:e[0].coinIn,coinOut:e[e.length-1].coinOut,paths:e})}return 0===a.length?null:{coinIn:t,coinOut:n,amountIn:BigInt(e.amount_in),amountOut:BigInt(e.amount_out),routes:a}};const aggregator_sdk_namespaceObject=require("@cetusprotocol/aggregator-sdk"),external_bn_js_namespaceObject=require("bn.js");var external_bn_js_default=__webpack_require__.n(external_bn_js_namespaceObject);(types_TradeFeeOptions||(types_TradeFeeOptions={})).equals=function(e,t){return e.tradeFeePercent===t.tradeFeePercent&&e.tradeFeeRecipientAddress===t.tradeFeeRecipientAddress};class cetus_CetusAggregator{_config;_suiClient;_cetusClient;constructor(e,t){this._config=e,this._suiClient=t}cetusClient(e,t){return t&&!types_TradeFeeOptions.equals(t,this._config.defaultTradeFee)?new aggregator_sdk_namespaceObject.AggregatorClient({client:this._suiClient,overlayFeeReceiver:t.tradeFeeRecipientAddress,overlayFeeRate:t.tradeFeePercent,env:aggregator_sdk_namespaceObject.Env.Mainnet,signer:e,...this._config.cetusApiKey&&this._config.cetusApiEndpoint?{apiKey:this._config.cetusApiKey,endpoint:this._config.cetusApiEndpoint}:{},partner:this._config.cetusPartnerId}):(this._cetusClient||(this._cetusClient=new aggregator_sdk_namespaceObject.AggregatorClient({client:this._suiClient,overlayFeeReceiver:this._config.defaultTradeFee.tradeFeeRecipientAddress,overlayFeeRate:this._config.defaultTradeFee.tradeFeePercent,env:aggregator_sdk_namespaceObject.Env.Mainnet,signer:e,...this._config.cetusApiKey&&this._config.cetusApiEndpoint?{apiKey:this._config.cetusApiKey,endpoint:this._config.cetusApiEndpoint}:{},partner:this._config.cetusPartnerId})),this._cetusClient)}async getTradeRoute({coinInAmount:e,coinInType:t,coinOutType:n,tradeFee:a}){try{let i=this.cetusClient(void 0,a);return await i.findRouters({from:t,target:n,amount:new(external_bn_js_default())(e.toString()),byAmountIn:!0})}catch(e){return null}}async getTransaction({completeRoute:e,walletAddress:t,slippage:n,tradeFee:a}){let i=new transactions_namespaceObject.Transaction,o=this.cetusClient(t,a);return await o.fastRouterSwap({router:e,txb:i,slippage:n}),await o.devInspectTransactionBlock(i),i.setSender(t),i.build({client:this._suiClient})}}(cetus_CetusAggregator||(cetus_CetusAggregator={})).toCommonTradeRoutes=function(e,t,n){if(0===e.paths.length)return null;let a=[],i=[],o=[];for(let t=0;t<e.paths.length;t++){let n=e.paths[t],a={poolAddress:n.id,amountIn:BigInt(n.amountIn),amountOut:BigInt(n.amountOut),coinIn:n.from,coinOut:n.target};if(o.push(a),t===e.paths.length-1)i.push([...o]);else{let a=e.paths[t+1];n.target!==a.from&&(i.push([...o]),o=[])}}for(let e of i)0!==e.length&&a.push({amountIn:e[0].amountIn,amountOut:e[e.length-1].amountOut,coinIn:e[0].coinIn,coinOut:e[e.length-1].coinOut,paths:e});return 0===a.length?null:{coinIn:t,coinOut:n,amountIn:BigInt(e.amountIn.toString(10)),amountOut:BigInt(e.amountOut.toString(10)),routes:a}};var common_SupportedAggregator=function(e){return e.ASTROS="ASTROS",e.AFTERMATH="AFTERMATH",e.SEVENK="7K",e.CETUS="CETUS",e.FLOWX="FLOWX",e}({});const sdk_namespaceObject=require("@flowx-finance/sdk");function getInputPercent(e){return 1e6*e}class flowx_FlowXAggregator{_config;_suiClient;constructor(e,t){this._config=e,this._suiClient=t}getCommission(e,t){let n,a;return t?(n=t.tradeFeePercent,a=t.tradeFeeRecipientAddress):(n=this._config.defaultTradeFee.tradeFeePercent,a=this._config.defaultTradeFee.tradeFeeRecipientAddress),new sdk_namespaceObject.Commission(a,new sdk_namespaceObject.Coin(e),sdk_namespaceObject.CommissionType.PERCENTAGE,getInputPercent(n),!0)}async getTradeRoute({coinInAmount:e,coinInType:t,coinOutType:n,tradeFee:a}){let i=new sdk_namespaceObject.AggregatorQuoter("mainnet",this._config.flowxApiKey);try{return await i.getRoutes({tokenIn:t,tokenOut:n,amountIn:e.toString(),commission:this.getCommission(t,a)})}catch(e){return null}}async getTransaction({walletAddress:e,completeRoute:t,slippage:n,tradeFee:a}){return new sdk_namespaceObject.TradeBuilder("mainnet",t.routes).sender(e).slippage(getInputPercent(n)).commission(this.getCommission(t.coinIn.coinType,a)).build().buildTransaction({client:this._suiClient}).then(t=>(t.setSender(e),t.build({client:this._suiClient})))}}(flowx_FlowXAggregator||(flowx_FlowXAggregator={})).toCommonTradeRoutes=function(e){if(0===e.routes.length)return null;let t=[];for(let n of e.routes){let e=[];for(let t of n.paths)e.push({amountIn:BigInt(t.amountIn.toString()),amountOut:BigInt(t.amountOut.toString()),coinIn:t.input.coinType,coinOut:t.output.coinType,poolAddress:t.pool.id});0!==e.length&&t.push({amountIn:BigInt(n.amountIn.toString()),amountOut:BigInt(n.amountOut.toString()),coinIn:n.input.coinType,coinOut:n.output.coinType,paths:e})}return 0===t.length?null:{coinIn:e.coinIn.coinType,coinOut:e.coinOut.coinType,amountIn:BigInt(e.amountIn.toString()),amountOut:BigInt(e.amountOut.toString()),routes:t}},function(e){e.PACKAGE_ID_V4="0x7e6aa6e179466ab2814425a780b122575296d011119fa69d27f289f5a28814bd",e.MEMEZ_AV_OBJECT_ID="0x2319e3e76dfad73d8f4684bdbf42be4f32d8ce4521dd61becc8261dc918d82c0"}(constants_BlastFunConstants||(constants_BlastFunConstants={}));const tiny_invariant_namespaceObject=require("@minswap/tiny-invariant");var tiny_invariant_default=__webpack_require__.n(tiny_invariant_namespaceObject);async function getMoveObjectContent(e,t){return(await getMoveObject(e,t)).fields}async function getMoveObject(e,t){let n=await e.getObject({id:t,options:{showContent:!0}}),a=n.data?.content;return tiny_invariant_default()(a,"Pool object not found or has no content"),tiny_invariant_default()("moveObject"===a.dataType,"Object is not a Move object"),a}const BASE_BPS=1e4;function getSplitCoinsAfterFee(e,t){let n=BigInt(e),a=BigInt(1e4*Number(t));if(a===BigInt(0))return[n.toString()];let i=n*a/BigInt(1e4);return[(n-i).toString(),i.toString()]}function getAmountAfterFee(e,t){if(!t||0>=Number(t))return BigInt(e);let n=BigInt(e),a=BigInt(1e4*Number(t));if(a===BigInt(0))return n;let i=n*a/BigInt(1e4);return n-i}async function getNeededGasFee(e,t,n,a){let{effects:{gasUsed:i,status:o}}=await e.devInspectTransactionBlock({sender:n,transactionBlock:t});if("success"!==o.status)throw Error(`Transaction failed during dev inspect: ${o.error??""}`);let r=BigInt(i.computationCost)+BigInt(i.storageCost)-BigInt(i.storageRebate),s=BigInt(1e4*Number(a));return r*(BigInt(1e4)+s)/BigInt(1e4)}!function(e){(e.U64||(e.U64={})).mulDivUp=function(e,t,n){let a=BigInt(0);return e*t%n>BigInt(0)&&(a=BigInt(1)),e*t/n+a}}(package_MathUtils||(package_MathUtils={})),function(e){function t(e){return tiny_invariant_default()(BigInt(e)<=BigInt(1e4),"Bps overflow"),BigInt(e)}e.calcUp=function(e,t){let n,a=BigInt(e.pos0),i=BigInt(1e4);return n=a*t%i!==BigInt(0)?BigInt(1):BigInt(0),a*t/i+n},e.sub=function(e,t){return tiny_invariant_default()(BigInt(e.pos0)>=BigInt(t.pos0),"Bps underflow"),{pos0:(BigInt(e.pos0)-BigInt(t.pos0)).toString()}},e.value=function(e){return BigInt(e.pos0)},e.new_=function(e){return{pos0:t(e).toString()}},e.assertOverflow=t}(package_Bps||(package_Bps={})),function(e){var t,n;(e.MemezFun||(e.MemezFun={})).isSniperProtectedMemezFun=async function(e,t){return(await getMoveObjectContent(e,t)).public_key.length>0},(t=e.MemezFees||(e.MemezFees={})).takeWithDiscount=function(e,t,n){if("Value"===e.variant){let n=BigInt(e.fields.pos0);if(n===BigInt(0))return BigInt(0);if(t>=n)return n;throw Error(`Insufficient amount to cover fee. Required: ${n}, provided: ${t}`)}if("Percentage"===e.variant){let a=e.fields.pos0.fields;if(BigInt(a.pos0)===BigInt(0))return BigInt(0);let i=package_Bps.calcUp(package_Bps.sub(a,n),t);if(t>=i)return i;throw Error(`Insufficient amount to cover fee. Required: ${i}, provided: ${t}`)}throw Error("Unknown fee variant")},t.calculateWithDiscount=function(e,t,n){if("Value"===e.variant)return BigInt(e.fields.pos0);if("Percentage"===e.variant){let a=e.fields.pos0.fields;return package_Bps.calcUp(package_Bps.sub(a,t),n)}throw Error("Unknown fee variant")},(e.MemezBurner||(e.MemezBurner={})).calculate=function(e,t){if(package_Bps.value(e.fee.fields)===BigInt(0)||t===BigInt(0)||t>=BigInt(e.target_liquidity))return package_Bps.new_(0);let n=BigInt(1e4);return package_Bps.new_(package_MathUtils.U64.mulDivUp(package_Bps.value(e.fee.fields),package_MathUtils.U64.mulDivUp(t,n,BigInt(e.target_liquidity)),n))},(n=e.MemezPump||(e.MemezPump={})).getPumpState=async function(e,t){return await getMoveObjectContent(e,t.inner_state)},n.pump=function(t,n){let a=t.constant_product.fields,i=e.MemezFees.takeWithDiscount(a.quote_swap_fee,n,a.quote_referrer_fee.fields),o=n-i,r=BigInt(a.meme_balance),s=BigInt(a.quote_balance),u=r*o/(BigInt(a.virtual_liquidity)+s+o),c=e.MemezFees.takeWithDiscount(a.meme_swap_fee,u,a.meme_referrer_fee.fields);return u-c},n.dump=function(t,n){let a=t.constant_product.fields,i=e.MemezFees.takeWithDiscount(a.meme_swap_fee,n,a.meme_referrer_fee.fields),o=n-i,r=BigInt(a.meme_balance),s=BigInt(a.quote_balance),u=BigInt(a.virtual_liquidity),c=e.MemezBurner.calculate(a.burner.fields,s),_=package_Bps.calcUp(c,o),l=o-(package_Bps.value(c)!==BigInt(0)?_:BigInt(0)),d=(u+s)*l/(r+l);d>s&&(d=s);let g=e.MemezFees.takeWithDiscount(a.quote_swap_fee,d,a.quote_referrer_fee.fields);return d-g}}(package_BlastFunPackage||(package_BlastFunPackage={})),function(e){e.getCurveAmountAfterBuy=async function(e,t){let{suiAmount:n,poolId:a,frontendFee:i}=e,o=await getMoveObjectContent(t,a),r=await package_BlastFunPackage.MemezPump.getPumpState(t,o);return n=getAmountAfterFee(n,i),package_BlastFunPackage.MemezPump.pump(r,n)},e.getSuiAmountAfterSell=async function(e,t){let{curveAmount:n,poolId:a,frontendFee:i}=e,o=await getMoveObjectContent(t,a),r=await package_BlastFunPackage.MemezPump.getPumpState(t,o);return getAmountAfterFee(package_BlastFunPackage.MemezPump.dump(r,n),i)}}(custom_calculation_BlastFunCustomCalculation||(custom_calculation_BlastFunCustomCalculation={}));const SUI_TYPE="0x2::sui::SUI",SUI_FULL_TYPE="0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI",USDC_TOKEN_TYPE="0x5d4b302506645c37ff133b98c4b50a5ae14841659738d6d733d59d0d217a93bf::coin::COIN",NATIVE_USDC_TOKEN_TYPE="0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC",SUI_METADATA_OBJECT_ID="0x9258181f5ceac8dbffb7030890243caed69a9599d2886d957a9cb7656af3bdb3",CLOCK_OBJECT_ID="0x0000000000000000000000000000000000000000000000000000000000000006";function isSuiCoinType(e){return e===SUI_TYPE||e===SUI_FULL_TYPE}const utils_namespaceObject=require("@mysten/sui/utils"),orderByKey=(e,t,n)=>{let a;if(e?.length){do{a=!1;for(let i=0;i<e.length-1;i++){let o=BigInt(e[i][t]),r=BigInt(e[i+1][t]);if("desc"===n?o<r:o>r){let t=e[i];e[i]=e[i+1],e[i+1]=t,a=!0}}}while(a);return e}},getCoinObjectIdsByAmount=async(e,t,n,a)=>{let i,o=[],r=!0;for(;r;)try{let n=await e.getCoins({owner:t,coinType:a,cursor:i});o=[...o,...n.data],r=n.hasNextPage,i=n.nextCursor}catch(e){console.error("Error fetching data:",e),r=!1}let s=orderByKey(o.map(e=>({...e,balance:e.balance})),"balance","desc")??[],u="0",c=[],_=[];for(let e of s)if(u=(BigInt(e.balance)+BigInt(u)).toString(10),c.push(e.coinObjectId),_.push(e),BigInt(u)>=BigInt(n))break;return{objectIds:c,balance:u,objectCoins:_}};async function getSplitCoinForTx(e,t){let{account:n,amount:a,splits:i,coinType:o,inheritTx:r,inspecTransaction:s,isSponsored:u=!1}=e,c=r??new transactions_namespaceObject.Transaction,{objectIds:_}=await getCoinObjectIdsByAmount(t,n,a,o),l=_[0];if((0,utils_namespaceObject.normalizeStructTag)(o)===(0,utils_namespaceObject.normalizeStructTag)(SUI_FULL_TYPE)&&!u){let e;return s?(_.length>1&&c.mergeCoins(c.object(l),_.slice(1).map(e=>c.object(e))),e=c.splitCoins(c.object(l),i)):e=c.splitCoins(c.gas,i),{tx:c,coinData:e}}_.length>1&&c.mergeCoins(c.object(l),_.slice(1).map(e=>c.object(e)));let d=c.splitCoins(c.object(l),i);return{tx:c,coinData:d}}const BLUEFIN_PACKAGE_ID="0x62412b7268c35f3808336aee57a52836501f40b8ba5d936f8ad275e672befd04";async function splitSuiCoinAfterFeeFromBuyTx(e,t){let n,a,{inputAmount:i,accountAddress:o,frontendFee:r,frontendFeeRecipient:s,extendTx:u,isSponsored:c}=e;tiny_invariant_default()(e.inCoinType===SUI_FULL_TYPE||e.inCoinType===SUI_TYPE,"Input must be SUI");let{tx:_,coinIn:l}=u||{},d=getSplitCoinsAfterFee(i,r||"0"),g=_||new transactions_namespaceObject.Transaction;if(l)n=g.splitCoins(l,d),bluefin_BluefinTx.transferOrDestroyZeroCoin(g,SUI_FULL_TYPE,l,o);else{let{coinData:e}=await getSplitCoinForTx({account:o,amount:i,splits:d,coinType:SUI_FULL_TYPE,inheritTx:g,isSponsored:c||!1},t);n=e}if(r&&s){let[e,t]=n;a=e,g.transferObjects([t],g.pure.address(s||o))}else[a]=n;return{tx:g,coinOut:a}}async function splitSuiCoinAfterFeeFromSellTx(e,t,n){if(tiny_invariant_default()(t.outCoinType===SUI_FULL_TYPE||t.outCoinType===SUI_TYPE,"Output must be SUI"),0>=Number(t.frontendFee||0))return{tx:e,coinOut:n};let a=e.moveCall({target:"0x2::coin::value",typeArguments:[t.outCoinType],arguments:[n]}),i=e.moveCall({target:`${BLUEFIN_PACKAGE_ID}::math::mul_div_u64`,typeArguments:[],arguments:[a,e.pure.u64(BigInt(1e4*Number(t.frontendFee||"0"))),e.pure.u64(BigInt(1e4))]}),o=e.moveCall({target:"0x2::coin::split",typeArguments:[t.outCoinType],arguments:[n,i]});return e.transferObjects([o],e.pure.address(t.frontendFeeRecipient||t.accountAddress)),{tx:e,coinOut:n}}(bluefin_BluefinTx||(bluefin_BluefinTx={})).transferOrDestroyZeroCoin=function(e,t,n,a){e.moveCall({target:`${BLUEFIN_PACKAGE_ID}::utils::transfer_or_destroy`,typeArguments:[t],arguments:[n,e.pure.address(a)]})},function(e){async function t(e){let t=e||new transactions_namespaceObject.Transaction;return t.moveCall({target:`${constants_BlastFunConstants.PACKAGE_ID_V4}::memez_allowed_versions::get_allowed_versions`,arguments:[t.object(constants_BlastFunConstants.MEMEZ_AV_OBJECT_ID)],typeArguments:[]})}e.getAllowedVersions=t,e.buildBuyTx=async function(e,n){tiny_invariant_default()(!await package_BlastFunPackage.MemezFun.isSniperProtectedMemezFun(n,e.poolId),"This coin is a sniper protected coin, please use the Blast Fun website to trade it.");let{tx:a,coinOut:i}=await splitSuiCoinAfterFeeFromBuyTx(e,n);tiny_invariant_default()(i,"Coin out is required");let o=a.moveCall({target:`${constants_BlastFunConstants.PACKAGE_ID_V4}::memez_pump::pump`,typeArguments:[e.outCoinType,SUI_FULL_TYPE],arguments:[a.object(e.poolId),i,a.pure.vector("address",[]),a.pure.vector("vector<u8>",[]),a.pure.u64(e.minAmountOut),await t(a)]});return{tx:a,coinOut:o}},e.buildSellTx=async function(e,n){tiny_invariant_default()(e.outCoinType===SUI_FULL_TYPE||e.outCoinType===SUI_TYPE,"Output must be SUI");let a=await getMoveObjectContent(n,e.poolId),{tx:i,coinData:o}=await getSplitCoinForTx({amount:e.inputAmount,coinType:e.inCoinType,inheritTx:e.extendTx?.tx,account:e.accountAddress,splits:[e.inputAmount]},n),[r]=o,[s]=i.moveCall({target:`${constants_BlastFunConstants.PACKAGE_ID_V4}::memez_pump::dump`,typeArguments:[e.inCoinType,e.outCoinType],arguments:[i.object(e.poolId),i.object(a.ipx_meme_coin_treasury),r,i.pure.vector("address",[]),i.pure.u64(e.minAmountOut),await t(i)]});return await splitSuiCoinAfterFeeFromSellTx(i,e,s)}}(custom_transaction_BlastFunCustomTransaction||(custom_transaction_BlastFunCustomTransaction={}));const memez_fun_sdk_namespaceObject=require("@interest-protocol/memez-fun-sdk"),sui_core_sdk_namespaceObject=require("@interest-protocol/sui-core-sdk"),client_namespaceObject=require("@mysten/sui/client"),payload={network:sui_core_sdk_namespaceObject.Network.MAINNET,fullNodeUrl:(0,client_namespaceObject.getFullnodeUrl)("mainnet")},memezPump=new memez_fun_sdk_namespaceObject.MemezPumpSDK(payload);function getMemezPumpSDK(){return memezPump}async function addGasFee(e,t){let{inheritTx:n,sender:a,feeAmount:i,suiInputAmount:o}=e,r=n||new transactions_namespaceObject.Transaction;r.setGasBudget(i);let{objectCoins:s}=await getCoinObjectIdsByAmount(t,a,(BigInt(o||"0")+i).toString(),SUI_FULL_TYPE);return r.setGasPayment(s.map(e=>({objectId:e.coinObjectId,version:e.version,digest:e.digest}))),r}!function(e){e.getCurveAmountAfterBuy=async function(e){let{suiAmount:t,poolId:n,frontendFee:a}=e;t=getAmountAfterFee(t,a);let{memeAmountOut:i}=await getMemezPumpSDK().quotePump({pool:n,amount:t});return i},e.getSuiAmountAfterSell=async function(e){let{curveAmount:t,poolId:n,frontendFee:a}=e,{quoteAmountOut:i}=await getMemezPumpSDK().quoteDump({pool:n,amount:t});return getAmountAfterFee(i,a)}}(sdk_calculation_BlastFunSDKCalculation||(sdk_calculation_BlastFunSDKCalculation={})),function(e){async function t(e,t){let{tx:n,coinOut:a}=await splitSuiCoinAfterFeeFromBuyTx(e,t);tiny_invariant_default()(a,"Coin out is required");let{memeCoin:i,tx:o}=await getMemezPumpSDK().pump({pool:e.poolId,quoteCoin:a,minAmountOut:e.minAmountOut,tx:n});return{tx:o,coinOut:i}}async function n(e,t){tiny_invariant_default()(isSuiCoinType(e.outCoinType),"Output must be SUI");let{tx:n,coinData:a}=await getSplitCoinForTx({amount:e.inputAmount,coinType:e.inCoinType,inheritTx:e.extendTx?.tx,account:e.accountAddress,splits:[e.inputAmount]},t),[i]=a,{quoteCoin:o,tx:r}=await getMemezPumpSDK().dump({pool:e.poolId,memeCoin:i,tx:n,minAmountOut:e.minAmountOut});return await splitSuiCoinAfterFeeFromSellTx(r,e,o)}e.buildBuyTx=t,e.buildSellTx=n,e.getBuyTransaction=async function({coinInAmount:e,coinInType:n,coinOutType:a,poolId:i,slippage:o,walletAddress:r,tradeFee:s},u){tiny_invariant_default()(isSuiCoinType(n),"coinInType must be SUI for buy transaction"),tiny_invariant_default()(a!==n,"coinOutType must be different from coinInType"),tiny_invariant_default()(o>=0&&o<1,"slippage must be between 0 (inclusive) and 1 (exclusive)"),tiny_invariant_default()(e>0,"coinInAmount must be greater than 0");let c=await sdk_calculation_BlastFunSDKCalculation.getCurveAmountAfterBuy({poolId:i,suiAmount:e,frontendFee:s?s.tradeFeePercent:void 0}),_=BigInt(new(external_bignumber_js_default())(c.toString()).multipliedBy(1-o).toFixed(0,3)),{tx:l,coinOut:d}=await t({accountAddress:r,inCoinType:n,outCoinType:a,inputAmount:e.toString(),minAmountOut:_.toString(),poolId:i,frontendFee:s?s.tradeFeePercent:void 0,frontendFeeRecipient:s?s.tradeFeeRecipientAddress:void 0,extendTx:void 0,isSponsored:!1},u);tiny_invariant_default()(d,"Coin out is required"),l.transferObjects([d],l.pure.address(r)),l.setSender(r);let g=await getNeededGasFee(u,l,r,0);return(l=await addGasFee({inheritTx:l,sender:r,feeAmount:g,suiInputAmount:e},u)).build({client:u})},e.getSellTransaction=async function({coinInAmount:e,coinInType:t,coinOutType:a,poolId:i,slippage:o,walletAddress:r,tradeFee:s},u){tiny_invariant_default()(isSuiCoinType(a),"coinOutType must be SUI for sell transaction"),tiny_invariant_default()(a!==t,"coinOutType must be different from coinInType"),tiny_invariant_default()(o>=0&&o<1,"slippage must be between 0 (inclusive) and 1 (exclusive)"),tiny_invariant_default()(e>0,"coinInAmount must be greater than 0");let c=await sdk_calculation_BlastFunSDKCalculation.getSuiAmountAfterSell({poolId:i,curveAmount:e,frontendFee:s?s.tradeFeePercent:void 0}),_=BigInt(new(external_bignumber_js_default())(c.toString()).multipliedBy(1-o).toFixed(0,3)),{tx:l,coinOut:d}=await n({accountAddress:r,inCoinType:t,outCoinType:a,inputAmount:e.toString(),minAmountOut:_.toString(),poolId:i,frontendFee:s?s.tradeFeePercent:void 0,frontendFeeRecipient:s?s.tradeFeeRecipientAddress:void 0,extendTx:void 0,isSponsored:!1},u);tiny_invariant_default()(d,"Coin out is required"),l.transferObjects([d],l.pure.address(r)),l.setSender(r);let g=await getNeededGasFee(u,l,r,0);return(l=await addGasFee({inheritTx:l,sender:r,feeAmount:g},u)).build({client:u})}}(sdk_transaction_BlastFunSDKTransaction||(sdk_transaction_BlastFunSDKTransaction={}));var types_SupportedBondingCurve=function(e){return e.BLAST_FUN="BLAST_FUN",e.MOONBAGS="MOONBAGS",e}({});function adaptSuiClient(e){return e}function adaptTransaction(e){return e}function createCompatibleSuiClient(e){return new Proxy(e,{get(e,t){let n=e[t];return"function"==typeof n?n.bind(e):n}})}!function(e){e.PACKAGE_ID="0xb8df325010942634a4afb3db3901ee215546af43a4ec4af781e7213b0bba7290",e.CONFIG_OBJECT_ID="0x74aecf86067c6913960ba4925333aefd2b1f929cafca7e21fd55a8f244b70499",e.LOCK_CONFIG_OBJECT_ID="0xfb09822d9808980abd04c51321adb850701f5f55535c6206658ef4d910c3e9be",e.BURN_MANAGER_OBJECT_ID="0x1d94aa32518d0cb00f9de6ed60d450c9a2090761f326752ffad06b2e9404f845",e.POOLS_OBJECT_ID="0xf699e7f2276f5c9a75944b37a0c5b5d9ddfd2471bf6242483b03ab2887d198d0",e.GLOBAL_CONFIG_OBJECT_ID="0xdaa46292632c3c4d8f31f23ea0f9b36a28ff3677e9684980e4438403a67a3d8f",e.FEE_DENOMINATOR=BigInt(1e4)}(constants_MoonbagsConstants||(constants_MoonbagsConstants={})),function(e){var t,n;(t=e.Curves||(e.Curves={})).calculateAddLiquidityCost=function(e,t,n){return e*t/(t-n)-e},t.calculateRemoveLiquidityReturn=function(e,t,n){return t-e*t/(e+n)},t.calculateTokenAmountReceived=function(e,t,n){return t-e*t/(e+n)},(n=e.Moonbags||(e.Moonbags={})).getDynamicVirtualTokenReserves=async function(e,t){let n=await e.getDynamicFieldObject({parentId:t,name:{type:"vector<u8>",value:"virtual_token_reserves"}});if(n.data)return BigInt(n.data.content.fields.value)},n.buyExactInReturnsWithLock=function(t){let{inputAmount:n,amountIn:a,pool:i,config:o,dynamicVirtualTokenReserves:r}=t,s=BigInt(i.virtual_sui_reserves),u=BigInt(i.virtual_token_reserves),c=BigInt(i.remain_token_reserves.fields.balance),_=e.Curves.calculateRemoveLiquidityReturn(s,u,a),l=u-(r||c),d=_,g=a;_>l&&(d=l,g=e.Curves.calculateAddLiquidityCost(s,u,l)+BigInt(1));let p=g*BigInt(o.platform_fee)/constants_MoonbagsConstants.FEE_DENOMINATOR;return tiny_invariant_default()(n>=g+p,"Input amount is less than used SUI + fee"),{receivedCurve:d,receivedSui:n-g-p}},n.sellReturns=function(t){let{amountIn:n,pool:a,config:i}=t,o=BigInt(a.virtual_sui_reserves),r=BigInt(a.virtual_token_reserves),s=BigInt(a.real_sui_reserves.fields.balance),u=e.Curves.calculateRemoveLiquidityReturn(r,o,n);u>s&&(u=s);let c=u*BigInt(i.platform_fee)/constants_MoonbagsConstants.FEE_DENOMINATOR,_=u-c;return{receivedCurve:BigInt(0),receivedSui:_}}}(package_MoonbagsPackage||(package_MoonbagsPackage={})),function(e){e.getCurveAmountAfterBuy=async function(e,t){let{suiAmount:n,poolId:a,frontendFee:i}=e,[o,r,s]=await Promise.all([getMoveObjectContent(t,a),getMoveObjectContent(t,constants_MoonbagsConstants.CONFIG_OBJECT_ID),package_MoonbagsPackage.Moonbags.getDynamicVirtualTokenReserves(t,a)]);void 0!==i&&(n=getAmountAfterFee(n,i));let u=n*constants_MoonbagsConstants.FEE_DENOMINATOR/(constants_MoonbagsConstants.FEE_DENOMINATOR+BigInt(r.platform_fee)),{receivedCurve:c}=package_MoonbagsPackage.Moonbags.buyExactInReturnsWithLock({inputAmount:n,amountIn:u,pool:o,config:r,dynamicVirtualTokenReserves:s});return c},e.getSuiAmountAfterSell=async function(e,t){let{curveAmount:n,poolId:a,frontendFee:i}=e,[o,r]=await Promise.all([getMoveObjectContent(t,a),getMoveObjectContent(t,constants_MoonbagsConstants.CONFIG_OBJECT_ID)]),{receivedSui:s}=package_MoonbagsPackage.Moonbags.sellReturns({amountIn:n,pool:o,config:r});return void 0!==i?getAmountAfterFee(s,i):s},e.getUsedSuiForTx=async function(e,t){let{suiAmount:n,frontendFee:a}=e,i=await getMoveObjectContent(t,constants_MoonbagsConstants.CONFIG_OBJECT_ID);return void 0!==a&&(n=getAmountAfterFee(n,a)),n*constants_MoonbagsConstants.FEE_DENOMINATOR/(constants_MoonbagsConstants.FEE_DENOMINATOR+BigInt(i.platform_fee))}}(calculation_MoonbagsCalculation||(calculation_MoonbagsCalculation={})),function(e){async function t(e,t){let{tx:n,coinOut:a}=await splitSuiCoinAfterFeeFromBuyTx(e,t);tiny_invariant_default()(a,"Coin out is required");let i=await calculation_MoonbagsCalculation.getUsedSuiForTx({suiAmount:BigInt(e.inputAmount),frontendFee:e.frontendFee},t),[o,r]=n.moveCall({target:`${constants_MoonbagsConstants.PACKAGE_ID}::moonbags::buy_exact_in_returns_with_lock`,typeArguments:[e.outCoinType],arguments:[n.object(constants_MoonbagsConstants.CONFIG_OBJECT_ID),n.object(constants_MoonbagsConstants.LOCK_CONFIG_OBJECT_ID),a,n.pure.u64(i),n.pure.u64(e.minAmountOut),n.object(constants_MoonbagsConstants.BURN_MANAGER_OBJECT_ID),n.object(constants_MoonbagsConstants.POOLS_OBJECT_ID),n.object(constants_MoonbagsConstants.GLOBAL_CONFIG_OBJECT_ID),n.object(SUI_METADATA_OBJECT_ID),n.object(CLOCK_OBJECT_ID)]});return bluefin_BluefinTx.transferOrDestroyZeroCoin(n,SUI_FULL_TYPE,o,e.accountAddress),{tx:n,coinOut:r}}async function n(e,t){tiny_invariant_default()(isSuiCoinType(e.outCoinType),"Output must be SUI");let{tx:n,coinData:a}=await getSplitCoinForTx({amount:e.inputAmount,coinType:e.inCoinType,inheritTx:e.extendTx?.tx,account:e.accountAddress,splits:[e.inputAmount]},t),[i]=a,[o,r]=n.moveCall({target:`${constants_MoonbagsConstants.PACKAGE_ID}::moonbags::sell_returns`,typeArguments:[e.inCoinType],arguments:[n.object(constants_MoonbagsConstants.CONFIG_OBJECT_ID),i,n.pure.u64(e.minAmountOut),n.object(CLOCK_OBJECT_ID)]});return bluefin_BluefinTx.transferOrDestroyZeroCoin(n,e.inCoinType,r,e.accountAddress),await splitSuiCoinAfterFeeFromSellTx(n,e,o)}e.buildBuyTx=t,e.buildSellTx=n,e.getBuyTransaction=async function({coinInAmount:e,coinInType:n,coinOutType:a,poolId:i,slippage:o,walletAddress:r,tradeFee:s},u){tiny_invariant_default()(isSuiCoinType(n),"coinInType must be SUI for buy transaction"),tiny_invariant_default()(a!==n,"coinOutType must be different from coinInType"),tiny_invariant_default()(o>=0&&o<1,"slippage must be between 0 (inclusive) and 1 (exclusive)"),tiny_invariant_default()(e>0,"coinInAmount must be greater than 0");let c=await calculation_MoonbagsCalculation.getCurveAmountAfterBuy({poolId:i,suiAmount:e,frontendFee:s?s.tradeFeePercent:void 0},u),_=BigInt(new(external_bignumber_js_default())(c.toString()).multipliedBy(1-o).toFixed(0,3)),{tx:l,coinOut:d}=await t({accountAddress:r,inCoinType:n,outCoinType:a,inputAmount:e.toString(),minAmountOut:_.toString(),poolId:i,frontendFee:s?s.tradeFeePercent:void 0,frontendFeeRecipient:s?s.tradeFeeRecipientAddress:void 0,extendTx:void 0,isSponsored:!1},u);tiny_invariant_default()(d,"Coin out is required"),l.transferObjects([d],l.pure.address(r)),l.setSender(r);let g=await getNeededGasFee(u,l,r,0);return(l=await addGasFee({inheritTx:l,sender:r,feeAmount:g,suiInputAmount:e},u)).build({client:u})},e.getSellTransaction=async function({coinInAmount:e,coinInType:t,coinOutType:a,poolId:i,slippage:o,walletAddress:r,tradeFee:s},u){tiny_invariant_default()(isSuiCoinType(a),"coinOutType must be SUI for sell transaction"),tiny_invariant_default()(a!==t,"coinOutType must be different from coinInType"),tiny_invariant_default()(o>=0&&o<1,"slippage must be between 0 (inclusive) and 1 (exclusive)"),tiny_invariant_default()(e>0,"coinInAmount must be greater than 0");let c=await calculation_MoonbagsCalculation.getSuiAmountAfterSell({poolId:i,curveAmount:e,frontendFee:s?s.tradeFeePercent:void 0},u),_=BigInt(new(external_bignumber_js_default())(c.toString()).multipliedBy(1-o).toFixed(0,3)),{tx:l,coinOut:d}=await n({accountAddress:r,inCoinType:t,outCoinType:a,inputAmount:e.toString(),minAmountOut:_.toString(),poolId:i,frontendFee:s?s.tradeFeePercent:void 0,frontendFeeRecipient:s?s.tradeFeeRecipientAddress:void 0,extendTx:void 0,isSponsored:!1},u);tiny_invariant_default()(d,"Coin out is required"),l.transferObjects([d],l.pure.address(r)),l.setSender(r);let g=await getNeededGasFee(u,l,r,0);return(l=await addGasFee({inheritTx:l,sender:r,feeAmount:g},u)).build({client:u})}}(transaction_MoonbagsTransaction||(transaction_MoonbagsTransaction={}));class AggregatorModule{sdk;_astrosAggregator;_aftermathAggregator;_sevenkAggregator;_cetusAggregator;_flowXAggregator;constructor(e){this.sdk=e,this._astrosAggregator=new astros_AstrosAggregator({defaultTradeFee:e.options.tradeFee,astrosApiKey:e.options.astrosApiKey},e.suiClient),this._aftermathAggregator=new aftermath_AftermathAggregator({defaultTradeFee:e.options.tradeFee,aftermathApiKey:e.options.aftermathApiKey,aftermathApiEndpoint:e.options.aftermathApiEndpoint},e.suiClient),this._sevenkAggregator=new _7k_SevenKAggregator({defaultTradeFee:e.options.tradeFee,sevenKApiKey:e.options.sevenKApiKey},e.suiClient),this._cetusAggregator=new cetus_CetusAggregator({defaultTradeFee:e.options.tradeFee,cetusApiKey:e.options.cetusApiKey,cetusApiEndpoint:e.options.cetusApiEndpoint,cetusPartnerId:e.options.cetusPartnerId},e.suiClient),this._flowXAggregator=new flowx_FlowXAggregator({defaultTradeFee:e.options.tradeFee,flowxApiKey:e.options.flowxApiKey},e.suiClient)}get astrosAggregator(){return this._astrosAggregator}get aftermathAggregator(){return this._aftermathAggregator}get sevenkAggregator(){return this._sevenkAggregator}get cetusAggregator(){return this._cetusAggregator}get flowXAggregator(){return this._flowXAggregator}async getTradeRoute(e,t){let n;switch(e){case common_SupportedAggregator.ASTROS:{let e,a=await this._astrosAggregator.getTradeRoute(t);if(!a)return null;let i=astros_AstrosAggregator.toCommonTradeRoutes(a,t.coinInType,t.coinOutType);if(!i)return null;e=t.tradeFee?t.tradeFee.tradeFeePercent:this.sdk.options.tradeFee.tradeFeePercent,i.amountOut=BigInt(new(external_bignumber_js_default())(a.amount_out).multipliedBy(1-e).toFixed(0,3)),n={route:i,aggregatorRoute:a};break}case common_SupportedAggregator.AFTERMATH:{let e=await this._aftermathAggregator.getTradeRoute(t);if(!e)return null;let a=aftermath_AftermathAggregator.toCommonTradeRoutes(e);if(!a)return null;n={route:a,aggregatorRoute:e};break}case common_SupportedAggregator.SEVENK:{let e=await this._sevenkAggregator.getTradeRoute(t);if(!e)return null;let a=_7k_SevenKAggregator.toCommonTradeRoutes(e);if(!a)return null;n={route:a,aggregatorRoute:e};break}case common_SupportedAggregator.CETUS:{let e=await this._cetusAggregator.getTradeRoute(t);if(!e)return null;let a=cetus_CetusAggregator.toCommonTradeRoutes(e,t.coinInType,t.coinOutType);if(!a)return null;n={route:a,aggregatorRoute:e};break}case common_SupportedAggregator.FLOWX:{let e=await this._flowXAggregator.getTradeRoute(t);if(!e)return null;let a=flowx_FlowXAggregator.toCommonTradeRoutes(e);if(!a)return null;n={route:a,aggregatorRoute:e}}}return n}async getTransactionByRoute(e,t){switch(e){case common_SupportedAggregator.ASTROS:return this._astrosAggregator.getTransaction({walletAddress:t.walletAddress,completeRoute:t.completeRoute,slippage:t.slippage,tradeFee:t.tradeFee});case common_SupportedAggregator.AFTERMATH:return this._aftermathAggregator.getTransaction({walletAddress:t.walletAddress,completeRoute:t.completeRoute,slippage:t.slippage});case common_SupportedAggregator.SEVENK:return this._sevenkAggregator.getTransaction({walletAddress:t.walletAddress,completeRoute:t.completeRoute,slippage:t.slippage,tradeFee:t.tradeFee});case common_SupportedAggregator.CETUS:return this._cetusAggregator.getTransaction({walletAddress:t.walletAddress,completeRoute:t.completeRoute,slippage:t.slippage,tradeFee:t.tradeFee});case common_SupportedAggregator.FLOWX:return this._flowXAggregator.getTransaction({walletAddress:t.walletAddress,completeRoute:t.completeRoute,slippage:t.slippage,tradeFee:t.tradeFee})}}async getTradeTransaction(e,t){let n=await this.getTradeRoute(e,{coinInAmount:t.coinInAmount,coinInType:t.coinInType,coinOutType:t.coinOutType,tradeFee:t.tradeFee});if(!n)return null;let a=await this.getTransactionByRoute(e,{walletAddress:t.walletAddress,completeRoute:n.aggregatorRoute,slippage:t.slippage,tradeFee:t.tradeFee});return{route:n.route,aggregatorRoute:n.aggregatorRoute,transaction:a}}async getTradeTransactionWithBestRate(e){let t=Object.keys(common_SupportedAggregator),n=await Promise.all(t.map(async t=>{try{return await this.getTradeRoute(t,e)}catch{return null}})),a=null,i=null;for(let e=0;e<n.length;e++){let o=n[e],r=t[e];if(o&&(!a||o.route.amountOut>a.route.amountOut)){a=o,i=r;continue}}if(!a||!i)return null;let o=await this.getTransactionByRoute(i,{walletAddress:e.walletAddress,completeRoute:a.aggregatorRoute,slippage:e.slippage,tradeFee:e.tradeFee});return{route:a.route,aggregatorRoute:a.aggregatorRoute,transaction:o}}async getAmountOut(e,t){let n=await this.getTradeRoute(e,t);return n?n.route.amountOut:null}async getBestAmountOut(e){let t=Object.keys(common_SupportedAggregator),n=null,a=null;for(let i of t){let t=await this.getAmountOut(i,e);null!==t&&(null===n||t>n)&&(n=t,a=i)}return null===n||null===a?null:{amountOut:n,aggregator:a}}}const BOOSTING_PACKAGE_ID="0x25fa0eb553dd69fa6a8028f73a38f1df7f289fa88a58ed3d7dc5a5360155bb19",CONFIG_ID="0x8b1a8ac6e34688cd8f8f8e5fefa9d5fb9e1ff74d2f132f8e208ae5ac9cc530bb",ADMIN_CAP_ID="0x13d101f44a0710a5475bec5f492a87b80e03d92d1cf540f26096f65850b23d26";class BoostingModule{sdk;constructor(e){this.sdk=e}async getConfig(){let e=await this.sdk.suiClient.getObject({id:CONFIG_ID,options:{showContent:!0}});tiny_invariant_default()(e.data?.content,"Config object not found or has no content"),tiny_invariant_default()(e.data?.content.dataType==="moveObject","Config object is not a Move object");let t=e.data.content.fields,n=t.id.id,a=t.fee_receiver,i=t.tiers.fields.contents,o={};for(let e of i){let t=e.fields.key,n=e.fields.value.fields.duration,a=e.fields.value.fields.amount,i=e.fields.value.fields.point,r=e.fields.value.fields.original_amount;o[t]={duration:BigInt(n),amount:BigInt(a),point:BigInt(i),originalAmount:BigInt(r)}}return{id:n,receiverAddress:a,tiers:o}}async buildPayBoostingTx({walletAddress:e,tierId:t,boostingCoinType:n,currentTx:a}){let i=await this.getConfig();tiny_invariant_default()(t in i.tiers,"Invalid tier ID");let o=i.tiers[t].amount,r=a||new transactions_namespaceObject.Transaction,s=r.splitCoins(r.gas,[r.pure.u64(o)]);r.moveCall({target:`${BOOSTING_PACKAGE_ID}::boosting::pay`,typeArguments:[(0,utils_namespaceObject.normalizeStructTag)(n)],arguments:[r.object(CONFIG_ID),r.pure.u64(t),s]}),r.setSender(e);let u=await getNeededGasFee(this.sdk.suiClient,r,e,0);return addGasFee({inheritTx:r,sender:e,feeAmount:u},this.sdk.suiClient)}async buildAddTierTx({adminAddress:e,tierId:t,duration:n,point:a,originalAmount:i,amount:o,currentTx:r}){let s=r||new transactions_namespaceObject.Transaction;s.moveCall({target:`${BOOSTING_PACKAGE_ID}::config::add_tier`,typeArguments:[],arguments:[s.object(CONFIG_ID),s.object(ADMIN_CAP_ID),s.pure.u64(t),s.pure.u64(a),s.pure.u64(n),s.pure.u64(i),s.pure.u64(o)]}),s.setSender(e);let u=await getNeededGasFee(this.sdk.suiClient,s,e,0);return addGasFee({inheritTx:s,sender:e,feeAmount:u},this.sdk.suiClient)}async buildUpdateTierTx({adminAddress:e,tierId:t,duration:n,amount:a,originalAmount:i,point:o,currentTx:r}){let s=r||new transactions_namespaceObject.Transaction;s.moveCall({target:`${BOOSTING_PACKAGE_ID}::config::update_tier`,typeArguments:[],arguments:[s.object(CONFIG_ID),s.object(ADMIN_CAP_ID),s.pure.u64(t),s.pure.u64(n),s.pure.u64(a),s.pure.u64(o),s.pure.u64(i)]}),s.setSender(e);let u=await getNeededGasFee(this.sdk.suiClient,s,e,0);return addGasFee({inheritTx:s,sender:e,feeAmount:u},this.sdk.suiClient)}async buildRemoveTierTx({adminAddress:e,tierId:t,currentTx:n}){let a=n||new transactions_namespaceObject.Transaction;a.moveCall({target:`${BOOSTING_PACKAGE_ID}::config::remove_tier`,typeArguments:[],arguments:[a.object(CONFIG_ID),a.object(ADMIN_CAP_ID),a.pure.u64(t)]}),a.setSender(e);let i=await getNeededGasFee(this.sdk.suiClient,a,e,0);return addGasFee({inheritTx:a,sender:e,feeAmount:i},this.sdk.suiClient)}async buildUpdateFeeReceiver({adminAddress:e,newReceiverAddress:t,currentTx:n}){let a=n||new transactions_namespaceObject.Transaction;a.moveCall({target:`${BOOSTING_PACKAGE_ID}::config::update_fee_receiver`,typeArguments:[],arguments:[a.object(CONFIG_ID),a.object(ADMIN_CAP_ID),a.pure.address(t)]}),a.setSender(e);let i=await getNeededGasFee(this.sdk.suiClient,a,e,0);return addGasFee({inheritTx:a,sender:e,feeAmount:i},this.sdk.suiClient)}async buildPayBoostingWithAdminTx({walletAddress:e,tierId:t,customAmount:n,boostingCoinType:a,currentTx:i}){let o=i||new transactions_namespaceObject.Transaction,r=o.splitCoins(o.gas,[o.pure.u64(n)]);o.moveCall({target:`${BOOSTING_PACKAGE_ID}::boosting::pay_with_admin`,typeArguments:[(0,utils_namespaceObject.normalizeStructTag)(a)],arguments:[o.object(ADMIN_CAP_ID),o.object(CONFIG_ID),o.pure.u64(t),o.pure.u64(n),r]}),o.setSender(e);let s=await getNeededGasFee(this.sdk.suiClient,o,e,0);return addGasFee({inheritTx:o,sender:e,feeAmount:s},this.sdk.suiClient)}}class CurveModule{sdk;constructor(e){this.sdk=e}async getEstimatedAmountOut(e,t){let{coinInType:n,coinOutType:a}=t;tiny_invariant_default()(n!==a,"coinInType and coinOutType must be different"),tiny_invariant_default()(isSuiCoinType(n)||isSuiCoinType(a),"One of coinInType or coinOutType must be SUI");let i=isSuiCoinType(n);switch(e){case types_SupportedBondingCurve.MOONBAGS:if(i)return await calculation_MoonbagsCalculation.getCurveAmountAfterBuy({poolId:t.poolId,suiAmount:t.coinInAmount,frontendFee:t.tradeFee?t.tradeFee.tradeFeePercent:void 0},this.sdk.suiClient);return await calculation_MoonbagsCalculation.getSuiAmountAfterSell({poolId:t.poolId,curveAmount:t.coinInAmount,frontendFee:t.tradeFee?t.tradeFee.tradeFeePercent:void 0},this.sdk.suiClient);case types_SupportedBondingCurve.BLAST_FUN:if(i)return await sdk_calculation_BlastFunSDKCalculation.getCurveAmountAfterBuy({poolId:t.poolId,suiAmount:t.coinInAmount,frontendFee:t.tradeFee?t.tradeFee.tradeFeePercent:void 0});return await sdk_calculation_BlastFunSDKCalculation.getSuiAmountAfterSell({poolId:t.poolId,curveAmount:t.coinInAmount,frontendFee:t.tradeFee?t.tradeFee.tradeFeePercent:void 0});default:throw Error(`Unsupported bonding curve platform: ${e}`)}}async getTradeTransaction(e,t){let n,{coinInType:a,coinOutType:i}=t;tiny_invariant_default()(a!==i,"coinInType and coinOutType must be different"),tiny_invariant_default()(isSuiCoinType(a)||isSuiCoinType(i),"One of coinInType or coinOutType must be SUI");let o=isSuiCoinType(a);switch(e){case types_SupportedBondingCurve.MOONBAGS:n=o?await transaction_MoonbagsTransaction.getBuyTransaction(t,this.sdk.suiClient):await transaction_MoonbagsTransaction.getSellTransaction(t,this.sdk.suiClient);break;case types_SupportedBondingCurve.BLAST_FUN:n=o?await sdk_transaction_BlastFunSDKTransaction.getBuyTransaction(t,this.sdk.suiClient):await sdk_transaction_BlastFunSDKTransaction.getSellTransaction(t,this.sdk.suiClient);break;default:throw Error(`Unsupported bonding curve platform: ${e}`)}return n}}const SUBSCRIPTION_PACKAGE_ID="0x5dd4286ec234c117bb9577d4eaed1885b70d73ab1d3dab2794d0ab9a2c06c4a1",SUBSCRIPTION_CONFIG_ID="0x095b941beff22213fe8ccb223e4d1c5b4ede4dcd7f82ca4bb18c9a45fd3d6e20",SUBSCRIPTION_ADMIN_CAP_ID="0xdc27fe8187131b7fc095fccd213b79f72312793152a2483d1f67199c390e256d",PAYMENT_COIN_TYPE="0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC";class SubscriptionModule{sdk;constructor(e){this.sdk=e}async getConfig(){let e=await this.sdk.suiClient.getObject({id:SUBSCRIPTION_CONFIG_ID,options:{showContent:!0}});tiny_invariant_default()(e.data,"Config object not found"),tiny_invariant_default()(e.data.content,"Config object has no content"),tiny_invariant_default()(e.data?.content.dataType==="moveObject","Config object is not a Move object");let t=e.data.content.fields,n=t.id.id,a=t.fee_receiver,i=t.paused,o=t.accepted_payment_type,r=t.plans.fields.contents,s={};for(let e of r){let t=e.fields.key,n=e.fields.value.fields.id,a=e.fields.value.fields.price,i=e.fields.value.fields.month_interval,o=e.fields.value.fields.ptype;s[t]={id:BigInt(n),price:BigInt(a),monthInterval:i,planType:o}}return{id:n,plans:s,feeReceiverWallet:a,paused:i,acceptedPaymentType:o}}async buildSubscribeCyclePlanTx({walletAddress:e,planId:t,reference:n,paymentCoinType:a=PAYMENT_COIN_TYPE,currentTx:i}){let o=await this.getConfig();tiny_invariant_default()(!o.paused,"Contract is paused"),tiny_invariant_default()(t in o.plans,"Invalid plan ID");let r=o.plans[t].price,{tx:s,coinData:u}=await getSplitCoinForTx({account:e,amount:r.toString(),splits:[r.toString()],coinType:a,inheritTx:i},this.sdk.suiClient);s.moveCall({target:`${SUBSCRIPTION_PACKAGE_ID}::subscription::subscribe_cycle_plan`,typeArguments:[a],arguments:[s.object(SUBSCRIPTION_CONFIG_ID),s.pure.u64(t),s.pure.string(n),u]}),s.setSender(e);let c=await getNeededGasFee(this.sdk.suiClient,s,e,0);return addGasFee({inheritTx:s,sender:e,feeAmount:c},this.sdk.suiClient)}async buildBuyMoreCUPlanTx({walletAddress:e,planId:t,reference:n,paidAmount:a,paymentCoinType:i=PAYMENT_COIN_TYPE,currentTx:o}){let r=await this.getConfig();tiny_invariant_default()(!r.paused,"Contract is paused"),tiny_invariant_default()(t in r.plans,"Invalid plan ID");let{tx:s,coinData:u}=await getSplitCoinForTx({account:e,amount:a.toString(),splits:[a.toString()],coinType:i,inheritTx:o},this.sdk.suiClient);s.moveCall({target:`${SUBSCRIPTION_PACKAGE_ID}::subscription::buy_more_cu`,typeArguments:[i],arguments:[s.object(SUBSCRIPTION_CONFIG_ID),s.pure.u64(t),s.pure.string(n),s.pure.u64(a),u]}),s.setSender(e);let c=await getNeededGasFee(this.sdk.suiClient,s,e,0);return addGasFee({inheritTx:s,sender:e,feeAmount:c},this.sdk.suiClient)}async buildSubscribePlanWithAdminTx({walletAddress:e,planId:t,reference:n,customAmount:a,paymentCoinType:i=PAYMENT_COIN_TYPE,currentTx:o}){let r=await this.getConfig();tiny_invariant_default()(!r.paused,"Contract is paused");let{tx:s,coinData:u}=await getSplitCoinForTx({account:e,amount:a.toString(),splits:[a.toString()],coinType:i,inheritTx:o},this.sdk.suiClient);s.moveCall({target:`${SUBSCRIPTION_PACKAGE_ID}::subscription::subscribe_plan_with_admin`,typeArguments:[i],arguments:[s.object(SUBSCRIPTION_ADMIN_CAP_ID),s.object(SUBSCRIPTION_CONFIG_ID),s.pure.u64(t),s.pure.string(n),s.pure.u64(a),u]}),s.setSender(e);let c=await getNeededGasFee(this.sdk.suiClient,s,e,0);return addGasFee({inheritTx:s,sender:e,feeAmount:c},this.sdk.suiClient)}async buildAddPlanTx({adminAddress:e,planId:t,planType:n,monthInterval:a,price:i,currentTx:o}){let r=o||new transactions_namespaceObject.Transaction;r.moveCall({target:`${SUBSCRIPTION_PACKAGE_ID}::config::add_plan`,typeArguments:[],arguments:[r.object(SUBSCRIPTION_CONFIG_ID),r.object(SUBSCRIPTION_ADMIN_CAP_ID),r.pure.u64(t),r.pure.u8(n),r.pure.u8(a),r.pure.u64(i)]}),r.setSender(e);let s=await getNeededGasFee(this.sdk.suiClient,r,e,0);return addGasFee({inheritTx:r,sender:e,feeAmount:s},this.sdk.suiClient)}async buildUpdatePlanTx({adminAddress:e,planId:t,planType:n,monthInterval:a,price:i,currentTx:o}){let r=o||new transactions_namespaceObject.Transaction;r.moveCall({target:`${SUBSCRIPTION_PACKAGE_ID}::config::update_plan`,typeArguments:[],arguments:[r.object(SUBSCRIPTION_CONFIG_ID),r.object(SUBSCRIPTION_ADMIN_CAP_ID),r.pure.u64(BigInt(t)),r.pure.u8(n),r.pure.u8(a),r.pure.u64(i)]}),r.setSender(e);let s=await getNeededGasFee(this.sdk.suiClient,r,e,0);return addGasFee({inheritTx:r,sender:e,feeAmount:s},this.sdk.suiClient)}async buildRemovePlanTx({adminAddress:e,planId:t,currentTx:n}){let a=n||new transactions_namespaceObject.Transaction;a.moveCall({target:`${SUBSCRIPTION_PACKAGE_ID}::config::remove_plan`,typeArguments:[],arguments:[a.object(SUBSCRIPTION_CONFIG_ID),a.object(SUBSCRIPTION_ADMIN_CAP_ID),a.pure.u64(BigInt(t))]}),a.setSender(e);let i=await getNeededGasFee(this.sdk.suiClient,a,e,0);return addGasFee({inheritTx:a,sender:e,feeAmount:i},this.sdk.suiClient)}async buildUpdateFeeReceiverWalletTx({adminAddress:e,newFeeReceiverWallet:t,currentTx:n}){let a=n||new transactions_namespaceObject.Transaction;a.moveCall({target:`${SUBSCRIPTION_PACKAGE_ID}::config::update_fee_receiver`,typeArguments:[],arguments:[a.object(SUBSCRIPTION_CONFIG_ID),a.object(SUBSCRIPTION_ADMIN_CAP_ID),a.pure.address(t)]}),a.setSender(e);let i=await getNeededGasFee(this.sdk.suiClient,a,e,0);return addGasFee({inheritTx:a,sender:e,feeAmount:i},this.sdk.suiClient)}async buildSetPausedTx({adminAddress:e,paused:t,currentTx:n}){let a=n||new transactions_namespaceObject.Transaction;a.moveCall({target:`${SUBSCRIPTION_PACKAGE_ID}::config::set_paused`,typeArguments:[],arguments:[a.object(SUBSCRIPTION_CONFIG_ID),a.object(SUBSCRIPTION_ADMIN_CAP_ID),a.pure.bool(t)]}),a.setSender(e);let i=await getNeededGasFee(this.sdk.suiClient,a,e,0);return addGasFee({inheritTx:a,sender:e,feeAmount:i},this.sdk.suiClient)}async buildSetAcceptedPaymentTypeTx({adminAddress:e,paymentCoinType:t,currentTx:n}){let a=n||new transactions_namespaceObject.Transaction;a.moveCall({target:`${SUBSCRIPTION_PACKAGE_ID}::config::set_accepted_payment_type`,typeArguments:[t],arguments:[a.object(SUBSCRIPTION_CONFIG_ID),a.object(SUBSCRIPTION_ADMIN_CAP_ID)]}),a.setSender(e);let i=await getNeededGasFee(this.sdk.suiClient,a,e,0);return addGasFee({inheritTx:a,sender:e,feeAmount:i},this.sdk.suiClient)}}class NoodlesPaySdk{_suiClient;boostingModule;subscriptionModule;constructor(){this._suiClient=new client_namespaceObject.SuiClient({url:(0,client_namespaceObject.getFullnodeUrl)("mainnet")}),this.subscriptionModule=new SubscriptionModule(this),this.boostingModule=new BoostingModule(this)}get suiClient(){return this._suiClient}}const DEFAULT_TRADE_FEE={tradeFeePercent:.01,tradeFeeRecipientAddress:"0xdaf1c8ed29d89cd8f217f609bad0a668fa6f158c12000bfa5f93e670c99e24ff"};class NoodlesSdk{options;_suiClient;aggregatorModule;curveModule;constructor(e){this.options=e,this._suiClient=new client_namespaceObject.SuiClient({url:(0,client_namespaceObject.getFullnodeUrl)("mainnet")}),this.aggregatorModule=new AggregatorModule(this),this.curveModule=new CurveModule(this)}get suiClient(){return this._suiClient}}const ed25519_namespaceObject=require("@mysten/sui/keypairs/ed25519"),CONSTANTS={GAS_FEE_BUFFER_PERCENTAGE:.1};class DraftTransferTx{suiClient;constructor(e){this.suiClient=e}validatePrivateKey(e,t){tiny_invariant_default()(e?.trim(),"Private key is required");let n=ed25519_namespaceObject.Ed25519Keypair.fromSecretKey(e),a=n.getPublicKey().toSuiAddress();if(a!==t)throw Error(`Private key mismatch. Expected: ${t}, Got: ${a}`);return n}async createDraft(e,t,n){tiny_invariant_default()(e?.trim(),"Sender address is required"),tiny_invariant_default()(t?.trim(),"Recipient address is required"),tiny_invariant_default()(e!==t,"Sender and recipient cannot be the same"),tiny_invariant_default()(n>0n,"Transfer amount must be at least 1 MIST");try{let a=new transactions_namespaceObject.Transaction,[i]=a.splitCoins(a.gas,[n]);a.transferObjects([i],t),a.setSender(e);let o=await this.suiClient.getReferenceGasPrice();a.setGasPrice(o);let r=await getNeededGasFee(this.suiClient,a,e,CONSTANTS.GAS_FEE_BUFFER_PERCENTAGE);a=await addGasFee({inheritTx:a,sender:e,feeAmount:r,suiInputAmount:n},this.suiClient);let s=await a.build({client:this.suiClient}),u=Buffer.from(s).toString("base64"),c=await a.getDigest();return{sender:e,recipient:t,amountMIST:n,txDraftBase64:u,txDigest:c}}catch(e){throw Error(`Failed to create draft transaction: ${e instanceof Error?e.message:"Unknown error"}`)}}async execute(e,t){try{tiny_invariant_default()(e,"Draft transaction is required"),tiny_invariant_default()(e.txDraftBase64?.trim(),"Transaction data is required");let n=this.validatePrivateKey(t,e.sender),a=(0,utils_namespaceObject.fromBase64)(e.txDraftBase64),{signature:i}=await n.signTransaction(a),o=await this.suiClient.executeTransactionBlock({transactionBlock:a,signature:i});return{success:!0,txDigest:o.digest,effects:o.effects}}catch(e){return{success:!1,error:e instanceof Error?e.message:"Unknown error occurred"}}}async getTransactionStatus(e){tiny_invariant_default()(e?.trim(),"Transaction digest is required");try{let t=await this.suiClient.getTransactionBlock({digest:e,options:{showEffects:!0}});if(!t?.effects?.status)return"pending";return"success"===t.effects.status.status?"success":"failure"}catch(e){if(e instanceof Error&&(e.message.includes("not found")||e.message.includes("Could not find")))return"pending";return"failure"}}}for(var __rspack_i in exports.ADMIN_CAP_ID=__webpack_exports__.ADMIN_CAP_ID,exports.AftermathAggregator=__webpack_exports__.AftermathAggregator,exports.AggregatorModule=__webpack_exports__.AggregatorModule,exports.AstrosAggregator=__webpack_exports__.AstrosAggregator,exports.BASE_BPS=__webpack_exports__.BASE_BPS,exports.BLUEFIN_PACKAGE_ID=__webpack_exports__.BLUEFIN_PACKAGE_ID,exports.BOOSTING_PACKAGE_ID=__webpack_exports__.BOOSTING_PACKAGE_ID,exports.BlastFunConstants=__webpack_exports__.BlastFunConstants,exports.BlastFunCustomCalculation=__webpack_exports__.BlastFunCustomCalculation,exports.BlastFunCustomTransaction=__webpack_exports__.BlastFunCustomTransaction,exports.BlastFunPackage=__webpack_exports__.BlastFunPackage,exports.BlastFunSDKCalculation=__webpack_exports__.BlastFunSDKCalculation,exports.BlastFunSDKTransaction=__webpack_exports__.BlastFunSDKTransaction,exports.BluefinTx=__webpack_exports__.BluefinTx,exports.BoostingModule=__webpack_exports__.BoostingModule,exports.Bps=__webpack_exports__.Bps,exports.CLOCK_OBJECT_ID=__webpack_exports__.CLOCK_OBJECT_ID,exports.CONFIG_ID=__webpack_exports__.CONFIG_ID,exports.CetusAggregator=__webpack_exports__.CetusAggregator,exports.CurveModule=__webpack_exports__.CurveModule,exports.DEFAULT_TRADE_FEE=__webpack_exports__.DEFAULT_TRADE_FEE,exports.DraftTransferTx=__webpack_exports__.DraftTransferTx,exports.FlowXAggregator=__webpack_exports__.FlowXAggregator,exports.MathUtils=__webpack_exports__.MathUtils,exports.MoonbagsCalculation=__webpack_exports__.MoonbagsCalculation,exports.MoonbagsConstants=__webpack_exports__.MoonbagsConstants,exports.MoonbagsPackage=__webpack_exports__.MoonbagsPackage,exports.MoonbagsTransaction=__webpack_exports__.MoonbagsTransaction,exports.NATIVE_USDC_TOKEN_TYPE=__webpack_exports__.NATIVE_USDC_TOKEN_TYPE,exports.NoodlesPaySdk=__webpack_exports__.NoodlesPaySdk,exports.NoodlesSdk=__webpack_exports__.NoodlesSdk,exports.PAYMENT_COIN_TYPE=__webpack_exports__.PAYMENT_COIN_TYPE,exports.SUBSCRIPTION_ADMIN_CAP_ID=__webpack_exports__.SUBSCRIPTION_ADMIN_CAP_ID,exports.SUBSCRIPTION_CONFIG_ID=__webpack_exports__.SUBSCRIPTION_CONFIG_ID,exports.SUBSCRIPTION_PACKAGE_ID=__webpack_exports__.SUBSCRIPTION_PACKAGE_ID,exports.SUI_FULL_TYPE=__webpack_exports__.SUI_FULL_TYPE,exports.SUI_METADATA_OBJECT_ID=__webpack_exports__.SUI_METADATA_OBJECT_ID,exports.SUI_TYPE=__webpack_exports__.SUI_TYPE,exports.SevenKAggregator=__webpack_exports__.SevenKAggregator,exports.SubscriptionModule=__webpack_exports__.SubscriptionModule,exports.SupportedAggregator=__webpack_exports__.SupportedAggregator,exports.SupportedBondingCurve=__webpack_exports__.SupportedBondingCurve,exports.TradeFeeOptions=__webpack_exports__.TradeFeeOptions,exports.USDC_TOKEN_TYPE=__webpack_exports__.USDC_TOKEN_TYPE,exports.adaptSuiClient=__webpack_exports__.adaptSuiClient,exports.adaptTransaction=__webpack_exports__.adaptTransaction,exports.addGasFee=__webpack_exports__.addGasFee,exports.createCompatibleSuiClient=__webpack_exports__.createCompatibleSuiClient,exports.getAmountAfterFee=__webpack_exports__.getAmountAfterFee,exports.getCoinObjectIdsByAmount=__webpack_exports__.getCoinObjectIdsByAmount,exports.getMemezPumpSDK=__webpack_exports__.getMemezPumpSDK,exports.getMoveObject=__webpack_exports__.getMoveObject,exports.getMoveObjectContent=__webpack_exports__.getMoveObjectContent,exports.getNeededGasFee=__webpack_exports__.getNeededGasFee,exports.getSplitCoinForTx=__webpack_exports__.getSplitCoinForTx,exports.getSplitCoinsAfterFee=__webpack_exports__.getSplitCoinsAfterFee,exports.isSuiCoinType=__webpack_exports__.isSuiCoinType,exports.splitSuiCoinAfterFeeFromBuyTx=__webpack_exports__.splitSuiCoinAfterFeeFromBuyTx,exports.splitSuiCoinAfterFeeFromSellTx=__webpack_exports__.splitSuiCoinAfterFeeFromSellTx,__webpack_exports__)-1===["ADMIN_CAP_ID","AftermathAggregator","AggregatorModule","AstrosAggregator","BASE_BPS","BLUEFIN_PACKAGE_ID","BOOSTING_PACKAGE_ID","BlastFunConstants","BlastFunCustomCalculation","BlastFunCustomTransaction","BlastFunPackage","BlastFunSDKCalculation","BlastFunSDKTransaction","BluefinTx","BoostingModule","Bps","CLOCK_OBJECT_ID","CONFIG_ID","CetusAggregator","CurveModule","DEFAULT_TRADE_FEE","DraftTransferTx","FlowXAggregator","MathUtils","MoonbagsCalculation","MoonbagsConstants","MoonbagsPackage","MoonbagsTransaction","NATIVE_USDC_TOKEN_TYPE","NoodlesPaySdk","NoodlesSdk","PAYMENT_COIN_TYPE","SUBSCRIPTION_ADMIN_CAP_ID","SUBSCRIPTION_CONFIG_ID","SUBSCRIPTION_PACKAGE_ID","SUI_FULL_TYPE","SUI_METADATA_OBJECT_ID","SUI_TYPE","SevenKAggregator","SubscriptionModule","SupportedAggregator","SupportedBondingCurve","TradeFeeOptions","USDC_TOKEN_TYPE","adaptSuiClient","adaptTransaction","addGasFee","createCompatibleSuiClient","getAmountAfterFee","getCoinObjectIdsByAmount","getMemezPumpSDK","getMoveObject","getMoveObjectContent","getNeededGasFee","getSplitCoinForTx","getSplitCoinsAfterFee","isSuiCoinType","splitSuiCoinAfterFeeFromBuyTx","splitSuiCoinAfterFeeFromSellTx"].indexOf(__rspack_i)&&(exports[__rspack_i]=__webpack_exports__[__rspack_i]);Object.defineProperty(exports,"__esModule",{value:!0});
1
+ "use strict";
2
+ const __rslib_import_meta_url__ = /*#__PURE__*/ (function () {
3
+ return typeof document === 'undefined'
4
+ ? new (require('url'.replace('', '')).URL)('file:' + __filename).href
5
+ : (document.currentScript && document.currentScript.src) ||
6
+ new URL('main.js', document.baseURI).href;
7
+ })();
8
+ ;
9
+ // The require scope
10
+ var __webpack_require__ = {};
11
+
12
+ // webpack/runtime/compat_get_default_export
13
+ (() => {
14
+ // getDefaultExport function for compatibility with non-ESM modules
15
+ __webpack_require__.n = (module) => {
16
+ var getter = module && module.__esModule ?
17
+ () => (module['default']) :
18
+ () => (module);
19
+ __webpack_require__.d(getter, { a: getter });
20
+ return getter;
21
+ };
22
+
23
+ })();
24
+ // webpack/runtime/define_property_getters
25
+ (() => {
26
+ __webpack_require__.d = (exports, definition) => {
27
+ for(var key in definition) {
28
+ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
29
+ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
30
+ }
31
+ }
32
+ };
33
+ })();
34
+ // webpack/runtime/has_own_property
35
+ (() => {
36
+ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
37
+ })();
38
+ // webpack/runtime/make_namespace_object
39
+ (() => {
40
+ // define __esModule on exports
41
+ __webpack_require__.r = (exports) => {
42
+ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
43
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
44
+ }
45
+ Object.defineProperty(exports, '__esModule', { value: true });
46
+ };
47
+ })();
48
+ var __webpack_exports__ = {};
49
+ // ESM COMPAT FLAG
50
+ __webpack_require__.r(__webpack_exports__);
51
+
52
+ // EXPORTS
53
+ __webpack_require__.d(__webpack_exports__, {
54
+ addGasFee: () => (/* reexport */ addGasFee),
55
+ TradeFeeOptions: () => (/* reexport */ types_TradeFeeOptions),
56
+ SUBSCRIPTION_CONFIG_ID: () => (/* reexport */ SUBSCRIPTION_CONFIG_ID),
57
+ getMemezPumpSDK: () => (/* reexport */ getMemezPumpSDK),
58
+ DraftTransferTx: () => (/* reexport */ DraftTransferTx),
59
+ BlastFunSDKCalculation: () => (/* reexport */ sdk_calculation_BlastFunSDKCalculation),
60
+ MoonbagsConstants: () => (/* reexport */ constants_MoonbagsConstants),
61
+ NoodlesPaySdk: () => (/* reexport */ NoodlesPaySdk),
62
+ Bps: () => (/* reexport */ package_Bps),
63
+ ADMIN_CAP_ID: () => (/* reexport */ ADMIN_CAP_ID),
64
+ splitSuiCoinAfterFeeFromBuyTx: () => (/* reexport */ splitSuiCoinAfterFeeFromBuyTx),
65
+ getMoveObject: () => (/* reexport */ getMoveObject),
66
+ SUBSCRIPTION_PACKAGE_ID: () => (/* reexport */ SUBSCRIPTION_PACKAGE_ID),
67
+ MoonbagsCalculation: () => (/* reexport */ calculation_MoonbagsCalculation),
68
+ SUBSCRIPTION_ADMIN_CAP_ID: () => (/* reexport */ SUBSCRIPTION_ADMIN_CAP_ID),
69
+ getSplitCoinsAfterFee: () => (/* reexport */ getSplitCoinsAfterFee),
70
+ AstrosAggregator: () => (/* reexport */ astros_AstrosAggregator),
71
+ BlastFunSDKTransaction: () => (/* reexport */ sdk_transaction_BlastFunSDKTransaction),
72
+ CONFIG_ID: () => (/* reexport */ CONFIG_ID),
73
+ AftermathAggregator: () => (/* reexport */ aftermath_AftermathAggregator),
74
+ FlowXAggregator: () => (/* reexport */ flowx_FlowXAggregator),
75
+ adaptSuiClient: () => (/* reexport */ adaptSuiClient),
76
+ getNeededGasFee: () => (/* reexport */ getNeededGasFee),
77
+ AggregatorModule: () => (/* reexport */ AggregatorModule),
78
+ adaptTransaction: () => (/* reexport */ adaptTransaction),
79
+ createCompatibleSuiClient: () => (/* reexport */ createCompatibleSuiClient),
80
+ splitSuiCoinAfterFeeFromSellTx: () => (/* reexport */ splitSuiCoinAfterFeeFromSellTx),
81
+ SupportedAggregator: () => (/* reexport */ common_SupportedAggregator),
82
+ NATIVE_USDC_TOKEN_TYPE: () => (/* reexport */ NATIVE_USDC_TOKEN_TYPE),
83
+ BOOSTING_PACKAGE_ID: () => (/* reexport */ BOOSTING_PACKAGE_ID),
84
+ SUI_TYPE: () => (/* reexport */ SUI_TYPE),
85
+ USDC_TOKEN_TYPE: () => (/* reexport */ USDC_TOKEN_TYPE),
86
+ isSuiCoinType: () => (/* reexport */ isSuiCoinType),
87
+ MoonbagsPackage: () => (/* reexport */ package_MoonbagsPackage),
88
+ getCoinObjectIdsByAmount: () => (/* reexport */ getCoinObjectIdsByAmount),
89
+ SUI_FULL_TYPE: () => (/* reexport */ SUI_FULL_TYPE),
90
+ getAmountAfterFee: () => (/* reexport */ getAmountAfterFee),
91
+ BLUEFIN_PACKAGE_ID: () => (/* reexport */ BLUEFIN_PACKAGE_ID),
92
+ SubscriptionModule: () => (/* reexport */ SubscriptionModule),
93
+ MathUtils: () => (/* reexport */ package_MathUtils),
94
+ CLOCK_OBJECT_ID: () => (/* reexport */ CLOCK_OBJECT_ID),
95
+ CurveModule: () => (/* reexport */ CurveModule),
96
+ MoonbagsTransaction: () => (/* reexport */ transaction_MoonbagsTransaction),
97
+ BlastFunPackage: () => (/* reexport */ package_BlastFunPackage),
98
+ CetusAggregator: () => (/* reexport */ cetus_CetusAggregator),
99
+ DEFAULT_TRADE_FEE: () => (/* reexport */ DEFAULT_TRADE_FEE),
100
+ BlastFunCustomTransaction: () => (/* reexport */ custom_transaction_BlastFunCustomTransaction),
101
+ NoodlesSdk: () => (/* reexport */ NoodlesSdk),
102
+ BoostingModule: () => (/* reexport */ BoostingModule),
103
+ getMoveObjectContent: () => (/* reexport */ getMoveObjectContent),
104
+ getSplitCoinForTx: () => (/* reexport */ getSplitCoinForTx),
105
+ BlastFunCustomCalculation: () => (/* reexport */ custom_calculation_BlastFunCustomCalculation),
106
+ SupportedBondingCurve: () => (/* reexport */ types_SupportedBondingCurve),
107
+ PAYMENT_COIN_TYPE: () => (/* reexport */ PAYMENT_COIN_TYPE),
108
+ BASE_BPS: () => (/* reexport */ /* inlined export .BASE_BPS */ (10000)),
109
+ BluefinTx: () => (/* reexport */ bluefin_BluefinTx),
110
+ SUI_METADATA_OBJECT_ID: () => (/* reexport */ SUI_METADATA_OBJECT_ID),
111
+ SevenKAggregator: () => (/* reexport */ _7k_SevenKAggregator),
112
+ BlastFunConstants: () => (/* reexport */ constants_BlastFunConstants)
113
+ });
114
+
115
+ ;// CONCATENATED MODULE: external "@7kprotocol/sdk-ts"
116
+ const sdk_ts_namespaceObject = require("@7kprotocol/sdk-ts");
117
+ ;// CONCATENATED MODULE: external "@mysten/sui/transactions"
118
+ const transactions_namespaceObject = require("@mysten/sui/transactions");
119
+ ;// CONCATENATED MODULE: external "bignumber.js"
120
+ const external_bignumber_js_namespaceObject = require("bignumber.js");
121
+ var external_bignumber_js_default = /*#__PURE__*/__webpack_require__.n(external_bignumber_js_namespaceObject);
122
+ ;// CONCATENATED MODULE: ./src/aggregator/7k.ts
123
+
124
+
125
+
126
+ /**
127
+ * 7K Protocol DEX aggregator client for routing trades across multiple pools
128
+ * 7K Protocol aggregates liquidity from various DEXs to find optimal trade routes
129
+ */ class _7k_SevenKAggregator {
130
+ /** Configuration settings for the aggregator */ _config;
131
+ /** Sui blockchain client */ _suiClient;
132
+ /**
133
+ * Creates a new SevenKAggregator instance
134
+ * @param config - Aggregator configuration including fee settings and optional API key
135
+ * @param suiClient - Sui client for blockchain interactions
136
+ */ constructor(config, suiClient){
137
+ this._config = config;
138
+ this._suiClient = suiClient;
139
+ // Config will be set lazily when the module is loaded
140
+ }
141
+ /**
142
+ * Finds the optimal trade route for swapping tokens using 7K Protocol
143
+ * @param params - Trade route parameters
144
+ * @param params.coinInAmount - Amount of input token to swap
145
+ * @param params.coinInType - Type/address of input token
146
+ * @param params.coinOutType - Type/address of output token
147
+ * @returns Promise resolving to quote response with pricing and route information, or null if no route found
148
+ */ async getTradeRoute({ coinInAmount, coinInType, coinOutType, tradeFee }) {
149
+ try {
150
+ // Set API key if provided
151
+ if (this._config.sevenKApiKey) {
152
+ sdk_ts_namespaceObject.Config.setApiKey(this._config.sevenKApiKey);
153
+ }
154
+ const tradeFeePercent = tradeFee ? tradeFee.tradeFeePercent : this._config.defaultTradeFee.tradeFeePercent;
155
+ return await (0,sdk_ts_namespaceObject.getQuote)({
156
+ tokenIn: coinInType,
157
+ tokenOut: coinOutType,
158
+ amountIn: coinInAmount.toString(),
159
+ commissionBps: tradeFeePercent * 10000
160
+ });
161
+ } catch (_err) {
162
+ return null;
163
+ }
164
+ }
165
+ /**
166
+ * Builds a transaction for executing a trade route from 7K Protocol
167
+ * @param params - Transaction parameters
168
+ * @param params.walletAddress - Address of the wallet executing the trade
169
+ * @param params.completeRoute - Complete quote response from getTradeRoute()
170
+ * @param params.slippage - Maximum acceptable slippage (e.g., 0.01 for 1%)
171
+ * @returns Promise resolving to built transaction bytes ready for signing and execution
172
+ */ async getTransaction({ walletAddress, completeRoute, slippage, tradeFee }) {
173
+ let tradeFeePercent;
174
+ let tradeFeeRecipientAddress;
175
+ if (tradeFee) {
176
+ tradeFeePercent = tradeFee.tradeFeePercent;
177
+ tradeFeeRecipientAddress = tradeFee.tradeFeeRecipientAddress;
178
+ } else {
179
+ tradeFeePercent = this._config.defaultTradeFee.tradeFeePercent;
180
+ tradeFeeRecipientAddress = this._config.defaultTradeFee.tradeFeeRecipientAddress;
181
+ }
182
+ const transaction = await (0,sdk_ts_namespaceObject.buildTx)({
183
+ quoteResponse: completeRoute,
184
+ slippage,
185
+ accountAddress: walletAddress,
186
+ commission: {
187
+ partner: tradeFeeRecipientAddress,
188
+ commissionBps: tradeFeePercent * 10000
189
+ }
190
+ });
191
+ if (transaction.tx instanceof sdk_ts_namespaceObject.BluefinXTx) {
192
+ const newTransaction = transactions_namespaceObject.Transaction.from(transaction.tx.txBytes);
193
+ return newTransaction.build({
194
+ client: this._suiClient
195
+ });
196
+ }
197
+ transaction.tx.setSender(walletAddress);
198
+ return transaction.tx.build({
199
+ client: this._suiClient
200
+ });
201
+ }
202
+ }
203
+ (function(SevenKAggregator) {
204
+ function toCommonTradeRoutes(tradeRouteResponse) {
205
+ const routes = [];
206
+ if (!tradeRouteResponse.routes || tradeRouteResponse.routes.length === 0) {
207
+ return null;
208
+ }
209
+ for (const route of tradeRouteResponse.routes){
210
+ const paths = [];
211
+ const allTokenDecimal = {};
212
+ for (const path of route.hops){
213
+ for (const t of path.pool.allTokens){
214
+ allTokenDecimal[t.address] = t.decimal;
215
+ }
216
+ const pathDecimalIn = allTokenDecimal[path.tokenIn] ?? 0;
217
+ const pathDecimalOut = allTokenDecimal[path.tokenOut] ?? 0;
218
+ const pathAmountIn = BigInt(new (external_bignumber_js_default())(path.tokenInAmount).multipliedBy(10 ** pathDecimalIn).toFixed(0, 3));
219
+ const pathAmountOut = BigInt(new (external_bignumber_js_default())(path.tokenOutAmount).multipliedBy(10 ** pathDecimalOut).toFixed(0, 3));
220
+ paths.push({
221
+ poolAddress: path.poolId,
222
+ coinIn: path.tokenIn,
223
+ coinOut: path.tokenOut,
224
+ amountIn: pathAmountIn,
225
+ amountOut: pathAmountOut
226
+ });
227
+ }
228
+ if (paths.length === 0) {
229
+ continue;
230
+ }
231
+ const routeDecimalIn = allTokenDecimal[route.tokenIn] ?? 0;
232
+ const routeDecimalOut = allTokenDecimal[route.tokenOut] ?? 0;
233
+ const routeAmountIn = BigInt(new (external_bignumber_js_default())(route.tokenInAmount).multipliedBy(10 ** routeDecimalIn).toFixed(0, 3));
234
+ const routeAmountOut = BigInt(new (external_bignumber_js_default())(route.tokenOutAmount).multipliedBy(10 ** routeDecimalOut).toFixed(0, 3));
235
+ routes.push({
236
+ paths: paths,
237
+ coinIn: route.tokenIn,
238
+ coinOut: route.tokenOut,
239
+ amountIn: routeAmountIn,
240
+ amountOut: routeAmountOut
241
+ });
242
+ }
243
+ if (routes.length === 0) {
244
+ return null;
245
+ }
246
+ return {
247
+ coinIn: tradeRouteResponse.tokenIn,
248
+ coinOut: tradeRouteResponse.tokenOut,
249
+ amountIn: BigInt(tradeRouteResponse.swapAmountWithDecimal),
250
+ amountOut: BigInt(tradeRouteResponse.returnAmountWithDecimal),
251
+ routes: routes
252
+ };
253
+ }
254
+ SevenKAggregator.toCommonTradeRoutes = toCommonTradeRoutes;
255
+ })(_7k_SevenKAggregator || (_7k_SevenKAggregator = {}));
256
+
257
+ ;// CONCATENATED MODULE: external "aftermath-ts-sdk"
258
+ const external_aftermath_ts_sdk_namespaceObject = require("aftermath-ts-sdk");
259
+ ;// CONCATENATED MODULE: ./src/aggregator/aftermath.ts
260
+
261
+ /**
262
+ * Aftermath DEX aggregator client for routing trades across multiple pools
263
+ */ class aftermath_AftermathAggregator {
264
+ /** Configuration settings for the aggregator */ _config;
265
+ /** Aftermath SDK client instance (lazy-loaded on first use) */ _aftermathClient;
266
+ /** Sui blockchain client */ _suiClient;
267
+ /**
268
+ * Creates a new AftermathAggregator instance
269
+ * @param config - Aggregator configuration including optional API settings
270
+ * @param suiClient - Sui client for blockchain interactions
271
+ */ constructor(config, suiClient){
272
+ this._config = config;
273
+ this._suiClient = suiClient;
274
+ }
275
+ /**
276
+ * Lazy-loads and returns the Aftermath client, initializing it on first use
277
+ * Handles authentication if API key is provided in config
278
+ * @returns Promise resolving to initialized Aftermath client
279
+ */ async aftermathClient() {
280
+ if (this._aftermathClient) {
281
+ return this._aftermathClient;
282
+ }
283
+ if (this._config.aftermathApiEndpoint) {
284
+ this._aftermathClient = new external_aftermath_ts_sdk_namespaceObject.Aftermath(this._config.aftermathApiEndpoint);
285
+ } else {
286
+ this._aftermathClient = new external_aftermath_ts_sdk_namespaceObject.Aftermath("MAINNET");
287
+ }
288
+ await this._aftermathClient.init();
289
+ if (this._config.aftermathApiKey) {
290
+ const keypair = external_aftermath_ts_sdk_namespaceObject.Helpers.keypairFromPrivateKey(this._config.aftermathApiKey);
291
+ await this._aftermathClient.Auth().init({
292
+ async signMessageCallback ({ message }) {
293
+ const { signature } = await keypair.signPersonalMessage(message);
294
+ return {
295
+ signature
296
+ };
297
+ },
298
+ walletAddress: keypair.toSuiAddress()
299
+ });
300
+ }
301
+ return this._aftermathClient;
302
+ }
303
+ /**
304
+ * Finds the optimal trade route for swapping tokens
305
+ * @param params - Trade route parameters
306
+ * @param params.coinInAmount - Amount of input token to swap
307
+ * @param params.coinInType - Type/address of input token
308
+ * @param params.coinOutType - Type/address of output token
309
+ * @returns Promise resolving to complete trade route with pricing and path information
310
+ */ async getTradeRoute({ coinInAmount, coinInType, coinOutType, tradeFee }) {
311
+ try {
312
+ let externalFee;
313
+ if (tradeFee) {
314
+ externalFee = {
315
+ recipient: tradeFee.tradeFeeRecipientAddress,
316
+ feePercentage: tradeFee.tradeFeePercent
317
+ };
318
+ } else {
319
+ externalFee = {
320
+ recipient: this._config.defaultTradeFee.tradeFeeRecipientAddress,
321
+ feePercentage: this._config.defaultTradeFee.tradeFeePercent
322
+ };
323
+ }
324
+ const client = await this.aftermathClient();
325
+ return await client.Router().getCompleteTradeRouteGivenAmountIn({
326
+ coinInAmount,
327
+ coinInType,
328
+ coinOutType,
329
+ externalFee
330
+ });
331
+ } catch (_err) {
332
+ return null;
333
+ }
334
+ }
335
+ /**
336
+ * Builds a transaction for executing a trade route
337
+ * @param params - Transaction parameters
338
+ * @param params.completeRoute - Complete trade route from getTradeRoute()
339
+ * @param params.walletAddress - Address of the wallet executing the trade
340
+ * @param params.slippage - Maximum acceptable slippage (e.g., 0.01 for 1%)
341
+ * @returns Promise resolving to built transaction bytes ready for signing and execution
342
+ */ async getTransaction({ completeRoute, walletAddress, slippage }) {
343
+ const client = await this.aftermathClient();
344
+ const transaction = await client.Router().getTransactionForCompleteTradeRoute({
345
+ completeRoute,
346
+ walletAddress,
347
+ slippage,
348
+ isSponsoredTx: false
349
+ });
350
+ transaction.setSender(walletAddress);
351
+ return transaction.build({
352
+ client: this._suiClient
353
+ });
354
+ }
355
+ }
356
+ (function(AftermathAggregator) {
357
+ function toCommonTradeRoutes(tradeRoute) {
358
+ if (tradeRoute.routes.length === 0) {
359
+ return null;
360
+ }
361
+ const routes = [];
362
+ for (const route of tradeRoute.routes){
363
+ const paths = [];
364
+ for (const path of route.paths){
365
+ paths.push({
366
+ poolAddress: path.poolId,
367
+ coinIn: path.coinIn.type,
368
+ coinOut: path.coinOut.type,
369
+ amountIn: BigInt(path.coinIn.amount),
370
+ amountOut: BigInt(path.coinOut.amount)
371
+ });
372
+ }
373
+ if (paths.length === 0) {
374
+ continue;
375
+ }
376
+ routes.push({
377
+ paths: paths,
378
+ coinIn: route.coinIn.type,
379
+ coinOut: route.coinOut.type,
380
+ amountIn: route.coinIn.amount,
381
+ amountOut: route.coinOut.amount
382
+ });
383
+ }
384
+ if (routes.length === 0) {
385
+ return null;
386
+ }
387
+ return {
388
+ coinIn: tradeRoute.coinIn.type,
389
+ coinOut: tradeRoute.coinOut.type,
390
+ amountIn: tradeRoute.coinIn.amount,
391
+ amountOut: tradeRoute.coinOut.amount,
392
+ routes: routes
393
+ };
394
+ }
395
+ AftermathAggregator.toCommonTradeRoutes = toCommonTradeRoutes;
396
+ })(aftermath_AftermathAggregator || (aftermath_AftermathAggregator = {}));
397
+
398
+ ;// CONCATENATED MODULE: external "@naviprotocol/astros-aggregator-sdk"
399
+ const astros_aggregator_sdk_namespaceObject = require("@naviprotocol/astros-aggregator-sdk");
400
+ ;// CONCATENATED MODULE: ./src/aggregator/astros.ts
401
+
402
+
403
+
404
+ /**
405
+ * Utility function to check if a coin type is SUI
406
+ * @param coin - The coin type string to check
407
+ * @returns True if the coin is SUI, false otherwise
408
+ */ function isSuiCoin(coin) {
409
+ return coin === "0x2::sui::SUI" || coin === "0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI";
410
+ }
411
+ /**
412
+ * Astros DEX aggregator client for routing trades across multiple pools
413
+ * Provides access to liquidity aggregation from various DEX protocols
414
+ */ class astros_AstrosAggregator {
415
+ /** Configuration settings for the aggregator */ _config;
416
+ /** Sui blockchain client */ _suiClient;
417
+ /**
418
+ * Creates a new AstrosAggregator instance
419
+ * @param config - Aggregator configuration including optional fee settings
420
+ * @param suiClient - Sui client for blockchain interactions
421
+ */ constructor(config, suiClient){
422
+ this._config = config;
423
+ this._suiClient = suiClient;
424
+ }
425
+ /**
426
+ * Finds the optimal trade route for swapping tokens using Astros aggregator
427
+ * @param params - Trade route parameters
428
+ * @param params.coinInAmount - Amount of input token to swap
429
+ * @param params.coinInType - Type/address of input token
430
+ * @param params.coinOutType - Type/address of output token
431
+ * @returns Promise resolving to quote with pricing and route information, or null if no route found
432
+ */ async getTradeRoute({ coinInAmount, coinInType, coinOutType, tradeFee }) {
433
+ try {
434
+ let serviceFee;
435
+ if (tradeFee) {
436
+ serviceFee = {
437
+ fee: tradeFee.tradeFeePercent,
438
+ receiverAddress: tradeFee.tradeFeeRecipientAddress
439
+ };
440
+ } else {
441
+ serviceFee = {
442
+ fee: this._config.defaultTradeFee.tradeFeePercent,
443
+ receiverAddress: this._config.defaultTradeFee.tradeFeeRecipientAddress
444
+ };
445
+ }
446
+ return await (0,astros_aggregator_sdk_namespaceObject.getQuote)(coinInType, coinOutType, coinInAmount, this._config.astrosApiKey, {
447
+ byAmountIn: true,
448
+ serviceFee: serviceFee
449
+ });
450
+ } catch (_err) {
451
+ return null;
452
+ }
453
+ }
454
+ /**
455
+ * Merges multiple coin objects into a single coin for trading
456
+ * Optimizes coin usage by merging smaller coins into larger ones
457
+ * @param txb - Transaction builder instance
458
+ * @param coins - Array of coin objects to merge
459
+ * @param amount - Required amount for the trade
460
+ * @returns Transaction object reference for the merged coin
461
+ */ returnMergedCoins(txb, coins, amount) {
462
+ if (coins.length < 2) {
463
+ return txb.object(coins[0].coinObjectId);
464
+ }
465
+ let mergedBalance = 0;
466
+ const mergeList = [];
467
+ coins.sort((a, b)=>Number(b.balance) - Number(a.balance)).slice(1).forEach((coin)=>{
468
+ if (mergedBalance >= amount) {
469
+ return;
470
+ }
471
+ mergedBalance += Number(coin.balance);
472
+ mergeList.push(coin.coinObjectId);
473
+ });
474
+ const baseObj = coins[0].coinObjectId;
475
+ txb.mergeCoins(baseObj, mergeList);
476
+ return txb.object(baseObj);
477
+ }
478
+ /**
479
+ * Builds a transaction for executing a trade route from Astros aggregator
480
+ * @param params - Transaction parameters
481
+ * @param params.completeRoute - Complete quote from getTradeRoute() (aliased as quote)
482
+ * @param params.walletAddress - Address of the wallet executing the trade
483
+ * @param params.slippage - Maximum acceptable slippage (e.g., 0.01 for 1%)
484
+ * @returns Promise resolving to built transaction bytes ready for signing and execution
485
+ */ async getTransaction({ completeRoute: quote, walletAddress, slippage, tradeFee }) {
486
+ let serviceFee;
487
+ if (tradeFee) {
488
+ serviceFee = {
489
+ fee: tradeFee.tradeFeePercent,
490
+ receiverAddress: tradeFee.tradeFeeRecipientAddress
491
+ };
492
+ } else {
493
+ serviceFee = {
494
+ fee: this._config.defaultTradeFee.tradeFeePercent,
495
+ receiverAddress: this._config.defaultTradeFee.tradeFeeRecipientAddress
496
+ };
497
+ }
498
+ const minAmountOut = new (external_bignumber_js_default())(quote.amount_out).multipliedBy(1 - slippage - serviceFee.fee).toNumber();
499
+ const txb = new transactions_namespaceObject.Transaction();
500
+ let coinIn;
501
+ if (isSuiCoin(quote.from)) {
502
+ coinIn = txb.splitCoins(txb.gas, [
503
+ txb.pure.u64(quote.amount_in)
504
+ ]);
505
+ } else {
506
+ const coins = await (0,astros_aggregator_sdk_namespaceObject.getCoins)(this._suiClient, walletAddress, quote.from);
507
+ const mergedCoins = this.returnMergedCoins(txb, coins.data, Number.parseFloat(quote.amount_in));
508
+ coinIn = txb.splitCoins(mergedCoins, [
509
+ txb.pure.u64(quote.amount_in)
510
+ ]);
511
+ }
512
+ const coinB = await (0,astros_aggregator_sdk_namespaceObject.buildSwapPTBFromQuote)(walletAddress, txb, minAmountOut, coinIn, quote, undefined, false, this._config.astrosApiKey, {
513
+ serviceFee: serviceFee
514
+ });
515
+ txb.transferObjects([
516
+ coinB
517
+ ], walletAddress);
518
+ txb.setSender(walletAddress);
519
+ return txb.build({
520
+ client: this._suiClient
521
+ });
522
+ }
523
+ }
524
+ (function(AstrosAggregator) {
525
+ function toCommonTradeRoutes(tradeRoute, coinInType, coinOutType) {
526
+ if (tradeRoute.routes.length === 0) {
527
+ return null;
528
+ }
529
+ const routes = [];
530
+ for (const route of tradeRoute.routes){
531
+ const paths = [];
532
+ for (const path of route.path){
533
+ paths.push({
534
+ poolAddress: path.id,
535
+ coinIn: path.from,
536
+ coinOut: path.target,
537
+ amountIn: BigInt(path.amount_in),
538
+ amountOut: BigInt(path.amount_out)
539
+ });
540
+ }
541
+ if (paths.length === 0) {
542
+ continue;
543
+ }
544
+ routes.push({
545
+ amountIn: BigInt(route.amount_in),
546
+ amountOut: BigInt(route.amount_out),
547
+ coinIn: paths[0].coinIn,
548
+ coinOut: paths[paths.length - 1].coinOut,
549
+ paths: paths
550
+ });
551
+ }
552
+ if (routes.length === 0) {
553
+ return null;
554
+ }
555
+ return {
556
+ coinIn: coinInType,
557
+ coinOut: coinOutType,
558
+ amountIn: BigInt(tradeRoute.amount_in),
559
+ amountOut: BigInt(tradeRoute.amount_out),
560
+ routes: routes
561
+ };
562
+ }
563
+ AstrosAggregator.toCommonTradeRoutes = toCommonTradeRoutes;
564
+ })(astros_AstrosAggregator || (astros_AstrosAggregator = {}));
565
+
566
+ ;// CONCATENATED MODULE: external "@cetusprotocol/aggregator-sdk"
567
+ const aggregator_sdk_namespaceObject = require("@cetusprotocol/aggregator-sdk");
568
+ ;// CONCATENATED MODULE: external "bn.js"
569
+ const external_bn_js_namespaceObject = require("bn.js");
570
+ var external_bn_js_default = /*#__PURE__*/__webpack_require__.n(external_bn_js_namespaceObject);
571
+ ;// CONCATENATED MODULE: ./src/fee/types.ts
572
+ /**
573
+ * Configuration options for trade fees applied to aggregator transactions
574
+ */ (function(TradeFeeOptions) {
575
+ function equals(a, b) {
576
+ return a.tradeFeePercent === b.tradeFeePercent && a.tradeFeeRecipientAddress === b.tradeFeeRecipientAddress;
577
+ }
578
+ TradeFeeOptions.equals = equals;
579
+ })(types_TradeFeeOptions || (types_TradeFeeOptions = {}));
580
+ var types_TradeFeeOptions;
581
+
582
+ ;// CONCATENATED MODULE: ./src/aggregator/cetus.ts
583
+
584
+
585
+
586
+
587
+ /**
588
+ * Cetus DEX aggregator client for routing trades across multiple pools
589
+ * Cetus is a concentrated liquidity protocol that provides efficient trading
590
+ */ class cetus_CetusAggregator {
591
+ /** Configuration settings for the aggregator */ _config;
592
+ /** Sui blockchain client */ _suiClient;
593
+ /** Cetus aggregator client instance (lazy-loaded) */ _cetusClient;
594
+ /**
595
+ * Creates a new CetusAggregator instance
596
+ * @param config - Aggregator configuration including fee settings and optional API credentials
597
+ * @param suiClient - Sui client for blockchain interactions
598
+ */ constructor(config, suiClient){
599
+ this._config = config;
600
+ this._suiClient = suiClient;
601
+ }
602
+ /**
603
+ * Lazy-loads and returns the Cetus aggregator client, initializing it on first use
604
+ * Configures the client with overlay fees, API credentials, and partner information
605
+ * @param walletAddress - Optional wallet address for signing transactions
606
+ * @param tradeFee - Optional custom trade fee settings for this client instance
607
+ * @returns Initialized Cetus AggregatorClient instance
608
+ */ cetusClient(walletAddress, tradeFee) {
609
+ if (tradeFee && !types_TradeFeeOptions.equals(tradeFee, this._config.defaultTradeFee)) {
610
+ return new aggregator_sdk_namespaceObject.AggregatorClient({
611
+ client: this._suiClient,
612
+ overlayFeeReceiver: tradeFee.tradeFeeRecipientAddress,
613
+ overlayFeeRate: tradeFee.tradeFeePercent,
614
+ env: aggregator_sdk_namespaceObject.Env.Mainnet,
615
+ signer: walletAddress,
616
+ ...this._config.cetusApiKey && this._config.cetusApiEndpoint ? {
617
+ apiKey: this._config.cetusApiKey,
618
+ endpoint: this._config.cetusApiEndpoint
619
+ } : {},
620
+ partner: this._config.cetusPartnerId
621
+ });
622
+ }
623
+ if (this._cetusClient) {
624
+ return this._cetusClient;
625
+ }
626
+ this._cetusClient = new aggregator_sdk_namespaceObject.AggregatorClient({
627
+ client: this._suiClient,
628
+ overlayFeeReceiver: this._config.defaultTradeFee.tradeFeeRecipientAddress,
629
+ overlayFeeRate: this._config.defaultTradeFee.tradeFeePercent,
630
+ env: aggregator_sdk_namespaceObject.Env.Mainnet,
631
+ signer: walletAddress,
632
+ ...this._config.cetusApiKey && this._config.cetusApiEndpoint ? {
633
+ apiKey: this._config.cetusApiKey,
634
+ endpoint: this._config.cetusApiEndpoint
635
+ } : {},
636
+ partner: this._config.cetusPartnerId
637
+ });
638
+ return this._cetusClient;
639
+ }
640
+ /**
641
+ * Finds the optimal trade route for swapping tokens using Cetus aggregator
642
+ * @param params - Trade route parameters
643
+ * @param params.coinInAmount - Amount of input token to swap
644
+ * @param params.coinInType - Type/address of input token
645
+ * @param params.coinOutType - Type/address of output token
646
+ * @returns Promise resolving to router data with pricing and route information, or null if no route found
647
+ */ async getTradeRoute({ coinInAmount, coinInType, coinOutType, tradeFee }) {
648
+ try {
649
+ const client = this.cetusClient(undefined, tradeFee);
650
+ return await client.findRouters({
651
+ from: coinInType,
652
+ target: coinOutType,
653
+ amount: new (external_bn_js_default())(coinInAmount.toString()),
654
+ byAmountIn: true
655
+ });
656
+ } catch (_err) {
657
+ return null;
658
+ }
659
+ }
660
+ /**
661
+ * Builds a transaction for executing a trade route from Cetus aggregator
662
+ * @param params - Transaction parameters
663
+ * @param params.completeRoute - Complete router data from getTradeRoute() (aliased as routers)
664
+ * @param params.walletAddress - Address of the wallet executing the trade
665
+ * @param params.slippage - Maximum acceptable slippage (e.g., 0.01 for 1%)
666
+ * @returns Promise resolving to built transaction bytes ready for signing and execution
667
+ */ async getTransaction({ completeRoute: routers, walletAddress, slippage, tradeFee }) {
668
+ const client = this.cetusClient(walletAddress, tradeFee);
669
+ const txb = new transactions_namespaceObject.Transaction();
670
+ txb.setSender(walletAddress);
671
+ await client.fastRouterSwap({
672
+ router: routers,
673
+ txb,
674
+ slippage
675
+ });
676
+ await client.devInspectTransactionBlock(txb);
677
+ return txb.build({
678
+ client: this._suiClient
679
+ });
680
+ }
681
+ }
682
+ (function(CetusAggregator) {
683
+ function toCommonTradeRoutes(tradeRoute, coinInType, coinOutType) {
684
+ if (tradeRoute.paths.length === 0) {
685
+ return null;
686
+ }
687
+ const routes = [];
688
+ const allPaths = [];
689
+ let currentRoute = [];
690
+ for(let i = 0; i < tradeRoute.paths.length; i++){
691
+ const currentPath = tradeRoute.paths[i];
692
+ const tradePath = {
693
+ poolAddress: currentPath.id,
694
+ amountIn: BigInt(currentPath.amountIn),
695
+ amountOut: BigInt(currentPath.amountOut),
696
+ coinIn: currentPath.from,
697
+ coinOut: currentPath.target
698
+ };
699
+ // Add current path to the current route
700
+ currentRoute.push(tradePath);
701
+ // Check if this is the last path or if the next path starts a new route
702
+ if (i === tradeRoute.paths.length - 1) {
703
+ // This is the last path, finish the current route
704
+ allPaths.push([
705
+ ...currentRoute
706
+ ]);
707
+ } else {
708
+ const nextPath = tradeRoute.paths[i + 1];
709
+ if (currentPath.target !== nextPath.from) {
710
+ // Next path doesn't connect, so current route is complete
711
+ allPaths.push([
712
+ ...currentRoute
713
+ ]);
714
+ currentRoute = []; // Start a new route
715
+ }
716
+ // If currentPath.target === nextPath.from, continue building the current route
717
+ }
718
+ }
719
+ for (const pathGroup of allPaths){
720
+ if (pathGroup.length === 0) {
721
+ continue;
722
+ }
723
+ routes.push({
724
+ amountIn: pathGroup[0].amountIn,
725
+ amountOut: pathGroup[pathGroup.length - 1].amountOut,
726
+ coinIn: pathGroup[0].coinIn,
727
+ coinOut: pathGroup[pathGroup.length - 1].coinOut,
728
+ paths: pathGroup
729
+ });
730
+ }
731
+ if (routes.length === 0) {
732
+ return null;
733
+ }
734
+ return {
735
+ coinIn: coinInType,
736
+ coinOut: coinOutType,
737
+ amountIn: BigInt(tradeRoute.amountIn.toString(10)),
738
+ amountOut: BigInt(tradeRoute.amountOut.toString(10)),
739
+ routes: routes
740
+ };
741
+ }
742
+ CetusAggregator.toCommonTradeRoutes = toCommonTradeRoutes;
743
+ })(cetus_CetusAggregator || (cetus_CetusAggregator = {}));
744
+
745
+ ;// CONCATENATED MODULE: ./src/aggregator/common.ts
746
+ var common_SupportedAggregator = /*#__PURE__*/ function(SupportedAggregator) {
747
+ SupportedAggregator["ASTROS"] = "ASTROS";
748
+ SupportedAggregator["AFTERMATH"] = "AFTERMATH";
749
+ SupportedAggregator["SEVENK"] = "7K";
750
+ SupportedAggregator["CETUS"] = "CETUS";
751
+ SupportedAggregator["FLOWX"] = "FLOWX";
752
+ return SupportedAggregator;
753
+ }({});
754
+
755
+ ;// CONCATENATED MODULE: external "@flowx-finance/sdk"
756
+ const sdk_namespaceObject = require("@flowx-finance/sdk");
757
+ ;// CONCATENATED MODULE: ./src/aggregator/flowx.ts
758
+
759
+ /**
760
+ * Converts percentage to FlowX's expected format (1e6 multiplier)
761
+ * @param percent - Percentage value (e.g., 0.01 for 1%)
762
+ * @returns Percentage in FlowX format (1% = 1,000,000)
763
+ */ function getInputPercent(percent) {
764
+ return 1e6 * percent;
765
+ }
766
+ /**
767
+ * FlowX DEX aggregator client for routing trades across multiple pools
768
+ * FlowX provides liquidity aggregation and optimized routing for Sui ecosystem
769
+ */ class flowx_FlowXAggregator {
770
+ /** Configuration settings for the aggregator */ _config;
771
+ /** Sui blockchain client */ _suiClient;
772
+ /**
773
+ * Creates a new FlowXAggregator instance
774
+ * @param config - Aggregator configuration including fee settings and optional API key
775
+ * @param suiClient - Sui client for blockchain interactions
776
+ */ constructor(config, suiClient){
777
+ this._config = config;
778
+ this._suiClient = suiClient;
779
+ }
780
+ /**
781
+ * Creates a commission configuration for FlowX trades
782
+ * @param coinInType - Type/address of the input coin for commission calculation
783
+ * @param tradeFee - Optional custom trade fee settings for this commission
784
+ * @returns Commission instance configured with fee recipient, percentage, and coin type
785
+ */ getCommission(coinInType, tradeFee) {
786
+ let tradeFeePercent;
787
+ let tradeFeeRecipientAddress;
788
+ if (tradeFee) {
789
+ tradeFeePercent = tradeFee.tradeFeePercent;
790
+ tradeFeeRecipientAddress = tradeFee.tradeFeeRecipientAddress;
791
+ } else {
792
+ tradeFeePercent = this._config.defaultTradeFee.tradeFeePercent;
793
+ tradeFeeRecipientAddress = this._config.defaultTradeFee.tradeFeeRecipientAddress;
794
+ }
795
+ return new sdk_namespaceObject.Commission(tradeFeeRecipientAddress, new sdk_namespaceObject.Coin(coinInType), sdk_namespaceObject.CommissionType.PERCENTAGE, getInputPercent(tradeFeePercent), true);
796
+ }
797
+ /**
798
+ * Finds the optimal trade route for swapping tokens using FlowX aggregator
799
+ * @param params - Trade route parameters
800
+ * @param params.coinInAmount - Amount of input token to swap
801
+ * @param params.coinInType - Type/address of input token
802
+ * @param params.coinOutType - Type/address of output token
803
+ * @returns Promise resolving to routes result with pricing and path information, or null if no route found
804
+ */ async getTradeRoute({ coinInAmount, coinInType, coinOutType, tradeFee }) {
805
+ const quoter = new sdk_namespaceObject.AggregatorQuoter("mainnet", this._config.flowxApiKey);
806
+ try {
807
+ return await quoter.getRoutes({
808
+ tokenIn: coinInType,
809
+ tokenOut: coinOutType,
810
+ amountIn: coinInAmount.toString(),
811
+ commission: this.getCommission(coinInType, tradeFee)
812
+ });
813
+ } catch (_err) {
814
+ return null;
815
+ }
816
+ }
817
+ /**
818
+ * Builds a transaction for executing a trade route from FlowX aggregator
819
+ * @param params - Transaction parameters
820
+ * @param params.walletAddress - Address of the wallet executing the trade
821
+ * @param params.completeRoute - Complete routes result from getTradeRoute()
822
+ * @param params.slippage - Maximum acceptable slippage (e.g., 0.01 for 1%)
823
+ * @returns Promise resolving to built transaction bytes ready for signing and execution
824
+ */ async getTransaction({ walletAddress, completeRoute, slippage, tradeFee }) {
825
+ const tradeBuilder = new sdk_namespaceObject.TradeBuilder("mainnet", completeRoute.routes);
826
+ const result = tradeBuilder.sender(walletAddress).slippage(getInputPercent(slippage)).commission(this.getCommission(completeRoute.coinIn.coinType, tradeFee)).build();
827
+ return result.buildTransaction({
828
+ client: this._suiClient
829
+ }).then((tx)=>{
830
+ tx.setSender(walletAddress);
831
+ return tx.build({
832
+ client: this._suiClient
833
+ });
834
+ });
835
+ }
836
+ }
837
+ (function(FlowXAggregator) {
838
+ function toCommonTradeRoutes(tradeRoute) {
839
+ if (tradeRoute.routes.length === 0) {
840
+ return null;
841
+ }
842
+ const routes = [];
843
+ for (const route of tradeRoute.routes){
844
+ const paths = [];
845
+ for (const path of route.paths){
846
+ paths.push({
847
+ amountIn: BigInt(path.amountIn.toString()),
848
+ amountOut: BigInt(path.amountOut.toString()),
849
+ coinIn: path.input.coinType,
850
+ coinOut: path.output.coinType,
851
+ poolAddress: path.pool.id
852
+ });
853
+ }
854
+ if (paths.length === 0) {
855
+ continue;
856
+ }
857
+ routes.push({
858
+ amountIn: BigInt(route.amountIn.toString()),
859
+ amountOut: BigInt(route.amountOut.toString()),
860
+ coinIn: route.input.coinType,
861
+ coinOut: route.output.coinType,
862
+ paths: paths
863
+ });
864
+ }
865
+ if (routes.length === 0) {
866
+ return null;
867
+ }
868
+ return {
869
+ coinIn: tradeRoute.coinIn.coinType,
870
+ coinOut: tradeRoute.coinOut.coinType,
871
+ amountIn: BigInt(tradeRoute.amountIn.toString()),
872
+ amountOut: BigInt(tradeRoute.amountOut.toString()),
873
+ routes: routes
874
+ };
875
+ }
876
+ FlowXAggregator.toCommonTradeRoutes = toCommonTradeRoutes;
877
+ })(flowx_FlowXAggregator || (flowx_FlowXAggregator = {}));
878
+
879
+ ;// CONCATENATED MODULE: ./src/aggregator/index.ts
880
+
881
+
882
+
883
+
884
+
885
+
886
+
887
+
888
+ ;// CONCATENATED MODULE: ./src/bonding-curve/blast-fun/constants.ts
889
+ (function(BlastFunConstants) {
890
+ BlastFunConstants.PACKAGE_ID_V4 = "0x7e6aa6e179466ab2814425a780b122575296d011119fa69d27f289f5a28814bd";
891
+ BlastFunConstants.MEMEZ_AV_OBJECT_ID = "0x2319e3e76dfad73d8f4684bdbf42be4f32d8ce4521dd61becc8261dc918d82c0";
892
+ })(constants_BlastFunConstants || (constants_BlastFunConstants = {}));
893
+ var constants_BlastFunConstants;
894
+
895
+ ;// CONCATENATED MODULE: external "@minswap/tiny-invariant"
896
+ const tiny_invariant_namespaceObject = require("@minswap/tiny-invariant");
897
+ var tiny_invariant_default = /*#__PURE__*/__webpack_require__.n(tiny_invariant_namespaceObject);
898
+ ;// CONCATENATED MODULE: ./src/libs/move/index.ts
899
+
900
+ async function getMoveObjectContent(suiClient, objectId) {
901
+ const moveObject = await getMoveObject(suiClient, objectId);
902
+ return moveObject.fields;
903
+ }
904
+ async function getMoveObject(suiClient, objectId) {
905
+ const objRes = await suiClient.getObject({
906
+ id: objectId,
907
+ options: {
908
+ showContent: true
909
+ }
910
+ });
911
+ const content = objRes.data?.content;
912
+ tiny_invariant_default()(content, "Pool object not found or has no content");
913
+ tiny_invariant_default()(content.dataType === "moveObject", "Object is not a Move object");
914
+ return content;
915
+ }
916
+
917
+ ;// CONCATENATED MODULE: ./src/libs/math/fee.ts
918
+ const BASE_BPS = 10000;
919
+ function getSplitCoinsAfterFee(amount, fee) {
920
+ const amountNum = BigInt(amount);
921
+ const feeNum = BigInt(Number(fee) * BASE_BPS);
922
+ if (feeNum === BigInt(0)) {
923
+ return [
924
+ amountNum.toString()
925
+ ];
926
+ }
927
+ const feeAmount = amountNum * feeNum / BigInt(BASE_BPS);
928
+ const remainingAmount = amountNum - feeAmount;
929
+ return [
930
+ remainingAmount.toString(),
931
+ feeAmount.toString()
932
+ ];
933
+ }
934
+ function getAmountAfterFee(amount, fee) {
935
+ if (!fee || Number(fee) <= 0) {
936
+ return BigInt(amount);
937
+ }
938
+ const amountNum = BigInt(amount);
939
+ const feeNum = BigInt(Number(fee) * BASE_BPS);
940
+ if (feeNum === BigInt(0)) {
941
+ return amountNum;
942
+ }
943
+ const feeAmount = amountNum * feeNum / BigInt(BASE_BPS);
944
+ return amountNum - feeAmount;
945
+ }
946
+ async function getNeededGasFee(suiClient, tx, sender, bufferPercent) {
947
+ const { effects: { gasUsed, status } } = await suiClient.devInspectTransactionBlock({
948
+ sender,
949
+ transactionBlock: tx
950
+ });
951
+ if (status.status !== "success") {
952
+ throw new Error(`Transaction failed during dev inspect: ${status.error ?? ""}`);
953
+ }
954
+ const fee = BigInt(gasUsed.computationCost) + BigInt(gasUsed.storageCost) - BigInt(gasUsed.storageRebate);
955
+ const feeNum = BigInt(Number(bufferPercent) * BASE_BPS);
956
+ return fee * (BigInt(BASE_BPS) + feeNum) / BigInt(BASE_BPS);
957
+ }
958
+
959
+ ;// CONCATENATED MODULE: ./src/bonding-curve/blast-fun/package.ts
960
+
961
+
962
+ (function(MathUtils) {
963
+ (function(U64) {
964
+ function mulDivUp(a, b, c) {
965
+ let roundUp = BigInt(0);
966
+ if (a * b % c > BigInt(0)) {
967
+ roundUp = BigInt(1);
968
+ }
969
+ return a * b / c + roundUp;
970
+ }
971
+ U64.mulDivUp = mulDivUp;
972
+ })(MathUtils.U64 || (MathUtils.U64 = {}));
973
+ })(package_MathUtils || (package_MathUtils = {}));
974
+ (function(Bps) {
975
+ function calcUp(bps, amount) {
976
+ const bpsValue = BigInt(bps.pos0);
977
+ const denominator = BigInt(10000);
978
+ let roundUp;
979
+ if (bpsValue * amount % denominator !== BigInt(0)) {
980
+ roundUp = BigInt(1);
981
+ } else {
982
+ roundUp = BigInt(0);
983
+ }
984
+ return bpsValue * amount / denominator + roundUp;
985
+ }
986
+ Bps.calcUp = calcUp;
987
+ function sub(lhs, rhs) {
988
+ tiny_invariant_default()(BigInt(lhs.pos0) >= BigInt(rhs.pos0), "Bps underflow");
989
+ return {
990
+ pos0: (BigInt(lhs.pos0) - BigInt(rhs.pos0)).toString()
991
+ };
992
+ }
993
+ Bps.sub = sub;
994
+ function value(bps) {
995
+ return BigInt(bps.pos0);
996
+ }
997
+ Bps.value = value;
998
+ function new_(bps) {
999
+ return {
1000
+ pos0: assertOverflow(bps).toString()
1001
+ };
1002
+ }
1003
+ Bps.new_ = new_;
1004
+ function assertOverflow(bps) {
1005
+ tiny_invariant_default()(BigInt(bps) <= BigInt(10000), "Bps overflow");
1006
+ return BigInt(bps);
1007
+ }
1008
+ Bps.assertOverflow = assertOverflow;
1009
+ })(package_Bps || (package_Bps = {}));
1010
+ (function(BlastFunPackage) {
1011
+ (function(MemezFun) {
1012
+ async function isSniperProtectedMemezFun(suiClient, poolId) {
1013
+ const memezFun = await getMoveObjectContent(suiClient, poolId);
1014
+ return memezFun.public_key.length > 0;
1015
+ }
1016
+ MemezFun.isSniperProtectedMemezFun = isSniperProtectedMemezFun;
1017
+ })(BlastFunPackage.MemezFun || (BlastFunPackage.MemezFun = {}));
1018
+ (function(MemezFees) {
1019
+ function takeWithDiscount(fee, amount, discountBps) {
1020
+ if (fee.variant === "Value") {
1021
+ const amountRequired = BigInt(fee.fields.pos0);
1022
+ if (amountRequired === BigInt(0)) {
1023
+ return BigInt(0);
1024
+ }
1025
+ if (amount >= amountRequired) {
1026
+ return amountRequired;
1027
+ }
1028
+ throw new Error(`Insufficient amount to cover fee. Required: ${amountRequired}, provided: ${amount}`);
1029
+ } else if (fee.variant === "Percentage") {
1030
+ const feeBps = fee.fields.pos0.fields;
1031
+ if (BigInt(feeBps.pos0) === BigInt(0)) {
1032
+ return BigInt(0);
1033
+ }
1034
+ const discountedFee = package_Bps.calcUp(package_Bps.sub(feeBps, discountBps), amount);
1035
+ if (amount >= discountedFee) {
1036
+ return discountedFee;
1037
+ } else {
1038
+ throw new Error(`Insufficient amount to cover fee. Required: ${discountedFee}, provided: ${amount}`);
1039
+ }
1040
+ }
1041
+ throw new Error(`Unknown fee variant`);
1042
+ }
1043
+ // return fee amount taken from `amount`
1044
+ MemezFees.takeWithDiscount = takeWithDiscount;
1045
+ function calculateWithDiscount(fee, discountBps, amount) {
1046
+ if (fee.variant === "Value") {
1047
+ return BigInt(fee.fields.pos0);
1048
+ } else if (fee.variant === "Percentage") {
1049
+ const feeBps = fee.fields.pos0.fields;
1050
+ return package_Bps.calcUp(package_Bps.sub(feeBps, discountBps), amount);
1051
+ }
1052
+ throw new Error(`Unknown fee variant`);
1053
+ }
1054
+ MemezFees.calculateWithDiscount = calculateWithDiscount;
1055
+ })(BlastFunPackage.MemezFees || (BlastFunPackage.MemezFees = {}));
1056
+ (function(MemezBurner) {
1057
+ function calculate(burner, poolMemeBalance) {
1058
+ const burnerFee = package_Bps.value(burner.fee.fields);
1059
+ if (burnerFee === BigInt(0) || poolMemeBalance === BigInt(0)) {
1060
+ return package_Bps.new_(0);
1061
+ }
1062
+ if (poolMemeBalance >= BigInt(burner.target_liquidity)) {
1063
+ return package_Bps.new_(0);
1064
+ }
1065
+ const baseBps = BigInt(10000);
1066
+ return package_Bps.new_(package_MathUtils.U64.mulDivUp(package_Bps.value(burner.fee.fields), package_MathUtils.U64.mulDivUp(poolMemeBalance, baseBps, BigInt(burner.target_liquidity)), baseBps));
1067
+ }
1068
+ MemezBurner.calculate = calculate;
1069
+ })(BlastFunPackage.MemezBurner || (BlastFunPackage.MemezBurner = {}));
1070
+ (function(MemezPump) {
1071
+ async function getPumpState(suiClient, memezFun) {
1072
+ return await getMoveObjectContent(suiClient, memezFun.inner_state);
1073
+ }
1074
+ MemezPump.getPumpState = getPumpState;
1075
+ function pump(pumpState, quoteAmount) {
1076
+ const constantProduct = pumpState.constant_product.fields;
1077
+ const quoteSwapFee = BlastFunPackage.MemezFees.takeWithDiscount(constantProduct.quote_swap_fee, quoteAmount, constantProduct.quote_referrer_fee.fields);
1078
+ const quoteAfterFee = quoteAmount - quoteSwapFee;
1079
+ const memeBalance = BigInt(constantProduct.meme_balance);
1080
+ const quoteBalance = BigInt(constantProduct.quote_balance);
1081
+ const virtualLiquidity = BigInt(constantProduct.virtual_liquidity);
1082
+ const memeOutExpected = memeBalance * quoteAfterFee / (virtualLiquidity + quoteBalance + quoteAfterFee);
1083
+ const memeSwapFee = BlastFunPackage.MemezFees.takeWithDiscount(constantProduct.meme_swap_fee, memeOutExpected, constantProduct.meme_referrer_fee.fields);
1084
+ return memeOutExpected - memeSwapFee;
1085
+ }
1086
+ MemezPump.pump = pump;
1087
+ function dump(pumpState, memeAmount) {
1088
+ const constantProduct = pumpState.constant_product.fields;
1089
+ const memeSwapFee = BlastFunPackage.MemezFees.takeWithDiscount(constantProduct.meme_swap_fee, memeAmount, constantProduct.meme_referrer_fee.fields);
1090
+ const inputAmount = memeAmount - memeSwapFee;
1091
+ const memeBalance = BigInt(constantProduct.meme_balance);
1092
+ const quoteBalance = BigInt(constantProduct.quote_balance);
1093
+ const virtualLiquidity = BigInt(constantProduct.virtual_liquidity);
1094
+ const burnBps = BlastFunPackage.MemezBurner.calculate(constantProduct.burner.fields, quoteBalance);
1095
+ const burnAmount = package_Bps.calcUp(burnBps, inputAmount);
1096
+ const inputAmountAfterFee = inputAmount - (package_Bps.value(burnBps) !== BigInt(0) ? burnAmount : BigInt(0));
1097
+ let quoteOutBeforeFee = (virtualLiquidity + quoteBalance) * inputAmountAfterFee / (memeBalance + inputAmountAfterFee);
1098
+ if (quoteOutBeforeFee > quoteBalance) {
1099
+ quoteOutBeforeFee = quoteBalance;
1100
+ }
1101
+ const quoteSwapFee = BlastFunPackage.MemezFees.takeWithDiscount(constantProduct.quote_swap_fee, quoteOutBeforeFee, constantProduct.quote_referrer_fee.fields);
1102
+ return quoteOutBeforeFee - quoteSwapFee;
1103
+ }
1104
+ MemezPump.dump = dump;
1105
+ })(BlastFunPackage.MemezPump || (BlastFunPackage.MemezPump = {}));
1106
+ })(package_BlastFunPackage || (package_BlastFunPackage = {}));
1107
+ var package_MathUtils, package_Bps, package_BlastFunPackage;
1108
+
1109
+ ;// CONCATENATED MODULE: ./src/bonding-curve/blast-fun/custom-calculation.ts
1110
+
1111
+
1112
+ (function(BlastFunCustomCalculation) {
1113
+ async function getCurveAmountAfterBuy(params, suiClient) {
1114
+ let { suiAmount, poolId, frontendFee } = params;
1115
+ const memezFun = await getMoveObjectContent(suiClient, poolId);
1116
+ const pumpState = await package_BlastFunPackage.MemezPump.getPumpState(suiClient, memezFun);
1117
+ suiAmount = getAmountAfterFee(suiAmount, frontendFee);
1118
+ return package_BlastFunPackage.MemezPump.pump(pumpState, suiAmount);
1119
+ }
1120
+ BlastFunCustomCalculation.getCurveAmountAfterBuy = getCurveAmountAfterBuy;
1121
+ async function getSuiAmountAfterSell(params, suiClient) {
1122
+ const { curveAmount, poolId, frontendFee } = params;
1123
+ const memezFun = await getMoveObjectContent(suiClient, poolId);
1124
+ const pumpState = await package_BlastFunPackage.MemezPump.getPumpState(suiClient, memezFun);
1125
+ const suiAmount = package_BlastFunPackage.MemezPump.dump(pumpState, curveAmount);
1126
+ return getAmountAfterFee(suiAmount, frontendFee);
1127
+ }
1128
+ BlastFunCustomCalculation.getSuiAmountAfterSell = getSuiAmountAfterSell;
1129
+ })(custom_calculation_BlastFunCustomCalculation || (custom_calculation_BlastFunCustomCalculation = {}));
1130
+ var custom_calculation_BlastFunCustomCalculation;
1131
+
1132
+ ;// CONCATENATED MODULE: ./src/constant/sui.ts
1133
+ const SUI_TYPE = "0x2::sui::SUI";
1134
+ const SUI_FULL_TYPE = "0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI";
1135
+ const USDC_TOKEN_TYPE = "0x5d4b302506645c37ff133b98c4b50a5ae14841659738d6d733d59d0d217a93bf::coin::COIN";
1136
+ const NATIVE_USDC_TOKEN_TYPE = "0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC";
1137
+ const SUI_METADATA_OBJECT_ID = "0x9258181f5ceac8dbffb7030890243caed69a9599d2886d957a9cb7656af3bdb3";
1138
+ const CLOCK_OBJECT_ID = "0x0000000000000000000000000000000000000000000000000000000000000006";
1139
+ function isSuiCoinType(coinType) {
1140
+ return coinType === SUI_TYPE || coinType === SUI_FULL_TYPE;
1141
+ }
1142
+
1143
+ ;// CONCATENATED MODULE: external "@mysten/sui/utils"
1144
+ const utils_namespaceObject = require("@mysten/sui/utils");
1145
+ ;// CONCATENATED MODULE: ./src/libs/getCoinOjectIdsByAmount.ts
1146
+ const orderByKey = (array, key, sortBy)=>{
1147
+ if (!array?.length) {
1148
+ return;
1149
+ }
1150
+ let swapped;
1151
+ do {
1152
+ swapped = false;
1153
+ for(let i = 0; i < array.length - 1; i++){
1154
+ const a = BigInt(array[i][key]);
1155
+ const b = BigInt(array[i + 1][key]);
1156
+ if (sortBy === "desc" ? a < b : a > b) {
1157
+ const temp = array[i];
1158
+ array[i] = array[i + 1];
1159
+ array[i + 1] = temp;
1160
+ swapped = true;
1161
+ }
1162
+ }
1163
+ }while (swapped);
1164
+ return array;
1165
+ };
1166
+ const getCoinObjectIdsByAmount = async (suiClient, address, amount, coinType)=>{
1167
+ let coinBalances = [];
1168
+ let hasNextPage = true;
1169
+ let nextCursor;
1170
+ while(hasNextPage){
1171
+ try {
1172
+ const coins = await suiClient.getCoins({
1173
+ owner: address,
1174
+ coinType,
1175
+ cursor: nextCursor
1176
+ });
1177
+ coinBalances = [
1178
+ ...coinBalances,
1179
+ ...coins.data
1180
+ ];
1181
+ hasNextPage = coins.hasNextPage;
1182
+ nextCursor = coins.nextCursor;
1183
+ } catch (error) {
1184
+ console.error("Error fetching data:", error);
1185
+ hasNextPage = false;
1186
+ }
1187
+ }
1188
+ // sort coin balance before get object id
1189
+ const coinObj = orderByKey(coinBalances.map((item)=>{
1190
+ return {
1191
+ ...item,
1192
+ balance: item.balance
1193
+ };
1194
+ }), "balance", "desc") ?? [];
1195
+ let balance = "0";
1196
+ const objectIds = [];
1197
+ const objectCoins = [];
1198
+ for (const coin of coinObj){
1199
+ balance = (BigInt(coin.balance) + BigInt(balance)).toString(10);
1200
+ objectIds.push(coin.coinObjectId);
1201
+ objectCoins.push(coin);
1202
+ if (BigInt(balance) >= BigInt(amount)) {
1203
+ break;
1204
+ }
1205
+ }
1206
+ return {
1207
+ objectIds,
1208
+ balance,
1209
+ objectCoins
1210
+ };
1211
+ };
1212
+
1213
+ ;// CONCATENATED MODULE: ./src/libs/getSplitCoinForTx.ts
1214
+
1215
+
1216
+
1217
+
1218
+ async function getSplitCoinForTx(params, suiClient) {
1219
+ const { account, amount, splits, coinType, inheritTx, inspecTransaction, isSponsored = false } = params;
1220
+ const tx = inheritTx ?? new transactions_namespaceObject.Transaction();
1221
+ const { objectIds } = await getCoinObjectIdsByAmount(suiClient, account, amount, coinType);
1222
+ const coinObjectId = objectIds[0];
1223
+ if ((0,utils_namespaceObject.normalizeStructTag)(coinType) === (0,utils_namespaceObject.normalizeStructTag)(SUI_FULL_TYPE) && !isSponsored) {
1224
+ let coin;
1225
+ if (inspecTransaction) {
1226
+ if (objectIds.length > 1) {
1227
+ tx.mergeCoins(tx.object(coinObjectId), objectIds.slice(1).map((item)=>tx.object(item)));
1228
+ }
1229
+ coin = tx.splitCoins(tx.object(coinObjectId), splits);
1230
+ } else {
1231
+ coin = tx.splitCoins(tx.gas, splits);
1232
+ }
1233
+ return {
1234
+ tx,
1235
+ coinData: coin
1236
+ };
1237
+ }
1238
+ if (objectIds.length > 1) {
1239
+ tx.mergeCoins(tx.object(coinObjectId), objectIds.slice(1).map((item)=>tx.object(item)));
1240
+ }
1241
+ // split correct amount to swap
1242
+ const coinData = tx.splitCoins(tx.object(coinObjectId), splits);
1243
+ return {
1244
+ tx,
1245
+ coinData
1246
+ };
1247
+ }
1248
+
1249
+ ;// CONCATENATED MODULE: ./src/constant/bluefin.ts
1250
+ const BLUEFIN_PACKAGE_ID = "0x62412b7268c35f3808336aee57a52836501f40b8ba5d936f8ad275e672befd04";
1251
+
1252
+ ;// CONCATENATED MODULE: ./src/libs/bluefin.ts
1253
+
1254
+ (function(BluefinTx) {
1255
+ function transferOrDestroyZeroCoin(tx, coinType, coin, address) {
1256
+ tx.moveCall({
1257
+ target: `${BLUEFIN_PACKAGE_ID}::utils::transfer_or_destroy`,
1258
+ typeArguments: [
1259
+ coinType
1260
+ ],
1261
+ arguments: [
1262
+ coin,
1263
+ tx.pure.address(address)
1264
+ ]
1265
+ });
1266
+ }
1267
+ BluefinTx.transferOrDestroyZeroCoin = transferOrDestroyZeroCoin;
1268
+ })(bluefin_BluefinTx || (bluefin_BluefinTx = {}));
1269
+ var bluefin_BluefinTx;
1270
+
1271
+ ;// CONCATENATED MODULE: ./src/bonding-curve/common/transaction.ts
1272
+
1273
+
1274
+
1275
+
1276
+ async function splitSuiCoinAfterFeeFromBuyTx(params, suiClient) {
1277
+ const { inputAmount, accountAddress, frontendFee, frontendFeeRecipient, extendTx, isSponsored } = params;
1278
+ tiny_invariant_default()(params.inCoinType === SUI_FULL_TYPE || params.inCoinType === SUI_TYPE, "Input must be SUI");
1279
+ const { tx: _tx, coinIn } = extendTx || {};
1280
+ const splitSui = getSplitCoinsAfterFee(inputAmount, frontendFee || "0");
1281
+ const tx = _tx || new transactions_namespaceObject.Transaction();
1282
+ let coinData;
1283
+ if (coinIn) {
1284
+ // Must be SUI
1285
+ coinData = tx.splitCoins(coinIn, splitSui);
1286
+ bluefin_BluefinTx.transferOrDestroyZeroCoin(tx, SUI_FULL_TYPE, coinIn, accountAddress);
1287
+ } else {
1288
+ const { coinData: _data } = await getSplitCoinForTx({
1289
+ account: accountAddress,
1290
+ amount: inputAmount,
1291
+ splits: splitSui,
1292
+ coinType: SUI_FULL_TYPE,
1293
+ inheritTx: tx,
1294
+ isSponsored: isSponsored || false
1295
+ }, suiClient);
1296
+ coinData = _data;
1297
+ }
1298
+ let inputSuiCoin;
1299
+ if (frontendFee && frontendFeeRecipient) {
1300
+ const [_inputSuiCoin, frontendFeeCoin] = coinData;
1301
+ inputSuiCoin = _inputSuiCoin;
1302
+ tx.transferObjects([
1303
+ frontendFeeCoin
1304
+ ], tx.pure.address(frontendFeeRecipient || accountAddress));
1305
+ } else {
1306
+ [inputSuiCoin] = coinData;
1307
+ }
1308
+ return {
1309
+ tx,
1310
+ coinOut: inputSuiCoin
1311
+ };
1312
+ }
1313
+ async function splitSuiCoinAfterFeeFromSellTx(tx, params, suiCoin) {
1314
+ tiny_invariant_default()(params.outCoinType === SUI_FULL_TYPE || params.outCoinType === SUI_TYPE, "Output must be SUI");
1315
+ if (Number(params.frontendFee || 0) <= 0) {
1316
+ return {
1317
+ tx,
1318
+ coinOut: suiCoin
1319
+ };
1320
+ }
1321
+ const suiCoinValue = tx.moveCall({
1322
+ target: `0x2::coin::value`,
1323
+ typeArguments: [
1324
+ params.outCoinType
1325
+ ],
1326
+ arguments: [
1327
+ suiCoin
1328
+ ]
1329
+ });
1330
+ const suiCoinFeeValue = tx.moveCall({
1331
+ target: `${BLUEFIN_PACKAGE_ID}::math::mul_div_u64`,
1332
+ typeArguments: [],
1333
+ arguments: [
1334
+ suiCoinValue,
1335
+ tx.pure.u64(BigInt(Number(params.frontendFee || "0") * /* inlined export .BASE_BPS */ (10000))),
1336
+ tx.pure.u64(BigInt(/* inlined export .BASE_BPS */ (10000)))
1337
+ ]
1338
+ });
1339
+ const suiCoinFee = tx.moveCall({
1340
+ target: `0x2::coin::split`,
1341
+ typeArguments: [
1342
+ params.outCoinType
1343
+ ],
1344
+ arguments: [
1345
+ suiCoin,
1346
+ suiCoinFeeValue
1347
+ ]
1348
+ });
1349
+ tx.transferObjects([
1350
+ suiCoinFee
1351
+ ], tx.pure.address(params.frontendFeeRecipient || params.accountAddress));
1352
+ return {
1353
+ tx,
1354
+ coinOut: suiCoin
1355
+ };
1356
+ }
1357
+
1358
+ ;// CONCATENATED MODULE: ./src/bonding-curve/blast-fun/custom-transaction.ts
1359
+
1360
+
1361
+
1362
+
1363
+
1364
+
1365
+
1366
+ (function(BlastFunCustomTransaction) {
1367
+ async function getAllowedVersions(_tx) {
1368
+ const tx = _tx || new transactions_namespaceObject.Transaction();
1369
+ return tx.moveCall({
1370
+ target: `${constants_BlastFunConstants.PACKAGE_ID_V4}::memez_allowed_versions::get_allowed_versions`,
1371
+ arguments: [
1372
+ tx.object(constants_BlastFunConstants.MEMEZ_AV_OBJECT_ID)
1373
+ ],
1374
+ typeArguments: []
1375
+ });
1376
+ }
1377
+ BlastFunCustomTransaction.getAllowedVersions = getAllowedVersions;
1378
+ async function buildBuyTx(params, suiClient) {
1379
+ 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.");
1380
+ const { tx, coinOut: suiCoinIn } = await splitSuiCoinAfterFeeFromBuyTx(params, suiClient);
1381
+ tiny_invariant_default()(suiCoinIn, "Coin out is required");
1382
+ const curveCoin = tx.moveCall({
1383
+ target: `${constants_BlastFunConstants.PACKAGE_ID_V4}::memez_pump::pump`,
1384
+ typeArguments: [
1385
+ params.outCoinType,
1386
+ SUI_FULL_TYPE
1387
+ ],
1388
+ arguments: [
1389
+ tx.object(params.poolId),
1390
+ suiCoinIn,
1391
+ tx.pure.vector("address", []),
1392
+ tx.pure.vector("vector<u8>", []),
1393
+ tx.pure.u64(params.minAmountOut),
1394
+ await getAllowedVersions(tx)
1395
+ ]
1396
+ });
1397
+ return {
1398
+ tx,
1399
+ coinOut: curveCoin
1400
+ };
1401
+ }
1402
+ BlastFunCustomTransaction.buildBuyTx = buildBuyTx;
1403
+ async function buildSellTx(params, suiClient) {
1404
+ tiny_invariant_default()(params.outCoinType === SUI_FULL_TYPE || params.outCoinType === SUI_TYPE, "Output must be SUI");
1405
+ const memezFun = await getMoveObjectContent(suiClient, params.poolId);
1406
+ const { tx, coinData } = await getSplitCoinForTx({
1407
+ amount: params.inputAmount,
1408
+ coinType: params.inCoinType,
1409
+ inheritTx: params.extendTx?.tx,
1410
+ account: params.accountAddress,
1411
+ splits: [
1412
+ params.inputAmount
1413
+ ]
1414
+ }, suiClient);
1415
+ const [inputCoin] = coinData;
1416
+ const [suiCoin] = tx.moveCall({
1417
+ target: `${constants_BlastFunConstants.PACKAGE_ID_V4}::memez_pump::dump`,
1418
+ typeArguments: [
1419
+ params.inCoinType,
1420
+ params.outCoinType
1421
+ ],
1422
+ arguments: [
1423
+ tx.object(params.poolId),
1424
+ tx.object(memezFun.ipx_meme_coin_treasury),
1425
+ inputCoin,
1426
+ tx.pure.vector("address", []),
1427
+ tx.pure.u64(params.minAmountOut),
1428
+ await getAllowedVersions(tx)
1429
+ ]
1430
+ });
1431
+ return await splitSuiCoinAfterFeeFromSellTx(tx, params, suiCoin);
1432
+ }
1433
+ BlastFunCustomTransaction.buildSellTx = buildSellTx;
1434
+ })(custom_transaction_BlastFunCustomTransaction || (custom_transaction_BlastFunCustomTransaction = {}));
1435
+ var custom_transaction_BlastFunCustomTransaction;
1436
+
1437
+ ;// CONCATENATED MODULE: external "@interest-protocol/memez-fun-sdk"
1438
+ const memez_fun_sdk_namespaceObject = require("@interest-protocol/memez-fun-sdk");
1439
+ ;// CONCATENATED MODULE: external "@interest-protocol/sui-core-sdk"
1440
+ const sui_core_sdk_namespaceObject = require("@interest-protocol/sui-core-sdk");
1441
+ ;// CONCATENATED MODULE: external "@mysten/sui/client"
1442
+ const client_namespaceObject = require("@mysten/sui/client");
1443
+ ;// CONCATENATED MODULE: ./src/bonding-curve/blast-fun/meme-pump-sdk.ts
1444
+
1445
+
1446
+
1447
+ const payload = {
1448
+ network: sui_core_sdk_namespaceObject.Network.MAINNET,
1449
+ fullNodeUrl: (0,client_namespaceObject.getFullnodeUrl)("mainnet")
1450
+ };
1451
+ const memezPump = new memez_fun_sdk_namespaceObject.MemezPumpSDK(payload);
1452
+ function getMemezPumpSDK() {
1453
+ return memezPump;
1454
+ }
1455
+
1456
+ ;// CONCATENATED MODULE: ./src/bonding-curve/blast-fun/sdk-calculation.ts
1457
+
1458
+
1459
+ (function(BlastFunSDKCalculation) {
1460
+ async function getCurveAmountAfterBuy(params) {
1461
+ let { suiAmount, poolId, frontendFee } = params;
1462
+ suiAmount = getAmountAfterFee(suiAmount, frontendFee);
1463
+ const { memeAmountOut } = await getMemezPumpSDK().quotePump({
1464
+ pool: poolId,
1465
+ amount: suiAmount
1466
+ });
1467
+ return memeAmountOut;
1468
+ }
1469
+ BlastFunSDKCalculation.getCurveAmountAfterBuy = getCurveAmountAfterBuy;
1470
+ async function getSuiAmountAfterSell(params) {
1471
+ const { curveAmount, poolId, frontendFee } = params;
1472
+ const { quoteAmountOut } = await getMemezPumpSDK().quoteDump({
1473
+ pool: poolId,
1474
+ amount: curveAmount
1475
+ });
1476
+ return getAmountAfterFee(quoteAmountOut, frontendFee);
1477
+ }
1478
+ BlastFunSDKCalculation.getSuiAmountAfterSell = getSuiAmountAfterSell;
1479
+ })(sdk_calculation_BlastFunSDKCalculation || (sdk_calculation_BlastFunSDKCalculation = {}));
1480
+ var sdk_calculation_BlastFunSDKCalculation;
1481
+
1482
+ ;// CONCATENATED MODULE: ./src/libs/addGasFee.ts
1483
+
1484
+
1485
+
1486
+ async function addGasFee(params, suiClient) {
1487
+ const { inheritTx, sender, feeAmount, suiInputAmount } = params;
1488
+ const tx = inheritTx || new transactions_namespaceObject.Transaction();
1489
+ tx.setGasBudget(feeAmount);
1490
+ const { objectCoins } = await getCoinObjectIdsByAmount(suiClient, sender, (BigInt(suiInputAmount || "0") + feeAmount).toString(), SUI_FULL_TYPE);
1491
+ tx.setGasPayment(objectCoins.map((c)=>({
1492
+ objectId: c.coinObjectId,
1493
+ version: c.version,
1494
+ digest: c.digest
1495
+ })));
1496
+ return tx;
1497
+ }
1498
+
1499
+ ;// CONCATENATED MODULE: ./src/bonding-curve/blast-fun/sdk-transaction.ts
1500
+
1501
+
1502
+
1503
+
1504
+
1505
+
1506
+
1507
+
1508
+ (function(BlastFunSDKTransaction) {
1509
+ async function buildBuyTx(params, suiClient) {
1510
+ const { tx, coinOut: suiCoinIn } = await splitSuiCoinAfterFeeFromBuyTx(params, suiClient);
1511
+ tiny_invariant_default()(suiCoinIn, "Coin out is required");
1512
+ const { memeCoin, tx: tx2 } = await getMemezPumpSDK().pump({
1513
+ pool: params.poolId,
1514
+ quoteCoin: suiCoinIn,
1515
+ minAmountOut: params.minAmountOut,
1516
+ tx
1517
+ });
1518
+ return {
1519
+ tx: tx2,
1520
+ coinOut: memeCoin
1521
+ };
1522
+ }
1523
+ BlastFunSDKTransaction.buildBuyTx = buildBuyTx;
1524
+ async function buildSellTx(params, suiClient) {
1525
+ tiny_invariant_default()(isSuiCoinType(params.outCoinType), "Output must be SUI");
1526
+ const { tx, coinData } = await getSplitCoinForTx({
1527
+ amount: params.inputAmount,
1528
+ coinType: params.inCoinType,
1529
+ inheritTx: params.extendTx?.tx,
1530
+ account: params.accountAddress,
1531
+ splits: [
1532
+ params.inputAmount
1533
+ ]
1534
+ }, suiClient);
1535
+ const [inputCoin] = coinData;
1536
+ const { quoteCoin, tx: tx2 } = await getMemezPumpSDK().dump({
1537
+ pool: params.poolId,
1538
+ memeCoin: inputCoin,
1539
+ tx,
1540
+ minAmountOut: params.minAmountOut
1541
+ });
1542
+ return await splitSuiCoinAfterFeeFromSellTx(tx2, params, quoteCoin);
1543
+ }
1544
+ BlastFunSDKTransaction.buildSellTx = buildSellTx;
1545
+ async function getBuyTransaction({ coinInAmount, coinInType, coinOutType, poolId, slippage, walletAddress, tradeFee }, suiClient) {
1546
+ tiny_invariant_default()(isSuiCoinType(coinInType), "coinInType must be SUI for buy transaction");
1547
+ tiny_invariant_default()(coinOutType !== coinInType, "coinOutType must be different from coinInType");
1548
+ tiny_invariant_default()(slippage >= 0 && slippage < 1, "slippage must be between 0 (inclusive) and 1 (exclusive)");
1549
+ tiny_invariant_default()(coinInAmount > 0, "coinInAmount must be greater than 0");
1550
+ const inputAmount = coinInAmount;
1551
+ const outputAmount = await sdk_calculation_BlastFunSDKCalculation.getCurveAmountAfterBuy({
1552
+ poolId: poolId,
1553
+ suiAmount: inputAmount,
1554
+ frontendFee: tradeFee ? tradeFee.tradeFeePercent : undefined
1555
+ });
1556
+ const minAmountOut = BigInt(new (external_bignumber_js_default())(outputAmount.toString()).multipliedBy(1 - slippage).toFixed(0, 3));
1557
+ let { tx, coinOut } = await buildBuyTx({
1558
+ accountAddress: walletAddress,
1559
+ inCoinType: coinInType,
1560
+ outCoinType: coinOutType,
1561
+ inputAmount: inputAmount.toString(),
1562
+ minAmountOut: minAmountOut.toString(),
1563
+ poolId: poolId,
1564
+ frontendFee: tradeFee ? tradeFee.tradeFeePercent : undefined,
1565
+ frontendFeeRecipient: tradeFee ? tradeFee.tradeFeeRecipientAddress : undefined,
1566
+ extendTx: undefined,
1567
+ isSponsored: false
1568
+ }, suiClient);
1569
+ tiny_invariant_default()(coinOut, "Coin out is required");
1570
+ tx.transferObjects([
1571
+ coinOut
1572
+ ], tx.pure.address(walletAddress));
1573
+ tx.setSender(walletAddress);
1574
+ const feeAmount = await getNeededGasFee(suiClient, tx, walletAddress, 0);
1575
+ tx = await addGasFee({
1576
+ inheritTx: tx,
1577
+ sender: walletAddress,
1578
+ feeAmount,
1579
+ suiInputAmount: inputAmount
1580
+ }, suiClient);
1581
+ return tx.build({
1582
+ client: suiClient
1583
+ });
1584
+ }
1585
+ BlastFunSDKTransaction.getBuyTransaction = getBuyTransaction;
1586
+ async function getSellTransaction({ coinInAmount, coinInType, coinOutType, poolId, slippage, walletAddress, tradeFee }, suiClient) {
1587
+ tiny_invariant_default()(isSuiCoinType(coinOutType), "coinOutType must be SUI for sell transaction");
1588
+ tiny_invariant_default()(coinOutType !== coinInType, "coinOutType must be different from coinInType");
1589
+ tiny_invariant_default()(slippage >= 0 && slippage < 1, "slippage must be between 0 (inclusive) and 1 (exclusive)");
1590
+ tiny_invariant_default()(coinInAmount > 0, "coinInAmount must be greater than 0");
1591
+ const inputAmount = coinInAmount;
1592
+ const outputAmount = await sdk_calculation_BlastFunSDKCalculation.getSuiAmountAfterSell({
1593
+ poolId: poolId,
1594
+ curveAmount: inputAmount,
1595
+ frontendFee: tradeFee ? tradeFee.tradeFeePercent : undefined
1596
+ });
1597
+ const minAmountOut = BigInt(new (external_bignumber_js_default())(outputAmount.toString()).multipliedBy(1 - slippage).toFixed(0, 3));
1598
+ let { tx, coinOut } = await buildSellTx({
1599
+ accountAddress: walletAddress,
1600
+ inCoinType: coinInType,
1601
+ outCoinType: coinOutType,
1602
+ inputAmount: inputAmount.toString(),
1603
+ minAmountOut: minAmountOut.toString(),
1604
+ poolId: poolId,
1605
+ frontendFee: tradeFee ? tradeFee.tradeFeePercent : undefined,
1606
+ frontendFeeRecipient: tradeFee ? tradeFee.tradeFeeRecipientAddress : undefined,
1607
+ extendTx: undefined,
1608
+ isSponsored: false
1609
+ }, suiClient);
1610
+ tiny_invariant_default()(coinOut, "Coin out is required");
1611
+ tx.transferObjects([
1612
+ coinOut
1613
+ ], tx.pure.address(walletAddress));
1614
+ tx.setSender(walletAddress);
1615
+ const feeAmount = await getNeededGasFee(suiClient, tx, walletAddress, 0);
1616
+ tx = await addGasFee({
1617
+ inheritTx: tx,
1618
+ sender: walletAddress,
1619
+ feeAmount
1620
+ }, suiClient);
1621
+ return tx.build({
1622
+ client: suiClient
1623
+ });
1624
+ }
1625
+ BlastFunSDKTransaction.getSellTransaction = getSellTransaction;
1626
+ })(sdk_transaction_BlastFunSDKTransaction || (sdk_transaction_BlastFunSDKTransaction = {}));
1627
+ var sdk_transaction_BlastFunSDKTransaction;
1628
+
1629
+ ;// CONCATENATED MODULE: ./src/bonding-curve/blast-fun/index.ts
1630
+
1631
+
1632
+
1633
+
1634
+
1635
+
1636
+
1637
+
1638
+ ;// CONCATENATED MODULE: ./src/bonding-curve/common/types.ts
1639
+ var types_SupportedBondingCurve = /*#__PURE__*/ function(SupportedBondingCurve) {
1640
+ SupportedBondingCurve["BLAST_FUN"] = "BLAST_FUN";
1641
+ SupportedBondingCurve["MOONBAGS"] = "MOONBAGS";
1642
+ return SupportedBondingCurve;
1643
+ }({});
1644
+
1645
+ ;// CONCATENATED MODULE: ./src/bonding-curve/common/index.ts
1646
+
1647
+
1648
+
1649
+ ;// CONCATENATED MODULE: ./src/bonding-curve/moonbags/constants.ts
1650
+ (function(MoonbagsConstants) {
1651
+ MoonbagsConstants.PACKAGE_ID = "0xb8df325010942634a4afb3db3901ee215546af43a4ec4af781e7213b0bba7290";
1652
+ MoonbagsConstants.CONFIG_OBJECT_ID = "0x74aecf86067c6913960ba4925333aefd2b1f929cafca7e21fd55a8f244b70499";
1653
+ MoonbagsConstants.LOCK_CONFIG_OBJECT_ID = "0xfb09822d9808980abd04c51321adb850701f5f55535c6206658ef4d910c3e9be";
1654
+ MoonbagsConstants.BURN_MANAGER_OBJECT_ID = "0x1d94aa32518d0cb00f9de6ed60d450c9a2090761f326752ffad06b2e9404f845";
1655
+ MoonbagsConstants.POOLS_OBJECT_ID = "0xf699e7f2276f5c9a75944b37a0c5b5d9ddfd2471bf6242483b03ab2887d198d0";
1656
+ MoonbagsConstants.GLOBAL_CONFIG_OBJECT_ID = "0xdaa46292632c3c4d8f31f23ea0f9b36a28ff3677e9684980e4438403a67a3d8f";
1657
+ MoonbagsConstants.FEE_DENOMINATOR = BigInt(10000);
1658
+ })(constants_MoonbagsConstants || (constants_MoonbagsConstants = {}));
1659
+ var constants_MoonbagsConstants;
1660
+
1661
+ ;// CONCATENATED MODULE: ./src/bonding-curve/moonbags/package.ts
1662
+
1663
+
1664
+ (function(MoonbagsPackage) {
1665
+ (function(Curves) {
1666
+ function calculateAddLiquidityCost(tokenIn, tokenReserve, tokenAmount) {
1667
+ const availableReserve = tokenReserve - tokenAmount;
1668
+ const numerator = tokenIn * tokenReserve;
1669
+ const fraction = numerator / availableReserve;
1670
+ return fraction - tokenIn;
1671
+ }
1672
+ Curves.calculateAddLiquidityCost = calculateAddLiquidityCost;
1673
+ function calculateRemoveLiquidityReturn(tokenIn, tokenReserve, tokenRemoved) {
1674
+ const denominator = tokenIn + tokenRemoved;
1675
+ const fraction = tokenIn * tokenReserve / denominator;
1676
+ return tokenReserve - fraction;
1677
+ }
1678
+ Curves.calculateRemoveLiquidityReturn = calculateRemoveLiquidityReturn;
1679
+ function calculateTokenAmountReceived(tokenIn, tokenReserve, tokenOutReserve) {
1680
+ const denominator = tokenIn + tokenOutReserve;
1681
+ const fraction = tokenIn * tokenReserve / denominator;
1682
+ return tokenReserve - fraction;
1683
+ }
1684
+ Curves.calculateTokenAmountReceived = calculateTokenAmountReceived;
1685
+ })(MoonbagsPackage.Curves || (MoonbagsPackage.Curves = {}));
1686
+ (function(Moonbags) {
1687
+ async function getDynamicVirtualTokenReserves(suiClient, poolId) {
1688
+ const result = await suiClient.getDynamicFieldObject({
1689
+ parentId: poolId,
1690
+ name: {
1691
+ type: "vector<u8>",
1692
+ value: "virtual_token_reserves"
1693
+ }
1694
+ });
1695
+ if (!result.data) {
1696
+ return undefined;
1697
+ }
1698
+ return BigInt(result.data.content.fields.value);
1699
+ }
1700
+ Moonbags.getDynamicVirtualTokenReserves = getDynamicVirtualTokenReserves;
1701
+ function buyExactInReturnsWithLock(params) {
1702
+ const { inputAmount, amountIn, pool, config, dynamicVirtualTokenReserves } = params;
1703
+ const virtualSuiReserves = BigInt(pool.virtual_sui_reserves);
1704
+ const virtualTokenReserves = BigInt(pool.virtual_token_reserves);
1705
+ const remainTokenReserves = BigInt(pool.remain_token_reserves.fields.balance);
1706
+ const expectedOut = MoonbagsPackage.Curves.calculateRemoveLiquidityReturn(virtualSuiReserves, virtualTokenReserves, amountIn);
1707
+ const availableOut = virtualTokenReserves - (dynamicVirtualTokenReserves || remainTokenReserves);
1708
+ let finalOut = expectedOut;
1709
+ let usedSui = amountIn;
1710
+ if (expectedOut > availableOut) {
1711
+ finalOut = availableOut;
1712
+ usedSui = MoonbagsPackage.Curves.calculateAddLiquidityCost(virtualSuiReserves, virtualTokenReserves, availableOut) + BigInt(1);
1713
+ }
1714
+ const feeAmount = usedSui * BigInt(config.platform_fee) / constants_MoonbagsConstants.FEE_DENOMINATOR;
1715
+ tiny_invariant_default()(inputAmount >= usedSui + feeAmount, "Input amount is less than used SUI + fee");
1716
+ return {
1717
+ receivedCurve: finalOut,
1718
+ receivedSui: inputAmount - usedSui - feeAmount
1719
+ };
1720
+ }
1721
+ Moonbags.buyExactInReturnsWithLock = buyExactInReturnsWithLock;
1722
+ function sellReturns(params) {
1723
+ const { amountIn, pool, config } = params;
1724
+ const virtualSuiReserves = BigInt(pool.virtual_sui_reserves);
1725
+ const virtualTokenReserves = BigInt(pool.virtual_token_reserves);
1726
+ const realSuiReserves = BigInt(pool.real_sui_reserves.fields.balance);
1727
+ let rawSuiOut = MoonbagsPackage.Curves.calculateRemoveLiquidityReturn(virtualTokenReserves, virtualSuiReserves, amountIn);
1728
+ if (rawSuiOut > realSuiReserves) {
1729
+ rawSuiOut = realSuiReserves;
1730
+ }
1731
+ const feeAmount = rawSuiOut * BigInt(config.platform_fee) / constants_MoonbagsConstants.FEE_DENOMINATOR;
1732
+ const finalSuiOut = rawSuiOut - feeAmount;
1733
+ return {
1734
+ receivedCurve: BigInt(0),
1735
+ receivedSui: finalSuiOut
1736
+ };
1737
+ }
1738
+ Moonbags.sellReturns = sellReturns;
1739
+ })(MoonbagsPackage.Moonbags || (MoonbagsPackage.Moonbags = {}));
1740
+ })(package_MoonbagsPackage || (package_MoonbagsPackage = {}));
1741
+ var package_MoonbagsPackage;
1742
+
1743
+ ;// CONCATENATED MODULE: ./src/bonding-curve/moonbags/calculation.ts
1744
+
1745
+
1746
+
1747
+ (function(MoonbagsCalculation) {
1748
+ async function getCurveAmountAfterBuy(params, suiClient) {
1749
+ let { suiAmount, poolId, frontendFee } = params;
1750
+ const [poolMoveStruct, configMoveStruct, dynamicVirtualTokenReserves] = await Promise.all([
1751
+ getMoveObjectContent(suiClient, poolId),
1752
+ getMoveObjectContent(suiClient, constants_MoonbagsConstants.CONFIG_OBJECT_ID),
1753
+ package_MoonbagsPackage.Moonbags.getDynamicVirtualTokenReserves(suiClient, poolId)
1754
+ ]);
1755
+ const pool = poolMoveStruct;
1756
+ const config = configMoveStruct;
1757
+ if (frontendFee !== undefined) {
1758
+ suiAmount = getAmountAfterFee(suiAmount, frontendFee);
1759
+ }
1760
+ const usedSui = suiAmount * constants_MoonbagsConstants.FEE_DENOMINATOR / (constants_MoonbagsConstants.FEE_DENOMINATOR + BigInt(config.platform_fee));
1761
+ const { receivedCurve } = package_MoonbagsPackage.Moonbags.buyExactInReturnsWithLock({
1762
+ inputAmount: suiAmount,
1763
+ amountIn: usedSui,
1764
+ pool,
1765
+ config,
1766
+ dynamicVirtualTokenReserves
1767
+ });
1768
+ return receivedCurve;
1769
+ }
1770
+ MoonbagsCalculation.getCurveAmountAfterBuy = getCurveAmountAfterBuy;
1771
+ async function getSuiAmountAfterSell(params, suiClient) {
1772
+ const { curveAmount, poolId, frontendFee } = params;
1773
+ const [poolMoveStruct, configMoveStruct] = await Promise.all([
1774
+ getMoveObjectContent(suiClient, poolId),
1775
+ getMoveObjectContent(suiClient, constants_MoonbagsConstants.CONFIG_OBJECT_ID)
1776
+ ]);
1777
+ const pool = poolMoveStruct;
1778
+ const config = configMoveStruct;
1779
+ const { receivedSui } = package_MoonbagsPackage.Moonbags.sellReturns({
1780
+ amountIn: curveAmount,
1781
+ pool,
1782
+ config
1783
+ });
1784
+ if (frontendFee !== undefined) {
1785
+ return getAmountAfterFee(receivedSui, frontendFee);
1786
+ }
1787
+ return receivedSui;
1788
+ }
1789
+ MoonbagsCalculation.getSuiAmountAfterSell = getSuiAmountAfterSell;
1790
+ async function getUsedSuiForTx(params, suiClient) {
1791
+ let { suiAmount, frontendFee } = params;
1792
+ const configMoveStruct = await getMoveObjectContent(suiClient, constants_MoonbagsConstants.CONFIG_OBJECT_ID);
1793
+ const config = configMoveStruct;
1794
+ if (frontendFee !== undefined) {
1795
+ suiAmount = getAmountAfterFee(suiAmount, frontendFee);
1796
+ }
1797
+ return suiAmount * constants_MoonbagsConstants.FEE_DENOMINATOR / (constants_MoonbagsConstants.FEE_DENOMINATOR + BigInt(config.platform_fee));
1798
+ }
1799
+ MoonbagsCalculation.getUsedSuiForTx = getUsedSuiForTx;
1800
+ })(calculation_MoonbagsCalculation || (calculation_MoonbagsCalculation = {}));
1801
+ var calculation_MoonbagsCalculation;
1802
+
1803
+ ;// CONCATENATED MODULE: ./src/bonding-curve/moonbags/transaction.ts
1804
+
1805
+
1806
+
1807
+
1808
+
1809
+
1810
+
1811
+
1812
+ (function(MoonbagsTransaction) {
1813
+ async function buildBuyTx(params, suiClient) {
1814
+ const { tx, coinOut } = await splitSuiCoinAfterFeeFromBuyTx(params, suiClient);
1815
+ tiny_invariant_default()(coinOut, "Coin out is required");
1816
+ const usedSui = await calculation_MoonbagsCalculation.getUsedSuiForTx({
1817
+ suiAmount: BigInt(params.inputAmount),
1818
+ frontendFee: params.frontendFee
1819
+ }, suiClient);
1820
+ const [suiCoin, curveCoin] = tx.moveCall({
1821
+ target: `${constants_MoonbagsConstants.PACKAGE_ID}::moonbags::buy_exact_in_returns_with_lock`,
1822
+ typeArguments: [
1823
+ params.outCoinType
1824
+ ],
1825
+ arguments: [
1826
+ tx.object(constants_MoonbagsConstants.CONFIG_OBJECT_ID),
1827
+ tx.object(constants_MoonbagsConstants.LOCK_CONFIG_OBJECT_ID),
1828
+ coinOut,
1829
+ tx.pure.u64(usedSui),
1830
+ tx.pure.u64(params.minAmountOut),
1831
+ tx.object(constants_MoonbagsConstants.BURN_MANAGER_OBJECT_ID),
1832
+ tx.object(constants_MoonbagsConstants.POOLS_OBJECT_ID),
1833
+ tx.object(constants_MoonbagsConstants.GLOBAL_CONFIG_OBJECT_ID),
1834
+ tx.object(SUI_METADATA_OBJECT_ID),
1835
+ tx.object(CLOCK_OBJECT_ID)
1836
+ ]
1837
+ });
1838
+ bluefin_BluefinTx.transferOrDestroyZeroCoin(tx, SUI_FULL_TYPE, suiCoin, params.accountAddress);
1839
+ return {
1840
+ tx,
1841
+ coinOut: curveCoin
1842
+ };
1843
+ }
1844
+ MoonbagsTransaction.buildBuyTx = buildBuyTx;
1845
+ async function buildSellTx(params, suiClient) {
1846
+ tiny_invariant_default()(isSuiCoinType(params.outCoinType), "Output must be SUI");
1847
+ const { tx, coinData } = await getSplitCoinForTx({
1848
+ amount: params.inputAmount,
1849
+ coinType: params.inCoinType,
1850
+ inheritTx: params.extendTx?.tx,
1851
+ account: params.accountAddress,
1852
+ splits: [
1853
+ params.inputAmount
1854
+ ]
1855
+ }, suiClient);
1856
+ const [inputCoin] = coinData;
1857
+ const [suiCoin, curveCoin] = tx.moveCall({
1858
+ target: `${constants_MoonbagsConstants.PACKAGE_ID}::moonbags::sell_returns`,
1859
+ typeArguments: [
1860
+ params.inCoinType
1861
+ ],
1862
+ arguments: [
1863
+ tx.object(constants_MoonbagsConstants.CONFIG_OBJECT_ID),
1864
+ inputCoin,
1865
+ tx.pure.u64(params.minAmountOut),
1866
+ tx.object(CLOCK_OBJECT_ID)
1867
+ ]
1868
+ });
1869
+ bluefin_BluefinTx.transferOrDestroyZeroCoin(tx, params.inCoinType, curveCoin, params.accountAddress);
1870
+ return await splitSuiCoinAfterFeeFromSellTx(tx, params, suiCoin);
1871
+ }
1872
+ MoonbagsTransaction.buildSellTx = buildSellTx;
1873
+ async function getBuyTransaction({ coinInAmount, coinInType, coinOutType, poolId, slippage, walletAddress, tradeFee }, suiClient) {
1874
+ tiny_invariant_default()(isSuiCoinType(coinInType), "coinInType must be SUI for buy transaction");
1875
+ tiny_invariant_default()(coinOutType !== coinInType, "coinOutType must be different from coinInType");
1876
+ tiny_invariant_default()(slippage >= 0 && slippage < 1, "slippage must be between 0 (inclusive) and 1 (exclusive)");
1877
+ tiny_invariant_default()(coinInAmount > 0, "coinInAmount must be greater than 0");
1878
+ const inputAmount = coinInAmount;
1879
+ const outputAmount = await calculation_MoonbagsCalculation.getCurveAmountAfterBuy({
1880
+ poolId: poolId,
1881
+ suiAmount: inputAmount,
1882
+ frontendFee: tradeFee ? tradeFee.tradeFeePercent : undefined
1883
+ }, suiClient);
1884
+ const minAmountOut = BigInt(new (external_bignumber_js_default())(outputAmount.toString()).multipliedBy(1 - slippage).toFixed(0, 3));
1885
+ let { tx, coinOut } = await buildBuyTx({
1886
+ accountAddress: walletAddress,
1887
+ inCoinType: coinInType,
1888
+ outCoinType: coinOutType,
1889
+ inputAmount: inputAmount.toString(),
1890
+ minAmountOut: minAmountOut.toString(),
1891
+ poolId: poolId,
1892
+ frontendFee: tradeFee ? tradeFee.tradeFeePercent : undefined,
1893
+ frontendFeeRecipient: tradeFee ? tradeFee.tradeFeeRecipientAddress : undefined,
1894
+ extendTx: undefined,
1895
+ isSponsored: false
1896
+ }, suiClient);
1897
+ tiny_invariant_default()(coinOut, "Coin out is required");
1898
+ tx.transferObjects([
1899
+ coinOut
1900
+ ], tx.pure.address(walletAddress));
1901
+ tx.setSender(walletAddress);
1902
+ const feeAmount = await getNeededGasFee(suiClient, tx, walletAddress, 0);
1903
+ tx = await addGasFee({
1904
+ inheritTx: tx,
1905
+ sender: walletAddress,
1906
+ feeAmount,
1907
+ suiInputAmount: inputAmount
1908
+ }, suiClient);
1909
+ return tx.build({
1910
+ client: suiClient
1911
+ });
1912
+ }
1913
+ MoonbagsTransaction.getBuyTransaction = getBuyTransaction;
1914
+ async function getSellTransaction({ coinInAmount, coinInType, coinOutType, poolId, slippage, walletAddress, tradeFee }, suiClient) {
1915
+ tiny_invariant_default()(isSuiCoinType(coinOutType), "coinOutType must be SUI for sell transaction");
1916
+ tiny_invariant_default()(coinOutType !== coinInType, "coinOutType must be different from coinInType");
1917
+ tiny_invariant_default()(slippage >= 0 && slippage < 1, "slippage must be between 0 (inclusive) and 1 (exclusive)");
1918
+ tiny_invariant_default()(coinInAmount > 0, "coinInAmount must be greater than 0");
1919
+ const inputAmount = coinInAmount;
1920
+ const outputAmount = await calculation_MoonbagsCalculation.getSuiAmountAfterSell({
1921
+ poolId: poolId,
1922
+ curveAmount: inputAmount,
1923
+ frontendFee: tradeFee ? tradeFee.tradeFeePercent : undefined
1924
+ }, suiClient);
1925
+ const minAmountOut = BigInt(new (external_bignumber_js_default())(outputAmount.toString()).multipliedBy(1 - slippage).toFixed(0, 3));
1926
+ let { tx, coinOut } = await buildSellTx({
1927
+ accountAddress: walletAddress,
1928
+ inCoinType: coinInType,
1929
+ outCoinType: coinOutType,
1930
+ inputAmount: inputAmount.toString(),
1931
+ minAmountOut: minAmountOut.toString(),
1932
+ poolId: poolId,
1933
+ frontendFee: tradeFee ? tradeFee.tradeFeePercent : undefined,
1934
+ frontendFeeRecipient: tradeFee ? tradeFee.tradeFeeRecipientAddress : undefined,
1935
+ extendTx: undefined,
1936
+ isSponsored: false
1937
+ }, suiClient);
1938
+ tiny_invariant_default()(coinOut, "Coin out is required");
1939
+ tx.transferObjects([
1940
+ coinOut
1941
+ ], tx.pure.address(walletAddress));
1942
+ tx.setSender(walletAddress);
1943
+ const feeAmount = await getNeededGasFee(suiClient, tx, walletAddress, 0);
1944
+ tx = await addGasFee({
1945
+ inheritTx: tx,
1946
+ sender: walletAddress,
1947
+ feeAmount
1948
+ }, suiClient);
1949
+ return tx.build({
1950
+ client: suiClient
1951
+ });
1952
+ }
1953
+ MoonbagsTransaction.getSellTransaction = getSellTransaction;
1954
+ })(transaction_MoonbagsTransaction || (transaction_MoonbagsTransaction = {}));
1955
+ var transaction_MoonbagsTransaction;
1956
+
1957
+ ;// CONCATENATED MODULE: ./src/bonding-curve/moonbags/index.ts
1958
+
1959
+
1960
+
1961
+
1962
+
1963
+ ;// CONCATENATED MODULE: ./src/bonding-curve/index.ts
1964
+
1965
+
1966
+
1967
+
1968
+ ;// CONCATENATED MODULE: ./src/constant/index.ts
1969
+
1970
+
1971
+
1972
+ ;// CONCATENATED MODULE: ./src/fee/index.ts
1973
+
1974
+
1975
+ ;// CONCATENATED MODULE: ./src/libs/math/index.ts
1976
+
1977
+
1978
+ ;// CONCATENATED MODULE: ./src/libs/sui-client-adapter.ts
1979
+ /**
1980
+ * Adapter to make SuiClient v1.38 compatible with libraries expecting v1.34
1981
+ * This works around TypeScript type incompatibilities between versions
1982
+ */ function adaptSuiClient(client) {
1983
+ // Return the client with type assertion to bypass strict type checking
1984
+ // The underlying implementation is compatible, just the types differ
1985
+ return client;
1986
+ }
1987
+ /**
1988
+ * Adapter to make Transaction v1.38 compatible with libraries expecting v1.34
1989
+ * This works around TypeScript type incompatibilities between versions
1990
+ */ function adaptTransaction(transaction) {
1991
+ // Return the transaction with type assertion to bypass strict type checking
1992
+ // The underlying implementation is compatible, just the types differ
1993
+ return transaction;
1994
+ }
1995
+ /**
1996
+ * Alternative: Create a proxy that ensures compatibility
1997
+ */ function createCompatibleSuiClient(client) {
1998
+ // You can add any necessary adaptations here if needed
1999
+ return new Proxy(client, {
2000
+ get (target, prop) {
2001
+ const value = target[prop];
2002
+ if (typeof value === "function") {
2003
+ return value.bind(target);
2004
+ }
2005
+ return value;
2006
+ }
2007
+ });
2008
+ }
2009
+
2010
+ ;// CONCATENATED MODULE: ./src/libs/index.ts
2011
+
2012
+
2013
+
2014
+
2015
+
2016
+
2017
+
2018
+
2019
+ ;// CONCATENATED MODULE: ./src/modules/aggregator-module.ts
2020
+
2021
+
2022
+ /**
2023
+ * Main aggregator module that provides unified access to multiple DEX aggregators
2024
+ * Supports routing trades through Cetus, FlowX, Astros, Aftermath, and 7K Protocol
2025
+ */ class AggregatorModule {
2026
+ /** Reference to the main Noodles SDK instance */ sdk;
2027
+ /** Astros/Navi Protocol aggregator instance */ _astrosAggregator;
2028
+ /** Aftermath Finance aggregator instance */ _aftermathAggregator;
2029
+ /** 7K Protocol aggregator instance */ _sevenkAggregator;
2030
+ /** Cetus Protocol aggregator instance */ _cetusAggregator;
2031
+ /** FlowX Finance aggregator instance */ _flowXAggregator;
2032
+ /**
2033
+ * Creates a new AggregatorModule instance with all supported aggregators
2034
+ * @param sdk - The main Noodles SDK instance containing configuration
2035
+ */ constructor(sdk){
2036
+ this.sdk = sdk;
2037
+ this._astrosAggregator = new astros_AstrosAggregator({
2038
+ defaultTradeFee: sdk.options.tradeFee,
2039
+ astrosApiKey: sdk.options.astrosApiKey
2040
+ }, sdk.suiClient);
2041
+ this._aftermathAggregator = new aftermath_AftermathAggregator({
2042
+ defaultTradeFee: sdk.options.tradeFee,
2043
+ aftermathApiKey: sdk.options.aftermathApiKey,
2044
+ aftermathApiEndpoint: sdk.options.aftermathApiEndpoint
2045
+ }, sdk.suiClient);
2046
+ this._sevenkAggregator = new _7k_SevenKAggregator({
2047
+ defaultTradeFee: sdk.options.tradeFee,
2048
+ sevenKApiKey: sdk.options.sevenKApiKey
2049
+ }, sdk.suiClient);
2050
+ this._cetusAggregator = new cetus_CetusAggregator({
2051
+ defaultTradeFee: sdk.options.tradeFee,
2052
+ cetusApiKey: sdk.options.cetusApiKey,
2053
+ cetusApiEndpoint: sdk.options.cetusApiEndpoint,
2054
+ cetusPartnerId: sdk.options.cetusPartnerId
2055
+ }, sdk.suiClient);
2056
+ this._flowXAggregator = new flowx_FlowXAggregator({
2057
+ defaultTradeFee: sdk.options.tradeFee,
2058
+ flowxApiKey: sdk.options.flowxApiKey
2059
+ }, sdk.suiClient);
2060
+ }
2061
+ /** Gets the Astros/Navi Protocol aggregator instance */ get astrosAggregator() {
2062
+ return this._astrosAggregator;
2063
+ }
2064
+ /** Gets the Aftermath Finance aggregator instance */ get aftermathAggregator() {
2065
+ return this._aftermathAggregator;
2066
+ }
2067
+ /** Gets the 7K Protocol aggregator instance */ get sevenkAggregator() {
2068
+ return this._sevenkAggregator;
2069
+ }
2070
+ /** Gets the Cetus Protocol aggregator instance */ get cetusAggregator() {
2071
+ return this._cetusAggregator;
2072
+ }
2073
+ /** Gets the FlowX Finance aggregator instance */ get flowXAggregator() {
2074
+ return this._flowXAggregator;
2075
+ }
2076
+ /**
2077
+ * Finds the optimal trade route using the specified aggregator
2078
+ * @param aggregator - The aggregator to use for route finding
2079
+ * @param params - Trade route parameters including token types and amounts
2080
+ * @returns Promise resolving to route response with both standardized and raw data, or null if no route found
2081
+ */ async getTradeRoute(aggregator, params) {
2082
+ let finalResponse;
2083
+ switch(aggregator){
2084
+ case common_SupportedAggregator.ASTROS:
2085
+ {
2086
+ const tradeRouteResponse = await this._astrosAggregator.getTradeRoute(params);
2087
+ if (!tradeRouteResponse) {
2088
+ return null;
2089
+ }
2090
+ const finalRoutes = astros_AstrosAggregator.toCommonTradeRoutes(tradeRouteResponse, params.coinInType, params.coinOutType);
2091
+ if (!finalRoutes) {
2092
+ return null;
2093
+ }
2094
+ let tradeFeePercent;
2095
+ if (params.tradeFee) {
2096
+ tradeFeePercent = params.tradeFee.tradeFeePercent;
2097
+ } else {
2098
+ tradeFeePercent = this.sdk.options.tradeFee.tradeFeePercent;
2099
+ }
2100
+ /**
2101
+ * Astros route amount_out does not consider the trade fee,
2102
+ * so we need to deduct the trade fee from the final amount_out
2103
+ */ const finalAmountOut = BigInt(new (external_bignumber_js_default())(tradeRouteResponse.amount_out).multipliedBy(1 - tradeFeePercent).toFixed(0, 3));
2104
+ finalRoutes.amountOut = finalAmountOut;
2105
+ finalResponse = {
2106
+ route: finalRoutes,
2107
+ aggregatorRoute: tradeRouteResponse
2108
+ };
2109
+ break;
2110
+ }
2111
+ case common_SupportedAggregator.AFTERMATH:
2112
+ {
2113
+ const tradeRouteResponse = await this._aftermathAggregator.getTradeRoute(params);
2114
+ if (!tradeRouteResponse) {
2115
+ return null;
2116
+ }
2117
+ const finalRoutes = aftermath_AftermathAggregator.toCommonTradeRoutes(tradeRouteResponse);
2118
+ if (!finalRoutes) {
2119
+ return null;
2120
+ }
2121
+ finalResponse = {
2122
+ route: finalRoutes,
2123
+ aggregatorRoute: tradeRouteResponse
2124
+ };
2125
+ break;
2126
+ }
2127
+ case common_SupportedAggregator.SEVENK:
2128
+ {
2129
+ const tradeRouteResponse = await this._sevenkAggregator.getTradeRoute(params);
2130
+ if (!tradeRouteResponse) {
2131
+ return null;
2132
+ }
2133
+ const finalRoutes = _7k_SevenKAggregator.toCommonTradeRoutes(tradeRouteResponse);
2134
+ if (!finalRoutes) {
2135
+ return null;
2136
+ }
2137
+ finalResponse = {
2138
+ route: finalRoutes,
2139
+ aggregatorRoute: tradeRouteResponse
2140
+ };
2141
+ break;
2142
+ }
2143
+ case common_SupportedAggregator.CETUS:
2144
+ {
2145
+ const tradeRouteResponse = await this._cetusAggregator.getTradeRoute(params);
2146
+ if (!tradeRouteResponse) {
2147
+ return null;
2148
+ }
2149
+ const finalRoutes = cetus_CetusAggregator.toCommonTradeRoutes(tradeRouteResponse, params.coinInType, params.coinOutType);
2150
+ if (!finalRoutes) {
2151
+ return null;
2152
+ }
2153
+ finalResponse = {
2154
+ route: finalRoutes,
2155
+ aggregatorRoute: tradeRouteResponse
2156
+ };
2157
+ break;
2158
+ }
2159
+ case common_SupportedAggregator.FLOWX:
2160
+ {
2161
+ const tradeRouteResponse = await this._flowXAggregator.getTradeRoute(params);
2162
+ if (!tradeRouteResponse) {
2163
+ return null;
2164
+ }
2165
+ const finalRoutes = flowx_FlowXAggregator.toCommonTradeRoutes(tradeRouteResponse);
2166
+ if (!finalRoutes) {
2167
+ return null;
2168
+ }
2169
+ finalResponse = {
2170
+ route: finalRoutes,
2171
+ aggregatorRoute: tradeRouteResponse
2172
+ };
2173
+ break;
2174
+ }
2175
+ }
2176
+ return finalResponse;
2177
+ }
2178
+ /**
2179
+ * Builds a transaction from an existing trade route
2180
+ * @param aggregator - The aggregator that generated the route
2181
+ * @param params - Transaction parameters including wallet address, route, and slippage
2182
+ * @returns Promise resolving to built transaction bytes ready for signing and execution
2183
+ */ async getTransactionByRoute(aggregator, params) {
2184
+ switch(aggregator){
2185
+ case common_SupportedAggregator.ASTROS:
2186
+ {
2187
+ return this._astrosAggregator.getTransaction({
2188
+ walletAddress: params.walletAddress,
2189
+ completeRoute: params.completeRoute,
2190
+ slippage: params.slippage,
2191
+ tradeFee: params.tradeFee
2192
+ });
2193
+ }
2194
+ case common_SupportedAggregator.AFTERMATH:
2195
+ {
2196
+ return this._aftermathAggregator.getTransaction({
2197
+ walletAddress: params.walletAddress,
2198
+ completeRoute: params.completeRoute,
2199
+ slippage: params.slippage
2200
+ });
2201
+ }
2202
+ case common_SupportedAggregator.SEVENK:
2203
+ {
2204
+ return this._sevenkAggregator.getTransaction({
2205
+ walletAddress: params.walletAddress,
2206
+ completeRoute: params.completeRoute,
2207
+ slippage: params.slippage,
2208
+ tradeFee: params.tradeFee
2209
+ });
2210
+ }
2211
+ case common_SupportedAggregator.CETUS:
2212
+ {
2213
+ return this._cetusAggregator.getTransaction({
2214
+ walletAddress: params.walletAddress,
2215
+ completeRoute: params.completeRoute,
2216
+ slippage: params.slippage,
2217
+ tradeFee: params.tradeFee
2218
+ });
2219
+ }
2220
+ case common_SupportedAggregator.FLOWX:
2221
+ {
2222
+ return this._flowXAggregator.getTransaction({
2223
+ walletAddress: params.walletAddress,
2224
+ completeRoute: params.completeRoute,
2225
+ slippage: params.slippage,
2226
+ tradeFee: params.tradeFee
2227
+ });
2228
+ }
2229
+ }
2230
+ }
2231
+ /**
2232
+ * Combines route finding and transaction building into a single operation
2233
+ * This is a convenience method that calls getTradeRoute followed by getTransactionByRoute
2234
+ * @param aggregator - The aggregator to use for both route finding and transaction building
2235
+ * @param params - Combined parameters including trade details, wallet address, and slippage
2236
+ * @returns Promise resolving to complete response with route info and built transaction, or null if no route found
2237
+ */ async getTradeTransaction(aggregator, params) {
2238
+ const routeResponse = await this.getTradeRoute(aggregator, {
2239
+ coinInAmount: params.coinInAmount,
2240
+ coinInType: params.coinInType,
2241
+ coinOutType: params.coinOutType,
2242
+ tradeFee: params.tradeFee
2243
+ });
2244
+ if (!routeResponse) {
2245
+ return null;
2246
+ }
2247
+ const transaction = await this.getTransactionByRoute(aggregator, {
2248
+ walletAddress: params.walletAddress,
2249
+ completeRoute: routeResponse.aggregatorRoute,
2250
+ slippage: params.slippage,
2251
+ tradeFee: params.tradeFee
2252
+ });
2253
+ return {
2254
+ route: routeResponse.route,
2255
+ aggregatorRoute: routeResponse.aggregatorRoute,
2256
+ transaction
2257
+ };
2258
+ }
2259
+ /**
2260
+ * Finds the best rate across all aggregators and returns the optimal trade transaction
2261
+ * This method queries all available aggregators and selects the one with the best output amount
2262
+ * @param params - Combined parameters including trade details, wallet address, and slippage
2263
+ * @returns Promise resolving to complete response with route info and built transaction from the best aggregator, or null if no routes found
2264
+ */ async getTradeTransactionWithBestRate(params) {
2265
+ const aggregators = Object.keys(common_SupportedAggregator);
2266
+ const tradeRouteResponses = await Promise.all(aggregators.map(async (aggregator)=>{
2267
+ try {
2268
+ return await this.getTradeRoute(aggregator, params);
2269
+ } catch {
2270
+ return null;
2271
+ }
2272
+ }));
2273
+ let bestResponse = null;
2274
+ let chosenAggregator = null;
2275
+ for(let i = 0; i < tradeRouteResponses.length; i++){
2276
+ const tradeRouteResponse = tradeRouteResponses[i];
2277
+ const aggregator = aggregators[i];
2278
+ if (!tradeRouteResponse) {
2279
+ continue;
2280
+ }
2281
+ if (!bestResponse) {
2282
+ bestResponse = tradeRouteResponse;
2283
+ chosenAggregator = aggregator;
2284
+ continue;
2285
+ }
2286
+ if (tradeRouteResponse.route.amountOut > bestResponse.route.amountOut) {
2287
+ bestResponse = tradeRouteResponse;
2288
+ chosenAggregator = aggregator;
2289
+ continue;
2290
+ }
2291
+ }
2292
+ if (!bestResponse || !chosenAggregator) {
2293
+ return null;
2294
+ }
2295
+ const transaction = await this.getTransactionByRoute(chosenAggregator, {
2296
+ walletAddress: params.walletAddress,
2297
+ completeRoute: bestResponse.aggregatorRoute,
2298
+ slippage: params.slippage,
2299
+ tradeFee: params.tradeFee
2300
+ });
2301
+ return {
2302
+ route: bestResponse.route,
2303
+ aggregatorRoute: bestResponse.aggregatorRoute,
2304
+ transaction
2305
+ };
2306
+ }
2307
+ /**
2308
+ * Gets the expected output amount for a trade using the specified aggregator
2309
+ * This is a lightweight method that only fetches the route and returns the output amount
2310
+ * without building a transaction
2311
+ *
2312
+ * @param aggregator - The aggregator to use for calculating output amount
2313
+ * @param params - Trade route parameters including token types and input amount
2314
+ * @returns Promise resolving to the expected output amount in smallest unit, or null if no route found
2315
+ */ async getAmountOut(aggregator, params) {
2316
+ const tradeRouteResult = await this.getTradeRoute(aggregator, params);
2317
+ if (!tradeRouteResult) {
2318
+ return null;
2319
+ }
2320
+ return tradeRouteResult.route.amountOut;
2321
+ }
2322
+ /**
2323
+ * Finds the best output amount across all aggregators without building a transaction
2324
+ * This method queries all available aggregators in parallel and returns the aggregator
2325
+ * that provides the highest output amount along with that amount
2326
+ *
2327
+ * @param params - Trade route parameters including token types and input amount
2328
+ * @returns Promise resolving to an object containing the best output amount and the aggregator that provided it, or null if no routes found
2329
+ */ async getBestAmountOut(params) {
2330
+ const aggregators = Object.keys(common_SupportedAggregator);
2331
+ let bestAmountOut = null;
2332
+ let bestAggregator = null;
2333
+ for (const aggregator of aggregators){
2334
+ const amountOut = await this.getAmountOut(aggregator, params);
2335
+ if (amountOut === null) {
2336
+ continue;
2337
+ }
2338
+ if (bestAmountOut === null || amountOut > bestAmountOut) {
2339
+ bestAmountOut = amountOut;
2340
+ bestAggregator = aggregator;
2341
+ }
2342
+ }
2343
+ if (bestAmountOut === null || bestAggregator === null) {
2344
+ return null;
2345
+ }
2346
+ return {
2347
+ amountOut: bestAmountOut,
2348
+ aggregator: bestAggregator
2349
+ };
2350
+ }
2351
+ }
2352
+
2353
+ ;// CONCATENATED MODULE: ./src/modules/boosting-module.ts
2354
+
2355
+
2356
+
2357
+
2358
+ /** Sui package ID for the boosting protocol */ const BOOSTING_PACKAGE_ID = "0x25fa0eb553dd69fa6a8028f73a38f1df7f289fa88a58ed3d7dc5a5360155bb19";
2359
+ /** Configuration object ID for boosting settings */ const CONFIG_ID = "0x8b1a8ac6e34688cd8f8f8e5fefa9d5fb9e1ff74d2f132f8e208ae5ac9cc530bb";
2360
+ /** Admin capability object ID for privileged operations */ const ADMIN_CAP_ID = "0x13d101f44a0710a5475bec5f492a87b80e03d92d1cf540f26096f65850b23d26";
2361
+ /**
2362
+ * Module for managing boosting functionality in the Noodles SDK.
2363
+ *
2364
+ * This module provides methods for:
2365
+ * - Paying boosting fees for different tiers
2366
+ * - Managing boosting tiers (admin functions)
2367
+ * - Retrieving boosting configuration
2368
+ * - Updating fee receiver settings
2369
+ */ class BoostingModule {
2370
+ /** Reference to the main SDK instance */ sdk;
2371
+ /**
2372
+ * Creates a new BoostingModule instance.
2373
+ *
2374
+ * @param sdk - The main Noodles Pay SDK instance
2375
+ */ constructor(sdk){
2376
+ this.sdk = sdk;
2377
+ }
2378
+ /**
2379
+ * Retrieves the current boosting configuration from the blockchain.
2380
+ *
2381
+ * @returns Promise resolving to the current boosting configuration
2382
+ * @throws Error if config object is not found or invalid
2383
+ */ async getConfig() {
2384
+ const configObject = await this.sdk.suiClient.getObject({
2385
+ id: CONFIG_ID,
2386
+ options: {
2387
+ showContent: true
2388
+ }
2389
+ });
2390
+ tiny_invariant_default()(configObject.data?.content, "Config object not found or has no content");
2391
+ tiny_invariant_default()(configObject.data?.content.dataType === "moveObject", "Config object is not a Move object");
2392
+ const objectFields = configObject.data.content.fields;
2393
+ const id = objectFields.id.id;
2394
+ const feeReceiver = objectFields.fee_receiver;
2395
+ const tiers = objectFields.tiers.fields.contents;
2396
+ // Parse tier information from blockchain data
2397
+ const tierMap = {};
2398
+ for (const tier of tiers){
2399
+ const key = tier.fields.key;
2400
+ const duration = tier.fields.value.fields.duration;
2401
+ const amount = tier.fields.value.fields.amount;
2402
+ const point = tier.fields.value.fields.point;
2403
+ const originalAmount = tier.fields.value.fields.original_amount;
2404
+ tierMap[key] = {
2405
+ duration: BigInt(duration),
2406
+ amount: BigInt(amount),
2407
+ point: BigInt(point),
2408
+ originalAmount: BigInt(originalAmount)
2409
+ };
2410
+ }
2411
+ return {
2412
+ id,
2413
+ receiverAddress: feeReceiver,
2414
+ tiers: tierMap
2415
+ };
2416
+ }
2417
+ /**
2418
+ * Builds a transaction for paying boosting fees for a specific tier.
2419
+ * The payment amount is determined by the tier configuration.
2420
+ *
2421
+ * @param request - Payment request parameters
2422
+ * @returns Promise resolving to a transaction ready for execution
2423
+ * @throws Error if tier ID is invalid
2424
+ */ async buildPayBoostingTx({ walletAddress, tierId, boostingCoinType, currentTx }) {
2425
+ const configObj = await this.getConfig();
2426
+ tiny_invariant_default()(tierId in configObj.tiers, "Invalid tier ID");
2427
+ const tier = configObj.tiers[tierId];
2428
+ const paymentAmount = tier.amount;
2429
+ const tx = currentTx || new transactions_namespaceObject.Transaction();
2430
+ const paymentCoin = tx.splitCoins(tx.gas, [
2431
+ tx.pure.u64(paymentAmount)
2432
+ ]);
2433
+ tx.moveCall({
2434
+ target: `${BOOSTING_PACKAGE_ID}::boosting::pay`,
2435
+ typeArguments: [
2436
+ (0,utils_namespaceObject.normalizeStructTag)(boostingCoinType)
2437
+ ],
2438
+ arguments: [
2439
+ tx.object(CONFIG_ID),
2440
+ tx.pure.u64(tierId),
2441
+ paymentCoin
2442
+ ]
2443
+ });
2444
+ tx.setSender(walletAddress);
2445
+ const gasAmount = await getNeededGasFee(this.sdk.suiClient, tx, walletAddress, 0);
2446
+ return addGasFee({
2447
+ inheritTx: tx,
2448
+ sender: walletAddress,
2449
+ feeAmount: gasAmount
2450
+ }, this.sdk.suiClient);
2451
+ }
2452
+ /**
2453
+ * Builds a transaction for adding a new boosting tier.
2454
+ *
2455
+ * **Requires admin capability.**
2456
+ *
2457
+ * @param request - Add tier request parameters
2458
+ * @returns Promise resolving to a transaction ready for execution
2459
+ */ async buildAddTierTx({ adminAddress, tierId, duration, point, originalAmount, amount, currentTx }) {
2460
+ const tx = currentTx || new transactions_namespaceObject.Transaction();
2461
+ tx.moveCall({
2462
+ target: `${BOOSTING_PACKAGE_ID}::config::add_tier`,
2463
+ typeArguments: [],
2464
+ arguments: [
2465
+ tx.object(CONFIG_ID),
2466
+ tx.object(ADMIN_CAP_ID),
2467
+ tx.pure.u64(tierId),
2468
+ tx.pure.u64(point),
2469
+ tx.pure.u64(duration),
2470
+ tx.pure.u64(originalAmount),
2471
+ tx.pure.u64(amount)
2472
+ ]
2473
+ });
2474
+ tx.setSender(adminAddress);
2475
+ const gasAmount = await getNeededGasFee(this.sdk.suiClient, tx, adminAddress, 0);
2476
+ return addGasFee({
2477
+ inheritTx: tx,
2478
+ sender: adminAddress,
2479
+ feeAmount: gasAmount
2480
+ }, this.sdk.suiClient);
2481
+ }
2482
+ /**
2483
+ * Builds a transaction for updating an existing boosting tier.
2484
+ *
2485
+ * **Requires admin capability.**
2486
+ *
2487
+ * @param request - Update tier request parameters
2488
+ * @returns Promise resolving to a transaction ready for execution
2489
+ */ async buildUpdateTierTx({ adminAddress, tierId, duration, amount, originalAmount, point, currentTx }) {
2490
+ const tx = currentTx || new transactions_namespaceObject.Transaction();
2491
+ tx.moveCall({
2492
+ target: `${BOOSTING_PACKAGE_ID}::config::update_tier`,
2493
+ typeArguments: [],
2494
+ arguments: [
2495
+ tx.object(CONFIG_ID),
2496
+ tx.object(ADMIN_CAP_ID),
2497
+ tx.pure.u64(tierId),
2498
+ tx.pure.u64(duration),
2499
+ tx.pure.u64(amount),
2500
+ tx.pure.u64(point),
2501
+ tx.pure.u64(originalAmount)
2502
+ ]
2503
+ });
2504
+ tx.setSender(adminAddress);
2505
+ const gasAmount = await getNeededGasFee(this.sdk.suiClient, tx, adminAddress, 0);
2506
+ return addGasFee({
2507
+ inheritTx: tx,
2508
+ sender: adminAddress,
2509
+ feeAmount: gasAmount
2510
+ }, this.sdk.suiClient);
2511
+ }
2512
+ /**
2513
+ * Builds a transaction for removing a boosting tier.
2514
+ *
2515
+ * **Requires admin capability.**
2516
+ *
2517
+ * @param request - Remove tier request parameters
2518
+ * @returns Promise resolving to a transaction ready for execution
2519
+ */ async buildRemoveTierTx({ adminAddress, tierId, currentTx }) {
2520
+ const tx = currentTx || new transactions_namespaceObject.Transaction();
2521
+ tx.moveCall({
2522
+ target: `${BOOSTING_PACKAGE_ID}::config::remove_tier`,
2523
+ typeArguments: [],
2524
+ arguments: [
2525
+ tx.object(CONFIG_ID),
2526
+ tx.object(ADMIN_CAP_ID),
2527
+ tx.pure.u64(tierId)
2528
+ ]
2529
+ });
2530
+ tx.setSender(adminAddress);
2531
+ const gasAmount = await getNeededGasFee(this.sdk.suiClient, tx, adminAddress, 0);
2532
+ return addGasFee({
2533
+ inheritTx: tx,
2534
+ sender: adminAddress,
2535
+ feeAmount: gasAmount
2536
+ }, this.sdk.suiClient);
2537
+ }
2538
+ /**
2539
+ * Builds a transaction for updating the fee receiver address.
2540
+ *
2541
+ * **Requires admin capability.**
2542
+ *
2543
+ * @param request - Update fee receiver request parameters
2544
+ * @returns Promise resolving to a transaction ready for execution
2545
+ */ async buildUpdateFeeReceiver({ adminAddress, newReceiverAddress, currentTx }) {
2546
+ const tx = currentTx || new transactions_namespaceObject.Transaction();
2547
+ tx.moveCall({
2548
+ target: `${BOOSTING_PACKAGE_ID}::config::update_fee_receiver`,
2549
+ typeArguments: [],
2550
+ arguments: [
2551
+ tx.object(CONFIG_ID),
2552
+ tx.object(ADMIN_CAP_ID),
2553
+ tx.pure.address(newReceiverAddress)
2554
+ ]
2555
+ });
2556
+ tx.setSender(adminAddress);
2557
+ const gasAmount = await getNeededGasFee(this.sdk.suiClient, tx, adminAddress, 0);
2558
+ return addGasFee({
2559
+ inheritTx: tx,
2560
+ sender: adminAddress,
2561
+ feeAmount: gasAmount
2562
+ }, this.sdk.suiClient);
2563
+ }
2564
+ /**
2565
+ * Builds a transaction for paying boosting fees with admin privileges.
2566
+ * Allows specifying a custom payment amount instead of using the tier's default amount.
2567
+ *
2568
+ * **Requires admin capability.**
2569
+ *
2570
+ * @param request - Admin payment request parameters
2571
+ * @returns Promise resolving to a transaction ready for execution
2572
+ */ async buildPayBoostingWithAdminTx({ walletAddress, tierId, customAmount, boostingCoinType, currentTx }) {
2573
+ const tx = currentTx || new transactions_namespaceObject.Transaction();
2574
+ const paymentCoin = tx.splitCoins(tx.gas, [
2575
+ tx.pure.u64(customAmount)
2576
+ ]);
2577
+ tx.moveCall({
2578
+ target: `${BOOSTING_PACKAGE_ID}::boosting::pay_with_admin`,
2579
+ typeArguments: [
2580
+ (0,utils_namespaceObject.normalizeStructTag)(boostingCoinType)
2581
+ ],
2582
+ arguments: [
2583
+ tx.object(ADMIN_CAP_ID),
2584
+ tx.object(CONFIG_ID),
2585
+ tx.pure.u64(tierId),
2586
+ tx.pure.u64(customAmount),
2587
+ paymentCoin
2588
+ ]
2589
+ });
2590
+ tx.setSender(walletAddress);
2591
+ const gasAmount = await getNeededGasFee(this.sdk.suiClient, tx, walletAddress, 0);
2592
+ return addGasFee({
2593
+ inheritTx: tx,
2594
+ sender: walletAddress,
2595
+ feeAmount: gasAmount
2596
+ }, this.sdk.suiClient);
2597
+ }
2598
+ }
2599
+
2600
+ ;// CONCATENATED MODULE: ./src/modules/curve-module.ts
2601
+
2602
+
2603
+
2604
+ class CurveModule {
2605
+ sdk;
2606
+ constructor(sdk){
2607
+ this.sdk = sdk;
2608
+ }
2609
+ async getEstimatedAmountOut(platform, params) {
2610
+ const { coinInType, coinOutType } = params;
2611
+ tiny_invariant_default()(coinInType !== coinOutType, "coinInType and coinOutType must be different");
2612
+ tiny_invariant_default()(isSuiCoinType(coinInType) || isSuiCoinType(coinOutType), "One of coinInType or coinOutType must be SUI");
2613
+ const isBuy = isSuiCoinType(coinInType);
2614
+ switch(platform){
2615
+ case types_SupportedBondingCurve.MOONBAGS:
2616
+ {
2617
+ if (isBuy) {
2618
+ return await calculation_MoonbagsCalculation.getCurveAmountAfterBuy({
2619
+ poolId: params.poolId,
2620
+ suiAmount: params.coinInAmount,
2621
+ frontendFee: params.tradeFee ? params.tradeFee.tradeFeePercent : undefined
2622
+ }, this.sdk.suiClient);
2623
+ } else {
2624
+ return await calculation_MoonbagsCalculation.getSuiAmountAfterSell({
2625
+ poolId: params.poolId,
2626
+ curveAmount: params.coinInAmount,
2627
+ frontendFee: params.tradeFee ? params.tradeFee.tradeFeePercent : undefined
2628
+ }, this.sdk.suiClient);
2629
+ }
2630
+ }
2631
+ case types_SupportedBondingCurve.BLAST_FUN:
2632
+ {
2633
+ if (isBuy) {
2634
+ return await sdk_calculation_BlastFunSDKCalculation.getCurveAmountAfterBuy({
2635
+ poolId: params.poolId,
2636
+ suiAmount: params.coinInAmount,
2637
+ frontendFee: params.tradeFee ? params.tradeFee.tradeFeePercent : undefined
2638
+ });
2639
+ } else {
2640
+ return await sdk_calculation_BlastFunSDKCalculation.getSuiAmountAfterSell({
2641
+ poolId: params.poolId,
2642
+ curveAmount: params.coinInAmount,
2643
+ frontendFee: params.tradeFee ? params.tradeFee.tradeFeePercent : undefined
2644
+ });
2645
+ }
2646
+ }
2647
+ default:
2648
+ throw new Error(`Unsupported bonding curve platform: ${platform}`);
2649
+ }
2650
+ }
2651
+ async getTradeTransaction(platform, params) {
2652
+ const { coinInType, coinOutType } = params;
2653
+ tiny_invariant_default()(coinInType !== coinOutType, "coinInType and coinOutType must be different");
2654
+ tiny_invariant_default()(isSuiCoinType(coinInType) || isSuiCoinType(coinOutType), "One of coinInType or coinOutType must be SUI");
2655
+ const isBuy = isSuiCoinType(coinInType);
2656
+ let tx;
2657
+ switch(platform){
2658
+ case types_SupportedBondingCurve.MOONBAGS:
2659
+ {
2660
+ if (isBuy) {
2661
+ tx = await transaction_MoonbagsTransaction.getBuyTransaction(params, this.sdk.suiClient);
2662
+ } else {
2663
+ tx = await transaction_MoonbagsTransaction.getSellTransaction(params, this.sdk.suiClient);
2664
+ }
2665
+ break;
2666
+ }
2667
+ case types_SupportedBondingCurve.BLAST_FUN:
2668
+ {
2669
+ if (isBuy) {
2670
+ tx = await sdk_transaction_BlastFunSDKTransaction.getBuyTransaction(params, this.sdk.suiClient);
2671
+ } else {
2672
+ tx = await sdk_transaction_BlastFunSDKTransaction.getSellTransaction(params, this.sdk.suiClient);
2673
+ }
2674
+ break;
2675
+ }
2676
+ default:
2677
+ throw new Error(`Unsupported bonding curve platform: ${platform}`);
2678
+ }
2679
+ return tx;
2680
+ }
2681
+ }
2682
+
2683
+ ;// CONCATENATED MODULE: ./src/modules/subscription-module.ts
2684
+
2685
+
2686
+
2687
+ /** Sui package ID for the subscription protocol */ const SUBSCRIPTION_PACKAGE_ID = "0x5dd4286ec234c117bb9577d4eaed1885b70d73ab1d3dab2794d0ab9a2c06c4a1";
2688
+ /** Configuration object ID for subscription settings */ const SUBSCRIPTION_CONFIG_ID = "0x095b941beff22213fe8ccb223e4d1c5b4ede4dcd7f82ca4bb18c9a45fd3d6e20";
2689
+ /** Admin capability object ID for privileged operations */ const SUBSCRIPTION_ADMIN_CAP_ID = "0xdc27fe8187131b7fc095fccd213b79f72312793152a2483d1f67199c390e256d";
2690
+ /** Payment coin type on SUI */ const PAYMENT_COIN_TYPE = "0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC";
2691
+ /**
2692
+ * Module for managing subscription functionality in the Noodles SDK.
2693
+ *
2694
+ * This module provides methods for:
2695
+ * - Subscribing to plans
2696
+ * - Upgrading plans (immediate or next billing cycle)
2697
+ * - Managing subscription plans (admin functions)
2698
+ * - Retrieving subscription configuration
2699
+ * - Updating fee receiver wallet and pause settings
2700
+ */ class SubscriptionModule {
2701
+ /** Reference to the main SDK instance */ sdk;
2702
+ /**
2703
+ * Creates a new SubscriptionModule instance.
2704
+ *
2705
+ * @param sdk - The main Noodles Pay SDK instance
2706
+ */ constructor(sdk){
2707
+ this.sdk = sdk;
2708
+ }
2709
+ /**
2710
+ * Retrieves the current subscription configuration from the blockchain.
2711
+ *
2712
+ * @returns Promise resolving to the current subscription configuration
2713
+ * @throws Error if config object is not found or invalid
2714
+ */ async getConfig() {
2715
+ const configObject = await this.sdk.suiClient.getObject({
2716
+ id: SUBSCRIPTION_CONFIG_ID,
2717
+ options: {
2718
+ showContent: true
2719
+ }
2720
+ });
2721
+ tiny_invariant_default()(configObject.data, "Config object not found");
2722
+ tiny_invariant_default()(configObject.data.content, "Config object has no content");
2723
+ tiny_invariant_default()(configObject.data?.content.dataType === "moveObject", "Config object is not a Move object");
2724
+ const objectFields = configObject.data.content.fields;
2725
+ const id = objectFields.id.id;
2726
+ const feeReceiverWallet = objectFields.fee_receiver;
2727
+ const paused = objectFields.paused;
2728
+ const acceptedPaymentType = objectFields.accepted_payment_type;
2729
+ const plans = objectFields.plans.fields.contents;
2730
+ // Parse plan information from blockchain data
2731
+ const planMap = {};
2732
+ for (const plan of plans){
2733
+ const key = plan.fields.key;
2734
+ const planId = plan.fields.value.fields.id;
2735
+ const price = plan.fields.value.fields.price;
2736
+ const monthInterval = plan.fields.value.fields.month_interval;
2737
+ const planType = plan.fields.value.fields.ptype;
2738
+ planMap[key] = {
2739
+ id: BigInt(planId),
2740
+ price: BigInt(price),
2741
+ monthInterval: monthInterval,
2742
+ planType: planType
2743
+ };
2744
+ }
2745
+ return {
2746
+ id,
2747
+ plans: planMap,
2748
+ feeReceiverWallet: feeReceiverWallet,
2749
+ paused,
2750
+ acceptedPaymentType
2751
+ };
2752
+ }
2753
+ /**
2754
+ * Builds a transaction for subscribing to a plan.
2755
+ * The payment amount is determined by the plan configuration.
2756
+ *
2757
+ * @param request - Subscription request parameters
2758
+ * @reference order_id generated from your backend to identify the purchase
2759
+ * @returns Promise resolving to a transaction ready for execution
2760
+ * @throws Error if plan ID is invalid or contract is paused
2761
+ */ async buildSubscribeCyclePlanTx({ walletAddress, planId, reference, paymentCoinType = PAYMENT_COIN_TYPE, currentTx }) {
2762
+ const configObj = await this.getConfig();
2763
+ tiny_invariant_default()(!configObj.paused, "Contract is paused");
2764
+ tiny_invariant_default()(planId in configObj.plans, "Invalid plan ID");
2765
+ const plan = configObj.plans[planId];
2766
+ const paymentAmount = plan.price;
2767
+ // Get USDC coins from user's wallet
2768
+ const { tx: txWithCoin, coinData } = await getSplitCoinForTx({
2769
+ account: walletAddress,
2770
+ amount: paymentAmount.toString(),
2771
+ splits: [
2772
+ paymentAmount.toString()
2773
+ ],
2774
+ coinType: paymentCoinType,
2775
+ inheritTx: currentTx
2776
+ }, this.sdk.suiClient);
2777
+ txWithCoin.moveCall({
2778
+ target: `${SUBSCRIPTION_PACKAGE_ID}::subscription::subscribe_cycle_plan`,
2779
+ typeArguments: [
2780
+ paymentCoinType
2781
+ ],
2782
+ arguments: [
2783
+ txWithCoin.object(SUBSCRIPTION_CONFIG_ID),
2784
+ txWithCoin.pure.u64(planId),
2785
+ txWithCoin.pure.string(reference),
2786
+ coinData
2787
+ ]
2788
+ });
2789
+ txWithCoin.setSender(walletAddress);
2790
+ const gasAmount = await getNeededGasFee(this.sdk.suiClient, txWithCoin, walletAddress, 0);
2791
+ return addGasFee({
2792
+ inheritTx: txWithCoin,
2793
+ sender: walletAddress,
2794
+ feeAmount: gasAmount
2795
+ }, this.sdk.suiClient);
2796
+ }
2797
+ /**
2798
+ * Builds a transaction for buying additional compute units (CU) for CUAddOn plans.
2799
+ *
2800
+ * @param request - Buy more CU request parameters
2801
+ * @reference order_id generated from your backend to identify the purchase
2802
+ * @returns Promise resolving to a transaction ready for execution
2803
+ * @throws Error if plan ID is invalid or contract is paused
2804
+ */ async buildBuyMoreCUPlanTx({ walletAddress, planId, reference, paidAmount, paymentCoinType = PAYMENT_COIN_TYPE, currentTx }) {
2805
+ const configObj = await this.getConfig();
2806
+ tiny_invariant_default()(!configObj.paused, "Contract is paused");
2807
+ tiny_invariant_default()(planId in configObj.plans, "Invalid plan ID");
2808
+ // Get USDC coins from user's wallet
2809
+ const { tx: txWithCoin, coinData } = await getSplitCoinForTx({
2810
+ account: walletAddress,
2811
+ amount: paidAmount.toString(),
2812
+ splits: [
2813
+ paidAmount.toString()
2814
+ ],
2815
+ coinType: paymentCoinType,
2816
+ inheritTx: currentTx
2817
+ }, this.sdk.suiClient);
2818
+ txWithCoin.moveCall({
2819
+ target: `${SUBSCRIPTION_PACKAGE_ID}::subscription::buy_more_cu`,
2820
+ typeArguments: [
2821
+ paymentCoinType
2822
+ ],
2823
+ arguments: [
2824
+ txWithCoin.object(SUBSCRIPTION_CONFIG_ID),
2825
+ txWithCoin.pure.u64(planId),
2826
+ txWithCoin.pure.string(reference),
2827
+ txWithCoin.pure.u64(paidAmount),
2828
+ coinData
2829
+ ]
2830
+ });
2831
+ txWithCoin.setSender(walletAddress);
2832
+ const gasAmount = await getNeededGasFee(this.sdk.suiClient, txWithCoin, walletAddress, 0);
2833
+ return addGasFee({
2834
+ inheritTx: txWithCoin,
2835
+ sender: walletAddress,
2836
+ feeAmount: gasAmount
2837
+ }, this.sdk.suiClient);
2838
+ }
2839
+ /**
2840
+ * Builds a transaction for subscribing with admin privileges.
2841
+ * Allows specifying a custom payment amount instead of using the plan's default price.
2842
+ * Useful for promotions, discounts, or special cases.
2843
+ *
2844
+ * **Requires admin capability.**
2845
+ *
2846
+ * @param request - Admin subscription request parameters
2847
+ * @returns Promise resolving to a transaction ready for execution
2848
+ * @throws Error if contract is paused
2849
+ */ async buildSubscribePlanWithAdminTx({ walletAddress, planId, reference, customAmount, paymentCoinType = PAYMENT_COIN_TYPE, currentTx }) {
2850
+ const configObj = await this.getConfig();
2851
+ tiny_invariant_default()(!configObj.paused, "Contract is paused");
2852
+ // Get USDC coins from user's wallet
2853
+ const { tx: txWithCoin, coinData } = await getSplitCoinForTx({
2854
+ account: walletAddress,
2855
+ amount: customAmount.toString(),
2856
+ splits: [
2857
+ customAmount.toString()
2858
+ ],
2859
+ coinType: paymentCoinType,
2860
+ inheritTx: currentTx
2861
+ }, this.sdk.suiClient);
2862
+ txWithCoin.moveCall({
2863
+ target: `${SUBSCRIPTION_PACKAGE_ID}::subscription::subscribe_plan_with_admin`,
2864
+ typeArguments: [
2865
+ paymentCoinType
2866
+ ],
2867
+ arguments: [
2868
+ txWithCoin.object(SUBSCRIPTION_ADMIN_CAP_ID),
2869
+ txWithCoin.object(SUBSCRIPTION_CONFIG_ID),
2870
+ txWithCoin.pure.u64(planId),
2871
+ txWithCoin.pure.string(reference),
2872
+ txWithCoin.pure.u64(customAmount),
2873
+ coinData
2874
+ ]
2875
+ });
2876
+ txWithCoin.setSender(walletAddress);
2877
+ const gasAmount = await getNeededGasFee(this.sdk.suiClient, txWithCoin, walletAddress, 0);
2878
+ return addGasFee({
2879
+ inheritTx: txWithCoin,
2880
+ sender: walletAddress,
2881
+ feeAmount: gasAmount
2882
+ }, this.sdk.suiClient);
2883
+ }
2884
+ /**
2885
+ * Builds a transaction for adding a new subscription plan.
2886
+ *
2887
+ * **Requires admin capability.**
2888
+ *
2889
+ * @param request - Add plan request parameters
2890
+ * @returns Promise resolving to a transaction ready for execution
2891
+ */ async buildAddPlanTx({ adminAddress, planId, planType, monthInterval, price, currentTx }) {
2892
+ const tx = currentTx || new transactions_namespaceObject.Transaction();
2893
+ tx.moveCall({
2894
+ target: `${SUBSCRIPTION_PACKAGE_ID}::config::add_plan`,
2895
+ typeArguments: [],
2896
+ arguments: [
2897
+ tx.object(SUBSCRIPTION_CONFIG_ID),
2898
+ tx.object(SUBSCRIPTION_ADMIN_CAP_ID),
2899
+ tx.pure.u64(planId),
2900
+ tx.pure.u8(planType),
2901
+ tx.pure.u8(monthInterval),
2902
+ tx.pure.u64(price)
2903
+ ]
2904
+ });
2905
+ tx.setSender(adminAddress);
2906
+ const gasAmount = await getNeededGasFee(this.sdk.suiClient, tx, adminAddress, 0);
2907
+ return addGasFee({
2908
+ inheritTx: tx,
2909
+ sender: adminAddress,
2910
+ feeAmount: gasAmount
2911
+ }, this.sdk.suiClient);
2912
+ }
2913
+ /**
2914
+ * Builds a transaction for updating an existing subscription plan.
2915
+ *
2916
+ * **Requires admin capability.**
2917
+ *
2918
+ * @param request - Update plan request parameters
2919
+ * @returns Promise resolving to a transaction ready for execution
2920
+ */ async buildUpdatePlanTx({ adminAddress, planId, planType, monthInterval, price, currentTx }) {
2921
+ const tx = currentTx || new transactions_namespaceObject.Transaction();
2922
+ tx.moveCall({
2923
+ target: `${SUBSCRIPTION_PACKAGE_ID}::config::update_plan`,
2924
+ typeArguments: [],
2925
+ arguments: [
2926
+ tx.object(SUBSCRIPTION_CONFIG_ID),
2927
+ tx.object(SUBSCRIPTION_ADMIN_CAP_ID),
2928
+ tx.pure.u64(BigInt(planId)),
2929
+ tx.pure.u8(planType),
2930
+ tx.pure.u8(monthInterval),
2931
+ tx.pure.u64(price)
2932
+ ]
2933
+ });
2934
+ tx.setSender(adminAddress);
2935
+ const gasAmount = await getNeededGasFee(this.sdk.suiClient, tx, adminAddress, 0);
2936
+ return addGasFee({
2937
+ inheritTx: tx,
2938
+ sender: adminAddress,
2939
+ feeAmount: gasAmount
2940
+ }, this.sdk.suiClient);
2941
+ }
2942
+ /**
2943
+ * Builds a transaction for removing a subscription plan.
2944
+ *
2945
+ * **Requires admin capability.**
2946
+ *
2947
+ * @param request - Remove plan request parameters
2948
+ * @returns Promise resolving to a transaction ready for execution
2949
+ */ async buildRemovePlanTx({ adminAddress, planId, currentTx }) {
2950
+ const tx = currentTx || new transactions_namespaceObject.Transaction();
2951
+ tx.moveCall({
2952
+ target: `${SUBSCRIPTION_PACKAGE_ID}::config::remove_plan`,
2953
+ typeArguments: [],
2954
+ arguments: [
2955
+ tx.object(SUBSCRIPTION_CONFIG_ID),
2956
+ tx.object(SUBSCRIPTION_ADMIN_CAP_ID),
2957
+ tx.pure.u64(BigInt(planId))
2958
+ ]
2959
+ });
2960
+ tx.setSender(adminAddress);
2961
+ const gasAmount = await getNeededGasFee(this.sdk.suiClient, tx, adminAddress, 0);
2962
+ return addGasFee({
2963
+ inheritTx: tx,
2964
+ sender: adminAddress,
2965
+ feeAmount: gasAmount
2966
+ }, this.sdk.suiClient);
2967
+ }
2968
+ /**
2969
+ * Builds a transaction for updating the admin wallet address.
2970
+ *
2971
+ * **Requires admin capability.**
2972
+ *
2973
+ * @param request - Update admin wallet request parameters
2974
+ * @returns Promise resolving to a transaction ready for execution
2975
+ */ async buildUpdateFeeReceiverWalletTx({ adminAddress, newFeeReceiverWallet, currentTx }) {
2976
+ const tx = currentTx || new transactions_namespaceObject.Transaction();
2977
+ tx.moveCall({
2978
+ target: `${SUBSCRIPTION_PACKAGE_ID}::config::update_fee_receiver`,
2979
+ typeArguments: [],
2980
+ arguments: [
2981
+ tx.object(SUBSCRIPTION_CONFIG_ID),
2982
+ tx.object(SUBSCRIPTION_ADMIN_CAP_ID),
2983
+ tx.pure.address(newFeeReceiverWallet)
2984
+ ]
2985
+ });
2986
+ tx.setSender(adminAddress);
2987
+ const gasAmount = await getNeededGasFee(this.sdk.suiClient, tx, adminAddress, 0);
2988
+ return addGasFee({
2989
+ inheritTx: tx,
2990
+ sender: adminAddress,
2991
+ feeAmount: gasAmount
2992
+ }, this.sdk.suiClient);
2993
+ }
2994
+ /**
2995
+ * Builds a transaction for pausing or unpausing the contract.
2996
+ *
2997
+ * **Requires admin capability.**
2998
+ *
2999
+ * @param request - Set paused request parameters
3000
+ * @returns Promise resolving to a transaction ready for execution
3001
+ */ async buildSetPausedTx({ adminAddress, paused, currentTx }) {
3002
+ const tx = currentTx || new transactions_namespaceObject.Transaction();
3003
+ tx.moveCall({
3004
+ target: `${SUBSCRIPTION_PACKAGE_ID}::config::set_paused`,
3005
+ typeArguments: [],
3006
+ arguments: [
3007
+ tx.object(SUBSCRIPTION_CONFIG_ID),
3008
+ tx.object(SUBSCRIPTION_ADMIN_CAP_ID),
3009
+ tx.pure.bool(paused)
3010
+ ]
3011
+ });
3012
+ tx.setSender(adminAddress);
3013
+ const gasAmount = await getNeededGasFee(this.sdk.suiClient, tx, adminAddress, 0);
3014
+ return addGasFee({
3015
+ inheritTx: tx,
3016
+ sender: adminAddress,
3017
+ feeAmount: gasAmount
3018
+ }, this.sdk.suiClient);
3019
+ }
3020
+ /**
3021
+ * Builds a transaction to set the accepted payment coin type.
3022
+ * Note: Only one payment type can be accepted at a time. Setting a new type replaces the previous one.
3023
+ *
3024
+ * **Requires admin capability.**
3025
+ *
3026
+ * @param request - Set accepted payment type request parameters
3027
+ * @returns Promise resolving to a transaction ready for execution
3028
+ */ async buildSetAcceptedPaymentTypeTx({ adminAddress, paymentCoinType, currentTx }) {
3029
+ const tx = currentTx || new transactions_namespaceObject.Transaction();
3030
+ tx.moveCall({
3031
+ target: `${SUBSCRIPTION_PACKAGE_ID}::config::set_accepted_payment_type`,
3032
+ typeArguments: [
3033
+ paymentCoinType
3034
+ ],
3035
+ arguments: [
3036
+ tx.object(SUBSCRIPTION_CONFIG_ID),
3037
+ tx.object(SUBSCRIPTION_ADMIN_CAP_ID)
3038
+ ]
3039
+ });
3040
+ tx.setSender(adminAddress);
3041
+ const gasAmount = await getNeededGasFee(this.sdk.suiClient, tx, adminAddress, 0);
3042
+ return addGasFee({
3043
+ inheritTx: tx,
3044
+ sender: adminAddress,
3045
+ feeAmount: gasAmount
3046
+ }, this.sdk.suiClient);
3047
+ }
3048
+ }
3049
+
3050
+ ;// CONCATENATED MODULE: ./src/modules/index.ts
3051
+
3052
+
3053
+
3054
+
3055
+
3056
+
3057
+ ;// CONCATENATED MODULE: ./src/pay-sdk.ts
3058
+
3059
+
3060
+ class NoodlesPaySdk {
3061
+ _suiClient;
3062
+ boostingModule;
3063
+ subscriptionModule;
3064
+ constructor(){
3065
+ this._suiClient = new client_namespaceObject.SuiClient({
3066
+ url: (0,client_namespaceObject.getFullnodeUrl)("mainnet")
3067
+ });
3068
+ this.subscriptionModule = new SubscriptionModule(this);
3069
+ this.boostingModule = new BoostingModule(this);
3070
+ }
3071
+ get suiClient() {
3072
+ return this._suiClient;
3073
+ }
3074
+ }
3075
+
3076
+ ;// CONCATENATED MODULE: ./src/sdk.ts
3077
+
3078
+
3079
+ const DEFAULT_TRADE_FEE = {
3080
+ tradeFeePercent: 0.01,
3081
+ tradeFeeRecipientAddress: "0xdaf1c8ed29d89cd8f217f609bad0a668fa6f158c12000bfa5f93e670c99e24ff"
3082
+ };
3083
+ class NoodlesSdk {
3084
+ options;
3085
+ _suiClient;
3086
+ aggregatorModule;
3087
+ curveModule;
3088
+ constructor(options){
3089
+ this.options = options;
3090
+ this._suiClient = new client_namespaceObject.SuiClient({
3091
+ url: (0,client_namespaceObject.getFullnodeUrl)("mainnet")
3092
+ });
3093
+ this.aggregatorModule = new AggregatorModule(this);
3094
+ this.curveModule = new CurveModule(this);
3095
+ }
3096
+ get suiClient() {
3097
+ return this._suiClient;
3098
+ }
3099
+ }
3100
+
3101
+ ;// CONCATENATED MODULE: external "@mysten/sui/keypairs/ed25519"
3102
+ const ed25519_namespaceObject = require("@mysten/sui/keypairs/ed25519");
3103
+ ;// CONCATENATED MODULE: ./src/transaction/draft-transfer.ts
3104
+
3105
+
3106
+
3107
+
3108
+
3109
+ // Constants
3110
+ const CONSTANTS = {
3111
+ GAS_FEE_BUFFER_PERCENTAGE: 0.1
3112
+ };
3113
+ class DraftTransferTx {
3114
+ suiClient;
3115
+ constructor(suiClient){
3116
+ this.suiClient = suiClient;
3117
+ }
3118
+ /**
3119
+ * Validates private key against expected sender address
3120
+ * @private
3121
+ */ validatePrivateKey(privateKey, expectedSender) {
3122
+ tiny_invariant_default()(privateKey?.trim(), "Private key is required");
3123
+ const keypair = ed25519_namespaceObject.Ed25519Keypair.fromSecretKey(privateKey);
3124
+ const derivedAddress = keypair.getPublicKey().toSuiAddress();
3125
+ if (derivedAddress !== expectedSender) {
3126
+ throw new Error(`Private key mismatch. Expected: ${expectedSender}, Got: ${derivedAddress}`);
3127
+ }
3128
+ return keypair;
3129
+ }
3130
+ /**
3131
+ * Creates a draft transaction for SUI transfer
3132
+ * @param params - Transfer parameters
3133
+ * @returns Draft transaction object with encoded transaction data
3134
+ * @throws {Error} If validation fails or transaction building fails
3135
+ */ async createDraft(sender, recipient, amountMIST) {
3136
+ tiny_invariant_default()(sender?.trim(), "Sender address is required");
3137
+ tiny_invariant_default()(recipient?.trim(), "Recipient address is required");
3138
+ tiny_invariant_default()(sender !== recipient, "Sender and recipient cannot be the same");
3139
+ tiny_invariant_default()(amountMIST > 0n, "Transfer amount must be at least 1 MIST");
3140
+ try {
3141
+ // Build the transaction
3142
+ let transaction = new transactions_namespaceObject.Transaction();
3143
+ const [coin] = transaction.splitCoins(transaction.gas, [
3144
+ amountMIST
3145
+ ]);
3146
+ transaction.transferObjects([
3147
+ coin
3148
+ ], recipient);
3149
+ transaction.setSender(sender);
3150
+ // Set gas configuration
3151
+ const referenceGasPrice = await this.suiClient.getReferenceGasPrice();
3152
+ transaction.setGasPrice(referenceGasPrice);
3153
+ // Calculate and set gas budget
3154
+ const feeAmount = await getNeededGasFee(this.suiClient, transaction, sender, CONSTANTS.GAS_FEE_BUFFER_PERCENTAGE);
3155
+ transaction = await addGasFee({
3156
+ inheritTx: transaction,
3157
+ sender,
3158
+ feeAmount,
3159
+ suiInputAmount: amountMIST
3160
+ }, this.suiClient);
3161
+ // Build and encode transaction
3162
+ const txBytes = await transaction.build({
3163
+ client: this.suiClient
3164
+ });
3165
+ const txDraftBase64 = Buffer.from(txBytes).toString("base64");
3166
+ const txDigest = await transaction.getDigest();
3167
+ return {
3168
+ sender,
3169
+ recipient,
3170
+ amountMIST,
3171
+ txDraftBase64,
3172
+ txDigest
3173
+ };
3174
+ } catch (error) {
3175
+ throw new Error(`Failed to create draft transaction: ${error instanceof Error ? error.message : "Unknown error"}`);
3176
+ }
3177
+ }
3178
+ /**
3179
+ * Executes a draft transaction on the Sui network
3180
+ * @param draftTx - Draft transaction to execute
3181
+ * @param privateKey - Sender's private key
3182
+ * @returns Execution result with success status and transaction details
3183
+ */ async execute(draftTx, privateKey) {
3184
+ try {
3185
+ tiny_invariant_default()(draftTx, "Draft transaction is required");
3186
+ tiny_invariant_default()(draftTx.txDraftBase64?.trim(), "Transaction data is required");
3187
+ // Validate private key and get keypair
3188
+ const keypair = this.validatePrivateKey(privateKey, draftTx.sender);
3189
+ // Decode and sign transaction
3190
+ const txBytes = (0,utils_namespaceObject.fromBase64)(draftTx.txDraftBase64);
3191
+ const { signature } = await keypair.signTransaction(txBytes);
3192
+ // Execute on network
3193
+ const result = await this.suiClient.executeTransactionBlock({
3194
+ transactionBlock: txBytes,
3195
+ signature
3196
+ });
3197
+ return {
3198
+ success: true,
3199
+ txDigest: result.digest,
3200
+ effects: result.effects
3201
+ };
3202
+ } catch (error) {
3203
+ const errorMessage = error instanceof Error ? error.message : "Unknown error occurred";
3204
+ return {
3205
+ success: false,
3206
+ error: errorMessage
3207
+ };
3208
+ }
3209
+ }
3210
+ /**
3211
+ * Verifies the status of a transaction on the Sui network
3212
+ * @param txDigest - Transaction digest to check
3213
+ * @returns Transaction status: 'success', 'failure', or 'pending'
3214
+ */ async getTransactionStatus(txDigest) {
3215
+ tiny_invariant_default()(txDigest?.trim(), "Transaction digest is required");
3216
+ try {
3217
+ const txResponse = await this.suiClient.getTransactionBlock({
3218
+ digest: txDigest,
3219
+ options: {
3220
+ showEffects: true
3221
+ }
3222
+ });
3223
+ if (!txResponse?.effects?.status) {
3224
+ return "pending";
3225
+ }
3226
+ return txResponse.effects.status.status === "success" ? "success" : "failure";
3227
+ } catch (error) {
3228
+ if (error instanceof Error) {
3229
+ // Transaction not found indicates it's still pending
3230
+ if (error.message.includes("not found") || error.message.includes("Could not find")) {
3231
+ return "pending";
3232
+ }
3233
+ }
3234
+ return "failure";
3235
+ }
3236
+ }
3237
+ }
3238
+
3239
+ ;// CONCATENATED MODULE: ./src/transaction/index.ts
3240
+
3241
+
3242
+ ;// CONCATENATED MODULE: ./src/exports/index.ts
3243
+
3244
+
3245
+
3246
+
3247
+
3248
+
3249
+
3250
+
3251
+
3252
+
3253
+ exports.ADMIN_CAP_ID = __webpack_exports__.ADMIN_CAP_ID;
3254
+ exports.AftermathAggregator = __webpack_exports__.AftermathAggregator;
3255
+ exports.AggregatorModule = __webpack_exports__.AggregatorModule;
3256
+ exports.AstrosAggregator = __webpack_exports__.AstrosAggregator;
3257
+ exports.BASE_BPS = __webpack_exports__.BASE_BPS;
3258
+ exports.BLUEFIN_PACKAGE_ID = __webpack_exports__.BLUEFIN_PACKAGE_ID;
3259
+ exports.BOOSTING_PACKAGE_ID = __webpack_exports__.BOOSTING_PACKAGE_ID;
3260
+ exports.BlastFunConstants = __webpack_exports__.BlastFunConstants;
3261
+ exports.BlastFunCustomCalculation = __webpack_exports__.BlastFunCustomCalculation;
3262
+ exports.BlastFunCustomTransaction = __webpack_exports__.BlastFunCustomTransaction;
3263
+ exports.BlastFunPackage = __webpack_exports__.BlastFunPackage;
3264
+ exports.BlastFunSDKCalculation = __webpack_exports__.BlastFunSDKCalculation;
3265
+ exports.BlastFunSDKTransaction = __webpack_exports__.BlastFunSDKTransaction;
3266
+ exports.BluefinTx = __webpack_exports__.BluefinTx;
3267
+ exports.BoostingModule = __webpack_exports__.BoostingModule;
3268
+ exports.Bps = __webpack_exports__.Bps;
3269
+ exports.CLOCK_OBJECT_ID = __webpack_exports__.CLOCK_OBJECT_ID;
3270
+ exports.CONFIG_ID = __webpack_exports__.CONFIG_ID;
3271
+ exports.CetusAggregator = __webpack_exports__.CetusAggregator;
3272
+ exports.CurveModule = __webpack_exports__.CurveModule;
3273
+ exports.DEFAULT_TRADE_FEE = __webpack_exports__.DEFAULT_TRADE_FEE;
3274
+ exports.DraftTransferTx = __webpack_exports__.DraftTransferTx;
3275
+ exports.FlowXAggregator = __webpack_exports__.FlowXAggregator;
3276
+ exports.MathUtils = __webpack_exports__.MathUtils;
3277
+ exports.MoonbagsCalculation = __webpack_exports__.MoonbagsCalculation;
3278
+ exports.MoonbagsConstants = __webpack_exports__.MoonbagsConstants;
3279
+ exports.MoonbagsPackage = __webpack_exports__.MoonbagsPackage;
3280
+ exports.MoonbagsTransaction = __webpack_exports__.MoonbagsTransaction;
3281
+ exports.NATIVE_USDC_TOKEN_TYPE = __webpack_exports__.NATIVE_USDC_TOKEN_TYPE;
3282
+ exports.NoodlesPaySdk = __webpack_exports__.NoodlesPaySdk;
3283
+ exports.NoodlesSdk = __webpack_exports__.NoodlesSdk;
3284
+ exports.PAYMENT_COIN_TYPE = __webpack_exports__.PAYMENT_COIN_TYPE;
3285
+ exports.SUBSCRIPTION_ADMIN_CAP_ID = __webpack_exports__.SUBSCRIPTION_ADMIN_CAP_ID;
3286
+ exports.SUBSCRIPTION_CONFIG_ID = __webpack_exports__.SUBSCRIPTION_CONFIG_ID;
3287
+ exports.SUBSCRIPTION_PACKAGE_ID = __webpack_exports__.SUBSCRIPTION_PACKAGE_ID;
3288
+ exports.SUI_FULL_TYPE = __webpack_exports__.SUI_FULL_TYPE;
3289
+ exports.SUI_METADATA_OBJECT_ID = __webpack_exports__.SUI_METADATA_OBJECT_ID;
3290
+ exports.SUI_TYPE = __webpack_exports__.SUI_TYPE;
3291
+ exports.SevenKAggregator = __webpack_exports__.SevenKAggregator;
3292
+ exports.SubscriptionModule = __webpack_exports__.SubscriptionModule;
3293
+ exports.SupportedAggregator = __webpack_exports__.SupportedAggregator;
3294
+ exports.SupportedBondingCurve = __webpack_exports__.SupportedBondingCurve;
3295
+ exports.TradeFeeOptions = __webpack_exports__.TradeFeeOptions;
3296
+ exports.USDC_TOKEN_TYPE = __webpack_exports__.USDC_TOKEN_TYPE;
3297
+ exports.adaptSuiClient = __webpack_exports__.adaptSuiClient;
3298
+ exports.adaptTransaction = __webpack_exports__.adaptTransaction;
3299
+ exports.addGasFee = __webpack_exports__.addGasFee;
3300
+ exports.createCompatibleSuiClient = __webpack_exports__.createCompatibleSuiClient;
3301
+ exports.getAmountAfterFee = __webpack_exports__.getAmountAfterFee;
3302
+ exports.getCoinObjectIdsByAmount = __webpack_exports__.getCoinObjectIdsByAmount;
3303
+ exports.getMemezPumpSDK = __webpack_exports__.getMemezPumpSDK;
3304
+ exports.getMoveObject = __webpack_exports__.getMoveObject;
3305
+ exports.getMoveObjectContent = __webpack_exports__.getMoveObjectContent;
3306
+ exports.getNeededGasFee = __webpack_exports__.getNeededGasFee;
3307
+ exports.getSplitCoinForTx = __webpack_exports__.getSplitCoinForTx;
3308
+ exports.getSplitCoinsAfterFee = __webpack_exports__.getSplitCoinsAfterFee;
3309
+ exports.isSuiCoinType = __webpack_exports__.isSuiCoinType;
3310
+ exports.splitSuiCoinAfterFeeFromBuyTx = __webpack_exports__.splitSuiCoinAfterFeeFromBuyTx;
3311
+ exports.splitSuiCoinAfterFeeFromSellTx = __webpack_exports__.splitSuiCoinAfterFeeFromSellTx;
3312
+ for(var __rspack_i in __webpack_exports__) {
3313
+ if(["ADMIN_CAP_ID","AftermathAggregator","AggregatorModule","AstrosAggregator","BASE_BPS","BLUEFIN_PACKAGE_ID","BOOSTING_PACKAGE_ID","BlastFunConstants","BlastFunCustomCalculation","BlastFunCustomTransaction","BlastFunPackage","BlastFunSDKCalculation","BlastFunSDKTransaction","BluefinTx","BoostingModule","Bps","CLOCK_OBJECT_ID","CONFIG_ID","CetusAggregator","CurveModule","DEFAULT_TRADE_FEE","DraftTransferTx","FlowXAggregator","MathUtils","MoonbagsCalculation","MoonbagsConstants","MoonbagsPackage","MoonbagsTransaction","NATIVE_USDC_TOKEN_TYPE","NoodlesPaySdk","NoodlesSdk","PAYMENT_COIN_TYPE","SUBSCRIPTION_ADMIN_CAP_ID","SUBSCRIPTION_CONFIG_ID","SUBSCRIPTION_PACKAGE_ID","SUI_FULL_TYPE","SUI_METADATA_OBJECT_ID","SUI_TYPE","SevenKAggregator","SubscriptionModule","SupportedAggregator","SupportedBondingCurve","TradeFeeOptions","USDC_TOKEN_TYPE","adaptSuiClient","adaptTransaction","addGasFee","createCompatibleSuiClient","getAmountAfterFee","getCoinObjectIdsByAmount","getMemezPumpSDK","getMoveObject","getMoveObjectContent","getNeededGasFee","getSplitCoinForTx","getSplitCoinsAfterFee","isSuiCoinType","splitSuiCoinAfterFeeFromBuyTx","splitSuiCoinAfterFeeFromSellTx"].indexOf(__rspack_i) === -1) {
3314
+ exports[__rspack_i] = __webpack_exports__[__rspack_i];
3315
+ }
3316
+ }
3317
+ Object.defineProperty(exports, '__esModule', { value: true });