@velocity-exchange/sdk 0.2.2 → 0.2.3

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 (49) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/lib/browser/adminClient.d.ts +4 -2
  3. package/lib/browser/adminClient.js +21 -4
  4. package/lib/browser/constants/numericConstants.d.ts +1 -0
  5. package/lib/browser/constants/numericConstants.js +2 -1
  6. package/lib/browser/idl/velocity.d.ts +61 -9
  7. package/lib/browser/idl/velocity.json +61 -9
  8. package/lib/browser/index.d.ts +1 -0
  9. package/lib/browser/index.js +1 -0
  10. package/lib/browser/math/funding.js +20 -4
  11. package/lib/browser/math/spotMarket.d.ts +6 -0
  12. package/lib/browser/math/spotMarket.js +16 -1
  13. package/lib/browser/tx/forwardOnlyTxSender.d.ts +37 -0
  14. package/lib/browser/tx/forwardOnlyTxSender.js +92 -0
  15. package/lib/browser/types.d.ts +2 -0
  16. package/lib/node/adminClient.d.ts +4 -2
  17. package/lib/node/adminClient.d.ts.map +1 -1
  18. package/lib/node/adminClient.js +21 -4
  19. package/lib/node/constants/numericConstants.d.ts +1 -0
  20. package/lib/node/constants/numericConstants.d.ts.map +1 -1
  21. package/lib/node/constants/numericConstants.js +2 -1
  22. package/lib/node/idl/velocity.d.ts +61 -9
  23. package/lib/node/idl/velocity.d.ts.map +1 -1
  24. package/lib/node/idl/velocity.json +61 -9
  25. package/lib/node/index.d.ts +1 -0
  26. package/lib/node/index.d.ts.map +1 -1
  27. package/lib/node/index.js +1 -0
  28. package/lib/node/math/funding.d.ts.map +1 -1
  29. package/lib/node/math/funding.js +20 -4
  30. package/lib/node/math/spotMarket.d.ts +6 -0
  31. package/lib/node/math/spotMarket.d.ts.map +1 -1
  32. package/lib/node/math/spotMarket.js +16 -1
  33. package/lib/node/tx/forwardOnlyTxSender.d.ts +38 -0
  34. package/lib/node/tx/forwardOnlyTxSender.d.ts.map +1 -0
  35. package/lib/node/tx/forwardOnlyTxSender.js +92 -0
  36. package/lib/node/types.d.ts +2 -0
  37. package/lib/node/types.d.ts.map +1 -1
  38. package/package.json +1 -1
  39. package/src/adminClient.ts +53 -3
  40. package/src/constants/numericConstants.ts +1 -0
  41. package/src/idl/velocity.json +61 -9
  42. package/src/idl/velocity.ts +61 -9
  43. package/src/index.ts +1 -0
  44. package/src/math/funding.ts +23 -5
  45. package/src/math/spotMarket.ts +28 -2
  46. package/src/tx/forwardOnlyTxSender.ts +145 -0
  47. package/src/types.ts +2 -0
  48. package/tests/amm/test.ts +2 -2
  49. package/tests/dlob/helpers.ts +2 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @velocity-exchange/sdk
2
2
 
3
+ ## 0.2.3
4
+
5
+ ### Patch Changes
6
+
7
+ - [#100](https://github.com/drift-labs/protocol-v2-shadow/pull/100) [`ae78769`](https://github.com/drift-labs/protocol-v2-shadow/commit/ae78769ef58355202c030435c2796ef045fe30a0) Thanks [@ChesterSim](https://github.com/ChesterSim)! - add back ForwardOnlyTxSender and calculateMaxRemainingDeposit
8
+
3
9
  ## 0.2.2
4
10
 
5
11
  ### Patch Changes
@@ -22,8 +22,8 @@ export declare class AdminClient extends VelocityClient {
22
22
  }, scaleInitialAssetWeightStart?: BN, withdrawGuardThreshold?: BN, orderTickSize?: BN, orderStepSize?: BN, ifTotalFactor?: number, name?: string, marketIndex?: number): Promise<TransactionInstruction>;
23
23
  deleteInitializedSpotMarket(marketIndex: number): Promise<TransactionSignature>;
24
24
  getDeleteInitializedSpotMarketIx(marketIndex: number): Promise<TransactionInstruction>;
25
- initializePerpMarket(marketIndex: number, priceOracle: PublicKey, baseAssetReserve: BN, quoteAssetReserve: BN, periodicity: BN, pegMultiplier?: BN, oracleSource?: OracleSource, contractTier?: ContractTier, marginRatioInitial?: number, marginRatioMaintenance?: number, liquidatorFee?: number, ifLiquidatorFee?: number, imfFactor?: number, activeStatus?: boolean, baseSpread?: number, maxSpread?: number, maxOpenInterest?: BN, maxRevenueWithdrawPerPeriod?: BN, quoteMaxInsurance?: BN, orderStepSize?: BN, orderTickSize?: BN, minOrderSize?: BN, concentrationCoefScale?: BN, curveUpdateIntensity?: number, ammJitIntensity?: number, name?: string, lpPoolId?: number): Promise<TransactionSignature>;
26
- getInitializePerpMarketIx(marketIndex: number, priceOracle: PublicKey, baseAssetReserve: BN, quoteAssetReserve: BN, periodicity: BN, pegMultiplier?: BN, oracleSource?: OracleSource, contractTier?: ContractTier, marginRatioInitial?: number, marginRatioMaintenance?: number, liquidatorFee?: number, ifLiquidatorFee?: number, imfFactor?: number, activeStatus?: boolean, baseSpread?: number, maxSpread?: number, maxOpenInterest?: BN, maxRevenueWithdrawPerPeriod?: BN, quoteMaxInsurance?: BN, orderStepSize?: BN, orderTickSize?: BN, minOrderSize?: BN, concentrationCoefScale?: BN, curveUpdateIntensity?: number, ammJitIntensity?: number, name?: string, lpPoolId?: number): Promise<TransactionInstruction[]>;
25
+ initializePerpMarket(marketIndex: number, priceOracle: PublicKey, baseAssetReserve: BN, quoteAssetReserve: BN, periodicity: BN, pegMultiplier?: BN, oracleSource?: OracleSource, contractTier?: ContractTier, marginRatioInitial?: number, marginRatioMaintenance?: number, liquidatorFee?: number, ifLiquidatorFee?: number, imfFactor?: number, activeStatus?: boolean, baseSpread?: number, maxSpread?: number, maxOpenInterest?: BN, maxRevenueWithdrawPerPeriod?: BN, quoteMaxInsurance?: BN, orderStepSize?: BN, orderTickSize?: BN, minOrderSize?: BN, concentrationCoefScale?: BN, curveUpdateIntensity?: number, ammJitIntensity?: number, name?: string, lpPoolId?: number, fundingClampThreshold?: number, fundingRampSlope?: number): Promise<TransactionSignature>;
26
+ getInitializePerpMarketIx(marketIndex: number, priceOracle: PublicKey, baseAssetReserve: BN, quoteAssetReserve: BN, periodicity: BN, pegMultiplier?: BN, oracleSource?: OracleSource, contractTier?: ContractTier, marginRatioInitial?: number, marginRatioMaintenance?: number, liquidatorFee?: number, ifLiquidatorFee?: number, imfFactor?: number, activeStatus?: boolean, baseSpread?: number, maxSpread?: number, maxOpenInterest?: BN, maxRevenueWithdrawPerPeriod?: BN, quoteMaxInsurance?: BN, orderStepSize?: BN, orderTickSize?: BN, minOrderSize?: BN, concentrationCoefScale?: BN, curveUpdateIntensity?: number, ammJitIntensity?: number, name?: string, lpPoolId?: number, fundingClampThreshold?: number, fundingRampSlope?: number): Promise<TransactionInstruction[]>;
27
27
  initializeAmmCache(txParams?: TxParams): Promise<TransactionSignature>;
28
28
  getInitializeAmmCacheIx(): Promise<TransactionInstruction>;
29
29
  addMarketToAmmCache(perpMarketIndex: number, txParams?: TxParams): Promise<TransactionSignature>;
@@ -92,6 +92,8 @@ export declare class AdminClient extends VelocityClient {
92
92
  getUpdatePerpMarketTargetBaseAssetAmountPerLpIx(perpMarketIndex: number, targetBaseAssetAmountPerLP: number): Promise<TransactionInstruction>;
93
93
  updatePerpMarketMarginRatio(perpMarketIndex: number, marginRatioInitial: number, marginRatioMaintenance: number): Promise<TransactionSignature>;
94
94
  getUpdatePerpMarketMarginRatioIx(perpMarketIndex: number, marginRatioInitial: number, marginRatioMaintenance: number): Promise<TransactionInstruction>;
95
+ updatePerpMarketFundingDeadZone(perpMarketIndex: number, fundingClampThreshold: number, fundingRampSlope: number): Promise<TransactionSignature>;
96
+ getUpdatePerpMarketFundingDeadZoneIx(perpMarketIndex: number, fundingClampThreshold: number, fundingRampSlope: number): Promise<TransactionInstruction>;
95
97
  updatePerpMarketImfFactor(perpMarketIndex: number, imfFactor: number, unrealizedPnlImfFactor: number): Promise<TransactionSignature>;
96
98
  getUpdatePerpMarketImfFactorIx(perpMarketIndex: number, imfFactor: number, unrealizedPnlImfFactor: number): Promise<TransactionInstruction>;
97
99
  updatePerpMarketBaseSpread(perpMarketIndex: number, baseSpread: number): Promise<TransactionSignature>;
@@ -137,9 +137,9 @@ class AdminClient extends velocityClient_1.VelocityClient {
137
137
  },
138
138
  });
139
139
  }
140
- async initializePerpMarket(marketIndex, priceOracle, baseAssetReserve, quoteAssetReserve, periodicity, pegMultiplier = numericConstants_1.PEG_PRECISION, oracleSource = types_1.OracleSource.PYTH_LAZER, contractTier = types_1.ContractTier.SPECULATIVE, marginRatioInitial = 2000, marginRatioMaintenance = 500, liquidatorFee = 0, ifLiquidatorFee = 10000, imfFactor = 0, activeStatus = true, baseSpread = 0, maxSpread = 142500, maxOpenInterest = numericConstants_1.ZERO, maxRevenueWithdrawPerPeriod = numericConstants_1.ZERO, quoteMaxInsurance = numericConstants_1.ZERO, orderStepSize = numericConstants_1.BASE_PRECISION.divn(10000), orderTickSize = numericConstants_1.PRICE_PRECISION.divn(100000), minOrderSize = numericConstants_1.BASE_PRECISION.divn(10000), concentrationCoefScale = numericConstants_1.ONE, curveUpdateIntensity = 0, ammJitIntensity = 0, name = userName_1.DEFAULT_MARKET_NAME, lpPoolId = 0) {
140
+ async initializePerpMarket(marketIndex, priceOracle, baseAssetReserve, quoteAssetReserve, periodicity, pegMultiplier = numericConstants_1.PEG_PRECISION, oracleSource = types_1.OracleSource.PYTH_LAZER, contractTier = types_1.ContractTier.SPECULATIVE, marginRatioInitial = 2000, marginRatioMaintenance = 500, liquidatorFee = 0, ifLiquidatorFee = 10000, imfFactor = 0, activeStatus = true, baseSpread = 0, maxSpread = 142500, maxOpenInterest = numericConstants_1.ZERO, maxRevenueWithdrawPerPeriod = numericConstants_1.ZERO, quoteMaxInsurance = numericConstants_1.ZERO, orderStepSize = numericConstants_1.BASE_PRECISION.divn(10000), orderTickSize = numericConstants_1.PRICE_PRECISION.divn(100000), minOrderSize = numericConstants_1.BASE_PRECISION.divn(10000), concentrationCoefScale = numericConstants_1.ONE, curveUpdateIntensity = 0, ammJitIntensity = 0, name = userName_1.DEFAULT_MARKET_NAME, lpPoolId = 0, fundingClampThreshold = 0, fundingRampSlope = 0) {
141
141
  const currentPerpMarketIndex = this.getStateAccount().numberOfMarkets;
142
- const initializeMarketIxs = await this.getInitializePerpMarketIx(marketIndex, priceOracle, baseAssetReserve, quoteAssetReserve, periodicity, pegMultiplier, oracleSource, contractTier, marginRatioInitial, marginRatioMaintenance, liquidatorFee, ifLiquidatorFee, imfFactor, activeStatus, baseSpread, maxSpread, maxOpenInterest, maxRevenueWithdrawPerPeriod, quoteMaxInsurance, orderStepSize, orderTickSize, minOrderSize, concentrationCoefScale, curveUpdateIntensity, ammJitIntensity, name, lpPoolId);
142
+ const initializeMarketIxs = await this.getInitializePerpMarketIx(marketIndex, priceOracle, baseAssetReserve, quoteAssetReserve, periodicity, pegMultiplier, oracleSource, contractTier, marginRatioInitial, marginRatioMaintenance, liquidatorFee, ifLiquidatorFee, imfFactor, activeStatus, baseSpread, maxSpread, maxOpenInterest, maxRevenueWithdrawPerPeriod, quoteMaxInsurance, orderStepSize, orderTickSize, minOrderSize, concentrationCoefScale, curveUpdateIntensity, ammJitIntensity, name, lpPoolId, fundingClampThreshold, fundingRampSlope);
143
143
  const tx = await this.buildTransaction(initializeMarketIxs);
144
144
  const { txSig } = await this.sendTransaction(tx, [], this.opts);
145
145
  while (this.getStateAccount().numberOfMarkets <= currentPerpMarketIndex) {
@@ -153,11 +153,11 @@ class AdminClient extends velocityClient_1.VelocityClient {
153
153
  await this.accountSubscriber.setPerpOracleMap();
154
154
  return txSig;
155
155
  }
156
- async getInitializePerpMarketIx(marketIndex, priceOracle, baseAssetReserve, quoteAssetReserve, periodicity, pegMultiplier = numericConstants_1.PEG_PRECISION, oracleSource = types_1.OracleSource.PYTH_LAZER, contractTier = types_1.ContractTier.SPECULATIVE, marginRatioInitial = 2000, marginRatioMaintenance = 500, liquidatorFee = 0, ifLiquidatorFee = 10000, imfFactor = 0, activeStatus = true, baseSpread = 0, maxSpread = 142500, maxOpenInterest = numericConstants_1.ZERO, maxRevenueWithdrawPerPeriod = numericConstants_1.ZERO, quoteMaxInsurance = numericConstants_1.ZERO, orderStepSize = numericConstants_1.BASE_PRECISION.divn(10000), orderTickSize = numericConstants_1.PRICE_PRECISION.divn(100000), minOrderSize = numericConstants_1.BASE_PRECISION.divn(10000), concentrationCoefScale = numericConstants_1.ONE, curveUpdateIntensity = 0, ammJitIntensity = 0, name = userName_1.DEFAULT_MARKET_NAME, lpPoolId = 0) {
156
+ async getInitializePerpMarketIx(marketIndex, priceOracle, baseAssetReserve, quoteAssetReserve, periodicity, pegMultiplier = numericConstants_1.PEG_PRECISION, oracleSource = types_1.OracleSource.PYTH_LAZER, contractTier = types_1.ContractTier.SPECULATIVE, marginRatioInitial = 2000, marginRatioMaintenance = 500, liquidatorFee = 0, ifLiquidatorFee = 10000, imfFactor = 0, activeStatus = true, baseSpread = 0, maxSpread = 142500, maxOpenInterest = numericConstants_1.ZERO, maxRevenueWithdrawPerPeriod = numericConstants_1.ZERO, quoteMaxInsurance = numericConstants_1.ZERO, orderStepSize = numericConstants_1.BASE_PRECISION.divn(10000), orderTickSize = numericConstants_1.PRICE_PRECISION.divn(100000), minOrderSize = numericConstants_1.BASE_PRECISION.divn(10000), concentrationCoefScale = numericConstants_1.ONE, curveUpdateIntensity = 0, ammJitIntensity = 0, name = userName_1.DEFAULT_MARKET_NAME, lpPoolId = 0, fundingClampThreshold = 0, fundingRampSlope = 0) {
157
157
  const perpMarketPublicKey = await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, marketIndex);
158
158
  const ixs = [];
159
159
  const nameBuffer = (0, userName_1.encodeName)(name);
160
- const initPerpIx = await this.program.instruction.initializePerpMarket(marketIndex, baseAssetReserve, quoteAssetReserve, periodicity, pegMultiplier, oracleSource, contractTier, marginRatioInitial, marginRatioMaintenance, liquidatorFee, ifLiquidatorFee, imfFactor, activeStatus, baseSpread, maxSpread, maxOpenInterest, maxRevenueWithdrawPerPeriod, quoteMaxInsurance, orderStepSize, orderTickSize, minOrderSize, concentrationCoefScale, curveUpdateIntensity, ammJitIntensity, nameBuffer, lpPoolId, {
160
+ const initPerpIx = await this.program.instruction.initializePerpMarket(marketIndex, baseAssetReserve, quoteAssetReserve, periodicity, pegMultiplier, oracleSource, contractTier, marginRatioInitial, marginRatioMaintenance, liquidatorFee, ifLiquidatorFee, imfFactor, activeStatus, baseSpread, maxSpread, maxOpenInterest, maxRevenueWithdrawPerPeriod, quoteMaxInsurance, orderStepSize, orderTickSize, minOrderSize, concentrationCoefScale, curveUpdateIntensity, ammJitIntensity, nameBuffer, lpPoolId, fundingClampThreshold, fundingRampSlope, {
161
161
  accounts: {
162
162
  state: await this.getStatePublicKey(),
163
163
  admin: this.useHotWalletAdmin
@@ -711,6 +711,23 @@ class AdminClient extends velocityClient_1.VelocityClient {
711
711
  },
712
712
  });
713
713
  }
714
+ async updatePerpMarketFundingDeadZone(perpMarketIndex, fundingClampThreshold, fundingRampSlope) {
715
+ const updatePerpMarketFundingDeadZoneIx = await this.getUpdatePerpMarketFundingDeadZoneIx(perpMarketIndex, fundingClampThreshold, fundingRampSlope);
716
+ const tx = await this.buildTransaction(updatePerpMarketFundingDeadZoneIx);
717
+ const { txSig } = await this.sendTransaction(tx, [], this.opts);
718
+ return txSig;
719
+ }
720
+ async getUpdatePerpMarketFundingDeadZoneIx(perpMarketIndex, fundingClampThreshold, fundingRampSlope) {
721
+ return await this.program.instruction.updatePerpMarketFundingDeadZone(fundingClampThreshold, fundingRampSlope, {
722
+ accounts: {
723
+ admin: this.isSubscribed
724
+ ? this.getStateAccount().coldAdmin
725
+ : this.wallet.publicKey,
726
+ state: await this.getStatePublicKey(),
727
+ perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
728
+ },
729
+ });
730
+ }
714
731
  async updatePerpMarketImfFactor(perpMarketIndex, imfFactor, unrealizedPnlImfFactor) {
715
732
  const updatePerpMarketImfFactorIx = await this.getUpdatePerpMarketImfFactorIx(perpMarketIndex, imfFactor, unrealizedPnlImfFactor);
716
733
  const tx = await this.buildTransaction(updatePerpMarketImfFactorIx);
@@ -49,6 +49,7 @@ export declare const PRICE_DIV_PEG: BN;
49
49
  export declare const PRICE_TO_QUOTE_PRECISION: BN;
50
50
  export declare const AMM_TIMES_PEG_TO_QUOTE_PRECISION_RATIO: BN;
51
51
  export declare const MARGIN_PRECISION: BN;
52
+ export declare const BPS_PRECISION: BN;
52
53
  export declare const BID_ASK_SPREAD_PRECISION: BN;
53
54
  export declare const LIQUIDATION_PCT_PRECISION: BN;
54
55
  export declare const FUNDING_RATE_OFFSET_DENOMINATOR: BN;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.MARGIN_PRECISION = exports.AMM_TIMES_PEG_TO_QUOTE_PRECISION_RATIO = exports.PRICE_TO_QUOTE_PRECISION = exports.PRICE_DIV_PEG = exports.AMM_TO_QUOTE_PRECISION_RATIO = exports.BASE_PRECISION_EXP = exports.BASE_PRECISION = exports.AMM_RESERVE_PRECISION = exports.PEG_PRECISION = exports.FUNDING_RATE_BUFFER_PRECISION = exports.FUNDING_RATE_PRECISION = exports.PRICE_PRECISION = exports.QUOTE_PRECISION = exports.LIQUIDATION_FEE_PRECISION = exports.SPOT_MARKET_IMF_PRECISION = exports.SPOT_MARKET_IMF_PRECISION_EXP = exports.SPOT_MARKET_BALANCE_PRECISION = exports.SPOT_MARKET_BALANCE_PRECISION_EXP = exports.SPOT_MARKET_WEIGHT_PRECISION = exports.SPOT_MARKET_UTILIZATION_PRECISION = exports.SPOT_MARKET_UTILIZATION_PRECISION_EXP = exports.SPOT_MARKET_CUMULATIVE_INTEREST_PRECISION = exports.SPOT_MARKET_CUMULATIVE_INTEREST_PRECISION_EXP = exports.SPOT_MARKET_RATE_PRECISION = exports.SPOT_MARKET_RATE_PRECISION_EXP = exports.AMM_RESERVE_PRECISION_EXP = exports.PEG_PRECISION_EXP = exports.FUNDING_RATE_PRECISION_EXP = exports.PRICE_PRECISION_EXP = exports.FUNDING_RATE_BUFFER_PRECISION_EXP = exports.QUOTE_PRECISION_EXP = exports.CONCENTRATION_PRECISION = exports.PERCENTAGE_PRECISION = exports.PERCENTAGE_PRECISION_EXP = exports.MAX_LEVERAGE_ORDER_SIZE = exports.MAX_LEVERAGE = exports.TEN_MILLION = exports.BN_MAX = exports.TEN_THOUSAND = exports.TEN = exports.NINE = exports.EIGHT = exports.SEVEN = exports.SIX = exports.FIVE = exports.FOUR = exports.THREE = exports.TWO = exports.ONE = exports.ZERO = void 0;
4
- exports.MIN_I64 = exports.MAX_I64 = exports.GET_MULTIPLE_ACCOUNTS_CHUNK_SIZE = exports.DUST_POSITION_SIZE = exports.SLOT_TIME_ESTIMATE_MS = exports.IDLE_TIME_SLOTS = exports.ACCOUNT_AGE_DELETION_CUTOFF_SECONDS = exports.DEFAULT_REVENUE_SINCE_LAST_FUNDING_SPREAD_RETREAT = exports.OPEN_ORDER_MARGIN_REQUIREMENT = exports.LAMPORTS_EXP = exports.LAMPORTS_PRECISION = exports.QUOTE_SPOT_MARKET_INDEX = exports.ONE_YEAR = exports.ONE_HOUR = exports.FIVE_MINUTE = exports.PRICE_TIMES_AMM_TO_QUOTE_PRECISION_RATIO = exports.FUNDING_RATE_CLAMP_DENOMINATOR = exports.FUNDING_RATE_OFFSET_PERCENTAGE = exports.FUNDING_RATE_OFFSET_DENOMINATOR = exports.LIQUIDATION_PCT_PRECISION = exports.BID_ASK_SPREAD_PRECISION = void 0;
4
+ exports.MIN_I64 = exports.MAX_I64 = exports.GET_MULTIPLE_ACCOUNTS_CHUNK_SIZE = exports.DUST_POSITION_SIZE = exports.SLOT_TIME_ESTIMATE_MS = exports.IDLE_TIME_SLOTS = exports.ACCOUNT_AGE_DELETION_CUTOFF_SECONDS = exports.DEFAULT_REVENUE_SINCE_LAST_FUNDING_SPREAD_RETREAT = exports.OPEN_ORDER_MARGIN_REQUIREMENT = exports.LAMPORTS_EXP = exports.LAMPORTS_PRECISION = exports.QUOTE_SPOT_MARKET_INDEX = exports.ONE_YEAR = exports.ONE_HOUR = exports.FIVE_MINUTE = exports.PRICE_TIMES_AMM_TO_QUOTE_PRECISION_RATIO = exports.FUNDING_RATE_CLAMP_DENOMINATOR = exports.FUNDING_RATE_OFFSET_PERCENTAGE = exports.FUNDING_RATE_OFFSET_DENOMINATOR = exports.LIQUIDATION_PCT_PRECISION = exports.BID_ASK_SPREAD_PRECISION = exports.BPS_PRECISION = void 0;
5
5
  const web3_js_1 = require("@solana/web3.js");
6
6
  const anchor_1 = require("../isomorphic/anchor");
7
7
  exports.ZERO = new anchor_1.BN(0);
@@ -54,6 +54,7 @@ exports.PRICE_DIV_PEG = exports.PRICE_PRECISION.div(exports.PEG_PRECISION); //10
54
54
  exports.PRICE_TO_QUOTE_PRECISION = exports.PRICE_PRECISION.div(exports.QUOTE_PRECISION); // 10^1
55
55
  exports.AMM_TIMES_PEG_TO_QUOTE_PRECISION_RATIO = exports.AMM_RESERVE_PRECISION.mul(exports.PEG_PRECISION).div(exports.QUOTE_PRECISION); // 10^9
56
56
  exports.MARGIN_PRECISION = exports.TEN_THOUSAND;
57
+ exports.BPS_PRECISION = exports.TEN_THOUSAND; // 1 unit = 1bp
57
58
  exports.BID_ASK_SPREAD_PRECISION = new anchor_1.BN(1000000); // 10^6
58
59
  exports.LIQUIDATION_PCT_PRECISION = exports.TEN_THOUSAND;
59
60
  exports.FUNDING_RATE_OFFSET_DENOMINATOR = new anchor_1.BN(3333);
@@ -3317,6 +3317,14 @@ export type Velocity = {
3317
3317
  {
3318
3318
  "name": "lpPoolId";
3319
3319
  "type": "u8";
3320
+ },
3321
+ {
3322
+ "name": "fundingClampThreshold";
3323
+ "type": "u32";
3324
+ },
3325
+ {
3326
+ "name": "fundingRampSlope";
3327
+ "type": "u32";
3320
3328
  }
3321
3329
  ];
3322
3330
  },
@@ -9895,6 +9903,42 @@ export type Velocity = {
9895
9903
  }
9896
9904
  ];
9897
9905
  },
9906
+ {
9907
+ "name": "updatePerpMarketFundingDeadZone";
9908
+ "discriminator": [
9909
+ 249,
9910
+ 58,
9911
+ 136,
9912
+ 96,
9913
+ 2,
9914
+ 116,
9915
+ 111,
9916
+ 127
9917
+ ];
9918
+ "accounts": [
9919
+ {
9920
+ "name": "admin";
9921
+ "signer": true;
9922
+ },
9923
+ {
9924
+ "name": "state";
9925
+ },
9926
+ {
9927
+ "name": "perpMarket";
9928
+ "writable": true;
9929
+ }
9930
+ ];
9931
+ "args": [
9932
+ {
9933
+ "name": "fundingClampThreshold";
9934
+ "type": "u32";
9935
+ },
9936
+ {
9937
+ "name": "fundingRampSlope";
9938
+ "type": "u32";
9939
+ }
9940
+ ];
9941
+ },
9898
9942
  {
9899
9943
  "name": "updatePerpMarketFundingPeriod";
9900
9944
  "discriminator": [
@@ -20656,17 +20700,25 @@ export type Velocity = {
20656
20700
  "type": "i64";
20657
20701
  },
20658
20702
  {
20659
- "name": "paddingFundingTwap";
20703
+ "name": "fundingClampThreshold";
20660
20704
  "docs": [
20661
- "Explicit padding where `last_funding_oracle_twap` used to live",
20662
- "(moved to `MarketStats`); keeps every later field at its old offset."
20705
+ "dead-zone threshold for the funding premium. mark/oracle twap spreads",
20706
+ "within +/- this band are treated as noise and add no premium; spreads",
20707
+ "past it are shrunk toward zero by this amount so funding stays continuous",
20708
+ "across the boundary. fit per market post-launch",
20709
+ "precision: BPS_PRECISION"
20663
20710
  ];
20664
- "type": {
20665
- "array": [
20666
- "u8",
20667
- 8
20668
- ];
20669
- };
20711
+ "type": "u32";
20712
+ },
20713
+ {
20714
+ "name": "fundingRampSlope";
20715
+ "docs": [
20716
+ "slope of the funding premium ramp above the dead zone. 1.0x passes the",
20717
+ "shrunk spread through unchanged; higher leans into the premium harder",
20718
+ "fit per market post-launch",
20719
+ "precision: PERCENTAGE_PRECISION"
20720
+ ];
20721
+ "type": "u32";
20670
20722
  },
20671
20723
  {
20672
20724
  "name": "orderStepSize";
@@ -3311,6 +3311,14 @@
3311
3311
  {
3312
3312
  "name": "lp_pool_id",
3313
3313
  "type": "u8"
3314
+ },
3315
+ {
3316
+ "name": "funding_clamp_threshold",
3317
+ "type": "u32"
3318
+ },
3319
+ {
3320
+ "name": "funding_ramp_slope",
3321
+ "type": "u32"
3314
3322
  }
3315
3323
  ]
3316
3324
  },
@@ -9889,6 +9897,42 @@
9889
9897
  }
9890
9898
  ]
9891
9899
  },
9900
+ {
9901
+ "name": "update_perp_market_funding_dead_zone",
9902
+ "discriminator": [
9903
+ 249,
9904
+ 58,
9905
+ 136,
9906
+ 96,
9907
+ 2,
9908
+ 116,
9909
+ 111,
9910
+ 127
9911
+ ],
9912
+ "accounts": [
9913
+ {
9914
+ "name": "admin",
9915
+ "signer": true
9916
+ },
9917
+ {
9918
+ "name": "state"
9919
+ },
9920
+ {
9921
+ "name": "perp_market",
9922
+ "writable": true
9923
+ }
9924
+ ],
9925
+ "args": [
9926
+ {
9927
+ "name": "funding_clamp_threshold",
9928
+ "type": "u32"
9929
+ },
9930
+ {
9931
+ "name": "funding_ramp_slope",
9932
+ "type": "u32"
9933
+ }
9934
+ ]
9935
+ },
9892
9936
  {
9893
9937
  "name": "update_perp_market_funding_period",
9894
9938
  "discriminator": [
@@ -20650,17 +20694,25 @@
20650
20694
  "type": "i64"
20651
20695
  },
20652
20696
  {
20653
- "name": "_padding_funding_twap",
20697
+ "name": "funding_clamp_threshold",
20654
20698
  "docs": [
20655
- "Explicit padding where `last_funding_oracle_twap` used to live",
20656
- "(moved to `MarketStats`); keeps every later field at its old offset."
20699
+ "dead-zone threshold for the funding premium. mark/oracle twap spreads",
20700
+ "within +/- this band are treated as noise and add no premium; spreads",
20701
+ "past it are shrunk toward zero by this amount so funding stays continuous",
20702
+ "across the boundary. fit per market post-launch",
20703
+ "precision: BPS_PRECISION"
20657
20704
  ],
20658
- "type": {
20659
- "array": [
20660
- "u8",
20661
- 8
20662
- ]
20663
- }
20705
+ "type": "u32"
20706
+ },
20707
+ {
20708
+ "name": "funding_ramp_slope",
20709
+ "docs": [
20710
+ "slope of the funding premium ramp above the dead zone. 1.0x passes the",
20711
+ "shrunk spread through unchanged; higher leans into the premium harder",
20712
+ "fit per market post-launch",
20713
+ "precision: PERCENTAGE_PRECISION"
20714
+ ],
20715
+ "type": "u32"
20664
20716
  },
20665
20717
  {
20666
20718
  "name": "order_step_size",
@@ -102,6 +102,7 @@ export * from './swift/swiftOrderSubscriber';
102
102
  export * from './swift/signedMsgUserAccountSubscriber';
103
103
  export * from './swift/grpcSignedMsgUserAccountSubscriber';
104
104
  export * from './tx/fastSingleTxSender';
105
+ export * from './tx/forwardOnlyTxSender';
105
106
  export * from './tx/retryTxSender';
106
107
  export * from './tx/whileValidTxSender';
107
108
  export * from './tx/priorityFeeCalculator';
@@ -133,6 +133,7 @@ __exportStar(require("./swift/swiftOrderSubscriber"), exports);
133
133
  __exportStar(require("./swift/signedMsgUserAccountSubscriber"), exports);
134
134
  __exportStar(require("./swift/grpcSignedMsgUserAccountSubscriber"), exports);
135
135
  __exportStar(require("./tx/fastSingleTxSender"), exports);
136
+ __exportStar(require("./tx/forwardOnlyTxSender"), exports);
136
137
  __exportStar(require("./tx/retryTxSender"), exports);
137
138
  __exportStar(require("./tx/whileValidTxSender"), exports);
138
139
  __exportStar(require("./tx/priorityFeeCalculator"), exports);
@@ -79,11 +79,27 @@ function calculateAllEstimatedFundingRate(market, mmOraclePriceData, oraclePrice
79
79
  // }
80
80
  const twapSpread = markTwap.sub(oracleTwap);
81
81
  const offset = oracleTwap.abs().div(numericConstants_1.FUNDING_RATE_OFFSET_DENOMINATOR);
82
- const twapSpreadWithOffset = twapSpread
82
+ // dead-zone threshold (per-market bps) as a price delta off the oracle twap
83
+ const clampThreshold = oracleTwap
83
84
  .abs()
84
- .lte(oracleTwap.abs().div(numericConstants_1.FUNDING_RATE_CLAMP_DENOMINATOR))
85
- ? offset
86
- : twapSpread.add(offset);
85
+ .mul(new anchor_1.BN(market.fundingClampThreshold))
86
+ .div(numericConstants_1.BPS_PRECISION);
87
+ let twapSpreadWithOffset;
88
+ if (twapSpread.abs().lte(clampThreshold)) {
89
+ // inside the band: noise, no premium, baseline offset only
90
+ twapSpreadWithOffset = offset;
91
+ }
92
+ else {
93
+ // outside the band: shrink the spread toward zero by the band width
94
+ // (keeping its sign), scale by the per-market ramp slope, add the offset
95
+ const shrunk = twapSpread.isNeg()
96
+ ? twapSpread.add(clampThreshold)
97
+ : twapSpread.sub(clampThreshold);
98
+ const ramped = shrunk
99
+ .mul(new anchor_1.BN(market.fundingRampSlope))
100
+ .div(numericConstants_1.PERCENTAGE_PRECISION);
101
+ twapSpreadWithOffset = ramped.add(offset);
102
+ }
87
103
  const maxSpread = getMaxPriceDivergenceForFundingRate(market, oracleTwap);
88
104
  const clampedSpreadWithOffset = (0, utils_1.clampBN)(twapSpreadWithOffset, maxSpread.mul(new anchor_1.BN(-1)), maxSpread);
89
105
  const twapSpreadPct = clampedSpreadWithOffset
@@ -2,3 +2,9 @@ import { BN } from '../isomorphic/anchor';
2
2
  import { MarginCategory, SpotBalanceType, SpotMarketAccount } from '../types';
3
3
  export declare function castNumberToSpotPrecision(value: number | BN, spotMarket: SpotMarketAccount): BN;
4
4
  export declare function calculateSpotMarketMarginRatio(market: SpotMarketAccount, oraclePrice: BN, marginCategory: MarginCategory, size: BN, balanceType: SpotBalanceType, customMarginRatio?: number): number;
5
+ /**
6
+ * Returns the maximum remaining deposit that can be made to the spot market. If the maxTokenDeposits on the market is zero then there is no limit and this function will also return zero. (so that needs to be checked)
7
+ * @param market
8
+ * @returns
9
+ */
10
+ export declare function calculateMaxRemainingDeposit(market: SpotMarketAccount): BN;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.calculateSpotMarketMarginRatio = exports.castNumberToSpotPrecision = void 0;
3
+ exports.calculateMaxRemainingDeposit = exports.calculateSpotMarketMarginRatio = exports.castNumberToSpotPrecision = void 0;
4
4
  const anchor_1 = require("../isomorphic/anchor");
5
5
  const types_1 = require("../types");
6
6
  const spotBalance_1 = require("./spotBalance");
@@ -32,3 +32,18 @@ function calculateSpotMarketMarginRatio(market, oraclePrice, marginCategory, siz
32
32
  return marginRatio;
33
33
  }
34
34
  exports.calculateSpotMarketMarginRatio = calculateSpotMarketMarginRatio;
35
+ /**
36
+ * Returns the maximum remaining deposit that can be made to the spot market. If the maxTokenDeposits on the market is zero then there is no limit and this function will also return zero. (so that needs to be checked)
37
+ * @param market
38
+ * @returns
39
+ */
40
+ function calculateMaxRemainingDeposit(market) {
41
+ const marketMaxTokenDeposits = market.maxTokenDeposits;
42
+ if (marketMaxTokenDeposits.eq(numericConstants_1.ZERO)) {
43
+ // If the maxTokenDeposits is set to zero then that means there is no limit. Return the largest number we can to represent infinite available deposit.
44
+ return numericConstants_1.ZERO;
45
+ }
46
+ const totalDepositsTokenAmount = (0, spotBalance_1.getTokenAmount)(market.depositBalance, market, types_1.SpotBalanceType.DEPOSIT);
47
+ return anchor_1.BN.max(numericConstants_1.ZERO, marketMaxTokenDeposits.sub(totalDepositsTokenAmount));
48
+ }
49
+ exports.calculateMaxRemainingDeposit = calculateMaxRemainingDeposit;
@@ -0,0 +1,37 @@
1
+ /// <reference types="node" />
2
+ /// <reference types="node" />
3
+ import { ConfirmOptions, Connection } from '@solana/web3.js';
4
+ import { BaseTxSender } from './baseTxSender';
5
+ import { ConfirmationStrategy, TxSigAndSlot } from './types';
6
+ import { TxHandler } from './txHandler';
7
+ import { IWallet } from '../types';
8
+ type ResolveReference = {
9
+ resolve?: () => void;
10
+ };
11
+ export declare class ForwardOnlyTxSender extends BaseTxSender {
12
+ connection: Connection;
13
+ wallet: IWallet;
14
+ opts: ConfirmOptions;
15
+ timeout: number;
16
+ retrySleep: number;
17
+ additionalConnections: Connection[];
18
+ timoutCount: number;
19
+ constructor({ connection, wallet, opts, timeout, retrySleep, confirmationStrategy, additionalTxSenderCallbacks, txHandler, trackTxLandRate, txLandRateLookbackWindowMinutes, landRateToFeeFunc, throwOnTimeoutError, }: {
20
+ connection: Connection;
21
+ wallet: IWallet;
22
+ opts?: ConfirmOptions;
23
+ timeout?: number;
24
+ retrySleep?: number;
25
+ confirmationStrategy?: ConfirmationStrategy;
26
+ additionalTxSenderCallbacks?: ((base58EncodedTx: string) => void)[];
27
+ txHandler?: TxHandler;
28
+ trackTxLandRate?: boolean;
29
+ txLandRateLookbackWindowMinutes?: number;
30
+ landRateToFeeFunc?: (landRate: number) => number;
31
+ throwOnTimeoutError?: boolean;
32
+ });
33
+ sleep(reference: ResolveReference): Promise<void>;
34
+ sendToAdditionalConnections(rawTx: Buffer | Uint8Array, _opts: ConfirmOptions): void;
35
+ sendRawTransaction(rawTransaction: Buffer | Uint8Array, opts: ConfirmOptions): Promise<TxSigAndSlot>;
36
+ }
37
+ export {};
@@ -0,0 +1,92 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.ForwardOnlyTxSender = void 0;
7
+ const web3_js_1 = require("@solana/web3.js");
8
+ const bs58_1 = __importDefault(require("bs58"));
9
+ const baseTxSender_1 = require("./baseTxSender");
10
+ const types_1 = require("./types");
11
+ const config_1 = require("../config");
12
+ const DEFAULT_TIMEOUT = 35000;
13
+ const DEFAULT_RETRY = 5000;
14
+ class ForwardOnlyTxSender extends baseTxSender_1.BaseTxSender {
15
+ constructor({ connection, wallet, opts = { ...config_1.DEFAULT_CONFIRMATION_OPTS, maxRetries: 0 }, timeout = DEFAULT_TIMEOUT, retrySleep = DEFAULT_RETRY, confirmationStrategy = types_1.ConfirmationStrategy.Combo, additionalTxSenderCallbacks = [], txHandler, trackTxLandRate, txLandRateLookbackWindowMinutes, landRateToFeeFunc, throwOnTimeoutError = true, }) {
16
+ super({
17
+ connection,
18
+ wallet,
19
+ opts,
20
+ timeout,
21
+ additionalConnections: [],
22
+ confirmationStrategy,
23
+ additionalTxSenderCallbacks,
24
+ txHandler,
25
+ trackTxLandRate,
26
+ txLandRateLookbackWindowMinutes,
27
+ landRateToFeeFunc,
28
+ throwOnTimeoutError,
29
+ });
30
+ this.timoutCount = 0;
31
+ this.connection = connection;
32
+ this.wallet = wallet;
33
+ this.opts = opts;
34
+ this.timeout = timeout;
35
+ this.retrySleep = retrySleep;
36
+ this.additionalConnections = [];
37
+ }
38
+ async sleep(reference) {
39
+ return new Promise((resolve) => {
40
+ reference.resolve = resolve;
41
+ setTimeout(resolve, this.retrySleep);
42
+ });
43
+ }
44
+ sendToAdditionalConnections(rawTx, _opts) {
45
+ var _a;
46
+ (_a = this.additionalTxSenderCallbacks) === null || _a === void 0 ? void 0 : _a.map((callback) => {
47
+ callback(bs58_1.default.encode(rawTx));
48
+ });
49
+ }
50
+ async sendRawTransaction(rawTransaction, opts) {
51
+ var _a, _b, _c;
52
+ const deserializedTx = web3_js_1.VersionedTransaction.deserialize(rawTransaction);
53
+ const txSig = deserializedTx.signatures[0];
54
+ const encodedTxSig = bs58_1.default.encode(txSig);
55
+ const startTime = this.getTimestamp();
56
+ this.sendToAdditionalConnections(rawTransaction, opts);
57
+ (_a = this.txSigCache) === null || _a === void 0 ? void 0 : _a.set(encodedTxSig, false);
58
+ let done = false;
59
+ const resolveReference = {
60
+ resolve: undefined,
61
+ };
62
+ const stopWaiting = () => {
63
+ done = true;
64
+ if (resolveReference.resolve) {
65
+ resolveReference.resolve();
66
+ }
67
+ };
68
+ (async () => {
69
+ while (!done && this.getTimestamp() - startTime < this.timeout) {
70
+ await this.sleep(resolveReference);
71
+ if (!done) {
72
+ this.sendToAdditionalConnections(rawTransaction, opts);
73
+ }
74
+ }
75
+ })();
76
+ let slot;
77
+ try {
78
+ const result = await this.confirmTransaction(encodedTxSig, opts.commitment);
79
+ slot = (_b = result === null || result === void 0 ? void 0 : result.context) === null || _b === void 0 ? void 0 : _b.slot;
80
+ (_c = this.txSigCache) === null || _c === void 0 ? void 0 : _c.set(encodedTxSig, true);
81
+ // eslint-disable-next-line no-useless-catch
82
+ }
83
+ catch (e) {
84
+ throw e;
85
+ }
86
+ finally {
87
+ stopWaiting();
88
+ }
89
+ return { txSig: encodedTxSig, slot };
90
+ }
91
+ }
92
+ exports.ForwardOnlyTxSender = ForwardOnlyTxSender;
@@ -901,6 +901,8 @@ export type PerpMarketAccount = {
901
901
  lastFundingRateShort: BN;
902
902
  lastFundingRateTs: BN;
903
903
  netUnsettledFundingPnl: BN;
904
+ fundingClampThreshold: number;
905
+ fundingRampSlope: number;
904
906
  orderStepSize: BN;
905
907
  orderTickSize: BN;
906
908
  };
@@ -22,8 +22,8 @@ export declare class AdminClient extends VelocityClient {
22
22
  }, scaleInitialAssetWeightStart?: BN, withdrawGuardThreshold?: BN, orderTickSize?: BN, orderStepSize?: BN, ifTotalFactor?: number, name?: string, marketIndex?: number): Promise<TransactionInstruction>;
23
23
  deleteInitializedSpotMarket(marketIndex: number): Promise<TransactionSignature>;
24
24
  getDeleteInitializedSpotMarketIx(marketIndex: number): Promise<TransactionInstruction>;
25
- initializePerpMarket(marketIndex: number, priceOracle: PublicKey, baseAssetReserve: BN, quoteAssetReserve: BN, periodicity: BN, pegMultiplier?: BN, oracleSource?: OracleSource, contractTier?: ContractTier, marginRatioInitial?: number, marginRatioMaintenance?: number, liquidatorFee?: number, ifLiquidatorFee?: number, imfFactor?: number, activeStatus?: boolean, baseSpread?: number, maxSpread?: number, maxOpenInterest?: BN, maxRevenueWithdrawPerPeriod?: BN, quoteMaxInsurance?: BN, orderStepSize?: BN, orderTickSize?: BN, minOrderSize?: BN, concentrationCoefScale?: BN, curveUpdateIntensity?: number, ammJitIntensity?: number, name?: string, lpPoolId?: number): Promise<TransactionSignature>;
26
- getInitializePerpMarketIx(marketIndex: number, priceOracle: PublicKey, baseAssetReserve: BN, quoteAssetReserve: BN, periodicity: BN, pegMultiplier?: BN, oracleSource?: OracleSource, contractTier?: ContractTier, marginRatioInitial?: number, marginRatioMaintenance?: number, liquidatorFee?: number, ifLiquidatorFee?: number, imfFactor?: number, activeStatus?: boolean, baseSpread?: number, maxSpread?: number, maxOpenInterest?: BN, maxRevenueWithdrawPerPeriod?: BN, quoteMaxInsurance?: BN, orderStepSize?: BN, orderTickSize?: BN, minOrderSize?: BN, concentrationCoefScale?: BN, curveUpdateIntensity?: number, ammJitIntensity?: number, name?: string, lpPoolId?: number): Promise<TransactionInstruction[]>;
25
+ initializePerpMarket(marketIndex: number, priceOracle: PublicKey, baseAssetReserve: BN, quoteAssetReserve: BN, periodicity: BN, pegMultiplier?: BN, oracleSource?: OracleSource, contractTier?: ContractTier, marginRatioInitial?: number, marginRatioMaintenance?: number, liquidatorFee?: number, ifLiquidatorFee?: number, imfFactor?: number, activeStatus?: boolean, baseSpread?: number, maxSpread?: number, maxOpenInterest?: BN, maxRevenueWithdrawPerPeriod?: BN, quoteMaxInsurance?: BN, orderStepSize?: BN, orderTickSize?: BN, minOrderSize?: BN, concentrationCoefScale?: BN, curveUpdateIntensity?: number, ammJitIntensity?: number, name?: string, lpPoolId?: number, fundingClampThreshold?: number, fundingRampSlope?: number): Promise<TransactionSignature>;
26
+ getInitializePerpMarketIx(marketIndex: number, priceOracle: PublicKey, baseAssetReserve: BN, quoteAssetReserve: BN, periodicity: BN, pegMultiplier?: BN, oracleSource?: OracleSource, contractTier?: ContractTier, marginRatioInitial?: number, marginRatioMaintenance?: number, liquidatorFee?: number, ifLiquidatorFee?: number, imfFactor?: number, activeStatus?: boolean, baseSpread?: number, maxSpread?: number, maxOpenInterest?: BN, maxRevenueWithdrawPerPeriod?: BN, quoteMaxInsurance?: BN, orderStepSize?: BN, orderTickSize?: BN, minOrderSize?: BN, concentrationCoefScale?: BN, curveUpdateIntensity?: number, ammJitIntensity?: number, name?: string, lpPoolId?: number, fundingClampThreshold?: number, fundingRampSlope?: number): Promise<TransactionInstruction[]>;
27
27
  initializeAmmCache(txParams?: TxParams): Promise<TransactionSignature>;
28
28
  getInitializeAmmCacheIx(): Promise<TransactionInstruction>;
29
29
  addMarketToAmmCache(perpMarketIndex: number, txParams?: TxParams): Promise<TransactionSignature>;
@@ -92,6 +92,8 @@ export declare class AdminClient extends VelocityClient {
92
92
  getUpdatePerpMarketTargetBaseAssetAmountPerLpIx(perpMarketIndex: number, targetBaseAssetAmountPerLP: number): Promise<TransactionInstruction>;
93
93
  updatePerpMarketMarginRatio(perpMarketIndex: number, marginRatioInitial: number, marginRatioMaintenance: number): Promise<TransactionSignature>;
94
94
  getUpdatePerpMarketMarginRatioIx(perpMarketIndex: number, marginRatioInitial: number, marginRatioMaintenance: number): Promise<TransactionInstruction>;
95
+ updatePerpMarketFundingDeadZone(perpMarketIndex: number, fundingClampThreshold: number, fundingRampSlope: number): Promise<TransactionSignature>;
96
+ getUpdatePerpMarketFundingDeadZoneIx(perpMarketIndex: number, fundingClampThreshold: number, fundingRampSlope: number): Promise<TransactionInstruction>;
95
97
  updatePerpMarketImfFactor(perpMarketIndex: number, imfFactor: number, unrealizedPnlImfFactor: number): Promise<TransactionSignature>;
96
98
  getUpdatePerpMarketImfFactorIx(perpMarketIndex: number, imfFactor: number, unrealizedPnlImfFactor: number): Promise<TransactionInstruction>;
97
99
  updatePerpMarketBaseSpread(perpMarketIndex: number, baseSpread: number): Promise<TransactionSignature>;