@cobaltx/sdk-v2
Version:
An SDK for building applications on top of CobaltX.
2 lines • 4.57 kB
JavaScript
import{PublicKey as I}from"@solana/web3.js";import w,{isBN as B}from"bn.js";import{bits as C,BitStructure as F,blob as _,Blob as O,cstr as M,f32 as E,f32be as v,f64 as R,f64be as Q,greedy as K,Layout as U,ns64 as z,ns64be as G,nu64 as j,nu64be as Y,offset as H,s16 as J,s16be as W,s24 as X,s24be as Z,s32 as $,s32be as ee,s40 as te,s40be as ne,s48 as re,s48be as oe,s8 as se,seq as q,struct as ae,Structure as k,u16 as ue,u16be as ie,u24 as ye,u24be as pe,u32 as ce,u32be as de,u40 as Pe,u40be as me,u48 as xe,u48be as le,u8 as be,UInt as A,union as fe,Union as Le,unionLayoutDiscriminator as ge,utf8 as Se}from"@solana/buffer-layout";var m=U,S=k;var T=A;var h=q;var x=_;var P=class extends m{constructor(t,r,a){super(t,a);this.blob=x(t),this.signed=r}decode(t,r=0){let a=new w(this.blob.decode(t,r),10,"le");return this.signed?a.fromTwos(this.span*8).clone():a}encode(t,r,a=0){return typeof t=="number"&&(t=new w(t)),this.signed&&(t=t.toTwos(this.span*8)),this.blob.encode(t.toArrayLike(Buffer,"le",this.span),r,a)}};function i(s){return new T(1,s)}function e(s){return new P(8,!1,s)}function y(s){return new P(16,!1,s)}var l=class extends m{constructor(t,r,a,p){super(t.span,p);this.layout=t,this.decoder=r,this.encoder=a}decode(t,r){return this.decoder(this.layout.decode(t,r))}encode(t,r,a){return this.layout.encode(this.encoder(t),r,a)}getSpan(t,r){return this.layout.getSpan(t,r)}};function n(s){return new l(x(32),o=>new I(o),o=>o.toBuffer(),s)}var b=class extends S{decode(o,t){return super.decode(o,t)}};function u(s,o,t){return new b(s,o,t)}function f(s,o,t){let r,a=typeof o=="number"?o:B(o)?o.toNumber():new Proxy(o,{get(p,d){if(!r){let c=Reflect.get(p,"count");r=B(c)?c.toNumber():c,Reflect.set(p,"count",r)}return Reflect.get(p,d)},set(p,d,c){return d==="count"&&(r=c),Reflect.set(p,d,c)}});return h(s,a,t)}var Oe=u([i("instruction"),e("amountIn"),e("minAmountOut")]),Me=u([i("instruction"),e("maxAmountIn"),e("amountOut")]),Ee=u([i("instruction"),i("nonce")]),ve=u([i("instruction"),i("nonce"),e("startTime")]),V=u([e("status"),e("nonce"),e("maxOrder"),e("depth"),e("baseDecimal"),e("quoteDecimal"),e("state"),e("resetFlag"),e("minSize"),e("volMaxCutRatio"),e("amountWaveRatio"),e("baseLotSize"),e("quoteLotSize"),e("minPriceMultiplier"),e("maxPriceMultiplier"),e("systemDecimalValue"),e("minSeparateNumerator"),e("minSeparateDenominator"),e("tradeFeeNumerator"),e("tradeFeeDenominator"),e("pnlNumerator"),e("pnlDenominator"),e("swapFeeNumerator"),e("swapFeeDenominator"),e("baseNeedTakePnl"),e("quoteNeedTakePnl"),e("quoteTotalPnl"),e("baseTotalPnl"),e("poolOpenTime"),e("punishPcAmount"),e("punishCoinAmount"),e("orderbookToInitTime"),y("swapBaseInAmount"),y("swapQuoteOutAmount"),e("swapBase2QuoteFee"),y("swapQuoteInAmount"),y("swapBaseOutAmount"),e("swapQuote2BaseFee"),n("baseVault"),n("quoteVault"),n("baseMint"),n("quoteMint"),n("lpMint"),n("openOrders"),n("marketId"),n("marketProgramId"),n("targetOrders"),n("withdrawQueue"),n("lpVault"),n("owner"),e("lpReserve"),f(e(),3,"padding")]),D=u([e("accountType"),e("status"),e("nonce"),e("maxOrder"),e("depth"),e("baseDecimal"),e("quoteDecimal"),e("state"),e("resetFlag"),e("minSize"),e("volMaxCutRatio"),e("amountWaveRatio"),e("baseLotSize"),e("quoteLotSize"),e("minPriceMultiplier"),e("maxPriceMultiplier"),e("systemDecimalsValue"),e("abortTradeFactor"),e("priceTickMultiplier"),e("priceTick"),e("minSeparateNumerator"),e("minSeparateDenominator"),e("tradeFeeNumerator"),e("tradeFeeDenominator"),e("pnlNumerator"),e("pnlDenominator"),e("swapFeeNumerator"),e("swapFeeDenominator"),e("baseNeedTakePnl"),e("quoteNeedTakePnl"),e("quoteTotalPnl"),e("baseTotalPnl"),e("poolOpenTime"),e("punishPcAmount"),e("punishCoinAmount"),e("orderbookToInitTime"),y("swapBaseInAmount"),y("swapQuoteOutAmount"),y("swapQuoteInAmount"),y("swapBaseOutAmount"),e("swapQuote2BaseFee"),e("swapBase2QuoteFee"),n("baseVault"),n("quoteVault"),n("baseMint"),n("quoteMint"),n("lpMint"),n("modelDataAccount"),n("openOrders"),n("marketId"),n("marketProgramId"),n("targetOrders"),n("owner"),f(e(),64,"padding")]),Re=u([i("instruction"),e("baseAmountIn"),e("quoteAmountIn"),e("fixedSide"),e("otherAmountMin")]),Qe=u([i("instruction"),e("lpAmount"),e("baseAmountMin"),e("quoteAmountMin")]),Ke={4:V,5:D},ze=u([e("fee")]);export{Ke as LIQUIDITY_VERSION_TO_STATE_LAYOUT,Re as addLiquidityLayout,ze as createPoolFeeLayout,Ee as createPoolV4Layout,Oe as fixedSwapInLayout,Me as fixedSwapOutLayout,ve as initPoolLayout,V as liquidityStateV4Layout,D as liquidityStateV5Layout,Qe as removeLiquidityLayout};
//# sourceMappingURL=layout.mjs.map