@minswap/noodles-sdk 0.0.43 → 0.0.44
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/982.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +24 -13
- package/dist/index.js +1 -1
- package/dist/pay.cjs +1 -1
- package/dist/pay.d.ts +21 -12
- package/dist/pay.js +1 -1
- package/package.json +1 -1
package/dist/982.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Transaction as e}from"@mysten/sui/transactions";import t from"@minswap/tiny-invariant";import{fromBase64 as i,normalizeStructTag as n}from"@mysten/sui/utils";import{SuiClient as s,getFullnodeUrl as a}from"@mysten/sui/client";function r(e,t){let i=BigInt(e),n=BigInt(1e4*Number(t));if(n===BigInt(0))return[i.toString()];let s=i*n/BigInt(1e4);return[(i-s).toString(),s.toString()]}function u(e,t){if(!t||0>=Number(t))return BigInt(e);let i=BigInt(e),n=BigInt(1e4*Number(t));if(n===BigInt(0))return i;let s=i*n/BigInt(1e4);return i-s}async function o(e,t,i,n){let{effects:{gasUsed:s,status:a}}=await e.devInspectTransactionBlock({sender:i,transactionBlock:t});if("success"!==a.status)throw Error(`Transaction failed during dev inspect: ${a.error??""}`);let r=BigInt(s.computationCost)+BigInt(s.storageCost)-BigInt(s.storageRebate),u=BigInt(1e4*Number(n));return r*(BigInt(1e4)+u)/BigInt(1e4)}let l="0x2::sui::SUI",d="0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI",c="0x5d4b302506645c37ff133b98c4b50a5ae14841659738d6d733d59d0d217a93bf::coin::COIN",g="0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC",f="0x9258181f5ceac8dbffb7030890243caed69a9599d2886d957a9cb7656af3bdb3",p="0x0000000000000000000000000000000000000000000000000000000000000006";function b(e){return e===l||e===d}let m=async(e,t,i,n)=>{let s,a=[],r=!0;for(;r;)try{let i=await e.getCoins({owner:t,coinType:n,cursor:s});a=[...a,...i.data],r=i.hasNextPage,s=i.nextCursor}catch(e){console.error("Error fetching data:",e),r=!1}let u=((e,t,i)=>{let n;if(e?.length){do{n=!1;for(let s=0;s<e.length-1;s++){let a=BigInt(e[s][t]),r=BigInt(e[s+1][t]);if("desc"===i?a<r:a>r){let t=e[s];e[s]=e[s+1],e[s+1]=t,n=!0}}}while(n);return e}})(a.map(e=>({...e,balance:e.balance})),"balance","desc")??[],o="0",l=[],d=[];for(let e of u)if(o=(BigInt(e.balance)+BigInt(o)).toString(10),l.push(e.coinObjectId),d.push(e),BigInt(o)>=BigInt(i))break;return{objectIds:l,balance:o,objectCoins:d}};async function C(t,i){let{account:s,amount:a,splits:r,coinType:u,inheritTx:o,inspecTransaction:l,isSponsored:c=!1}=t,g=o??new e,{objectIds:f}=await m(i,s,a,u),p=f[0];if(n(u)===n(d)&&!c){let e;return l?(f.length>1&&g.mergeCoins(g.object(p),f.slice(1).map(e=>g.object(e))),e=g.splitCoins(g.object(p),r)):e=g.splitCoins(g.gas,r),{tx:g,coinData:e}}f.length>1&&g.mergeCoins(g.object(p),f.slice(1).map(e=>g.object(e)));let b=g.splitCoins(g.object(p),r);return{tx:g,coinData:b}}async function h(t,i){let{inheritTx:n,sender:s,feeAmount:a,suiInputAmount:r}=t,u=n||new e;u.setGasBudget(a);let{objectCoins:o}=await m(i,s,(BigInt(r||"0")+a).toString(),d);return u.setGasPayment(o.map(e=>({objectId:e.coinObjectId,version:e.version,digest:e.digest}))),u}let I="0x25fa0eb553dd69fa6a8028f73a38f1df7f289fa88a58ed3d7dc5a5360155bb19",y="0x8b1a8ac6e34688cd8f8f8e5fefa9d5fb9e1ff74d2f132f8e208ae5ac9cc530bb",T="0x13d101f44a0710a5475bec5f492a87b80e03d92d1cf540f26096f65850b23d26";class _{sdk;constructor(e){this.sdk=e}async getConfig(){let e=await this.sdk.suiClient.getObject({id:y,options:{showContent:!0}});t(e.data?.content,"Config object not found or has no content"),t(e.data?.content.dataType==="moveObject","Config object is not a Move object");let i=e.data.content.fields,n=i.id.id,s=i.fee_receiver,a=i.tiers.fields.contents,r={};for(let e of a){let t=e.fields.key,i=e.fields.value.fields.duration,n=e.fields.value.fields.amount,s=e.fields.value.fields.point,a=e.fields.value.fields.original_amount;r[t]={duration:BigInt(i),amount:BigInt(n),point:BigInt(s),originalAmount:BigInt(a)}}return{id:n,receiverAddress:s,tiers:r}}async buildPayBoostingTx({walletAddress:i,tierId:s,boostingCoinType:a,currentTx:r}){let u=await this.getConfig();t(s in u.tiers,"Invalid tier ID");let l=u.tiers[s].amount,d=r||new e,c=d.splitCoins(d.gas,[d.pure.u64(l)]);d.moveCall({target:`${I}::boosting::pay`,typeArguments:[n(a)],arguments:[d.object(y),d.pure.u64(s),c]}),d.setSender(i);let g=await o(this.sdk.suiClient,d,i,0);return h({inheritTx:d,sender:i,feeAmount:g},this.sdk.suiClient)}async buildAddTierTx({adminAddress:t,tierId:i,duration:n,point:s,originalAmount:a,amount:r,currentTx:u}){let l=u||new e;l.moveCall({target:`${I}::config::add_tier`,typeArguments:[],arguments:[l.object(y),l.object(T),l.pure.u64(i),l.pure.u64(s),l.pure.u64(n),l.pure.u64(a),l.pure.u64(r)]}),l.setSender(t);let d=await o(this.sdk.suiClient,l,t,0);return h({inheritTx:l,sender:t,feeAmount:d},this.sdk.suiClient)}async buildUpdateTierTx({adminAddress:t,tierId:i,duration:n,amount:s,originalAmount:a,point:r,currentTx:u}){let l=u||new e;l.moveCall({target:`${I}::config::update_tier`,typeArguments:[],arguments:[l.object(y),l.object(T),l.pure.u64(i),l.pure.u64(n),l.pure.u64(s),l.pure.u64(r),l.pure.u64(a)]}),l.setSender(t);let d=await o(this.sdk.suiClient,l,t,0);return h({inheritTx:l,sender:t,feeAmount:d},this.sdk.suiClient)}async buildRemoveTierTx({adminAddress:t,tierId:i,currentTx:n}){let s=n||new e;s.moveCall({target:`${I}::config::remove_tier`,typeArguments:[],arguments:[s.object(y),s.object(T),s.pure.u64(i)]}),s.setSender(t);let a=await o(this.sdk.suiClient,s,t,0);return h({inheritTx:s,sender:t,feeAmount:a},this.sdk.suiClient)}async buildUpdateFeeReceiver({adminAddress:t,newReceiverAddress:i,currentTx:n}){let s=n||new e;s.moveCall({target:`${I}::config::update_fee_receiver`,typeArguments:[],arguments:[s.object(y),s.object(T),s.pure.address(i)]}),s.setSender(t);let a=await o(this.sdk.suiClient,s,t,0);return h({inheritTx:s,sender:t,feeAmount:a},this.sdk.suiClient)}async buildPayBoostingWithAdminTx({walletAddress:t,tierId:i,customAmount:s,boostingCoinType:a,currentTx:r}){let u=r||new e,l=u.splitCoins(u.gas,[u.pure.u64(s)]);u.moveCall({target:`${I}::boosting::pay_with_admin`,typeArguments:[n(a)],arguments:[u.object(T),u.object(y),u.pure.u64(i),u.pure.u64(s),l]}),u.setSender(t);let d=await o(this.sdk.suiClient,u,t,0);return h({inheritTx:u,sender:t,feeAmount:d},this.sdk.suiClient)}}let A="0x3dd678c250a667f1551bc4b9e35fd070896f4775dd2900d5cb2910d2aea0b068",w="0x3eb7bd15f61b7cc1a9fd36151e9c3d05aa37bfadb0a58c3a26a6c02c2e99f3ca",x="0xf375fcb3d95934143766cab2028ab49441fa04ef2ce27c08c01004c455bcbad4",S="0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC";class v{sdk;constructor(e){this.sdk=e}async getConfig(){let e=await this.sdk.suiClient.getObject({id:w,options:{showContent:!0}});t(e.data,"Config object not found"),t(e.data.content,"Config object has no content"),t(e.data?.content.dataType==="moveObject","Config object is not a Move object");let i=e.data.content.fields,n=i.id.id,s=i.fee_receiver,a=i.paused,r=i.accepted_payment_type,u=i.plans.fields.contents,o={};for(let e of u){let t=e.fields.key,i=e.fields.value.fields.id,n=e.fields.value.fields.price,s=e.fields.value.fields.month_interval,a=e.fields.value.fields.ptype;o[t]={id:BigInt(i),price:BigInt(n),monthInterval:s,planType:a}}return{id:n,plans:o,feeReceiverWallet:s,paused:a,acceptedPaymentType:r}}async buildSubscribeCyclePlanTx({walletAddress:e,planId:i,reference:n,paymentCoinType:s=S,currentTx:a}){let r=await this.getConfig();t(!r.paused,"Contract is paused"),t(i in r.plans,"Invalid plan ID");let u=r.plans[i],l=u.price*BigInt(u.monthInterval),{tx:d,coinData:c}=await C({account:e,amount:l.toString(),splits:[l.toString()],coinType:s,inheritTx:a},this.sdk.suiClient);d.moveCall({target:`${A}::subscription::subscribe_cycle_plan`,typeArguments:[s],arguments:[d.object(w),d.pure.u64(i),d.pure.string(n),c]}),d.setSender(e);let g=await o(this.sdk.suiClient,d,e,0);return h({inheritTx:d,sender:e,feeAmount:g},this.sdk.suiClient)}async buildBuyMoreCUPlanTx({walletAddress:e,planId:i,reference:n,paidAmount:s,paymentCoinType:a=S,currentTx:r}){let u=await this.getConfig();t(!u.paused,"Contract is paused"),t(i in u.plans,"Invalid plan ID");let{tx:l,coinData:d}=await C({account:e,amount:s.toString(),splits:[s.toString()],coinType:a,inheritTx:r},this.sdk.suiClient);l.moveCall({target:`${A}::subscription::buy_more_cu`,typeArguments:[a],arguments:[l.object(w),l.pure.u64(i),l.pure.string(n),l.pure.u64(s),d]}),l.setSender(e);let c=await o(this.sdk.suiClient,l,e,0);return h({inheritTx:l,sender:e,feeAmount:c},this.sdk.suiClient)}async buildSubscribePlanWithAdminTx({walletAddress:e,planId:i,reference:n,customAmount:s,paymentCoinType:a=S,currentTx:r}){t(!(await this.getConfig()).paused,"Contract is paused");let{tx:u,coinData:l}=await C({account:e,amount:s.toString(),splits:[s.toString()],coinType:a,inheritTx:r},this.sdk.suiClient);u.moveCall({target:`${A}::subscription::subscribe_plan_with_admin`,typeArguments:[a],arguments:[u.object(x),u.object(w),u.pure.u64(i),u.pure.string(n),u.pure.u64(s),l]}),u.setSender(e);let d=await o(this.sdk.suiClient,u,e,0);return h({inheritTx:u,sender:e,feeAmount:d},this.sdk.suiClient)}async buildAddPlanTx({adminAddress:t,planId:i,planType:n,monthInterval:s,price:a,currentTx:r}){let u=r||new e;u.moveCall({target:`${A}::config::add_plan`,typeArguments:[],arguments:[u.object(w),u.object(x),u.pure.u64(i),u.pure.u8(n),u.pure.u8(s),u.pure.u64(a)]}),u.setSender(t);let l=await o(this.sdk.suiClient,u,t,0);return h({inheritTx:u,sender:t,feeAmount:l},this.sdk.suiClient)}async buildUpdatePlanTx({adminAddress:t,planId:i,planType:n,monthInterval:s,price:a,currentTx:r}){let u=r||new e;u.moveCall({target:`${A}::config::update_plan`,typeArguments:[],arguments:[u.object(w),u.object(x),u.pure.u64(BigInt(i)),u.pure.u8(n),u.pure.u8(s),u.pure.u64(a)]}),u.setSender(t);let l=await o(this.sdk.suiClient,u,t,0);return h({inheritTx:u,sender:t,feeAmount:l},this.sdk.suiClient)}async buildRemovePlanTx({adminAddress:t,planId:i,currentTx:n}){let s=n||new e;s.moveCall({target:`${A}::config::remove_plan`,typeArguments:[],arguments:[s.object(w),s.object(x),s.pure.u64(BigInt(i))]}),s.setSender(t);let a=await o(this.sdk.suiClient,s,t,0);return h({inheritTx:s,sender:t,feeAmount:a},this.sdk.suiClient)}async buildUpdateFeeReceiverWalletTx({adminAddress:t,newFeeReceiverWallet:i,currentTx:n}){let s=n||new e;s.moveCall({target:`${A}::config::update_fee_receiver`,typeArguments:[],arguments:[s.object(w),s.object(x),s.pure.address(i)]}),s.setSender(t);let a=await o(this.sdk.suiClient,s,t,0);return h({inheritTx:s,sender:t,feeAmount:a},this.sdk.suiClient)}async buildSetPausedTx({adminAddress:t,paused:i,currentTx:n}){let s=n||new e;s.moveCall({target:`${A}::config::set_paused`,typeArguments:[],arguments:[s.object(w),s.object(x),s.pure.bool(i)]}),s.setSender(t);let a=await o(this.sdk.suiClient,s,t,0);return h({inheritTx:s,sender:t,feeAmount:a},this.sdk.suiClient)}async buildSetAcceptedPaymentTypeTx({adminAddress:t,paymentCoinType:i,currentTx:n}){let s=n||new e;s.moveCall({target:`${A}::config::set_accepted_payment_type`,typeArguments:[i],arguments:[s.object(w),s.object(x)]}),s.setSender(t);let a=await o(this.sdk.suiClient,s,t,0);return h({inheritTx:s,sender:t,feeAmount:a},this.sdk.suiClient)}}class j{_suiClient;boostingModule;subscriptionModule;constructor(){this._suiClient=new s({url:a("mainnet")}),this.subscriptionModule=new v(this),this.boostingModule=new _(this)}get suiClient(){return this._suiClient}}export{T as ADMIN_CAP_ID,I as BOOSTING_PACKAGE_ID,_ as BoostingModule,p as CLOCK_OBJECT_ID,y as CONFIG_ID,g as NATIVE_USDC_TOKEN_TYPE,j as NoodlesPaySdk,S as PAYMENT_COIN_TYPE,x as SUBSCRIPTION_ADMIN_CAP_ID,w as SUBSCRIPTION_CONFIG_ID,A as SUBSCRIPTION_PACKAGE_ID,d as SUI_FULL_TYPE,f as SUI_METADATA_OBJECT_ID,l as SUI_TYPE,v as SubscriptionModule,s as SuiClient,e as Transaction,c as USDC_TOKEN_TYPE,h as addGasFee,i as fromBase64,u as getAmountAfterFee,m as getCoinObjectIdsByAmount,a as getFullnodeUrl,o as getNeededGasFee,C as getSplitCoinForTx,r as getSplitCoinsAfterFee,b as isSuiCoinType,t as tiny_invariant};
|
|
1
|
+
import{Transaction as e}from"@mysten/sui/transactions";import t from"@minswap/tiny-invariant";import{fromBase64 as i,normalizeStructTag as n}from"@mysten/sui/utils";import{SuiClient as s,getFullnodeUrl as a}from"@mysten/sui/client";function d(e,t){let i=BigInt(e),n=BigInt(1e4*Number(t));if(n===BigInt(0))return[i.toString()];let s=i*n/BigInt(1e4);return[(i-s).toString(),s.toString()]}function r(e,t){if(!t||0>=Number(t))return BigInt(e);let i=BigInt(e),n=BigInt(1e4*Number(t));if(n===BigInt(0))return i;let s=i*n/BigInt(1e4);return i-s}async function o(e,t,i,n){let{effects:{gasUsed:s,status:a}}=await e.devInspectTransactionBlock({sender:i,transactionBlock:t});if("success"!==a.status)throw Error(`Transaction failed during dev inspect: ${a.error??""}`);let d=BigInt(s.computationCost)+BigInt(s.storageCost)-BigInt(s.storageRebate),r=BigInt(1e4*Number(n));return d*(BigInt(1e4)+r)/BigInt(1e4)}let u="0x2::sui::SUI",c="0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI",l="0x5d4b302506645c37ff133b98c4b50a5ae14841659738d6d733d59d0d217a93bf::coin::COIN",f="0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC",g="0x9258181f5ceac8dbffb7030890243caed69a9599d2886d957a9cb7656af3bdb3",p="0x0000000000000000000000000000000000000000000000000000000000000006";function b(e){return e===u||e===c}let m=async(e,t,i,n)=>{let s,a=[],d=!0;for(;d;)try{let i=await e.getCoins({owner:t,coinType:n,cursor:s});a=[...a,...i.data],d=i.hasNextPage,s=i.nextCursor}catch(e){console.error("Error fetching data:",e),d=!1}let r=((e,t,i)=>{let n;if(e?.length){do{n=!1;for(let s=0;s<e.length-1;s++){let a=BigInt(e[s][t]),d=BigInt(e[s+1][t]);if("desc"===i?a<d:a>d){let t=e[s];e[s]=e[s+1],e[s+1]=t,n=!0}}}while(n);return e}})(a.map(e=>({...e,balance:e.balance})),"balance","desc")??[],o="0",u=[],c=[];for(let e of r)if(o=(BigInt(e.balance)+BigInt(o)).toString(10),u.push(e.coinObjectId),c.push(e),BigInt(o)>=BigInt(i))break;return{objectIds:u,balance:o,objectCoins:c}};async function h(t,i){let{account:s,amount:a,splits:d,coinType:r,inheritTx:o,inspecTransaction:u,isSponsored:l=!1}=t,f=o??new e,{objectIds:g}=await m(i,s,a,r),p=g[0];if(n(r)===n(c)&&!l){let e;return u?(g.length>1&&f.mergeCoins(f.object(p),g.slice(1).map(e=>f.object(e))),e=f.splitCoins(f.object(p),d)):e=f.splitCoins(f.gas,d),{tx:f,coinData:e}}g.length>1&&f.mergeCoins(f.object(p),g.slice(1).map(e=>f.object(e)));let b=f.splitCoins(f.object(p),d);return{tx:f,coinData:b}}async function C(t,i){let{inheritTx:n,sender:s,feeAmount:a,suiInputAmount:d}=t,r=n||new e;r.setGasBudget(a);let{objectCoins:o}=await m(i,s,(BigInt(d||"0")+a).toString(),c);return r.setGasPayment(o.map(e=>({objectId:e.coinObjectId,version:e.version,digest:e.digest}))),r}let I="0x25fa0eb553dd69fa6a8028f73a38f1df7f289fa88a58ed3d7dc5a5360155bb19",k="0x8b1a8ac6e34688cd8f8f8e5fefa9d5fb9e1ff74d2f132f8e208ae5ac9cc530bb",v="0x13d101f44a0710a5475bec5f492a87b80e03d92d1cf540f26096f65850b23d26";class y{sdk;constructor(e){this.sdk=e}async getConfig(){let e=await this.sdk.suiClient.getObject({id:k,options:{showContent:!0}});t(e.data?.content,"Config object not found or has no content"),t(e.data?.content.dataType==="moveObject","Config object is not a Move object");let i=e.data.content.fields,n=i.id.id,s=i.fee_receiver,a=i.tiers.fields.contents,d={};for(let e of a){let t=e.fields.key,i=e.fields.value.fields.duration,n=e.fields.value.fields.amount,s=e.fields.value.fields.point,a=e.fields.value.fields.original_amount;d[t]={duration:BigInt(i),amount:BigInt(n),point:BigInt(s),originalAmount:BigInt(a)}}return{id:n,receiverAddress:s,tiers:d}}async buildPayBoostingTx({walletAddress:i,tierId:s,boostingCoinType:a,currentTx:d}){let r=await this.getConfig();t(s in r.tiers,"Invalid tier ID");let u=r.tiers[s].amount,c=d||new e,l=c.splitCoins(c.gas,[c.pure.u64(u)]);c.moveCall({target:`${I}::boosting::pay`,typeArguments:[n(a)],arguments:[c.object(k),c.pure.u64(s),l]}),c.setSender(i);let f=await o(this.sdk.suiClient,c,i,0);return C({inheritTx:c,sender:i,feeAmount:f},this.sdk.suiClient)}async buildAddTierTx({adminAddress:t,tierId:i,duration:n,point:s,originalAmount:a,amount:d,currentTx:r}){let u=r||new e;u.moveCall({target:`${I}::config::add_tier`,typeArguments:[],arguments:[u.object(k),u.object(v),u.pure.u64(i),u.pure.u64(s),u.pure.u64(n),u.pure.u64(a),u.pure.u64(d)]}),u.setSender(t);let c=await o(this.sdk.suiClient,u,t,0);return C({inheritTx:u,sender:t,feeAmount:c},this.sdk.suiClient)}async buildUpdateTierTx({adminAddress:t,tierId:i,duration:n,amount:s,originalAmount:a,point:d,currentTx:r}){let u=r||new e;u.moveCall({target:`${I}::config::update_tier`,typeArguments:[],arguments:[u.object(k),u.object(v),u.pure.u64(i),u.pure.u64(n),u.pure.u64(s),u.pure.u64(d),u.pure.u64(a)]}),u.setSender(t);let c=await o(this.sdk.suiClient,u,t,0);return C({inheritTx:u,sender:t,feeAmount:c},this.sdk.suiClient)}async buildRemoveTierTx({adminAddress:t,tierId:i,currentTx:n}){let s=n||new e;s.moveCall({target:`${I}::config::remove_tier`,typeArguments:[],arguments:[s.object(k),s.object(v),s.pure.u64(i)]}),s.setSender(t);let a=await o(this.sdk.suiClient,s,t,0);return C({inheritTx:s,sender:t,feeAmount:a},this.sdk.suiClient)}async buildUpdateFeeReceiver({adminAddress:t,newReceiverAddress:i,currentTx:n}){let s=n||new e;s.moveCall({target:`${I}::config::update_fee_receiver`,typeArguments:[],arguments:[s.object(k),s.object(v),s.pure.address(i)]}),s.setSender(t);let a=await o(this.sdk.suiClient,s,t,0);return C({inheritTx:s,sender:t,feeAmount:a},this.sdk.suiClient)}async buildPayBoostingWithAdminTx({walletAddress:t,tierId:i,customAmount:s,boostingCoinType:a,currentTx:d}){let r=d||new e,u=r.splitCoins(r.gas,[r.pure.u64(s)]);r.moveCall({target:`${I}::boosting::pay_with_admin`,typeArguments:[n(a)],arguments:[r.object(v),r.object(k),r.pure.u64(i),r.pure.u64(s),u]}),r.setSender(t);let c=await o(this.sdk.suiClient,r,t,0);return C({inheritTx:r,sender:t,feeAmount:c},this.sdk.suiClient)}}let T={prod:{packageId:"0x3dd678c250a667f1551bc4b9e35fd070896f4775dd2900d5cb2910d2aea0b068",configId:"0x3eb7bd15f61b7cc1a9fd36151e9c3d05aa37bfadb0a58c3a26a6c02c2e99f3ca",adminCapId:"0xf375fcb3d95934143766cab2028ab49441fa04ef2ce27c08c01004c455bcbad4",paymentCoinType:"0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC"},staging:{packageId:"0xa83cd093ce5142649adae10d21fe87d55fa2df4e52a4292c77ba039bb12bfe67",configId:"0x19fb8f91946e58c068fa4238bdd7a531216a0c4dcfaa279a8a02c60cb02f6711",adminCapId:"0xd8139544d054702dfab6de4e9c55f162c8a6f30465935af56cffed99c5e1c2bd",paymentCoinType:"0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC"}};class x{sdk;constructor(e){this.sdk=e}async getConfig(){let e=await this.sdk.suiClient.getObject({id:T[this.sdk.env].configId,options:{showContent:!0}});t(e.data,"Config object not found"),t(e.data.content,"Config object has no content"),t(e.data?.content.dataType==="moveObject","Config object is not a Move object");let i=e.data.content.fields,n=i.id.id,s=i.fee_receiver,a=i.paused,d=i.accepted_payment_type,r=i.plans.fields.contents,o={};for(let e of r){let t=e.fields.key,i=e.fields.value.fields.id,n=e.fields.value.fields.price,s=e.fields.value.fields.month_interval,a=e.fields.value.fields.ptype;o[t]={id:BigInt(i),price:BigInt(n),monthInterval:s,planType:a}}return{id:n,plans:o,feeReceiverWallet:s,paused:a,acceptedPaymentType:d}}async buildSubscribeCyclePlanTx({walletAddress:e,planId:i,reference:n,paymentCoinType:s=T[this.sdk.env].paymentCoinType,currentTx:a}){let d=await this.getConfig();t(!d.paused,"Contract is paused"),t(i in d.plans,"Invalid plan ID");let r=d.plans[i],u=r.price*BigInt(r.monthInterval),{tx:c,coinData:l}=await h({account:e,amount:u.toString(),splits:[u.toString()],coinType:s,inheritTx:a},this.sdk.suiClient);c.moveCall({target:`${T[this.sdk.env].packageId}::subscription::subscribe_cycle_plan`,typeArguments:[s],arguments:[c.object(T[this.sdk.env].configId),c.pure.u64(i),c.pure.string(n),l]}),c.setSender(e);let f=await o(this.sdk.suiClient,c,e,0);return C({inheritTx:c,sender:e,feeAmount:f},this.sdk.suiClient)}async buildBuyMoreCUPlanTx({walletAddress:e,planId:i,reference:n,paidAmount:s,paymentCoinType:a=T[this.sdk.env].paymentCoinType,currentTx:d}){let r=await this.getConfig();t(!r.paused,"Contract is paused"),t(i in r.plans,"Invalid plan ID");let{tx:u,coinData:c}=await h({account:e,amount:s.toString(),splits:[s.toString()],coinType:a,inheritTx:d},this.sdk.suiClient);u.moveCall({target:`${T[this.sdk.env].packageId}::subscription::buy_more_cu`,typeArguments:[a],arguments:[u.object(T[this.sdk.env].configId),u.pure.u64(i),u.pure.string(n),u.pure.u64(s),c]}),u.setSender(e);let l=await o(this.sdk.suiClient,u,e,0);return C({inheritTx:u,sender:e,feeAmount:l},this.sdk.suiClient)}async buildSubscribePlanWithAdminTx({walletAddress:e,planId:i,reference:n,customAmount:s,paymentCoinType:a=T[this.sdk.env].paymentCoinType,currentTx:d}){t(!(await this.getConfig()).paused,"Contract is paused");let{tx:r,coinData:u}=await h({account:e,amount:s.toString(),splits:[s.toString()],coinType:a,inheritTx:d},this.sdk.suiClient);r.moveCall({target:`${T[this.sdk.env].packageId}::subscription::subscribe_plan_with_admin`,typeArguments:[a],arguments:[r.object(T[this.sdk.env].adminCapId),r.object(T[this.sdk.env].configId),r.pure.u64(i),r.pure.string(n),r.pure.u64(s),u]}),r.setSender(e);let c=await o(this.sdk.suiClient,r,e,0);return C({inheritTx:r,sender:e,feeAmount:c},this.sdk.suiClient)}async buildAddPlanTx({adminAddress:t,planId:i,planType:n,monthInterval:s,price:a,currentTx:d}){let r=d||new e;r.moveCall({target:`${T[this.sdk.env].packageId}::config::add_plan`,typeArguments:[],arguments:[r.object(T[this.sdk.env].configId),r.object(T[this.sdk.env].adminCapId),r.pure.u64(i),r.pure.u8(n),r.pure.u8(s),r.pure.u64(a)]}),r.setSender(t);let u=await o(this.sdk.suiClient,r,t,0);return C({inheritTx:r,sender:t,feeAmount:u},this.sdk.suiClient)}async buildUpdatePlanTx({adminAddress:t,planId:i,planType:n,monthInterval:s,price:a,currentTx:d}){let r=d||new e;r.moveCall({target:`${T[this.sdk.env].packageId}::config::update_plan`,typeArguments:[],arguments:[r.object(T[this.sdk.env].configId),r.object(T[this.sdk.env].adminCapId),r.pure.u64(BigInt(i)),r.pure.u8(n),r.pure.u8(s),r.pure.u64(a)]}),r.setSender(t);let u=await o(this.sdk.suiClient,r,t,0);return C({inheritTx:r,sender:t,feeAmount:u},this.sdk.suiClient)}async buildRemovePlanTx({adminAddress:t,planId:i,currentTx:n}){let s=n||new e;s.moveCall({target:`${T[this.sdk.env].packageId}::config::remove_plan`,typeArguments:[],arguments:[s.object(T[this.sdk.env].configId),s.object(T[this.sdk.env].adminCapId),s.pure.u64(BigInt(i))]}),s.setSender(t);let a=await o(this.sdk.suiClient,s,t,0);return C({inheritTx:s,sender:t,feeAmount:a},this.sdk.suiClient)}async buildUpdateFeeReceiverWalletTx({adminAddress:t,newFeeReceiverWallet:i,currentTx:n}){let s=n||new e;s.moveCall({target:`${T[this.sdk.env].packageId}::config::update_fee_receiver`,typeArguments:[],arguments:[s.object(T[this.sdk.env].configId),s.object(T[this.sdk.env].adminCapId),s.pure.address(i)]}),s.setSender(t);let a=await o(this.sdk.suiClient,s,t,0);return C({inheritTx:s,sender:t,feeAmount:a},this.sdk.suiClient)}async buildSetPausedTx({adminAddress:t,paused:i,currentTx:n}){let s=n||new e;s.moveCall({target:`${T[this.sdk.env].packageId}::config::set_paused`,typeArguments:[],arguments:[s.object(T[this.sdk.env].configId),s.object(T[this.sdk.env].adminCapId),s.pure.bool(i)]}),s.setSender(t);let a=await o(this.sdk.suiClient,s,t,0);return C({inheritTx:s,sender:t,feeAmount:a},this.sdk.suiClient)}async buildSetAcceptedPaymentTypeTx({adminAddress:t,paymentCoinType:i,currentTx:n}){let s=n||new e;s.moveCall({target:`${T[this.sdk.env].packageId}::config::set_accepted_payment_type`,typeArguments:[i],arguments:[s.object(T[this.sdk.env].configId),s.object(T[this.sdk.env].adminCapId)]}),s.setSender(t);let a=await o(this.sdk.suiClient,s,t,0);return C({inheritTx:s,sender:t,feeAmount:a},this.sdk.suiClient)}}class w{network;env;_suiClient;boostingModule;subscriptionModule;constructor(e="mainnet",t="prod"){this.network=e,this.env=t;let i=a(e);this._suiClient=new s({url:i}),this.subscriptionModule=new x(this),this.boostingModule=new y(this)}get suiClient(){return this._suiClient}}export{v as ADMIN_CAP_ID,I as BOOSTING_PACKAGE_ID,y as BoostingModule,p as CLOCK_OBJECT_ID,k as CONFIG_ID,f as NATIVE_USDC_TOKEN_TYPE,w as NoodlesPaySdk,T as SUBSCRIPTION_CONFIG,c as SUI_FULL_TYPE,g as SUI_METADATA_OBJECT_ID,u as SUI_TYPE,x as SubscriptionModule,s as SuiClient,e as Transaction,l as USDC_TOKEN_TYPE,C as addGasFee,i as fromBase64,r as getAmountAfterFee,m as getCoinObjectIdsByAmount,a as getFullnodeUrl,o as getNeededGasFee,h as getSplitCoinForTx,d as getSplitCoinsAfterFee,b as isSuiCoinType,t as tiny_invariant};
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
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 bluefin7k_aggregator_sdk_namespaceObject=require("@bluefin-exchange/bluefin7k-aggregator-sdk"),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&&bluefin7k_aggregator_sdk_namespaceObject.Config.setApiKey(this._config.sevenKApiKey);let i=a?a.tradeFeePercent:this._config.defaultTradeFee.tradeFeePercent;return await (0,bluefin7k_aggregator_sdk_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,bluefin7k_aggregator_sdk_namespaceObject.buildTx)({quoteResponse:t,slippage:n,accountAddress:e,commission:{partner:o,commissionBps:1e4*i}});return r.tx instanceof bluefin7k_aggregator_sdk_namespaceObject.BluefinXTx?transactions_namespaceObject.Transaction.from(r.tx.txBytes).build({client:this._suiClient}):(r.tx.setSender(e),r.tx.build({client:this._suiClient}))}}!function(e){e.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}}}(_7k_SevenKAggregator||(_7k_SevenKAggregator={}));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})}}!function(e){e.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}}}(aftermath_AftermathAggregator||(aftermath_AftermathAggregator={}));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})}}!function(e){e.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}}}(astros_AstrosAggregator||(astros_AstrosAggregator={}));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);!function(e){e.equals=function(e,t){return e.tradeFeePercent===t.tradeFeePercent&&e.tradeFeeRecipientAddress===t.tradeFeeRecipientAddress}}(types_TradeFeeOptions||(types_TradeFeeOptions={}));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=this.cetusClient(t,a),o=new transactions_namespaceObject.Transaction;return o.setSender(t),await i.fastRouterSwap({router:e,txb:o,slippage:n}),o.build({client:this._suiClient})}}!function(e){e.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}}}(cetus_CetusAggregator||(cetus_CetusAggregator={}));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})))}}!function(e){e.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}}}(flowx_FlowXAggregator||(flowx_FlowXAggregator={})),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}}!function(e){e.transferOrDestroyZeroCoin=function(e,t,n,a){e.moveCall({target:`${BLUEFIN_PACKAGE_ID}::utils::transfer_or_destroy`,typeArguments:[t],arguments:[n,e.pure.address(a)]})}}(bluefin_BluefinTx||(bluefin_BluefinTx={})),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="0x3dd678c250a667f1551bc4b9e35fd070896f4775dd2900d5cb2910d2aea0b068",SUBSCRIPTION_CONFIG_ID="0x3eb7bd15f61b7cc1a9fd36151e9c3d05aa37bfadb0a58c3a26a6c02c2e99f3ca",SUBSCRIPTION_ADMIN_CAP_ID="0xf375fcb3d95934143766cab2028ab49441fa04ef2ce27c08c01004c455bcbad4",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],s=r.price*BigInt(r.monthInterval),{tx:u,coinData:c}=await getSplitCoinForTx({account:e,amount:s.toString(),splits:[s.toString()],coinType:a,inheritTx:i},this.sdk.suiClient);u.moveCall({target:`${SUBSCRIPTION_PACKAGE_ID}::subscription::subscribe_cycle_plan`,typeArguments:[a],arguments:[u.object(SUBSCRIPTION_CONFIG_ID),u.pure.u64(t),u.pure.string(n),c]}),u.setSender(e);let _=await getNeededGasFee(this.sdk.suiClient,u,e,0);return addGasFee({inheritTx:u,sender:e,feeAmount:_},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";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__,{splitSuiCoinAfterFeeFromBuyTx:()=>splitSuiCoinAfterFeeFromBuyTx,getAmountAfterFee:()=>getAmountAfterFee,addGasFee:()=>addGasFee,TradeFeeOptions:()=>types_TradeFeeOptions,getMemezPumpSDK:()=>getMemezPumpSDK,BLUEFIN_PACKAGE_ID:()=>BLUEFIN_PACKAGE_ID,DraftTransferTx:()=>DraftTransferTx,BlastFunSDKCalculation:()=>sdk_calculation_BlastFunSDKCalculation,SubscriptionModule:()=>SubscriptionModule,MoonbagsConstants:()=>constants_MoonbagsConstants,NoodlesPaySdk:()=>NoodlesPaySdk,Bps:()=>package_Bps,ADMIN_CAP_ID:()=>ADMIN_CAP_ID,MathUtils:()=>package_MathUtils,getMoveObject:()=>getMoveObject,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,MoonbagsCalculation:()=>calculation_MoonbagsCalculation,BoostingModule:()=>BoostingModule,NoodlesSdk:()=>NoodlesSdk,AstrosAggregator:()=>astros_AstrosAggregator,getMoveObjectContent:()=>getMoveObjectContent,getSplitCoinsAfterFee:()=>getSplitCoinsAfterFee,BlastFunSDKTransaction:()=>sdk_transaction_BlastFunSDKTransaction,CONFIG_ID:()=>CONFIG_ID,AftermathAggregator:()=>aftermath_AftermathAggregator,FlowXAggregator:()=>flowx_FlowXAggregator,SUBSCRIPTION_CONFIG:()=>SUBSCRIPTION_CONFIG,adaptSuiClient:()=>adaptSuiClient,getNeededGasFee:()=>getNeededGasFee,AggregatorModule:()=>AggregatorModule,BlastFunCustomCalculation:()=>custom_calculation_BlastFunCustomCalculation,SupportedBondingCurve:()=>types_SupportedBondingCurve,adaptTransaction:()=>adaptTransaction,BASE_BPS:()=>1e4,createCompatibleSuiClient:()=>createCompatibleSuiClient,getSplitCoinForTx:()=>getSplitCoinForTx,BluefinTx:()=>bluefin_BluefinTx,splitSuiCoinAfterFeeFromSellTx:()=>splitSuiCoinAfterFeeFromSellTx,SupportedAggregator:()=>common_SupportedAggregator,NATIVE_USDC_TOKEN_TYPE:()=>NATIVE_USDC_TOKEN_TYPE,BOOSTING_PACKAGE_ID:()=>BOOSTING_PACKAGE_ID,SUI_METADATA_OBJECT_ID:()=>SUI_METADATA_OBJECT_ID,SUI_TYPE:()=>SUI_TYPE,USDC_TOKEN_TYPE:()=>USDC_TOKEN_TYPE,isSuiCoinType:()=>isSuiCoinType,MoonbagsPackage:()=>package_MoonbagsPackage,SevenKAggregator:()=>_7k_SevenKAggregator,SUI_FULL_TYPE:()=>SUI_FULL_TYPE,getCoinObjectIdsByAmount:()=>getCoinObjectIdsByAmount,BlastFunConstants:()=>constants_BlastFunConstants});const bluefin7k_aggregator_sdk_namespaceObject=require("@bluefin-exchange/bluefin7k-aggregator-sdk"),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&&bluefin7k_aggregator_sdk_namespaceObject.Config.setApiKey(this._config.sevenKApiKey);let i=a?a.tradeFeePercent:this._config.defaultTradeFee.tradeFeePercent;return await (0,bluefin7k_aggregator_sdk_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,bluefin7k_aggregator_sdk_namespaceObject.buildTx)({quoteResponse:t,slippage:n,accountAddress:e,commission:{partner:o,commissionBps:1e4*i}});return r.tx instanceof bluefin7k_aggregator_sdk_namespaceObject.BluefinXTx?transactions_namespaceObject.Transaction.from(r.tx.txBytes).build({client:this._suiClient}):(r.tx.setSender(e),r.tx.build({client:this._suiClient}))}}!function(e){e.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}}}(_7k_SevenKAggregator||(_7k_SevenKAggregator={}));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})}}!function(e){e.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}}}(aftermath_AftermathAggregator||(aftermath_AftermathAggregator={}));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})}}!function(e){e.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}}}(astros_AstrosAggregator||(astros_AstrosAggregator={}));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);!function(e){e.equals=function(e,t){return e.tradeFeePercent===t.tradeFeePercent&&e.tradeFeeRecipientAddress===t.tradeFeeRecipientAddress}}(types_TradeFeeOptions||(types_TradeFeeOptions={}));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=this.cetusClient(t,a),o=new transactions_namespaceObject.Transaction;return o.setSender(t),await i.fastRouterSwap({router:e,txb:o,slippage:n}),o.build({client:this._suiClient})}}!function(e){e.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}}}(cetus_CetusAggregator||(cetus_CetusAggregator={}));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})))}}!function(e){e.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}}}(flowx_FlowXAggregator||(flowx_FlowXAggregator={})),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),l=package_Bps.calcUp(c,o),_=o-(package_Bps.value(c)!==BigInt(0)?l:BigInt(0)),d=(u+s)*_/(r+_);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=[],l=[];for(let e of s)if(u=(BigInt(e.balance)+BigInt(u)).toString(10),c.push(e.coinObjectId),l.push(e),BigInt(u)>=BigInt(n))break;return{objectIds:c,balance:u,objectCoins:l}};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:l}=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?(l.length>1&&c.mergeCoins(c.object(_),l.slice(1).map(e=>c.object(e))),e=c.splitCoins(c.object(_),i)):e=c.splitCoins(c.gas,i),{tx:c,coinData:e}}l.length>1&&c.mergeCoins(c.object(_),l.slice(1).map(e=>c.object(e)));let d=c.splitCoins(c.object(_),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:l,coinIn:_}=u||{},d=getSplitCoinsAfterFee(i,r||"0"),g=l||new transactions_namespaceObject.Transaction;if(_)n=g.splitCoins(_,d),bluefin_BluefinTx.transferOrDestroyZeroCoin(g,SUI_FULL_TYPE,_,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}}!function(e){e.transferOrDestroyZeroCoin=function(e,t,n,a){e.moveCall({target:`${BLUEFIN_PACKAGE_ID}::utils::transfer_or_destroy`,typeArguments:[t],arguments:[n,e.pure.address(a)]})}}(bluefin_BluefinTx||(bluefin_BluefinTx={})),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}),l=BigInt(new(external_bignumber_js_default())(c.toString()).multipliedBy(1-o).toFixed(0,3)),{tx:_,coinOut:d}=await t({accountAddress:r,inCoinType:n,outCoinType:a,inputAmount:e.toString(),minAmountOut:l.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"),_.transferObjects([d],_.pure.address(r)),_.setSender(r);let g=await getNeededGasFee(u,_,r,0);return(_=await addGasFee({inheritTx:_,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}),l=BigInt(new(external_bignumber_js_default())(c.toString()).multipliedBy(1-o).toFixed(0,3)),{tx:_,coinOut:d}=await n({accountAddress:r,inCoinType:t,outCoinType:a,inputAmount:e.toString(),minAmountOut:l.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"),_.transferObjects([d],_.pure.address(r)),_.setSender(r);let g=await getNeededGasFee(u,_,r,0);return(_=await addGasFee({inheritTx:_,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),l=e.Curves.calculateRemoveLiquidityReturn(s,u,a),_=u-(r||c),d=l,g=a;l>_&&(d=_,g=e.Curves.calculateAddLiquidityCost(s,u,_)+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,l=u-c;return{receivedCurve:BigInt(0),receivedSui:l}}}(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),l=BigInt(new(external_bignumber_js_default())(c.toString()).multipliedBy(1-o).toFixed(0,3)),{tx:_,coinOut:d}=await t({accountAddress:r,inCoinType:n,outCoinType:a,inputAmount:e.toString(),minAmountOut:l.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"),_.transferObjects([d],_.pure.address(r)),_.setSender(r);let g=await getNeededGasFee(u,_,r,0);return(_=await addGasFee({inheritTx:_,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),l=BigInt(new(external_bignumber_js_default())(c.toString()).multipliedBy(1-o).toFixed(0,3)),{tx:_,coinOut:d}=await n({accountAddress:r,inCoinType:t,outCoinType:a,inputAmount:e.toString(),minAmountOut:l.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"),_.transferObjects([d],_.pure.address(r)),_.setSender(r);let g=await getNeededGasFee(u,_,r,0);return(_=await addGasFee({inheritTx:_,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_CONFIG={prod:{packageId:"0x3dd678c250a667f1551bc4b9e35fd070896f4775dd2900d5cb2910d2aea0b068",configId:"0x3eb7bd15f61b7cc1a9fd36151e9c3d05aa37bfadb0a58c3a26a6c02c2e99f3ca",adminCapId:"0xf375fcb3d95934143766cab2028ab49441fa04ef2ce27c08c01004c455bcbad4",paymentCoinType:"0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC"},staging:{packageId:"0xa83cd093ce5142649adae10d21fe87d55fa2df4e52a4292c77ba039bb12bfe67",configId:"0x19fb8f91946e58c068fa4238bdd7a531216a0c4dcfaa279a8a02c60cb02f6711",adminCapId:"0xd8139544d054702dfab6de4e9c55f162c8a6f30465935af56cffed99c5e1c2bd",paymentCoinType:"0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC"}};class SubscriptionModule{sdk;constructor(e){this.sdk=e}async getConfig(){let e=await this.sdk.suiClient.getObject({id:SUBSCRIPTION_CONFIG[this.sdk.env].configId,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=SUBSCRIPTION_CONFIG[this.sdk.env].paymentCoinType,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],s=r.price*BigInt(r.monthInterval),{tx:u,coinData:c}=await getSplitCoinForTx({account:e,amount:s.toString(),splits:[s.toString()],coinType:a,inheritTx:i},this.sdk.suiClient);u.moveCall({target:`${SUBSCRIPTION_CONFIG[this.sdk.env].packageId}::subscription::subscribe_cycle_plan`,typeArguments:[a],arguments:[u.object(SUBSCRIPTION_CONFIG[this.sdk.env].configId),u.pure.u64(t),u.pure.string(n),c]}),u.setSender(e);let l=await getNeededGasFee(this.sdk.suiClient,u,e,0);return addGasFee({inheritTx:u,sender:e,feeAmount:l},this.sdk.suiClient)}async buildBuyMoreCUPlanTx({walletAddress:e,planId:t,reference:n,paidAmount:a,paymentCoinType:i=SUBSCRIPTION_CONFIG[this.sdk.env].paymentCoinType,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_CONFIG[this.sdk.env].packageId}::subscription::buy_more_cu`,typeArguments:[i],arguments:[s.object(SUBSCRIPTION_CONFIG[this.sdk.env].configId),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=SUBSCRIPTION_CONFIG[this.sdk.env].paymentCoinType,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_CONFIG[this.sdk.env].packageId}::subscription::subscribe_plan_with_admin`,typeArguments:[i],arguments:[s.object(SUBSCRIPTION_CONFIG[this.sdk.env].adminCapId),s.object(SUBSCRIPTION_CONFIG[this.sdk.env].configId),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_CONFIG[this.sdk.env].packageId}::config::add_plan`,typeArguments:[],arguments:[r.object(SUBSCRIPTION_CONFIG[this.sdk.env].configId),r.object(SUBSCRIPTION_CONFIG[this.sdk.env].adminCapId),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_CONFIG[this.sdk.env].packageId}::config::update_plan`,typeArguments:[],arguments:[r.object(SUBSCRIPTION_CONFIG[this.sdk.env].configId),r.object(SUBSCRIPTION_CONFIG[this.sdk.env].adminCapId),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_CONFIG[this.sdk.env].packageId}::config::remove_plan`,typeArguments:[],arguments:[a.object(SUBSCRIPTION_CONFIG[this.sdk.env].configId),a.object(SUBSCRIPTION_CONFIG[this.sdk.env].adminCapId),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_CONFIG[this.sdk.env].packageId}::config::update_fee_receiver`,typeArguments:[],arguments:[a.object(SUBSCRIPTION_CONFIG[this.sdk.env].configId),a.object(SUBSCRIPTION_CONFIG[this.sdk.env].adminCapId),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_CONFIG[this.sdk.env].packageId}::config::set_paused`,typeArguments:[],arguments:[a.object(SUBSCRIPTION_CONFIG[this.sdk.env].configId),a.object(SUBSCRIPTION_CONFIG[this.sdk.env].adminCapId),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_CONFIG[this.sdk.env].packageId}::config::set_accepted_payment_type`,typeArguments:[t],arguments:[a.object(SUBSCRIPTION_CONFIG[this.sdk.env].configId),a.object(SUBSCRIPTION_CONFIG[this.sdk.env].adminCapId)]}),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{network;env;_suiClient;boostingModule;subscriptionModule;constructor(e="mainnet",t="prod"){this.network=e,this.env=t;const n=(0,client_namespaceObject.getFullnodeUrl)(e);this._suiClient=new client_namespaceObject.SuiClient({url:n}),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{network;env;options;_suiClient;aggregatorModule;curveModule;constructor(e,t="mainnet",n="prod"){this.options=e,this.network=t,this.env=n;const a=(0,client_namespaceObject.getFullnodeUrl)(t);this._suiClient=new client_namespaceObject.SuiClient({url:a}),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.SUBSCRIPTION_CONFIG=__webpack_exports__.SUBSCRIPTION_CONFIG,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","SUBSCRIPTION_CONFIG","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});
|
package/dist/index.d.ts
CHANGED
|
@@ -736,6 +736,11 @@ export declare class DraftTransferTx {
|
|
|
736
736
|
getTransactionStatus(txDigest: string): Promise<TransactionStatus>;
|
|
737
737
|
}
|
|
738
738
|
|
|
739
|
+
declare enum Environment {
|
|
740
|
+
Prod = "prod",
|
|
741
|
+
Staging = "staging"
|
|
742
|
+
}
|
|
743
|
+
|
|
739
744
|
export declare interface ExecutionResult {
|
|
740
745
|
readonly success: boolean;
|
|
741
746
|
readonly txDigest?: string;
|
|
@@ -1197,20 +1202,29 @@ export declare type MoveObjectStruct<Content> = {
|
|
|
1197
1202
|
|
|
1198
1203
|
export declare const NATIVE_USDC_TOKEN_TYPE = "0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC";
|
|
1199
1204
|
|
|
1205
|
+
declare enum Network {
|
|
1206
|
+
Mainnet = "mainnet",
|
|
1207
|
+
Testnet = "testnet"
|
|
1208
|
+
}
|
|
1209
|
+
|
|
1200
1210
|
export declare class NoodlesPaySdk {
|
|
1211
|
+
readonly network: Network;
|
|
1212
|
+
readonly env: Environment;
|
|
1201
1213
|
private _suiClient;
|
|
1202
1214
|
readonly boostingModule: BoostingModule;
|
|
1203
1215
|
readonly subscriptionModule: SubscriptionModule;
|
|
1204
|
-
constructor();
|
|
1216
|
+
constructor(network?: Network, env?: Environment);
|
|
1205
1217
|
get suiClient(): SuiClient;
|
|
1206
1218
|
}
|
|
1207
1219
|
|
|
1208
1220
|
export declare class NoodlesSdk {
|
|
1221
|
+
readonly network: Network;
|
|
1222
|
+
readonly env: Environment;
|
|
1209
1223
|
readonly options: SdkOptions;
|
|
1210
1224
|
private _suiClient;
|
|
1211
1225
|
readonly aggregatorModule: AggregatorModule;
|
|
1212
1226
|
readonly curveModule: CurveModule;
|
|
1213
|
-
constructor(options: SdkOptions);
|
|
1227
|
+
constructor(options: SdkOptions, network?: Network, env?: Environment);
|
|
1214
1228
|
get suiClient(): SuiClient;
|
|
1215
1229
|
}
|
|
1216
1230
|
|
|
@@ -1244,9 +1258,6 @@ export declare type PayBoostingWithAdminRequest = {
|
|
|
1244
1258
|
currentTx?: Transaction;
|
|
1245
1259
|
};
|
|
1246
1260
|
|
|
1247
|
-
/** Payment coin type on SUI */
|
|
1248
|
-
export declare const PAYMENT_COIN_TYPE = "0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC";
|
|
1249
|
-
|
|
1250
1261
|
/**
|
|
1251
1262
|
* Parameters for removing a subscription plan (admin only).
|
|
1252
1263
|
*/
|
|
@@ -1403,14 +1414,7 @@ export declare type SubscribePlanWithAdminRequest = {
|
|
|
1403
1414
|
currentTx?: Transaction;
|
|
1404
1415
|
};
|
|
1405
1416
|
|
|
1406
|
-
|
|
1407
|
-
export declare const SUBSCRIPTION_ADMIN_CAP_ID = "0xf375fcb3d95934143766cab2028ab49441fa04ef2ce27c08c01004c455bcbad4";
|
|
1408
|
-
|
|
1409
|
-
/** Configuration object ID for subscription settings */
|
|
1410
|
-
export declare const SUBSCRIPTION_CONFIG_ID = "0x3eb7bd15f61b7cc1a9fd36151e9c3d05aa37bfadb0a58c3a26a6c02c2e99f3ca";
|
|
1411
|
-
|
|
1412
|
-
/** Sui package ID for the subscription protocol */
|
|
1413
|
-
export declare const SUBSCRIPTION_PACKAGE_ID = "0x3dd678c250a667f1551bc4b9e35fd070896f4775dd2900d5cb2910d2aea0b068";
|
|
1417
|
+
export declare const SUBSCRIPTION_CONFIG: Record<Environment, SubscriptionPkgConfig>;
|
|
1414
1418
|
|
|
1415
1419
|
/**
|
|
1416
1420
|
* Complete subscription protocol configuration.
|
|
@@ -1542,6 +1546,13 @@ export declare class SubscriptionModule implements IPayModule {
|
|
|
1542
1546
|
buildSetAcceptedPaymentTypeTx({ adminAddress, paymentCoinType, currentTx, }: SetAcceptedPaymentTypeRequest): Promise<Transaction>;
|
|
1543
1547
|
}
|
|
1544
1548
|
|
|
1549
|
+
declare type SubscriptionPkgConfig = {
|
|
1550
|
+
packageId: string;
|
|
1551
|
+
configId: string;
|
|
1552
|
+
adminCapId: string;
|
|
1553
|
+
paymentCoinType: string;
|
|
1554
|
+
};
|
|
1555
|
+
|
|
1545
1556
|
/**
|
|
1546
1557
|
* Information about a specific subscription plan.
|
|
1547
1558
|
*/
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{BluefinXTx as e,Config as t,buildTx as n,getQuote as i}from"@bluefin-exchange/bluefin7k-aggregator-sdk";import r from"bignumber.js";import{Aftermath as o,Helpers as a}from"aftermath-ts-sdk";import{buildSwapPTBFromQuote as u,getCoins as s,getQuote as c}from"@naviprotocol/astros-aggregator-sdk";import{AggregatorClient as l,Env as d}from"@cetusprotocol/aggregator-sdk";import g from"bn.js";import{AggregatorQuoter as p,Coin as m,Commission as f,CommissionType as _,TradeBuilder as A}from"@flowx-finance/sdk";import{MemezPumpSDK as I}from"@interest-protocol/memez-fun-sdk";import{Network as T}from"@interest-protocol/sui-core-sdk";import{Ed25519Keypair as h}from"@mysten/sui/keypairs/ed25519";import{getAmountAfterFee as y,getSplitCoinForTx as C,getNeededGasFee as F,addGasFee as O,Transaction as w,SuiClient as B,CLOCK_OBJECT_ID as b,SUI_TYPE as v,isSuiCoinType as S,SUI_METADATA_OBJECT_ID as R,getFullnodeUrl as E,SUI_FULL_TYPE as P,getSplitCoinsAfterFee as x,fromBase64 as k,tiny_invariant as M}from"./982.js";class D{_config;_suiClient;constructor(e,t){this._config=e,this._suiClient=t}async getTradeRoute({coinInAmount:e,coinInType:n,coinOutType:r,tradeFee:o}){try{this._config.sevenKApiKey&&t.setApiKey(this._config.sevenKApiKey);let a=o?o.tradeFeePercent:this._config.defaultTradeFee.tradeFeePercent;return await i({tokenIn:n,tokenOut:r,amountIn:e.toString(),commissionBps:1e4*a})}catch(e){return null}}async getTransaction({walletAddress:t,completeRoute:i,slippage:r,tradeFee:o}){let a,u;o?(a=o.tradeFeePercent,u=o.tradeFeeRecipientAddress):(a=this._config.defaultTradeFee.tradeFeePercent,u=this._config.defaultTradeFee.tradeFeeRecipientAddress);let s=await n({quoteResponse:i,slippage:r,accountAddress:t,commission:{partner:u,commissionBps:1e4*a}});return s.tx instanceof e?w.from(s.tx.txBytes).build({client:this._suiClient}):(s.tx.setSender(t),s.tx.build({client:this._suiClient}))}}(D||(D={})).toCommonTradeRoutes=function(e){let t=[];if(!e.routes||0===e.routes.length)return null;for(let n of e.routes){let e=[],i={};for(let t of n.hops){for(let e of t.pool.allTokens)i[e.address]=e.decimal;let n=i[t.tokenIn]??0,o=i[t.tokenOut]??0,a=BigInt(new r(t.tokenInAmount).multipliedBy(10**n).toFixed(0,3)),u=BigInt(new r(t.tokenOutAmount).multipliedBy(10**o).toFixed(0,3));e.push({poolAddress:t.poolId,coinIn:t.tokenIn,coinOut:t.tokenOut,amountIn:a,amountOut:u})}if(0===e.length)continue;let o=i[n.tokenIn]??0,a=i[n.tokenOut]??0,u=BigInt(new r(n.tokenInAmount).multipliedBy(10**o).toFixed(0,3)),s=BigInt(new r(n.tokenOutAmount).multipliedBy(10**a).toFixed(0,3));t.push({paths:e,coinIn:n.tokenIn,coinOut:n.tokenOut,amountIn:u,amountOut:s})}return 0===t.length?null:{coinIn:e.tokenIn,coinOut:e.tokenOut,amountIn:BigInt(e.swapAmountWithDecimal),amountOut:BigInt(e.returnAmountWithDecimal),routes:t}};class N{_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 o(this._config.aftermathApiEndpoint):this._aftermathClient=new o("MAINNET"),await this._aftermathClient.init(),this._config.aftermathApiKey){let e=a.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:i}){try{let r;r=i?{recipient:i.tradeFeeRecipientAddress,feePercentage:i.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:r})}catch(e){return null}}async getTransaction({completeRoute:e,walletAddress:t,slippage:n}){let i=await this.aftermathClient(),r=await i.Router().getTransactionForCompleteTradeRoute({completeRoute:e,walletAddress:t,slippage:n,isSponsoredTx:!1});return r.setSender(t),r.build({client:this._suiClient})}}(N||(N={})).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}};class K{_config;_suiClient;constructor(e,t){this._config=e,this._suiClient=t}async getTradeRoute({coinInAmount:e,coinInType:t,coinOutType:n,tradeFee:i}){try{let r;return r=i?{fee:i.tradeFeePercent,receiverAddress:i.tradeFeeRecipientAddress}:{fee:this._config.defaultTradeFee.tradeFeePercent,receiverAddress:this._config.defaultTradeFee.tradeFeeRecipientAddress},await c(t,n,e,this._config.astrosApiKey,{byAmountIn:!0,serviceFee:r})}catch(e){return null}}returnMergedCoins(e,t,n){if(t.length<2)return e.object(t[0].coinObjectId);let i=0,r=[];t.sort((e,t)=>Number(t.balance)-Number(e.balance)).slice(1).forEach(e=>{i>=n||(i+=Number(e.balance),r.push(e.coinObjectId))});let o=t[0].coinObjectId;return e.mergeCoins(o,r),e.object(o)}async getTransaction({completeRoute:e,walletAddress:t,slippage:n,tradeFee:i}){var o;let a,c;a=i?{fee:i.tradeFeePercent,receiverAddress:i.tradeFeeRecipientAddress}:{fee:this._config.defaultTradeFee.tradeFeePercent,receiverAddress:this._config.defaultTradeFee.tradeFeeRecipientAddress};let l=new r(e.amount_out).multipliedBy(1-n-a.fee).toNumber(),d=new w;if("0x2::sui::SUI"===(o=e.from)||"0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI"===o)c=d.splitCoins(d.gas,[d.pure.u64(e.amount_in)]);else{let n=await s(this._suiClient,t,e.from),i=this.returnMergedCoins(d,n.data,Number.parseFloat(e.amount_in));c=d.splitCoins(i,[d.pure.u64(e.amount_in)])}let g=await u(t,d,l,c,e,void 0,!1,this._config.astrosApiKey,{serviceFee:a});return d.transferObjects([g],t),d.setSender(t),d.build({client:this._suiClient})}}(K||(K={})).toCommonTradeRoutes=function(e,t,n){if(0===e.routes.length)return null;let i=[];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&&i.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===i.length?null:{coinIn:t,coinOut:n,amountIn:BigInt(e.amount_in),amountOut:BigInt(e.amount_out),routes:i}},(ee||(ee={})).equals=function(e,t){return e.tradeFeePercent===t.tradeFeePercent&&e.tradeFeeRecipientAddress===t.tradeFeeRecipientAddress};class U{_config;_suiClient;_cetusClient;constructor(e,t){this._config=e,this._suiClient=t}cetusClient(e,t){return t&&!ee.equals(t,this._config.defaultTradeFee)?new l({client:this._suiClient,overlayFeeReceiver:t.tradeFeeRecipientAddress,overlayFeeRate:t.tradeFeePercent,env:d.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 l({client:this._suiClient,overlayFeeReceiver:this._config.defaultTradeFee.tradeFeeRecipientAddress,overlayFeeRate:this._config.defaultTradeFee.tradeFeePercent,env:d.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:i}){try{let r=this.cetusClient(void 0,i);return await r.findRouters({from:t,target:n,amount:new g(e.toString()),byAmountIn:!0})}catch(e){return null}}async getTransaction({completeRoute:e,walletAddress:t,slippage:n,tradeFee:i}){let r=this.cetusClient(t,i),o=new w;return o.setSender(t),await r.fastRouterSwap({router:e,txb:o,slippage:n}),o.build({client:this._suiClient})}}(U||(U={})).toCommonTradeRoutes=function(e,t,n){if(0===e.paths.length)return null;let i=[],r=[],o=[];for(let t=0;t<e.paths.length;t++){let n=e.paths[t],i={poolAddress:n.id,amountIn:BigInt(n.amountIn),amountOut:BigInt(n.amountOut),coinIn:n.from,coinOut:n.target};if(o.push(i),t===e.paths.length-1)r.push([...o]);else{let i=e.paths[t+1];n.target!==i.from&&(r.push([...o]),o=[])}}for(let e of r)0!==e.length&&i.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===i.length?null:{coinIn:t,coinOut:n,amountIn:BigInt(e.amountIn.toString(10)),amountOut:BigInt(e.amountOut.toString(10)),routes:i}};var j,G,q,L,z,J,$,V,W,X,H,Y,Z,Q,ee,et,en,ei,er,eo,ea,eu,es,ec,el,ed,eg,ep,em=((Q={}).ASTROS="ASTROS",Q.AFTERMATH="AFTERMATH",Q.SEVENK="7K",Q.CETUS="CETUS",Q.FLOWX="FLOWX",Q);class ef{_config;_suiClient;constructor(e,t){this._config=e,this._suiClient=t}getCommission(e,t){let n,i;return t?(n=t.tradeFeePercent,i=t.tradeFeeRecipientAddress):(n=this._config.defaultTradeFee.tradeFeePercent,i=this._config.defaultTradeFee.tradeFeeRecipientAddress),new f(i,new m(e),_.PERCENTAGE,1e6*n,!0)}async getTradeRoute({coinInAmount:e,coinInType:t,coinOutType:n,tradeFee:i}){let r=new p("mainnet",this._config.flowxApiKey);try{return await r.getRoutes({tokenIn:t,tokenOut:n,amountIn:e.toString(),commission:this.getCommission(t,i)})}catch(e){return null}}async getTransaction({walletAddress:e,completeRoute:t,slippage:n,tradeFee:i}){return new A("mainnet",t.routes).sender(e).slippage(1e6*n).commission(this.getCommission(t.coinIn.coinType,i)).build().buildTransaction({client:this._suiClient}).then(t=>(t.setSender(e),t.build({client:this._suiClient})))}}async function e_(e,t){return(await eA(e,t)).fields}async function eA(e,t){let n=await e.getObject({id:t,options:{showContent:!0}}),i=n.data?.content;return M(i,"Pool object not found or has no content"),M("moveObject"===i.dataType,"Object is not a Move object"),i}(ef||(ef={})).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}},(j=et||(et={})).PACKAGE_ID_V4="0x7e6aa6e179466ab2814425a780b122575296d011119fa69d27f289f5a28814bd",j.MEMEZ_AV_OBJECT_ID="0x2319e3e76dfad73d8f4684bdbf42be4f32d8ce4521dd61becc8261dc918d82c0",((G=en||(en={})).U64||(G.U64={})).mulDivUp=function(e,t,n){let i=BigInt(0);return e*t%n>BigInt(0)&&(i=BigInt(1)),e*t/n+i};var eI=ei||(ei={});function eT(e){return M(BigInt(e)<=BigInt(1e4),"Bps overflow"),BigInt(e)}eI.calcUp=function(e,t){let n,i=BigInt(e.pos0),r=BigInt(1e4);return n=i*t%r!==BigInt(0)?BigInt(1):BigInt(0),i*t/r+n},eI.sub=function(e,t){return M(BigInt(e.pos0)>=BigInt(t.pos0),"Bps underflow"),{pos0:(BigInt(e.pos0)-BigInt(t.pos0)).toString()}},eI.value=function(e){return BigInt(e.pos0)},eI.new_=function(e){return{pos0:eT(e).toString()}},eI.assertOverflow=eT,((q=er||(er={})).MemezFun||(q.MemezFun={})).isSniperProtectedMemezFun=async function(e,t){return(await e_(e,t)).public_key.length>0},(L=q.MemezFees||(q.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 i=e.fields.pos0.fields;if(BigInt(i.pos0)===BigInt(0))return BigInt(0);let r=ei.calcUp(ei.sub(i,n),t);if(t>=r)return r;throw Error(`Insufficient amount to cover fee. Required: ${r}, provided: ${t}`)}throw Error("Unknown fee variant")},L.calculateWithDiscount=function(e,t,n){if("Value"===e.variant)return BigInt(e.fields.pos0);if("Percentage"===e.variant){let i=e.fields.pos0.fields;return ei.calcUp(ei.sub(i,t),n)}throw Error("Unknown fee variant")},(q.MemezBurner||(q.MemezBurner={})).calculate=function(e,t){if(ei.value(e.fee.fields)===BigInt(0)||t===BigInt(0)||t>=BigInt(e.target_liquidity))return ei.new_(0);let n=BigInt(1e4);return ei.new_(en.U64.mulDivUp(ei.value(e.fee.fields),en.U64.mulDivUp(t,n,BigInt(e.target_liquidity)),n))},(z=q.MemezPump||(q.MemezPump={})).getPumpState=async function(e,t){return await e_(e,t.inner_state)},z.pump=function(e,t){let n=e.constant_product.fields,i=q.MemezFees.takeWithDiscount(n.quote_swap_fee,t,n.quote_referrer_fee.fields),r=t-i,o=BigInt(n.meme_balance),a=BigInt(n.quote_balance),u=o*r/(BigInt(n.virtual_liquidity)+a+r),s=q.MemezFees.takeWithDiscount(n.meme_swap_fee,u,n.meme_referrer_fee.fields);return u-s},z.dump=function(e,t){let n=e.constant_product.fields,i=q.MemezFees.takeWithDiscount(n.meme_swap_fee,t,n.meme_referrer_fee.fields),r=t-i,o=BigInt(n.meme_balance),a=BigInt(n.quote_balance),u=BigInt(n.virtual_liquidity),s=q.MemezBurner.calculate(n.burner.fields,a),c=ei.calcUp(s,r),l=r-(ei.value(s)!==BigInt(0)?c:BigInt(0)),d=(u+a)*l/(o+l);d>a&&(d=a);let g=q.MemezFees.takeWithDiscount(n.quote_swap_fee,d,n.quote_referrer_fee.fields);return d-g},(J=eo||(eo={})).getCurveAmountAfterBuy=async function(e,t){let{suiAmount:n,poolId:i,frontendFee:r}=e,o=await e_(t,i),a=await er.MemezPump.getPumpState(t,o);return n=y(n,r),er.MemezPump.pump(a,n)},J.getSuiAmountAfterSell=async function(e,t){let{curveAmount:n,poolId:i,frontendFee:r}=e,o=await e_(t,i),a=await er.MemezPump.getPumpState(t,o);return y(er.MemezPump.dump(a,n),r)};let eh="0x62412b7268c35f3808336aee57a52836501f40b8ba5d936f8ad275e672befd04";async function ey(e,t){let n,i,{inputAmount:r,accountAddress:o,frontendFee:a,frontendFeeRecipient:u,extendTx:s,isSponsored:c}=e;M(e.inCoinType===P||e.inCoinType===v,"Input must be SUI");let{tx:l,coinIn:d}=s||{},g=x(r,a||"0"),p=l||new w;if(d)n=p.splitCoins(d,g),ea.transferOrDestroyZeroCoin(p,P,d,o);else{let{coinData:e}=await C({account:o,amount:r,splits:g,coinType:P,inheritTx:p,isSponsored:c||!1},t);n=e}if(a&&u){let[e,t]=n;i=e,p.transferObjects([t],p.pure.address(u||o))}else[i]=n;return{tx:p,coinOut:i}}async function eC(e,t,n){if(M(t.outCoinType===P||t.outCoinType===v,"Output must be SUI"),0>=Number(t.frontendFee||0))return{tx:e,coinOut:n};let i=e.moveCall({target:"0x2::coin::value",typeArguments:[t.outCoinType],arguments:[n]}),r=e.moveCall({target:`${eh}::math::mul_div_u64`,typeArguments:[],arguments:[i,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,r]});return e.transferObjects([o],e.pure.address(t.frontendFeeRecipient||t.accountAddress)),{tx:e,coinOut:n}}(ea||(ea={})).transferOrDestroyZeroCoin=function(e,t,n,i){e.moveCall({target:`${eh}::utils::transfer_or_destroy`,typeArguments:[t],arguments:[n,e.pure.address(i)]})};var eF=eu||(eu={});async function eO(e){let t=e||new w;return t.moveCall({target:`${et.PACKAGE_ID_V4}::memez_allowed_versions::get_allowed_versions`,arguments:[t.object(et.MEMEZ_AV_OBJECT_ID)],typeArguments:[]})}eF.getAllowedVersions=eO,eF.buildBuyTx=async function(e,t){M(!await er.MemezFun.isSniperProtectedMemezFun(t,e.poolId),"This coin is a sniper protected coin, please use the Blast Fun website to trade it.");let{tx:n,coinOut:i}=await ey(e,t);M(i,"Coin out is required");let r=n.moveCall({target:`${et.PACKAGE_ID_V4}::memez_pump::pump`,typeArguments:[e.outCoinType,P],arguments:[n.object(e.poolId),i,n.pure.vector("address",[]),n.pure.vector("vector<u8>",[]),n.pure.u64(e.minAmountOut),await eO(n)]});return{tx:n,coinOut:r}},eF.buildSellTx=async function(e,t){M(e.outCoinType===P||e.outCoinType===v,"Output must be SUI");let n=await e_(t,e.poolId),{tx:i,coinData:r}=await C({amount:e.inputAmount,coinType:e.inCoinType,inheritTx:e.extendTx?.tx,account:e.accountAddress,splits:[e.inputAmount]},t),[o]=r,[a]=i.moveCall({target:`${et.PACKAGE_ID_V4}::memez_pump::dump`,typeArguments:[e.inCoinType,e.outCoinType],arguments:[i.object(e.poolId),i.object(n.ipx_meme_coin_treasury),o,i.pure.vector("address",[]),i.pure.u64(e.minAmountOut),await eO(i)]});return await eC(i,e,a)};let ew=new I({network:T.MAINNET,fullNodeUrl:E("mainnet")});function eB(){return ew}($=es||(es={})).getCurveAmountAfterBuy=async function(e){let{suiAmount:t,poolId:n,frontendFee:i}=e;t=y(t,i);let{memeAmountOut:r}=await eB().quotePump({pool:n,amount:t});return r},$.getSuiAmountAfterSell=async function(e){let{curveAmount:t,poolId:n,frontendFee:i}=e,{quoteAmountOut:r}=await eB().quoteDump({pool:n,amount:t});return y(r,i)};var eb=ec||(ec={});async function ev(e,t){let{tx:n,coinOut:i}=await ey(e,t);M(i,"Coin out is required");let{memeCoin:r,tx:o}=await eB().pump({pool:e.poolId,quoteCoin:i,minAmountOut:e.minAmountOut,tx:n});return{tx:o,coinOut:r}}async function eS(e,t){M(S(e.outCoinType),"Output must be SUI");let{tx:n,coinData:i}=await C({amount:e.inputAmount,coinType:e.inCoinType,inheritTx:e.extendTx?.tx,account:e.accountAddress,splits:[e.inputAmount]},t),[r]=i,{quoteCoin:o,tx:a}=await eB().dump({pool:e.poolId,memeCoin:r,tx:n,minAmountOut:e.minAmountOut});return await eC(a,e,o)}eb.buildBuyTx=ev,eb.buildSellTx=eS,eb.getBuyTransaction=async function({coinInAmount:e,coinInType:t,coinOutType:n,poolId:i,slippage:o,walletAddress:a,tradeFee:u},s){M(S(t),"coinInType must be SUI for buy transaction"),M(n!==t,"coinOutType must be different from coinInType"),M(o>=0&&o<1,"slippage must be between 0 (inclusive) and 1 (exclusive)"),M(e>0,"coinInAmount must be greater than 0");let c=BigInt(new r((await es.getCurveAmountAfterBuy({poolId:i,suiAmount:e,frontendFee:u?u.tradeFeePercent:void 0})).toString()).multipliedBy(1-o).toFixed(0,3)),{tx:l,coinOut:d}=await ev({accountAddress:a,inCoinType:t,outCoinType:n,inputAmount:e.toString(),minAmountOut:c.toString(),poolId:i,frontendFee:u?u.tradeFeePercent:void 0,frontendFeeRecipient:u?u.tradeFeeRecipientAddress:void 0,extendTx:void 0,isSponsored:!1},s);M(d,"Coin out is required"),l.transferObjects([d],l.pure.address(a)),l.setSender(a);let g=await F(s,l,a,0);return(l=await O({inheritTx:l,sender:a,feeAmount:g,suiInputAmount:e},s)).build({client:s})},eb.getSellTransaction=async function({coinInAmount:e,coinInType:t,coinOutType:n,poolId:i,slippage:o,walletAddress:a,tradeFee:u},s){M(S(n),"coinOutType must be SUI for sell transaction"),M(n!==t,"coinOutType must be different from coinInType"),M(o>=0&&o<1,"slippage must be between 0 (inclusive) and 1 (exclusive)"),M(e>0,"coinInAmount must be greater than 0");let c=BigInt(new r((await es.getSuiAmountAfterSell({poolId:i,curveAmount:e,frontendFee:u?u.tradeFeePercent:void 0})).toString()).multipliedBy(1-o).toFixed(0,3)),{tx:l,coinOut:d}=await eS({accountAddress:a,inCoinType:t,outCoinType:n,inputAmount:e.toString(),minAmountOut:c.toString(),poolId:i,frontendFee:u?u.tradeFeePercent:void 0,frontendFeeRecipient:u?u.tradeFeeRecipientAddress:void 0,extendTx:void 0,isSponsored:!1},s);M(d,"Coin out is required"),l.transferObjects([d],l.pure.address(a)),l.setSender(a);let g=await F(s,l,a,0);return(l=await O({inheritTx:l,sender:a,feeAmount:g},s)).build({client:s})};var eR=((V={}).BLAST_FUN="BLAST_FUN",V.MOONBAGS="MOONBAGS",V);(W=el||(el={})).PACKAGE_ID="0xb8df325010942634a4afb3db3901ee215546af43a4ec4af781e7213b0bba7290",W.CONFIG_OBJECT_ID="0x74aecf86067c6913960ba4925333aefd2b1f929cafca7e21fd55a8f244b70499",W.LOCK_CONFIG_OBJECT_ID="0xfb09822d9808980abd04c51321adb850701f5f55535c6206658ef4d910c3e9be",W.BURN_MANAGER_OBJECT_ID="0x1d94aa32518d0cb00f9de6ed60d450c9a2090761f326752ffad06b2e9404f845",W.POOLS_OBJECT_ID="0xf699e7f2276f5c9a75944b37a0c5b5d9ddfd2471bf6242483b03ab2887d198d0",W.GLOBAL_CONFIG_OBJECT_ID="0xdaa46292632c3c4d8f31f23ea0f9b36a28ff3677e9684980e4438403a67a3d8f",W.FEE_DENOMINATOR=BigInt(1e4),(H=(X=ed||(ed={})).Curves||(X.Curves={})).calculateAddLiquidityCost=function(e,t,n){return e*t/(t-n)-e},H.calculateRemoveLiquidityReturn=function(e,t,n){return t-e*t/(e+n)},H.calculateTokenAmountReceived=function(e,t,n){return t-e*t/(e+n)},(Y=X.Moonbags||(X.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)},Y.buyExactInReturnsWithLock=function(e){let{inputAmount:t,amountIn:n,pool:i,config:r,dynamicVirtualTokenReserves:o}=e,a=BigInt(i.virtual_sui_reserves),u=BigInt(i.virtual_token_reserves),s=BigInt(i.remain_token_reserves.fields.balance),c=X.Curves.calculateRemoveLiquidityReturn(a,u,n),l=u-(o||s),d=c,g=n;c>l&&(d=l,g=X.Curves.calculateAddLiquidityCost(a,u,l)+BigInt(1));let p=g*BigInt(r.platform_fee)/el.FEE_DENOMINATOR;return M(t>=g+p,"Input amount is less than used SUI + fee"),{receivedCurve:d,receivedSui:t-g-p}},Y.sellReturns=function(e){let{amountIn:t,pool:n,config:i}=e,r=BigInt(n.virtual_sui_reserves),o=BigInt(n.virtual_token_reserves),a=BigInt(n.real_sui_reserves.fields.balance),u=X.Curves.calculateRemoveLiquidityReturn(o,r,t);u>a&&(u=a);let s=u*BigInt(i.platform_fee)/el.FEE_DENOMINATOR,c=u-s;return{receivedCurve:BigInt(0),receivedSui:c}},(Z=eg||(eg={})).getCurveAmountAfterBuy=async function(e,t){let{suiAmount:n,poolId:i,frontendFee:r}=e,[o,a,u]=await Promise.all([e_(t,i),e_(t,el.CONFIG_OBJECT_ID),ed.Moonbags.getDynamicVirtualTokenReserves(t,i)]);void 0!==r&&(n=y(n,r));let s=n*el.FEE_DENOMINATOR/(el.FEE_DENOMINATOR+BigInt(a.platform_fee)),{receivedCurve:c}=ed.Moonbags.buyExactInReturnsWithLock({inputAmount:n,amountIn:s,pool:o,config:a,dynamicVirtualTokenReserves:u});return c},Z.getSuiAmountAfterSell=async function(e,t){let{curveAmount:n,poolId:i,frontendFee:r}=e,[o,a]=await Promise.all([e_(t,i),e_(t,el.CONFIG_OBJECT_ID)]),{receivedSui:u}=ed.Moonbags.sellReturns({amountIn:n,pool:o,config:a});return void 0!==r?y(u,r):u},Z.getUsedSuiForTx=async function(e,t){let{suiAmount:n,frontendFee:i}=e,r=await e_(t,el.CONFIG_OBJECT_ID);return void 0!==i&&(n=y(n,i)),n*el.FEE_DENOMINATOR/(el.FEE_DENOMINATOR+BigInt(r.platform_fee))};var eE=ep||(ep={});async function eP(e,t){let{tx:n,coinOut:i}=await ey(e,t);M(i,"Coin out is required");let r=await eg.getUsedSuiForTx({suiAmount:BigInt(e.inputAmount),frontendFee:e.frontendFee},t),[o,a]=n.moveCall({target:`${el.PACKAGE_ID}::moonbags::buy_exact_in_returns_with_lock`,typeArguments:[e.outCoinType],arguments:[n.object(el.CONFIG_OBJECT_ID),n.object(el.LOCK_CONFIG_OBJECT_ID),i,n.pure.u64(r),n.pure.u64(e.minAmountOut),n.object(el.BURN_MANAGER_OBJECT_ID),n.object(el.POOLS_OBJECT_ID),n.object(el.GLOBAL_CONFIG_OBJECT_ID),n.object(R),n.object(b)]});return ea.transferOrDestroyZeroCoin(n,P,o,e.accountAddress),{tx:n,coinOut:a}}async function ex(e,t){M(S(e.outCoinType),"Output must be SUI");let{tx:n,coinData:i}=await C({amount:e.inputAmount,coinType:e.inCoinType,inheritTx:e.extendTx?.tx,account:e.accountAddress,splits:[e.inputAmount]},t),[r]=i,[o,a]=n.moveCall({target:`${el.PACKAGE_ID}::moonbags::sell_returns`,typeArguments:[e.inCoinType],arguments:[n.object(el.CONFIG_OBJECT_ID),r,n.pure.u64(e.minAmountOut),n.object(b)]});return ea.transferOrDestroyZeroCoin(n,e.inCoinType,a,e.accountAddress),await eC(n,e,o)}function ek(e){return e}function eM(e){return e}function eD(e){return new Proxy(e,{get(e,t){let n=e[t];return"function"==typeof n?n.bind(e):n}})}eE.buildBuyTx=eP,eE.buildSellTx=ex,eE.getBuyTransaction=async function({coinInAmount:e,coinInType:t,coinOutType:n,poolId:i,slippage:o,walletAddress:a,tradeFee:u},s){M(S(t),"coinInType must be SUI for buy transaction"),M(n!==t,"coinOutType must be different from coinInType"),M(o>=0&&o<1,"slippage must be between 0 (inclusive) and 1 (exclusive)"),M(e>0,"coinInAmount must be greater than 0");let c=BigInt(new r((await eg.getCurveAmountAfterBuy({poolId:i,suiAmount:e,frontendFee:u?u.tradeFeePercent:void 0},s)).toString()).multipliedBy(1-o).toFixed(0,3)),{tx:l,coinOut:d}=await eP({accountAddress:a,inCoinType:t,outCoinType:n,inputAmount:e.toString(),minAmountOut:c.toString(),poolId:i,frontendFee:u?u.tradeFeePercent:void 0,frontendFeeRecipient:u?u.tradeFeeRecipientAddress:void 0,extendTx:void 0,isSponsored:!1},s);M(d,"Coin out is required"),l.transferObjects([d],l.pure.address(a)),l.setSender(a);let g=await F(s,l,a,0);return(l=await O({inheritTx:l,sender:a,feeAmount:g,suiInputAmount:e},s)).build({client:s})},eE.getSellTransaction=async function({coinInAmount:e,coinInType:t,coinOutType:n,poolId:i,slippage:o,walletAddress:a,tradeFee:u},s){M(S(n),"coinOutType must be SUI for sell transaction"),M(n!==t,"coinOutType must be different from coinInType"),M(o>=0&&o<1,"slippage must be between 0 (inclusive) and 1 (exclusive)"),M(e>0,"coinInAmount must be greater than 0");let c=BigInt(new r((await eg.getSuiAmountAfterSell({poolId:i,curveAmount:e,frontendFee:u?u.tradeFeePercent:void 0},s)).toString()).multipliedBy(1-o).toFixed(0,3)),{tx:l,coinOut:d}=await ex({accountAddress:a,inCoinType:t,outCoinType:n,inputAmount:e.toString(),minAmountOut:c.toString(),poolId:i,frontendFee:u?u.tradeFeePercent:void 0,frontendFeeRecipient:u?u.tradeFeeRecipientAddress:void 0,extendTx:void 0,isSponsored:!1},s);M(d,"Coin out is required"),l.transferObjects([d],l.pure.address(a)),l.setSender(a);let g=await F(s,l,a,0);return(l=await O({inheritTx:l,sender:a,feeAmount:g},s)).build({client:s})};class eN{sdk;_astrosAggregator;_aftermathAggregator;_sevenkAggregator;_cetusAggregator;_flowXAggregator;constructor(e){this.sdk=e,this._astrosAggregator=new K({defaultTradeFee:e.options.tradeFee,astrosApiKey:e.options.astrosApiKey},e.suiClient),this._aftermathAggregator=new N({defaultTradeFee:e.options.tradeFee,aftermathApiKey:e.options.aftermathApiKey,aftermathApiEndpoint:e.options.aftermathApiEndpoint},e.suiClient),this._sevenkAggregator=new D({defaultTradeFee:e.options.tradeFee,sevenKApiKey:e.options.sevenKApiKey},e.suiClient),this._cetusAggregator=new U({defaultTradeFee:e.options.tradeFee,cetusApiKey:e.options.cetusApiKey,cetusApiEndpoint:e.options.cetusApiEndpoint,cetusPartnerId:e.options.cetusPartnerId},e.suiClient),this._flowXAggregator=new ef({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 em.ASTROS:{let e,i=await this._astrosAggregator.getTradeRoute(t);if(!i)return null;let o=K.toCommonTradeRoutes(i,t.coinInType,t.coinOutType);if(!o)return null;e=t.tradeFee?t.tradeFee.tradeFeePercent:this.sdk.options.tradeFee.tradeFeePercent,o.amountOut=BigInt(new r(i.amount_out).multipliedBy(1-e).toFixed(0,3)),n={route:o,aggregatorRoute:i};break}case em.AFTERMATH:{let e=await this._aftermathAggregator.getTradeRoute(t);if(!e)return null;let i=N.toCommonTradeRoutes(e);if(!i)return null;n={route:i,aggregatorRoute:e};break}case em.SEVENK:{let e=await this._sevenkAggregator.getTradeRoute(t);if(!e)return null;let i=D.toCommonTradeRoutes(e);if(!i)return null;n={route:i,aggregatorRoute:e};break}case em.CETUS:{let e=await this._cetusAggregator.getTradeRoute(t);if(!e)return null;let i=U.toCommonTradeRoutes(e,t.coinInType,t.coinOutType);if(!i)return null;n={route:i,aggregatorRoute:e};break}case em.FLOWX:{let e=await this._flowXAggregator.getTradeRoute(t);if(!e)return null;let i=ef.toCommonTradeRoutes(e);if(!i)return null;n={route:i,aggregatorRoute:e}}}return n}async getTransactionByRoute(e,t){switch(e){case em.ASTROS:return this._astrosAggregator.getTransaction({walletAddress:t.walletAddress,completeRoute:t.completeRoute,slippage:t.slippage,tradeFee:t.tradeFee});case em.AFTERMATH:return this._aftermathAggregator.getTransaction({walletAddress:t.walletAddress,completeRoute:t.completeRoute,slippage:t.slippage});case em.SEVENK:return this._sevenkAggregator.getTransaction({walletAddress:t.walletAddress,completeRoute:t.completeRoute,slippage:t.slippage,tradeFee:t.tradeFee});case em.CETUS:return this._cetusAggregator.getTransaction({walletAddress:t.walletAddress,completeRoute:t.completeRoute,slippage:t.slippage,tradeFee:t.tradeFee});case em.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 i=await this.getTransactionByRoute(e,{walletAddress:t.walletAddress,completeRoute:n.aggregatorRoute,slippage:t.slippage,tradeFee:t.tradeFee});return{route:n.route,aggregatorRoute:n.aggregatorRoute,transaction:i}}async getTradeTransactionWithBestRate(e){let t=Object.keys(em),n=await Promise.all(t.map(async t=>{try{return await this.getTradeRoute(t,e)}catch{return null}})),i=null,r=null;for(let e=0;e<n.length;e++){let o=n[e],a=t[e];if(o&&(!i||o.route.amountOut>i.route.amountOut)){i=o,r=a;continue}}if(!i||!r)return null;let o=await this.getTransactionByRoute(r,{walletAddress:e.walletAddress,completeRoute:i.aggregatorRoute,slippage:e.slippage,tradeFee:e.tradeFee});return{route:i.route,aggregatorRoute:i.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(em),n=null,i=null;for(let r of t){let t=await this.getAmountOut(r,e);null!==t&&(null===n||t>n)&&(n=t,i=r)}return null===n||null===i?null:{amountOut:n,aggregator:i}}}class eK{sdk;constructor(e){this.sdk=e}async getEstimatedAmountOut(e,t){let{coinInType:n,coinOutType:i}=t;M(n!==i,"coinInType and coinOutType must be different"),M(S(n)||S(i),"One of coinInType or coinOutType must be SUI");let r=S(n);switch(e){case eR.MOONBAGS:if(r)return await eg.getCurveAmountAfterBuy({poolId:t.poolId,suiAmount:t.coinInAmount,frontendFee:t.tradeFee?t.tradeFee.tradeFeePercent:void 0},this.sdk.suiClient);return await eg.getSuiAmountAfterSell({poolId:t.poolId,curveAmount:t.coinInAmount,frontendFee:t.tradeFee?t.tradeFee.tradeFeePercent:void 0},this.sdk.suiClient);case eR.BLAST_FUN:if(r)return await es.getCurveAmountAfterBuy({poolId:t.poolId,suiAmount:t.coinInAmount,frontendFee:t.tradeFee?t.tradeFee.tradeFeePercent:void 0});return await es.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:i,coinOutType:r}=t;M(i!==r,"coinInType and coinOutType must be different"),M(S(i)||S(r),"One of coinInType or coinOutType must be SUI");let o=S(i);switch(e){case eR.MOONBAGS:n=o?await ep.getBuyTransaction(t,this.sdk.suiClient):await ep.getSellTransaction(t,this.sdk.suiClient);break;case eR.BLAST_FUN:n=o?await ec.getBuyTransaction(t,this.sdk.suiClient):await ec.getSellTransaction(t,this.sdk.suiClient);break;default:throw Error(`Unsupported bonding curve platform: ${e}`)}return n}}let eU={tradeFeePercent:.01,tradeFeeRecipientAddress:"0xdaf1c8ed29d89cd8f217f609bad0a668fa6f158c12000bfa5f93e670c99e24ff"};class ej{options;_suiClient;aggregatorModule;curveModule;constructor(e){this.options=e,this._suiClient=new B({url:E("mainnet")}),this.aggregatorModule=new eN(this),this.curveModule=new eK(this)}get suiClient(){return this._suiClient}}class eG{suiClient;constructor(e){this.suiClient=e}validatePrivateKey(e,t){M(e?.trim(),"Private key is required");let n=h.fromSecretKey(e),i=n.getPublicKey().toSuiAddress();if(i!==t)throw Error(`Private key mismatch. Expected: ${t}, Got: ${i}`);return n}async createDraft(e,t,n){M(e?.trim(),"Sender address is required"),M(t?.trim(),"Recipient address is required"),M(e!==t,"Sender and recipient cannot be the same"),M(n>0n,"Transfer amount must be at least 1 MIST");try{let i=new w,[r]=i.splitCoins(i.gas,[n]);i.transferObjects([r],t),i.setSender(e);let o=await this.suiClient.getReferenceGasPrice();i.setGasPrice(o);let a=await F(this.suiClient,i,e,.1);i=await O({inheritTx:i,sender:e,feeAmount:a,suiInputAmount:n},this.suiClient);let u=await i.build({client:this.suiClient}),s=Buffer.from(u).toString("base64"),c=await i.getDigest();return{sender:e,recipient:t,amountMIST:n,txDraftBase64:s,txDigest:c}}catch(e){throw Error(`Failed to create draft transaction: ${e instanceof Error?e.message:"Unknown error"}`)}}async execute(e,t){try{M(e,"Draft transaction is required"),M(e.txDraftBase64?.trim(),"Transaction data is required");let n=this.validatePrivateKey(t,e.sender),i=k(e.txDraftBase64),{signature:r}=await n.signTransaction(i),o=await this.suiClient.executeTransactionBlock({transactionBlock:i,signature:r});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){M(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"}}}var eq=1e4;export{ADMIN_CAP_ID,BOOSTING_PACKAGE_ID,BoostingModule,CLOCK_OBJECT_ID,CONFIG_ID,NATIVE_USDC_TOKEN_TYPE,NoodlesPaySdk,PAYMENT_COIN_TYPE,SUBSCRIPTION_ADMIN_CAP_ID,SUBSCRIPTION_CONFIG_ID,SUBSCRIPTION_PACKAGE_ID,SUI_FULL_TYPE,SUI_METADATA_OBJECT_ID,SUI_TYPE,SubscriptionModule,USDC_TOKEN_TYPE,addGasFee,getAmountAfterFee,getCoinObjectIdsByAmount,getNeededGasFee,getSplitCoinForTx,getSplitCoinsAfterFee,isSuiCoinType}from"./982.js";export{eN as AggregatorModule,eh as BLUEFIN_PACKAGE_ID,eK as CurveModule,eU as DEFAULT_TRADE_FEE,eG as DraftTransferTx,ej as NoodlesSdk,D as SevenKAggregator,ek as adaptSuiClient,eM as adaptTransaction,N as AftermathAggregator,K as AstrosAggregator,ea as BluefinTx,eg as MoonbagsCalculation,U as CetusAggregator,em as SupportedAggregator,et as BlastFunConstants,el as MoonbagsConstants,eD as createCompatibleSuiClient,eo as BlastFunCustomCalculation,eu as BlastFunCustomTransaction,eq as BASE_BPS,ef as FlowXAggregator,eB as getMemezPumpSDK,eA as getMoveObject,e_ as getMoveObjectContent,er as BlastFunPackage,ei as Bps,en as MathUtils,ed as MoonbagsPackage,es as BlastFunSDKCalculation,ec as BlastFunSDKTransaction,ey as splitSuiCoinAfterFeeFromBuyTx,eC as splitSuiCoinAfterFeeFromSellTx,ep as MoonbagsTransaction,eR as SupportedBondingCurve,ee as TradeFeeOptions};
|
|
1
|
+
import{BluefinXTx as e,Config as t,buildTx as n,getQuote as i}from"@bluefin-exchange/bluefin7k-aggregator-sdk";import r from"bignumber.js";import{Aftermath as o,Helpers as a}from"aftermath-ts-sdk";import{buildSwapPTBFromQuote as u,getCoins as s,getQuote as c}from"@naviprotocol/astros-aggregator-sdk";import{AggregatorClient as l,Env as d}from"@cetusprotocol/aggregator-sdk";import g from"bn.js";import{AggregatorQuoter as p,Coin as m,Commission as f,CommissionType as _,TradeBuilder as A}from"@flowx-finance/sdk";import{MemezPumpSDK as I}from"@interest-protocol/memez-fun-sdk";import{Network as h}from"@interest-protocol/sui-core-sdk";import{Ed25519Keypair as T}from"@mysten/sui/keypairs/ed25519";import{getAmountAfterFee as y,getSplitCoinForTx as C,getNeededGasFee as F,addGasFee as O,Transaction as w,SuiClient as b,CLOCK_OBJECT_ID as B,SUI_TYPE as v,isSuiCoinType as S,SUI_METADATA_OBJECT_ID as R,getFullnodeUrl as E,SUI_FULL_TYPE as x,getSplitCoinsAfterFee as k,fromBase64 as P,tiny_invariant as M}from"./982.js";class D{_config;_suiClient;constructor(e,t){this._config=e,this._suiClient=t}async getTradeRoute({coinInAmount:e,coinInType:n,coinOutType:r,tradeFee:o}){try{this._config.sevenKApiKey&&t.setApiKey(this._config.sevenKApiKey);let a=o?o.tradeFeePercent:this._config.defaultTradeFee.tradeFeePercent;return await i({tokenIn:n,tokenOut:r,amountIn:e.toString(),commissionBps:1e4*a})}catch(e){return null}}async getTransaction({walletAddress:t,completeRoute:i,slippage:r,tradeFee:o}){let a,u;o?(a=o.tradeFeePercent,u=o.tradeFeeRecipientAddress):(a=this._config.defaultTradeFee.tradeFeePercent,u=this._config.defaultTradeFee.tradeFeeRecipientAddress);let s=await n({quoteResponse:i,slippage:r,accountAddress:t,commission:{partner:u,commissionBps:1e4*a}});return s.tx instanceof e?w.from(s.tx.txBytes).build({client:this._suiClient}):(s.tx.setSender(t),s.tx.build({client:this._suiClient}))}}(D||(D={})).toCommonTradeRoutes=function(e){let t=[];if(!e.routes||0===e.routes.length)return null;for(let n of e.routes){let e=[],i={};for(let t of n.hops){for(let e of t.pool.allTokens)i[e.address]=e.decimal;let n=i[t.tokenIn]??0,o=i[t.tokenOut]??0,a=BigInt(new r(t.tokenInAmount).multipliedBy(10**n).toFixed(0,3)),u=BigInt(new r(t.tokenOutAmount).multipliedBy(10**o).toFixed(0,3));e.push({poolAddress:t.poolId,coinIn:t.tokenIn,coinOut:t.tokenOut,amountIn:a,amountOut:u})}if(0===e.length)continue;let o=i[n.tokenIn]??0,a=i[n.tokenOut]??0,u=BigInt(new r(n.tokenInAmount).multipliedBy(10**o).toFixed(0,3)),s=BigInt(new r(n.tokenOutAmount).multipliedBy(10**a).toFixed(0,3));t.push({paths:e,coinIn:n.tokenIn,coinOut:n.tokenOut,amountIn:u,amountOut:s})}return 0===t.length?null:{coinIn:e.tokenIn,coinOut:e.tokenOut,amountIn:BigInt(e.swapAmountWithDecimal),amountOut:BigInt(e.returnAmountWithDecimal),routes:t}};class N{_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 o(this._config.aftermathApiEndpoint):this._aftermathClient=new o("MAINNET"),await this._aftermathClient.init(),this._config.aftermathApiKey){let e=a.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:i}){try{let r;r=i?{recipient:i.tradeFeeRecipientAddress,feePercentage:i.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:r})}catch(e){return null}}async getTransaction({completeRoute:e,walletAddress:t,slippage:n}){let i=await this.aftermathClient(),r=await i.Router().getTransactionForCompleteTradeRoute({completeRoute:e,walletAddress:t,slippage:n,isSponsoredTx:!1});return r.setSender(t),r.build({client:this._suiClient})}}(N||(N={})).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}};class K{_config;_suiClient;constructor(e,t){this._config=e,this._suiClient=t}async getTradeRoute({coinInAmount:e,coinInType:t,coinOutType:n,tradeFee:i}){try{let r;return r=i?{fee:i.tradeFeePercent,receiverAddress:i.tradeFeeRecipientAddress}:{fee:this._config.defaultTradeFee.tradeFeePercent,receiverAddress:this._config.defaultTradeFee.tradeFeeRecipientAddress},await c(t,n,e,this._config.astrosApiKey,{byAmountIn:!0,serviceFee:r})}catch(e){return null}}returnMergedCoins(e,t,n){if(t.length<2)return e.object(t[0].coinObjectId);let i=0,r=[];t.sort((e,t)=>Number(t.balance)-Number(e.balance)).slice(1).forEach(e=>{i>=n||(i+=Number(e.balance),r.push(e.coinObjectId))});let o=t[0].coinObjectId;return e.mergeCoins(o,r),e.object(o)}async getTransaction({completeRoute:e,walletAddress:t,slippage:n,tradeFee:i}){var o;let a,c;a=i?{fee:i.tradeFeePercent,receiverAddress:i.tradeFeeRecipientAddress}:{fee:this._config.defaultTradeFee.tradeFeePercent,receiverAddress:this._config.defaultTradeFee.tradeFeeRecipientAddress};let l=new r(e.amount_out).multipliedBy(1-n-a.fee).toNumber(),d=new w;if("0x2::sui::SUI"===(o=e.from)||"0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI"===o)c=d.splitCoins(d.gas,[d.pure.u64(e.amount_in)]);else{let n=await s(this._suiClient,t,e.from),i=this.returnMergedCoins(d,n.data,Number.parseFloat(e.amount_in));c=d.splitCoins(i,[d.pure.u64(e.amount_in)])}let g=await u(t,d,l,c,e,void 0,!1,this._config.astrosApiKey,{serviceFee:a});return d.transferObjects([g],t),d.setSender(t),d.build({client:this._suiClient})}}(K||(K={})).toCommonTradeRoutes=function(e,t,n){if(0===e.routes.length)return null;let i=[];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&&i.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===i.length?null:{coinIn:t,coinOut:n,amountIn:BigInt(e.amount_in),amountOut:BigInt(e.amount_out),routes:i}},(ee||(ee={})).equals=function(e,t){return e.tradeFeePercent===t.tradeFeePercent&&e.tradeFeeRecipientAddress===t.tradeFeeRecipientAddress};class U{_config;_suiClient;_cetusClient;constructor(e,t){this._config=e,this._suiClient=t}cetusClient(e,t){return t&&!ee.equals(t,this._config.defaultTradeFee)?new l({client:this._suiClient,overlayFeeReceiver:t.tradeFeeRecipientAddress,overlayFeeRate:t.tradeFeePercent,env:d.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 l({client:this._suiClient,overlayFeeReceiver:this._config.defaultTradeFee.tradeFeeRecipientAddress,overlayFeeRate:this._config.defaultTradeFee.tradeFeePercent,env:d.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:i}){try{let r=this.cetusClient(void 0,i);return await r.findRouters({from:t,target:n,amount:new g(e.toString()),byAmountIn:!0})}catch(e){return null}}async getTransaction({completeRoute:e,walletAddress:t,slippage:n,tradeFee:i}){let r=this.cetusClient(t,i),o=new w;return o.setSender(t),await r.fastRouterSwap({router:e,txb:o,slippage:n}),o.build({client:this._suiClient})}}(U||(U={})).toCommonTradeRoutes=function(e,t,n){if(0===e.paths.length)return null;let i=[],r=[],o=[];for(let t=0;t<e.paths.length;t++){let n=e.paths[t],i={poolAddress:n.id,amountIn:BigInt(n.amountIn),amountOut:BigInt(n.amountOut),coinIn:n.from,coinOut:n.target};if(o.push(i),t===e.paths.length-1)r.push([...o]);else{let i=e.paths[t+1];n.target!==i.from&&(r.push([...o]),o=[])}}for(let e of r)0!==e.length&&i.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===i.length?null:{coinIn:t,coinOut:n,amountIn:BigInt(e.amountIn.toString(10)),amountOut:BigInt(e.amountOut.toString(10)),routes:i}};var j,G,q,L,z,J,$,V,W,X,H,Z,Y,Q,ee,et,en,ei,er,eo,ea,eu,es,ec,el,ed,eg,ep,em=((Q={}).ASTROS="ASTROS",Q.AFTERMATH="AFTERMATH",Q.SEVENK="7K",Q.CETUS="CETUS",Q.FLOWX="FLOWX",Q);class ef{_config;_suiClient;constructor(e,t){this._config=e,this._suiClient=t}getCommission(e,t){let n,i;return t?(n=t.tradeFeePercent,i=t.tradeFeeRecipientAddress):(n=this._config.defaultTradeFee.tradeFeePercent,i=this._config.defaultTradeFee.tradeFeeRecipientAddress),new f(i,new m(e),_.PERCENTAGE,1e6*n,!0)}async getTradeRoute({coinInAmount:e,coinInType:t,coinOutType:n,tradeFee:i}){let r=new p("mainnet",this._config.flowxApiKey);try{return await r.getRoutes({tokenIn:t,tokenOut:n,amountIn:e.toString(),commission:this.getCommission(t,i)})}catch(e){return null}}async getTransaction({walletAddress:e,completeRoute:t,slippage:n,tradeFee:i}){return new A("mainnet",t.routes).sender(e).slippage(1e6*n).commission(this.getCommission(t.coinIn.coinType,i)).build().buildTransaction({client:this._suiClient}).then(t=>(t.setSender(e),t.build({client:this._suiClient})))}}async function e_(e,t){return(await eA(e,t)).fields}async function eA(e,t){let n=await e.getObject({id:t,options:{showContent:!0}}),i=n.data?.content;return M(i,"Pool object not found or has no content"),M("moveObject"===i.dataType,"Object is not a Move object"),i}(ef||(ef={})).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}},(j=et||(et={})).PACKAGE_ID_V4="0x7e6aa6e179466ab2814425a780b122575296d011119fa69d27f289f5a28814bd",j.MEMEZ_AV_OBJECT_ID="0x2319e3e76dfad73d8f4684bdbf42be4f32d8ce4521dd61becc8261dc918d82c0",((G=en||(en={})).U64||(G.U64={})).mulDivUp=function(e,t,n){let i=BigInt(0);return e*t%n>BigInt(0)&&(i=BigInt(1)),e*t/n+i};var eI=ei||(ei={});function eh(e){return M(BigInt(e)<=BigInt(1e4),"Bps overflow"),BigInt(e)}eI.calcUp=function(e,t){let n,i=BigInt(e.pos0),r=BigInt(1e4);return n=i*t%r!==BigInt(0)?BigInt(1):BigInt(0),i*t/r+n},eI.sub=function(e,t){return M(BigInt(e.pos0)>=BigInt(t.pos0),"Bps underflow"),{pos0:(BigInt(e.pos0)-BigInt(t.pos0)).toString()}},eI.value=function(e){return BigInt(e.pos0)},eI.new_=function(e){return{pos0:eh(e).toString()}},eI.assertOverflow=eh,((q=er||(er={})).MemezFun||(q.MemezFun={})).isSniperProtectedMemezFun=async function(e,t){return(await e_(e,t)).public_key.length>0},(L=q.MemezFees||(q.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 i=e.fields.pos0.fields;if(BigInt(i.pos0)===BigInt(0))return BigInt(0);let r=ei.calcUp(ei.sub(i,n),t);if(t>=r)return r;throw Error(`Insufficient amount to cover fee. Required: ${r}, provided: ${t}`)}throw Error("Unknown fee variant")},L.calculateWithDiscount=function(e,t,n){if("Value"===e.variant)return BigInt(e.fields.pos0);if("Percentage"===e.variant){let i=e.fields.pos0.fields;return ei.calcUp(ei.sub(i,t),n)}throw Error("Unknown fee variant")},(q.MemezBurner||(q.MemezBurner={})).calculate=function(e,t){if(ei.value(e.fee.fields)===BigInt(0)||t===BigInt(0)||t>=BigInt(e.target_liquidity))return ei.new_(0);let n=BigInt(1e4);return ei.new_(en.U64.mulDivUp(ei.value(e.fee.fields),en.U64.mulDivUp(t,n,BigInt(e.target_liquidity)),n))},(z=q.MemezPump||(q.MemezPump={})).getPumpState=async function(e,t){return await e_(e,t.inner_state)},z.pump=function(e,t){let n=e.constant_product.fields,i=q.MemezFees.takeWithDiscount(n.quote_swap_fee,t,n.quote_referrer_fee.fields),r=t-i,o=BigInt(n.meme_balance),a=BigInt(n.quote_balance),u=o*r/(BigInt(n.virtual_liquidity)+a+r),s=q.MemezFees.takeWithDiscount(n.meme_swap_fee,u,n.meme_referrer_fee.fields);return u-s},z.dump=function(e,t){let n=e.constant_product.fields,i=q.MemezFees.takeWithDiscount(n.meme_swap_fee,t,n.meme_referrer_fee.fields),r=t-i,o=BigInt(n.meme_balance),a=BigInt(n.quote_balance),u=BigInt(n.virtual_liquidity),s=q.MemezBurner.calculate(n.burner.fields,a),c=ei.calcUp(s,r),l=r-(ei.value(s)!==BigInt(0)?c:BigInt(0)),d=(u+a)*l/(o+l);d>a&&(d=a);let g=q.MemezFees.takeWithDiscount(n.quote_swap_fee,d,n.quote_referrer_fee.fields);return d-g},(J=eo||(eo={})).getCurveAmountAfterBuy=async function(e,t){let{suiAmount:n,poolId:i,frontendFee:r}=e,o=await e_(t,i),a=await er.MemezPump.getPumpState(t,o);return n=y(n,r),er.MemezPump.pump(a,n)},J.getSuiAmountAfterSell=async function(e,t){let{curveAmount:n,poolId:i,frontendFee:r}=e,o=await e_(t,i),a=await er.MemezPump.getPumpState(t,o);return y(er.MemezPump.dump(a,n),r)};let eT="0x62412b7268c35f3808336aee57a52836501f40b8ba5d936f8ad275e672befd04";async function ey(e,t){let n,i,{inputAmount:r,accountAddress:o,frontendFee:a,frontendFeeRecipient:u,extendTx:s,isSponsored:c}=e;M(e.inCoinType===x||e.inCoinType===v,"Input must be SUI");let{tx:l,coinIn:d}=s||{},g=k(r,a||"0"),p=l||new w;if(d)n=p.splitCoins(d,g),ea.transferOrDestroyZeroCoin(p,x,d,o);else{let{coinData:e}=await C({account:o,amount:r,splits:g,coinType:x,inheritTx:p,isSponsored:c||!1},t);n=e}if(a&&u){let[e,t]=n;i=e,p.transferObjects([t],p.pure.address(u||o))}else[i]=n;return{tx:p,coinOut:i}}async function eC(e,t,n){if(M(t.outCoinType===x||t.outCoinType===v,"Output must be SUI"),0>=Number(t.frontendFee||0))return{tx:e,coinOut:n};let i=e.moveCall({target:"0x2::coin::value",typeArguments:[t.outCoinType],arguments:[n]}),r=e.moveCall({target:`${eT}::math::mul_div_u64`,typeArguments:[],arguments:[i,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,r]});return e.transferObjects([o],e.pure.address(t.frontendFeeRecipient||t.accountAddress)),{tx:e,coinOut:n}}(ea||(ea={})).transferOrDestroyZeroCoin=function(e,t,n,i){e.moveCall({target:`${eT}::utils::transfer_or_destroy`,typeArguments:[t],arguments:[n,e.pure.address(i)]})};var eF=eu||(eu={});async function eO(e){let t=e||new w;return t.moveCall({target:`${et.PACKAGE_ID_V4}::memez_allowed_versions::get_allowed_versions`,arguments:[t.object(et.MEMEZ_AV_OBJECT_ID)],typeArguments:[]})}eF.getAllowedVersions=eO,eF.buildBuyTx=async function(e,t){M(!await er.MemezFun.isSniperProtectedMemezFun(t,e.poolId),"This coin is a sniper protected coin, please use the Blast Fun website to trade it.");let{tx:n,coinOut:i}=await ey(e,t);M(i,"Coin out is required");let r=n.moveCall({target:`${et.PACKAGE_ID_V4}::memez_pump::pump`,typeArguments:[e.outCoinType,x],arguments:[n.object(e.poolId),i,n.pure.vector("address",[]),n.pure.vector("vector<u8>",[]),n.pure.u64(e.minAmountOut),await eO(n)]});return{tx:n,coinOut:r}},eF.buildSellTx=async function(e,t){M(e.outCoinType===x||e.outCoinType===v,"Output must be SUI");let n=await e_(t,e.poolId),{tx:i,coinData:r}=await C({amount:e.inputAmount,coinType:e.inCoinType,inheritTx:e.extendTx?.tx,account:e.accountAddress,splits:[e.inputAmount]},t),[o]=r,[a]=i.moveCall({target:`${et.PACKAGE_ID_V4}::memez_pump::dump`,typeArguments:[e.inCoinType,e.outCoinType],arguments:[i.object(e.poolId),i.object(n.ipx_meme_coin_treasury),o,i.pure.vector("address",[]),i.pure.u64(e.minAmountOut),await eO(i)]});return await eC(i,e,a)};let ew=new I({network:h.MAINNET,fullNodeUrl:E("mainnet")});function eb(){return ew}($=es||(es={})).getCurveAmountAfterBuy=async function(e){let{suiAmount:t,poolId:n,frontendFee:i}=e;t=y(t,i);let{memeAmountOut:r}=await eb().quotePump({pool:n,amount:t});return r},$.getSuiAmountAfterSell=async function(e){let{curveAmount:t,poolId:n,frontendFee:i}=e,{quoteAmountOut:r}=await eb().quoteDump({pool:n,amount:t});return y(r,i)};var eB=ec||(ec={});async function ev(e,t){let{tx:n,coinOut:i}=await ey(e,t);M(i,"Coin out is required");let{memeCoin:r,tx:o}=await eb().pump({pool:e.poolId,quoteCoin:i,minAmountOut:e.minAmountOut,tx:n});return{tx:o,coinOut:r}}async function eS(e,t){M(S(e.outCoinType),"Output must be SUI");let{tx:n,coinData:i}=await C({amount:e.inputAmount,coinType:e.inCoinType,inheritTx:e.extendTx?.tx,account:e.accountAddress,splits:[e.inputAmount]},t),[r]=i,{quoteCoin:o,tx:a}=await eb().dump({pool:e.poolId,memeCoin:r,tx:n,minAmountOut:e.minAmountOut});return await eC(a,e,o)}eB.buildBuyTx=ev,eB.buildSellTx=eS,eB.getBuyTransaction=async function({coinInAmount:e,coinInType:t,coinOutType:n,poolId:i,slippage:o,walletAddress:a,tradeFee:u},s){M(S(t),"coinInType must be SUI for buy transaction"),M(n!==t,"coinOutType must be different from coinInType"),M(o>=0&&o<1,"slippage must be between 0 (inclusive) and 1 (exclusive)"),M(e>0,"coinInAmount must be greater than 0");let c=BigInt(new r((await es.getCurveAmountAfterBuy({poolId:i,suiAmount:e,frontendFee:u?u.tradeFeePercent:void 0})).toString()).multipliedBy(1-o).toFixed(0,3)),{tx:l,coinOut:d}=await ev({accountAddress:a,inCoinType:t,outCoinType:n,inputAmount:e.toString(),minAmountOut:c.toString(),poolId:i,frontendFee:u?u.tradeFeePercent:void 0,frontendFeeRecipient:u?u.tradeFeeRecipientAddress:void 0,extendTx:void 0,isSponsored:!1},s);M(d,"Coin out is required"),l.transferObjects([d],l.pure.address(a)),l.setSender(a);let g=await F(s,l,a,0);return(l=await O({inheritTx:l,sender:a,feeAmount:g,suiInputAmount:e},s)).build({client:s})},eB.getSellTransaction=async function({coinInAmount:e,coinInType:t,coinOutType:n,poolId:i,slippage:o,walletAddress:a,tradeFee:u},s){M(S(n),"coinOutType must be SUI for sell transaction"),M(n!==t,"coinOutType must be different from coinInType"),M(o>=0&&o<1,"slippage must be between 0 (inclusive) and 1 (exclusive)"),M(e>0,"coinInAmount must be greater than 0");let c=BigInt(new r((await es.getSuiAmountAfterSell({poolId:i,curveAmount:e,frontendFee:u?u.tradeFeePercent:void 0})).toString()).multipliedBy(1-o).toFixed(0,3)),{tx:l,coinOut:d}=await eS({accountAddress:a,inCoinType:t,outCoinType:n,inputAmount:e.toString(),minAmountOut:c.toString(),poolId:i,frontendFee:u?u.tradeFeePercent:void 0,frontendFeeRecipient:u?u.tradeFeeRecipientAddress:void 0,extendTx:void 0,isSponsored:!1},s);M(d,"Coin out is required"),l.transferObjects([d],l.pure.address(a)),l.setSender(a);let g=await F(s,l,a,0);return(l=await O({inheritTx:l,sender:a,feeAmount:g},s)).build({client:s})};var eR=((V={}).BLAST_FUN="BLAST_FUN",V.MOONBAGS="MOONBAGS",V);(W=el||(el={})).PACKAGE_ID="0xb8df325010942634a4afb3db3901ee215546af43a4ec4af781e7213b0bba7290",W.CONFIG_OBJECT_ID="0x74aecf86067c6913960ba4925333aefd2b1f929cafca7e21fd55a8f244b70499",W.LOCK_CONFIG_OBJECT_ID="0xfb09822d9808980abd04c51321adb850701f5f55535c6206658ef4d910c3e9be",W.BURN_MANAGER_OBJECT_ID="0x1d94aa32518d0cb00f9de6ed60d450c9a2090761f326752ffad06b2e9404f845",W.POOLS_OBJECT_ID="0xf699e7f2276f5c9a75944b37a0c5b5d9ddfd2471bf6242483b03ab2887d198d0",W.GLOBAL_CONFIG_OBJECT_ID="0xdaa46292632c3c4d8f31f23ea0f9b36a28ff3677e9684980e4438403a67a3d8f",W.FEE_DENOMINATOR=BigInt(1e4),(H=(X=ed||(ed={})).Curves||(X.Curves={})).calculateAddLiquidityCost=function(e,t,n){return e*t/(t-n)-e},H.calculateRemoveLiquidityReturn=function(e,t,n){return t-e*t/(e+n)},H.calculateTokenAmountReceived=function(e,t,n){return t-e*t/(e+n)},(Z=X.Moonbags||(X.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)},Z.buyExactInReturnsWithLock=function(e){let{inputAmount:t,amountIn:n,pool:i,config:r,dynamicVirtualTokenReserves:o}=e,a=BigInt(i.virtual_sui_reserves),u=BigInt(i.virtual_token_reserves),s=BigInt(i.remain_token_reserves.fields.balance),c=X.Curves.calculateRemoveLiquidityReturn(a,u,n),l=u-(o||s),d=c,g=n;c>l&&(d=l,g=X.Curves.calculateAddLiquidityCost(a,u,l)+BigInt(1));let p=g*BigInt(r.platform_fee)/el.FEE_DENOMINATOR;return M(t>=g+p,"Input amount is less than used SUI + fee"),{receivedCurve:d,receivedSui:t-g-p}},Z.sellReturns=function(e){let{amountIn:t,pool:n,config:i}=e,r=BigInt(n.virtual_sui_reserves),o=BigInt(n.virtual_token_reserves),a=BigInt(n.real_sui_reserves.fields.balance),u=X.Curves.calculateRemoveLiquidityReturn(o,r,t);u>a&&(u=a);let s=u*BigInt(i.platform_fee)/el.FEE_DENOMINATOR,c=u-s;return{receivedCurve:BigInt(0),receivedSui:c}},(Y=eg||(eg={})).getCurveAmountAfterBuy=async function(e,t){let{suiAmount:n,poolId:i,frontendFee:r}=e,[o,a,u]=await Promise.all([e_(t,i),e_(t,el.CONFIG_OBJECT_ID),ed.Moonbags.getDynamicVirtualTokenReserves(t,i)]);void 0!==r&&(n=y(n,r));let s=n*el.FEE_DENOMINATOR/(el.FEE_DENOMINATOR+BigInt(a.platform_fee)),{receivedCurve:c}=ed.Moonbags.buyExactInReturnsWithLock({inputAmount:n,amountIn:s,pool:o,config:a,dynamicVirtualTokenReserves:u});return c},Y.getSuiAmountAfterSell=async function(e,t){let{curveAmount:n,poolId:i,frontendFee:r}=e,[o,a]=await Promise.all([e_(t,i),e_(t,el.CONFIG_OBJECT_ID)]),{receivedSui:u}=ed.Moonbags.sellReturns({amountIn:n,pool:o,config:a});return void 0!==r?y(u,r):u},Y.getUsedSuiForTx=async function(e,t){let{suiAmount:n,frontendFee:i}=e,r=await e_(t,el.CONFIG_OBJECT_ID);return void 0!==i&&(n=y(n,i)),n*el.FEE_DENOMINATOR/(el.FEE_DENOMINATOR+BigInt(r.platform_fee))};var eE=ep||(ep={});async function ex(e,t){let{tx:n,coinOut:i}=await ey(e,t);M(i,"Coin out is required");let r=await eg.getUsedSuiForTx({suiAmount:BigInt(e.inputAmount),frontendFee:e.frontendFee},t),[o,a]=n.moveCall({target:`${el.PACKAGE_ID}::moonbags::buy_exact_in_returns_with_lock`,typeArguments:[e.outCoinType],arguments:[n.object(el.CONFIG_OBJECT_ID),n.object(el.LOCK_CONFIG_OBJECT_ID),i,n.pure.u64(r),n.pure.u64(e.minAmountOut),n.object(el.BURN_MANAGER_OBJECT_ID),n.object(el.POOLS_OBJECT_ID),n.object(el.GLOBAL_CONFIG_OBJECT_ID),n.object(R),n.object(B)]});return ea.transferOrDestroyZeroCoin(n,x,o,e.accountAddress),{tx:n,coinOut:a}}async function ek(e,t){M(S(e.outCoinType),"Output must be SUI");let{tx:n,coinData:i}=await C({amount:e.inputAmount,coinType:e.inCoinType,inheritTx:e.extendTx?.tx,account:e.accountAddress,splits:[e.inputAmount]},t),[r]=i,[o,a]=n.moveCall({target:`${el.PACKAGE_ID}::moonbags::sell_returns`,typeArguments:[e.inCoinType],arguments:[n.object(el.CONFIG_OBJECT_ID),r,n.pure.u64(e.minAmountOut),n.object(B)]});return ea.transferOrDestroyZeroCoin(n,e.inCoinType,a,e.accountAddress),await eC(n,e,o)}function eP(e){return e}function eM(e){return e}function eD(e){return new Proxy(e,{get(e,t){let n=e[t];return"function"==typeof n?n.bind(e):n}})}eE.buildBuyTx=ex,eE.buildSellTx=ek,eE.getBuyTransaction=async function({coinInAmount:e,coinInType:t,coinOutType:n,poolId:i,slippage:o,walletAddress:a,tradeFee:u},s){M(S(t),"coinInType must be SUI for buy transaction"),M(n!==t,"coinOutType must be different from coinInType"),M(o>=0&&o<1,"slippage must be between 0 (inclusive) and 1 (exclusive)"),M(e>0,"coinInAmount must be greater than 0");let c=BigInt(new r((await eg.getCurveAmountAfterBuy({poolId:i,suiAmount:e,frontendFee:u?u.tradeFeePercent:void 0},s)).toString()).multipliedBy(1-o).toFixed(0,3)),{tx:l,coinOut:d}=await ex({accountAddress:a,inCoinType:t,outCoinType:n,inputAmount:e.toString(),minAmountOut:c.toString(),poolId:i,frontendFee:u?u.tradeFeePercent:void 0,frontendFeeRecipient:u?u.tradeFeeRecipientAddress:void 0,extendTx:void 0,isSponsored:!1},s);M(d,"Coin out is required"),l.transferObjects([d],l.pure.address(a)),l.setSender(a);let g=await F(s,l,a,0);return(l=await O({inheritTx:l,sender:a,feeAmount:g,suiInputAmount:e},s)).build({client:s})},eE.getSellTransaction=async function({coinInAmount:e,coinInType:t,coinOutType:n,poolId:i,slippage:o,walletAddress:a,tradeFee:u},s){M(S(n),"coinOutType must be SUI for sell transaction"),M(n!==t,"coinOutType must be different from coinInType"),M(o>=0&&o<1,"slippage must be between 0 (inclusive) and 1 (exclusive)"),M(e>0,"coinInAmount must be greater than 0");let c=BigInt(new r((await eg.getSuiAmountAfterSell({poolId:i,curveAmount:e,frontendFee:u?u.tradeFeePercent:void 0},s)).toString()).multipliedBy(1-o).toFixed(0,3)),{tx:l,coinOut:d}=await ek({accountAddress:a,inCoinType:t,outCoinType:n,inputAmount:e.toString(),minAmountOut:c.toString(),poolId:i,frontendFee:u?u.tradeFeePercent:void 0,frontendFeeRecipient:u?u.tradeFeeRecipientAddress:void 0,extendTx:void 0,isSponsored:!1},s);M(d,"Coin out is required"),l.transferObjects([d],l.pure.address(a)),l.setSender(a);let g=await F(s,l,a,0);return(l=await O({inheritTx:l,sender:a,feeAmount:g},s)).build({client:s})};class eN{sdk;_astrosAggregator;_aftermathAggregator;_sevenkAggregator;_cetusAggregator;_flowXAggregator;constructor(e){this.sdk=e,this._astrosAggregator=new K({defaultTradeFee:e.options.tradeFee,astrosApiKey:e.options.astrosApiKey},e.suiClient),this._aftermathAggregator=new N({defaultTradeFee:e.options.tradeFee,aftermathApiKey:e.options.aftermathApiKey,aftermathApiEndpoint:e.options.aftermathApiEndpoint},e.suiClient),this._sevenkAggregator=new D({defaultTradeFee:e.options.tradeFee,sevenKApiKey:e.options.sevenKApiKey},e.suiClient),this._cetusAggregator=new U({defaultTradeFee:e.options.tradeFee,cetusApiKey:e.options.cetusApiKey,cetusApiEndpoint:e.options.cetusApiEndpoint,cetusPartnerId:e.options.cetusPartnerId},e.suiClient),this._flowXAggregator=new ef({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 em.ASTROS:{let e,i=await this._astrosAggregator.getTradeRoute(t);if(!i)return null;let o=K.toCommonTradeRoutes(i,t.coinInType,t.coinOutType);if(!o)return null;e=t.tradeFee?t.tradeFee.tradeFeePercent:this.sdk.options.tradeFee.tradeFeePercent,o.amountOut=BigInt(new r(i.amount_out).multipliedBy(1-e).toFixed(0,3)),n={route:o,aggregatorRoute:i};break}case em.AFTERMATH:{let e=await this._aftermathAggregator.getTradeRoute(t);if(!e)return null;let i=N.toCommonTradeRoutes(e);if(!i)return null;n={route:i,aggregatorRoute:e};break}case em.SEVENK:{let e=await this._sevenkAggregator.getTradeRoute(t);if(!e)return null;let i=D.toCommonTradeRoutes(e);if(!i)return null;n={route:i,aggregatorRoute:e};break}case em.CETUS:{let e=await this._cetusAggregator.getTradeRoute(t);if(!e)return null;let i=U.toCommonTradeRoutes(e,t.coinInType,t.coinOutType);if(!i)return null;n={route:i,aggregatorRoute:e};break}case em.FLOWX:{let e=await this._flowXAggregator.getTradeRoute(t);if(!e)return null;let i=ef.toCommonTradeRoutes(e);if(!i)return null;n={route:i,aggregatorRoute:e}}}return n}async getTransactionByRoute(e,t){switch(e){case em.ASTROS:return this._astrosAggregator.getTransaction({walletAddress:t.walletAddress,completeRoute:t.completeRoute,slippage:t.slippage,tradeFee:t.tradeFee});case em.AFTERMATH:return this._aftermathAggregator.getTransaction({walletAddress:t.walletAddress,completeRoute:t.completeRoute,slippage:t.slippage});case em.SEVENK:return this._sevenkAggregator.getTransaction({walletAddress:t.walletAddress,completeRoute:t.completeRoute,slippage:t.slippage,tradeFee:t.tradeFee});case em.CETUS:return this._cetusAggregator.getTransaction({walletAddress:t.walletAddress,completeRoute:t.completeRoute,slippage:t.slippage,tradeFee:t.tradeFee});case em.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 i=await this.getTransactionByRoute(e,{walletAddress:t.walletAddress,completeRoute:n.aggregatorRoute,slippage:t.slippage,tradeFee:t.tradeFee});return{route:n.route,aggregatorRoute:n.aggregatorRoute,transaction:i}}async getTradeTransactionWithBestRate(e){let t=Object.keys(em),n=await Promise.all(t.map(async t=>{try{return await this.getTradeRoute(t,e)}catch{return null}})),i=null,r=null;for(let e=0;e<n.length;e++){let o=n[e],a=t[e];if(o&&(!i||o.route.amountOut>i.route.amountOut)){i=o,r=a;continue}}if(!i||!r)return null;let o=await this.getTransactionByRoute(r,{walletAddress:e.walletAddress,completeRoute:i.aggregatorRoute,slippage:e.slippage,tradeFee:e.tradeFee});return{route:i.route,aggregatorRoute:i.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(em),n=null,i=null;for(let r of t){let t=await this.getAmountOut(r,e);null!==t&&(null===n||t>n)&&(n=t,i=r)}return null===n||null===i?null:{amountOut:n,aggregator:i}}}class eK{sdk;constructor(e){this.sdk=e}async getEstimatedAmountOut(e,t){let{coinInType:n,coinOutType:i}=t;M(n!==i,"coinInType and coinOutType must be different"),M(S(n)||S(i),"One of coinInType or coinOutType must be SUI");let r=S(n);switch(e){case eR.MOONBAGS:if(r)return await eg.getCurveAmountAfterBuy({poolId:t.poolId,suiAmount:t.coinInAmount,frontendFee:t.tradeFee?t.tradeFee.tradeFeePercent:void 0},this.sdk.suiClient);return await eg.getSuiAmountAfterSell({poolId:t.poolId,curveAmount:t.coinInAmount,frontendFee:t.tradeFee?t.tradeFee.tradeFeePercent:void 0},this.sdk.suiClient);case eR.BLAST_FUN:if(r)return await es.getCurveAmountAfterBuy({poolId:t.poolId,suiAmount:t.coinInAmount,frontendFee:t.tradeFee?t.tradeFee.tradeFeePercent:void 0});return await es.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:i,coinOutType:r}=t;M(i!==r,"coinInType and coinOutType must be different"),M(S(i)||S(r),"One of coinInType or coinOutType must be SUI");let o=S(i);switch(e){case eR.MOONBAGS:n=o?await ep.getBuyTransaction(t,this.sdk.suiClient):await ep.getSellTransaction(t,this.sdk.suiClient);break;case eR.BLAST_FUN:n=o?await ec.getBuyTransaction(t,this.sdk.suiClient):await ec.getSellTransaction(t,this.sdk.suiClient);break;default:throw Error(`Unsupported bonding curve platform: ${e}`)}return n}}let eU={tradeFeePercent:.01,tradeFeeRecipientAddress:"0xdaf1c8ed29d89cd8f217f609bad0a668fa6f158c12000bfa5f93e670c99e24ff"};class ej{network;env;options;_suiClient;aggregatorModule;curveModule;constructor(e,t="mainnet",n="prod"){this.options=e,this.network=t,this.env=n;let i=E(t);this._suiClient=new b({url:i}),this.aggregatorModule=new eN(this),this.curveModule=new eK(this)}get suiClient(){return this._suiClient}}class eG{suiClient;constructor(e){this.suiClient=e}validatePrivateKey(e,t){M(e?.trim(),"Private key is required");let n=T.fromSecretKey(e),i=n.getPublicKey().toSuiAddress();if(i!==t)throw Error(`Private key mismatch. Expected: ${t}, Got: ${i}`);return n}async createDraft(e,t,n){M(e?.trim(),"Sender address is required"),M(t?.trim(),"Recipient address is required"),M(e!==t,"Sender and recipient cannot be the same"),M(n>0n,"Transfer amount must be at least 1 MIST");try{let i=new w,[r]=i.splitCoins(i.gas,[n]);i.transferObjects([r],t),i.setSender(e);let o=await this.suiClient.getReferenceGasPrice();i.setGasPrice(o);let a=await F(this.suiClient,i,e,.1);i=await O({inheritTx:i,sender:e,feeAmount:a,suiInputAmount:n},this.suiClient);let u=await i.build({client:this.suiClient}),s=Buffer.from(u).toString("base64"),c=await i.getDigest();return{sender:e,recipient:t,amountMIST:n,txDraftBase64:s,txDigest:c}}catch(e){throw Error(`Failed to create draft transaction: ${e instanceof Error?e.message:"Unknown error"}`)}}async execute(e,t){try{M(e,"Draft transaction is required"),M(e.txDraftBase64?.trim(),"Transaction data is required");let n=this.validatePrivateKey(t,e.sender),i=P(e.txDraftBase64),{signature:r}=await n.signTransaction(i),o=await this.suiClient.executeTransactionBlock({transactionBlock:i,signature:r});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){M(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"}}}var eq=1e4;export{ADMIN_CAP_ID,BOOSTING_PACKAGE_ID,BoostingModule,CLOCK_OBJECT_ID,CONFIG_ID,NATIVE_USDC_TOKEN_TYPE,NoodlesPaySdk,SUBSCRIPTION_CONFIG,SUI_FULL_TYPE,SUI_METADATA_OBJECT_ID,SUI_TYPE,SubscriptionModule,USDC_TOKEN_TYPE,addGasFee,getAmountAfterFee,getCoinObjectIdsByAmount,getNeededGasFee,getSplitCoinForTx,getSplitCoinsAfterFee,isSuiCoinType}from"./982.js";export{eN as AggregatorModule,eT as BLUEFIN_PACKAGE_ID,eK as CurveModule,eU as DEFAULT_TRADE_FEE,eG as DraftTransferTx,ej as NoodlesSdk,D as SevenKAggregator,eP as adaptSuiClient,eM as adaptTransaction,N as AftermathAggregator,K as AstrosAggregator,ea as BluefinTx,eg as MoonbagsCalculation,U as CetusAggregator,em as SupportedAggregator,et as BlastFunConstants,el as MoonbagsConstants,eD as createCompatibleSuiClient,eo as BlastFunCustomCalculation,eu as BlastFunCustomTransaction,eq as BASE_BPS,ef as FlowXAggregator,eb as getMemezPumpSDK,eA as getMoveObject,e_ as getMoveObjectContent,er as BlastFunPackage,ei as Bps,en as MathUtils,ed as MoonbagsPackage,es as BlastFunSDKCalculation,ec as BlastFunSDKTransaction,ey as splitSuiCoinAfterFeeFromBuyTx,eC as splitSuiCoinAfterFeeFromSellTx,ep as MoonbagsTransaction,eR as SupportedBondingCurve,ee as TradeFeeOptions};
|
package/dist/pay.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
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 __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__,{ADMIN_CAP_ID:()=>ADMIN_CAP_ID,CONFIG_ID:()=>CONFIG_ID,BOOSTING_PACKAGE_ID:()=>BOOSTING_PACKAGE_ID,SUBSCRIPTION_PACKAGE_ID:()=>SUBSCRIPTION_PACKAGE_ID,SUBSCRIPTION_ADMIN_CAP_ID:()=>SUBSCRIPTION_ADMIN_CAP_ID,SUBSCRIPTION_CONFIG_ID:()=>SUBSCRIPTION_CONFIG_ID,SubscriptionModule:()=>SubscriptionModule,PAYMENT_COIN_TYPE:()=>PAYMENT_COIN_TYPE,BoostingModule:()=>BoostingModule,NoodlesPaySdk:()=>NoodlesPaySdk});const tiny_invariant_namespaceObject=require("@minswap/tiny-invariant");var tiny_invariant_default=__webpack_require__.n(tiny_invariant_namespaceObject);const transactions_namespaceObject=require("@mysten/sui/transactions"),utils_namespaceObject=require("@mysten/sui/utils"),BASE_BPS=1e4;function getSplitCoinsAfterFee(e,t){let n=BigInt(e),i=BigInt(1e4*Number(t));if(i===BigInt(0))return[n.toString()];let a=n*i/BigInt(1e4);return[(n-a).toString(),a.toString()]}function getAmountAfterFee(e,t){if(!t||0>=Number(t))return BigInt(e);let n=BigInt(e),i=BigInt(1e4*Number(t));if(i===BigInt(0))return n;let a=n*i/BigInt(1e4);return n-a}async function getNeededGasFee(e,t,n,i){let{effects:{gasUsed:a,status:s}}=await e.devInspectTransactionBlock({sender:n,transactionBlock:t});if("success"!==s.status)throw Error(`Transaction failed during dev inspect: ${s.error??""}`);let r=BigInt(a.computationCost)+BigInt(a.storageCost)-BigInt(a.storageRebate),_=BigInt(1e4*Number(i));return r*(BigInt(1e4)+_)/BigInt(1e4)}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"0x2::sui::SUI"===e||e===SUI_FULL_TYPE}const orderByKey=(e,t,n)=>{let i;if(e?.length){do{i=!1;for(let a=0;a<e.length-1;a++){let s=BigInt(e[a][t]),r=BigInt(e[a+1][t]);if("desc"===n?s<r:s>r){let t=e[a];e[a]=e[a+1],e[a+1]=t,i=!0}}}while(i);return e}},getCoinObjectIdsByAmount=async(e,t,n,i)=>{let a,s=[],r=!0;for(;r;)try{let n=await e.getCoins({owner:t,coinType:i,cursor:a});s=[...s,...n.data],r=n.hasNextPage,a=n.nextCursor}catch(e){console.error("Error fetching data:",e),r=!1}let _=orderByKey(s.map(e=>({...e,balance:e.balance})),"balance","desc")??[],o="0",c=[],u=[];for(let e of _)if(o=(BigInt(e.balance)+BigInt(o)).toString(10),c.push(e.coinObjectId),u.push(e),BigInt(o)>=BigInt(n))break;return{objectIds:c,balance:o,objectCoins:u}};async function addGasFee(e,t){let{inheritTx:n,sender:i,feeAmount:a,suiInputAmount:s}=e,r=n||new transactions_namespaceObject.Transaction;r.setGasBudget(a);let{objectCoins:_}=await getCoinObjectIdsByAmount(t,i,(BigInt(s||"0")+a).toString(),SUI_FULL_TYPE);return r.setGasPayment(_.map(e=>({objectId:e.coinObjectId,version:e.version,digest:e.digest}))),r}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,i=t.fee_receiver,a=t.tiers.fields.contents,s={};for(let e of a){let t=e.fields.key,n=e.fields.value.fields.duration,i=e.fields.value.fields.amount,a=e.fields.value.fields.point,r=e.fields.value.fields.original_amount;s[t]={duration:BigInt(n),amount:BigInt(i),point:BigInt(a),originalAmount:BigInt(r)}}return{id:n,receiverAddress:i,tiers:s}}async buildPayBoostingTx({walletAddress:e,tierId:t,boostingCoinType:n,currentTx:i}){let a=await this.getConfig();tiny_invariant_default()(t in a.tiers,"Invalid tier ID");let s=a.tiers[t].amount,r=i||new transactions_namespaceObject.Transaction,_=r.splitCoins(r.gas,[r.pure.u64(s)]);r.moveCall({target:`${BOOSTING_PACKAGE_ID}::boosting::pay`,typeArguments:[(0,utils_namespaceObject.normalizeStructTag)(n)],arguments:[r.object(CONFIG_ID),r.pure.u64(t),_]}),r.setSender(e);let o=await getNeededGasFee(this.sdk.suiClient,r,e,0);return addGasFee({inheritTx:r,sender:e,feeAmount:o},this.sdk.suiClient)}async buildAddTierTx({adminAddress:e,tierId:t,duration:n,point:i,originalAmount:a,amount:s,currentTx:r}){let _=r||new transactions_namespaceObject.Transaction;_.moveCall({target:`${BOOSTING_PACKAGE_ID}::config::add_tier`,typeArguments:[],arguments:[_.object(CONFIG_ID),_.object(ADMIN_CAP_ID),_.pure.u64(t),_.pure.u64(i),_.pure.u64(n),_.pure.u64(a),_.pure.u64(s)]}),_.setSender(e);let o=await getNeededGasFee(this.sdk.suiClient,_,e,0);return addGasFee({inheritTx:_,sender:e,feeAmount:o},this.sdk.suiClient)}async buildUpdateTierTx({adminAddress:e,tierId:t,duration:n,amount:i,originalAmount:a,point:s,currentTx:r}){let _=r||new transactions_namespaceObject.Transaction;_.moveCall({target:`${BOOSTING_PACKAGE_ID}::config::update_tier`,typeArguments:[],arguments:[_.object(CONFIG_ID),_.object(ADMIN_CAP_ID),_.pure.u64(t),_.pure.u64(n),_.pure.u64(i),_.pure.u64(s),_.pure.u64(a)]}),_.setSender(e);let o=await getNeededGasFee(this.sdk.suiClient,_,e,0);return addGasFee({inheritTx:_,sender:e,feeAmount:o},this.sdk.suiClient)}async buildRemoveTierTx({adminAddress:e,tierId:t,currentTx:n}){let i=n||new transactions_namespaceObject.Transaction;i.moveCall({target:`${BOOSTING_PACKAGE_ID}::config::remove_tier`,typeArguments:[],arguments:[i.object(CONFIG_ID),i.object(ADMIN_CAP_ID),i.pure.u64(t)]}),i.setSender(e);let a=await getNeededGasFee(this.sdk.suiClient,i,e,0);return addGasFee({inheritTx:i,sender:e,feeAmount:a},this.sdk.suiClient)}async buildUpdateFeeReceiver({adminAddress:e,newReceiverAddress:t,currentTx:n}){let i=n||new transactions_namespaceObject.Transaction;i.moveCall({target:`${BOOSTING_PACKAGE_ID}::config::update_fee_receiver`,typeArguments:[],arguments:[i.object(CONFIG_ID),i.object(ADMIN_CAP_ID),i.pure.address(t)]}),i.setSender(e);let a=await getNeededGasFee(this.sdk.suiClient,i,e,0);return addGasFee({inheritTx:i,sender:e,feeAmount:a},this.sdk.suiClient)}async buildPayBoostingWithAdminTx({walletAddress:e,tierId:t,customAmount:n,boostingCoinType:i,currentTx:a}){let s=a||new transactions_namespaceObject.Transaction,r=s.splitCoins(s.gas,[s.pure.u64(n)]);s.moveCall({target:`${BOOSTING_PACKAGE_ID}::boosting::pay_with_admin`,typeArguments:[(0,utils_namespaceObject.normalizeStructTag)(i)],arguments:[s.object(ADMIN_CAP_ID),s.object(CONFIG_ID),s.pure.u64(t),s.pure.u64(n),r]}),s.setSender(e);let _=await getNeededGasFee(this.sdk.suiClient,s,e,0);return addGasFee({inheritTx:s,sender:e,feeAmount:_},this.sdk.suiClient)}}async function getSplitCoinForTx(e,t){let{account:n,amount:i,splits:a,coinType:s,inheritTx:r,inspecTransaction:_,isSponsored:o=!1}=e,c=r??new transactions_namespaceObject.Transaction,{objectIds:u}=await getCoinObjectIdsByAmount(t,n,i,s),d=u[0];if((0,utils_namespaceObject.normalizeStructTag)(s)===(0,utils_namespaceObject.normalizeStructTag)(SUI_FULL_TYPE)&&!o){let e;return _?(u.length>1&&c.mergeCoins(c.object(d),u.slice(1).map(e=>c.object(e))),e=c.splitCoins(c.object(d),a)):e=c.splitCoins(c.gas,a),{tx:c,coinData:e}}u.length>1&&c.mergeCoins(c.object(d),u.slice(1).map(e=>c.object(e)));let l=c.splitCoins(c.object(d),a);return{tx:c,coinData:l}}const SUBSCRIPTION_PACKAGE_ID="0x3dd678c250a667f1551bc4b9e35fd070896f4775dd2900d5cb2910d2aea0b068",SUBSCRIPTION_CONFIG_ID="0x3eb7bd15f61b7cc1a9fd36151e9c3d05aa37bfadb0a58c3a26a6c02c2e99f3ca",SUBSCRIPTION_ADMIN_CAP_ID="0xf375fcb3d95934143766cab2028ab49441fa04ef2ce27c08c01004c455bcbad4",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,i=t.fee_receiver,a=t.paused,s=t.accepted_payment_type,r=t.plans.fields.contents,_={};for(let e of r){let t=e.fields.key,n=e.fields.value.fields.id,i=e.fields.value.fields.price,a=e.fields.value.fields.month_interval,s=e.fields.value.fields.ptype;_[t]={id:BigInt(n),price:BigInt(i),monthInterval:a,planType:s}}return{id:n,plans:_,feeReceiverWallet:i,paused:a,acceptedPaymentType:s}}async buildSubscribeCyclePlanTx({walletAddress:e,planId:t,reference:n,paymentCoinType:i=PAYMENT_COIN_TYPE,currentTx:a}){let s=await this.getConfig();tiny_invariant_default()(!s.paused,"Contract is paused"),tiny_invariant_default()(t in s.plans,"Invalid plan ID");let r=s.plans[t],_=r.price*BigInt(r.monthInterval),{tx:o,coinData:c}=await getSplitCoinForTx({account:e,amount:_.toString(),splits:[_.toString()],coinType:i,inheritTx:a},this.sdk.suiClient);o.moveCall({target:`${SUBSCRIPTION_PACKAGE_ID}::subscription::subscribe_cycle_plan`,typeArguments:[i],arguments:[o.object(SUBSCRIPTION_CONFIG_ID),o.pure.u64(t),o.pure.string(n),c]}),o.setSender(e);let u=await getNeededGasFee(this.sdk.suiClient,o,e,0);return addGasFee({inheritTx:o,sender:e,feeAmount:u},this.sdk.suiClient)}async buildBuyMoreCUPlanTx({walletAddress:e,planId:t,reference:n,paidAmount:i,paymentCoinType:a=PAYMENT_COIN_TYPE,currentTx:s}){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:_,coinData:o}=await getSplitCoinForTx({account:e,amount:i.toString(),splits:[i.toString()],coinType:a,inheritTx:s},this.sdk.suiClient);_.moveCall({target:`${SUBSCRIPTION_PACKAGE_ID}::subscription::buy_more_cu`,typeArguments:[a],arguments:[_.object(SUBSCRIPTION_CONFIG_ID),_.pure.u64(t),_.pure.string(n),_.pure.u64(i),o]}),_.setSender(e);let c=await getNeededGasFee(this.sdk.suiClient,_,e,0);return addGasFee({inheritTx:_,sender:e,feeAmount:c},this.sdk.suiClient)}async buildSubscribePlanWithAdminTx({walletAddress:e,planId:t,reference:n,customAmount:i,paymentCoinType:a=PAYMENT_COIN_TYPE,currentTx:s}){let r=await this.getConfig();tiny_invariant_default()(!r.paused,"Contract is paused");let{tx:_,coinData:o}=await getSplitCoinForTx({account:e,amount:i.toString(),splits:[i.toString()],coinType:a,inheritTx:s},this.sdk.suiClient);_.moveCall({target:`${SUBSCRIPTION_PACKAGE_ID}::subscription::subscribe_plan_with_admin`,typeArguments:[a],arguments:[_.object(SUBSCRIPTION_ADMIN_CAP_ID),_.object(SUBSCRIPTION_CONFIG_ID),_.pure.u64(t),_.pure.string(n),_.pure.u64(i),o]}),_.setSender(e);let c=await getNeededGasFee(this.sdk.suiClient,_,e,0);return addGasFee({inheritTx:_,sender:e,feeAmount:c},this.sdk.suiClient)}async buildAddPlanTx({adminAddress:e,planId:t,planType:n,monthInterval:i,price:a,currentTx:s}){let r=s||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(i),r.pure.u64(a)]}),r.setSender(e);let _=await getNeededGasFee(this.sdk.suiClient,r,e,0);return addGasFee({inheritTx:r,sender:e,feeAmount:_},this.sdk.suiClient)}async buildUpdatePlanTx({adminAddress:e,planId:t,planType:n,monthInterval:i,price:a,currentTx:s}){let r=s||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(i),r.pure.u64(a)]}),r.setSender(e);let _=await getNeededGasFee(this.sdk.suiClient,r,e,0);return addGasFee({inheritTx:r,sender:e,feeAmount:_},this.sdk.suiClient)}async buildRemovePlanTx({adminAddress:e,planId:t,currentTx:n}){let i=n||new transactions_namespaceObject.Transaction;i.moveCall({target:`${SUBSCRIPTION_PACKAGE_ID}::config::remove_plan`,typeArguments:[],arguments:[i.object(SUBSCRIPTION_CONFIG_ID),i.object(SUBSCRIPTION_ADMIN_CAP_ID),i.pure.u64(BigInt(t))]}),i.setSender(e);let a=await getNeededGasFee(this.sdk.suiClient,i,e,0);return addGasFee({inheritTx:i,sender:e,feeAmount:a},this.sdk.suiClient)}async buildUpdateFeeReceiverWalletTx({adminAddress:e,newFeeReceiverWallet:t,currentTx:n}){let i=n||new transactions_namespaceObject.Transaction;i.moveCall({target:`${SUBSCRIPTION_PACKAGE_ID}::config::update_fee_receiver`,typeArguments:[],arguments:[i.object(SUBSCRIPTION_CONFIG_ID),i.object(SUBSCRIPTION_ADMIN_CAP_ID),i.pure.address(t)]}),i.setSender(e);let a=await getNeededGasFee(this.sdk.suiClient,i,e,0);return addGasFee({inheritTx:i,sender:e,feeAmount:a},this.sdk.suiClient)}async buildSetPausedTx({adminAddress:e,paused:t,currentTx:n}){let i=n||new transactions_namespaceObject.Transaction;i.moveCall({target:`${SUBSCRIPTION_PACKAGE_ID}::config::set_paused`,typeArguments:[],arguments:[i.object(SUBSCRIPTION_CONFIG_ID),i.object(SUBSCRIPTION_ADMIN_CAP_ID),i.pure.bool(t)]}),i.setSender(e);let a=await getNeededGasFee(this.sdk.suiClient,i,e,0);return addGasFee({inheritTx:i,sender:e,feeAmount:a},this.sdk.suiClient)}async buildSetAcceptedPaymentTypeTx({adminAddress:e,paymentCoinType:t,currentTx:n}){let i=n||new transactions_namespaceObject.Transaction;i.moveCall({target:`${SUBSCRIPTION_PACKAGE_ID}::config::set_accepted_payment_type`,typeArguments:[t],arguments:[i.object(SUBSCRIPTION_CONFIG_ID),i.object(SUBSCRIPTION_ADMIN_CAP_ID)]}),i.setSender(e);let a=await getNeededGasFee(this.sdk.suiClient,i,e,0);return addGasFee({inheritTx:i,sender:e,feeAmount:a},this.sdk.suiClient)}}const client_namespaceObject=require("@mysten/sui/client");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}}for(var __rspack_i in exports.ADMIN_CAP_ID=__webpack_exports__.ADMIN_CAP_ID,exports.BOOSTING_PACKAGE_ID=__webpack_exports__.BOOSTING_PACKAGE_ID,exports.BoostingModule=__webpack_exports__.BoostingModule,exports.CONFIG_ID=__webpack_exports__.CONFIG_ID,exports.NoodlesPaySdk=__webpack_exports__.NoodlesPaySdk,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.SubscriptionModule=__webpack_exports__.SubscriptionModule,__webpack_exports__)-1===["ADMIN_CAP_ID","BOOSTING_PACKAGE_ID","BoostingModule","CONFIG_ID","NoodlesPaySdk","PAYMENT_COIN_TYPE","SUBSCRIPTION_ADMIN_CAP_ID","SUBSCRIPTION_CONFIG_ID","SUBSCRIPTION_PACKAGE_ID","SubscriptionModule"].indexOf(__rspack_i)&&(exports[__rspack_i]=__webpack_exports__[__rspack_i]);Object.defineProperty(exports,"__esModule",{value:!0});
|
|
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 __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__,{ADMIN_CAP_ID:()=>ADMIN_CAP_ID,CONFIG_ID:()=>CONFIG_ID,SUBSCRIPTION_CONFIG:()=>SUBSCRIPTION_CONFIG,BOOSTING_PACKAGE_ID:()=>BOOSTING_PACKAGE_ID,BoostingModule:()=>BoostingModule,NoodlesPaySdk:()=>NoodlesPaySdk,SubscriptionModule:()=>SubscriptionModule});const tiny_invariant_namespaceObject=require("@minswap/tiny-invariant");var tiny_invariant_default=__webpack_require__.n(tiny_invariant_namespaceObject);const transactions_namespaceObject=require("@mysten/sui/transactions"),utils_namespaceObject=require("@mysten/sui/utils"),BASE_BPS=1e4;function getSplitCoinsAfterFee(e,t){let n=BigInt(e),i=BigInt(1e4*Number(t));if(i===BigInt(0))return[n.toString()];let a=n*i/BigInt(1e4);return[(n-a).toString(),a.toString()]}function getAmountAfterFee(e,t){if(!t||0>=Number(t))return BigInt(e);let n=BigInt(e),i=BigInt(1e4*Number(t));if(i===BigInt(0))return n;let a=n*i/BigInt(1e4);return n-a}async function getNeededGasFee(e,t,n,i){let{effects:{gasUsed:a,status:s}}=await e.devInspectTransactionBlock({sender:n,transactionBlock:t});if("success"!==s.status)throw Error(`Transaction failed during dev inspect: ${s.error??""}`);let r=BigInt(a.computationCost)+BigInt(a.storageCost)-BigInt(a.storageRebate),d=BigInt(1e4*Number(i));return r*(BigInt(1e4)+d)/BigInt(1e4)}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"0x2::sui::SUI"===e||e===SUI_FULL_TYPE}const orderByKey=(e,t,n)=>{let i;if(e?.length){do{i=!1;for(let a=0;a<e.length-1;a++){let s=BigInt(e[a][t]),r=BigInt(e[a+1][t]);if("desc"===n?s<r:s>r){let t=e[a];e[a]=e[a+1],e[a+1]=t,i=!0}}}while(i);return e}},getCoinObjectIdsByAmount=async(e,t,n,i)=>{let a,s=[],r=!0;for(;r;)try{let n=await e.getCoins({owner:t,coinType:i,cursor:a});s=[...s,...n.data],r=n.hasNextPage,a=n.nextCursor}catch(e){console.error("Error fetching data:",e),r=!1}let d=orderByKey(s.map(e=>({...e,balance:e.balance})),"balance","desc")??[],o="0",c=[],u=[];for(let e of d)if(o=(BigInt(e.balance)+BigInt(o)).toString(10),c.push(e.coinObjectId),u.push(e),BigInt(o)>=BigInt(n))break;return{objectIds:c,balance:o,objectCoins:u}};async function addGasFee(e,t){let{inheritTx:n,sender:i,feeAmount:a,suiInputAmount:s}=e,r=n||new transactions_namespaceObject.Transaction;r.setGasBudget(a);let{objectCoins:d}=await getCoinObjectIdsByAmount(t,i,(BigInt(s||"0")+a).toString(),SUI_FULL_TYPE);return r.setGasPayment(d.map(e=>({objectId:e.coinObjectId,version:e.version,digest:e.digest}))),r}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,i=t.fee_receiver,a=t.tiers.fields.contents,s={};for(let e of a){let t=e.fields.key,n=e.fields.value.fields.duration,i=e.fields.value.fields.amount,a=e.fields.value.fields.point,r=e.fields.value.fields.original_amount;s[t]={duration:BigInt(n),amount:BigInt(i),point:BigInt(a),originalAmount:BigInt(r)}}return{id:n,receiverAddress:i,tiers:s}}async buildPayBoostingTx({walletAddress:e,tierId:t,boostingCoinType:n,currentTx:i}){let a=await this.getConfig();tiny_invariant_default()(t in a.tiers,"Invalid tier ID");let s=a.tiers[t].amount,r=i||new transactions_namespaceObject.Transaction,d=r.splitCoins(r.gas,[r.pure.u64(s)]);r.moveCall({target:`${BOOSTING_PACKAGE_ID}::boosting::pay`,typeArguments:[(0,utils_namespaceObject.normalizeStructTag)(n)],arguments:[r.object(CONFIG_ID),r.pure.u64(t),d]}),r.setSender(e);let o=await getNeededGasFee(this.sdk.suiClient,r,e,0);return addGasFee({inheritTx:r,sender:e,feeAmount:o},this.sdk.suiClient)}async buildAddTierTx({adminAddress:e,tierId:t,duration:n,point:i,originalAmount:a,amount:s,currentTx:r}){let d=r||new transactions_namespaceObject.Transaction;d.moveCall({target:`${BOOSTING_PACKAGE_ID}::config::add_tier`,typeArguments:[],arguments:[d.object(CONFIG_ID),d.object(ADMIN_CAP_ID),d.pure.u64(t),d.pure.u64(i),d.pure.u64(n),d.pure.u64(a),d.pure.u64(s)]}),d.setSender(e);let o=await getNeededGasFee(this.sdk.suiClient,d,e,0);return addGasFee({inheritTx:d,sender:e,feeAmount:o},this.sdk.suiClient)}async buildUpdateTierTx({adminAddress:e,tierId:t,duration:n,amount:i,originalAmount:a,point:s,currentTx:r}){let d=r||new transactions_namespaceObject.Transaction;d.moveCall({target:`${BOOSTING_PACKAGE_ID}::config::update_tier`,typeArguments:[],arguments:[d.object(CONFIG_ID),d.object(ADMIN_CAP_ID),d.pure.u64(t),d.pure.u64(n),d.pure.u64(i),d.pure.u64(s),d.pure.u64(a)]}),d.setSender(e);let o=await getNeededGasFee(this.sdk.suiClient,d,e,0);return addGasFee({inheritTx:d,sender:e,feeAmount:o},this.sdk.suiClient)}async buildRemoveTierTx({adminAddress:e,tierId:t,currentTx:n}){let i=n||new transactions_namespaceObject.Transaction;i.moveCall({target:`${BOOSTING_PACKAGE_ID}::config::remove_tier`,typeArguments:[],arguments:[i.object(CONFIG_ID),i.object(ADMIN_CAP_ID),i.pure.u64(t)]}),i.setSender(e);let a=await getNeededGasFee(this.sdk.suiClient,i,e,0);return addGasFee({inheritTx:i,sender:e,feeAmount:a},this.sdk.suiClient)}async buildUpdateFeeReceiver({adminAddress:e,newReceiverAddress:t,currentTx:n}){let i=n||new transactions_namespaceObject.Transaction;i.moveCall({target:`${BOOSTING_PACKAGE_ID}::config::update_fee_receiver`,typeArguments:[],arguments:[i.object(CONFIG_ID),i.object(ADMIN_CAP_ID),i.pure.address(t)]}),i.setSender(e);let a=await getNeededGasFee(this.sdk.suiClient,i,e,0);return addGasFee({inheritTx:i,sender:e,feeAmount:a},this.sdk.suiClient)}async buildPayBoostingWithAdminTx({walletAddress:e,tierId:t,customAmount:n,boostingCoinType:i,currentTx:a}){let s=a||new transactions_namespaceObject.Transaction,r=s.splitCoins(s.gas,[s.pure.u64(n)]);s.moveCall({target:`${BOOSTING_PACKAGE_ID}::boosting::pay_with_admin`,typeArguments:[(0,utils_namespaceObject.normalizeStructTag)(i)],arguments:[s.object(ADMIN_CAP_ID),s.object(CONFIG_ID),s.pure.u64(t),s.pure.u64(n),r]}),s.setSender(e);let d=await getNeededGasFee(this.sdk.suiClient,s,e,0);return addGasFee({inheritTx:s,sender:e,feeAmount:d},this.sdk.suiClient)}}async function getSplitCoinForTx(e,t){let{account:n,amount:i,splits:a,coinType:s,inheritTx:r,inspecTransaction:d,isSponsored:o=!1}=e,c=r??new transactions_namespaceObject.Transaction,{objectIds:u}=await getCoinObjectIdsByAmount(t,n,i,s),_=u[0];if((0,utils_namespaceObject.normalizeStructTag)(s)===(0,utils_namespaceObject.normalizeStructTag)(SUI_FULL_TYPE)&&!o){let e;return d?(u.length>1&&c.mergeCoins(c.object(_),u.slice(1).map(e=>c.object(e))),e=c.splitCoins(c.object(_),a)):e=c.splitCoins(c.gas,a),{tx:c,coinData:e}}u.length>1&&c.mergeCoins(c.object(_),u.slice(1).map(e=>c.object(e)));let l=c.splitCoins(c.object(_),a);return{tx:c,coinData:l}}const SUBSCRIPTION_CONFIG={prod:{packageId:"0x3dd678c250a667f1551bc4b9e35fd070896f4775dd2900d5cb2910d2aea0b068",configId:"0x3eb7bd15f61b7cc1a9fd36151e9c3d05aa37bfadb0a58c3a26a6c02c2e99f3ca",adminCapId:"0xf375fcb3d95934143766cab2028ab49441fa04ef2ce27c08c01004c455bcbad4",paymentCoinType:"0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC"},staging:{packageId:"0xa83cd093ce5142649adae10d21fe87d55fa2df4e52a4292c77ba039bb12bfe67",configId:"0x19fb8f91946e58c068fa4238bdd7a531216a0c4dcfaa279a8a02c60cb02f6711",adminCapId:"0xd8139544d054702dfab6de4e9c55f162c8a6f30465935af56cffed99c5e1c2bd",paymentCoinType:"0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC"}};class SubscriptionModule{sdk;constructor(e){this.sdk=e}async getConfig(){let e=await this.sdk.suiClient.getObject({id:SUBSCRIPTION_CONFIG[this.sdk.env].configId,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,i=t.fee_receiver,a=t.paused,s=t.accepted_payment_type,r=t.plans.fields.contents,d={};for(let e of r){let t=e.fields.key,n=e.fields.value.fields.id,i=e.fields.value.fields.price,a=e.fields.value.fields.month_interval,s=e.fields.value.fields.ptype;d[t]={id:BigInt(n),price:BigInt(i),monthInterval:a,planType:s}}return{id:n,plans:d,feeReceiverWallet:i,paused:a,acceptedPaymentType:s}}async buildSubscribeCyclePlanTx({walletAddress:e,planId:t,reference:n,paymentCoinType:i=SUBSCRIPTION_CONFIG[this.sdk.env].paymentCoinType,currentTx:a}){let s=await this.getConfig();tiny_invariant_default()(!s.paused,"Contract is paused"),tiny_invariant_default()(t in s.plans,"Invalid plan ID");let r=s.plans[t],d=r.price*BigInt(r.monthInterval),{tx:o,coinData:c}=await getSplitCoinForTx({account:e,amount:d.toString(),splits:[d.toString()],coinType:i,inheritTx:a},this.sdk.suiClient);o.moveCall({target:`${SUBSCRIPTION_CONFIG[this.sdk.env].packageId}::subscription::subscribe_cycle_plan`,typeArguments:[i],arguments:[o.object(SUBSCRIPTION_CONFIG[this.sdk.env].configId),o.pure.u64(t),o.pure.string(n),c]}),o.setSender(e);let u=await getNeededGasFee(this.sdk.suiClient,o,e,0);return addGasFee({inheritTx:o,sender:e,feeAmount:u},this.sdk.suiClient)}async buildBuyMoreCUPlanTx({walletAddress:e,planId:t,reference:n,paidAmount:i,paymentCoinType:a=SUBSCRIPTION_CONFIG[this.sdk.env].paymentCoinType,currentTx:s}){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:d,coinData:o}=await getSplitCoinForTx({account:e,amount:i.toString(),splits:[i.toString()],coinType:a,inheritTx:s},this.sdk.suiClient);d.moveCall({target:`${SUBSCRIPTION_CONFIG[this.sdk.env].packageId}::subscription::buy_more_cu`,typeArguments:[a],arguments:[d.object(SUBSCRIPTION_CONFIG[this.sdk.env].configId),d.pure.u64(t),d.pure.string(n),d.pure.u64(i),o]}),d.setSender(e);let c=await getNeededGasFee(this.sdk.suiClient,d,e,0);return addGasFee({inheritTx:d,sender:e,feeAmount:c},this.sdk.suiClient)}async buildSubscribePlanWithAdminTx({walletAddress:e,planId:t,reference:n,customAmount:i,paymentCoinType:a=SUBSCRIPTION_CONFIG[this.sdk.env].paymentCoinType,currentTx:s}){let r=await this.getConfig();tiny_invariant_default()(!r.paused,"Contract is paused");let{tx:d,coinData:o}=await getSplitCoinForTx({account:e,amount:i.toString(),splits:[i.toString()],coinType:a,inheritTx:s},this.sdk.suiClient);d.moveCall({target:`${SUBSCRIPTION_CONFIG[this.sdk.env].packageId}::subscription::subscribe_plan_with_admin`,typeArguments:[a],arguments:[d.object(SUBSCRIPTION_CONFIG[this.sdk.env].adminCapId),d.object(SUBSCRIPTION_CONFIG[this.sdk.env].configId),d.pure.u64(t),d.pure.string(n),d.pure.u64(i),o]}),d.setSender(e);let c=await getNeededGasFee(this.sdk.suiClient,d,e,0);return addGasFee({inheritTx:d,sender:e,feeAmount:c},this.sdk.suiClient)}async buildAddPlanTx({adminAddress:e,planId:t,planType:n,monthInterval:i,price:a,currentTx:s}){let r=s||new transactions_namespaceObject.Transaction;r.moveCall({target:`${SUBSCRIPTION_CONFIG[this.sdk.env].packageId}::config::add_plan`,typeArguments:[],arguments:[r.object(SUBSCRIPTION_CONFIG[this.sdk.env].configId),r.object(SUBSCRIPTION_CONFIG[this.sdk.env].adminCapId),r.pure.u64(t),r.pure.u8(n),r.pure.u8(i),r.pure.u64(a)]}),r.setSender(e);let d=await getNeededGasFee(this.sdk.suiClient,r,e,0);return addGasFee({inheritTx:r,sender:e,feeAmount:d},this.sdk.suiClient)}async buildUpdatePlanTx({adminAddress:e,planId:t,planType:n,monthInterval:i,price:a,currentTx:s}){let r=s||new transactions_namespaceObject.Transaction;r.moveCall({target:`${SUBSCRIPTION_CONFIG[this.sdk.env].packageId}::config::update_plan`,typeArguments:[],arguments:[r.object(SUBSCRIPTION_CONFIG[this.sdk.env].configId),r.object(SUBSCRIPTION_CONFIG[this.sdk.env].adminCapId),r.pure.u64(BigInt(t)),r.pure.u8(n),r.pure.u8(i),r.pure.u64(a)]}),r.setSender(e);let d=await getNeededGasFee(this.sdk.suiClient,r,e,0);return addGasFee({inheritTx:r,sender:e,feeAmount:d},this.sdk.suiClient)}async buildRemovePlanTx({adminAddress:e,planId:t,currentTx:n}){let i=n||new transactions_namespaceObject.Transaction;i.moveCall({target:`${SUBSCRIPTION_CONFIG[this.sdk.env].packageId}::config::remove_plan`,typeArguments:[],arguments:[i.object(SUBSCRIPTION_CONFIG[this.sdk.env].configId),i.object(SUBSCRIPTION_CONFIG[this.sdk.env].adminCapId),i.pure.u64(BigInt(t))]}),i.setSender(e);let a=await getNeededGasFee(this.sdk.suiClient,i,e,0);return addGasFee({inheritTx:i,sender:e,feeAmount:a},this.sdk.suiClient)}async buildUpdateFeeReceiverWalletTx({adminAddress:e,newFeeReceiverWallet:t,currentTx:n}){let i=n||new transactions_namespaceObject.Transaction;i.moveCall({target:`${SUBSCRIPTION_CONFIG[this.sdk.env].packageId}::config::update_fee_receiver`,typeArguments:[],arguments:[i.object(SUBSCRIPTION_CONFIG[this.sdk.env].configId),i.object(SUBSCRIPTION_CONFIG[this.sdk.env].adminCapId),i.pure.address(t)]}),i.setSender(e);let a=await getNeededGasFee(this.sdk.suiClient,i,e,0);return addGasFee({inheritTx:i,sender:e,feeAmount:a},this.sdk.suiClient)}async buildSetPausedTx({adminAddress:e,paused:t,currentTx:n}){let i=n||new transactions_namespaceObject.Transaction;i.moveCall({target:`${SUBSCRIPTION_CONFIG[this.sdk.env].packageId}::config::set_paused`,typeArguments:[],arguments:[i.object(SUBSCRIPTION_CONFIG[this.sdk.env].configId),i.object(SUBSCRIPTION_CONFIG[this.sdk.env].adminCapId),i.pure.bool(t)]}),i.setSender(e);let a=await getNeededGasFee(this.sdk.suiClient,i,e,0);return addGasFee({inheritTx:i,sender:e,feeAmount:a},this.sdk.suiClient)}async buildSetAcceptedPaymentTypeTx({adminAddress:e,paymentCoinType:t,currentTx:n}){let i=n||new transactions_namespaceObject.Transaction;i.moveCall({target:`${SUBSCRIPTION_CONFIG[this.sdk.env].packageId}::config::set_accepted_payment_type`,typeArguments:[t],arguments:[i.object(SUBSCRIPTION_CONFIG[this.sdk.env].configId),i.object(SUBSCRIPTION_CONFIG[this.sdk.env].adminCapId)]}),i.setSender(e);let a=await getNeededGasFee(this.sdk.suiClient,i,e,0);return addGasFee({inheritTx:i,sender:e,feeAmount:a},this.sdk.suiClient)}}const client_namespaceObject=require("@mysten/sui/client");class NoodlesPaySdk{network;env;_suiClient;boostingModule;subscriptionModule;constructor(e="mainnet",t="prod"){this.network=e,this.env=t;const n=(0,client_namespaceObject.getFullnodeUrl)(e);this._suiClient=new client_namespaceObject.SuiClient({url:n}),this.subscriptionModule=new SubscriptionModule(this),this.boostingModule=new BoostingModule(this)}get suiClient(){return this._suiClient}}for(var __rspack_i in exports.ADMIN_CAP_ID=__webpack_exports__.ADMIN_CAP_ID,exports.BOOSTING_PACKAGE_ID=__webpack_exports__.BOOSTING_PACKAGE_ID,exports.BoostingModule=__webpack_exports__.BoostingModule,exports.CONFIG_ID=__webpack_exports__.CONFIG_ID,exports.NoodlesPaySdk=__webpack_exports__.NoodlesPaySdk,exports.SUBSCRIPTION_CONFIG=__webpack_exports__.SUBSCRIPTION_CONFIG,exports.SubscriptionModule=__webpack_exports__.SubscriptionModule,__webpack_exports__)-1===["ADMIN_CAP_ID","BOOSTING_PACKAGE_ID","BoostingModule","CONFIG_ID","NoodlesPaySdk","SUBSCRIPTION_CONFIG","SubscriptionModule"].indexOf(__rspack_i)&&(exports[__rspack_i]=__webpack_exports__[__rspack_i]);Object.defineProperty(exports,"__esModule",{value:!0});
|
package/dist/pay.d.ts
CHANGED
|
@@ -160,15 +160,27 @@ export declare type BuyMoreCUPlanRequest = {
|
|
|
160
160
|
/** Configuration object ID for boosting settings */
|
|
161
161
|
export declare const CONFIG_ID = "0x8b1a8ac6e34688cd8f8f8e5fefa9d5fb9e1ff74d2f132f8e208ae5ac9cc530bb";
|
|
162
162
|
|
|
163
|
+
declare enum Environment {
|
|
164
|
+
Prod = "prod",
|
|
165
|
+
Staging = "staging"
|
|
166
|
+
}
|
|
167
|
+
|
|
163
168
|
declare interface IPayModule {
|
|
164
169
|
readonly sdk: NoodlesPaySdk;
|
|
165
170
|
}
|
|
166
171
|
|
|
172
|
+
declare enum Network {
|
|
173
|
+
Mainnet = "mainnet",
|
|
174
|
+
Testnet = "testnet"
|
|
175
|
+
}
|
|
176
|
+
|
|
167
177
|
export declare class NoodlesPaySdk {
|
|
178
|
+
readonly network: Network;
|
|
179
|
+
readonly env: Environment;
|
|
168
180
|
private _suiClient;
|
|
169
181
|
readonly boostingModule: BoostingModule;
|
|
170
182
|
readonly subscriptionModule: SubscriptionModule;
|
|
171
|
-
constructor();
|
|
183
|
+
constructor(network?: Network, env?: Environment);
|
|
172
184
|
get suiClient(): SuiClient;
|
|
173
185
|
}
|
|
174
186
|
|
|
@@ -202,9 +214,6 @@ export declare type PayBoostingWithAdminRequest = {
|
|
|
202
214
|
currentTx?: Transaction;
|
|
203
215
|
};
|
|
204
216
|
|
|
205
|
-
/** Payment coin type on SUI */
|
|
206
|
-
export declare const PAYMENT_COIN_TYPE = "0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC";
|
|
207
|
-
|
|
208
217
|
/**
|
|
209
218
|
* Parameters for removing a subscription plan (admin only).
|
|
210
219
|
*/
|
|
@@ -288,14 +297,7 @@ export declare type SubscribePlanWithAdminRequest = {
|
|
|
288
297
|
currentTx?: Transaction;
|
|
289
298
|
};
|
|
290
299
|
|
|
291
|
-
|
|
292
|
-
export declare const SUBSCRIPTION_ADMIN_CAP_ID = "0xf375fcb3d95934143766cab2028ab49441fa04ef2ce27c08c01004c455bcbad4";
|
|
293
|
-
|
|
294
|
-
/** Configuration object ID for subscription settings */
|
|
295
|
-
export declare const SUBSCRIPTION_CONFIG_ID = "0x3eb7bd15f61b7cc1a9fd36151e9c3d05aa37bfadb0a58c3a26a6c02c2e99f3ca";
|
|
296
|
-
|
|
297
|
-
/** Sui package ID for the subscription protocol */
|
|
298
|
-
export declare const SUBSCRIPTION_PACKAGE_ID = "0x3dd678c250a667f1551bc4b9e35fd070896f4775dd2900d5cb2910d2aea0b068";
|
|
300
|
+
export declare const SUBSCRIPTION_CONFIG: Record<Environment, SubscriptionPkgConfig>;
|
|
299
301
|
|
|
300
302
|
/**
|
|
301
303
|
* Complete subscription protocol configuration.
|
|
@@ -427,6 +429,13 @@ export declare class SubscriptionModule implements IPayModule {
|
|
|
427
429
|
buildSetAcceptedPaymentTypeTx({ adminAddress, paymentCoinType, currentTx, }: SetAcceptedPaymentTypeRequest): Promise<Transaction>;
|
|
428
430
|
}
|
|
429
431
|
|
|
432
|
+
declare type SubscriptionPkgConfig = {
|
|
433
|
+
packageId: string;
|
|
434
|
+
configId: string;
|
|
435
|
+
adminCapId: string;
|
|
436
|
+
paymentCoinType: string;
|
|
437
|
+
};
|
|
438
|
+
|
|
430
439
|
/**
|
|
431
440
|
* Information about a specific subscription plan.
|
|
432
441
|
*/
|
package/dist/pay.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{ADMIN_CAP_ID,BOOSTING_PACKAGE_ID,BoostingModule,CONFIG_ID,NoodlesPaySdk,
|
|
1
|
+
export{ADMIN_CAP_ID,BOOSTING_PACKAGE_ID,BoostingModule,CONFIG_ID,NoodlesPaySdk,SUBSCRIPTION_CONFIG,SubscriptionModule}from"./982.js";
|