goosefx-amm-sdk
Version:
SDK for the GooseFx AMM
2 lines • 2.52 kB
JavaScript
import{PublicKey as P,ComputeBudgetProgram as D,Transaction as W,TransactionMessage as V,Keypair as N,VersionedTransaction as $}from"@solana/web3.js";import{TOKEN_PROGRAM_ID as F}from"@solana/spl-token";import{get as c,set as b}from"lodash";var s=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 n=e.map(r=>typeof r=="object"?JSON.stringify(r):r).join(", ");throw new Error(n)}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}},l={},d={};function f(t){let e=c(l,t);if(!e){let n=c(d,t);e=new s({name:t,logLevel:n}),b(l,t,e)}return e}var Q=f("Gfx_txUtil");function i(t,e){let[n,r]=P.findProgramAddressSync(t,e);return{publicKey:n,nonce:r}}var L=Buffer.from("vault_and_lp_mint_auth_seed","utf8"),K=Buffer.from("amm_config","utf8"),B=Buffer.from("pool","utf8"),w=Buffer.from("pool_lp_mint","utf8"),C=Buffer.from("pool_vault","utf8"),S=Buffer.from("observation","utf8"),T=Buffer.from("user-pool-liquidity","utf8"),E=Buffer.from("partner_infos","utf8");function v(t){return i([L],t)}function ee(t,e){return i([K,x(e)],t)}function I(t,e,n,r){return i([B,e.toBuffer(),n.toBuffer(),r.toBuffer()],t)}function te(t,e){return i([w,e.toBuffer()],t)}function g(t,e,n){return i([C,e.toBuffer(),n.toBuffer()],t)}function A(t,e){return i([S,e.toBuffer()],t)}function ne(t,e,n){return i([T,e.toBuffer(),n.toBuffer()],t)}function re(t,e){return i([E,e.toBuffer()],t)}function x(t){let e=new ArrayBuffer(2);return new DataView(e).setUint16(0,t,!1),new Uint8Array(e)}function ie({programId:t,configId:e,mintA:n,mintB:r}){let m=v(t).publicKey,o=I(t,e,n,r).publicKey,p=g(t,o,n).publicKey,y=g(t,o,r).publicKey,h=A(t,o).publicKey;return{poolId:o,configId:e,authority:m,vaultA:p,vaultB:y,observationId:h}}export{ee as getCpmmPdaAmmConfigId,I as getCpmmPdaPoolId,ie as getCreatePoolKeys,te as getPdaLpMint,A as getPdaObservationId,v as getPdaPoolAuthority,re as getPdaPoolPartners,ne as getPdaUserLiquidity,g as getPdaVault};
//# sourceMappingURL=pda.mjs.map