@cobaltx/sdk-v2
Version:
An SDK for building applications on top of CobaltX.
2 lines • 2.46 kB
JavaScript
import{ComputeBudgetProgram as W,Keypair as z,PublicKey as L,Transaction as H,TransactionMessage as j,VersionedTransaction as G}from"@solana/web3.js";import{get as l,set as P}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(o=>typeof o=="object"?JSON.stringify(o):o).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}},m={},C={};function f(t){let e=l(m,t);if(!e){let r=l(C,t);e=new a({name:t,logLevel:r}),P(m,t,e)}return e}import{TOKEN_PROGRAM_ID as Q}from"@solana/spl-token";var Z=f("CobaltX_txUtil");function i(t,e){let[r,o]=L.findProgramAddressSync(t,e);return{publicKey:r,nonce:o}}var w=Buffer.from("vault_and_lp_mint_auth_seed","utf8"),S=Buffer.from("amm_config","utf8"),A=Buffer.from("pool","utf8"),B=Buffer.from("pool_lp_mint","utf8"),K=Buffer.from("pool_vault","utf8"),V=Buffer.from("observation","utf8");function I(t){return i([w],t)}function re(t,e){return i([S,x(e)],t)}function T(t,e,r,o){return i([A,e.toBuffer(),r.toBuffer(),o.toBuffer()],t)}function v(t,e){return i([B,e.toBuffer()],t)}function g(t,e,r){return i([K,e.toBuffer(),r.toBuffer()],t)}function E(t,e){return i([V,e.toBuffer()],t)}function x(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:o,mintB:c}){let p=I(e).publicKey,n=t||T(e,r,o,c).publicKey,d=v(e,n).publicKey,y=g(e,n,o).publicKey,h=g(e,n,c).publicKey,b=E(e,n).publicKey;return{poolId:n,configId:r,authority:p,lpMint:d,vaultA:y,vaultB:h,observationId:b}}var R=Buffer.from("locked_liquidity","utf8");function ie(t,e){return i([R,e.toBuffer()],t)}export{R as LOCK_LIQUIDITY_SEED,ie as getCpLockPda,re as getCpmmPdaAmmConfigId,T as getCpmmPdaPoolId,oe as getCreatePoolKeys,v as getPdaLpMint,E as getPdaObservationId,I as getPdaPoolAuthority,g as getPdaVault};
//# sourceMappingURL=pda.mjs.map