@glamsystems/glam-sdk 1.0.5 → 1.0.7

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.
package/index.cjs.js CHANGED
@@ -3015,6 +3015,11 @@ var constants$d = [
3015
3015
  type: "u16",
3016
3016
  value: "1"
3017
3017
  },
3018
+ {
3019
+ name: "PROTO_SYSTEM_PERM_EMERGENCY_UPDATE",
3020
+ type: "u64",
3021
+ value: "4"
3022
+ },
3018
3023
  {
3019
3024
  name: "PROTO_SYSTEM_PERM_TRANSFER",
3020
3025
  type: "u64",
@@ -41803,27 +41808,69 @@ function getExtCctpProgram(provider) {
41803
41808
  return new anchor.Program(ExtCctpIdlJson, provider);
41804
41809
  }
41805
41810
 
41806
- /**
41807
- * Compares two sets for equality
41808
- */ const setsAreEqual = (a, b)=>{
41809
- if (a.size !== b.size) return false;
41810
- for (let item of a){
41811
- if (!b.has(item)) return false;
41812
- }
41813
- return true;
41814
- };
41815
41811
  /**
41816
41812
  * Converts a buffer or array of character codes to a string
41817
- */ function charsToName(chars) {
41813
+ */ function charsToString(chars) {
41818
41814
  return String.fromCharCode(...chars).replace(/\0/g, "").trim();
41819
41815
  }
41820
41816
  /**
41821
- * Converts a string to an array of character codes (max 32 bytes)
41822
- */ function nameToChars(name) {
41823
- return Array.from(Buffer.from(name).subarray(0, 32));
41817
+ * Converts a string to an array of character codes
41818
+ */ function stringToChars(name, length = 32) {
41819
+ return Array.from(Buffer.from(name).subarray(0, length));
41820
+ }
41821
+ /**
41822
+ * Safely converts a BN amount to a UI amount (with decimals).
41823
+ *
41824
+ * @param amount - The amount in base units (BN)
41825
+ * @param decimals - The number of decimals (e.g., 9)
41826
+ * @returns The UI amount as a number
41827
+ *
41828
+ * @example
41829
+ * // Convert 10010000000 base units with 9 decimals
41830
+ * const uiAmount = toUiAmount(new BN(10010000000), 9); // Returns 10.01
41831
+ *
41832
+ * @throws Error if the BN amount is too large to safely convert to number
41833
+ */ function toUiAmount(amount, decimals) {
41834
+ const divisor = new anchor.BN(10).pow(new anchor.BN(decimals));
41835
+ const integerPart = amount.div(divisor);
41836
+ const fractionalPart = amount.mod(divisor);
41837
+ // Convert to number - will throw if too large for Number.MAX_SAFE_INTEGER
41838
+ const intNum = integerPart.toNumber();
41839
+ const fracNum = fractionalPart.toNumber();
41840
+ return intNum + fracNum / Math.pow(10, decimals);
41824
41841
  }
41825
- function toUiAmount(amount, decimals) {
41826
- return amount.toNumber() / 10 ** decimals;
41842
+ /**
41843
+ * Safely converts a UI amount (with decimals) to a BN amount.
41844
+ *
41845
+ * @param amount - The UI amount (e.g., 10.01)
41846
+ * @param decimals - The number of decimals (e.g., 9)
41847
+ * @returns BN representing the amount in base units
41848
+ *
41849
+ * @example
41850
+ * // Convert 10.01 with 9 decimals
41851
+ * const amount = fromUiAmount(10.01, 9); // Returns BN(10010000000)
41852
+ */ function fromUiAmount(amount, decimals) {
41853
+ // Handle scientific notation by converting to fixed-point string
41854
+ let amountStr;
41855
+ if (typeof amount === "number") {
41856
+ // Convert number to fixed-point string to avoid scientific notation
41857
+ amountStr = amount.toFixed(decimals);
41858
+ } else {
41859
+ amountStr = amount;
41860
+ }
41861
+ const [integerPart, fractionalPart = ""] = amountStr.split(".");
41862
+ // Convert integer part
41863
+ const integerBN = new anchor.BN(integerPart || "0");
41864
+ // Convert fractional part
41865
+ let fractionalBN = new anchor.BN(0);
41866
+ if (fractionalPart) {
41867
+ // Pad or truncate fractional part to match decimals
41868
+ const paddedFractional = fractionalPart.padEnd(decimals, "0").slice(0, decimals);
41869
+ fractionalBN = new anchor.BN(paddedFractional);
41870
+ }
41871
+ // Combine: (integer * 10^decimals) + fractional
41872
+ const multiplier = new anchor.BN(10).pow(new anchor.BN(decimals));
41873
+ return integerBN.mul(multiplier).add(fractionalBN);
41827
41874
  }
41828
41875
 
41829
41876
  class MintPolicy {
@@ -42051,7 +42098,7 @@ class MintIdlModel {
42051
42098
  }
42052
42099
  class MintModel extends MintIdlModel {
42053
42100
  get nameStr() {
42054
- return this.name ? charsToName(this.name) : "";
42101
+ return this.name ? charsToString(this.name) : "";
42055
42102
  }
42056
42103
  constructor(data){
42057
42104
  super(data);
@@ -42171,27 +42218,32 @@ const GLAM_CONFIG_PROGRAM = new web3_js.PublicKey("gConFzxKL9USmwTdJoeQJvfKmqhJ2
42171
42218
  3: "Exponent Market"
42172
42219
  };
42173
42220
  /**
42174
- * Get protocol and permission mappings at runtime to ensure correct program IDs based on environment
42221
+ * Get protocol and permission mappings at runtime to ensure correct program IDs based on environment.
42222
+ *
42223
+ * This method provides the source of truth for protocol and permission mappings and staging status in SDK.
42175
42224
  */ const getProtocolsAndPermissions = ()=>({
42176
42225
  // Supported protocols and permissions are defined in:
42177
42226
  // @anchor/programs/glam_protocol/src/state/acl.rs
42178
42227
  [getGlamProtocolProgramId().toBase58()]: {
42179
42228
  "0000000000000001": {
42180
- name: "System Program",
42229
+ name: "SystemProgram",
42230
+ staging: false,
42181
42231
  permissions: {
42182
42232
  [1 << 0]: "WSOL",
42183
42233
  [1 << 1]: "Transfer"
42184
42234
  }
42185
42235
  },
42186
42236
  "0000000000000010": {
42187
- name: "Stake Program",
42237
+ name: "StakeProgram",
42238
+ staging: true,
42188
42239
  permissions: {
42189
42240
  [1 << 0]: "Stake",
42190
42241
  [1 << 1]: "Unstake"
42191
42242
  }
42192
42243
  },
42193
42244
  "0000000000000100": {
42194
- name: "Jupiter Swap",
42245
+ name: "JupiterSwap",
42246
+ staging: false,
42195
42247
  permissions: {
42196
42248
  [1 << 0]: "SwapAny",
42197
42249
  [1 << 1]: "SwapLST",
@@ -42203,7 +42255,8 @@ const GLAM_CONFIG_PROGRAM = new web3_js.PublicKey("gConFzxKL9USmwTdJoeQJvfKmqhJ2
42203
42255
  // @anchor/programs/glam_mint/src/state/acl.rs
42204
42256
  [getGlamMintProgramId().toBase58()]: {
42205
42257
  "0000000000000001": {
42206
- name: "Glam Mint",
42258
+ name: "GlamMint",
42259
+ staging: false,
42207
42260
  permissions: {
42208
42261
  [1 << 0]: "MintTokens",
42209
42262
  [1 << 1]: "BurnTokens",
@@ -42221,7 +42274,8 @@ const GLAM_CONFIG_PROGRAM = new web3_js.PublicKey("gConFzxKL9USmwTdJoeQJvfKmqhJ2
42221
42274
  // @anchor/programs/ext_kamino/src/state/acl.rs
42222
42275
  [getExtKaminoProgramId().toBase58()]: {
42223
42276
  "0000000000000001": {
42224
- name: "Kamino Lend",
42277
+ name: "KaminoLend",
42278
+ staging: false,
42225
42279
  permissions: {
42226
42280
  [1 << 0]: "Init",
42227
42281
  [1 << 1]: "Deposit",
@@ -42231,14 +42285,16 @@ const GLAM_CONFIG_PROGRAM = new web3_js.PublicKey("gConFzxKL9USmwTdJoeQJvfKmqhJ2
42231
42285
  }
42232
42286
  },
42233
42287
  "0000000000000010": {
42234
- name: "Kamino Vaults",
42288
+ name: "KaminoVaults",
42289
+ staging: false,
42235
42290
  permissions: {
42236
42291
  [1 << 0]: "Deposit",
42237
42292
  [1 << 1]: "Withdraw"
42238
42293
  }
42239
42294
  },
42240
42295
  "0000000000000100": {
42241
- name: "Kamino Farms",
42296
+ name: "KaminoFarms",
42297
+ staging: false,
42242
42298
  permissions: {
42243
42299
  [1 << 0]: "Stake",
42244
42300
  [1 << 1]: "Unstake",
@@ -42250,7 +42306,8 @@ const GLAM_CONFIG_PROGRAM = new web3_js.PublicKey("gConFzxKL9USmwTdJoeQJvfKmqhJ2
42250
42306
  // @anchor/programs/ext_drift/src/state/acl.rs
42251
42307
  [getExtDriftProgramId().toBase58()]: {
42252
42308
  "0000000000000001": {
42253
- name: "Drift Protocol",
42309
+ name: "DriftProtocol",
42310
+ staging: false,
42254
42311
  permissions: {
42255
42312
  [1 << 0]: "InitUser",
42256
42313
  [1 << 1]: "UpdateUser",
@@ -42266,7 +42323,8 @@ const GLAM_CONFIG_PROGRAM = new web3_js.PublicKey("gConFzxKL9USmwTdJoeQJvfKmqhJ2
42266
42323
  }
42267
42324
  },
42268
42325
  "0000000000000010": {
42269
- name: "Drift Vaults",
42326
+ name: "DriftVaults",
42327
+ staging: false,
42270
42328
  permissions: {
42271
42329
  [1 << 0]: "Deposit",
42272
42330
  [1 << 1]: "Withdraw"
@@ -42277,7 +42335,8 @@ const GLAM_CONFIG_PROGRAM = new web3_js.PublicKey("gConFzxKL9USmwTdJoeQJvfKmqhJ2
42277
42335
  // @anchor/programs/ext_spl/src/state/acl.rs
42278
42336
  [getExtSplProgramId().toBase58()]: {
42279
42337
  "0000000000000001": {
42280
- name: "Spl Token",
42338
+ name: "SplToken",
42339
+ staging: false,
42281
42340
  permissions: {
42282
42341
  [1 << 0]: "Transfer"
42283
42342
  }
@@ -42288,6 +42347,7 @@ const GLAM_CONFIG_PROGRAM = new web3_js.PublicKey("gConFzxKL9USmwTdJoeQJvfKmqhJ2
42288
42347
  [getExtCctpProgramId().toBase58()]: {
42289
42348
  "0000000000000001": {
42290
42349
  name: "CCTP",
42350
+ staging: false,
42291
42351
  permissions: {
42292
42352
  [1 << 0]: "Transfer"
42293
42353
  }
@@ -42298,6 +42358,7 @@ const GLAM_CONFIG_PROGRAM = new web3_js.PublicKey("gConFzxKL9USmwTdJoeQJvfKmqhJ2
42298
42358
  [getExtMarinadeProgramId().toBase58()]: {
42299
42359
  "0000000000000001": {
42300
42360
  name: "Marinade",
42361
+ staging: true,
42301
42362
  permissions: {
42302
42363
  [1 << 0]: "Stake",
42303
42364
  [1 << 1]: "Unstake"
@@ -42308,7 +42369,8 @@ const GLAM_CONFIG_PROGRAM = new web3_js.PublicKey("gConFzxKL9USmwTdJoeQJvfKmqhJ2
42308
42369
  // @anchor/programs/ext_stake_pool/src/state/acl.rs
42309
42370
  [getExtStakePoolProgramId().toBase58()]: {
42310
42371
  "0000000000000001": {
42311
- name: "Stake Pool",
42372
+ name: "StakePool",
42373
+ staging: true,
42312
42374
  permissions: {
42313
42375
  [1 << 0]: "DepositSol",
42314
42376
  [1 << 1]: "DepositStake",
@@ -42319,7 +42381,8 @@ const GLAM_CONFIG_PROGRAM = new web3_js.PublicKey("gConFzxKL9USmwTdJoeQJvfKmqhJ2
42319
42381
  }
42320
42382
  },
42321
42383
  "0000000000000010": {
42322
- name: "Sanctum Single",
42384
+ name: "SanctumSingle",
42385
+ staging: true,
42323
42386
  permissions: {
42324
42387
  [1 << 0]: "DepositSol",
42325
42388
  [1 << 1]: "DepositStake",
@@ -42330,7 +42393,8 @@ const GLAM_CONFIG_PROGRAM = new web3_js.PublicKey("gConFzxKL9USmwTdJoeQJvfKmqhJ2
42330
42393
  }
42331
42394
  },
42332
42395
  "0000000000000100": {
42333
- name: "Sanctum Multi",
42396
+ name: "SanctumMulti",
42397
+ staging: true,
42334
42398
  permissions: {
42335
42399
  [1 << 0]: "DepositSol",
42336
42400
  [1 << 1]: "DepositStake",
@@ -42360,7 +42424,7 @@ const GLAM_CONFIG_PROGRAM = new web3_js.PublicKey("gConFzxKL9USmwTdJoeQJvfKmqhJ2
42360
42424
  const mapping = {};
42361
42425
  Object.entries(getProtocolsAndPermissions()).forEach(([programId, protocols])=>{
42362
42426
  Object.entries(protocols).forEach(([bitflag, protocol])=>{
42363
- const name = protocol.name.replace(" ", "");
42427
+ const name = protocol.name;
42364
42428
  mapping[name] = [
42365
42429
  programId,
42366
42430
  bitflag
@@ -42723,7 +42787,15 @@ const getStakeAccountsWithStates = async (connection, withdrawAuthority)=>{
42723
42787
  1,
42724
42788
  0,
42725
42789
  0,
42726
- 0
42790
+ 0,
42791
+ 0xff,
42792
+ 0xff,
42793
+ 0xff,
42794
+ 0xff,
42795
+ 0xff,
42796
+ 0xff,
42797
+ 0xff,
42798
+ 0xff
42727
42799
  ])
42728
42800
  }
42729
42801
  },
@@ -42860,6 +42932,37 @@ const getStakeAccountsWithStates = async (connection, withdrawAuthority)=>{
42860
42932
  permissions
42861
42933
  };
42862
42934
  }
42935
+ /**
42936
+ * Given the protocol name and a list of permission names, returns the permissions bitmask.
42937
+ */ function parsePermissionNames({ protocolName, permissionNames }) {
42938
+ const protocolConfig = getProgramAndBitflagByProtocolName()[protocolName];
42939
+ if (!protocolConfig) {
42940
+ throw new Error(`Unknown protocol name ${protocolName}`);
42941
+ }
42942
+ const [programIdStr, bitflagStr] = protocolConfig;
42943
+ const protocolPermissions = getProtocolsAndPermissions()[programIdStr]?.[bitflagStr];
42944
+ if (!protocolPermissions) {
42945
+ throw new Error(`Protocol mapping not found for protocol name ${protocolName}`);
42946
+ }
42947
+ const integrationProgram = new web3_js.PublicKey(programIdStr);
42948
+ const protocolBitflag = parseInt(bitflagStr, 2);
42949
+ // Calculate permissions bitmask
42950
+ const permissionNameToBitflag = {};
42951
+ for (const [bitflag, name] of Object.entries(protocolPermissions.permissions)){
42952
+ permissionNameToBitflag[name] = new anchor.BN(bitflag);
42953
+ }
42954
+ const permissionsBitmask = permissionNames.reduce((mask, p)=>{
42955
+ if (!permissionNameToBitflag[p]) {
42956
+ throw new Error(`Unknown permission name ${p} for protocol name ${protocolName}`);
42957
+ }
42958
+ return mask.or(permissionNameToBitflag[p]);
42959
+ }, new anchor.BN(0));
42960
+ return {
42961
+ integrationProgram,
42962
+ protocolBitflag,
42963
+ permissionsBitmask
42964
+ };
42965
+ }
42863
42966
 
42864
42967
  class BlockhashWithCache {
42865
42968
  async get() {
@@ -42962,6 +43065,12 @@ const publicKeyToEvmAddress = (publicKey)=>{
42962
43065
  const evmAddress = hex.slice(-40);
42963
43066
  return `0x${evmAddress}`;
42964
43067
  };
43068
+ /**
43069
+ * Validates if a string is a valid EVM address (40 hex characters)
43070
+ */ const isValidEvmAddress = (addr)=>{
43071
+ const cleanAddr = addr.startsWith("0x") ? addr.slice(2) : addr;
43072
+ return /^[0-9a-fA-F]{40}$/.test(cleanAddr);
43073
+ };
42965
43074
 
42966
43075
  function getStatePda(initKey, owner, programId) {
42967
43076
  const [pda, _bump] = web3_js.PublicKey.findProgramAddressSync([
@@ -43575,8 +43684,28 @@ const getErrorFromRpcResponse = (rpcResponse)=>{
43575
43684
  }
43576
43685
  };
43577
43686
 
43687
+ function readUnsignedBigInt64LE(buffer, offset) {
43688
+ return new anchor.BN(buffer.subarray(offset, offset + 8), 10, "le");
43689
+ }
43690
+ function readSignedBigInt64LE(buffer, offset) {
43691
+ const unsignedValue = new anchor.BN(buffer.subarray(offset, offset + 8), 10, "le");
43692
+ if (unsignedValue.testn(63)) {
43693
+ const inverted = unsignedValue.notn(64).addn(1);
43694
+ return inverted.neg();
43695
+ } else {
43696
+ return unsignedValue;
43697
+ }
43698
+ }
43699
+ function readI128LE(buffer, offset) {
43700
+ const lo = buffer.readBigUInt64LE(offset);
43701
+ const hi = buffer.readBigUInt64LE(offset + 8);
43702
+ let v = (hi << 64n) + lo;
43703
+ if ((hi & 1n << 63n) !== 0n) {
43704
+ v -= 1n << 128n;
43705
+ }
43706
+ return new anchor.BN(v.toString());
43707
+ }
43578
43708
  const ZERO = new anchor.BN(0);
43579
- // # Utility Types / Enums / Constants
43580
43709
  var ExchangeStatus = /*#__PURE__*/ function(ExchangeStatus) {
43581
43710
  ExchangeStatus[ExchangeStatus["ACTIVE"] = 0] = "ACTIVE";
43582
43711
  ExchangeStatus[ExchangeStatus["DEPOSIT_PAUSED"] = 1] = "DEPOSIT_PAUSED";
@@ -44019,65 +44148,6 @@ StakeAction.UNSTAKE_TRANSFER = {
44019
44148
  StakeAction.STAKE_TRANSFER = {
44020
44149
  stakeTransfer: {}
44021
44150
  };
44022
- class SettlePnlMode {
44023
- }
44024
- SettlePnlMode.TRY_SETTLE = {
44025
- trySettle: {}
44026
- };
44027
- SettlePnlMode.MUST_SETTLE = {
44028
- mustSettle: {}
44029
- };
44030
- function isVariant(object, type) {
44031
- return object.hasOwnProperty(type);
44032
- }
44033
- function isOneOfVariant(object, types) {
44034
- return types.reduce((result, type)=>{
44035
- return result || object.hasOwnProperty(type);
44036
- }, false);
44037
- }
44038
- function getVariant(object) {
44039
- return Object.keys(object)[0];
44040
- }
44041
- var TradeSide = /*#__PURE__*/ function(TradeSide) {
44042
- TradeSide[TradeSide["None"] = 0] = "None";
44043
- TradeSide[TradeSide["Buy"] = 1] = "Buy";
44044
- TradeSide[TradeSide["Sell"] = 2] = "Sell";
44045
- return TradeSide;
44046
- }({});
44047
- class LPAction {
44048
- }
44049
- LPAction.ADD_LIQUIDITY = {
44050
- addLiquidity: {}
44051
- };
44052
- LPAction.REMOVE_LIQUIDITY = {
44053
- removeLiquidity: {}
44054
- };
44055
- LPAction.SETTLE_LIQUIDITY = {
44056
- settleLiquidity: {}
44057
- };
44058
- LPAction.REMOVE_LIQUIDITY_DERISK = {
44059
- removeLiquidityDerisk: {}
44060
- };
44061
- class LiquidationType {
44062
- }
44063
- LiquidationType.LIQUIDATE_PERP = {
44064
- liquidatePerp: {}
44065
- };
44066
- LiquidationType.LIQUIDATE_BORROW_FOR_PERP_PNL = {
44067
- liquidateBorrowForPerpPnl: {}
44068
- };
44069
- LiquidationType.LIQUIDATE_PERP_PNL_FOR_DEPOSIT = {
44070
- liquidatePerpPnlForDeposit: {}
44071
- };
44072
- LiquidationType.PERP_BANKRUPTCY = {
44073
- perpBankruptcy: {}
44074
- };
44075
- LiquidationType.SPOT_BANKRUPTCY = {
44076
- spotBankruptcy: {}
44077
- };
44078
- LiquidationType.LIQUIDATE_SPOT = {
44079
- liquidateSpot: {}
44080
- };
44081
44151
  class PostOnlyParams {
44082
44152
  }
44083
44153
  PostOnlyParams.NONE = {
@@ -44116,28 +44186,6 @@ const DefaultOrderParams = {
44116
44186
  auctionStartPrice: null,
44117
44187
  auctionEndPrice: null
44118
44188
  };
44119
- var ReferrerStatus = /*#__PURE__*/ function(ReferrerStatus) {
44120
- ReferrerStatus[ReferrerStatus["IsReferrer"] = 1] = "IsReferrer";
44121
- ReferrerStatus[ReferrerStatus["IsReferred"] = 2] = "IsReferred";
44122
- return ReferrerStatus;
44123
- }({});
44124
- var FuelOverflowStatus = /*#__PURE__*/ function(FuelOverflowStatus) {
44125
- FuelOverflowStatus[FuelOverflowStatus["Exists"] = 1] = "Exists";
44126
- return FuelOverflowStatus;
44127
- }({});
44128
- var PlaceAndTakeOrderSuccessCondition = /*#__PURE__*/ function(PlaceAndTakeOrderSuccessCondition) {
44129
- PlaceAndTakeOrderSuccessCondition[PlaceAndTakeOrderSuccessCondition["PartialFill"] = 1] = "PartialFill";
44130
- PlaceAndTakeOrderSuccessCondition[PlaceAndTakeOrderSuccessCondition["FullFill"] = 2] = "FullFill";
44131
- return PlaceAndTakeOrderSuccessCondition;
44132
- }({});
44133
- class SwapReduceOnly {
44134
- }
44135
- SwapReduceOnly.In = {
44136
- in: {}
44137
- };
44138
- SwapReduceOnly.Out = {
44139
- out: {}
44140
- };
44141
44189
 
44142
44190
  function getLimitOrderParams(params) {
44143
44191
  return getOrderParams(Object.assign({}, params, {
@@ -44174,19 +44222,6 @@ function getMarketOrderParams(params) {
44174
44222
  return Object.assign({}, DefaultOrderParams, optionalOrderParams, overridingParams);
44175
44223
  }
44176
44224
 
44177
- function readUnsignedBigInt64LE(buffer, offset) {
44178
- return new anchor.BN(buffer.subarray(offset, offset + 8), 10, "le");
44179
- }
44180
- function readSignedBigInt64LE(buffer, offset) {
44181
- const unsignedValue = new anchor.BN(buffer.subarray(offset, offset + 8), 10, "le");
44182
- if (unsignedValue.testn(63)) {
44183
- const inverted = unsignedValue.notn(64).addn(1);
44184
- return inverted.neg();
44185
- } else {
44186
- return unsignedValue;
44187
- }
44188
- }
44189
-
44190
44225
  const FractionDecimal = Decimal.clone({
44191
44226
  precision: 40
44192
44227
  });
@@ -44235,6 +44270,21 @@ function bfToDecimal(x) {
44235
44270
  return new Fraction(accSf).toDecimal();
44236
44271
  }
44237
44272
 
44273
+ class JupTokenList {
44274
+ getByMint(mintAddress) {
44275
+ return this.mintMap.get(mintAddress.toString());
44276
+ }
44277
+ getBySymbol(symbol) {
44278
+ return this.tokens.find((token)=>token.symbol === symbol);
44279
+ }
44280
+ constructor(tokens){
44281
+ this.tokens = tokens;
44282
+ this.mintMap = new Map(tokens.map((token)=>[
44283
+ token.address,
44284
+ token
44285
+ ]));
44286
+ }
44287
+ }
44238
44288
  const TOKEN_LIST_CACHE_TTL = 5 * 60 * 1000; // 5 minutes
44239
44289
  const JUPITER_API_DEFAULT = "https://api.jup.ag";
44240
44290
  // Zod schemas for runtime validation
@@ -44293,11 +44343,12 @@ class JupiterApiClient {
44293
44343
  usdPrice: t.usdPrice,
44294
44344
  slot: t.priceBlockId
44295
44345
  }));
44346
+ const jupTokenList = new JupTokenList(tokenList);
44296
44347
  this.tokenListCache = {
44297
- data: tokenList,
44348
+ data: jupTokenList,
44298
44349
  timestamp: Date.now()
44299
44350
  };
44300
- return tokenList;
44351
+ return jupTokenList;
44301
44352
  }
44302
44353
  async fetchProgramLabels() {
44303
44354
  if (!this.apiKey) {
@@ -44399,7 +44450,7 @@ class JupiterApiClient {
44399
44450
  return this.id?.toBase58() || "";
44400
44451
  }
44401
44452
  get nameStr() {
44402
- return this.name ? charsToName(this.name) : "";
44453
+ return this.name ? charsToString(this.name) : "";
44403
44454
  }
44404
44455
  get productType() {
44405
44456
  // @ts-ignore
@@ -44411,12 +44462,8 @@ class JupiterApiClient {
44411
44462
  return new Date(createdAt * 1000).toISOString().split("T")[0] || "Unknown";
44412
44463
  }
44413
44464
  get sparkleKey() {
44414
- if (!this.mint && !this.id) {
44415
- throw new Error("Cannot generate sparkle key");
44416
- }
44417
- // An edge case is mint is closed but state account is not
44418
- // this.mint would be `null`
44419
- return (!this.mint?.equals(web3_js.PublicKey.default) ? this.id : this.mint)?.toBase58();
44465
+ const pubkey = (this.mint?.equals(web3_js.PublicKey.default) ? this.id : this.mint) || web3_js.PublicKey.default;
44466
+ return pubkey.toBase58();
44420
44467
  }
44421
44468
  get baseAssetTokenProgramId() {
44422
44469
  switch(this.baseAssetTokenProgram){
@@ -44498,7 +44545,7 @@ class JupiterApiClient {
44498
44545
  const extMetadata = splToken.getExtensionData(splToken.ExtensionType.TokenMetadata, glamMint.tlvData);
44499
44546
  const tokenMetadata = extMetadata ? splTokenMetadata.unpack(extMetadata) : {};
44500
44547
  mintModel["symbol"] = tokenMetadata?.symbol;
44501
- mintModel["name"] = nameToChars(tokenMetadata?.name);
44548
+ mintModel["name"] = stringToChars(tokenMetadata?.name);
44502
44549
  mintModel["uri"] = tokenMetadata?.uri;
44503
44550
  if (tokenMetadata?.additionalMetadata) {
44504
44551
  tokenMetadata.additionalMetadata.forEach(([k, v])=>{
@@ -44564,6 +44611,18 @@ class StateAccountType {
44564
44611
  static equals(a, b) {
44565
44612
  return Object.keys(a)[0] === Object.keys(b)[0];
44566
44613
  }
44614
+ static from(s) {
44615
+ if (s === "vault") {
44616
+ return StateAccountType.VAULT;
44617
+ }
44618
+ if (s === "tokenizedVault") {
44619
+ return StateAccountType.TOKENIZED_VAULT;
44620
+ }
44621
+ if (s === "mint") {
44622
+ return StateAccountType.MINT;
44623
+ }
44624
+ throw new Error(`Invalid state account type: ${s}`);
44625
+ }
44567
44626
  }
44568
44627
  StateAccountType.VAULT = {
44569
44628
  vault: {}
@@ -45097,10 +45156,11 @@ class BaseClient {
45097
45156
  });
45098
45157
  anchor__namespace.setProvider(this.provider);
45099
45158
  }
45100
- this.cluster = config?.cluster || exports.ClusterNetwork.fromUrl(this.provider.connection.rpcEndpoint);
45101
45159
  if (config?.statePda) {
45102
45160
  this.statePda = config.statePda;
45103
45161
  }
45162
+ this.cluster = config?.cluster || exports.ClusterNetwork.fromUrl(this.provider.connection.rpcEndpoint);
45163
+ this.jupiterApiKey = config?.jupiterApiKey;
45104
45164
  this.blockhashWithCache = new BlockhashWithCache(this.provider);
45105
45165
  }
45106
45166
  }
@@ -45124,9 +45184,6 @@ class BaseClient {
45124
45184
  }
45125
45185
  }
45126
45186
 
45127
- const DRIFT_SIGNER = new web3_js.PublicKey("JCNCMFXo5M5qwUPg2Utu1u6YWp3MbygxqBsBeXXJfrw");
45128
- const DRIFT_MARGIN_PRECISION = 10000;
45129
-
45130
45187
  /**
45131
45188
  * Base class for decodable on-chain account structures.
45132
45189
  *
@@ -45148,16 +45205,97 @@ const DRIFT_MARGIN_PRECISION = 10000;
45148
45205
  }
45149
45206
  }
45150
45207
 
45151
- function readI128LE(buffer, offset) {
45152
- const lo = buffer.readBigUInt64LE(offset);
45153
- const hi = buffer.readBigUInt64LE(offset + 8);
45154
- let v = (hi << 64n) + lo;
45155
- if ((hi & 1n << 63n) !== 0n) {
45156
- v -= 1n << 128n;
45208
+ class SpotPosition {
45209
+ get marketPda() {
45210
+ return web3_js.PublicKey.findProgramAddressSync([
45211
+ Buffer.from("spot_market"),
45212
+ new anchor.BN(this.marketIndex).toArrayLike(Buffer, "le", 2)
45213
+ ], DRIFT_PROGRAM_ID)[0];
45214
+ }
45215
+ calcBalance(decimals, cumulativeDepositInterest, cumulativeBorrowInterest) {
45216
+ const precisionAdjustment = new anchor.BN(10 ** (19 - decimals));
45217
+ const balance = this.scaledBalance.mul(this._interest(cumulativeDepositInterest, cumulativeBorrowInterest)).div(precisionAdjustment);
45218
+ const amount = this.balanceType === SpotBalanceType.BORROW ? balance.neg().toNumber() : balance.toNumber();
45219
+ const uiAmount = amount / 10 ** decimals;
45220
+ return {
45221
+ amount,
45222
+ uiAmount
45223
+ };
45224
+ }
45225
+ calcBalanceBn(decimals, cumulativeDepositInterest, cumulativeBorrowInterest) {
45226
+ const precisionAdjustment = new anchor.BN(10 ** (19 - decimals));
45227
+ const sign = this.balanceType === SpotBalanceType.BORROW ? new anchor.BN(-1) : new anchor.BN(1);
45228
+ return this.scaledBalance.mul(this._interest(cumulativeDepositInterest, cumulativeBorrowInterest)).div(precisionAdjustment).mul(sign);
45229
+ }
45230
+ _interest(cumulativeDepositInterest, cumulativeBorrowInterest) {
45231
+ return this.balanceType === SpotBalanceType.BORROW ? cumulativeBorrowInterest : cumulativeDepositInterest;
45232
+ }
45233
+ get direction() {
45234
+ return this.balanceType === SpotBalanceType.BORROW ? "borrow" : "deposit";
45235
+ }
45236
+ constructor(data){
45237
+ this.marketIndex = data?.marketIndex;
45238
+ this.balanceType = data?.balanceType;
45239
+ this.scaledBalance = data?.scaledBalance;
45240
+ this.openOrders = data?.openOrders;
45241
+ this.openBids = data?.openBids;
45242
+ this.openAsks = data?.openAsks;
45243
+ this.cumulativeDeposits = data?.cumulativeDeposits;
45244
+ }
45245
+ }
45246
+ class PerpPosition {
45247
+ get marketPda() {
45248
+ return web3_js.PublicKey.findProgramAddressSync([
45249
+ Buffer.from("perp_market"),
45250
+ new anchor.BN(this.marketIndex).toArrayLike(Buffer, "le", 2)
45251
+ ], DRIFT_PROGRAM_ID)[0];
45252
+ }
45253
+ baseAssetValue(oraclePrice) {
45254
+ return this.baseAssetAmount.mul(oraclePrice).div(new anchor.BN(1000000000));
45255
+ }
45256
+ unrealizedPnl(oraclePrice) {
45257
+ return this.baseAssetValue(oraclePrice).add(this.quoteAssetAmount);
45258
+ }
45259
+ getUsdValueScaled(oraclePrice, cumulativeFundingRateLong, cumulativeFundingRateShort) {
45260
+ const unrealizedPnl = this.unrealizedPnl(oraclePrice);
45261
+ const fundingPayment = this.calcFundingPayment(cumulativeFundingRateLong, cumulativeFundingRateShort);
45262
+ return unrealizedPnl.add(fundingPayment);
45263
+ }
45264
+ calcFundingPayment(cumulativeFundingRateLong, cumulativeFundingRateShort) {
45265
+ const fundingRate = this.baseAssetAmount.isNeg() ? cumulativeFundingRateShort : cumulativeFundingRateLong;
45266
+ const fundingRateDelta = fundingRate.sub(this.lastCumulativeFundingRate);
45267
+ if (fundingRateDelta.eq(new anchor.BN(0))) {
45268
+ return new anchor.BN(0);
45269
+ }
45270
+ const fundingRateDeltaSign = fundingRateDelta.isNeg() ? -1 : 1;
45271
+ const usdPricePrecision = new anchor.BN(1000000);
45272
+ const fundingRatePaymentMagnitude = fundingRateDelta.abs().mul(this.baseAssetAmount.abs()).div(usdPricePrecision).div(new anchor.BN(1000));
45273
+ const fundingRatePaymentSign = this.baseAssetAmount.isNeg() ? 1 : -1;
45274
+ const sign = fundingRatePaymentSign * fundingRateDeltaSign;
45275
+ return sign < 0 ? fundingRatePaymentMagnitude.neg() : fundingRatePaymentMagnitude;
45276
+ }
45277
+ constructor(data){
45278
+ this.baseAssetAmount = data?.baseAssetAmount;
45279
+ this.lastCumulativeFundingRate = data?.lastCumulativeFundingRate;
45280
+ this.marketIndex = data?.marketIndex;
45281
+ this.quoteAssetAmount = data?.quoteAssetAmount;
45282
+ this.quoteEntryAmount = data?.quoteEntryAmount;
45283
+ this.quoteBreakEvenAmount = data?.quoteBreakEvenAmount;
45284
+ this.openOrders = data?.openOrders;
45285
+ this.openBids = data?.openBids;
45286
+ this.openAsks = data?.openAsks;
45287
+ this.settledPnl = data?.settledPnl;
45288
+ this.lpShares = data?.lpShares;
45289
+ this.remainderBaseAssetAmount = data?.remainderBaseAssetAmount;
45290
+ this.lastBaseAssetAmountPerLp = data?.lastBaseAssetAmountPerLp;
45291
+ this.lastQuoteAssetAmountPerLp = data?.lastQuoteAssetAmountPerLp;
45292
+ this.perLpBase = data?.perLpBase;
45157
45293
  }
45158
- return new anchor.BN(v.toString());
45159
45294
  }
45160
45295
  class DriftVaultDepositor extends Decodable {
45296
+ get netShares() {
45297
+ return this.vaultShares.sub(this.lastWithdrawRequest.shares);
45298
+ }
45161
45299
  }
45162
45300
  DriftVaultDepositor._layout = borsh.struct([
45163
45301
  borsh.array(borsh.u8(), 8, "discriminator"),
@@ -45184,7 +45322,7 @@ DriftVaultDepositor._layout = borsh.struct([
45184
45322
  ]);
45185
45323
  class DriftVault extends Decodable {
45186
45324
  get name() {
45187
- return charsToName(this.nameBytes);
45325
+ return charsToString(this.nameBytes);
45188
45326
  }
45189
45327
  marketPda(marketType, marketIndex) {
45190
45328
  const marketTypeStr = marketType === MarketType.SPOT ? "spot" : "perp";
@@ -45195,21 +45333,15 @@ class DriftVault extends Decodable {
45195
45333
  }
45196
45334
  aum(spotPositions, perpPositions, spotMarketsMap, perpMarketsMap) {
45197
45335
  const positionBalances = [];
45198
- for (const { marketIndex, scaledBalance, balanceType } of spotPositions){
45199
- const marketPda = this.marketPda(MarketType.SPOT, marketIndex);
45200
- const spotMarket = spotMarketsMap.get(marketPda);
45201
- const amount = spotMarket.calcSpotBalanceBn(scaledBalance, balanceType);
45202
- const balance = amount.mul(spotMarket.lastOraclePrice).div(new anchor.BN(10 ** spotMarket.decimals));
45336
+ for (const spotPosition of spotPositions){
45337
+ const { decimals, lastOraclePrice, cumulativeDepositInterest, cumulativeBorrowInterest } = spotMarketsMap.get(spotPosition.marketPda);
45338
+ const amount = spotPosition.calcBalanceBn(decimals, cumulativeDepositInterest, cumulativeBorrowInterest);
45339
+ const balance = amount.mul(lastOraclePrice).div(new anchor.BN(10 ** decimals));
45203
45340
  positionBalances.push(balance);
45204
45341
  }
45205
45342
  for (const perpPosition of perpPositions){
45206
- const { baseAssetAmount, quoteAssetAmount, marketIndex } = perpPosition;
45207
- const marketPda = this.marketPda(MarketType.PERP, marketIndex);
45208
- const perpMarket = perpMarketsMap.get(marketPda);
45209
- const baseAssetValue = baseAssetAmount.mul(perpMarket.lastOraclePrice).div(new anchor.BN(1000000000));
45210
- const unrealizedPnl = baseAssetValue.add(quoteAssetAmount);
45211
- const fundingPayment = perpMarket.calcFundingPayment(perpPosition);
45212
- positionBalances.push(unrealizedPnl.add(fundingPayment));
45343
+ const { lastOraclePrice, cumulativeFundingRateLong, cumulativeFundingRateShort } = perpMarketsMap.get(perpPosition.marketPda);
45344
+ positionBalances.push(perpPosition.getUsdValueScaled(lastOraclePrice, cumulativeFundingRateLong, cumulativeFundingRateShort));
45213
45345
  }
45214
45346
  return positionBalances.reduce((a, b)=>a.add(b), new anchor.BN(0));
45215
45347
  }
@@ -45323,15 +45455,15 @@ class DriftUser {
45323
45455
  balanceType = SpotBalanceType.BORROW;
45324
45456
  }
45325
45457
  offset += 6;
45326
- spotPositions.push({
45458
+ spotPositions.push(new SpotPosition({
45459
+ marketIndex,
45460
+ balanceType,
45327
45461
  scaledBalance,
45462
+ openOrders,
45328
45463
  openBids,
45329
45464
  openAsks,
45330
- cumulativeDeposits,
45331
- marketIndex,
45332
- balanceType,
45333
- openOrders
45334
- });
45465
+ cumulativeDeposits
45466
+ }));
45335
45467
  }
45336
45468
  const perpPositions = [];
45337
45469
  for(let i = 0; i < 8; i++){
@@ -45365,23 +45497,23 @@ class DriftUser {
45365
45497
  offset += 3;
45366
45498
  const perLpBase = buffer.readUInt8(offset);
45367
45499
  offset += 1;
45368
- perpPositions.push({
45369
- lastCumulativeFundingRate,
45500
+ perpPositions.push(new PerpPosition({
45370
45501
  baseAssetAmount,
45502
+ lastCumulativeFundingRate,
45503
+ marketIndex,
45371
45504
  quoteAssetAmount,
45372
- quoteBreakEvenAmount,
45373
45505
  quoteEntryAmount,
45506
+ quoteBreakEvenAmount,
45507
+ openOrders,
45374
45508
  openBids,
45375
45509
  openAsks,
45376
45510
  settledPnl,
45377
45511
  lpShares,
45512
+ remainderBaseAssetAmount,
45378
45513
  lastBaseAssetAmountPerLp,
45379
45514
  lastQuoteAssetAmountPerLp,
45380
- remainderBaseAssetAmount,
45381
- marketIndex,
45382
- openOrders,
45383
45515
  perLpBase
45384
- });
45516
+ }));
45385
45517
  }
45386
45518
  const orders = [];
45387
45519
  for(let i = 0; i < 32; i++){
@@ -45612,7 +45744,7 @@ class DriftUser {
45612
45744
  return instance;
45613
45745
  }
45614
45746
  get name() {
45615
- return charsToName(this.nameBytes);
45747
+ return charsToString(this.nameBytes);
45616
45748
  }
45617
45749
  getAddress() {
45618
45750
  return this._address;
@@ -45620,7 +45752,7 @@ class DriftUser {
45620
45752
  }
45621
45753
  class DriftSpotMarket extends Decodable {
45622
45754
  get name() {
45623
- return charsToName(this.nameBytes);
45755
+ return charsToString(this.nameBytes);
45624
45756
  }
45625
45757
  get oracleSource() {
45626
45758
  return OracleSource.get(this.oracleSourceOrd);
@@ -45628,24 +45760,6 @@ class DriftSpotMarket extends Decodable {
45628
45760
  get tokenProgramId() {
45629
45761
  return this.tokenProgram === 0 ? splToken.TOKEN_PROGRAM_ID : splToken.TOKEN_2022_PROGRAM_ID;
45630
45762
  }
45631
- calcSpotBalance(scaledBalance, scaledBalanceType) {
45632
- const precisionAdjustment = new anchor.BN(10 ** (19 - this.decimals));
45633
- const balance = scaledBalance.mul(this._interest(scaledBalanceType)).div(precisionAdjustment);
45634
- const amount = scaledBalanceType === SpotBalanceType.BORROW ? balance.neg().toNumber() : balance.toNumber();
45635
- const uiAmount = amount / 10 ** this.decimals;
45636
- return {
45637
- amount,
45638
- uiAmount
45639
- };
45640
- }
45641
- calcSpotBalanceBn(scaledBalance, scaledBalanceType) {
45642
- const precisionAdjustment = new anchor.BN(10 ** (19 - this.decimals));
45643
- const sign = scaledBalanceType === SpotBalanceType.BORROW ? new anchor.BN(-1) : new anchor.BN(1);
45644
- return scaledBalance.mul(this._interest(scaledBalanceType)).div(precisionAdjustment).mul(sign);
45645
- }
45646
- _interest(balanceType) {
45647
- return balanceType === SpotBalanceType.BORROW ? this.cumulativeBorrowInterest : this.cumulativeDepositInterest;
45648
- }
45649
45763
  }
45650
45764
  DriftSpotMarket._layout = borsh.struct([
45651
45765
  borsh.array(borsh.u8(), 8, "discriminator"),
@@ -45680,24 +45794,11 @@ class DriftPerpMarket extends Decodable {
45680
45794
  return instance;
45681
45795
  }
45682
45796
  get name() {
45683
- return charsToName(this.nameBytes);
45797
+ return charsToString(this.nameBytes);
45684
45798
  }
45685
45799
  get oracleSource() {
45686
45800
  return OracleSource.get(this.oracleSourceOrd);
45687
45801
  }
45688
- calcFundingPayment(perpPosition) {
45689
- const fundingRate = perpPosition.baseAssetAmount.isNeg() ? this.cumulativeFundingRateShort : this.cumulativeFundingRateLong;
45690
- const fundingRateDelta = fundingRate.sub(perpPosition.lastCumulativeFundingRate);
45691
- if (fundingRateDelta.eq(new anchor.BN(0))) {
45692
- return new anchor.BN(0);
45693
- }
45694
- const fundingRateDeltaSign = fundingRateDelta.isNeg() ? -1 : 1;
45695
- const usdPricePrecision = new anchor.BN(1000000);
45696
- const fundingRatePaymentMagnitude = fundingRateDelta.abs().mul(perpPosition.baseAssetAmount.abs()).div(usdPricePrecision).div(new anchor.BN(1000));
45697
- const fundingRatePaymentSign = perpPosition.baseAssetAmount.isNeg() ? 1 : -1;
45698
- const sign = fundingRatePaymentSign * fundingRateDeltaSign;
45699
- return sign < 0 ? fundingRatePaymentMagnitude.neg() : fundingRatePaymentMagnitude;
45700
- }
45701
45802
  }
45702
45803
  DriftPerpMarket._layout = borsh.struct([
45703
45804
  borsh.array(borsh.u8(), 8, "discriminator"),
@@ -45714,6 +45815,31 @@ DriftPerpMarket._layout = borsh.struct([
45714
45815
  borsh.u16("quoteSpotMarketIndex")
45715
45816
  ]);
45716
45817
 
45818
+ const DRIFT_SIGNER = new web3_js.PublicKey("JCNCMFXo5M5qwUPg2Utu1u6YWp3MbygxqBsBeXXJfrw");
45819
+ const DRIFT_MARGIN_PRECISION = 10000;
45820
+ class DriftMarketConfigs {
45821
+ getPerp(marketIndex) {
45822
+ const market = this.perpMarkets[marketIndex];
45823
+ if (market.marketIndex === marketIndex) {
45824
+ return market;
45825
+ }
45826
+ }
45827
+ getSpot(mintOrIndex) {
45828
+ if (typeof mintOrIndex === "number") {
45829
+ const market = this.spotMarkets[mintOrIndex];
45830
+ if (market.marketIndex === mintOrIndex) {
45831
+ return market;
45832
+ }
45833
+ } else {
45834
+ return this.spotMarkets.find(({ mint })=>mint.equals(mintOrIndex));
45835
+ }
45836
+ }
45837
+ constructor(orderConstants, perpMarkets, spotMarkets){
45838
+ this.orderConstants = orderConstants;
45839
+ this.perpMarkets = perpMarkets;
45840
+ this.spotMarkets = spotMarkets;
45841
+ }
45842
+ }
45717
45843
  let TxBuilder$g = class TxBuilder extends BaseTxBuilder {
45718
45844
  async initializeUserStatsIx(glamSigner) {
45719
45845
  const { userStats } = this.client.getDriftUserPdas();
@@ -46115,6 +46241,15 @@ class DriftProtocolClient {
46115
46241
  userStats: this.getUserStatsPda(vault)
46116
46242
  };
46117
46243
  }
46244
+ getSubAccountId(driftUser) {
46245
+ for(let i = 0; i < 100; ++i){
46246
+ const { user } = this.getDriftUserPdas(i);
46247
+ if (user.equals(driftUser)) {
46248
+ return i;
46249
+ }
46250
+ }
46251
+ throw new Error("Sub account not found");
46252
+ }
46118
46253
  get driftStatePda() {
46119
46254
  return web3_js.PublicKey.findProgramAddressSync([
46120
46255
  Buffer.from("drift_state")
@@ -46181,7 +46316,7 @@ class DriftProtocolClient {
46181
46316
  }
46182
46317
  const perpMarkets = marketIndexes.map((marketIndex)=>this.perpMarkets.get(marketIndex)).filter((m)=>m !== undefined);
46183
46318
  const invalidIndexes = marketIndexes.filter((marketIndex)=>!this.perpMarkets.has(marketIndex));
46184
- if (invalidIndexes.length > 0) {
46319
+ if (invalidIndexes.length > 0 && process.env.NODE_ENV === "development") {
46185
46320
  console.warn(`The following perp markets could not be found: ${invalidIndexes.join(", ")}`);
46186
46321
  }
46187
46322
  return perpMarkets;
@@ -46193,14 +46328,10 @@ class DriftProtocolClient {
46193
46328
  // FIXME: one day the number of markets will exceed 100 and a better solution will be needed
46194
46329
  const perpMarkets = await this.fetchAndParsePerpMarkets(Array.from(Array(100).keys()), skipCache);
46195
46330
  const spotMarkets = await this.fetchAndParseSpotMarkets(Array.from(Array(100).keys()), skipCache);
46196
- this.marketConfigs = {
46197
- orderConstants: {
46198
- perpBaseScale: 9,
46199
- quoteScale: 6
46200
- },
46201
- perpMarkets,
46202
- spotMarkets
46203
- };
46331
+ this.marketConfigs = new DriftMarketConfigs({
46332
+ perpBaseScale: 9,
46333
+ quoteScale: 6
46334
+ }, perpMarkets, spotMarkets);
46204
46335
  return this.marketConfigs;
46205
46336
  }
46206
46337
  async fetchAndParseDriftUser(subAccountId = 0) {
@@ -47074,7 +47205,9 @@ class JupiterSwapClient {
47074
47205
  this.base = base;
47075
47206
  this.vault = vault;
47076
47207
  this.txBuilder = new TxBuilder$e(this);
47077
- this.jupApi = new JupiterApiClient();
47208
+ this.jupApi = new JupiterApiClient({
47209
+ apiKey: this.base.jupiterApiKey
47210
+ });
47078
47211
  }
47079
47212
  }
47080
47213
 
@@ -47579,7 +47712,7 @@ let TxBuilder$b = class TxBuilder extends BaseTxBuilder {
47579
47712
  // stateInitKey = hash state name and get first 8 bytes
47580
47713
  // useful for re-computing state account PDA in the future
47581
47714
  const stateInitKey = [
47582
- ...Buffer.from(anchor__namespace.utils.sha256.hash(charsToName(params.name))).subarray(0, 8)
47715
+ ...Buffer.from(anchor__namespace.utils.sha256.hash(charsToString(params.name))).subarray(0, 8)
47583
47716
  ];
47584
47717
  const created = new CreatedModel({
47585
47718
  key: stateInitKey
@@ -47701,7 +47834,7 @@ const KAMINO_VAULTS_EVENT_AUTHORITY = new web3_js.PublicKey("24tHwQyJJ9akVXxnvke
47701
47834
  const MAX_RESERVES = 25;
47702
47835
  class KVaultState extends Decodable {
47703
47836
  get nameStr() {
47704
- return charsToName(this.name);
47837
+ return charsToString(this.name);
47705
47838
  }
47706
47839
  get validAllocations() {
47707
47840
  return this.vaultAllocationStrategy.filter(({ reserve })=>!reserve.equals(web3_js.PublicKey.default));
@@ -49545,6 +49678,7 @@ class PriceClient {
49545
49678
  const { integrationAcls, externalPositions } = await this.base.fetchStateAccount(); // fetch state account only, don't need to build entire state model
49546
49679
  const externalPositionsSet = new PkSet(externalPositions);
49547
49680
  let glamDriftUserSpotMarketsMap = new PkMap(); // glam-controlled drift user -> spot markets map
49681
+ let glamDriftUserPerpMarketsMap = new PkMap(); // glam-controlled drift user -> perp markets map
49548
49682
  let dvaultDepositorsAndVaults = new PkMap(); // dvault depositor -> drift vault map
49549
49683
  let dvaultUserSpotMarketsMap = new PkMap(); // dvault drift user -> spot markets map
49550
49684
  let dvaultUserPerpMarketsMap = new PkMap(); // dvault drift user -> perp markets map
@@ -49560,6 +49694,7 @@ class PriceClient {
49560
49694
  return user;
49561
49695
  });
49562
49696
  glamDriftUserSpotMarketsMap = await this.getPubkeysForSpotHoldings(userPdas, commitment);
49697
+ glamDriftUserPerpMarketsMap = await this.getPubkeysForPerpHoldings(userPdas, commitment);
49563
49698
  }
49564
49699
  if (driftIntegrationAcl.protocolsBitmask & 0b10) {
49565
49700
  // 1. find all depositors
@@ -49596,6 +49731,9 @@ class PriceClient {
49596
49731
  const glamDriftSpotMarkets = [
49597
49732
  ...glamDriftUserSpotMarketsMap.values()
49598
49733
  ].map((s)=>Array.from(s.pkValues())).flat();
49734
+ const glamDriftPerpMarkets = [
49735
+ ...glamDriftUserPerpMarketsMap.values()
49736
+ ].map((s)=>Array.from(s.pkValues())).flat();
49599
49737
  const dvaultDepositors = Array.from(dvaultDepositorsAndVaults.pkKeys());
49600
49738
  const dvaultUsers = [
49601
49739
  ...dvaultDepositorsAndVaults.values()
@@ -49616,6 +49754,7 @@ class PriceClient {
49616
49754
  ...tokenPubkeys,
49617
49755
  ...glamDriftUsers,
49618
49756
  ...glamDriftSpotMarkets,
49757
+ ...glamDriftPerpMarkets,
49619
49758
  ...dvaultDepositors,
49620
49759
  ...dvaultUsers,
49621
49760
  ...dvaultUserSpotMarkets,
@@ -49655,6 +49794,13 @@ class PriceClient {
49655
49794
  }
49656
49795
  // Build a map of parsed drift perp markets
49657
49796
  const driftPerpMarketsMap = new PkMap();
49797
+ for (const marketPda of glamDriftPerpMarkets){
49798
+ const data = accountsDataMap.get(marketPda);
49799
+ if (data) {
49800
+ const market = DriftPerpMarket.decode(marketPda, data);
49801
+ driftPerpMarketsMap.set(marketPda, market);
49802
+ }
49803
+ }
49658
49804
  for (const marketPda of dvaultUserPerpMarkets){
49659
49805
  const data = accountsDataMap.get(marketPda);
49660
49806
  if (data) {
@@ -49682,13 +49828,13 @@ class PriceClient {
49682
49828
  }
49683
49829
  // Build a map of token prices (in USD)
49684
49830
  const tokenPricesMap = new PkMap();
49685
- const tokenList = await this.jupiterApi.fetchTokensList();
49686
- tokenList.forEach((item)=>{
49831
+ const tokenList = await this.jupiterApi.fetchTokensList(true);
49832
+ tokenList.tokens.forEach((item)=>{
49687
49833
  const tokenMint = new web3_js.PublicKey(item.address);
49688
49834
  tokenPricesMap.set(tokenMint, item);
49689
49835
  });
49690
49836
  const tokenHoldings = this.getTokenHoldings(tokenPubkeys, accountsDataMap, tokenPricesMap, "Jupiter");
49691
- const driftSpotHoldings = this.getDriftSpotHoldings(glamDriftUserSpotMarketsMap.pkKeys(), driftSpotMarketsMap, accountsDataMap, tokenPricesMap, "Jupiter");
49837
+ const driftSpotHoldings = this.getDriftHoldings(glamDriftUserSpotMarketsMap.pkKeys(), driftSpotMarketsMap, driftPerpMarketsMap, accountsDataMap, tokenPricesMap, "Jupiter");
49692
49838
  const dvaultHoldings = this.getDriftVaultsHoldings(dvaultDepositorsAndVaults, dvaultDepositorsMap, driftSpotMarketsMap, driftPerpMarketsMap, accountsDataMap, tokenPricesMap, "Jupiter");
49693
49839
  const kaminoLendHoldings = this.getKaminoLendHoldings(kaminoPubkeys.pkKeys(), kaminoReservesMap, accountsDataMap, tokenPricesMap, "Jupiter");
49694
49840
  const kaminoVaultsHoldings = this.getKaminoVaultsHoldings(kvaultAtasAndStates, kaminoReservesMap, accountsDataMap, tokenPricesMap, "Jupiter");
@@ -49808,7 +49954,6 @@ class PriceClient {
49808
49954
  }
49809
49955
  for (const pubkey of tokenAccountPubkeys){
49810
49956
  const data = accountsDataMap.get(pubkey);
49811
- if (!data) continue;
49812
49957
  const { amount, mint } = splToken.AccountLayout.decode(data);
49813
49958
  const tokenInfo = tokenPricesMap.get(mint);
49814
49959
  if (tokenInfo) {
@@ -49824,28 +49969,39 @@ class PriceClient {
49824
49969
  }
49825
49970
  return holdings;
49826
49971
  }
49827
- getDriftSpotHoldings(userPubkeys, spotMarketsMap, accountsDataMap, tokenPricesMap, priceSource) {
49972
+ getDriftHoldings(userPubkeys, spotMarketsMap, perpMarketsMap, accountsDataMap, tokenPricesMap, priceSource) {
49828
49973
  const holdings = [];
49829
49974
  for (const userPda of userPubkeys){
49830
49975
  const userData = accountsDataMap.get(userPda);
49831
- if (!userData) continue;
49832
- const { spotPositions } = DriftUser.decode(userPda, userData);
49833
- for (const { marketIndex, scaledBalance, balanceType } of spotPositions){
49834
- const marketPda = this.drift.getMarketPda(MarketType.SPOT, marketIndex);
49835
- const spotMarket = spotMarketsMap.get(marketPda);
49836
- if (!spotMarket) continue;
49837
- const amount = spotMarket.calcSpotBalanceBn(scaledBalance, balanceType).abs();
49838
- const direction = Object.keys(balanceType)[0];
49839
- const tokenPrice = tokenPricesMap.get(spotMarket.mint);
49840
- if (!tokenPrice) continue;
49976
+ const { spotPositions, perpPositions } = DriftUser.decode(userPda, userData);
49977
+ for (const spotPosition of spotPositions){
49978
+ const { marketIndex, mint, decimals, cumulativeDepositInterest, cumulativeBorrowInterest } = spotMarketsMap.get(spotPosition.marketPda);
49979
+ const amount = spotPosition.calcBalanceBn(decimals, cumulativeDepositInterest, cumulativeBorrowInterest).abs();
49980
+ const { usdPrice, slot } = tokenPricesMap.get(mint);
49981
+ const holding = new Holding(mint, decimals, amount, usdPrice, {
49982
+ slot,
49983
+ source: priceSource
49984
+ }, "DriftProtocol", {
49985
+ user: userPda,
49986
+ marketIndex,
49987
+ direction: spotPosition.direction,
49988
+ marketType: "spot"
49989
+ });
49990
+ holdings.push(holding);
49991
+ }
49992
+ for (const perpPosition of perpPositions){
49993
+ const { marketIndex, marketPda } = perpPosition;
49994
+ const { lastOraclePrice, cumulativeFundingRateLong, cumulativeFundingRateShort } = perpMarketsMap.get(marketPda);
49995
+ const amount = perpPosition.getUsdValueScaled(lastOraclePrice, cumulativeFundingRateLong, cumulativeFundingRateShort);
49996
+ const tokenPrice = tokenPricesMap.get(USDC);
49841
49997
  const { usdPrice, slot } = tokenPrice;
49842
- const holding = new Holding(spotMarket.mint, spotMarket.decimals, amount, usdPrice, {
49998
+ const holding = new Holding(USDC, 6, amount, usdPrice, {
49843
49999
  slot,
49844
50000
  source: priceSource
49845
50001
  }, "DriftProtocol", {
49846
50002
  user: userPda,
49847
50003
  marketIndex,
49848
- direction
50004
+ marketType: "perp"
49849
50005
  });
49850
50006
  holdings.push(holding);
49851
50007
  }
@@ -49859,16 +50015,15 @@ class PriceClient {
49859
50015
  const dvaultUserData = accountsDataMap.get(dvault.user);
49860
50016
  const { spotPositions, perpPositions } = DriftUser.decode(dvault.user, dvaultUserData);
49861
50017
  const aum = dvault.aumInBaseAsset(spotPositions, perpPositions, spotMarketsMap, perpMarketsMap);
49862
- const amount = depositor.vaultShares.mul(aum).div(dvault.totalShares);
50018
+ const amount = depositor.netShares.mul(aum).div(dvault.totalShares).add(depositor.lastWithdrawRequest.value);
49863
50019
  const { mint, decimals } = dvault.getBaseAsset(spotMarketsMap);
49864
50020
  const tokenPrice = tokenPricesMap.get(mint);
49865
- if (!tokenPrice) continue;
49866
50021
  const { usdPrice, slot } = tokenPrice;
49867
50022
  const holding = new Holding(mint, decimals, amount, usdPrice, {
49868
50023
  slot,
49869
50024
  source: priceSource
49870
50025
  }, "DriftVaults", {
49871
- vault: pubkey,
50026
+ vault: dvault.getAddress(),
49872
50027
  depositor: depositor.getAddress()
49873
50028
  });
49874
50029
  holdings.push(holding);
@@ -49879,16 +50034,13 @@ class PriceClient {
49879
50034
  const holdings = [];
49880
50035
  for (const obligation of obligationPubkeys){
49881
50036
  const obligationData = accountsDataMap.get(obligation);
49882
- if (!obligationData) continue;
49883
50037
  const { activeDeposits, activeBorrows } = Obligation.decode(obligation, obligationData);
49884
50038
  for (const { depositReserve, depositedAmount } of activeDeposits){
49885
50039
  const reserve = reservesMap.get(depositReserve);
49886
- if (!reserve) continue;
49887
50040
  const { collateralExchangeRate, lendingMarket, liquidity } = reserve;
49888
50041
  const supplyAmount = new Decimal(depositedAmount.toString()).div(collateralExchangeRate).floor();
49889
50042
  const amount = new anchor.BN(supplyAmount.toString());
49890
50043
  const tokenPrice = tokenPricesMap.get(liquidity.mintPubkey);
49891
- if (!tokenPrice) continue;
49892
50044
  const { usdPrice, slot } = tokenPrice;
49893
50045
  const holding = new Holding(liquidity.mintPubkey, liquidity.mintDecimals.toNumber(), amount, usdPrice, {
49894
50046
  slot,
@@ -49903,13 +50055,11 @@ class PriceClient {
49903
50055
  }
49904
50056
  for (const { borrowReserve, borrowedAmountSf, cumulativeBorrowRateBsf } of activeBorrows){
49905
50057
  const reserve = reservesMap.get(borrowReserve);
49906
- if (!reserve) continue;
49907
50058
  const { cumulativeBorrowRate, lendingMarket, liquidity } = reserve;
49908
50059
  const obligationCumulativeBorrowRate = bfToDecimal(cumulativeBorrowRateBsf);
49909
50060
  const borrowAmount = new Fraction(borrowedAmountSf).toDecimal().mul(cumulativeBorrowRate).div(obligationCumulativeBorrowRate).ceil();
49910
50061
  const amount = new anchor.BN(borrowAmount.toString());
49911
50062
  const tokenPrice = tokenPricesMap.get(liquidity.mintPubkey);
49912
- if (!tokenPrice) continue;
49913
50063
  const { usdPrice, slot } = tokenPrice;
49914
50064
  const holding = new Holding(liquidity.mintPubkey, liquidity.mintDecimals.toNumber(), amount, usdPrice, {
49915
50065
  slot,
@@ -49929,12 +50079,10 @@ class PriceClient {
49929
50079
  const holdings = [];
49930
50080
  for (const [ata, kvaultState] of kvaultAtasAndStates.pkEntries()){
49931
50081
  const ataData = accountsDataMap.get(ata);
49932
- if (!ataData) continue;
49933
50082
  const tokenAccount = splToken.AccountLayout.decode(ataData);
49934
50083
  let aum = new Decimal(kvaultState.tokenAvailable.toString());
49935
50084
  kvaultState.validAllocations.map((allocation)=>{
49936
50085
  const reserve = reservesMap.get(allocation.reserve);
49937
- if (!reserve) return;
49938
50086
  const { collateralExchangeRate } = reserve;
49939
50087
  // allocation ctoken amount to liq asset amount
49940
50088
  const liqAmount = new Decimal(allocation.ctokenAllocation.toString()).div(collateralExchangeRate).floor();
@@ -49943,7 +50091,6 @@ class PriceClient {
49943
50091
  // calculate liquidity token amount
49944
50092
  const amount = new Decimal(tokenAccount.amount.toString()).div(new Decimal(kvaultState.sharesIssued.toString())).mul(aum).floor();
49945
50093
  const tokenPrice = tokenPricesMap.get(kvaultState.tokenMint);
49946
- if (!tokenPrice) continue;
49947
50094
  const { usdPrice, slot } = tokenPrice;
49948
50095
  const holding = new Holding(kvaultState.tokenMint, kvaultState.tokenMintDecimals.toNumber(), new anchor.BN(amount.toString()), usdPrice, {
49949
50096
  slot,
@@ -50654,7 +50801,7 @@ let TxBuilder$5 = class TxBuilder extends BaseTxBuilder {
50654
50801
  async initializeIxs(initMintParams, stateParams, glamSigner) {
50655
50802
  const decimals = typeof initMintParams.decimals === "number" ? initMintParams.decimals : null;
50656
50803
  const stateInitKey = [
50657
- ...Buffer.from(anchor.utils.sha256.hash(charsToName(initMintParams.name))).subarray(0, 8)
50804
+ ...Buffer.from(anchor.utils.sha256.hash(charsToString(initMintParams.name))).subarray(0, 8)
50658
50805
  ];
50659
50806
  const glamState = getStatePda(stateInitKey, glamSigner, this.client.base.protocolProgram.programId);
50660
50807
  const postInstructions = [];
@@ -51527,12 +51674,14 @@ const MESSAGE_RECEIVED_EVENT_DISCM = new Uint8Array([
51527
51674
  0x9d,
51528
51675
  0xa6
51529
51676
  ]);
51677
+ const CCTP_DOMAIN_SOLANA = 5;
51530
51678
  class CctpBridgeEvent {
51531
- constructor(amount, sourceDomain, sourceAddress, destinationDomain, destinationAddress, attestation, nonce, status, txHash){
51679
+ constructor(amount, sourceDomain, sourceAddress, destinationDomain, destinationCaller, destinationAddress, attestation, nonce, status, txHash){
51532
51680
  this.amount = amount;
51533
51681
  this.sourceDomain = sourceDomain;
51534
51682
  this.sourceAddress = sourceAddress;
51535
51683
  this.destinationDomain = destinationDomain;
51684
+ this.destinationCaller = destinationCaller;
51536
51685
  this.destinationAddress = destinationAddress;
51537
51686
  this.attestation = attestation;
51538
51687
  this.nonce = nonce;
@@ -51552,7 +51701,7 @@ let TxBuilder = class TxBuilder extends BaseTxBuilder {
51552
51701
  amount,
51553
51702
  destinationDomain: domain,
51554
51703
  mintRecipient: recipient,
51555
- destinationCaller: web3_js.PublicKey.default,
51704
+ destinationCaller: params.destinationCaller || web3_js.PublicKey.default,
51556
51705
  ...params
51557
51706
  };
51558
51707
  const denylistAccount = web3_js.PublicKey.findProgramAddressSync([
@@ -51878,9 +52027,6 @@ class CctpClient {
51878
52027
  ...options.commitment ? {
51879
52028
  commitment: options.commitment
51880
52029
  } : {},
51881
- ...options.minSlot ? {
51882
- minContextSlot: options.minSlot
51883
- } : {},
51884
52030
  filters: [
51885
52031
  {
51886
52032
  dataSize: 428
@@ -51933,6 +52079,7 @@ class CctpClient {
51933
52079
  const status = message.status;
51934
52080
  const nonce = message.decodedMessage.nonce;
51935
52081
  const destinationDomain = Number(message.decodedMessage.destinationDomain);
52082
+ const destinationCaller = message.decodedMessage.destinationCaller;
51936
52083
  const destinationAddress = message.decodedMessage.decodedMessageBody.mintRecipient;
51937
52084
  const sourceAddress = message.decodedMessage.decodedMessageBody.messageSender;
51938
52085
  const amount = message.decodedMessage.decodedMessageBody.amount;
@@ -51940,7 +52087,7 @@ class CctpClient {
51940
52087
  if (sourceDomain === 5 && token !== USDC.toBase58()) {
51941
52088
  throw new Error("Invalid message, expected burn token to be USDC");
51942
52089
  }
51943
- return new CctpBridgeEvent(new anchor.BN(amount), sourceDomain, sourceAddress, destinationDomain, destinationAddress, attestation, nonce, status, txHash ?? "");
52090
+ return new CctpBridgeEvent(new anchor.BN(amount), sourceDomain, sourceAddress, destinationDomain, destinationCaller, destinationAddress, attestation, nonce, status, txHash ?? "");
51944
52091
  });
51945
52092
  }
51946
52093
  /**
@@ -51952,16 +52099,16 @@ class CctpClient {
51952
52099
  * 2. Filter transactions that contain the bridge events
51953
52100
  * 3. Parse the bridge events from the transactions
51954
52101
  */ async getIncomingBridgeEvents(options) {
51955
- const { batchSize = 1, commitment = "confirmed", minSlot } = options;
52102
+ const { batchSize = 1, commitment = "confirmed", minSlot = 0 } = options;
51956
52103
  const txHashes = new Set(options.txHashes ?? []);
52104
+ const txSlots = new Map();
51957
52105
  // If no txHashes provided, find transactions involving vault's USDC token account
51958
52106
  if (txHashes.size === 0) {
51959
- const signatures = await this.base.connection.getSignaturesForAddress(this.base.getVaultAta(USDC), {
51960
- ...minSlot ? {
51961
- minContextSlot: minSlot
51962
- } : {}
51963
- }, commitment);
51964
- signatures.forEach((sig)=>txHashes.add(sig.signature));
52107
+ const signatures = await this.base.connection.getSignaturesForAddress(this.base.getVaultAta(USDC), {}, commitment);
52108
+ signatures.filter((s)=>s.slot >= minSlot).forEach((sig)=>{
52109
+ txHashes.add(sig.signature);
52110
+ txSlots.set(sig.signature, sig.slot);
52111
+ });
51965
52112
  }
51966
52113
  if (txHashes.size === 0) {
51967
52114
  return [];
@@ -52009,6 +52156,9 @@ class CctpClient {
52009
52156
  nonce,
52010
52157
  txHash
52011
52158
  });
52159
+ for (const event of events){
52160
+ event.slot = txSlots.get(txHash);
52161
+ }
52012
52162
  allEvents.push(...events);
52013
52163
  }
52014
52164
  }
@@ -52023,34 +52173,42 @@ class CctpClient {
52023
52173
  * 2. Get the created transaction for each message account
52024
52174
  * 3. Call iris api to get the attestation status and parsed message using each tx hash
52025
52175
  */ async getOutgoingBridgeEvents(options) {
52026
- const { batchSize = 1, commitment = "confirmed", minSlot } = options;
52176
+ const { batchSize = 1, commitment = "confirmed", minSlot = 0 } = options;
52027
52177
  const txHashes = new Set(options.txHashes ?? []);
52178
+ const txSlots = new Map();
52028
52179
  // If no txHashes are provided, find all message accounts for the vault
52029
52180
  if (txHashes.size === 0) {
52030
52181
  const messagePubkeys = await this.findV2Messages(this.base.vaultPda, {
52031
- commitment,
52032
- minSlot
52182
+ commitment
52033
52183
  });
52034
52184
  if (messagePubkeys.length === 0) {
52035
52185
  return [];
52036
52186
  }
52187
+ // Get account creation transaction for each message account
52037
52188
  for(let i = 0; i < messagePubkeys.length; i += batchSize){
52038
52189
  const batch = messagePubkeys.slice(i, i + batchSize);
52039
52190
  const signaturesPromises = batch.map((pubkey)=>this.base.connection.getSignaturesForAddress(pubkey));
52040
52191
  const batchSignatures = await Promise.all(signaturesPromises);
52041
52192
  // Process batch results and collect transaction signatures
52042
52193
  for(let j = 0; j < batch.length; j++){
52043
- const sigs = batchSignatures[j];
52194
+ const sigs = batchSignatures[j].filter((s)=>s.slot >= minSlot);
52195
+ if (sigs.length === 0) {
52196
+ continue;
52197
+ }
52044
52198
  const createdTx = sigs.sort((a, b)=>a.slot - b.slot)[0];
52045
52199
  txHashes.add(createdTx.signature);
52200
+ txSlots.set(createdTx.signature, createdTx.slot);
52046
52201
  }
52047
52202
  }
52048
52203
  }
52049
52204
  const allEvents = [];
52050
52205
  for (const txHash of txHashes){
52051
- const events = await this.parseEventsFromAttestion(5, {
52206
+ const events = await this.parseEventsFromAttestion(CCTP_DOMAIN_SOLANA, {
52052
52207
  txHash
52053
52208
  });
52209
+ for (const event of events){
52210
+ event.slot = txSlots.get(txHash);
52211
+ }
52054
52212
  allEvents.push(...events);
52055
52213
  }
52056
52214
  return allEvents;
@@ -52203,6 +52361,7 @@ exports.DefaultOrderParams = DefaultOrderParams;
52203
52361
  exports.DelegateAcl = DelegateAcl;
52204
52362
  exports.DepositDirection = DepositDirection;
52205
52363
  exports.DepositExplanation = DepositExplanation;
52364
+ exports.DriftMarketConfigs = DriftMarketConfigs;
52206
52365
  exports.DriftProtocolClient = DriftProtocolClient;
52207
52366
  exports.DriftProtocolPolicy = DriftProtocolPolicy;
52208
52367
  exports.DriftVaultsClient = DriftVaultsClient;
@@ -52211,11 +52370,11 @@ exports.EmergencyAccessUpdateArgs = EmergencyAccessUpdateArgs;
52211
52370
  exports.EmergencyUpdateMintArgs = EmergencyUpdateMintArgs;
52212
52371
  exports.ExchangeStatus = ExchangeStatus;
52213
52372
  exports.Fraction = Fraction;
52214
- exports.FuelOverflowStatus = FuelOverflowStatus;
52215
52373
  exports.GLAM_CONFIG_PROGRAM = GLAM_CONFIG_PROGRAM;
52216
52374
  exports.GLAM_REFERRER = GLAM_REFERRER;
52217
52375
  exports.GlamClient = GlamClient;
52218
52376
  exports.GlamError = GlamError;
52377
+ exports.Holding = Holding;
52219
52378
  exports.InsuranceFundOperation = InsuranceFundOperation;
52220
52379
  exports.IntegrationAcl = IntegrationAcl;
52221
52380
  exports.IntegrationPermissions = IntegrationPermissions;
@@ -52223,6 +52382,7 @@ exports.JITO_TIP_DEFAULT = JITO_TIP_DEFAULT;
52223
52382
  exports.JUP = JUP;
52224
52383
  exports.JUPITER_API_DEFAULT = JUPITER_API_DEFAULT;
52225
52384
  exports.JUPITER_PROGRAM_ID = JUPITER_PROGRAM_ID;
52385
+ exports.JupTokenList = JupTokenList;
52226
52386
  exports.JupiterApiClient = JupiterApiClient;
52227
52387
  exports.JupiterSwapClient = JupiterSwapClient;
52228
52388
  exports.JupiterSwapPolicy = JupiterSwapPolicy;
@@ -52234,8 +52394,6 @@ exports.KAMINO_VAULTS_PROGRAM = KAMINO_VAULTS_PROGRAM;
52234
52394
  exports.KAMINO_VAULT_STATE_SIZE = KAMINO_VAULT_STATE_SIZE;
52235
52395
  exports.KaminoLendingPolicy = KaminoLendingPolicy;
52236
52396
  exports.KaminoVaultsPolicy = KaminoVaultsPolicy;
52237
- exports.LPAction = LPAction;
52238
- exports.LiquidationType = LiquidationType;
52239
52397
  exports.MARINADE_NATIVE_STAKE_AUTHORITY = MARINADE_NATIVE_STAKE_AUTHORITY;
52240
52398
  exports.MARINADE_PROGRAM_ID = MARINADE_PROGRAM_ID;
52241
52399
  exports.MEMO_PROGRAM = MEMO_PROGRAM;
@@ -52259,13 +52417,12 @@ exports.OrderType = OrderType;
52259
52417
  exports.PerpOperation = PerpOperation;
52260
52418
  exports.PkMap = PkMap;
52261
52419
  exports.PkSet = PkSet;
52262
- exports.PlaceAndTakeOrderSuccessCondition = PlaceAndTakeOrderSuccessCondition;
52263
52420
  exports.PositionDirection = PositionDirection;
52264
52421
  exports.PostOnlyParams = PostOnlyParams;
52422
+ exports.PriceClient = PriceClient;
52265
52423
  exports.PriceDenom = PriceDenom;
52266
52424
  exports.ProtocolPermissions = ProtocolPermissions;
52267
52425
  exports.ProtocolPolicy = ProtocolPolicy;
52268
- exports.ReferrerStatus = ReferrerStatus;
52269
52426
  exports.RequestType = RequestType;
52270
52427
  exports.SANCTUM_STAKE_POOL_PROGRAM_ID = SANCTUM_STAKE_POOL_PROGRAM_ID;
52271
52428
  exports.SEED_ACCOUNT_POLICY = SEED_ACCOUNT_POLICY;
@@ -52283,7 +52440,6 @@ exports.STAKE_ACCOUNT_SIZE = STAKE_ACCOUNT_SIZE;
52283
52440
  exports.STAKE_POOLS = STAKE_POOLS;
52284
52441
  exports.STAKE_POOLS_MAP = STAKE_POOLS_MAP;
52285
52442
  exports.SettlePnlExplanation = SettlePnlExplanation;
52286
- exports.SettlePnlMode = SettlePnlMode;
52287
52443
  exports.SpotBalanceType = SpotBalanceType;
52288
52444
  exports.SpotFulfillmentConfigStatus = SpotFulfillmentConfigStatus;
52289
52445
  exports.SpotFulfillmentStatus = SpotFulfillmentStatus;
@@ -52294,24 +52450,23 @@ exports.StateAccountType = StateAccountType;
52294
52450
  exports.StateIdlModel = StateIdlModel;
52295
52451
  exports.StateModel = StateModel;
52296
52452
  exports.SwapDirection = SwapDirection;
52297
- exports.SwapReduceOnly = SwapReduceOnly;
52298
52453
  exports.TOKEN_MESSENGER_MINTER_V2 = TOKEN_MESSENGER_MINTER_V2;
52299
52454
  exports.TRANSFER_HOOK_PROGRAM = TRANSFER_HOOK_PROGRAM;
52300
52455
  exports.TimeUnit = TimeUnit;
52301
52456
  exports.TimelockClient = TimelockClient;
52302
- exports.TradeSide = TradeSide;
52303
52457
  exports.TransferPolicy = TransferPolicy;
52304
52458
  exports.USDC = USDC;
52305
52459
  exports.USDC_DEVNET = USDC_DEVNET;
52306
52460
  exports.USDC_ORACLE = USDC_ORACLE;
52307
52461
  exports.UserStatus = UserStatus;
52462
+ exports.VaultHoldings = VaultHoldings;
52308
52463
  exports.VoteAuthorize = VoteAuthorize;
52309
52464
  exports.WSOL = WSOL;
52310
52465
  exports.ZERO = ZERO;
52311
52466
  exports.bfToDecimal = bfToDecimal;
52312
52467
  exports.buildComputeBudgetInstructions = buildComputeBudgetInstructions;
52313
52468
  exports.bytesToHex = bytesToHex;
52314
- exports.charsToName = charsToName;
52469
+ exports.charsToString = charsToString;
52315
52470
  exports.compareDelegateAcls = compareDelegateAcls;
52316
52471
  exports.compareIntegrationAcls = compareIntegrationAcls;
52317
52472
  exports.evmAddressToBytes32 = evmAddressToBytes32;
@@ -52324,6 +52479,7 @@ exports.fetchMintsAndTokenPrograms = fetchMintsAndTokenPrograms;
52324
52479
  exports.findGlamLookupTables = findGlamLookupTables;
52325
52480
  exports.findStakeAccounts = findStakeAccounts;
52326
52481
  exports.formatBits = formatBits;
52482
+ exports.fromUiAmount = fromUiAmount;
52327
52483
  exports.getAccountPolicyPda = getAccountPolicyPda;
52328
52484
  exports.getAssetMeta = getAssetMeta;
52329
52485
  exports.getEscrowPda = getEscrowPda;
@@ -52375,18 +52531,17 @@ exports.getStatePda = getStatePda;
52375
52531
  exports.getTokenAccountsByOwner = getTokenAccountsByOwner;
52376
52532
  exports.getTriggerLimitOrderParams = getTriggerLimitOrderParams;
52377
52533
  exports.getTriggerMarketOrderParams = getTriggerMarketOrderParams;
52378
- exports.getVariant = getVariant;
52379
52534
  exports.getVaultPda = getVaultPda;
52380
52535
  exports.hexToBytes = hexToBytes;
52381
- exports.isOneOfVariant = isOneOfVariant;
52382
- exports.isVariant = isVariant;
52383
- exports.nameToChars = nameToChars;
52536
+ exports.isValidEvmAddress = isValidEvmAddress;
52384
52537
  exports.parseMintAccountInfo = parseMintAccountInfo;
52538
+ exports.parsePermissionNames = parsePermissionNames;
52385
52539
  exports.parseProgramLogs = parseProgramLogs;
52386
52540
  exports.parseProtocolPermissionsBitmask = parseProtocolPermissionsBitmask;
52387
52541
  exports.parseProtocolsBitmask = parseProtocolsBitmask;
52388
52542
  exports.publicKeyToEvmAddress = publicKeyToEvmAddress;
52543
+ exports.readI128LE = readI128LE;
52389
52544
  exports.readSignedBigInt64LE = readSignedBigInt64LE;
52390
52545
  exports.readUnsignedBigInt64LE = readUnsignedBigInt64LE;
52391
- exports.setsAreEqual = setsAreEqual;
52546
+ exports.stringToChars = stringToChars;
52392
52547
  exports.toUiAmount = toUiAmount;