UNPKG

@sega-so/sega-sdk

Version:

An SDK for building applications on top of SEGA.

2 lines 2.45 kB
import{ComputeBudgetProgram as W,Keypair as z,PublicKey as P,Transaction as H,TransactionMessage as j,VersionedTransaction as G}from"@solana/web3.js";import{get as u,set as h}from"lodash";var a=class{constructor(e){this.logLevel=e.logLevel!==void 0?e.logLevel:0,this.name=e.name}set level(e){this.logLevel=e}get time(){return Date.now().toString()}get moduleName(){return this.name}isLogLevel(e){return e<=this.logLevel}error(...e){return this.isLogLevel(0)?(console.error(this.time,this.name,"sdk logger error",...e),this):this}logWithError(...e){let r=e.map(i=>typeof i=="object"?JSON.stringify(i):i).join(", ");throw new Error(r)}warning(...e){return this.isLogLevel(1)?(console.warn(this.time,this.name,"sdk logger warning",...e),this):this}info(...e){return this.isLogLevel(2)?(console.info(this.time,this.name,"sdk logger info",...e),this):this}debug(...e){return this.isLogLevel(3)?(console.debug(this.time,this.name,"sdk logger debug",...e),this):this}},c={},b={};function l(t){let e=u(c,t);if(!e){let r=u(b,t);e=new a({name:t,logLevel:r}),h(c,t,e)}return e}import{TOKEN_PROGRAM_ID as X}from"@solana/spl-token";var Z=l("Sega_txUtil");function o(t,e){let[r,i]=P.findProgramAddressSync(t,e);return{publicKey:r,nonce:i}}var C=Buffer.from("vault_and_lp_mint_auth_seed","utf8"),L=Buffer.from("amm_config","utf8"),w=Buffer.from("pool","utf8"),S=Buffer.from("pool_lp_mint","utf8"),A=Buffer.from("pool_vault","utf8"),B=Buffer.from("observation","utf8");function K(t){return o([C],t)}function ie(t,e){return o([L,v(e)],t)}function V(t,e,r,i){return o([w,e.toBuffer(),r.toBuffer(),i.toBuffer()],t)}function T(t,e){return o([S,e.toBuffer()],t)}function m(t,e,r){return o([A,e.toBuffer(),r.toBuffer()],t)}function I(t,e){return o([B,e.toBuffer()],t)}function v(t){let e=new ArrayBuffer(2);return new DataView(e).setUint16(0,t,!1),new Uint8Array(e)}function oe({poolId:t,programId:e,configId:r,mintA:i,mintB:s}){let f=K(e).publicKey,n=t||V(e,r,i,s).publicKey,g=T(e,n).publicKey,p=m(e,n,i).publicKey,d=m(e,n,s).publicKey,y=I(e,n).publicKey;return{poolId:n,configId:r,authority:f,lpMint:g,vaultA:p,vaultB:d,observationId:y}}var E=Buffer.from("locked_liquidity","utf8");function ne(t,e){return o([E,e.toBuffer()],t)}export{E as LOCK_LIQUIDITY_SEED,ne as getCpLockPda,ie as getCpmmPdaAmmConfigId,V as getCpmmPdaPoolId,oe as getCreatePoolKeys,T as getPdaLpMint,I as getPdaObservationId,K as getPdaPoolAuthority,m as getPdaVault}; //# sourceMappingURL=pda.mjs.map