@raydium-io/raydium-sdk-v2 0.1.73-alpha → 0.1.74-alpha

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (106) hide show
  1. package/lib/api/api.d.ts +1 -1
  2. package/lib/api/index.d.ts +1 -1
  3. package/lib/api/type.d.ts +1 -1
  4. package/lib/common/accountInfo.d.ts +1 -1
  5. package/lib/common/bignumber.d.ts +1 -1
  6. package/lib/common/constant.d.ts +1 -1
  7. package/lib/common/fractionUtil.d.ts +1 -1
  8. package/lib/common/index.d.ts +1 -1
  9. package/lib/common/transfer.d.ts +1 -1
  10. package/lib/common/txTool/txTool.d.ts +1 -1
  11. package/lib/common/txTool/txUtils.d.ts +1 -1
  12. package/lib/common/utility.d.ts +1 -1
  13. package/lib/index.d.ts +3 -3
  14. package/lib/index.js +1 -1
  15. package/lib/index.js.map +1 -1
  16. package/lib/index.mjs +1 -1
  17. package/lib/index.mjs.map +1 -1
  18. package/lib/module/amount.d.ts +1 -1
  19. package/lib/module/fraction.d.ts +1 -1
  20. package/lib/module/index.d.ts +1 -1
  21. package/lib/module/percent.d.ts +1 -1
  22. package/lib/module/price.d.ts +1 -1
  23. package/lib/raydium/account/account.d.ts +3 -3
  24. package/lib/raydium/account/index.d.ts +1 -1
  25. package/lib/raydium/account/instruction.d.ts +1 -1
  26. package/lib/raydium/account/types.d.ts +1 -1
  27. package/lib/raydium/account/util.d.ts +1 -1
  28. package/lib/raydium/clmm/clmm.d.ts +3 -3
  29. package/lib/raydium/clmm/index.d.ts +3 -3
  30. package/lib/raydium/clmm/instrument.d.ts +2 -2
  31. package/lib/raydium/clmm/layout.d.ts +1 -1
  32. package/lib/raydium/clmm/type.d.ts +2 -2
  33. package/lib/raydium/clmm/utils/math.d.ts +2 -2
  34. package/lib/raydium/clmm/utils/pool.d.ts +2 -2
  35. package/lib/raydium/clmm/utils/position.d.ts +2 -2
  36. package/lib/raydium/clmm/utils/tick.d.ts +2 -2
  37. package/lib/raydium/clmm/utils/tickQuery.d.ts +2 -2
  38. package/lib/raydium/clmm/utils/tickarrayBitmap.d.ts +2 -2
  39. package/lib/raydium/cpmm/cpmm.d.ts +3 -3
  40. package/lib/raydium/cpmm/curve/calculator.d.ts +1 -1
  41. package/lib/raydium/cpmm/curve/constantProduct.d.ts +1 -1
  42. package/lib/raydium/cpmm/index.d.ts +1 -1
  43. package/lib/raydium/cpmm/instruction.d.ts +1 -1
  44. package/lib/raydium/cpmm/layout.d.ts +1 -1
  45. package/lib/raydium/cpmm/type.d.ts +1 -1
  46. package/lib/raydium/farm/config.d.ts +1 -1
  47. package/lib/raydium/farm/farm.d.ts +3 -3
  48. package/lib/raydium/farm/index.d.ts +1 -1
  49. package/lib/raydium/farm/instruction.d.ts +1 -1
  50. package/lib/raydium/farm/layout.d.ts +1 -1
  51. package/lib/raydium/farm/type.d.ts +1 -1
  52. package/lib/raydium/farm/util.d.ts +1 -1
  53. package/lib/raydium/ido/ido.d.ts +3 -3
  54. package/lib/raydium/ido/index.d.ts +3 -3
  55. package/lib/raydium/ido/instruction.d.ts +1 -1
  56. package/lib/raydium/ido/type.d.ts +1 -1
  57. package/lib/raydium/index.d.ts +3 -3
  58. package/lib/raydium/index.js +1 -1
  59. package/lib/raydium/index.js.map +1 -1
  60. package/lib/raydium/index.mjs +1 -1
  61. package/lib/raydium/index.mjs.map +1 -1
  62. package/lib/raydium/liquidity/index.d.ts +1 -1
  63. package/lib/raydium/liquidity/instruction.d.ts +1 -1
  64. package/lib/raydium/liquidity/layout.d.ts +6 -6
  65. package/lib/raydium/liquidity/liquidity.d.ts +3 -3
  66. package/lib/raydium/liquidity/type.d.ts +1 -1
  67. package/lib/raydium/liquidity/utils.d.ts +1 -1
  68. package/lib/raydium/marketV2/createMarket.d.ts +3 -3
  69. package/lib/raydium/marketV2/createMarket.js +1 -1
  70. package/lib/raydium/marketV2/createMarket.js.map +1 -1
  71. package/lib/raydium/marketV2/createMarket.mjs +1 -1
  72. package/lib/raydium/marketV2/createMarket.mjs.map +1 -1
  73. package/lib/raydium/marketV2/index.d.ts +3 -3
  74. package/lib/raydium/marketV2/index.js +1 -1
  75. package/lib/raydium/marketV2/index.js.map +1 -1
  76. package/lib/raydium/marketV2/index.mjs +1 -1
  77. package/lib/raydium/marketV2/index.mjs.map +1 -1
  78. package/lib/raydium/marketV2/instrument.d.ts +1 -0
  79. package/lib/raydium/marketV2/instrument.js +1 -1
  80. package/lib/raydium/marketV2/instrument.js.map +1 -1
  81. package/lib/raydium/marketV2/instrument.mjs +1 -1
  82. package/lib/raydium/marketV2/instrument.mjs.map +1 -1
  83. package/lib/raydium/moduleBase.d.ts +3 -3
  84. package/lib/raydium/raydium.d.ts +3 -3
  85. package/lib/raydium/raydium.js +1 -1
  86. package/lib/raydium/raydium.js.map +1 -1
  87. package/lib/raydium/raydium.mjs +1 -1
  88. package/lib/raydium/raydium.mjs.map +1 -1
  89. package/lib/raydium/token/constant.d.ts +1 -1
  90. package/lib/raydium/token/index.d.ts +1 -1
  91. package/lib/raydium/token/token.d.ts +3 -3
  92. package/lib/raydium/token/type.d.ts +1 -1
  93. package/lib/raydium/token/utils.d.ts +1 -1
  94. package/lib/raydium/tradeV2/index.d.ts +2 -2
  95. package/lib/raydium/tradeV2/instrument.d.ts +2 -2
  96. package/lib/raydium/tradeV2/trade.d.ts +3 -3
  97. package/lib/raydium/tradeV2/type.d.ts +2 -2
  98. package/lib/raydium/type.d.ts +1 -1
  99. package/lib/raydium/utils1216/index.d.ts +3 -3
  100. package/lib/raydium/utils1216/utils1216.d.ts +3 -3
  101. package/lib/{raydium-94d49791.d.ts → raydium-87764c35.d.ts} +5 -4
  102. package/lib/{type-11af28b1.d.ts → type-91ebce1b.d.ts} +1 -1
  103. package/package.json +1 -1
  104. package/src/raydium/marketV2/createMarket.ts +4 -0
  105. package/src/raydium/marketV2/instrument.ts +14 -4
  106. package/lib/{api-f6d3edc7.d.ts → api-fd862469.d.ts} +5 -5
@@ -71,6 +71,7 @@ declare function makeCreateMarketInstruction({ connection, wallet, marketInfo, }
71
71
  requestQueueSpace?: number;
72
72
  eventQueueSpace?: number;
73
73
  orderbookQueueSpace?: number;
74
+ lowestFeeMarket?: boolean;
74
75
  };
75
76
  }): Promise<Transactions>;
76
77
 
@@ -1,2 +1,2 @@
1
- var G=Object.create;var m=Object.defineProperty;var Y=Object.getOwnPropertyDescriptor;var I=Object.getOwnPropertyNames,v=Object.getOwnPropertySymbols,j=Object.getPrototypeOf,D=Object.prototype.hasOwnProperty,H=Object.prototype.propertyIsEnumerable;var N=(r,t,e)=>t in r?m(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,L=(r,t)=>{for(var e in t||(t={}))D.call(t,e)&&N(r,e,t[e]);if(v)for(var e of v(t))H.call(t,e)&&N(r,e,t[e]);return r};var J=(r,t)=>{for(var e in t)m(r,e,{get:t[e],enumerable:!0})},M=(r,t,e,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of I(t))!D.call(r,s)&&s!==e&&m(r,s,{get:()=>t[s],enumerable:!(o=Y(t,s))||o.enumerable});return r};var X=(r,t,e)=>(e=r!=null?G(j(r)):{},M(t||!r||!r.__esModule?m(e,"default",{value:r,enumerable:!0}):e,r)),Z=r=>M(m({},"__esModule",{value:!0}),r);var te={};J(te,{initializeMarket:()=>z,makeCreateMarketInstruction:()=>ee});module.exports=Z(te);var a=require("@solana/web3.js"),d=require("@solana/spl-token");var i={CreateAccount:"CreateAccount",InitAccount:"InitAccount",CreateATA:"CreateATA",CloseAccount:"CloseAccount",TransferAmount:"TransferAmount",InitMint:"InitMint",MintTo:"MintTo",InitMarket:"InitMarket",Util1216OwnerClaim:"Util1216OwnerClaim",SetComputeUnitPrice:"SetComputeUnitPrice",SetComputeUnitLimit:"SetComputeUnitLimit",ClmmCreatePool:"ClmmCreatePool",ClmmOpenPosition:"ClmmOpenPosition",ClmmIncreasePosition:"ClmmIncreasePosition",ClmmDecreasePosition:"ClmmDecreasePosition",ClmmClosePosition:"ClmmClosePosition",ClmmSwapBaseIn:"ClmmSwapBaseIn",ClmmSwapBaseOut:"ClmmSwapBaseOut",ClmmInitReward:"ClmmInitReward",ClmmSetReward:"ClmmSetReward",ClmmCollectReward:"ClmmCollectReward",ClmmLockPosition:"ClmmLockPosition",ClmmHarvestLockPosition:"ClmmHarvestLockPosition",AmmV4Swap:"AmmV4Swap",AmmV4AddLiquidity:"AmmV4AddLiquidity",AmmV4RemoveLiquidity:"AmmV4RemoveLiquidity",AmmV4SimulatePoolInfo:"AmmV4SimulatePoolInfo",AmmV4SwapBaseIn:"AmmV4SwapBaseIn",AmmV4SwapBaseOut:"AmmV4SwapBaseOut",AmmV4CreatePool:"AmmV4CreatePool",AmmV4InitPool:"AmmV4InitPool",AmmV5AddLiquidity:"AmmV5AddLiquidity",AmmV5RemoveLiquidity:"AmmV5RemoveLiquidity",AmmV5SimulatePoolInfo:"AmmV5SimulatePoolInfo",AmmV5SwapBaseIn:"AmmV5SwapBaseIn",AmmV5SwapBaseOut:"AmmV5SwapBaseOut",RouteSwap:"RouteSwap",RouteSwap1:"RouteSwap1",RouteSwap2:"RouteSwap2",FarmV3Deposit:"FarmV3Deposit",FarmV3Withdraw:"FarmV3Withdraw",FarmV3CreateLedger:"FarmV3CreateLedger",FarmV5Deposit:"FarmV5Deposit",FarmV5Withdraw:"FarmV5Withdraw",FarmV5CreateLedger:"FarmV5CreateLedger",FarmV6Deposit:"FarmV6Deposit",FarmV6Withdraw:"FarmV6Withdraw",FarmV6Create:"FarmV6Create",FarmV6Restart:"FarmV6Restart",FarmV6CreatorAddReward:"FarmV6CreatorAddReward",FarmV6CreatorWithdraw:"FarmV6CreatorWithdraw",CpmmCreatePool:"CpmmCreatePool",CpmmAddLiquidity:"CpmmAddLiquidity",CpmmWithdrawLiquidity:"CpmmWithdrawLiquidity",CpmmSwapBaseIn:"CpmmSwapBaseIn",CpmmSwapBaseOut:"CpmmSwapBaseOut",CpmmLockLp:"CpmmLockLp",CpmmCollectLockFee:"CpmmCollectLockFee"};var W=require("@solana/web3.js"),l=X(require("bn.js"));var n=require("@solana/buffer-layout"),P=n.Layout,E=n.Structure;var S=n.UInt;var Q=n.u16;var f=n.u32;var y=n.blob;var h=n.bits;var T=class extends P{constructor(e,o,s){super(e,s);this.blob=y(e),this.signed=o}decode(e,o=0){let s=new l.default(this.blob.decode(e,o),10,"le");return this.signed?s.fromTwos(this.span*8).clone():s}encode(e,o,s=0){return typeof e=="number"&&(e=new l.default(e)),this.signed&&(e=e.toTwos(this.span*8)),this.blob.encode(e.toArrayLike(Buffer,"le",this.span),o,s)}},x=class extends P{constructor(e){super(8,e);this._lower=h(f(),!1),this._upper=h(f(),!1)}addBoolean(e){this._lower.fields.length<32?this._lower.addBoolean(e):this._upper.addBoolean(e)}decode(e,o=0){let s=this._lower.decode(e,o),p=this._upper.decode(e,o+this._lower.span);return L(L({},s),p)}encode(e,o,s=0){return this._lower.encode(e,o,s)+this._upper.encode(e,o,s+this._lower.span)}};function k(r){return new S(1,r)}function O(r){return new S(4,r)}function u(r){return new T(8,!1,r)}var w=class extends P{constructor(e,o,s,p){super(e.span,p);this.layout=e,this.decoder=o,this.encoder=s}decode(e,o){return this.decoder(this.layout.decode(e,o))}encode(e,o,s){return this.layout.encode(this.encoder(e),o,s)}getSpan(e,o){return this.layout.getSpan(e,o)}};function c(r){return new w(y(32),t=>new W.PublicKey(t),t=>t.toBuffer(),r)}var B=class extends E{decode(t,e){return super.decode(t,e)}};function g(r,t,e){return new B(r,t,e)}function $(r="accountFlags"){let t=new x(r);return t.addBoolean("initialized"),t.addBoolean("market"),t.addBoolean("openOrders"),t.addBoolean("requestQueue"),t.addBoolean("eventQueue"),t.addBoolean("bids"),t.addBoolean("asks"),t}var A=g([y(5),$("accountFlags"),c("ownAddress"),u("vaultSignerNonce"),c("baseMint"),c("quoteMint"),c("baseVault"),u("baseDepositsTotal"),u("baseFeesAccrued"),c("quoteVault"),u("quoteDepositsTotal"),u("quoteFeesAccrued"),u("quoteDustThreshold"),c("requestQueue"),c("eventQueue"),c("bids"),c("asks"),u("baseLotSize"),u("quoteLotSize"),u("feeRateBps"),u("referrerRebatesAccrued"),y(7)]);function z({programId:r,marketInfo:t}){let e=g([k("version"),O("instruction"),u("baseLotSize"),u("quoteLotSize"),Q("feeRateBps"),u("vaultSignerNonce"),u("quoteDustThreshold")]),o=[{pubkey:t.id,isSigner:!1,isWritable:!0},{pubkey:t.requestQueue,isSigner:!1,isWritable:!0},{pubkey:t.eventQueue,isSigner:!1,isWritable:!0},{pubkey:t.bids,isSigner:!1,isWritable:!0},{pubkey:t.asks,isSigner:!1,isWritable:!0},{pubkey:t.baseVault,isSigner:!1,isWritable:!0},{pubkey:t.quoteVault,isSigner:!1,isWritable:!0},{pubkey:t.baseMint,isSigner:!1,isWritable:!1},{pubkey:t.quoteMint,isSigner:!1,isWritable:!1},{pubkey:t.authority?t.quoteMint:a.SYSVAR_RENT_PUBKEY,isSigner:!1,isWritable:!1}].concat(t.authority?{pubkey:t.authority,isSigner:!1,isWritable:!1}:[]).concat(t.authority&&t.pruneAuthority?{pubkey:t.pruneAuthority,isSigner:!1,isWritable:!1}:[]),s=Buffer.alloc(e.span);return e.encode({version:0,instruction:0,baseLotSize:t.baseLotSize,quoteLotSize:t.quoteLotSize,feeRateBps:t.feeRateBps,vaultSignerNonce:t.vaultSignerNonce,quoteDustThreshold:t.quoteDustThreshold},s),new a.TransactionInstruction({keys:o,programId:r,data:s})}async function ee({connection:r,wallet:t,marketInfo:e}){var C,V,_,q,K,U,R,F;let o=new a.Transaction,s=await r.getMinimumBalanceForRentExemption(165);o.add(a.SystemProgram.createAccountWithSeed({fromPubkey:t,basePubkey:t,seed:e.baseVault.seed,newAccountPubkey:e.baseVault.publicKey,lamports:s,space:165,programId:d.TOKEN_PROGRAM_ID}),a.SystemProgram.createAccountWithSeed({fromPubkey:t,basePubkey:t,seed:e.quoteVault.seed,newAccountPubkey:e.quoteVault.publicKey,lamports:s,space:165,programId:d.TOKEN_PROGRAM_ID}),(0,d.createInitializeAccountInstruction)(e.baseVault.publicKey,e.baseMint,e.vaultOwner),(0,d.createInitializeAccountInstruction)(e.quoteVault.publicKey,e.quoteMint,e.vaultOwner));let p=new a.Transaction;return p.add(a.SystemProgram.createAccountWithSeed({fromPubkey:t,basePubkey:t,seed:e.id.seed,newAccountPubkey:e.id.publicKey,lamports:await r.getMinimumBalanceForRentExemption(A.span),space:A.span,programId:e.programId}),a.SystemProgram.createAccountWithSeed({fromPubkey:t,basePubkey:t,seed:e.requestQueue.seed,newAccountPubkey:e.requestQueue.publicKey,lamports:await r.getMinimumBalanceForRentExemption((C=e.requestQueueSpace)!=null?C:5120+12),space:(V=e.requestQueueSpace)!=null?V:5120+12,programId:e.programId}),a.SystemProgram.createAccountWithSeed({fromPubkey:t,basePubkey:t,seed:e.eventQueue.seed,newAccountPubkey:e.eventQueue.publicKey,lamports:await r.getMinimumBalanceForRentExemption((_=e.eventQueueSpace)!=null?_:262144+12),space:(q=e.eventQueueSpace)!=null?q:262144+12,programId:e.programId}),a.SystemProgram.createAccountWithSeed({fromPubkey:t,basePubkey:t,seed:e.bids.seed,newAccountPubkey:e.bids.publicKey,lamports:await r.getMinimumBalanceForRentExemption((K=e.orderbookQueueSpace)!=null?K:65536+12),space:(U=e.orderbookQueueSpace)!=null?U:65536+12,programId:e.programId}),a.SystemProgram.createAccountWithSeed({fromPubkey:t,basePubkey:t,seed:e.asks.seed,newAccountPubkey:e.asks.publicKey,lamports:await r.getMinimumBalanceForRentExemption((R=e.orderbookQueueSpace)!=null?R:65536+12),space:(F=e.orderbookQueueSpace)!=null?F:65536+12,programId:e.programId}),z({programId:e.programId,marketInfo:{id:e.id.publicKey,requestQueue:e.requestQueue.publicKey,eventQueue:e.eventQueue.publicKey,bids:e.bids.publicKey,asks:e.asks.publicKey,baseVault:e.baseVault.publicKey,quoteVault:e.quoteVault.publicKey,baseMint:e.baseMint,quoteMint:e.quoteMint,baseLotSize:e.baseLotSize,quoteLotSize:e.quoteLotSize,feeRateBps:e.feeRateBps,vaultSignerNonce:e.vaultSignerNonce,quoteDustThreshold:e.quoteDustThreshold}})),[{transaction:o,signer:[],instructionTypes:[i.CreateAccount,i.CreateAccount,i.InitAccount,i.InitAccount]},{transaction:p,signer:[],instructionTypes:[i.CreateAccount,i.CreateAccount,i.CreateAccount,i.CreateAccount,i.CreateAccount,i.InitMarket]}]}0&&(module.exports={initializeMarket,makeCreateMarketInstruction});
1
+ var G=Object.create;var b=Object.defineProperty;var Y=Object.getOwnPropertyDescriptor;var j=Object.getOwnPropertyNames,v=Object.getOwnPropertySymbols,H=Object.getPrototypeOf,N=Object.prototype.hasOwnProperty,J=Object.prototype.propertyIsEnumerable;var M=(r,t,e)=>t in r?b(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,L=(r,t)=>{for(var e in t||(t={}))N.call(t,e)&&M(r,e,t[e]);if(v)for(var e of v(t))J.call(t,e)&&M(r,e,t[e]);return r};var X=(r,t)=>{for(var e in t)b(r,e,{get:t[e],enumerable:!0})},D=(r,t,e,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of j(t))!N.call(r,s)&&s!==e&&b(r,s,{get:()=>t[s],enumerable:!(o=Y(t,s))||o.enumerable});return r};var Z=(r,t,e)=>(e=r!=null?G(H(r)):{},D(t||!r||!r.__esModule?b(e,"default",{value:r,enumerable:!0}):e,r)),$=r=>D(b({},"__esModule",{value:!0}),r);var te={};X(te,{initializeMarket:()=>z,makeCreateMarketInstruction:()=>ee});module.exports=$(te);var a=require("@solana/web3.js"),d=require("@solana/spl-token");var i={CreateAccount:"CreateAccount",InitAccount:"InitAccount",CreateATA:"CreateATA",CloseAccount:"CloseAccount",TransferAmount:"TransferAmount",InitMint:"InitMint",MintTo:"MintTo",InitMarket:"InitMarket",Util1216OwnerClaim:"Util1216OwnerClaim",SetComputeUnitPrice:"SetComputeUnitPrice",SetComputeUnitLimit:"SetComputeUnitLimit",ClmmCreatePool:"ClmmCreatePool",ClmmOpenPosition:"ClmmOpenPosition",ClmmIncreasePosition:"ClmmIncreasePosition",ClmmDecreasePosition:"ClmmDecreasePosition",ClmmClosePosition:"ClmmClosePosition",ClmmSwapBaseIn:"ClmmSwapBaseIn",ClmmSwapBaseOut:"ClmmSwapBaseOut",ClmmInitReward:"ClmmInitReward",ClmmSetReward:"ClmmSetReward",ClmmCollectReward:"ClmmCollectReward",ClmmLockPosition:"ClmmLockPosition",ClmmHarvestLockPosition:"ClmmHarvestLockPosition",AmmV4Swap:"AmmV4Swap",AmmV4AddLiquidity:"AmmV4AddLiquidity",AmmV4RemoveLiquidity:"AmmV4RemoveLiquidity",AmmV4SimulatePoolInfo:"AmmV4SimulatePoolInfo",AmmV4SwapBaseIn:"AmmV4SwapBaseIn",AmmV4SwapBaseOut:"AmmV4SwapBaseOut",AmmV4CreatePool:"AmmV4CreatePool",AmmV4InitPool:"AmmV4InitPool",AmmV5AddLiquidity:"AmmV5AddLiquidity",AmmV5RemoveLiquidity:"AmmV5RemoveLiquidity",AmmV5SimulatePoolInfo:"AmmV5SimulatePoolInfo",AmmV5SwapBaseIn:"AmmV5SwapBaseIn",AmmV5SwapBaseOut:"AmmV5SwapBaseOut",RouteSwap:"RouteSwap",RouteSwap1:"RouteSwap1",RouteSwap2:"RouteSwap2",FarmV3Deposit:"FarmV3Deposit",FarmV3Withdraw:"FarmV3Withdraw",FarmV3CreateLedger:"FarmV3CreateLedger",FarmV5Deposit:"FarmV5Deposit",FarmV5Withdraw:"FarmV5Withdraw",FarmV5CreateLedger:"FarmV5CreateLedger",FarmV6Deposit:"FarmV6Deposit",FarmV6Withdraw:"FarmV6Withdraw",FarmV6Create:"FarmV6Create",FarmV6Restart:"FarmV6Restart",FarmV6CreatorAddReward:"FarmV6CreatorAddReward",FarmV6CreatorWithdraw:"FarmV6CreatorWithdraw",CpmmCreatePool:"CpmmCreatePool",CpmmAddLiquidity:"CpmmAddLiquidity",CpmmWithdrawLiquidity:"CpmmWithdrawLiquidity",CpmmSwapBaseIn:"CpmmSwapBaseIn",CpmmSwapBaseOut:"CpmmSwapBaseOut",CpmmLockLp:"CpmmLockLp",CpmmCollectLockFee:"CpmmCollectLockFee"};var W=require("@solana/web3.js"),P=Z(require("bn.js"));var n=require("@solana/buffer-layout"),m=n.Layout,E=n.Structure;var S=n.UInt;var Q=n.u16;var f=n.u32;var y=n.blob;var h=n.bits;var w=class extends m{constructor(e,o,s){super(e,s);this.blob=y(e),this.signed=o}decode(e,o=0){let s=new P.default(this.blob.decode(e,o),10,"le");return this.signed?s.fromTwos(this.span*8).clone():s}encode(e,o,s=0){return typeof e=="number"&&(e=new P.default(e)),this.signed&&(e=e.toTwos(this.span*8)),this.blob.encode(e.toArrayLike(Buffer,"le",this.span),o,s)}},x=class extends m{constructor(e){super(8,e);this._lower=h(f(),!1),this._upper=h(f(),!1)}addBoolean(e){this._lower.fields.length<32?this._lower.addBoolean(e):this._upper.addBoolean(e)}decode(e,o=0){let s=this._lower.decode(e,o),p=this._upper.decode(e,o+this._lower.span);return L(L({},s),p)}encode(e,o,s=0){return this._lower.encode(e,o,s)+this._upper.encode(e,o,s+this._lower.span)}};function k(r){return new S(1,r)}function O(r){return new S(4,r)}function u(r){return new w(8,!1,r)}var T=class extends m{constructor(e,o,s,p){super(e.span,p);this.layout=e,this.decoder=o,this.encoder=s}decode(e,o){return this.decoder(this.layout.decode(e,o))}encode(e,o,s){return this.layout.encode(this.encoder(e),o,s)}getSpan(e,o){return this.layout.getSpan(e,o)}};function c(r){return new T(y(32),t=>new W.PublicKey(t),t=>t.toBuffer(),r)}var B=class extends E{decode(t,e){return super.decode(t,e)}};function g(r,t,e){return new B(r,t,e)}function I(r="accountFlags"){let t=new x(r);return t.addBoolean("initialized"),t.addBoolean("market"),t.addBoolean("openOrders"),t.addBoolean("requestQueue"),t.addBoolean("eventQueue"),t.addBoolean("bids"),t.addBoolean("asks"),t}var A=g([y(5),I("accountFlags"),c("ownAddress"),u("vaultSignerNonce"),c("baseMint"),c("quoteMint"),c("baseVault"),u("baseDepositsTotal"),u("baseFeesAccrued"),c("quoteVault"),u("quoteDepositsTotal"),u("quoteFeesAccrued"),u("quoteDustThreshold"),c("requestQueue"),c("eventQueue"),c("bids"),c("asks"),u("baseLotSize"),u("quoteLotSize"),u("feeRateBps"),u("referrerRebatesAccrued"),y(7)]);function z({programId:r,marketInfo:t}){let e=g([k("version"),O("instruction"),u("baseLotSize"),u("quoteLotSize"),Q("feeRateBps"),u("vaultSignerNonce"),u("quoteDustThreshold")]),o=[{pubkey:t.id,isSigner:!1,isWritable:!0},{pubkey:t.requestQueue,isSigner:!1,isWritable:!0},{pubkey:t.eventQueue,isSigner:!1,isWritable:!0},{pubkey:t.bids,isSigner:!1,isWritable:!0},{pubkey:t.asks,isSigner:!1,isWritable:!0},{pubkey:t.baseVault,isSigner:!1,isWritable:!0},{pubkey:t.quoteVault,isSigner:!1,isWritable:!0},{pubkey:t.baseMint,isSigner:!1,isWritable:!1},{pubkey:t.quoteMint,isSigner:!1,isWritable:!1},{pubkey:t.authority?t.quoteMint:a.SYSVAR_RENT_PUBKEY,isSigner:!1,isWritable:!1}].concat(t.authority?{pubkey:t.authority,isSigner:!1,isWritable:!1}:[]).concat(t.authority&&t.pruneAuthority?{pubkey:t.pruneAuthority,isSigner:!1,isWritable:!1}:[]),s=Buffer.alloc(e.span);return e.encode({version:0,instruction:0,baseLotSize:t.baseLotSize,quoteLotSize:t.quoteLotSize,feeRateBps:t.feeRateBps,vaultSignerNonce:t.vaultSignerNonce,quoteDustThreshold:t.quoteDustThreshold},s),new a.TransactionInstruction({keys:o,programId:r,data:s})}async function ee({connection:r,wallet:t,marketInfo:e}){var C,V,_,q,K,U,R,F;let o=new a.Transaction,s=await r.getMinimumBalanceForRentExemption(165);o.add(a.SystemProgram.createAccountWithSeed({fromPubkey:t,basePubkey:t,seed:e.baseVault.seed,newAccountPubkey:e.baseVault.publicKey,lamports:s,space:165,programId:d.TOKEN_PROGRAM_ID}),a.SystemProgram.createAccountWithSeed({fromPubkey:t,basePubkey:t,seed:e.quoteVault.seed,newAccountPubkey:e.quoteVault.publicKey,lamports:s,space:165,programId:d.TOKEN_PROGRAM_ID}),(0,d.createInitializeAccountInstruction)(e.baseVault.publicKey,e.baseMint,e.vaultOwner),(0,d.createInitializeAccountInstruction)(e.quoteVault.publicKey,e.quoteMint,e.vaultOwner));let p=new a.Transaction;return p.add(a.SystemProgram.createAccountWithSeed({fromPubkey:t,basePubkey:t,seed:e.id.seed,newAccountPubkey:e.id.publicKey,lamports:await r.getMinimumBalanceForRentExemption(A.span),space:A.span,programId:e.programId}),a.SystemProgram.createAccountWithSeed({fromPubkey:t,basePubkey:t,seed:e.requestQueue.seed,newAccountPubkey:e.requestQueue.publicKey,lamports:e.lowestFeeMarket?6208320:await r.getMinimumBalanceForRentExemption((C=e.requestQueueSpace)!=null?C:5120+12),space:(V=e.requestQueueSpace)!=null?V:5120+12,programId:e.programId}),a.SystemProgram.createAccountWithSeed({fromPubkey:t,basePubkey:t,seed:e.eventQueue.seed,newAccountPubkey:e.eventQueue.publicKey,lamports:e.lowestFeeMarket?79594560:await r.getMinimumBalanceForRentExemption((_=e.eventQueueSpace)!=null?_:262144+12),space:(q=e.eventQueueSpace)!=null?q:262144+12,programId:e.programId}),a.SystemProgram.createAccountWithSeed({fromPubkey:t,basePubkey:t,seed:e.bids.seed,newAccountPubkey:e.bids.publicKey,lamports:e.lowestFeeMarket?101977920:await r.getMinimumBalanceForRentExemption((K=e.orderbookQueueSpace)!=null?K:65536+12),space:(U=e.orderbookQueueSpace)!=null?U:65536+12,programId:e.programId}),a.SystemProgram.createAccountWithSeed({fromPubkey:t,basePubkey:t,seed:e.asks.seed,newAccountPubkey:e.asks.publicKey,lamports:e.lowestFeeMarket?101977920:await r.getMinimumBalanceForRentExemption((R=e.orderbookQueueSpace)!=null?R:65536+12),space:(F=e.orderbookQueueSpace)!=null?F:65536+12,programId:e.programId}),z({programId:e.programId,marketInfo:{id:e.id.publicKey,requestQueue:e.requestQueue.publicKey,eventQueue:e.eventQueue.publicKey,bids:e.bids.publicKey,asks:e.asks.publicKey,baseVault:e.baseVault.publicKey,quoteVault:e.quoteVault.publicKey,baseMint:e.baseMint,quoteMint:e.quoteMint,baseLotSize:e.baseLotSize,quoteLotSize:e.quoteLotSize,feeRateBps:e.feeRateBps,vaultSignerNonce:e.vaultSignerNonce,quoteDustThreshold:e.quoteDustThreshold}})),[{transaction:o,signer:[],instructionTypes:[i.CreateAccount,i.CreateAccount,i.InitAccount,i.InitAccount]},{transaction:p,signer:[],instructionTypes:[i.CreateAccount,i.CreateAccount,i.CreateAccount,i.CreateAccount,i.CreateAccount,i.InitMarket]}]}0&&(module.exports={initializeMarket,makeCreateMarketInstruction});
2
2
  //# sourceMappingURL=instrument.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/raydium/marketV2/instrument.ts","../../../src/common/txTool/txType.ts","../../../src/marshmallow/index.ts","../../../src/marshmallow/buffer-layout.ts","../../../src/raydium/marketV2/layout.ts"],"sourcesContent":["import {\n Connection,\n Keypair,\n PublicKey,\n SystemProgram,\n SYSVAR_RENT_PUBKEY,\n Transaction,\n TransactionInstruction,\n} from \"@solana/web3.js\";\nimport BN from \"bn.js\";\nimport { createInitializeAccountInstruction, TOKEN_PROGRAM_ID } from \"@solana/spl-token\";\nimport { InstructionType } from \"@/common/txTool/txType\";\nimport { struct, u16, u32, u64, u8 } from \"../../marshmallow\";\nimport { MARKET_STATE_LAYOUT_V2 } from \"./layout\";\n\ntype Transactions = {\n transaction: Transaction;\n signer?: Keypair[] | undefined;\n instructionTypes?: string[];\n}[];\n\nexport function initializeMarket({\n programId,\n marketInfo,\n}: {\n programId: PublicKey;\n marketInfo: {\n id: PublicKey;\n requestQueue: PublicKey;\n eventQueue: PublicKey;\n bids: PublicKey;\n asks: PublicKey;\n baseVault: PublicKey;\n quoteVault: PublicKey;\n baseMint: PublicKey;\n quoteMint: PublicKey;\n authority?: PublicKey;\n pruneAuthority?: PublicKey;\n\n baseLotSize: BN;\n quoteLotSize: BN;\n feeRateBps: number;\n vaultSignerNonce: BN;\n quoteDustThreshold: BN;\n };\n}): TransactionInstruction {\n const dataLayout = struct([\n u8(\"version\"),\n u32(\"instruction\"),\n u64(\"baseLotSize\"),\n u64(\"quoteLotSize\"),\n u16(\"feeRateBps\"),\n u64(\"vaultSignerNonce\"),\n u64(\"quoteDustThreshold\"),\n ]);\n\n const keys = [\n { pubkey: marketInfo.id, isSigner: false, isWritable: true },\n { pubkey: marketInfo.requestQueue, isSigner: false, isWritable: true },\n { pubkey: marketInfo.eventQueue, isSigner: false, isWritable: true },\n { pubkey: marketInfo.bids, isSigner: false, isWritable: true },\n { pubkey: marketInfo.asks, isSigner: false, isWritable: true },\n { pubkey: marketInfo.baseVault, isSigner: false, isWritable: true },\n { pubkey: marketInfo.quoteVault, isSigner: false, isWritable: true },\n { pubkey: marketInfo.baseMint, isSigner: false, isWritable: false },\n { pubkey: marketInfo.quoteMint, isSigner: false, isWritable: false },\n // Use a dummy address if using the new dex upgrade to save tx space.\n {\n pubkey: marketInfo.authority ? marketInfo.quoteMint : SYSVAR_RENT_PUBKEY,\n isSigner: false,\n isWritable: false,\n },\n ]\n .concat(marketInfo.authority ? { pubkey: marketInfo.authority, isSigner: false, isWritable: false } : [])\n .concat(\n marketInfo.authority && marketInfo.pruneAuthority\n ? { pubkey: marketInfo.pruneAuthority, isSigner: false, isWritable: false }\n : [],\n );\n\n const data = Buffer.alloc(dataLayout.span);\n dataLayout.encode(\n {\n version: 0,\n instruction: 0,\n baseLotSize: marketInfo.baseLotSize,\n quoteLotSize: marketInfo.quoteLotSize,\n feeRateBps: marketInfo.feeRateBps,\n vaultSignerNonce: marketInfo.vaultSignerNonce,\n quoteDustThreshold: marketInfo.quoteDustThreshold,\n },\n data,\n );\n\n return new TransactionInstruction({\n keys,\n programId,\n data,\n });\n}\n\nexport async function makeCreateMarketInstruction({\n connection,\n wallet,\n marketInfo,\n}: {\n connection: Connection;\n wallet: PublicKey;\n marketInfo: {\n programId: PublicKey;\n id: { publicKey: PublicKey; seed: string };\n baseMint: PublicKey;\n quoteMint: PublicKey;\n baseVault: { publicKey: PublicKey; seed: string };\n quoteVault: { publicKey: PublicKey; seed: string };\n vaultOwner: PublicKey;\n\n requestQueue: { publicKey: PublicKey; seed: string };\n eventQueue: { publicKey: PublicKey; seed: string };\n bids: { publicKey: PublicKey; seed: string };\n asks: { publicKey: PublicKey; seed: string };\n\n feeRateBps: number;\n vaultSignerNonce: BN;\n quoteDustThreshold: BN;\n\n baseLotSize: BN;\n quoteLotSize: BN;\n\n requestQueueSpace?: number;\n eventQueueSpace?: number;\n orderbookQueueSpace?: number;\n };\n}): Promise<Transactions> {\n const tx1 = new Transaction();\n const accountLamports = await connection.getMinimumBalanceForRentExemption(165);\n tx1.add(\n SystemProgram.createAccountWithSeed({\n fromPubkey: wallet,\n basePubkey: wallet,\n seed: marketInfo.baseVault.seed,\n newAccountPubkey: marketInfo.baseVault.publicKey,\n lamports: accountLamports,\n space: 165,\n programId: TOKEN_PROGRAM_ID,\n }),\n SystemProgram.createAccountWithSeed({\n fromPubkey: wallet,\n basePubkey: wallet,\n seed: marketInfo.quoteVault.seed,\n newAccountPubkey: marketInfo.quoteVault.publicKey,\n lamports: accountLamports,\n space: 165,\n programId: TOKEN_PROGRAM_ID,\n }),\n createInitializeAccountInstruction(marketInfo.baseVault.publicKey, marketInfo.baseMint, marketInfo.vaultOwner),\n createInitializeAccountInstruction(marketInfo.quoteVault.publicKey, marketInfo.quoteMint, marketInfo.vaultOwner),\n );\n\n const tx2 = new Transaction();\n tx2.add(\n SystemProgram.createAccountWithSeed({\n fromPubkey: wallet,\n basePubkey: wallet,\n seed: marketInfo.id.seed,\n newAccountPubkey: marketInfo.id.publicKey,\n lamports: await connection.getMinimumBalanceForRentExemption(MARKET_STATE_LAYOUT_V2.span),\n space: MARKET_STATE_LAYOUT_V2.span,\n programId: marketInfo.programId,\n }),\n SystemProgram.createAccountWithSeed({\n fromPubkey: wallet,\n basePubkey: wallet,\n seed: marketInfo.requestQueue.seed,\n newAccountPubkey: marketInfo.requestQueue.publicKey,\n lamports: await connection.getMinimumBalanceForRentExemption(marketInfo.requestQueueSpace ?? 5120 + 12),\n space: marketInfo.requestQueueSpace ?? 5120 + 12,\n programId: marketInfo.programId,\n }),\n SystemProgram.createAccountWithSeed({\n fromPubkey: wallet,\n basePubkey: wallet,\n seed: marketInfo.eventQueue.seed,\n newAccountPubkey: marketInfo.eventQueue.publicKey,\n lamports: await connection.getMinimumBalanceForRentExemption(marketInfo.eventQueueSpace ?? 262144 + 12),\n space: marketInfo.eventQueueSpace ?? 262144 + 12,\n programId: marketInfo.programId,\n }),\n SystemProgram.createAccountWithSeed({\n fromPubkey: wallet,\n basePubkey: wallet,\n seed: marketInfo.bids.seed,\n newAccountPubkey: marketInfo.bids.publicKey,\n lamports: await connection.getMinimumBalanceForRentExemption(marketInfo.orderbookQueueSpace ?? 65536 + 12),\n space: marketInfo.orderbookQueueSpace ?? 65536 + 12,\n programId: marketInfo.programId,\n }),\n SystemProgram.createAccountWithSeed({\n fromPubkey: wallet,\n basePubkey: wallet,\n seed: marketInfo.asks.seed,\n newAccountPubkey: marketInfo.asks.publicKey,\n lamports: await connection.getMinimumBalanceForRentExemption(marketInfo.orderbookQueueSpace ?? 65536 + 12),\n space: marketInfo.orderbookQueueSpace ?? 65536 + 12,\n programId: marketInfo.programId,\n }),\n initializeMarket({\n programId: marketInfo.programId,\n marketInfo: {\n id: marketInfo.id.publicKey,\n requestQueue: marketInfo.requestQueue.publicKey,\n eventQueue: marketInfo.eventQueue.publicKey,\n bids: marketInfo.bids.publicKey,\n asks: marketInfo.asks.publicKey,\n baseVault: marketInfo.baseVault.publicKey,\n quoteVault: marketInfo.quoteVault.publicKey,\n baseMint: marketInfo.baseMint,\n quoteMint: marketInfo.quoteMint,\n\n baseLotSize: marketInfo.baseLotSize,\n quoteLotSize: marketInfo.quoteLotSize,\n feeRateBps: marketInfo.feeRateBps,\n vaultSignerNonce: marketInfo.vaultSignerNonce,\n quoteDustThreshold: marketInfo.quoteDustThreshold,\n },\n }),\n );\n\n return [\n {\n transaction: tx1,\n signer: [],\n instructionTypes: [\n InstructionType.CreateAccount,\n InstructionType.CreateAccount,\n InstructionType.InitAccount,\n InstructionType.InitAccount,\n ],\n },\n {\n transaction: tx2,\n signer: [],\n instructionTypes: [\n InstructionType.CreateAccount,\n InstructionType.CreateAccount,\n InstructionType.CreateAccount,\n InstructionType.CreateAccount,\n InstructionType.CreateAccount,\n InstructionType.InitMarket,\n ],\n },\n ];\n}\n","export enum TxVersion {\n \"V0\",\n \"LEGACY\",\n}\n\nexport const InstructionType = {\n CreateAccount: \"CreateAccount\",\n InitAccount: \"InitAccount\",\n CreateATA: \"CreateATA\",\n CloseAccount: \"CloseAccount\",\n TransferAmount: \"TransferAmount\",\n InitMint: \"InitMint\",\n MintTo: \"MintTo\",\n\n InitMarket: \"InitMarket\", // create market main ins\n Util1216OwnerClaim: \"Util1216OwnerClaim\", // owner claim token ins\n\n SetComputeUnitPrice: \"SetComputeUnitPrice\",\n SetComputeUnitLimit: \"SetComputeUnitLimit\",\n\n // CLMM\n ClmmCreatePool: \"ClmmCreatePool\",\n ClmmOpenPosition: \"ClmmOpenPosition\",\n ClmmIncreasePosition: \"ClmmIncreasePosition\",\n ClmmDecreasePosition: \"ClmmDecreasePosition\",\n ClmmClosePosition: \"ClmmClosePosition\",\n ClmmSwapBaseIn: \"ClmmSwapBaseIn\",\n ClmmSwapBaseOut: \"ClmmSwapBaseOut\",\n ClmmInitReward: \"ClmmInitReward\",\n ClmmSetReward: \"ClmmSetReward\",\n ClmmCollectReward: \"ClmmCollectReward\",\n ClmmLockPosition: \"ClmmLockPosition\",\n ClmmHarvestLockPosition: \"ClmmHarvestLockPosition\",\n\n AmmV4Swap: \"AmmV4Swap\",\n AmmV4AddLiquidity: \"AmmV4AddLiquidity\",\n AmmV4RemoveLiquidity: \"AmmV4RemoveLiquidity\",\n AmmV4SimulatePoolInfo: \"AmmV4SimulatePoolInfo\",\n AmmV4SwapBaseIn: \"AmmV4SwapBaseIn\",\n AmmV4SwapBaseOut: \"AmmV4SwapBaseOut\",\n AmmV4CreatePool: \"AmmV4CreatePool\",\n AmmV4InitPool: \"AmmV4InitPool\",\n\n AmmV5AddLiquidity: \"AmmV5AddLiquidity\",\n AmmV5RemoveLiquidity: \"AmmV5RemoveLiquidity\",\n AmmV5SimulatePoolInfo: \"AmmV5SimulatePoolInfo\",\n AmmV5SwapBaseIn: \"AmmV5SwapBaseIn\",\n AmmV5SwapBaseOut: \"AmmV5SwapBaseOut\",\n\n RouteSwap: \"RouteSwap\",\n RouteSwap1: \"RouteSwap1\",\n RouteSwap2: \"RouteSwap2\",\n\n FarmV3Deposit: \"FarmV3Deposit\",\n FarmV3Withdraw: \"FarmV3Withdraw\",\n FarmV3CreateLedger: \"FarmV3CreateLedger\",\n\n FarmV5Deposit: \"FarmV5Deposit\",\n FarmV5Withdraw: \"FarmV5Withdraw\",\n FarmV5CreateLedger: \"FarmV5CreateLedger\",\n\n FarmV6Deposit: \"FarmV6Deposit\",\n FarmV6Withdraw: \"FarmV6Withdraw\",\n FarmV6Create: \"FarmV6Create\",\n FarmV6Restart: \"FarmV6Restart\",\n FarmV6CreatorAddReward: \"FarmV6CreatorAddReward\",\n FarmV6CreatorWithdraw: \"FarmV6CreatorWithdraw\",\n\n CpmmCreatePool: \"CpmmCreatePool\",\n CpmmAddLiquidity: \"CpmmAddLiquidity\",\n CpmmWithdrawLiquidity: \"CpmmWithdrawLiquidity\",\n CpmmSwapBaseIn: \"CpmmSwapBaseIn\",\n CpmmSwapBaseOut: \"CpmmSwapBaseOut\",\n\n CpmmLockLp: \"CpmmLockLp\",\n CpmmCollectLockFee: \"CpmmCollectLockFee\",\n};\n","import { PublicKey } from \"@solana/web3.js\";\nimport BN, { isBN } from \"bn.js\";\n\nimport {\n bits,\n blob,\n Blob,\n Layout,\n offset as _offset,\n seq as _seq,\n Structure as _Structure,\n u32 as _u32,\n u8 as _u8,\n UInt,\n union as _union,\n Union as _Union,\n} from \"./buffer-layout\";\n\nexport * from \"./buffer-layout\";\nexport { blob };\n\nexport class BNLayout<P extends string = \"\"> extends Layout<BN, P> {\n blob: Layout<Buffer>;\n signed: boolean;\n\n constructor(span: number, signed: boolean, property?: P) {\n //@ts-expect-error type wrong for super()'s type different from extends, but it desn't matter\n super(span, property);\n this.blob = blob(span);\n this.signed = signed;\n }\n\n /** @override */\n decode(b: Buffer, offset = 0): BN {\n const num = new BN(this.blob.decode(b, offset), 10, \"le\");\n if (this.signed) {\n return num.fromTwos(this.span * 8).clone();\n }\n return num;\n }\n\n /** @override */\n encode(src: BN, b: Buffer, offset = 0): number {\n if (typeof src === \"number\") src = new BN(src); // src will pass a number accidently in union\n if (this.signed) {\n src = src.toTwos(this.span * 8);\n }\n return this.blob.encode(src.toArrayLike(Buffer, \"le\", this.span), b, offset);\n }\n}\n\nexport class WideBits<P extends string = \"\"> extends Layout<Record<string, boolean>, P> {\n _lower: any;\n _upper: any;\n // TODO: unknown\n constructor(property?: P) {\n //@ts-expect-error type wrong for super()'s type different from extends , but it desn't matter\n super(8, property);\n this._lower = bits(_u32(), false);\n this._upper = bits(_u32(), false);\n }\n\n addBoolean(property: string): void {\n if (this._lower.fields.length < 32) {\n this._lower.addBoolean(property);\n } else {\n this._upper.addBoolean(property);\n }\n }\n\n decode(b: Buffer, offset = 0): Record<string, boolean> {\n const lowerDecoded = this._lower.decode(b, offset);\n const upperDecoded = this._upper.decode(b, offset + this._lower.span);\n return { ...lowerDecoded, ...upperDecoded };\n }\n\n encode(src: any /* TEMP */, b: Buffer, offset = 0): any {\n return this._lower.encode(src, b, offset) + this._upper.encode(src, b, offset + this._lower.span);\n }\n}\n\nexport function u8<P extends string = \"\">(property?: P): UInt<number, P> {\n return new UInt(1, property);\n}\n\nexport function u32<P extends string = \"\">(property?: P): UInt<number, P> {\n return new UInt(4, property);\n}\n\nexport function u64<P extends string = \"\">(property?: P): BNLayout<P> {\n return new BNLayout(8, false, property);\n}\n\nexport function u128<P extends string = \"\">(property?: P): BNLayout<P> {\n return new BNLayout(16, false, property);\n}\n\nexport function i8<P extends string = \"\">(property?: P): BNLayout<P> {\n return new BNLayout(1, true, property);\n}\n\nexport function i64<P extends string = \"\">(property?: P): BNLayout<P> {\n return new BNLayout(8, true, property);\n}\n\nexport function i128<P extends string = \"\">(property?: P): BNLayout<P> {\n return new BNLayout(16, true, property);\n}\n\nexport class WrappedLayout<T, U, P extends string = \"\"> extends Layout<U, P> {\n layout: Layout<T>;\n decoder: (data: T) => U;\n encoder: (src: U) => T;\n\n constructor(layout: Layout<T>, decoder: (data: T) => U, encoder: (src: U) => T, property?: P) {\n //@ts-expect-error type wrong for super()'s type different from extends , but it desn't matter\n super(layout.span, property);\n this.layout = layout;\n this.decoder = decoder;\n this.encoder = encoder;\n }\n\n decode(b: Buffer, offset?: number): U {\n return this.decoder(this.layout.decode(b, offset));\n }\n\n encode(src: U, b: Buffer, offset?: number): number {\n return this.layout.encode(this.encoder(src), b, offset);\n }\n\n getSpan(b: Buffer, offset?: number): number {\n return this.layout.getSpan(b, offset);\n }\n}\n\nexport function publicKey<P extends string = \"\">(property?: P): Layout<PublicKey, P> {\n return new WrappedLayout(\n blob(32),\n (b: Buffer) => new PublicKey(b),\n (key: PublicKey) => key.toBuffer(),\n property,\n );\n}\n\nexport class OptionLayout<T, P> extends Layout<T | null, P> {\n layout: Layout<T>;\n discriminator: Layout<number>;\n\n constructor(layout: Layout<T>, property?: P) {\n //@ts-expect-error type wrong for super()'s type different from extends , but it desn't matter\n super(-1, property);\n this.layout = layout;\n this.discriminator = _u8();\n }\n\n encode(src: T | null, b: Buffer, offset = 0): number {\n if (src === null || src === undefined) {\n return this.discriminator.encode(0, b, offset);\n }\n this.discriminator.encode(1, b, offset);\n return this.layout.encode(src, b, offset + 1) + 1;\n }\n\n decode(b: Buffer, offset = 0): T | null {\n const discriminator = this.discriminator.decode(b, offset);\n if (discriminator === 0) {\n return null;\n } else if (discriminator === 1) {\n return this.layout.decode(b, offset + 1);\n }\n throw new Error(\"Invalid option \" + this.property);\n }\n\n getSpan(b: Buffer, offset = 0): number {\n const discriminator = this.discriminator.decode(b, offset);\n if (discriminator === 0) {\n return 1;\n } else if (discriminator === 1) {\n return this.layout.getSpan(b, offset + 1) + 1;\n }\n throw new Error(\"Invalid option \" + this.property);\n }\n}\n\nexport function option<T, P extends string = \"\">(layout: Layout<T>, property?: P): Layout<T | null, P> {\n return new OptionLayout<T, P>(layout, property);\n}\n\nexport function bool<P extends string = \"\">(property?: P): Layout<boolean, P> {\n return new WrappedLayout(_u8(), decodeBool, encodeBool, property);\n}\n\nexport function decodeBool(value: number): boolean {\n if (value === 0) {\n return false;\n } else if (value === 1) {\n return true;\n }\n throw new Error(\"Invalid bool: \" + value);\n}\n\nexport function encodeBool(value: boolean): number {\n return value ? 1 : 0;\n}\n\nexport function vec<T, P extends string = \"\">(elementLayout: Layout<T>, property?: P): Layout<T[], P> {\n const length = _u32(\"length\");\n const layout: Layout<{ values: T[] }> = struct([\n length,\n seq(elementLayout, _offset(length, -length.span), \"values\"),\n ]) as any; // Something I don't know\n return new WrappedLayout(\n layout,\n ({ values }) => values,\n (values) => ({ values }),\n property,\n );\n}\n\nexport function tagged<T, P extends string = \"\">(tag: BN, layout: Layout<T>, property?: P): Layout<T, P> {\n const wrappedLayout: Layout<{ tag: BN; data: T }> = struct([u64(\"tag\"), layout.replicate(\"data\")]) as any; // Something I don't know\n\n function decodeTag({ tag: receivedTag, data }: { tag: BN; data: T }): T {\n if (!receivedTag.eq(tag)) {\n throw new Error(\"Invalid tag, expected: \" + tag.toString(\"hex\") + \", got: \" + receivedTag.toString(\"hex\"));\n }\n return data;\n }\n\n return new WrappedLayout(wrappedLayout, decodeTag, (data) => ({ tag, data }), property);\n}\n\nexport function vecU8<P extends string = \"\">(property?: P): Layout<Buffer, P> {\n const length = _u32(\"length\");\n const layout: Layout<{ data: Buffer }> = struct([length, blob(_offset(length, -length.span), \"data\")]) as any; // Something I don't know\n return new WrappedLayout(\n layout,\n ({ data }) => data,\n (data) => ({ data }),\n property,\n );\n}\n\nexport function str<P extends string = \"\">(property?: P): Layout<string, P> {\n return new WrappedLayout(\n vecU8(),\n (data) => data.toString(\"utf-8\"),\n (s) => Buffer.from(s, \"utf-8\"),\n property,\n );\n}\n\nexport interface EnumLayout<T, P extends string = \"\"> extends Layout<T, P> {\n registry: Record<string, Layout<any>>;\n}\n\nexport function rustEnum<T, P extends string = \"\">(variants: Layout<any>[], property?: P): EnumLayout<T, P> {\n const unionLayout = _union(_u8(), property);\n variants.forEach((variant, index) => unionLayout.addVariant(index, variant, variant.property));\n return unionLayout as any; // ?why use UnionLayout? This must be a fault\n}\n\nexport function array<T, P extends string = \"\">(\n elementLayout: Layout<T>,\n length: number,\n property?: P,\n): Layout<T[], P> {\n const layout = struct([seq(elementLayout, length, \"values\")]) as any as Layout<{ values: T[] }>; // Something I don't know\n return new WrappedLayout(\n layout,\n ({ values }) => values,\n (values) => ({ values }),\n property,\n );\n}\n\nexport class Structure<T, P, D extends { [key: string]: any; }> extends _Structure<T, P, D> {\n /** @override */\n decode(b: Buffer, offset?: number): D {\n return super.decode(b, offset);\n }\n}\n\nexport function struct<T, P extends string = \"\">(\n fields: T,\n property?: P,\n decodePrefixes?: boolean,\n): T extends Layout<infer Value, infer Property>[]\n ? Structure<\n Value,\n P,\n {\n [K in Exclude<Extract<Property, string>, \"\">]: Extract<T[number], Layout<any, K>> extends Layout<infer V, any>\n ? V\n : any;\n }\n >\n : any {\n //@ts-expect-error this type is not quite satisfied the define, but, never no need to worry about.\n return new Structure(fields, property, decodePrefixes);\n}\n\nexport type GetLayoutSchemaFromStructure<T extends Structure<any, any, any>> = T extends Structure<any, any, infer S>\n ? S\n : any;\nexport type GetStructureFromLayoutSchema<S extends { [key: string]: any; }> = Structure<any, any, S>;\n\nexport class Union<Schema extends { [key: string]: any; }> extends _Union<Schema> {\n encodeInstruction(instruction: any): Buffer {\n const instructionMaxSpan = Math.max(...Object.values(this.registry).map((r) => r.span));\n const b = Buffer.alloc(instructionMaxSpan);\n return b.slice(0, this.encode(instruction, b));\n }\n\n decodeInstruction(instruction: any): Partial<Schema> {\n return this.decode(instruction);\n }\n}\nexport function union<UnionSchema extends { [key: string]: any } = any>(\n discr: any,\n defaultLayout?: any,\n property?: string,\n): Union<UnionSchema> {\n return new Union(discr, defaultLayout, property);\n}\n\nclass Zeros extends Blob {\n decode(b: Buffer, offset: number): Buffer {\n const slice = super.decode(b, offset);\n if (!slice.every((v) => v === 0)) {\n throw new Error(\"nonzero padding bytes\");\n }\n return slice;\n }\n}\n\nexport function zeros(length: number): Zeros {\n return new Zeros(length);\n}\n\nexport function seq<T, P extends string = \"\", AnotherP extends string = \"\">(\n elementLayout: Layout<T, P>,\n count: number | BN | Layout<BN | number, P>,\n property?: AnotherP,\n): Layout<T[], AnotherP> {\n let parsedCount: number;\n const superCount =\n typeof count === \"number\"\n ? count\n : isBN(count)\n ? count.toNumber()\n : new Proxy(count as unknown as Layout<number> /* pretend to be Layout<number> */, {\n get(target, property): any {\n if (!parsedCount) {\n // get count in targetLayout. note that count may be BN\n const countProperty = Reflect.get(target, \"count\");\n\n // let targetLayout's property:count be a number\n parsedCount = isBN(countProperty) ? countProperty.toNumber() : countProperty;\n\n // record the count\n Reflect.set(target, \"count\", parsedCount);\n }\n return Reflect.get(target, property);\n },\n set(target, property, value): any {\n if (property === \"count\") {\n parsedCount = value;\n }\n return Reflect.set(target, property, value);\n },\n });\n\n // @ts-expect-error force type\n return _seq(elementLayout, superCount, property);\n}\n","import {\n bits as _bits,\n BitStructure as _BitStructure,\n blob as _blob,\n Blob as _Blob,\n cstr as _cstr,\n f32 as _f32,\n f32be as _f32be,\n f64 as _f64,\n f64be as _f64be,\n greedy as _greedy,\n Layout as _Layout,\n ns64 as _ns64,\n ns64be as _ns64be,\n nu64 as _nu64,\n nu64be as _nu64be,\n offset as _offset,\n s16 as _s16,\n s16be as _s16be,\n s24 as _s24,\n s24be as _s24be,\n s32 as _s32,\n s32be as _s32be,\n s40 as _s40,\n s40be as _s40be,\n s48 as _s48,\n s48be as _s48be,\n s8 as _s8,\n seq as _seq,\n struct as _struct,\n Structure as _Structure,\n u16 as _u16,\n u16be as _u16be,\n u24 as _u24,\n u24be as _u24be,\n u32 as _u32,\n u32be as _u32be,\n u40 as _u40,\n u40be as _u40be,\n u48 as _u48,\n u48be as _u48be,\n u8 as _u8,\n UInt as _UInt,\n union as _union,\n Union as _Union,\n unionLayoutDiscriminator as _unionLayoutDiscriminator,\n utf8 as _utf8,\n} from \"@solana/buffer-layout\";\n\n//#region ------------------- Layout -------------------\nexport interface Layout<T = any, P = \"\"> {\n span: number;\n property?: P;\n decode(b: Buffer, offset?: number): T;\n encode(src: T, b: Buffer, offset?: number): number;\n getSpan(b: Buffer, offset?: number): number;\n replicate<AP extends string>(name: AP): Layout<T, AP>;\n}\nexport interface LayoutConstructor {\n new <T, P>(): Layout<T, P>; // for class extends syntex\n new <T, P>(span?: T, property?: P): Layout<T, P>;\n readonly prototype: Layout;\n}\nexport const Layout = _Layout as unknown as LayoutConstructor;\n//#endregion\n\n//#region ------------------- Structure -------------------\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nexport interface Structure<T = any, P = \"\", DecodeSchema extends { [key: string]: any } = any>\n extends Layout<DecodeSchema, P> {\n span: number;\n decode(b: Buffer, offset?: number): DecodeSchema;\n layoutFor<AP extends string>(property: AP): Layout<DecodeSchema[AP]>;\n offsetOf<AP extends string>(property: AP): number;\n}\ninterface StructureConstructor {\n new <T = any, P = \"\", DecodeSchema extends { [key: string]: any } = any>(): Structure<T, P, DecodeSchema>;\n new <T = any, P = \"\", DecodeSchema extends { [key: string]: any } = any>(\n fields: T,\n property?: P,\n decodePrefixes?: boolean,\n ): Structure<T, P, DecodeSchema>;\n}\nexport const Structure = _Structure as unknown as StructureConstructor;\n//#endregion\n\n//#region ------------------- Union -------------------\nexport interface Union<UnionSchema extends { [key: string]: any } = any> extends Layout {\n registry: object;\n decode(b: Buffer, offset?: number): Partial<UnionSchema>;\n addVariant(\n variant: number,\n layout: Structure<any, any, Partial<UnionSchema>> | Layout<any, keyof UnionSchema>,\n property?: string,\n ): any /* TEMP: code in Layout.js 1809 */;\n}\ninterface UnionConstructor {\n new <UnionSchema extends { [key: string]: any } = any>(): Union<UnionSchema>;\n new <UnionSchema extends { [key: string]: any } = any>(\n discr: Layout<any, any>,\n defaultLayout: Layout<any, any>,\n property?: string,\n ): Union<UnionSchema>;\n}\nexport const Union = _Union as unknown as UnionConstructor;\n//#endregion\n\n//#region ------------------- BitStructure -------------------\nexport type BitStructure<T = unknown /* TEMP */, P = \"\"> = Layout<T, P>;\ninterface BitStructureConstructor {\n new (...params: any[]): BitStructure;\n}\nexport const BitStructure = _BitStructure as BitStructureConstructor;\n//#endregion\n\n//#region ------------------- UInt -------------------\nexport type UInt<T = any, P = \"\"> = Layout<T, P>;\ninterface UIntConstructor {\n new <T, P>(span?: T, property?: P): UInt<T, P>;\n}\nexport const UInt = _UInt as UIntConstructor;\n//#endregion\n\n//#region ------------------- Blob -------------------\nexport type Blob<P extends string = \"\"> = Layout<Buffer, P>;\ninterface BlobConstructor {\n new (...params: ConstructorParameters<LayoutConstructor>): Blob;\n}\nexport const Blob = _Blob as unknown as BlobConstructor;\n//#endregion\n\nexport const greedy = _greedy as <P extends string = \"\">(elementSpan?: number, property?: P) => Layout<number, P>;\nexport const u8 = _u8 as <P extends string = \"\">(property?: P) => Layout<number, P>;\nexport const u16 = _u16 as <P extends string = \"\">(property?: P) => Layout<number, P>;\nexport const u24 = _u24 as <P extends string = \"\">(property?: P) => Layout<number, P>;\nexport const u32 = _u32 as <P extends string = \"\">(property?: P) => Layout<number, P>;\nexport const u40 = _u40 as <P extends string = \"\">(property?: P) => Layout<number, P>;\nexport const u48 = _u48 as <P extends string = \"\">(property?: P) => Layout<number, P>;\nexport const nu64 = _nu64 as <P extends string = \"\">(property?: P) => Layout<number, P>;\nexport const u16be = _u16be as <P extends string = \"\">(property?: P) => Layout<number, P>;\nexport const u24be = _u24be as <P extends string = \"\">(property?: P) => Layout<number, P>;\nexport const u32be = _u32be as <P extends string = \"\">(property?: P) => Layout<number, P>;\nexport const u40be = _u40be as <P extends string = \"\">(property?: P) => Layout<number, P>;\nexport const u48be = _u48be as <P extends string = \"\">(property?: P) => Layout<number, P>;\nexport const nu64be = _nu64be as <P extends string = \"\">(property?: P) => Layout<number, P>;\nexport const s8 = _s8 as <P extends string = \"\">(property?: P) => Layout<number, P>;\nexport const s16 = _s16 as <P extends string = \"\">(property?: P) => Layout<number, P>;\nexport const s24 = _s24 as <P extends string = \"\">(property?: P) => Layout<number, P>;\nexport const s32 = _s32 as <P extends string = \"\">(property?: P) => Layout<number, P>;\nexport const s40 = _s40 as <P extends string = \"\">(property?: P) => Layout<number, P>;\nexport const s48 = _s48 as <P extends string = \"\">(property?: P) => Layout<number, P>;\nexport const ns64 = _ns64 as <P extends string = \"\">(property?: P) => Layout<number, P>;\nexport const s16be = _s16be as <P extends string = \"\">(property?: P) => Layout<number, P>;\nexport const s24be = _s24be as <P extends string = \"\">(property?: P) => Layout<number, P>;\nexport const s32be = _s32be as <P extends string = \"\">(property?: P) => Layout<number, P>;\nexport const s40be = _s40be as <P extends string = \"\">(property?: P) => Layout<number, P>;\nexport const s48be = _s48be as <P extends string = \"\">(property?: P) => Layout<number, P>;\nexport const ns64be = _ns64be as <P extends string = \"\">(property?: P) => Layout<number, P>;\nexport const f32 = _f32 as <P extends string = \"\">(property?: P) => Layout<number, P>;\nexport const f32be = _f32be as <P extends string = \"\">(property?: P) => Layout<number, P>;\nexport const f64 = _f64 as <P extends string = \"\">(property?: P) => Layout<number, P>;\nexport const f64be = _f64be as <P extends string = \"\">(property?: P) => Layout<number, P>;\n\nexport const struct = _struct as <T, P extends string = \"\">(\n fields: T,\n property?: P,\n decodePrefixes?: boolean,\n) => T extends Layout<infer Value, infer Property>[]\n ? Structure<\n Value,\n P,\n {\n [K in Exclude<Extract<Property, string>, \"\">]: Extract<T[number], Layout<any, K>> extends Layout<infer V, any>\n ? V\n : any;\n }\n >\n : any;\n\nexport const seq = _seq as unknown as <T, P>(\n elementLayout: Layout<T, string>,\n count: number | Layout<number, string>,\n property?: P,\n) => Layout<T[]>;\nexport const union = _union as <UnionSchema extends { [key: string]: any } = any>(\n discr: Layout<any, any>,\n defaultLayout?: any,\n property?: string,\n) => Union<UnionSchema>;\nexport const unionLayoutDiscriminator = _unionLayoutDiscriminator as <P extends string = \"\">(\n layout: Layout<any, P>,\n property?: P,\n) => any;\nexport const blob = _blob as unknown as <P extends string = \"\">(\n length: number | Layout<number, P>,\n property?: P,\n) => Blob<P>;\nexport const cstr = _cstr as <P extends string = \"\">(property?: P) => Layout<string, P>;\nexport const utf8 = _utf8 as <P extends string = \"\">(maxSpan: number, property?: P) => Layout<string, P>;\nexport const bits = _bits as unknown as <T, P extends string = \"\">(\n word: Layout<T>,\n msb?: boolean,\n property?: P,\n) => BitStructure<T, P>; // TODO: not quite sure\nexport const offset = _offset as unknown as <T, P extends string = \"\">(\n layout: Layout<T, P>,\n offset?: number,\n property?: P,\n) => Layout<T, P>;\n\nexport type GetStructureSchema<T extends Structure> = T extends Structure<any, any, infer S> ? S : unknown;\n","import { blob, publicKey, struct, u64, WideBits } from \"../../marshmallow\";\n\nfunction accountFlagsLayout(property = \"accountFlags\"): WideBits<string> {\n const ACCOUNT_FLAGS_LAYOUT = new WideBits(property);\n ACCOUNT_FLAGS_LAYOUT.addBoolean(\"initialized\");\n ACCOUNT_FLAGS_LAYOUT.addBoolean(\"market\");\n ACCOUNT_FLAGS_LAYOUT.addBoolean(\"openOrders\");\n ACCOUNT_FLAGS_LAYOUT.addBoolean(\"requestQueue\");\n ACCOUNT_FLAGS_LAYOUT.addBoolean(\"eventQueue\");\n ACCOUNT_FLAGS_LAYOUT.addBoolean(\"bids\");\n ACCOUNT_FLAGS_LAYOUT.addBoolean(\"asks\");\n return ACCOUNT_FLAGS_LAYOUT;\n}\n\nexport const MARKET_STATE_LAYOUT_V2 = struct([\n blob(5),\n accountFlagsLayout(\"accountFlags\"),\n publicKey(\"ownAddress\"),\n u64(\"vaultSignerNonce\"),\n publicKey(\"baseMint\"),\n publicKey(\"quoteMint\"),\n publicKey(\"baseVault\"),\n u64(\"baseDepositsTotal\"),\n u64(\"baseFeesAccrued\"),\n publicKey(\"quoteVault\"),\n u64(\"quoteDepositsTotal\"),\n u64(\"quoteFeesAccrued\"),\n u64(\"quoteDustThreshold\"),\n publicKey(\"requestQueue\"),\n publicKey(\"eventQueue\"),\n publicKey(\"bids\"),\n publicKey(\"asks\"),\n u64(\"baseLotSize\"),\n u64(\"quoteLotSize\"),\n u64(\"feeRateBps\"),\n u64(\"referrerRebatesAccrued\"),\n blob(7),\n]);\n"],"mappings":"4zBAAA,iGAAA,MAQO,2BAEP,EAAqE,6BCL9D,GAAM,GAAkB,CAC7B,cAAe,gBACf,YAAa,cACb,UAAW,YACX,aAAc,eACd,eAAgB,iBAChB,SAAU,WACV,OAAQ,SAER,WAAY,aACZ,mBAAoB,qBAEpB,oBAAqB,sBACrB,oBAAqB,sBAGrB,eAAgB,iBAChB,iBAAkB,mBAClB,qBAAsB,uBACtB,qBAAsB,uBACtB,kBAAmB,oBACnB,eAAgB,iBAChB,gBAAiB,kBACjB,eAAgB,iBAChB,cAAe,gBACf,kBAAmB,oBACnB,iBAAkB,mBAClB,wBAAyB,0BAEzB,UAAW,YACX,kBAAmB,oBACnB,qBAAsB,uBACtB,sBAAuB,wBACvB,gBAAiB,kBACjB,iBAAkB,mBAClB,gBAAiB,kBACjB,cAAe,gBAEf,kBAAmB,oBACnB,qBAAsB,uBACtB,sBAAuB,wBACvB,gBAAiB,kBACjB,iBAAkB,mBAElB,UAAW,YACX,WAAY,aACZ,WAAY,aAEZ,cAAe,gBACf,eAAgB,iBAChB,mBAAoB,qBAEpB,cAAe,gBACf,eAAgB,iBAChB,mB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GAAG,UAClB,aAAc,EAAW,aAAa,UACtC,WAAY,EAAW,WAAW,UAClC,KAAM,EAAW,KAAK,UACtB,KAAM,EAAW,KAAK,UACtB,UAAW,EAAW,UAAU,UAChC,WAAY,EAAW,WAAW,UAClC,SAAU,EAAW,SACrB,UAAW,EAAW,UAEtB,YAAa,EAAW,YACxB,aAAc,EAAW,aACzB,WAAY,EAAW,WACvB,iBAAkB,EAAW,iBAC7B,mBAAoB,EAAW,kBACjC,CACF,CAAC,CACH,EAEO,CACL,CACE,YAAa,EACb,OAAQ,CAAC,EACT,iBAAkB,CAChB,EAAgB,cAChB,EAAgB,cAChB,EAAgB,YAChB,EAAgB,WAClB,CACF,EACA,CACE,YAAa,EACb,OAAQ,CAAC,EACT,iBAAkB,CAChB,EAAgB,cAChB,EAAgB,cAChB,EAAgB,cAChB,EAAgB,cAChB,EAAgB,cAChB,EAAgB,UAClB,CACF,CACF,CACF","names":[]}
1
+ {"version":3,"sources":["../../../src/raydium/marketV2/instrument.ts","../../../src/common/txTool/txType.ts","../../../src/marshmallow/index.ts","../../../src/marshmallow/buffer-layout.ts","../../../src/raydium/marketV2/layout.ts"],"sourcesContent":["import {\n Connection,\n Keypair,\n PublicKey,\n SystemProgram,\n SYSVAR_RENT_PUBKEY,\n Transaction,\n TransactionInstruction,\n} from \"@solana/web3.js\";\nimport BN from \"bn.js\";\nimport { createInitializeAccountInstruction, TOKEN_PROGRAM_ID } from \"@solana/spl-token\";\nimport { InstructionType } from \"@/common/txTool/txType\";\nimport { struct, u16, u32, u64, u8 } from \"../../marshmallow\";\nimport { MARKET_STATE_LAYOUT_V2 } from \"./layout\";\n\ntype Transactions = {\n transaction: Transaction;\n signer?: Keypair[] | undefined;\n instructionTypes?: string[];\n}[];\n\nexport function initializeMarket({\n programId,\n marketInfo,\n}: {\n programId: PublicKey;\n marketInfo: {\n id: PublicKey;\n requestQueue: PublicKey;\n eventQueue: PublicKey;\n bids: PublicKey;\n asks: PublicKey;\n baseVault: PublicKey;\n quoteVault: PublicKey;\n baseMint: PublicKey;\n quoteMint: PublicKey;\n authority?: PublicKey;\n pruneAuthority?: PublicKey;\n\n baseLotSize: BN;\n quoteLotSize: BN;\n feeRateBps: number;\n vaultSignerNonce: BN;\n quoteDustThreshold: BN;\n };\n}): TransactionInstruction {\n const dataLayout = struct([\n u8(\"version\"),\n u32(\"instruction\"),\n u64(\"baseLotSize\"),\n u64(\"quoteLotSize\"),\n u16(\"feeRateBps\"),\n u64(\"vaultSignerNonce\"),\n u64(\"quoteDustThreshold\"),\n ]);\n\n const keys = [\n { pubkey: marketInfo.id, isSigner: false, isWritable: true },\n { pubkey: marketInfo.requestQueue, isSigner: false, isWritable: true },\n { pubkey: marketInfo.eventQueue, isSigner: false, isWritable: true },\n { pubkey: marketInfo.bids, isSigner: false, isWritable: true },\n { pubkey: marketInfo.asks, isSigner: false, isWritable: true },\n { pubkey: marketInfo.baseVault, isSigner: false, isWritable: true },\n { pubkey: marketInfo.quoteVault, isSigner: false, isWritable: true },\n { pubkey: marketInfo.baseMint, isSigner: false, isWritable: false },\n { pubkey: marketInfo.quoteMint, isSigner: false, isWritable: false },\n // Use a dummy address if using the new dex upgrade to save tx space.\n {\n pubkey: marketInfo.authority ? marketInfo.quoteMint : SYSVAR_RENT_PUBKEY,\n isSigner: false,\n isWritable: false,\n },\n ]\n .concat(marketInfo.authority ? { pubkey: marketInfo.authority, isSigner: false, isWritable: false } : [])\n .concat(\n marketInfo.authority && marketInfo.pruneAuthority\n ? { pubkey: marketInfo.pruneAuthority, isSigner: false, isWritable: false }\n : [],\n );\n\n const data = Buffer.alloc(dataLayout.span);\n dataLayout.encode(\n {\n version: 0,\n instruction: 0,\n baseLotSize: marketInfo.baseLotSize,\n quoteLotSize: marketInfo.quoteLotSize,\n feeRateBps: marketInfo.feeRateBps,\n vaultSignerNonce: marketInfo.vaultSignerNonce,\n quoteDustThreshold: marketInfo.quoteDustThreshold,\n },\n data,\n );\n\n return new TransactionInstruction({\n keys,\n programId,\n data,\n });\n}\n\nexport async function makeCreateMarketInstruction({\n connection,\n wallet,\n marketInfo,\n}: {\n connection: Connection;\n wallet: PublicKey;\n marketInfo: {\n programId: PublicKey;\n id: { publicKey: PublicKey; seed: string };\n baseMint: PublicKey;\n quoteMint: PublicKey;\n baseVault: { publicKey: PublicKey; seed: string };\n quoteVault: { publicKey: PublicKey; seed: string };\n vaultOwner: PublicKey;\n\n requestQueue: { publicKey: PublicKey; seed: string };\n eventQueue: { publicKey: PublicKey; seed: string };\n bids: { publicKey: PublicKey; seed: string };\n asks: { publicKey: PublicKey; seed: string };\n\n feeRateBps: number;\n vaultSignerNonce: BN;\n quoteDustThreshold: BN;\n\n baseLotSize: BN;\n quoteLotSize: BN;\n\n requestQueueSpace?: number;\n eventQueueSpace?: number;\n orderbookQueueSpace?: number;\n\n lowestFeeMarket?: boolean;\n };\n}): Promise<Transactions> {\n const tx1 = new Transaction();\n const accountLamports = await connection.getMinimumBalanceForRentExemption(165);\n tx1.add(\n SystemProgram.createAccountWithSeed({\n fromPubkey: wallet,\n basePubkey: wallet,\n seed: marketInfo.baseVault.seed,\n newAccountPubkey: marketInfo.baseVault.publicKey,\n lamports: accountLamports,\n space: 165,\n programId: TOKEN_PROGRAM_ID,\n }),\n SystemProgram.createAccountWithSeed({\n fromPubkey: wallet,\n basePubkey: wallet,\n seed: marketInfo.quoteVault.seed,\n newAccountPubkey: marketInfo.quoteVault.publicKey,\n lamports: accountLamports,\n space: 165,\n programId: TOKEN_PROGRAM_ID,\n }),\n createInitializeAccountInstruction(marketInfo.baseVault.publicKey, marketInfo.baseMint, marketInfo.vaultOwner),\n createInitializeAccountInstruction(marketInfo.quoteVault.publicKey, marketInfo.quoteMint, marketInfo.vaultOwner),\n );\n\n const tx2 = new Transaction();\n tx2.add(\n SystemProgram.createAccountWithSeed({\n fromPubkey: wallet,\n basePubkey: wallet,\n seed: marketInfo.id.seed,\n newAccountPubkey: marketInfo.id.publicKey,\n lamports: await connection.getMinimumBalanceForRentExemption(MARKET_STATE_LAYOUT_V2.span),\n space: MARKET_STATE_LAYOUT_V2.span,\n programId: marketInfo.programId,\n }),\n SystemProgram.createAccountWithSeed({\n fromPubkey: wallet,\n basePubkey: wallet,\n seed: marketInfo.requestQueue.seed,\n newAccountPubkey: marketInfo.requestQueue.publicKey,\n lamports: marketInfo.lowestFeeMarket\n ? 6208320\n : await connection.getMinimumBalanceForRentExemption(marketInfo.requestQueueSpace ?? 5120 + 12),\n space: marketInfo.requestQueueSpace ?? 5120 + 12,\n programId: marketInfo.programId,\n }),\n SystemProgram.createAccountWithSeed({\n fromPubkey: wallet,\n basePubkey: wallet,\n seed: marketInfo.eventQueue.seed,\n newAccountPubkey: marketInfo.eventQueue.publicKey,\n lamports: marketInfo.lowestFeeMarket\n ? 79594560\n : await connection.getMinimumBalanceForRentExemption(marketInfo.eventQueueSpace ?? 262144 + 12),\n space: marketInfo.eventQueueSpace ?? 262144 + 12,\n programId: marketInfo.programId,\n }),\n SystemProgram.createAccountWithSeed({\n fromPubkey: wallet,\n basePubkey: wallet,\n seed: marketInfo.bids.seed,\n newAccountPubkey: marketInfo.bids.publicKey,\n lamports: marketInfo.lowestFeeMarket\n ? 101977920\n : await connection.getMinimumBalanceForRentExemption(marketInfo.orderbookQueueSpace ?? 65536 + 12),\n space: marketInfo.orderbookQueueSpace ?? 65536 + 12,\n programId: marketInfo.programId,\n }),\n SystemProgram.createAccountWithSeed({\n fromPubkey: wallet,\n basePubkey: wallet,\n seed: marketInfo.asks.seed,\n newAccountPubkey: marketInfo.asks.publicKey,\n lamports: marketInfo.lowestFeeMarket\n ? 101977920\n : await connection.getMinimumBalanceForRentExemption(marketInfo.orderbookQueueSpace ?? 65536 + 12),\n space: marketInfo.orderbookQueueSpace ?? 65536 + 12,\n programId: marketInfo.programId,\n }),\n initializeMarket({\n programId: marketInfo.programId,\n marketInfo: {\n id: marketInfo.id.publicKey,\n requestQueue: marketInfo.requestQueue.publicKey,\n eventQueue: marketInfo.eventQueue.publicKey,\n bids: marketInfo.bids.publicKey,\n asks: marketInfo.asks.publicKey,\n baseVault: marketInfo.baseVault.publicKey,\n quoteVault: marketInfo.quoteVault.publicKey,\n baseMint: marketInfo.baseMint,\n quoteMint: marketInfo.quoteMint,\n\n baseLotSize: marketInfo.baseLotSize,\n quoteLotSize: marketInfo.quoteLotSize,\n feeRateBps: marketInfo.feeRateBps,\n vaultSignerNonce: marketInfo.vaultSignerNonce,\n quoteDustThreshold: marketInfo.quoteDustThreshold,\n },\n }),\n );\n\n return [\n {\n transaction: tx1,\n signer: [],\n instructionTypes: [\n InstructionType.CreateAccount,\n InstructionType.CreateAccount,\n InstructionType.InitAccount,\n InstructionType.InitAccount,\n ],\n },\n {\n transaction: tx2,\n signer: [],\n instructionTypes: [\n InstructionType.CreateAccount,\n InstructionType.CreateAccount,\n InstructionType.CreateAccount,\n InstructionType.CreateAccount,\n InstructionType.CreateAccount,\n InstructionType.InitMarket,\n ],\n },\n ];\n}\n","export enum TxVersion {\n \"V0\",\n \"LEGACY\",\n}\n\nexport const InstructionType = {\n CreateAccount: \"CreateAccount\",\n InitAccount: \"InitAccount\",\n CreateATA: \"CreateATA\",\n CloseAccount: \"CloseAccount\",\n TransferAmount: \"TransferAmount\",\n InitMint: \"InitMint\",\n MintTo: \"MintTo\",\n\n InitMarket: \"InitMarket\", // create market main ins\n Util1216OwnerClaim: \"Util1216OwnerClaim\", // owner claim token ins\n\n SetComputeUnitPrice: \"SetComputeUnitPrice\",\n SetComputeUnitLimit: \"SetComputeUnitLimit\",\n\n // CLMM\n ClmmCreatePool: \"ClmmCreatePool\",\n ClmmOpenPosition: \"ClmmOpenPosition\",\n ClmmIncreasePosition: \"ClmmIncreasePosition\",\n ClmmDecreasePosition: \"ClmmDecreasePosition\",\n ClmmClosePosition: \"ClmmClosePosition\",\n ClmmSwapBaseIn: \"ClmmSwapBaseIn\",\n ClmmSwapBaseOut: \"ClmmSwapBaseOut\",\n ClmmInitReward: \"ClmmInitReward\",\n ClmmSetReward: \"ClmmSetReward\",\n ClmmCollectReward: \"ClmmCollectReward\",\n ClmmLockPosition: \"ClmmLockPosition\",\n ClmmHarvestLockPosition: \"ClmmHarvestLockPosition\",\n\n AmmV4Swap: \"AmmV4Swap\",\n AmmV4AddLiquidity: \"AmmV4AddLiquidity\",\n AmmV4RemoveLiquidity: \"AmmV4RemoveLiquidity\",\n AmmV4SimulatePoolInfo: \"AmmV4SimulatePoolInfo\",\n AmmV4SwapBaseIn: \"AmmV4SwapBaseIn\",\n AmmV4SwapBaseOut: \"AmmV4SwapBaseOut\",\n AmmV4CreatePool: \"AmmV4CreatePool\",\n AmmV4InitPool: \"AmmV4InitPool\",\n\n AmmV5AddLiquidity: \"AmmV5AddLiquidity\",\n AmmV5RemoveLiquidity: \"AmmV5RemoveLiquidity\",\n AmmV5SimulatePoolInfo: \"AmmV5SimulatePoolInfo\",\n AmmV5SwapBaseIn: \"AmmV5SwapBaseIn\",\n AmmV5SwapBaseOut: \"AmmV5SwapBaseOut\",\n\n RouteSwap: \"RouteSwap\",\n RouteSwap1: \"RouteSwap1\",\n RouteSwap2: \"RouteSwap2\",\n\n FarmV3Deposit: \"FarmV3Deposit\",\n FarmV3Withdraw: \"FarmV3Withdraw\",\n FarmV3CreateLedger: \"FarmV3CreateLedger\",\n\n FarmV5Deposit: \"FarmV5Deposit\",\n FarmV5Withdraw: \"FarmV5Withdraw\",\n FarmV5CreateLedger: \"FarmV5CreateLedger\",\n\n FarmV6Deposit: \"FarmV6Deposit\",\n FarmV6Withdraw: \"FarmV6Withdraw\",\n FarmV6Create: \"FarmV6Create\",\n FarmV6Restart: \"FarmV6Restart\",\n FarmV6CreatorAddReward: \"FarmV6CreatorAddReward\",\n FarmV6CreatorWithdraw: \"FarmV6CreatorWithdraw\",\n\n CpmmCreatePool: \"CpmmCreatePool\",\n CpmmAddLiquidity: \"CpmmAddLiquidity\",\n CpmmWithdrawLiquidity: \"CpmmWithdrawLiquidity\",\n CpmmSwapBaseIn: \"CpmmSwapBaseIn\",\n CpmmSwapBaseOut: \"CpmmSwapBaseOut\",\n\n CpmmLockLp: \"CpmmLockLp\",\n CpmmCollectLockFee: \"CpmmCollectLockFee\",\n};\n","import { PublicKey } from \"@solana/web3.js\";\nimport BN, { isBN } from \"bn.js\";\n\nimport {\n bits,\n blob,\n Blob,\n Layout,\n offset as _offset,\n seq as _seq,\n Structure as _Structure,\n u32 as _u32,\n u8 as _u8,\n UInt,\n union as _union,\n Union as _Union,\n} from \"./buffer-layout\";\n\nexport * from \"./buffer-layout\";\nexport { blob };\n\nexport class BNLayout<P extends string = \"\"> extends Layout<BN, P> {\n blob: Layout<Buffer>;\n signed: boolean;\n\n constructor(span: number, signed: boolean, property?: P) {\n //@ts-expect-error type wrong for super()'s type different from extends, but it desn't matter\n super(span, property);\n this.blob = blob(span);\n this.signed = signed;\n }\n\n /** @override */\n decode(b: Buffer, offset = 0): BN {\n const num = new BN(this.blob.decode(b, offset), 10, \"le\");\n if (this.signed) {\n return num.fromTwos(this.span * 8).clone();\n }\n return num;\n }\n\n /** @override */\n encode(src: BN, b: Buffer, offset = 0): number {\n if (typeof src === \"number\") src = new BN(src); // src will pass a number accidently in union\n if (this.signed) {\n src = src.toTwos(this.span * 8);\n }\n return this.blob.encode(src.toArrayLike(Buffer, \"le\", this.span), b, offset);\n }\n}\n\nexport class WideBits<P extends string = \"\"> extends Layout<Record<string, boolean>, P> {\n _lower: any;\n _upper: any;\n // TODO: unknown\n constructor(property?: P) {\n //@ts-expect-error type wrong for super()'s type different from extends , but it desn't matter\n super(8, property);\n this._lower = bits(_u32(), false);\n this._upper = bits(_u32(), false);\n }\n\n addBoolean(property: string): void {\n if (this._lower.fields.length < 32) {\n this._lower.addBoolean(property);\n } else {\n this._upper.addBoolean(property);\n }\n }\n\n decode(b: Buffer, offset = 0): Record<string, boolean> {\n const lowerDecoded = this._lower.decode(b, offset);\n const upperDecoded = this._upper.decode(b, offset + this._lower.span);\n return { ...lowerDecoded, ...upperDecoded };\n }\n\n encode(src: any /* TEMP */, b: Buffer, offset = 0): any {\n return this._lower.encode(src, b, offset) + this._upper.encode(src, b, offset + this._lower.span);\n }\n}\n\nexport function u8<P extends string = \"\">(property?: P): UInt<number, P> {\n return new UInt(1, property);\n}\n\nexport function u32<P extends string = \"\">(property?: P): UInt<number, P> {\n return new UInt(4, property);\n}\n\nexport function u64<P extends string = \"\">(property?: P): BNLayout<P> {\n return new BNLayout(8, false, property);\n}\n\nexport function u128<P extends string = \"\">(property?: P): BNLayout<P> {\n return new BNLayout(16, false, property);\n}\n\nexport function i8<P extends string = \"\">(property?: P): BNLayout<P> {\n return new BNLayout(1, true, property);\n}\n\nexport function i64<P extends string = \"\">(property?: P): BNLayout<P> {\n return new BNLayout(8, true, property);\n}\n\nexport function i128<P extends string = \"\">(property?: P): BNLayout<P> {\n return new BNLayout(16, true, property);\n}\n\nexport class WrappedLayout<T, U, P extends string = \"\"> extends Layout<U, P> {\n layout: Layout<T>;\n decoder: (data: T) => U;\n encoder: (src: U) => T;\n\n constructor(layout: Layout<T>, decoder: (data: T) => U, encoder: (src: U) => T, property?: P) {\n //@ts-expect-error type wrong for super()'s type different from extends , but it desn't matter\n super(layout.span, property);\n this.layout = layout;\n this.decoder = decoder;\n this.encoder = encoder;\n }\n\n decode(b: Buffer, offset?: number): U {\n return this.decoder(this.layout.decode(b, offset));\n }\n\n encode(src: U, b: Buffer, offset?: number): number {\n return this.layout.encode(this.encoder(src), b, offset);\n }\n\n getSpan(b: Buffer, offset?: number): number {\n return this.layout.getSpan(b, offset);\n }\n}\n\nexport function publicKey<P extends string = \"\">(property?: P): Layout<PublicKey, P> {\n return new WrappedLayout(\n blob(32),\n (b: Buffer) => new PublicKey(b),\n (key: PublicKey) => key.toBuffer(),\n property,\n );\n}\n\nexport class OptionLayout<T, P> extends Layout<T | null, P> {\n layout: Layout<T>;\n discriminator: Layout<number>;\n\n constructor(layout: Layout<T>, property?: P) {\n //@ts-expect-error type wrong for super()'s type different from extends , but it desn't matter\n super(-1, property);\n this.layout = layout;\n this.discriminator = _u8();\n }\n\n encode(src: T | null, b: Buffer, offset = 0): number {\n if (src === null || src === undefined) {\n return this.discriminator.encode(0, b, offset);\n }\n this.discriminator.encode(1, b, offset);\n return this.layout.encode(src, b, offset + 1) + 1;\n }\n\n decode(b: Buffer, offset = 0): T | null {\n const discriminator = this.discriminator.decode(b, offset);\n if (discriminator === 0) {\n return null;\n } else if (discriminator === 1) {\n return this.layout.decode(b, offset + 1);\n }\n throw new Error(\"Invalid option \" + this.property);\n }\n\n getSpan(b: Buffer, offset = 0): number {\n const discriminator = this.discriminator.decode(b, offset);\n if (discriminator === 0) {\n return 1;\n } else if (discriminator === 1) {\n return this.layout.getSpan(b, offset + 1) + 1;\n }\n throw new Error(\"Invalid option \" + this.property);\n }\n}\n\nexport function option<T, P extends string = \"\">(layout: Layout<T>, property?: P): Layout<T | null, P> {\n return new OptionLayout<T, P>(layout, property);\n}\n\nexport function bool<P extends string = \"\">(property?: P): Layout<boolean, P> {\n return new WrappedLayout(_u8(), decodeBool, encodeBool, property);\n}\n\nexport function decodeBool(value: number): boolean {\n if (value === 0) {\n return false;\n } else if (value === 1) {\n return true;\n }\n throw new Error(\"Invalid bool: \" + value);\n}\n\nexport function encodeBool(value: boolean): number {\n return value ? 1 : 0;\n}\n\nexport function vec<T, P extends string = \"\">(elementLayout: Layout<T>, property?: P): Layout<T[], P> {\n const length = _u32(\"length\");\n const layout: Layout<{ values: T[] }> = struct([\n length,\n seq(elementLayout, _offset(length, -length.span), \"values\"),\n ]) as any; // Something I don't know\n return new WrappedLayout(\n layout,\n ({ values }) => values,\n (values) => ({ values }),\n property,\n );\n}\n\nexport function tagged<T, P extends string = \"\">(tag: BN, layout: Layout<T>, property?: P): Layout<T, P> {\n const wrappedLayout: Layout<{ tag: BN; data: T }> = struct([u64(\"tag\"), layout.replicate(\"data\")]) as any; // Something I don't know\n\n function decodeTag({ tag: receivedTag, data }: { tag: BN; data: T }): T {\n if (!receivedTag.eq(tag)) {\n throw new Error(\"Invalid tag, expected: \" + tag.toString(\"hex\") + \", got: \" + receivedTag.toString(\"hex\"));\n }\n return data;\n }\n\n return new WrappedLayout(wrappedLayout, decodeTag, (data) => ({ tag, data }), property);\n}\n\nexport function vecU8<P extends string = \"\">(property?: P): Layout<Buffer, P> {\n const length = _u32(\"length\");\n const layout: Layout<{ data: Buffer }> = struct([length, blob(_offset(length, -length.span), \"data\")]) as any; // Something I don't know\n return new WrappedLayout(\n layout,\n ({ data }) => data,\n (data) => ({ data }),\n property,\n );\n}\n\nexport function str<P extends string = \"\">(property?: P): Layout<string, P> {\n return new WrappedLayout(\n vecU8(),\n (data) => data.toString(\"utf-8\"),\n (s) => Buffer.from(s, \"utf-8\"),\n property,\n );\n}\n\nexport interface EnumLayout<T, P extends string = \"\"> extends Layout<T, P> {\n registry: Record<string, Layout<any>>;\n}\n\nexport function rustEnum<T, P extends string = \"\">(variants: Layout<any>[], property?: P): EnumLayout<T, P> {\n const unionLayout = _union(_u8(), property);\n variants.forEach((variant, index) => unionLayout.addVariant(index, variant, variant.property));\n return unionLayout as any; // ?why use UnionLayout? This must be a fault\n}\n\nexport function array<T, P extends string = \"\">(\n elementLayout: Layout<T>,\n length: number,\n property?: P,\n): Layout<T[], P> {\n const layout = struct([seq(elementLayout, length, \"values\")]) as any as Layout<{ values: T[] }>; // Something I don't know\n return new WrappedLayout(\n layout,\n ({ values }) => values,\n (values) => ({ values }),\n property,\n );\n}\n\nexport class Structure<T, P, D extends { [key: string]: any; }> extends _Structure<T, P, D> {\n /** @override */\n decode(b: Buffer, offset?: number): D {\n return super.decode(b, offset);\n }\n}\n\nexport function struct<T, P extends string = \"\">(\n fields: T,\n property?: P,\n decodePrefixes?: boolean,\n): T extends Layout<infer Value, infer Property>[]\n ? Structure<\n Value,\n P,\n {\n [K in Exclude<Extract<Property, string>, \"\">]: Extract<T[number], Layout<any, K>> extends Layout<infer V, any>\n ? V\n : any;\n }\n >\n : any {\n //@ts-expect-error this type is not quite satisfied the define, but, never no need to worry about.\n return new Structure(fields, property, decodePrefixes);\n}\n\nexport type GetLayoutSchemaFromStructure<T extends Structure<any, any, any>> = T extends Structure<any, any, infer S>\n ? S\n : any;\nexport type GetStructureFromLayoutSchema<S extends { [key: string]: any; }> = Structure<any, any, S>;\n\nexport class Union<Schema extends { [key: string]: any; }> extends _Union<Schema> {\n encodeInstruction(instruction: any): Buffer {\n const instructionMaxSpan = Math.max(...Object.values(this.registry).map((r) => r.span));\n const b = Buffer.alloc(instructionMaxSpan);\n return b.slice(0, this.encode(instruction, b));\n }\n\n decodeInstruction(instruction: any): Partial<Schema> {\n return this.decode(instruction);\n }\n}\nexport function union<UnionSchema extends { [key: string]: any } = any>(\n discr: any,\n defaultLayout?: any,\n property?: string,\n): Union<UnionSchema> {\n return new Union(discr, defaultLayout, property);\n}\n\nclass Zeros extends Blob {\n decode(b: Buffer, offset: number): Buffer {\n const slice = super.decode(b, offset);\n if (!slice.every((v) => v === 0)) {\n throw new Error(\"nonzero padding bytes\");\n }\n return slice;\n }\n}\n\nexport function zeros(length: number): Zeros {\n return new Zeros(length);\n}\n\nexport function seq<T, P extends string = \"\", AnotherP extends string = \"\">(\n elementLayout: Layout<T, P>,\n count: number | BN | Layout<BN | number, P>,\n property?: AnotherP,\n): Layout<T[], AnotherP> {\n let parsedCount: number;\n const superCount =\n typeof count === \"number\"\n ? count\n : isBN(count)\n ? count.toNumber()\n : new Proxy(count as unknown as Layout<number> /* pretend to be Layout<number> */, {\n get(target, property): any {\n if (!parsedCount) {\n // get count in targetLayout. note that count may be BN\n const countProperty = Reflect.get(target, \"count\");\n\n // let targetLayout's property:count be a number\n parsedCount = isBN(countProperty) ? countProperty.toNumber() : countProperty;\n\n // record the count\n Reflect.set(target, \"count\", parsedCount);\n }\n return Reflect.get(target, property);\n },\n set(target, property, value): any {\n if (property === \"count\") {\n parsedCount = value;\n }\n return Reflect.set(target, property, value);\n },\n });\n\n // @ts-expect-error force type\n return _seq(elementLayout, superCount, property);\n}\n","import {\n bits as _bits,\n BitStructure as _BitStructure,\n blob as _blob,\n Blob as _Blob,\n cstr as _cstr,\n f32 as _f32,\n f32be as _f32be,\n f64 as _f64,\n f64be as _f64be,\n greedy as _greedy,\n Layout as _Layout,\n ns64 as _ns64,\n ns64be as _ns64be,\n nu64 as _nu64,\n nu64be as _nu64be,\n offset as _offset,\n s16 as _s16,\n s16be as _s16be,\n s24 as _s24,\n s24be as _s24be,\n s32 as _s32,\n s32be as _s32be,\n s40 as _s40,\n s40be as _s40be,\n s48 as _s48,\n s48be as _s48be,\n s8 as _s8,\n seq as _seq,\n struct as _struct,\n Structure as _Structure,\n u16 as _u16,\n u16be as _u16be,\n u24 as _u24,\n u24be as _u24be,\n u32 as _u32,\n u32be as _u32be,\n u40 as _u40,\n u40be as _u40be,\n u48 as _u48,\n u48be as _u48be,\n u8 as _u8,\n UInt as _UInt,\n union as _union,\n Union as _Union,\n unionLayoutDiscriminator as _unionLayoutDiscriminator,\n utf8 as _utf8,\n} from \"@solana/buffer-layout\";\n\n//#region ------------------- Layout -------------------\nexport interface Layout<T = any, P = \"\"> {\n span: number;\n property?: P;\n decode(b: Buffer, offset?: number): T;\n encode(src: T, b: Buffer, offset?: number): number;\n getSpan(b: Buffer, offset?: number): number;\n replicate<AP extends string>(name: AP): Layout<T, AP>;\n}\nexport interface LayoutConstructor {\n new <T, P>(): Layout<T, P>; // for class extends syntex\n new <T, P>(span?: T, property?: P): Layout<T, P>;\n readonly prototype: Layout;\n}\nexport const Layout = _Layout as unknown as LayoutConstructor;\n//#endregion\n\n//#region ------------------- Structure -------------------\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nexport interface Structure<T = any, P = \"\", DecodeSchema extends { [key: string]: any } = any>\n extends Layout<DecodeSchema, P> {\n span: number;\n decode(b: Buffer, offset?: number): DecodeSchema;\n layoutFor<AP extends string>(property: AP): Layout<DecodeSchema[AP]>;\n offsetOf<AP extends string>(property: AP): number;\n}\ninterface StructureConstructor {\n new <T = any, P = \"\", DecodeSchema extends { [key: string]: any } = any>(): Structure<T, P, DecodeSchema>;\n new <T = any, P = \"\", DecodeSchema extends { [key: string]: any } = any>(\n fields: T,\n property?: P,\n decodePrefixes?: boolean,\n ): Structure<T, P, DecodeSchema>;\n}\nexport const Structure = _Structure as unknown as StructureConstructor;\n//#endregion\n\n//#region ------------------- Union -------------------\nexport interface Union<UnionSchema extends { [key: string]: any } = any> extends Layout {\n registry: object;\n decode(b: Buffer, offset?: number): Partial<UnionSchema>;\n addVariant(\n variant: number,\n layout: Structure<any, any, Partial<UnionSchema>> | Layout<any, keyof UnionSchema>,\n property?: string,\n ): any /* TEMP: code in Layout.js 1809 */;\n}\ninterface UnionConstructor {\n new <UnionSchema extends { [key: string]: any } = any>(): Union<UnionSchema>;\n new <UnionSchema extends { [key: string]: any } = any>(\n discr: Layout<any, any>,\n defaultLayout: Layout<any, any>,\n property?: string,\n ): Union<UnionSchema>;\n}\nexport const Union = _Union as unknown as UnionConstructor;\n//#endregion\n\n//#region ------------------- BitStructure -------------------\nexport type BitStructure<T = unknown /* TEMP */, P = \"\"> = Layout<T, P>;\ninterface BitStructureConstructor {\n new (...params: any[]): BitStructure;\n}\nexport const BitStructure = _BitStructure as BitStructureConstructor;\n//#endregion\n\n//#region ------------------- UInt -------------------\nexport type UInt<T = any, P = \"\"> = Layout<T, P>;\ninterface UIntConstructor {\n new <T, P>(span?: T, property?: P): UInt<T, P>;\n}\nexport const UInt = _UInt as UIntConstructor;\n//#endregion\n\n//#region ------------------- Blob -------------------\nexport type Blob<P extends string = \"\"> = Layout<Buffer, P>;\ninterface BlobConstructor {\n new (...params: ConstructorParameters<LayoutConstructor>): Blob;\n}\nexport const Blob = _Blob as unknown as BlobConstructor;\n//#endregion\n\nexport const greedy = _greedy as <P extends string = \"\">(elementSpan?: number, property?: P) => Layout<number, P>;\nexport const u8 = _u8 as <P extends string = \"\">(property?: P) => Layout<number, P>;\nexport const u16 = _u16 as <P extends string = \"\">(property?: P) => Layout<number, P>;\nexport const u24 = _u24 as <P extends string = \"\">(property?: P) => Layout<number, P>;\nexport const u32 = _u32 as <P extends string = \"\">(property?: P) => Layout<number, P>;\nexport const u40 = _u40 as <P extends string = \"\">(property?: P) => Layout<number, P>;\nexport const u48 = _u48 as <P extends string = \"\">(property?: P) => Layout<number, P>;\nexport const nu64 = _nu64 as <P extends string = \"\">(property?: P) => Layout<number, P>;\nexport const u16be = _u16be as <P extends string = \"\">(property?: P) => Layout<number, P>;\nexport const u24be = _u24be as <P extends string = \"\">(property?: P) => Layout<number, P>;\nexport const u32be = _u32be as <P extends string = \"\">(property?: P) => Layout<number, P>;\nexport const u40be = _u40be as <P extends string = \"\">(property?: P) => Layout<number, P>;\nexport const u48be = _u48be as <P extends string = \"\">(property?: P) => Layout<number, P>;\nexport const nu64be = _nu64be as <P extends string = \"\">(property?: P) => Layout<number, P>;\nexport const s8 = _s8 as <P extends string = \"\">(property?: P) => Layout<number, P>;\nexport const s16 = _s16 as <P extends string = \"\">(property?: P) => Layout<number, P>;\nexport const s24 = _s24 as <P extends string = \"\">(property?: P) => Layout<number, P>;\nexport const s32 = _s32 as <P extends string = \"\">(property?: P) => Layout<number, P>;\nexport const s40 = _s40 as <P extends string = \"\">(property?: P) => Layout<number, P>;\nexport const s48 = _s48 as <P extends string = \"\">(property?: P) => Layout<number, P>;\nexport const ns64 = _ns64 as <P extends string = \"\">(property?: P) => Layout<number, P>;\nexport const s16be = _s16be as <P extends string = \"\">(property?: P) => Layout<number, P>;\nexport const s24be = _s24be as <P extends string = \"\">(property?: P) => Layout<number, P>;\nexport const s32be = _s32be as <P extends string = \"\">(property?: P) => Layout<number, P>;\nexport const s40be = _s40be as <P extends string = \"\">(property?: P) => Layout<number, P>;\nexport const s48be = _s48be as <P extends string = \"\">(property?: P) => Layout<number, P>;\nexport const ns64be = _ns64be as <P extends string = \"\">(property?: P) => Layout<number, P>;\nexport const f32 = _f32 as <P extends string = \"\">(property?: P) => Layout<number, P>;\nexport const f32be = _f32be as <P extends string = \"\">(property?: P) => Layout<number, P>;\nexport const f64 = _f64 as <P extends string = \"\">(property?: P) => Layout<number, P>;\nexport const f64be = _f64be as <P extends string = \"\">(property?: P) => Layout<number, P>;\n\nexport const struct = _struct as <T, P extends string = \"\">(\n fields: T,\n property?: P,\n decodePrefixes?: boolean,\n) => T extends Layout<infer Value, infer Property>[]\n ? Structure<\n Value,\n P,\n {\n [K in Exclude<Extract<Property, string>, \"\">]: Extract<T[number], Layout<any, K>> extends Layout<infer V, any>\n ? V\n : any;\n }\n >\n : any;\n\nexport const seq = _seq as unknown as <T, P>(\n elementLayout: Layout<T, string>,\n count: number | Layout<number, string>,\n property?: P,\n) => Layout<T[]>;\nexport const union = _union as <UnionSchema extends { [key: string]: any } = any>(\n discr: Layout<any, any>,\n defaultLayout?: any,\n property?: string,\n) => Union<UnionSchema>;\nexport const unionLayoutDiscriminator = _unionLayoutDiscriminator as <P extends string = \"\">(\n layout: Layout<any, P>,\n property?: P,\n) => any;\nexport const blob = _blob as unknown as <P extends string = \"\">(\n length: number | Layout<number, P>,\n property?: P,\n) => Blob<P>;\nexport const cstr = _cstr as <P extends string = \"\">(property?: P) => Layout<string, P>;\nexport const utf8 = _utf8 as <P extends string = \"\">(maxSpan: number, property?: P) => Layout<string, P>;\nexport const bits = _bits as unknown as <T, P extends string = \"\">(\n word: Layout<T>,\n msb?: boolean,\n property?: P,\n) => BitStructure<T, P>; // TODO: not quite sure\nexport const offset = _offset as unknown as <T, P extends string = \"\">(\n layout: Layout<T, P>,\n offset?: number,\n property?: P,\n) => Layout<T, P>;\n\nexport type GetStructureSchema<T extends Structure> = T extends Structure<any, any, infer S> ? S : unknown;\n","import { blob, publicKey, struct, u64, WideBits } from \"../../marshmallow\";\n\nfunction accountFlagsLayout(property = \"accountFlags\"): WideBits<string> {\n const ACCOUNT_FLAGS_LAYOUT = new WideBits(property);\n ACCOUNT_FLAGS_LAYOUT.addBoolean(\"initialized\");\n ACCOUNT_FLAGS_LAYOUT.addBoolean(\"market\");\n ACCOUNT_FLAGS_LAYOUT.addBoolean(\"openOrders\");\n ACCOUNT_FLAGS_LAYOUT.addBoolean(\"requestQueue\");\n ACCOUNT_FLAGS_LAYOUT.addBoolean(\"eventQueue\");\n ACCOUNT_FLAGS_LAYOUT.addBoolean(\"bids\");\n ACCOUNT_FLAGS_LAYOUT.addBoolean(\"asks\");\n return ACCOUNT_FLAGS_LAYOUT;\n}\n\nexport const MARKET_STATE_LAYOUT_V2 = struct([\n blob(5),\n accountFlagsLayout(\"accountFlags\"),\n publicKey(\"ownAddress\"),\n u64(\"vaultSignerNonce\"),\n publicKey(\"baseMint\"),\n publicKey(\"quoteMint\"),\n publicKey(\"baseVault\"),\n u64(\"baseDepositsTotal\"),\n u64(\"baseFeesAccrued\"),\n publicKey(\"quoteVault\"),\n u64(\"quoteDepositsTotal\"),\n u64(\"quoteFeesAccrued\"),\n u64(\"quoteDustThreshold\"),\n publicKey(\"requestQueue\"),\n publicKey(\"eventQueue\"),\n publicKey(\"bids\"),\n publicKey(\"asks\"),\n u64(\"baseLotSize\"),\n u64(\"quoteLotSize\"),\n u64(\"feeRateBps\"),\n u64(\"referrerRebatesAccrued\"),\n blob(7),\n]);\n"],"mappings":"4zBAAA,iGAAA,MAQO,2BAEP,EAAqE,6BCL9D,GAAM,GAAkB,CAC7B,cAAe,gBACf,YAAa,cACb,UAAW,YACX,aAAc,eACd,eAAgB,iBAChB,SAAU,WACV,OAAQ,SAER,WAAY,aACZ,mBAAoB,qBAEpB,oBAAqB,sBACrB,oBAAqB,sBAGrB,eAAgB,iBAChB,iBAAkB,mBAClB,qBAAsB,uBACtB,qBAAsB,uBACtB,kBAAmB,oBACnB,eAAgB,iBAChB,gBAAiB,kBACjB,eAAgB,iBAChB,cAAe,gBACf,kBAAmB,oBACnB,iBAAkB,mBAClB,wBAAyB,0BAEzB,UAAW,YACX,kBAAmB,oBACnB,qBAAsB,uBACtB,sBAAuB,wBACvB,gBAAiB,kBACjB,iBAAkB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c,sBAAsB,CAClC,WAAY,EACZ,WAAY,EACZ,KAAM,EAAW,KAAK,KACtB,iBAAkB,EAAW,KAAK,UAClC,SAAU,EAAW,gBACjB,UACA,KAAM,GAAW,kCAAkC,KAAW,sBAAX,OAAkC,MAAQ,EAAE,EACnG,MAAO,KAAW,sBAAX,OAAkC,MAAQ,GACjD,UAAW,EAAW,SACxB,CAAC,EACD,EAAiB,CACf,UAAW,EAAW,UACtB,WAAY,CACV,GAAI,EAAW,GAAG,UAClB,aAAc,EAAW,aAAa,UACtC,WAAY,EAAW,WAAW,UAClC,KAAM,EAAW,KAAK,UACtB,KAAM,EAAW,KAAK,UACtB,UAAW,EAAW,UAAU,UAChC,WAAY,EAAW,WAAW,UAClC,SAAU,EAAW,SACrB,UAAW,EAAW,UAEtB,YAAa,EAAW,YACxB,aAAc,EAAW,aACzB,WAAY,EAAW,WACvB,iBAAkB,EAAW,iBAC7B,mBAAoB,EAAW,kBACjC,CACF,CAAC,CACH,EAEO,CACL,CACE,YAAa,EACb,OAAQ,CAAC,EACT,iBAAkB,CAChB,EAAgB,cAChB,EAAgB,cAChB,EAAgB,YAChB,EAAgB,WAClB,CACF,EACA,CACE,YAAa,EACb,OAAQ,CAAC,EACT,iBAAkB,CAChB,EAAgB,cAChB,EAAgB,cAChB,EAAgB,cAChB,EAAgB,cAChB,EAAgB,cAChB,EAAgB,UAClB,CACF,CACF,CACF","names":[]}
@@ -1,2 +1,2 @@
1
- var k=Object.defineProperty;var U=Object.getOwnPropertySymbols;var O=Object.prototype.hasOwnProperty,z=Object.prototype.propertyIsEnumerable;var R=(n,t,e)=>t in n?k(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,l=(n,t)=>{for(var e in t||(t={}))O.call(t,e)&&R(n,e,t[e]);if(U)for(var e of U(t))z.call(t,e)&&R(n,e,t[e]);return n};import{SystemProgram as i,SYSVAR_RENT_PUBKEY as ee,Transaction as E,TransactionInstruction as te}from"@solana/web3.js";import{createInitializeAccountInstruction as Q,TOKEN_PROGRAM_ID as W}from"@solana/spl-token";var u={CreateAccount:"CreateAccount",InitAccount:"InitAccount",CreateATA:"CreateATA",CloseAccount:"CloseAccount",TransferAmount:"TransferAmount",InitMint:"InitMint",MintTo:"MintTo",InitMarket:"InitMarket",Util1216OwnerClaim:"Util1216OwnerClaim",SetComputeUnitPrice:"SetComputeUnitPrice",SetComputeUnitLimit:"SetComputeUnitLimit",ClmmCreatePool:"ClmmCreatePool",ClmmOpenPosition:"ClmmOpenPosition",ClmmIncreasePosition:"ClmmIncreasePosition",ClmmDecreasePosition:"ClmmDecreasePosition",ClmmClosePosition:"ClmmClosePosition",ClmmSwapBaseIn:"ClmmSwapBaseIn",ClmmSwapBaseOut:"ClmmSwapBaseOut",ClmmInitReward:"ClmmInitReward",ClmmSetReward:"ClmmSetReward",ClmmCollectReward:"ClmmCollectReward",ClmmLockPosition:"ClmmLockPosition",ClmmHarvestLockPosition:"ClmmHarvestLockPosition",AmmV4Swap:"AmmV4Swap",AmmV4AddLiquidity:"AmmV4AddLiquidity",AmmV4RemoveLiquidity:"AmmV4RemoveLiquidity",AmmV4SimulatePoolInfo:"AmmV4SimulatePoolInfo",AmmV4SwapBaseIn:"AmmV4SwapBaseIn",AmmV4SwapBaseOut:"AmmV4SwapBaseOut",AmmV4CreatePool:"AmmV4CreatePool",AmmV4InitPool:"AmmV4InitPool",AmmV5AddLiquidity:"AmmV5AddLiquidity",AmmV5RemoveLiquidity:"AmmV5RemoveLiquidity",AmmV5SimulatePoolInfo:"AmmV5SimulatePoolInfo",AmmV5SwapBaseIn:"AmmV5SwapBaseIn",AmmV5SwapBaseOut:"AmmV5SwapBaseOut",RouteSwap:"RouteSwap",RouteSwap1:"RouteSwap1",RouteSwap2:"RouteSwap2",FarmV3Deposit:"FarmV3Deposit",FarmV3Withdraw:"FarmV3Withdraw",FarmV3CreateLedger:"FarmV3CreateLedger",FarmV5Deposit:"FarmV5Deposit",FarmV5Withdraw:"FarmV5Withdraw",FarmV5CreateLedger:"FarmV5CreateLedger",FarmV6Deposit:"FarmV6Deposit",FarmV6Withdraw:"FarmV6Withdraw",FarmV6Create:"FarmV6Create",FarmV6Restart:"FarmV6Restart",FarmV6CreatorAddReward:"FarmV6CreatorAddReward",FarmV6CreatorWithdraw:"FarmV6CreatorWithdraw",CpmmCreatePool:"CpmmCreatePool",CpmmAddLiquidity:"CpmmAddLiquidity",CpmmWithdrawLiquidity:"CpmmWithdrawLiquidity",CpmmSwapBaseIn:"CpmmSwapBaseIn",CpmmSwapBaseOut:"CpmmSwapBaseOut",CpmmLockLp:"CpmmLockLp",CpmmCollectLockFee:"CpmmCollectLockFee"};import{PublicKey as Z}from"@solana/web3.js";import N,{isBN as et}from"bn.js";import{bits as G,BitStructure as ue,blob as Y,Blob as ae,cstr as ie,f32 as ce,f32be as pe,f64 as ye,f64be as de,greedy as me,Layout as I,ns64 as be,ns64be as Pe,nu64 as le,nu64be as xe,offset as ge,s16 as Le,s16be as Se,s24 as fe,s24be as he,s32 as Te,s32be as we,s40 as Be,s40be as Ae,s48 as Ce,s48be as Ve,s8 as _e,seq as qe,struct as Ke,Structure as j,u16 as H,u16be as Ue,u24 as Re,u24be as Fe,u32 as J,u32be as ve,u40 as Ne,u40be as De,u48 as Me,u48be as Ee,u8 as Qe,UInt as X,union as We,Union as ke,unionLayoutDiscriminator as Oe,utf8 as ze}from"@solana/buffer-layout";var m=I,F=j;var x=X;var v=H;var g=J;var p=Y;var L=G;var S=class extends m{constructor(e,r,o){super(e,o);this.blob=p(e),this.signed=r}decode(e,r=0){let o=new N(this.blob.decode(e,r),10,"le");return this.signed?o.fromTwos(this.span*8).clone():o}encode(e,r,o=0){return typeof e=="number"&&(e=new N(e)),this.signed&&(e=e.toTwos(this.span*8)),this.blob.encode(e.toArrayLike(Buffer,"le",this.span),r,o)}},b=class extends m{constructor(e){super(8,e);this._lower=L(g(),!1),this._upper=L(g(),!1)}addBoolean(e){this._lower.fields.length<32?this._lower.addBoolean(e):this._upper.addBoolean(e)}decode(e,r=0){let o=this._lower.decode(e,r),c=this._upper.decode(e,r+this._lower.span);return l(l({},o),c)}encode(e,r,o=0){return this._lower.encode(e,r,o)+this._upper.encode(e,r,o+this._lower.span)}};function D(n){return new x(1,n)}function M(n){return new x(4,n)}function s(n){return new S(8,!1,n)}var f=class extends m{constructor(e,r,o,c){super(e.span,c);this.layout=e,this.decoder=r,this.encoder=o}decode(e,r){return this.decoder(this.layout.decode(e,r))}encode(e,r,o){return this.layout.encode(this.encoder(e),r,o)}getSpan(e,r){return this.layout.getSpan(e,r)}};function a(n){return new f(p(32),t=>new Z(t),t=>t.toBuffer(),n)}var h=class extends F{decode(t,e){return super.decode(t,e)}};function P(n,t,e){return new h(n,t,e)}function $(n="accountFlags"){let t=new b(n);return t.addBoolean("initialized"),t.addBoolean("market"),t.addBoolean("openOrders"),t.addBoolean("requestQueue"),t.addBoolean("eventQueue"),t.addBoolean("bids"),t.addBoolean("asks"),t}var T=P([p(5),$("accountFlags"),a("ownAddress"),s("vaultSignerNonce"),a("baseMint"),a("quoteMint"),a("baseVault"),s("baseDepositsTotal"),s("baseFeesAccrued"),a("quoteVault"),s("quoteDepositsTotal"),s("quoteFeesAccrued"),s("quoteDustThreshold"),a("requestQueue"),a("eventQueue"),a("bids"),a("asks"),s("baseLotSize"),s("quoteLotSize"),s("feeRateBps"),s("referrerRebatesAccrued"),p(7)]);function ne({programId:n,marketInfo:t}){let e=P([D("version"),M("instruction"),s("baseLotSize"),s("quoteLotSize"),v("feeRateBps"),s("vaultSignerNonce"),s("quoteDustThreshold")]),r=[{pubkey:t.id,isSigner:!1,isWritable:!0},{pubkey:t.requestQueue,isSigner:!1,isWritable:!0},{pubkey:t.eventQueue,isSigner:!1,isWritable:!0},{pubkey:t.bids,isSigner:!1,isWritable:!0},{pubkey:t.asks,isSigner:!1,isWritable:!0},{pubkey:t.baseVault,isSigner:!1,isWritable:!0},{pubkey:t.quoteVault,isSigner:!1,isWritable:!0},{pubkey:t.baseMint,isSigner:!1,isWritable:!1},{pubkey:t.quoteMint,isSigner:!1,isWritable:!1},{pubkey:t.authority?t.quoteMint:ee,isSigner:!1,isWritable:!1}].concat(t.authority?{pubkey:t.authority,isSigner:!1,isWritable:!1}:[]).concat(t.authority&&t.pruneAuthority?{pubkey:t.pruneAuthority,isSigner:!1,isWritable:!1}:[]),o=Buffer.alloc(e.span);return e.encode({version:0,instruction:0,baseLotSize:t.baseLotSize,quoteLotSize:t.quoteLotSize,feeRateBps:t.feeRateBps,vaultSignerNonce:t.vaultSignerNonce,quoteDustThreshold:t.quoteDustThreshold},o),new te({keys:r,programId:n,data:o})}async function bt({connection:n,wallet:t,marketInfo:e}){var w,B,A,C,V,_,q,K;let r=new E,o=await n.getMinimumBalanceForRentExemption(165);r.add(i.createAccountWithSeed({fromPubkey:t,basePubkey:t,seed:e.baseVault.seed,newAccountPubkey:e.baseVault.publicKey,lamports:o,space:165,programId:W}),i.createAccountWithSeed({fromPubkey:t,basePubkey:t,seed:e.quoteVault.seed,newAccountPubkey:e.quoteVault.publicKey,lamports:o,space:165,programId:W}),Q(e.baseVault.publicKey,e.baseMint,e.vaultOwner),Q(e.quoteVault.publicKey,e.quoteMint,e.vaultOwner));let c=new E;return c.add(i.createAccountWithSeed({fromPubkey:t,basePubkey:t,seed:e.id.seed,newAccountPubkey:e.id.publicKey,lamports:await n.getMinimumBalanceForRentExemption(T.span),space:T.span,programId:e.programId}),i.createAccountWithSeed({fromPubkey:t,basePubkey:t,seed:e.requestQueue.seed,newAccountPubkey:e.requestQueue.publicKey,lamports:await n.getMinimumBalanceForRentExemption((w=e.requestQueueSpace)!=null?w:5120+12),space:(B=e.requestQueueSpace)!=null?B:5120+12,programId:e.programId}),i.createAccountWithSeed({fromPubkey:t,basePubkey:t,seed:e.eventQueue.seed,newAccountPubkey:e.eventQueue.publicKey,lamports:await n.getMinimumBalanceForRentExemption((A=e.eventQueueSpace)!=null?A:262144+12),space:(C=e.eventQueueSpace)!=null?C:262144+12,programId:e.programId}),i.createAccountWithSeed({fromPubkey:t,basePubkey:t,seed:e.bids.seed,newAccountPubkey:e.bids.publicKey,lamports:await n.getMinimumBalanceForRentExemption((V=e.orderbookQueueSpace)!=null?V:65536+12),space:(_=e.orderbookQueueSpace)!=null?_:65536+12,programId:e.programId}),i.createAccountWithSeed({fromPubkey:t,basePubkey:t,seed:e.asks.seed,newAccountPubkey:e.asks.publicKey,lamports:await n.getMinimumBalanceForRentExemption((q=e.orderbookQueueSpace)!=null?q:65536+12),space:(K=e.orderbookQueueSpace)!=null?K:65536+12,programId:e.programId}),ne({programId:e.programId,marketInfo:{id:e.id.publicKey,requestQueue:e.requestQueue.publicKey,eventQueue:e.eventQueue.publicKey,bids:e.bids.publicKey,asks:e.asks.publicKey,baseVault:e.baseVault.publicKey,quoteVault:e.quoteVault.publicKey,baseMint:e.baseMint,quoteMint:e.quoteMint,baseLotSize:e.baseLotSize,quoteLotSize:e.quoteLotSize,feeRateBps:e.feeRateBps,vaultSignerNonce:e.vaultSignerNonce,quoteDustThreshold:e.quoteDustThreshold}})),[{transaction:r,signer:[],instructionTypes:[u.CreateAccount,u.CreateAccount,u.InitAccount,u.InitAccount]},{transaction:c,signer:[],instructionTypes:[u.CreateAccount,u.CreateAccount,u.CreateAccount,u.CreateAccount,u.CreateAccount,u.InitMarket]}]}export{ne as initializeMarket,bt as makeCreateMarketInstruction};
1
+ var k=Object.defineProperty;var U=Object.getOwnPropertySymbols;var O=Object.prototype.hasOwnProperty,z=Object.prototype.propertyIsEnumerable;var R=(n,t,e)=>t in n?k(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,P=(n,t)=>{for(var e in t||(t={}))O.call(t,e)&&R(n,e,t[e]);if(U)for(var e of U(t))z.call(t,e)&&R(n,e,t[e]);return n};import{SystemProgram as i,SYSVAR_RENT_PUBKEY as ee,Transaction as E,TransactionInstruction as te}from"@solana/web3.js";import{createInitializeAccountInstruction as Q,TOKEN_PROGRAM_ID as W}from"@solana/spl-token";var u={CreateAccount:"CreateAccount",InitAccount:"InitAccount",CreateATA:"CreateATA",CloseAccount:"CloseAccount",TransferAmount:"TransferAmount",InitMint:"InitMint",MintTo:"MintTo",InitMarket:"InitMarket",Util1216OwnerClaim:"Util1216OwnerClaim",SetComputeUnitPrice:"SetComputeUnitPrice",SetComputeUnitLimit:"SetComputeUnitLimit",ClmmCreatePool:"ClmmCreatePool",ClmmOpenPosition:"ClmmOpenPosition",ClmmIncreasePosition:"ClmmIncreasePosition",ClmmDecreasePosition:"ClmmDecreasePosition",ClmmClosePosition:"ClmmClosePosition",ClmmSwapBaseIn:"ClmmSwapBaseIn",ClmmSwapBaseOut:"ClmmSwapBaseOut",ClmmInitReward:"ClmmInitReward",ClmmSetReward:"ClmmSetReward",ClmmCollectReward:"ClmmCollectReward",ClmmLockPosition:"ClmmLockPosition",ClmmHarvestLockPosition:"ClmmHarvestLockPosition",AmmV4Swap:"AmmV4Swap",AmmV4AddLiquidity:"AmmV4AddLiquidity",AmmV4RemoveLiquidity:"AmmV4RemoveLiquidity",AmmV4SimulatePoolInfo:"AmmV4SimulatePoolInfo",AmmV4SwapBaseIn:"AmmV4SwapBaseIn",AmmV4SwapBaseOut:"AmmV4SwapBaseOut",AmmV4CreatePool:"AmmV4CreatePool",AmmV4InitPool:"AmmV4InitPool",AmmV5AddLiquidity:"AmmV5AddLiquidity",AmmV5RemoveLiquidity:"AmmV5RemoveLiquidity",AmmV5SimulatePoolInfo:"AmmV5SimulatePoolInfo",AmmV5SwapBaseIn:"AmmV5SwapBaseIn",AmmV5SwapBaseOut:"AmmV5SwapBaseOut",RouteSwap:"RouteSwap",RouteSwap1:"RouteSwap1",RouteSwap2:"RouteSwap2",FarmV3Deposit:"FarmV3Deposit",FarmV3Withdraw:"FarmV3Withdraw",FarmV3CreateLedger:"FarmV3CreateLedger",FarmV5Deposit:"FarmV5Deposit",FarmV5Withdraw:"FarmV5Withdraw",FarmV5CreateLedger:"FarmV5CreateLedger",FarmV6Deposit:"FarmV6Deposit",FarmV6Withdraw:"FarmV6Withdraw",FarmV6Create:"FarmV6Create",FarmV6Restart:"FarmV6Restart",FarmV6CreatorAddReward:"FarmV6CreatorAddReward",FarmV6CreatorWithdraw:"FarmV6CreatorWithdraw",CpmmCreatePool:"CpmmCreatePool",CpmmAddLiquidity:"CpmmAddLiquidity",CpmmWithdrawLiquidity:"CpmmWithdrawLiquidity",CpmmSwapBaseIn:"CpmmSwapBaseIn",CpmmSwapBaseOut:"CpmmSwapBaseOut",CpmmLockLp:"CpmmLockLp",CpmmCollectLockFee:"CpmmCollectLockFee"};import{PublicKey as $}from"@solana/web3.js";import M,{isBN as et}from"bn.js";import{bits as G,BitStructure as ue,blob as Y,Blob as ae,cstr as ie,f32 as ce,f32be as pe,f64 as ye,f64be as de,greedy as be,Layout as j,ns64 as le,ns64be as me,nu64 as Pe,nu64be as xe,offset as ge,s16 as Le,s16be as Se,s24 as fe,s24be as he,s32 as we,s32be as Te,s40 as Be,s40be as Ae,s48 as Ce,s48be as Ve,s8 as _e,seq as qe,struct as Ke,Structure as H,u16 as J,u16be as Ue,u24 as Re,u24be as Fe,u32 as X,u32be as ve,u40 as Me,u40be as Ne,u48 as De,u48be as Ee,u8 as Qe,UInt as Z,union as We,Union as ke,unionLayoutDiscriminator as Oe,utf8 as ze}from"@solana/buffer-layout";var b=j,F=H;var x=Z;var v=J;var g=X;var p=Y;var L=G;var S=class extends b{constructor(e,r,o){super(e,o);this.blob=p(e),this.signed=r}decode(e,r=0){let o=new M(this.blob.decode(e,r),10,"le");return this.signed?o.fromTwos(this.span*8).clone():o}encode(e,r,o=0){return typeof e=="number"&&(e=new M(e)),this.signed&&(e=e.toTwos(this.span*8)),this.blob.encode(e.toArrayLike(Buffer,"le",this.span),r,o)}},l=class extends b{constructor(e){super(8,e);this._lower=L(g(),!1),this._upper=L(g(),!1)}addBoolean(e){this._lower.fields.length<32?this._lower.addBoolean(e):this._upper.addBoolean(e)}decode(e,r=0){let o=this._lower.decode(e,r),c=this._upper.decode(e,r+this._lower.span);return P(P({},o),c)}encode(e,r,o=0){return this._lower.encode(e,r,o)+this._upper.encode(e,r,o+this._lower.span)}};function N(n){return new x(1,n)}function D(n){return new x(4,n)}function s(n){return new S(8,!1,n)}var f=class extends b{constructor(e,r,o,c){super(e.span,c);this.layout=e,this.decoder=r,this.encoder=o}decode(e,r){return this.decoder(this.layout.decode(e,r))}encode(e,r,o){return this.layout.encode(this.encoder(e),r,o)}getSpan(e,r){return this.layout.getSpan(e,r)}};function a(n){return new f(p(32),t=>new $(t),t=>t.toBuffer(),n)}var h=class extends F{decode(t,e){return super.decode(t,e)}};function m(n,t,e){return new h(n,t,e)}function I(n="accountFlags"){let t=new l(n);return t.addBoolean("initialized"),t.addBoolean("market"),t.addBoolean("openOrders"),t.addBoolean("requestQueue"),t.addBoolean("eventQueue"),t.addBoolean("bids"),t.addBoolean("asks"),t}var w=m([p(5),I("accountFlags"),a("ownAddress"),s("vaultSignerNonce"),a("baseMint"),a("quoteMint"),a("baseVault"),s("baseDepositsTotal"),s("baseFeesAccrued"),a("quoteVault"),s("quoteDepositsTotal"),s("quoteFeesAccrued"),s("quoteDustThreshold"),a("requestQueue"),a("eventQueue"),a("bids"),a("asks"),s("baseLotSize"),s("quoteLotSize"),s("feeRateBps"),s("referrerRebatesAccrued"),p(7)]);function ne({programId:n,marketInfo:t}){let e=m([N("version"),D("instruction"),s("baseLotSize"),s("quoteLotSize"),v("feeRateBps"),s("vaultSignerNonce"),s("quoteDustThreshold")]),r=[{pubkey:t.id,isSigner:!1,isWritable:!0},{pubkey:t.requestQueue,isSigner:!1,isWritable:!0},{pubkey:t.eventQueue,isSigner:!1,isWritable:!0},{pubkey:t.bids,isSigner:!1,isWritable:!0},{pubkey:t.asks,isSigner:!1,isWritable:!0},{pubkey:t.baseVault,isSigner:!1,isWritable:!0},{pubkey:t.quoteVault,isSigner:!1,isWritable:!0},{pubkey:t.baseMint,isSigner:!1,isWritable:!1},{pubkey:t.quoteMint,isSigner:!1,isWritable:!1},{pubkey:t.authority?t.quoteMint:ee,isSigner:!1,isWritable:!1}].concat(t.authority?{pubkey:t.authority,isSigner:!1,isWritable:!1}:[]).concat(t.authority&&t.pruneAuthority?{pubkey:t.pruneAuthority,isSigner:!1,isWritable:!1}:[]),o=Buffer.alloc(e.span);return e.encode({version:0,instruction:0,baseLotSize:t.baseLotSize,quoteLotSize:t.quoteLotSize,feeRateBps:t.feeRateBps,vaultSignerNonce:t.vaultSignerNonce,quoteDustThreshold:t.quoteDustThreshold},o),new te({keys:r,programId:n,data:o})}async function lt({connection:n,wallet:t,marketInfo:e}){var T,B,A,C,V,_,q,K;let r=new E,o=await n.getMinimumBalanceForRentExemption(165);r.add(i.createAccountWithSeed({fromPubkey:t,basePubkey:t,seed:e.baseVault.seed,newAccountPubkey:e.baseVault.publicKey,lamports:o,space:165,programId:W}),i.createAccountWithSeed({fromPubkey:t,basePubkey:t,seed:e.quoteVault.seed,newAccountPubkey:e.quoteVault.publicKey,lamports:o,space:165,programId:W}),Q(e.baseVault.publicKey,e.baseMint,e.vaultOwner),Q(e.quoteVault.publicKey,e.quoteMint,e.vaultOwner));let c=new E;return c.add(i.createAccountWithSeed({fromPubkey:t,basePubkey:t,seed:e.id.seed,newAccountPubkey:e.id.publicKey,lamports:await n.getMinimumBalanceForRentExemption(w.span),space:w.span,programId:e.programId}),i.createAccountWithSeed({fromPubkey:t,basePubkey:t,seed:e.requestQueue.seed,newAccountPubkey:e.requestQueue.publicKey,lamports:e.lowestFeeMarket?6208320:await n.getMinimumBalanceForRentExemption((T=e.requestQueueSpace)!=null?T:5120+12),space:(B=e.requestQueueSpace)!=null?B:5120+12,programId:e.programId}),i.createAccountWithSeed({fromPubkey:t,basePubkey:t,seed:e.eventQueue.seed,newAccountPubkey:e.eventQueue.publicKey,lamports:e.lowestFeeMarket?79594560:await n.getMinimumBalanceForRentExemption((A=e.eventQueueSpace)!=null?A:262144+12),space:(C=e.eventQueueSpace)!=null?C:262144+12,programId:e.programId}),i.createAccountWithSeed({fromPubkey:t,basePubkey:t,seed:e.bids.seed,newAccountPubkey:e.bids.publicKey,lamports:e.lowestFeeMarket?101977920:await n.getMinimumBalanceForRentExemption((V=e.orderbookQueueSpace)!=null?V:65536+12),space:(_=e.orderbookQueueSpace)!=null?_:65536+12,programId:e.programId}),i.createAccountWithSeed({fromPubkey:t,basePubkey:t,seed:e.asks.seed,newAccountPubkey:e.asks.publicKey,lamports:e.lowestFeeMarket?101977920:await n.getMinimumBalanceForRentExemption((q=e.orderbookQueueSpace)!=null?q:65536+12),space:(K=e.orderbookQueueSpace)!=null?K:65536+12,programId:e.programId}),ne({programId:e.programId,marketInfo:{id:e.id.publicKey,requestQueue:e.requestQueue.publicKey,eventQueue:e.eventQueue.publicKey,bids:e.bids.publicKey,asks:e.asks.publicKey,baseVault:e.baseVault.publicKey,quoteVault:e.quoteVault.publicKey,baseMint:e.baseMint,quoteMint:e.quoteMint,baseLotSize:e.baseLotSize,quoteLotSize:e.quoteLotSize,feeRateBps:e.feeRateBps,vaultSignerNonce:e.vaultSignerNonce,quoteDustThreshold:e.quoteDustThreshold}})),[{transaction:r,signer:[],instructionTypes:[u.CreateAccount,u.CreateAccount,u.InitAccount,u.InitAccount]},{transaction:c,signer:[],instructionTypes:[u.CreateAccount,u.CreateAccount,u.CreateAccount,u.CreateAccount,u.CreateAccount,u.InitMarket]}]}export{ne as initializeMarket,lt as makeCreateMarketInstruction};
2
2
  //# sourceMappingURL=instrument.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/raydium/marketV2/instrument.ts","../../../src/common/txTool/txType.ts","../../../src/marshmallow/index.ts","../../../src/marshmallow/buffer-layout.ts","../../../src/raydium/marketV2/layout.ts"],"sourcesContent":["import {\n Connection,\n Keypair,\n PublicKey,\n SystemProgram,\n SYSVAR_RENT_PUBKEY,\n Transaction,\n TransactionInstruction,\n} from \"@solana/web3.js\";\nimport BN from \"bn.js\";\nimport { createInitializeAccountInstruction, TOKEN_PROGRAM_ID } from \"@solana/spl-token\";\nimport { InstructionType } from \"@/common/txTool/txType\";\nimport { struct, u16, u32, u64, u8 } from \"../../marshmallow\";\nimport { MARKET_STATE_LAYOUT_V2 } from \"./layout\";\n\ntype Transactions = {\n transaction: Transaction;\n signer?: Keypair[] | undefined;\n instructionTypes?: string[];\n}[];\n\nexport function initializeMarket({\n programId,\n marketInfo,\n}: {\n programId: PublicKey;\n marketInfo: {\n id: PublicKey;\n requestQueue: PublicKey;\n eventQueue: PublicKey;\n bids: PublicKey;\n asks: PublicKey;\n baseVault: PublicKey;\n quoteVault: PublicKey;\n baseMint: PublicKey;\n quoteMint: PublicKey;\n authority?: PublicKey;\n pruneAuthority?: PublicKey;\n\n baseLotSize: BN;\n quoteLotSize: BN;\n feeRateBps: number;\n vaultSignerNonce: BN;\n quoteDustThreshold: BN;\n };\n}): TransactionInstruction {\n const dataLayout = struct([\n u8(\"version\"),\n u32(\"instruction\"),\n u64(\"baseLotSize\"),\n u64(\"quoteLotSize\"),\n u16(\"feeRateBps\"),\n u64(\"vaultSignerNonce\"),\n u64(\"quoteDustThreshold\"),\n ]);\n\n const keys = [\n { pubkey: marketInfo.id, isSigner: false, isWritable: true },\n { pubkey: marketInfo.requestQueue, isSigner: false, isWritable: true },\n { pubkey: marketInfo.eventQueue, isSigner: false, isWritable: true },\n { pubkey: marketInfo.bids, isSigner: false, isWritable: true },\n { pubkey: marketInfo.asks, isSigner: false, isWritable: true },\n { pubkey: marketInfo.baseVault, isSigner: false, isWritable: true },\n { pubkey: marketInfo.quoteVault, isSigner: false, isWritable: true },\n { pubkey: marketInfo.baseMint, isSigner: false, isWritable: false },\n { pubkey: marketInfo.quoteMint, isSigner: false, isWritable: false },\n // Use a dummy address if using the new dex upgrade to save tx space.\n {\n pubkey: marketInfo.authority ? marketInfo.quoteMint : SYSVAR_RENT_PUBKEY,\n isSigner: false,\n isWritable: false,\n },\n ]\n .concat(marketInfo.authority ? { pubkey: marketInfo.authority, isSigner: false, isWritable: false } : [])\n .concat(\n marketInfo.authority && marketInfo.pruneAuthority\n ? { pubkey: marketInfo.pruneAuthority, isSigner: false, isWritable: false }\n : [],\n );\n\n const data = Buffer.alloc(dataLayout.span);\n dataLayout.encode(\n {\n version: 0,\n instruction: 0,\n baseLotSize: marketInfo.baseLotSize,\n quoteLotSize: marketInfo.quoteLotSize,\n feeRateBps: marketInfo.feeRateBps,\n vaultSignerNonce: marketInfo.vaultSignerNonce,\n quoteDustThreshold: marketInfo.quoteDustThreshold,\n },\n data,\n );\n\n return new TransactionInstruction({\n keys,\n programId,\n data,\n });\n}\n\nexport async function makeCreateMarketInstruction({\n connection,\n wallet,\n marketInfo,\n}: {\n connection: Connection;\n wallet: PublicKey;\n marketInfo: {\n programId: PublicKey;\n id: { publicKey: PublicKey; seed: string };\n baseMint: PublicKey;\n quoteMint: PublicKey;\n baseVault: { publicKey: PublicKey; seed: string };\n quoteVault: { publicKey: PublicKey; seed: string };\n vaultOwner: PublicKey;\n\n requestQueue: { publicKey: PublicKey; seed: string };\n eventQueue: { publicKey: PublicKey; seed: string };\n bids: { publicKey: PublicKey; seed: string };\n asks: { publicKey: PublicKey; seed: string };\n\n feeRateBps: number;\n vaultSignerNonce: BN;\n quoteDustThreshold: BN;\n\n baseLotSize: BN;\n quoteLotSize: BN;\n\n requestQueueSpace?: number;\n eventQueueSpace?: number;\n orderbookQueueSpace?: number;\n };\n}): Promise<Transactions> {\n const tx1 = new Transaction();\n const accountLamports = await connection.getMinimumBalanceForRentExemption(165);\n tx1.add(\n SystemProgram.createAccountWithSeed({\n fromPubkey: wallet,\n basePubkey: wallet,\n seed: marketInfo.baseVault.seed,\n newAccountPubkey: marketInfo.baseVault.publicKey,\n lamports: accountLamports,\n space: 165,\n programId: TOKEN_PROGRAM_ID,\n }),\n SystemProgram.createAccountWithSeed({\n fromPubkey: wallet,\n basePubkey: wallet,\n seed: marketInfo.quoteVault.seed,\n newAccountPubkey: marketInfo.quoteVault.publicKey,\n lamports: accountLamports,\n space: 165,\n programId: TOKEN_PROGRAM_ID,\n }),\n createInitializeAccountInstruction(marketInfo.baseVault.publicKey, marketInfo.baseMint, marketInfo.vaultOwner),\n createInitializeAccountInstruction(marketInfo.quoteVault.publicKey, marketInfo.quoteMint, marketInfo.vaultOwner),\n );\n\n const tx2 = new Transaction();\n tx2.add(\n SystemProgram.createAccountWithSeed({\n fromPubkey: wallet,\n basePubkey: wallet,\n seed: marketInfo.id.seed,\n newAccountPubkey: marketInfo.id.publicKey,\n lamports: await connection.getMinimumBalanceForRentExemption(MARKET_STATE_LAYOUT_V2.span),\n space: MARKET_STATE_LAYOUT_V2.span,\n programId: marketInfo.programId,\n }),\n SystemProgram.createAccountWithSeed({\n fromPubkey: wallet,\n basePubkey: wallet,\n seed: marketInfo.requestQueue.seed,\n newAccountPubkey: marketInfo.requestQueue.publicKey,\n lamports: await connection.getMinimumBalanceForRentExemption(marketInfo.requestQueueSpace ?? 5120 + 12),\n space: marketInfo.requestQueueSpace ?? 5120 + 12,\n programId: marketInfo.programId,\n }),\n SystemProgram.createAccountWithSeed({\n fromPubkey: wallet,\n basePubkey: wallet,\n seed: marketInfo.eventQueue.seed,\n newAccountPubkey: marketInfo.eventQueue.publicKey,\n lamports: await connection.getMinimumBalanceForRentExemption(marketInfo.eventQueueSpace ?? 262144 + 12),\n space: marketInfo.eventQueueSpace ?? 262144 + 12,\n programId: marketInfo.programId,\n }),\n SystemProgram.createAccountWithSeed({\n fromPubkey: wallet,\n basePubkey: wallet,\n seed: marketInfo.bids.seed,\n newAccountPubkey: marketInfo.bids.publicKey,\n lamports: await connection.getMinimumBalanceForRentExemption(marketInfo.orderbookQueueSpace ?? 65536 + 12),\n space: marketInfo.orderbookQueueSpace ?? 65536 + 12,\n programId: marketInfo.programId,\n }),\n SystemProgram.createAccountWithSeed({\n fromPubkey: wallet,\n basePubkey: wallet,\n seed: marketInfo.asks.seed,\n newAccountPubkey: marketInfo.asks.publicKey,\n lamports: await connection.getMinimumBalanceForRentExemption(marketInfo.orderbookQueueSpace ?? 65536 + 12),\n space: marketInfo.orderbookQueueSpace ?? 65536 + 12,\n programId: marketInfo.programId,\n }),\n initializeMarket({\n programId: marketInfo.programId,\n marketInfo: {\n id: marketInfo.id.publicKey,\n requestQueue: marketInfo.requestQueue.publicKey,\n eventQueue: marketInfo.eventQueue.publicKey,\n bids: marketInfo.bids.publicKey,\n asks: marketInfo.asks.publicKey,\n baseVault: marketInfo.baseVault.publicKey,\n quoteVault: marketInfo.quoteVault.publicKey,\n baseMint: marketInfo.baseMint,\n quoteMint: marketInfo.quoteMint,\n\n baseLotSize: marketInfo.baseLotSize,\n quoteLotSize: marketInfo.quoteLotSize,\n feeRateBps: marketInfo.feeRateBps,\n vaultSignerNonce: marketInfo.vaultSignerNonce,\n quoteDustThreshold: marketInfo.quoteDustThreshold,\n },\n }),\n );\n\n return [\n {\n transaction: tx1,\n signer: [],\n instructionTypes: [\n InstructionType.CreateAccount,\n InstructionType.CreateAccount,\n InstructionType.InitAccount,\n InstructionType.InitAccount,\n ],\n },\n {\n transaction: tx2,\n signer: [],\n instructionTypes: [\n InstructionType.CreateAccount,\n InstructionType.CreateAccount,\n InstructionType.CreateAccount,\n InstructionType.CreateAccount,\n InstructionType.CreateAccount,\n InstructionType.InitMarket,\n ],\n },\n ];\n}\n","export enum TxVersion {\n \"V0\",\n \"LEGACY\",\n}\n\nexport const InstructionType = {\n CreateAccount: \"CreateAccount\",\n InitAccount: \"InitAccount\",\n CreateATA: \"CreateATA\",\n CloseAccount: \"CloseAccount\",\n TransferAmount: \"TransferAmount\",\n InitMint: \"InitMint\",\n MintTo: \"MintTo\",\n\n InitMarket: \"InitMarket\", // create market main ins\n Util1216OwnerClaim: \"Util1216OwnerClaim\", // owner claim token ins\n\n SetComputeUnitPrice: \"SetComputeUnitPrice\",\n SetComputeUnitLimit: \"SetComputeUnitLimit\",\n\n // CLMM\n ClmmCreatePool: \"ClmmCreatePool\",\n ClmmOpenPosition: \"ClmmOpenPosition\",\n ClmmIncreasePosition: \"ClmmIncreasePosition\",\n ClmmDecreasePosition: \"ClmmDecreasePosition\",\n ClmmClosePosition: \"ClmmClosePosition\",\n ClmmSwapBaseIn: \"ClmmSwapBaseIn\",\n ClmmSwapBaseOut: \"ClmmSwapBaseOut\",\n ClmmInitReward: \"ClmmInitReward\",\n ClmmSetReward: \"ClmmSetReward\",\n ClmmCollectReward: \"ClmmCollectReward\",\n ClmmLockPosition: \"ClmmLockPosition\",\n ClmmHarvestLockPosition: \"ClmmHarvestLockPosition\",\n\n AmmV4Swap: \"AmmV4Swap\",\n AmmV4AddLiquidity: \"AmmV4AddLiquidity\",\n AmmV4RemoveLiquidity: \"AmmV4RemoveLiquidity\",\n AmmV4SimulatePoolInfo: \"AmmV4SimulatePoolInfo\",\n AmmV4SwapBaseIn: \"AmmV4SwapBaseIn\",\n AmmV4SwapBaseOut: \"AmmV4SwapBaseOut\",\n AmmV4CreatePool: \"AmmV4CreatePool\",\n AmmV4InitPool: \"AmmV4InitPool\",\n\n AmmV5AddLiquidity: \"AmmV5AddLiquidity\",\n AmmV5RemoveLiquidity: \"AmmV5RemoveLiquidity\",\n AmmV5SimulatePoolInfo: \"AmmV5SimulatePoolInfo\",\n AmmV5SwapBaseIn: \"AmmV5SwapBaseIn\",\n AmmV5SwapBaseOut: \"AmmV5SwapBaseOut\",\n\n RouteSwap: \"RouteSwap\",\n RouteSwap1: \"RouteSwap1\",\n RouteSwap2: \"RouteSwap2\",\n\n FarmV3Deposit: \"FarmV3Deposit\",\n FarmV3Withdraw: \"FarmV3Withdraw\",\n FarmV3CreateLedger: \"FarmV3CreateLedger\",\n\n FarmV5Deposit: \"FarmV5Deposit\",\n FarmV5Withdraw: \"FarmV5Withdraw\",\n FarmV5CreateLedger: \"FarmV5CreateLedger\",\n\n FarmV6Deposit: \"FarmV6Deposit\",\n FarmV6Withdraw: \"FarmV6Withdraw\",\n FarmV6Create: \"FarmV6Create\",\n FarmV6Restart: \"FarmV6Restart\",\n FarmV6CreatorAddReward: \"FarmV6CreatorAddReward\",\n FarmV6CreatorWithdraw: \"FarmV6CreatorWithdraw\",\n\n CpmmCreatePool: \"CpmmCreatePool\",\n CpmmAddLiquidity: \"CpmmAddLiquidity\",\n CpmmWithdrawLiquidity: \"CpmmWithdrawLiquidity\",\n CpmmSwapBaseIn: \"CpmmSwapBaseIn\",\n CpmmSwapBaseOut: \"CpmmSwapBaseOut\",\n\n CpmmLockLp: \"CpmmLockLp\",\n CpmmCollectLockFee: \"CpmmCollectLockFee\",\n};\n","import { PublicKey } from \"@solana/web3.js\";\nimport BN, { isBN } from \"bn.js\";\n\nimport {\n bits,\n blob,\n Blob,\n Layout,\n offset as _offset,\n seq as _seq,\n Structure as _Structure,\n u32 as _u32,\n u8 as _u8,\n UInt,\n union as _union,\n Union as _Union,\n} from \"./buffer-layout\";\n\nexport * from \"./buffer-layout\";\nexport { blob };\n\nexport class BNLayout<P extends string = \"\"> extends Layout<BN, P> {\n blob: Layout<Buffer>;\n signed: boolean;\n\n constructor(span: number, signed: boolean, property?: P) {\n //@ts-expect-error type wrong for super()'s type different from extends, but it desn't matter\n super(span, property);\n this.blob = blob(span);\n this.signed = signed;\n }\n\n /** @override */\n decode(b: Buffer, offset = 0): BN {\n const num = new BN(this.blob.decode(b, offset), 10, \"le\");\n if (this.signed) {\n return num.fromTwos(this.span * 8).clone();\n }\n return num;\n }\n\n /** @override */\n encode(src: BN, b: Buffer, offset = 0): number {\n if (typeof src === \"number\") src = new BN(src); // src will pass a number accidently in union\n if (this.signed) {\n src = src.toTwos(this.span * 8);\n }\n return this.blob.encode(src.toArrayLike(Buffer, \"le\", this.span), b, offset);\n }\n}\n\nexport class WideBits<P extends string = \"\"> extends Layout<Record<string, boolean>, P> {\n _lower: any;\n _upper: any;\n // TODO: unknown\n constructor(property?: P) {\n //@ts-expect-error type wrong for super()'s type different from extends , but it desn't matter\n super(8, property);\n this._lower = bits(_u32(), false);\n this._upper = bits(_u32(), false);\n }\n\n addBoolean(property: string): void {\n if (this._lower.fields.length < 32) {\n this._lower.addBoolean(property);\n } else {\n this._upper.addBoolean(property);\n }\n }\n\n decode(b: Buffer, offset = 0): Record<string, boolean> {\n const lowerDecoded = this._lower.decode(b, offset);\n const upperDecoded = this._upper.decode(b, offset + this._lower.span);\n return { ...lowerDecoded, ...upperDecoded };\n }\n\n encode(src: any /* TEMP */, b: Buffer, offset = 0): any {\n return this._lower.encode(src, b, offset) + this._upper.encode(src, b, offset + this._lower.span);\n }\n}\n\nexport function u8<P extends string = \"\">(property?: P): UInt<number, P> {\n return new UInt(1, property);\n}\n\nexport function u32<P extends string = \"\">(property?: P): UInt<number, P> {\n return new UInt(4, property);\n}\n\nexport function u64<P extends string = \"\">(property?: P): BNLayout<P> {\n return new BNLayout(8, false, property);\n}\n\nexport function u128<P extends string = \"\">(property?: P): BNLayout<P> {\n return new BNLayout(16, false, property);\n}\n\nexport function i8<P extends string = \"\">(property?: P): BNLayout<P> {\n return new BNLayout(1, true, property);\n}\n\nexport function i64<P extends string = \"\">(property?: P): BNLayout<P> {\n return new BNLayout(8, true, property);\n}\n\nexport function i128<P extends string = \"\">(property?: P): BNLayout<P> {\n return new BNLayout(16, true, property);\n}\n\nexport class WrappedLayout<T, U, P extends string = \"\"> extends Layout<U, P> {\n layout: Layout<T>;\n decoder: (data: T) => U;\n encoder: (src: U) => T;\n\n constructor(layout: Layout<T>, decoder: (data: T) => U, encoder: (src: U) => T, property?: P) {\n //@ts-expect-error type wrong for super()'s type different from extends , but it desn't matter\n super(layout.span, property);\n this.layout = layout;\n this.decoder = decoder;\n this.encoder = encoder;\n }\n\n decode(b: Buffer, offset?: number): U {\n return this.decoder(this.layout.decode(b, offset));\n }\n\n encode(src: U, b: Buffer, offset?: number): number {\n return this.layout.encode(this.encoder(src), b, offset);\n }\n\n getSpan(b: Buffer, offset?: number): number {\n return this.layout.getSpan(b, offset);\n }\n}\n\nexport function publicKey<P extends string = \"\">(property?: P): Layout<PublicKey, P> {\n return new WrappedLayout(\n blob(32),\n (b: Buffer) => new PublicKey(b),\n (key: PublicKey) => key.toBuffer(),\n property,\n );\n}\n\nexport class OptionLayout<T, P> extends Layout<T | null, P> {\n layout: Layout<T>;\n discriminator: Layout<number>;\n\n constructor(layout: Layout<T>, property?: P) {\n //@ts-expect-error type wrong for super()'s type different from extends , but it desn't matter\n super(-1, property);\n this.layout = layout;\n this.discriminator = _u8();\n }\n\n encode(src: T | null, b: Buffer, offset = 0): number {\n if (src === null || src === undefined) {\n return this.discriminator.encode(0, b, offset);\n }\n this.discriminator.encode(1, b, offset);\n return this.layout.encode(src, b, offset + 1) + 1;\n }\n\n decode(b: Buffer, offset = 0): T | null {\n const discriminator = this.discriminator.decode(b, offset);\n if (discriminator === 0) {\n return null;\n } else if (discriminator === 1) {\n return this.layout.decode(b, offset + 1);\n }\n throw new Error(\"Invalid option \" + this.property);\n }\n\n getSpan(b: Buffer, offset = 0): number {\n const discriminator = this.discriminator.decode(b, offset);\n if (discriminator === 0) {\n return 1;\n } else if (discriminator === 1) {\n return this.layout.getSpan(b, offset + 1) + 1;\n }\n throw new Error(\"Invalid option \" + this.property);\n }\n}\n\nexport function option<T, P extends string = \"\">(layout: Layout<T>, property?: P): Layout<T | null, P> {\n return new OptionLayout<T, P>(layout, property);\n}\n\nexport function bool<P extends string = \"\">(property?: P): Layout<boolean, P> {\n return new WrappedLayout(_u8(), decodeBool, encodeBool, property);\n}\n\nexport function decodeBool(value: number): boolean {\n if (value === 0) {\n return false;\n } else if (value === 1) {\n return true;\n }\n throw new Error(\"Invalid bool: \" + value);\n}\n\nexport function encodeBool(value: boolean): number {\n return value ? 1 : 0;\n}\n\nexport function vec<T, P extends string = \"\">(elementLayout: Layout<T>, property?: P): Layout<T[], P> {\n const length = _u32(\"length\");\n const layout: Layout<{ values: T[] }> = struct([\n length,\n seq(elementLayout, _offset(length, -length.span), \"values\"),\n ]) as any; // Something I don't know\n return new WrappedLayout(\n layout,\n ({ values }) => values,\n (values) => ({ values }),\n property,\n );\n}\n\nexport function tagged<T, P extends string = \"\">(tag: BN, layout: Layout<T>, property?: P): Layout<T, P> {\n const wrappedLayout: Layout<{ tag: BN; data: T }> = struct([u64(\"tag\"), layout.replicate(\"data\")]) as any; // Something I don't know\n\n function decodeTag({ tag: receivedTag, data }: { tag: BN; data: T }): T {\n if (!receivedTag.eq(tag)) {\n throw new Error(\"Invalid tag, expected: \" + tag.toString(\"hex\") + \", got: \" + receivedTag.toString(\"hex\"));\n }\n return data;\n }\n\n return new WrappedLayout(wrappedLayout, decodeTag, (data) => ({ tag, data }), property);\n}\n\nexport function vecU8<P extends string = \"\">(property?: P): Layout<Buffer, P> {\n const length = _u32(\"length\");\n const layout: Layout<{ data: Buffer }> = struct([length, blob(_offset(length, -length.span), \"data\")]) as any; // Something I don't know\n return new WrappedLayout(\n layout,\n ({ data }) => data,\n (data) => ({ data }),\n property,\n );\n}\n\nexport function str<P extends string = \"\">(property?: P): Layout<string, P> {\n return new WrappedLayout(\n vecU8(),\n (data) => data.toString(\"utf-8\"),\n (s) => Buffer.from(s, \"utf-8\"),\n property,\n );\n}\n\nexport interface EnumLayout<T, P extends string = \"\"> extends Layout<T, P> {\n registry: Record<string, Layout<any>>;\n}\n\nexport function rustEnum<T, P extends string = \"\">(variants: Layout<any>[], property?: P): EnumLayout<T, P> {\n const unionLayout = _union(_u8(), property);\n variants.forEach((variant, index) => unionLayout.addVariant(index, variant, variant.property));\n return unionLayout as any; // ?why use UnionLayout? This must be a fault\n}\n\nexport function array<T, P extends string = \"\">(\n elementLayout: Layout<T>,\n length: number,\n property?: P,\n): Layout<T[], P> {\n const layout = struct([seq(elementLayout, length, \"values\")]) as any as Layout<{ values: T[] }>; // Something I don't know\n return new WrappedLayout(\n layout,\n ({ values }) => values,\n (values) => ({ values }),\n property,\n );\n}\n\nexport class Structure<T, P, D extends { [key: string]: any; }> extends _Structure<T, P, D> {\n /** @override */\n decode(b: Buffer, offset?: number): D {\n return super.decode(b, offset);\n }\n}\n\nexport function struct<T, P extends string = \"\">(\n fields: T,\n property?: P,\n decodePrefixes?: boolean,\n): T extends Layout<infer Value, infer Property>[]\n ? Structure<\n Value,\n P,\n {\n [K in Exclude<Extract<Property, string>, \"\">]: Extract<T[number], Layout<any, K>> extends Layout<infer V, any>\n ? V\n : any;\n }\n >\n : any {\n //@ts-expect-error this type is not quite satisfied the define, but, never no need to worry about.\n return new Structure(fields, property, decodePrefixes);\n}\n\nexport type GetLayoutSchemaFromStructure<T extends Structure<any, any, any>> = T extends Structure<any, any, infer S>\n ? S\n : any;\nexport type GetStructureFromLayoutSchema<S extends { [key: string]: any; }> = Structure<any, any, S>;\n\nexport class Union<Schema extends { [key: string]: any; }> extends _Union<Schema> {\n encodeInstruction(instruction: any): Buffer {\n const instructionMaxSpan = Math.max(...Object.values(this.registry).map((r) => r.span));\n const b = Buffer.alloc(instructionMaxSpan);\n return b.slice(0, this.encode(instruction, b));\n }\n\n decodeInstruction(instruction: any): Partial<Schema> {\n return this.decode(instruction);\n }\n}\nexport function union<UnionSchema extends { [key: string]: any } = any>(\n discr: any,\n defaultLayout?: any,\n property?: string,\n): Union<UnionSchema> {\n return new Union(discr, defaultLayout, property);\n}\n\nclass Zeros extends Blob {\n decode(b: Buffer, offset: number): Buffer {\n const slice = super.decode(b, offset);\n if (!slice.every((v) => v === 0)) {\n throw new Error(\"nonzero padding bytes\");\n }\n return slice;\n }\n}\n\nexport function zeros(length: number): Zeros {\n return new Zeros(length);\n}\n\nexport function seq<T, P extends string = \"\", AnotherP extends string = \"\">(\n elementLayout: Layout<T, P>,\n count: number | BN | Layout<BN | number, P>,\n property?: AnotherP,\n): Layout<T[], AnotherP> {\n let parsedCount: number;\n const superCount =\n typeof count === \"number\"\n ? count\n : isBN(count)\n ? count.toNumber()\n : new Proxy(count as unknown as Layout<number> /* pretend to be Layout<number> */, {\n get(target, property): any {\n if (!parsedCount) {\n // get count in targetLayout. note that count may be BN\n const countProperty = Reflect.get(target, \"count\");\n\n // let targetLayout's property:count be a number\n parsedCount = isBN(countProperty) ? countProperty.toNumber() : countProperty;\n\n // record the count\n Reflect.set(target, \"count\", parsedCount);\n }\n return Reflect.get(target, property);\n },\n set(target, property, value): any {\n if (property === \"count\") {\n parsedCount = value;\n }\n return Reflect.set(target, property, value);\n },\n });\n\n // @ts-expect-error force type\n return _seq(elementLayout, superCount, property);\n}\n","import {\n bits as _bits,\n BitStructure as _BitStructure,\n blob as _blob,\n Blob as _Blob,\n cstr as _cstr,\n f32 as _f32,\n f32be as _f32be,\n f64 as _f64,\n f64be as _f64be,\n greedy as _greedy,\n Layout as _Layout,\n ns64 as _ns64,\n ns64be as _ns64be,\n nu64 as _nu64,\n nu64be as _nu64be,\n offset as _offset,\n s16 as _s16,\n s16be as _s16be,\n s24 as _s24,\n s24be as _s24be,\n s32 as _s32,\n s32be as _s32be,\n s40 as _s40,\n s40be as _s40be,\n s48 as _s48,\n s48be as _s48be,\n s8 as _s8,\n seq as _seq,\n struct as _struct,\n Structure as _Structure,\n u16 as _u16,\n u16be as _u16be,\n u24 as _u24,\n u24be as _u24be,\n u32 as _u32,\n u32be as _u32be,\n u40 as _u40,\n u40be as _u40be,\n u48 as _u48,\n u48be as _u48be,\n u8 as _u8,\n UInt as _UInt,\n union as _union,\n Union as _Union,\n unionLayoutDiscriminator as _unionLayoutDiscriminator,\n utf8 as _utf8,\n} from \"@solana/buffer-layout\";\n\n//#region ------------------- Layout -------------------\nexport interface Layout<T = any, P = \"\"> {\n span: number;\n property?: P;\n decode(b: Buffer, offset?: number): T;\n encode(src: T, b: Buffer, offset?: number): number;\n getSpan(b: Buffer, offset?: number): number;\n replicate<AP extends string>(name: AP): Layout<T, AP>;\n}\nexport interface LayoutConstructor {\n new <T, P>(): Layout<T, P>; // for class extends syntex\n new <T, P>(span?: T, property?: P): Layout<T, P>;\n readonly prototype: Layout;\n}\nexport const Layout = _Layout as unknown as LayoutConstructor;\n//#endregion\n\n//#region ------------------- Structure -------------------\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nexport interface Structure<T = any, P = \"\", DecodeSchema extends { [key: string]: any } = any>\n extends Layout<DecodeSchema, P> {\n span: number;\n decode(b: Buffer, offset?: number): DecodeSchema;\n layoutFor<AP extends string>(property: AP): Layout<DecodeSchema[AP]>;\n offsetOf<AP extends string>(property: AP): number;\n}\ninterface StructureConstructor {\n new <T = any, P = \"\", DecodeSchema extends { [key: string]: any } = any>(): Structure<T, P, DecodeSchema>;\n new <T = any, P = \"\", DecodeSchema extends { [key: string]: any } = any>(\n fields: T,\n property?: P,\n decodePrefixes?: boolean,\n ): Structure<T, P, DecodeSchema>;\n}\nexport const Structure = _Structure as unknown as StructureConstructor;\n//#endregion\n\n//#region ------------------- Union -------------------\nexport interface Union<UnionSchema extends { [key: string]: any } = any> extends Layout {\n registry: object;\n decode(b: Buffer, offset?: number): Partial<UnionSchema>;\n addVariant(\n variant: number,\n layout: Structure<any, any, Partial<UnionSchema>> | Layout<any, keyof UnionSchema>,\n property?: string,\n ): any /* TEMP: code in Layout.js 1809 */;\n}\ninterface UnionConstructor {\n new <UnionSchema extends { [key: string]: any } = any>(): Union<UnionSchema>;\n new <UnionSchema extends { [key: string]: any } = any>(\n discr: Layout<any, any>,\n defaultLayout: Layout<any, any>,\n property?: string,\n ): Union<UnionSchema>;\n}\nexport const Union = _Union as unknown as UnionConstructor;\n//#endregion\n\n//#region ------------------- BitStructure -------------------\nexport type BitStructure<T = unknown /* TEMP */, P = \"\"> = Layout<T, P>;\ninterface BitStructureConstructor {\n new (...params: any[]): BitStructure;\n}\nexport const BitStructure = _BitStructure as BitStructureConstructor;\n//#endregion\n\n//#region ------------------- UInt -------------------\nexport type UInt<T = any, P = \"\"> = Layout<T, P>;\ninterface UIntConstructor {\n new <T, P>(span?: T, property?: P): UInt<T, P>;\n}\nexport const UInt = _UInt as UIntConstructor;\n//#endregion\n\n//#region ------------------- Blob -------------------\nexport type Blob<P extends string = \"\"> = Layout<Buffer, P>;\ninterface BlobConstructor {\n new (...params: ConstructorParameters<LayoutConstructor>): Blob;\n}\nexport const Blob = _Blob as unknown as BlobConstructor;\n//#endregion\n\nexport const greedy = _greedy as <P extends string = \"\">(elementSpan?: number, property?: P) => Layout<number, P>;\nexport const u8 = _u8 as <P extends string = \"\">(property?: P) => Layout<number, P>;\nexport const u16 = _u16 as <P extends string = \"\">(property?: P) => Layout<number, P>;\nexport const u24 = _u24 as <P extends string = \"\">(property?: P) => Layout<number, P>;\nexport const u32 = _u32 as <P extends string = \"\">(property?: P) => Layout<number, P>;\nexport const u40 = _u40 as <P extends string = \"\">(property?: P) => Layout<number, P>;\nexport const u48 = _u48 as <P extends string = \"\">(property?: P) => Layout<number, P>;\nexport const nu64 = _nu64 as <P extends string = \"\">(property?: P) => Layout<number, P>;\nexport const u16be = _u16be as <P extends string = \"\">(property?: P) => Layout<number, P>;\nexport const u24be = _u24be as <P extends string = \"\">(property?: P) => Layout<number, P>;\nexport const u32be = _u32be as <P extends string = \"\">(property?: P) => Layout<number, P>;\nexport const u40be = _u40be as <P extends string = \"\">(property?: P) => Layout<number, P>;\nexport const u48be = _u48be as <P extends string = \"\">(property?: P) => Layout<number, P>;\nexport const nu64be = _nu64be as <P extends string = \"\">(property?: P) => Layout<number, P>;\nexport const s8 = _s8 as <P extends string = \"\">(property?: P) => Layout<number, P>;\nexport const s16 = _s16 as <P extends string = \"\">(property?: P) => Layout<number, P>;\nexport const s24 = _s24 as <P extends string = \"\">(property?: P) => Layout<number, P>;\nexport const s32 = _s32 as <P extends string = \"\">(property?: P) => Layout<number, P>;\nexport const s40 = _s40 as <P extends string = \"\">(property?: P) => Layout<number, P>;\nexport const s48 = _s48 as <P extends string = \"\">(property?: P) => Layout<number, P>;\nexport const ns64 = _ns64 as <P extends string = \"\">(property?: P) => Layout<number, P>;\nexport const s16be = _s16be as <P extends string = \"\">(property?: P) => Layout<number, P>;\nexport const s24be = _s24be as <P extends string = \"\">(property?: P) => Layout<number, P>;\nexport const s32be = _s32be as <P extends string = \"\">(property?: P) => Layout<number, P>;\nexport const s40be = _s40be as <P extends string = \"\">(property?: P) => Layout<number, P>;\nexport const s48be = _s48be as <P extends string = \"\">(property?: P) => Layout<number, P>;\nexport const ns64be = _ns64be as <P extends string = \"\">(property?: P) => Layout<number, P>;\nexport const f32 = _f32 as <P extends string = \"\">(property?: P) => Layout<number, P>;\nexport const f32be = _f32be as <P extends string = \"\">(property?: P) => Layout<number, P>;\nexport const f64 = _f64 as <P extends string = \"\">(property?: P) => Layout<number, P>;\nexport const f64be = _f64be as <P extends string = \"\">(property?: P) => Layout<number, P>;\n\nexport const struct = _struct as <T, P extends string = \"\">(\n fields: T,\n property?: P,\n decodePrefixes?: boolean,\n) => T extends Layout<infer Value, infer Property>[]\n ? Structure<\n Value,\n P,\n {\n [K in Exclude<Extract<Property, string>, \"\">]: Extract<T[number], Layout<any, K>> extends Layout<infer V, any>\n ? V\n : any;\n }\n >\n : any;\n\nexport const seq = _seq as unknown as <T, P>(\n elementLayout: Layout<T, string>,\n count: number | Layout<number, string>,\n property?: P,\n) => Layout<T[]>;\nexport const union = _union as <UnionSchema extends { [key: string]: any } = any>(\n discr: Layout<any, any>,\n defaultLayout?: any,\n property?: string,\n) => Union<UnionSchema>;\nexport const unionLayoutDiscriminator = _unionLayoutDiscriminator as <P extends string = \"\">(\n layout: Layout<any, P>,\n property?: P,\n) => any;\nexport const blob = _blob as unknown as <P extends string = \"\">(\n length: number | Layout<number, P>,\n property?: P,\n) => Blob<P>;\nexport const cstr = _cstr as <P extends string = \"\">(property?: P) => Layout<string, P>;\nexport const utf8 = _utf8 as <P extends string = \"\">(maxSpan: number, property?: P) => Layout<string, P>;\nexport const bits = _bits as unknown as <T, P extends string = \"\">(\n word: Layout<T>,\n msb?: boolean,\n property?: P,\n) => BitStructure<T, P>; // TODO: not quite sure\nexport const offset = _offset as unknown as <T, P extends string = \"\">(\n layout: Layout<T, P>,\n offset?: number,\n property?: P,\n) => Layout<T, P>;\n\nexport type GetStructureSchema<T extends Structure> = T extends Structure<any, any, infer S> ? S : unknown;\n","import { blob, publicKey, struct, u64, WideBits } from \"../../marshmallow\";\n\nfunction accountFlagsLayout(property = \"accountFlags\"): WideBits<string> {\n const ACCOUNT_FLAGS_LAYOUT = new WideBits(property);\n ACCOUNT_FLAGS_LAYOUT.addBoolean(\"initialized\");\n ACCOUNT_FLAGS_LAYOUT.addBoolean(\"market\");\n ACCOUNT_FLAGS_LAYOUT.addBoolean(\"openOrders\");\n ACCOUNT_FLAGS_LAYOUT.addBoolean(\"requestQueue\");\n ACCOUNT_FLAGS_LAYOUT.addBoolean(\"eventQueue\");\n ACCOUNT_FLAGS_LAYOUT.addBoolean(\"bids\");\n ACCOUNT_FLAGS_LAYOUT.addBoolean(\"asks\");\n return ACCOUNT_FLAGS_LAYOUT;\n}\n\nexport const MARKET_STATE_LAYOUT_V2 = struct([\n blob(5),\n accountFlagsLayout(\"accountFlags\"),\n publicKey(\"ownAddress\"),\n u64(\"vaultSignerNonce\"),\n publicKey(\"baseMint\"),\n publicKey(\"quoteMint\"),\n publicKey(\"baseVault\"),\n u64(\"baseDepositsTotal\"),\n u64(\"baseFeesAccrued\"),\n publicKey(\"quoteVault\"),\n u64(\"quoteDepositsTotal\"),\n u64(\"quoteFeesAccrued\"),\n u64(\"quoteDustThreshold\"),\n publicKey(\"requestQueue\"),\n publicKey(\"eventQueue\"),\n publicKey(\"bids\"),\n publicKey(\"asks\"),\n u64(\"baseLotSize\"),\n u64(\"quoteLotSize\"),\n u64(\"feeRateBps\"),\n u64(\"referrerRebatesAccrued\"),\n blob(7),\n]);\n"],"mappings":"yVAAA,uHAUA,6FCLO,GAAM,GAAkB,CAC7B,cAAe,gBACf,YAAa,cACb,UAAW,YACX,aAAc,eACd,eAAgB,iBAChB,SAAU,WACV,OAAQ,SAER,WAAY,aACZ,mBAAoB,qBAEpB,oBAAqB,sBACrB,oBAAqB,sBAGrB,eAAgB,iBAChB,iBAAkB,mBAClB,qBAAsB,uBACtB,qBAAsB,uBACtB,kBAAmB,oBACnB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AAkC,MAAQ,EAAE,EACzG,MAAO,KAAW,sBAAX,OAAkC,MAAQ,GACjD,UAAW,EAAW,SACxB,CAAC,EACD,EAAc,sBAAsB,CAClC,WAAY,EACZ,WAAY,EACZ,KAAM,EAAW,KAAK,KACtB,iBAAkB,EAAW,KAAK,UAClC,SAAU,KAAM,GAAW,kCAAkC,KAAW,sBAAX,OAAkC,MAAQ,EAAE,EACzG,MAAO,KAAW,sBAAX,OAAkC,MAAQ,GACjD,UAAW,EAAW,SACxB,CAAC,EACD,GAAiB,CACf,UAAW,EAAW,UACtB,WAAY,CACV,GAAI,EAAW,GAAG,UAClB,aAAc,EAAW,aAAa,UACtC,WAAY,EAAW,WAAW,UAClC,KAAM,EAAW,KAAK,UACtB,KAAM,EAAW,KAAK,UACtB,UAAW,EAAW,UAAU,UAChC,WAAY,EAAW,WAAW,UAClC,SAAU,EAAW,SACrB,UAAW,EAAW,UAEtB,YAAa,EAAW,YACxB,aAAc,EAAW,aACzB,WAAY,EAAW,WACvB,iBAAkB,EAAW,iBAC7B,mBAAoB,EAAW,kBACjC,CACF,CAAC,CACH,EAEO,CACL,CACE,YAAa,EACb,OAAQ,CAAC,EACT,iBAAkB,CAChB,EAAgB,cAChB,EAAgB,cAChB,EAAgB,YAChB,EAAgB,WAClB,CACF,EACA,CACE,YAAa,EACb,OAAQ,CAAC,EACT,iBAAkB,CAChB,EAAgB,cAChB,EAAgB,cAChB,EAAgB,cAChB,EAAgB,cAChB,EAAgB,cAChB,EAAgB,UAClB,CACF,CACF,CACF","names":[]}
1
+ {"version":3,"sources":["../../../src/raydium/marketV2/instrument.ts","../../../src/common/txTool/txType.ts","../../../src/marshmallow/index.ts","../../../src/marshmallow/buffer-layout.ts","../../../src/raydium/marketV2/layout.ts"],"sourcesContent":["import {\n Connection,\n Keypair,\n PublicKey,\n SystemProgram,\n SYSVAR_RENT_PUBKEY,\n Transaction,\n TransactionInstruction,\n} from \"@solana/web3.js\";\nimport BN from \"bn.js\";\nimport { createInitializeAccountInstruction, TOKEN_PROGRAM_ID } from \"@solana/spl-token\";\nimport { InstructionType } from \"@/common/txTool/txType\";\nimport { struct, u16, u32, u64, u8 } from \"../../marshmallow\";\nimport { MARKET_STATE_LAYOUT_V2 } from \"./layout\";\n\ntype Transactions = {\n transaction: Transaction;\n signer?: Keypair[] | undefined;\n instructionTypes?: string[];\n}[];\n\nexport function initializeMarket({\n programId,\n marketInfo,\n}: {\n programId: PublicKey;\n marketInfo: {\n id: PublicKey;\n requestQueue: PublicKey;\n eventQueue: PublicKey;\n bids: PublicKey;\n asks: PublicKey;\n baseVault: PublicKey;\n quoteVault: PublicKey;\n baseMint: PublicKey;\n quoteMint: PublicKey;\n authority?: PublicKey;\n pruneAuthority?: PublicKey;\n\n baseLotSize: BN;\n quoteLotSize: BN;\n feeRateBps: number;\n vaultSignerNonce: BN;\n quoteDustThreshold: BN;\n };\n}): TransactionInstruction {\n const dataLayout = struct([\n u8(\"version\"),\n u32(\"instruction\"),\n u64(\"baseLotSize\"),\n u64(\"quoteLotSize\"),\n u16(\"feeRateBps\"),\n u64(\"vaultSignerNonce\"),\n u64(\"quoteDustThreshold\"),\n ]);\n\n const keys = [\n { pubkey: marketInfo.id, isSigner: false, isWritable: true },\n { pubkey: marketInfo.requestQueue, isSigner: false, isWritable: true },\n { pubkey: marketInfo.eventQueue, isSigner: false, isWritable: true },\n { pubkey: marketInfo.bids, isSigner: false, isWritable: true },\n { pubkey: marketInfo.asks, isSigner: false, isWritable: true },\n { pubkey: marketInfo.baseVault, isSigner: false, isWritable: true },\n { pubkey: marketInfo.quoteVault, isSigner: false, isWritable: true },\n { pubkey: marketInfo.baseMint, isSigner: false, isWritable: false },\n { pubkey: marketInfo.quoteMint, isSigner: false, isWritable: false },\n // Use a dummy address if using the new dex upgrade to save tx space.\n {\n pubkey: marketInfo.authority ? marketInfo.quoteMint : SYSVAR_RENT_PUBKEY,\n isSigner: false,\n isWritable: false,\n },\n ]\n .concat(marketInfo.authority ? { pubkey: marketInfo.authority, isSigner: false, isWritable: false } : [])\n .concat(\n marketInfo.authority && marketInfo.pruneAuthority\n ? { pubkey: marketInfo.pruneAuthority, isSigner: false, isWritable: false }\n : [],\n );\n\n const data = Buffer.alloc(dataLayout.span);\n dataLayout.encode(\n {\n version: 0,\n instruction: 0,\n baseLotSize: marketInfo.baseLotSize,\n quoteLotSize: marketInfo.quoteLotSize,\n feeRateBps: marketInfo.feeRateBps,\n vaultSignerNonce: marketInfo.vaultSignerNonce,\n quoteDustThreshold: marketInfo.quoteDustThreshold,\n },\n data,\n );\n\n return new TransactionInstruction({\n keys,\n programId,\n data,\n });\n}\n\nexport async function makeCreateMarketInstruction({\n connection,\n wallet,\n marketInfo,\n}: {\n connection: Connection;\n wallet: PublicKey;\n marketInfo: {\n programId: PublicKey;\n id: { publicKey: PublicKey; seed: string };\n baseMint: PublicKey;\n quoteMint: PublicKey;\n baseVault: { publicKey: PublicKey; seed: string };\n quoteVault: { publicKey: PublicKey; seed: string };\n vaultOwner: PublicKey;\n\n requestQueue: { publicKey: PublicKey; seed: string };\n eventQueue: { publicKey: PublicKey; seed: string };\n bids: { publicKey: PublicKey; seed: string };\n asks: { publicKey: PublicKey; seed: string };\n\n feeRateBps: number;\n vaultSignerNonce: BN;\n quoteDustThreshold: BN;\n\n baseLotSize: BN;\n quoteLotSize: BN;\n\n requestQueueSpace?: number;\n eventQueueSpace?: number;\n orderbookQueueSpace?: number;\n\n lowestFeeMarket?: boolean;\n };\n}): Promise<Transactions> {\n const tx1 = new Transaction();\n const accountLamports = await connection.getMinimumBalanceForRentExemption(165);\n tx1.add(\n SystemProgram.createAccountWithSeed({\n fromPubkey: wallet,\n basePubkey: wallet,\n seed: marketInfo.baseVault.seed,\n newAccountPubkey: marketInfo.baseVault.publicKey,\n lamports: accountLamports,\n space: 165,\n programId: TOKEN_PROGRAM_ID,\n }),\n SystemProgram.createAccountWithSeed({\n fromPubkey: wallet,\n basePubkey: wallet,\n seed: marketInfo.quoteVault.seed,\n newAccountPubkey: marketInfo.quoteVault.publicKey,\n lamports: accountLamports,\n space: 165,\n programId: TOKEN_PROGRAM_ID,\n }),\n createInitializeAccountInstruction(marketInfo.baseVault.publicKey, marketInfo.baseMint, marketInfo.vaultOwner),\n createInitializeAccountInstruction(marketInfo.quoteVault.publicKey, marketInfo.quoteMint, marketInfo.vaultOwner),\n );\n\n const tx2 = new Transaction();\n tx2.add(\n SystemProgram.createAccountWithSeed({\n fromPubkey: wallet,\n basePubkey: wallet,\n seed: marketInfo.id.seed,\n newAccountPubkey: marketInfo.id.publicKey,\n lamports: await connection.getMinimumBalanceForRentExemption(MARKET_STATE_LAYOUT_V2.span),\n space: MARKET_STATE_LAYOUT_V2.span,\n programId: marketInfo.programId,\n }),\n SystemProgram.createAccountWithSeed({\n fromPubkey: wallet,\n basePubkey: wallet,\n seed: marketInfo.requestQueue.seed,\n newAccountPubkey: marketInfo.requestQueue.publicKey,\n lamports: marketInfo.lowestFeeMarket\n ? 6208320\n : await connection.getMinimumBalanceForRentExemption(marketInfo.requestQueueSpace ?? 5120 + 12),\n space: marketInfo.requestQueueSpace ?? 5120 + 12,\n programId: marketInfo.programId,\n }),\n SystemProgram.createAccountWithSeed({\n fromPubkey: wallet,\n basePubkey: wallet,\n seed: marketInfo.eventQueue.seed,\n newAccountPubkey: marketInfo.eventQueue.publicKey,\n lamports: marketInfo.lowestFeeMarket\n ? 79594560\n : await connection.getMinimumBalanceForRentExemption(marketInfo.eventQueueSpace ?? 262144 + 12),\n space: marketInfo.eventQueueSpace ?? 262144 + 12,\n programId: marketInfo.programId,\n }),\n SystemProgram.createAccountWithSeed({\n fromPubkey: wallet,\n basePubkey: wallet,\n seed: marketInfo.bids.seed,\n newAccountPubkey: marketInfo.bids.publicKey,\n lamports: marketInfo.lowestFeeMarket\n ? 101977920\n : await connection.getMinimumBalanceForRentExemption(marketInfo.orderbookQueueSpace ?? 65536 + 12),\n space: marketInfo.orderbookQueueSpace ?? 65536 + 12,\n programId: marketInfo.programId,\n }),\n SystemProgram.createAccountWithSeed({\n fromPubkey: wallet,\n basePubkey: wallet,\n seed: marketInfo.asks.seed,\n newAccountPubkey: marketInfo.asks.publicKey,\n lamports: marketInfo.lowestFeeMarket\n ? 101977920\n : await connection.getMinimumBalanceForRentExemption(marketInfo.orderbookQueueSpace ?? 65536 + 12),\n space: marketInfo.orderbookQueueSpace ?? 65536 + 12,\n programId: marketInfo.programId,\n }),\n initializeMarket({\n programId: marketInfo.programId,\n marketInfo: {\n id: marketInfo.id.publicKey,\n requestQueue: marketInfo.requestQueue.publicKey,\n eventQueue: marketInfo.eventQueue.publicKey,\n bids: marketInfo.bids.publicKey,\n asks: marketInfo.asks.publicKey,\n baseVault: marketInfo.baseVault.publicKey,\n quoteVault: marketInfo.quoteVault.publicKey,\n baseMint: marketInfo.baseMint,\n quoteMint: marketInfo.quoteMint,\n\n baseLotSize: marketInfo.baseLotSize,\n quoteLotSize: marketInfo.quoteLotSize,\n feeRateBps: marketInfo.feeRateBps,\n vaultSignerNonce: marketInfo.vaultSignerNonce,\n quoteDustThreshold: marketInfo.quoteDustThreshold,\n },\n }),\n );\n\n return [\n {\n transaction: tx1,\n signer: [],\n instructionTypes: [\n InstructionType.CreateAccount,\n InstructionType.CreateAccount,\n InstructionType.InitAccount,\n InstructionType.InitAccount,\n ],\n },\n {\n transaction: tx2,\n signer: [],\n instructionTypes: [\n InstructionType.CreateAccount,\n InstructionType.CreateAccount,\n InstructionType.CreateAccount,\n InstructionType.CreateAccount,\n InstructionType.CreateAccount,\n InstructionType.InitMarket,\n ],\n },\n ];\n}\n","export enum TxVersion {\n \"V0\",\n \"LEGACY\",\n}\n\nexport const InstructionType = {\n CreateAccount: \"CreateAccount\",\n InitAccount: \"InitAccount\",\n CreateATA: \"CreateATA\",\n CloseAccount: \"CloseAccount\",\n TransferAmount: \"TransferAmount\",\n InitMint: \"InitMint\",\n MintTo: \"MintTo\",\n\n InitMarket: \"InitMarket\", // create market main ins\n Util1216OwnerClaim: \"Util1216OwnerClaim\", // owner claim token ins\n\n SetComputeUnitPrice: \"SetComputeUnitPrice\",\n SetComputeUnitLimit: \"SetComputeUnitLimit\",\n\n // CLMM\n ClmmCreatePool: \"ClmmCreatePool\",\n ClmmOpenPosition: \"ClmmOpenPosition\",\n ClmmIncreasePosition: \"ClmmIncreasePosition\",\n ClmmDecreasePosition: \"ClmmDecreasePosition\",\n ClmmClosePosition: \"ClmmClosePosition\",\n ClmmSwapBaseIn: \"ClmmSwapBaseIn\",\n ClmmSwapBaseOut: \"ClmmSwapBaseOut\",\n ClmmInitReward: \"ClmmInitReward\",\n ClmmSetReward: \"ClmmSetReward\",\n ClmmCollectReward: \"ClmmCollectReward\",\n ClmmLockPosition: \"ClmmLockPosition\",\n ClmmHarvestLockPosition: \"ClmmHarvestLockPosition\",\n\n AmmV4Swap: \"AmmV4Swap\",\n AmmV4AddLiquidity: \"AmmV4AddLiquidity\",\n AmmV4RemoveLiquidity: \"AmmV4RemoveLiquidity\",\n AmmV4SimulatePoolInfo: \"AmmV4SimulatePoolInfo\",\n AmmV4SwapBaseIn: \"AmmV4SwapBaseIn\",\n AmmV4SwapBaseOut: \"AmmV4SwapBaseOut\",\n AmmV4CreatePool: \"AmmV4CreatePool\",\n AmmV4InitPool: \"AmmV4InitPool\",\n\n AmmV5AddLiquidity: \"AmmV5AddLiquidity\",\n AmmV5RemoveLiquidity: \"AmmV5RemoveLiquidity\",\n AmmV5SimulatePoolInfo: \"AmmV5SimulatePoolInfo\",\n AmmV5SwapBaseIn: \"AmmV5SwapBaseIn\",\n AmmV5SwapBaseOut: \"AmmV5SwapBaseOut\",\n\n RouteSwap: \"RouteSwap\",\n RouteSwap1: \"RouteSwap1\",\n RouteSwap2: \"RouteSwap2\",\n\n FarmV3Deposit: \"FarmV3Deposit\",\n FarmV3Withdraw: \"FarmV3Withdraw\",\n FarmV3CreateLedger: \"FarmV3CreateLedger\",\n\n FarmV5Deposit: \"FarmV5Deposit\",\n FarmV5Withdraw: \"FarmV5Withdraw\",\n FarmV5CreateLedger: \"FarmV5CreateLedger\",\n\n FarmV6Deposit: \"FarmV6Deposit\",\n FarmV6Withdraw: \"FarmV6Withdraw\",\n FarmV6Create: \"FarmV6Create\",\n FarmV6Restart: \"FarmV6Restart\",\n FarmV6CreatorAddReward: \"FarmV6CreatorAddReward\",\n FarmV6CreatorWithdraw: \"FarmV6CreatorWithdraw\",\n\n CpmmCreatePool: \"CpmmCreatePool\",\n CpmmAddLiquidity: \"CpmmAddLiquidity\",\n CpmmWithdrawLiquidity: \"CpmmWithdrawLiquidity\",\n CpmmSwapBaseIn: \"CpmmSwapBaseIn\",\n CpmmSwapBaseOut: \"CpmmSwapBaseOut\",\n\n CpmmLockLp: \"CpmmLockLp\",\n CpmmCollectLockFee: \"CpmmCollectLockFee\",\n};\n","import { PublicKey } from \"@solana/web3.js\";\nimport BN, { isBN } from \"bn.js\";\n\nimport {\n bits,\n blob,\n Blob,\n Layout,\n offset as _offset,\n seq as _seq,\n Structure as _Structure,\n u32 as _u32,\n u8 as _u8,\n UInt,\n union as _union,\n Union as _Union,\n} from \"./buffer-layout\";\n\nexport * from \"./buffer-layout\";\nexport { blob };\n\nexport class BNLayout<P extends string = \"\"> extends Layout<BN, P> {\n blob: Layout<Buffer>;\n signed: boolean;\n\n constructor(span: number, signed: boolean, property?: P) {\n //@ts-expect-error type wrong for super()'s type different from extends, but it desn't matter\n super(span, property);\n this.blob = blob(span);\n this.signed = signed;\n }\n\n /** @override */\n decode(b: Buffer, offset = 0): BN {\n const num = new BN(this.blob.decode(b, offset), 10, \"le\");\n if (this.signed) {\n return num.fromTwos(this.span * 8).clone();\n }\n return num;\n }\n\n /** @override */\n encode(src: BN, b: Buffer, offset = 0): number {\n if (typeof src === \"number\") src = new BN(src); // src will pass a number accidently in union\n if (this.signed) {\n src = src.toTwos(this.span * 8);\n }\n return this.blob.encode(src.toArrayLike(Buffer, \"le\", this.span), b, offset);\n }\n}\n\nexport class WideBits<P extends string = \"\"> extends Layout<Record<string, boolean>, P> {\n _lower: any;\n _upper: any;\n // TODO: unknown\n constructor(property?: P) {\n //@ts-expect-error type wrong for super()'s type different from extends , but it desn't matter\n super(8, property);\n this._lower = bits(_u32(), false);\n this._upper = bits(_u32(), false);\n }\n\n addBoolean(property: string): void {\n if (this._lower.fields.length < 32) {\n this._lower.addBoolean(property);\n } else {\n this._upper.addBoolean(property);\n }\n }\n\n decode(b: Buffer, offset = 0): Record<string, boolean> {\n const lowerDecoded = this._lower.decode(b, offset);\n const upperDecoded = this._upper.decode(b, offset + this._lower.span);\n return { ...lowerDecoded, ...upperDecoded };\n }\n\n encode(src: any /* TEMP */, b: Buffer, offset = 0): any {\n return this._lower.encode(src, b, offset) + this._upper.encode(src, b, offset + this._lower.span);\n }\n}\n\nexport function u8<P extends string = \"\">(property?: P): UInt<number, P> {\n return new UInt(1, property);\n}\n\nexport function u32<P extends string = \"\">(property?: P): UInt<number, P> {\n return new UInt(4, property);\n}\n\nexport function u64<P extends string = \"\">(property?: P): BNLayout<P> {\n return new BNLayout(8, false, property);\n}\n\nexport function u128<P extends string = \"\">(property?: P): BNLayout<P> {\n return new BNLayout(16, false, property);\n}\n\nexport function i8<P extends string = \"\">(property?: P): BNLayout<P> {\n return new BNLayout(1, true, property);\n}\n\nexport function i64<P extends string = \"\">(property?: P): BNLayout<P> {\n return new BNLayout(8, true, property);\n}\n\nexport function i128<P extends string = \"\">(property?: P): BNLayout<P> {\n return new BNLayout(16, true, property);\n}\n\nexport class WrappedLayout<T, U, P extends string = \"\"> extends Layout<U, P> {\n layout: Layout<T>;\n decoder: (data: T) => U;\n encoder: (src: U) => T;\n\n constructor(layout: Layout<T>, decoder: (data: T) => U, encoder: (src: U) => T, property?: P) {\n //@ts-expect-error type wrong for super()'s type different from extends , but it desn't matter\n super(layout.span, property);\n this.layout = layout;\n this.decoder = decoder;\n this.encoder = encoder;\n }\n\n decode(b: Buffer, offset?: number): U {\n return this.decoder(this.layout.decode(b, offset));\n }\n\n encode(src: U, b: Buffer, offset?: number): number {\n return this.layout.encode(this.encoder(src), b, offset);\n }\n\n getSpan(b: Buffer, offset?: number): number {\n return this.layout.getSpan(b, offset);\n }\n}\n\nexport function publicKey<P extends string = \"\">(property?: P): Layout<PublicKey, P> {\n return new WrappedLayout(\n blob(32),\n (b: Buffer) => new PublicKey(b),\n (key: PublicKey) => key.toBuffer(),\n property,\n );\n}\n\nexport class OptionLayout<T, P> extends Layout<T | null, P> {\n layout: Layout<T>;\n discriminator: Layout<number>;\n\n constructor(layout: Layout<T>, property?: P) {\n //@ts-expect-error type wrong for super()'s type different from extends , but it desn't matter\n super(-1, property);\n this.layout = layout;\n this.discriminator = _u8();\n }\n\n encode(src: T | null, b: Buffer, offset = 0): number {\n if (src === null || src === undefined) {\n return this.discriminator.encode(0, b, offset);\n }\n this.discriminator.encode(1, b, offset);\n return this.layout.encode(src, b, offset + 1) + 1;\n }\n\n decode(b: Buffer, offset = 0): T | null {\n const discriminator = this.discriminator.decode(b, offset);\n if (discriminator === 0) {\n return null;\n } else if (discriminator === 1) {\n return this.layout.decode(b, offset + 1);\n }\n throw new Error(\"Invalid option \" + this.property);\n }\n\n getSpan(b: Buffer, offset = 0): number {\n const discriminator = this.discriminator.decode(b, offset);\n if (discriminator === 0) {\n return 1;\n } else if (discriminator === 1) {\n return this.layout.getSpan(b, offset + 1) + 1;\n }\n throw new Error(\"Invalid option \" + this.property);\n }\n}\n\nexport function option<T, P extends string = \"\">(layout: Layout<T>, property?: P): Layout<T | null, P> {\n return new OptionLayout<T, P>(layout, property);\n}\n\nexport function bool<P extends string = \"\">(property?: P): Layout<boolean, P> {\n return new WrappedLayout(_u8(), decodeBool, encodeBool, property);\n}\n\nexport function decodeBool(value: number): boolean {\n if (value === 0) {\n return false;\n } else if (value === 1) {\n return true;\n }\n throw new Error(\"Invalid bool: \" + value);\n}\n\nexport function encodeBool(value: boolean): number {\n return value ? 1 : 0;\n}\n\nexport function vec<T, P extends string = \"\">(elementLayout: Layout<T>, property?: P): Layout<T[], P> {\n const length = _u32(\"length\");\n const layout: Layout<{ values: T[] }> = struct([\n length,\n seq(elementLayout, _offset(length, -length.span), \"values\"),\n ]) as any; // Something I don't know\n return new WrappedLayout(\n layout,\n ({ values }) => values,\n (values) => ({ values }),\n property,\n );\n}\n\nexport function tagged<T, P extends string = \"\">(tag: BN, layout: Layout<T>, property?: P): Layout<T, P> {\n const wrappedLayout: Layout<{ tag: BN; data: T }> = struct([u64(\"tag\"), layout.replicate(\"data\")]) as any; // Something I don't know\n\n function decodeTag({ tag: receivedTag, data }: { tag: BN; data: T }): T {\n if (!receivedTag.eq(tag)) {\n throw new Error(\"Invalid tag, expected: \" + tag.toString(\"hex\") + \", got: \" + receivedTag.toString(\"hex\"));\n }\n return data;\n }\n\n return new WrappedLayout(wrappedLayout, decodeTag, (data) => ({ tag, data }), property);\n}\n\nexport function vecU8<P extends string = \"\">(property?: P): Layout<Buffer, P> {\n const length = _u32(\"length\");\n const layout: Layout<{ data: Buffer }> = struct([length, blob(_offset(length, -length.span), \"data\")]) as any; // Something I don't know\n return new WrappedLayout(\n layout,\n ({ data }) => data,\n (data) => ({ data }),\n property,\n );\n}\n\nexport function str<P extends string = \"\">(property?: P): Layout<string, P> {\n return new WrappedLayout(\n vecU8(),\n (data) => data.toString(\"utf-8\"),\n (s) => Buffer.from(s, \"utf-8\"),\n property,\n );\n}\n\nexport interface EnumLayout<T, P extends string = \"\"> extends Layout<T, P> {\n registry: Record<string, Layout<any>>;\n}\n\nexport function rustEnum<T, P extends string = \"\">(variants: Layout<any>[], property?: P): EnumLayout<T, P> {\n const unionLayout = _union(_u8(), property);\n variants.forEach((variant, index) => unionLayout.addVariant(index, variant, variant.property));\n return unionLayout as any; // ?why use UnionLayout? This must be a fault\n}\n\nexport function array<T, P extends string = \"\">(\n elementLayout: Layout<T>,\n length: number,\n property?: P,\n): Layout<T[], P> {\n const layout = struct([seq(elementLayout, length, \"values\")]) as any as Layout<{ values: T[] }>; // Something I don't know\n return new WrappedLayout(\n layout,\n ({ values }) => values,\n (values) => ({ values }),\n property,\n );\n}\n\nexport class Structure<T, P, D extends { [key: string]: any; }> extends _Structure<T, P, D> {\n /** @override */\n decode(b: Buffer, offset?: number): D {\n return super.decode(b, offset);\n }\n}\n\nexport function struct<T, P extends string = \"\">(\n fields: T,\n property?: P,\n decodePrefixes?: boolean,\n): T extends Layout<infer Value, infer Property>[]\n ? Structure<\n Value,\n P,\n {\n [K in Exclude<Extract<Property, string>, \"\">]: Extract<T[number], Layout<any, K>> extends Layout<infer V, any>\n ? V\n : any;\n }\n >\n : any {\n //@ts-expect-error this type is not quite satisfied the define, but, never no need to worry about.\n return new Structure(fields, property, decodePrefixes);\n}\n\nexport type GetLayoutSchemaFromStructure<T extends Structure<any, any, any>> = T extends Structure<any, any, infer S>\n ? S\n : any;\nexport type GetStructureFromLayoutSchema<S extends { [key: string]: any; }> = Structure<any, any, S>;\n\nexport class Union<Schema extends { [key: string]: any; }> extends _Union<Schema> {\n encodeInstruction(instruction: any): Buffer {\n const instructionMaxSpan = Math.max(...Object.values(this.registry).map((r) => r.span));\n const b = Buffer.alloc(instructionMaxSpan);\n return b.slice(0, this.encode(instruction, b));\n }\n\n decodeInstruction(instruction: any): Partial<Schema> {\n return this.decode(instruction);\n }\n}\nexport function union<UnionSchema extends { [key: string]: any } = any>(\n discr: any,\n defaultLayout?: any,\n property?: string,\n): Union<UnionSchema> {\n return new Union(discr, defaultLayout, property);\n}\n\nclass Zeros extends Blob {\n decode(b: Buffer, offset: number): Buffer {\n const slice = super.decode(b, offset);\n if (!slice.every((v) => v === 0)) {\n throw new Error(\"nonzero padding bytes\");\n }\n return slice;\n }\n}\n\nexport function zeros(length: number): Zeros {\n return new Zeros(length);\n}\n\nexport function seq<T, P extends string = \"\", AnotherP extends string = \"\">(\n elementLayout: Layout<T, P>,\n count: number | BN | Layout<BN | number, P>,\n property?: AnotherP,\n): Layout<T[], AnotherP> {\n let parsedCount: number;\n const superCount =\n typeof count === \"number\"\n ? count\n : isBN(count)\n ? count.toNumber()\n : new Proxy(count as unknown as Layout<number> /* pretend to be Layout<number> */, {\n get(target, property): any {\n if (!parsedCount) {\n // get count in targetLayout. note that count may be BN\n const countProperty = Reflect.get(target, \"count\");\n\n // let targetLayout's property:count be a number\n parsedCount = isBN(countProperty) ? countProperty.toNumber() : countProperty;\n\n // record the count\n Reflect.set(target, \"count\", parsedCount);\n }\n return Reflect.get(target, property);\n },\n set(target, property, value): any {\n if (property === \"count\") {\n parsedCount = value;\n }\n return Reflect.set(target, property, value);\n },\n });\n\n // @ts-expect-error force type\n return _seq(elementLayout, superCount, property);\n}\n","import {\n bits as _bits,\n BitStructure as _BitStructure,\n blob as _blob,\n Blob as _Blob,\n cstr as _cstr,\n f32 as _f32,\n f32be as _f32be,\n f64 as _f64,\n f64be as _f64be,\n greedy as _greedy,\n Layout as _Layout,\n ns64 as _ns64,\n ns64be as _ns64be,\n nu64 as _nu64,\n nu64be as _nu64be,\n offset as _offset,\n s16 as _s16,\n s16be as _s16be,\n s24 as _s24,\n s24be as _s24be,\n s32 as _s32,\n s32be as _s32be,\n s40 as _s40,\n s40be as _s40be,\n s48 as _s48,\n s48be as _s48be,\n s8 as _s8,\n seq as _seq,\n struct as _struct,\n Structure as _Structure,\n u16 as _u16,\n u16be as _u16be,\n u24 as _u24,\n u24be as _u24be,\n u32 as _u32,\n u32be as _u32be,\n u40 as _u40,\n u40be as _u40be,\n u48 as _u48,\n u48be as _u48be,\n u8 as _u8,\n UInt as _UInt,\n union as _union,\n Union as _Union,\n unionLayoutDiscriminator as _unionLayoutDiscriminator,\n utf8 as _utf8,\n} from \"@solana/buffer-layout\";\n\n//#region ------------------- Layout -------------------\nexport interface Layout<T = any, P = \"\"> {\n span: number;\n property?: P;\n decode(b: Buffer, offset?: number): T;\n encode(src: T, b: Buffer, offset?: number): number;\n getSpan(b: Buffer, offset?: number): number;\n replicate<AP extends string>(name: AP): Layout<T, AP>;\n}\nexport interface LayoutConstructor {\n new <T, P>(): Layout<T, P>; // for class extends syntex\n new <T, P>(span?: T, property?: P): Layout<T, P>;\n readonly prototype: Layout;\n}\nexport const Layout = _Layout as unknown as LayoutConstructor;\n//#endregion\n\n//#region ------------------- Structure -------------------\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nexport interface Structure<T = any, P = \"\", DecodeSchema extends { [key: string]: any } = any>\n extends Layout<DecodeSchema, P> {\n span: number;\n decode(b: Buffer, offset?: number): DecodeSchema;\n layoutFor<AP extends string>(property: AP): Layout<DecodeSchema[AP]>;\n offsetOf<AP extends string>(property: AP): number;\n}\ninterface StructureConstructor {\n new <T = any, P = \"\", DecodeSchema extends { [key: string]: any } = any>(): Structure<T, P, DecodeSchema>;\n new <T = any, P = \"\", DecodeSchema extends { [key: string]: any } = any>(\n fields: T,\n property?: P,\n decodePrefixes?: boolean,\n ): Structure<T, P, DecodeSchema>;\n}\nexport const Structure = _Structure as unknown as StructureConstructor;\n//#endregion\n\n//#region ------------------- Union -------------------\nexport interface Union<UnionSchema extends { [key: string]: any } = any> extends Layout {\n registry: object;\n decode(b: Buffer, offset?: number): Partial<UnionSchema>;\n addVariant(\n variant: number,\n layout: Structure<any, any, Partial<UnionSchema>> | Layout<any, keyof UnionSchema>,\n property?: string,\n ): any /* TEMP: code in Layout.js 1809 */;\n}\ninterface UnionConstructor {\n new <UnionSchema extends { [key: string]: any } = any>(): Union<UnionSchema>;\n new <UnionSchema extends { [key: string]: any } = any>(\n discr: Layout<any, any>,\n defaultLayout: Layout<any, any>,\n property?: string,\n ): Union<UnionSchema>;\n}\nexport const Union = _Union as unknown as UnionConstructor;\n//#endregion\n\n//#region ------------------- BitStructure -------------------\nexport type BitStructure<T = unknown /* TEMP */, P = \"\"> = Layout<T, P>;\ninterface BitStructureConstructor {\n new (...params: any[]): BitStructure;\n}\nexport const BitStructure = _BitStructure as BitStructureConstructor;\n//#endregion\n\n//#region ------------------- UInt -------------------\nexport type UInt<T = any, P = \"\"> = Layout<T, P>;\ninterface UIntConstructor {\n new <T, P>(span?: T, property?: P): UInt<T, P>;\n}\nexport const UInt = _UInt as UIntConstructor;\n//#endregion\n\n//#region ------------------- Blob -------------------\nexport type Blob<P extends string = \"\"> = Layout<Buffer, P>;\ninterface BlobConstructor {\n new (...params: ConstructorParameters<LayoutConstructor>): Blob;\n}\nexport const Blob = _Blob as unknown as BlobConstructor;\n//#endregion\n\nexport const greedy = _greedy as <P extends string = \"\">(elementSpan?: number, property?: P) => Layout<number, P>;\nexport const u8 = _u8 as <P extends string = \"\">(property?: P) => Layout<number, P>;\nexport const u16 = _u16 as <P extends string = \"\">(property?: P) => Layout<number, P>;\nexport const u24 = _u24 as <P extends string = \"\">(property?: P) => Layout<number, P>;\nexport const u32 = _u32 as <P extends string = \"\">(property?: P) => Layout<number, P>;\nexport const u40 = _u40 as <P extends string = \"\">(property?: P) => Layout<number, P>;\nexport const u48 = _u48 as <P extends string = \"\">(property?: P) => Layout<number, P>;\nexport const nu64 = _nu64 as <P extends string = \"\">(property?: P) => Layout<number, P>;\nexport const u16be = _u16be as <P extends string = \"\">(property?: P) => Layout<number, P>;\nexport const u24be = _u24be as <P extends string = \"\">(property?: P) => Layout<number, P>;\nexport const u32be = _u32be as <P extends string = \"\">(property?: P) => Layout<number, P>;\nexport const u40be = _u40be as <P extends string = \"\">(property?: P) => Layout<number, P>;\nexport const u48be = _u48be as <P extends string = \"\">(property?: P) => Layout<number, P>;\nexport const nu64be = _nu64be as <P extends string = \"\">(property?: P) => Layout<number, P>;\nexport const s8 = _s8 as <P extends string = \"\">(property?: P) => Layout<number, P>;\nexport const s16 = _s16 as <P extends string = \"\">(property?: P) => Layout<number, P>;\nexport const s24 = _s24 as <P extends string = \"\">(property?: P) => Layout<number, P>;\nexport const s32 = _s32 as <P extends string = \"\">(property?: P) => Layout<number, P>;\nexport const s40 = _s40 as <P extends string = \"\">(property?: P) => Layout<number, P>;\nexport const s48 = _s48 as <P extends string = \"\">(property?: P) => Layout<number, P>;\nexport const ns64 = _ns64 as <P extends string = \"\">(property?: P) => Layout<number, P>;\nexport const s16be = _s16be as <P extends string = \"\">(property?: P) => Layout<number, P>;\nexport const s24be = _s24be as <P extends string = \"\">(property?: P) => Layout<number, P>;\nexport const s32be = _s32be as <P extends string = \"\">(property?: P) => Layout<number, P>;\nexport const s40be = _s40be as <P extends string = \"\">(property?: P) => Layout<number, P>;\nexport const s48be = _s48be as <P extends string = \"\">(property?: P) => Layout<number, P>;\nexport const ns64be = _ns64be as <P extends string = \"\">(property?: P) => Layout<number, P>;\nexport const f32 = _f32 as <P extends string = \"\">(property?: P) => Layout<number, P>;\nexport const f32be = _f32be as <P extends string = \"\">(property?: P) => Layout<number, P>;\nexport const f64 = _f64 as <P extends string = \"\">(property?: P) => Layout<number, P>;\nexport const f64be = _f64be as <P extends string = \"\">(property?: P) => Layout<number, P>;\n\nexport const struct = _struct as <T, P extends string = \"\">(\n fields: T,\n property?: P,\n decodePrefixes?: boolean,\n) => T extends Layout<infer Value, infer Property>[]\n ? Structure<\n Value,\n P,\n {\n [K in Exclude<Extract<Property, string>, \"\">]: Extract<T[number], Layout<any, K>> extends Layout<infer V, any>\n ? V\n : any;\n }\n >\n : any;\n\nexport const seq = _seq as unknown as <T, P>(\n elementLayout: Layout<T, string>,\n count: number | Layout<number, string>,\n property?: P,\n) => Layout<T[]>;\nexport const union = _union as <UnionSchema extends { [key: string]: any } = any>(\n discr: Layout<any, any>,\n defaultLayout?: any,\n property?: string,\n) => Union<UnionSchema>;\nexport const unionLayoutDiscriminator = _unionLayoutDiscriminator as <P extends string = \"\">(\n layout: Layout<any, P>,\n property?: P,\n) => any;\nexport const blob = _blob as unknown as <P extends string = \"\">(\n length: number | Layout<number, P>,\n property?: P,\n) => Blob<P>;\nexport const cstr = _cstr as <P extends string = \"\">(property?: P) => Layout<string, P>;\nexport const utf8 = _utf8 as <P extends string = \"\">(maxSpan: number, property?: P) => Layout<string, P>;\nexport const bits = _bits as unknown as <T, P extends string = \"\">(\n word: Layout<T>,\n msb?: boolean,\n property?: P,\n) => BitStructure<T, P>; // TODO: not quite sure\nexport const offset = _offset as unknown as <T, P extends string = \"\">(\n layout: Layout<T, P>,\n offset?: number,\n property?: P,\n) => Layout<T, P>;\n\nexport type GetStructureSchema<T extends Structure> = T extends Structure<any, any, infer S> ? S : unknown;\n","import { blob, publicKey, struct, u64, WideBits } from \"../../marshmallow\";\n\nfunction accountFlagsLayout(property = \"accountFlags\"): WideBits<string> {\n const ACCOUNT_FLAGS_LAYOUT = new WideBits(property);\n ACCOUNT_FLAGS_LAYOUT.addBoolean(\"initialized\");\n ACCOUNT_FLAGS_LAYOUT.addBoolean(\"market\");\n ACCOUNT_FLAGS_LAYOUT.addBoolean(\"openOrders\");\n ACCOUNT_FLAGS_LAYOUT.addBoolean(\"requestQueue\");\n ACCOUNT_FLAGS_LAYOUT.addBoolean(\"eventQueue\");\n ACCOUNT_FLAGS_LAYOUT.addBoolean(\"bids\");\n ACCOUNT_FLAGS_LAYOUT.addBoolean(\"asks\");\n return ACCOUNT_FLAGS_LAYOUT;\n}\n\nexport const MARKET_STATE_LAYOUT_V2 = struct([\n blob(5),\n accountFlagsLayout(\"accountFlags\"),\n publicKey(\"ownAddress\"),\n u64(\"vaultSignerNonce\"),\n publicKey(\"baseMint\"),\n publicKey(\"quoteMint\"),\n publicKey(\"baseVault\"),\n u64(\"baseDepositsTotal\"),\n u64(\"baseFeesAccrued\"),\n publicKey(\"quoteVault\"),\n u64(\"quoteDepositsTotal\"),\n u64(\"quoteFeesAccrued\"),\n u64(\"quoteDustThreshold\"),\n publicKey(\"requestQueue\"),\n publicKey(\"eventQueue\"),\n publicKey(\"bids\"),\n publicKey(\"asks\"),\n u64(\"baseLotSize\"),\n u64(\"quoteLotSize\"),\n u64(\"feeRateBps\"),\n u64(\"referrerRebatesAccrued\"),\n blob(7),\n]);\n"],"mappings":"yVAAA,uHAUA,6FCLO,GAAM,GAAkB,CAC7B,cAAe,gBACf,YAAa,cACb,UAAW,YACX,aAAc,eACd,eAAgB,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js';
2
2
  import '../common/logger.js';
3
- import '../api-f6d3edc7.js';
4
- export { g as ModuleBaseProps, f as default } from '../raydium-94d49791.js';
3
+ import '../api-fd862469.js';
4
+ export { g as ModuleBaseProps, f as default } from '../raydium-87764c35.js';
5
5
  import 'axios';
6
6
  import '../solana/type.js';
7
7
  import 'bn.js';
@@ -22,7 +22,7 @@ import './liquidity/stable.js';
22
22
  import './liquidity/type.js';
23
23
  import './liquidity/layout.js';
24
24
  import './clmm/layout.js';
25
- import '../type-11af28b1.js';
25
+ import '../type-91ebce1b.js';
26
26
  import './cpmm/type.js';
27
27
  import './cpmm/curve/calculator.js';
28
28
  import './cpmm/layout.js';
@@ -1,9 +1,9 @@
1
1
  import '@solana/web3.js';
2
- import '../api-f6d3edc7.js';
2
+ import '../api-fd862469.js';
3
3
  import '../api/url.js';
4
4
  import '../common/owner.js';
5
5
  import '../solana/type.js';
6
- export { c as Raydium, a as RaydiumApiBatchRequestParams, b as RaydiumConstructorParams, R as RaydiumLoadParams } from '../raydium-94d49791.js';
6
+ export { c as Raydium, a as RaydiumApiBatchRequestParams, b as RaydiumConstructorParams, R as RaydiumLoadParams } from '../raydium-87764c35.js';
7
7
  import 'axios';
8
8
  import 'bn.js';
9
9
  import '@solana/spl-token';
@@ -22,7 +22,7 @@ import './liquidity/stable.js';
22
22
  import './liquidity/type.js';
23
23
  import './liquidity/layout.js';
24
24
  import './clmm/layout.js';
25
- import '../type-11af28b1.js';
25
+ import '../type-91ebce1b.js';
26
26
  import './cpmm/type.js';
27
27
  import './cpmm/curve/calculator.js';
28
28
  import './cpmm/layout.js';