@raydium-io/raydium-sdk-v2
Version:
An SDK for building applications on top of Raydium.
2 lines • 2.77 kB
JavaScript
var l=Object.defineProperty;var S=Object.getOwnPropertyDescriptor;var A=Object.getOwnPropertyNames;var B=Object.prototype.hasOwnProperty;var V=(t,e)=>{for(var r in e)l(t,r,{get:e[r],enumerable:!0})},K=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of A(e))!B.call(t,n)&&n!==r&&l(t,n,{get:()=>e[n],enumerable:!(i=S(e,n))||i.enumerable});return t};var I=t=>K(l({},"__esModule",{value:!0}),t);var W={};V(W,{getCpmmPdaAmmConfigId:()=>F,getCpmmPdaPoolId:()=>y,getCreatePoolKeys:()=>M,getPdaLpMint:()=>h,getPdaObservationId:()=>b,getPdaPoolAuthority:()=>d,getPdaVault:()=>f});module.exports=I(W);var o=require("@solana/web3.js"),v=require("@solana/spl-token");var u=require("lodash");var c=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}},g={},T={};function p(t){let e=(0,u.get)(g,t);if(!e){let r=(0,u.get)(T,t);e=new c({name:t,logLevel:r}),(0,u.set)(g,t,e)}return e}var Z=p("Raydium_txUtil");function a(t,e){let[r,i]=o.PublicKey.findProgramAddressSync(t,e);return{publicKey:r,nonce:i}}var E=Buffer.from("vault_and_lp_mint_auth_seed","utf8"),R=Buffer.from("amm_config","utf8"),x=Buffer.from("pool","utf8"),_=Buffer.from("pool_lp_mint","utf8"),O=Buffer.from("pool_vault","utf8"),k=Buffer.from("observation","utf8");function d(t){return a([E],t)}function F(t,e){return a([R,D(e)],t)}function y(t,e,r,i){return a([x,e.toBuffer(),r.toBuffer(),i.toBuffer()],t)}function h(t,e){return a([_,e.toBuffer()],t)}function f(t,e,r){return a([O,e.toBuffer(),r.toBuffer()],t)}function b(t,e){return a([k,e.toBuffer()],t)}function D(t){let e=new ArrayBuffer(2);return new DataView(e).setUint16(0,t,!1),new Uint8Array(e)}function M({programId:t,configId:e,mintA:r,mintB:i}){let n=d(t).publicKey,s=y(t,e,r,i).publicKey,P=h(t,s).publicKey,C=f(t,s,r).publicKey,w=f(t,s,i).publicKey,L=b(t,s).publicKey;return{poolId:s,configId:e,authority:n,lpMint:P,vaultA:C,vaultB:w,observationId:L}}0&&(module.exports={getCpmmPdaAmmConfigId,getCpmmPdaPoolId,getCreatePoolKeys,getPdaLpMint,getPdaObservationId,getPdaPoolAuthority,getPdaVault});
//# sourceMappingURL=pda.js.map