UNPKG

@sega-so/sega-sdk

Version:

An SDK for building applications on top of SEGA.

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