flash-sdk 2.3.16 → 2.3.17

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.
@@ -20,7 +20,7 @@ export declare class OraclePrice {
20
20
  }): OraclePrice;
21
21
  toContractOraclePrice(): ContractOraclePrice;
22
22
  cmp(other: OraclePrice): -1 | 0 | 1;
23
- getDeviationFactor(other: OraclePrice): BN;
23
+ getDivergenceFactor(other: OraclePrice): BN;
24
24
  scale_to_exponent(target_exponent: BN): OraclePrice;
25
25
  getTokenAmount(asset_amount_usd: BN, token_decimals: number): BN;
26
26
  getAssetAmountUsd(token_amount: BN, token_decimals: number): BN;
@@ -36,20 +36,29 @@ var OraclePrice = (function () {
36
36
  ;
37
37
  return lhs.cmp(rhs);
38
38
  };
39
- OraclePrice.prototype.getDeviationFactor = function (other) {
40
- if (!this.exponent.eq(other.exponent)) {
41
- throw "Exponents mistmatch ".concat(this.exponent.toNumber(), " != ").concat(other.exponent.toNumber());
39
+ OraclePrice.prototype.getDivergenceFactor = function (other) {
40
+ var thisPrice, reference;
41
+ if (this.exponent.lte(other.exponent)) {
42
+ thisPrice = this;
43
+ reference = other.scale_to_exponent(this.exponent);
44
+ }
45
+ else {
46
+ thisPrice = this.scale_to_exponent(other.exponent);
47
+ reference = other;
48
+ }
49
+ if (!thisPrice.exponent.eq(reference.exponent)) {
50
+ throw "Exponents mistmatch ".concat(thisPrice.exponent.toNumber(), " != ").concat(reference.exponent.toNumber());
42
51
  }
43
52
  var factor;
44
- if (this.price.gt(other.price)) {
45
- factor = OraclePrice.from({ price: (this.price.sub(other.price).div(other.price)), exponent: this.exponent, confidence: constants_1.BN_ZERO, timestamp: constants_1.BN_ZERO });
53
+ if (thisPrice.price.gt(reference.price)) {
54
+ factor = OraclePrice.from({ price: (thisPrice.price.sub(reference.price).div(reference.price)), exponent: thisPrice.exponent, confidence: constants_1.BN_ZERO, timestamp: constants_1.BN_ZERO });
46
55
  }
47
56
  else {
48
- if (!other.price.isZero()) {
49
- factor = OraclePrice.from({ price: (other.price.sub(this.price).div(other.price)), exponent: this.exponent, confidence: constants_1.BN_ZERO, timestamp: constants_1.BN_ZERO });
57
+ if (!reference.price.isZero()) {
58
+ factor = OraclePrice.from({ price: (reference.price.sub(thisPrice.price).div(reference.price)), exponent: thisPrice.exponent, confidence: constants_1.BN_ZERO, timestamp: constants_1.BN_ZERO });
50
59
  }
51
60
  else {
52
- factor = OraclePrice.from({ price: constants_1.BN_ZERO, exponent: this.exponent, confidence: constants_1.BN_ZERO, timestamp: constants_1.BN_ZERO });
61
+ factor = OraclePrice.from({ price: constants_1.BN_ZERO, exponent: thisPrice.exponent, confidence: constants_1.BN_ZERO, timestamp: constants_1.BN_ZERO });
53
62
  }
54
63
  }
55
64
  return (factor.scale_to_exponent(new anchor_1.BN(-1 * constants_1.BPS_DECIMALS)).price);
@@ -2145,7 +2145,7 @@ export declare class PerpetualsClient {
2145
2145
  prettyPrint: (object: object) => void;
2146
2146
  init: (admins: PublicKey[], config: any) => Promise<void>;
2147
2147
  setAdminSigners: (admins: PublicKey[], minSignatures: number) => Promise<void>;
2148
- addPool: (name: string, maxAumUsd: BN, permissions: Permissions, metadataSymbol: string, metadataTitle: string, metadataUri: string) => Promise<void>;
2148
+ addPool: (name: string, maxAumUsd: BN, permissions: Permissions, metadataSymbol: string, metadataTitle: string, metadataUri: string, stakingFeeShareBps: BN, vpVolumeFactor: number) => Promise<void>;
2149
2149
  removePool: (name: string) => Promise<void>;
2150
2150
  addCustody: (poolName: string, tokenMint: PublicKey, isStable: boolean, isVirtual: boolean, oracle: OracleParams, pricing: PricingParams, permissions: Permissions, fees: Fees, borrowRate: BorrowRateParams, ratios: TokenRatios[], depegAdjustment: boolean) => Promise<void>;
2151
2151
  editCustody: (poolName: string, tokenMint: PublicKey, isStable: boolean, oracle: OracleParams, pricing: PricingParams, permissions: Permissions, fees: Fees, borrowRate: BorrowRateParams, ratios: TokenRatios[]) => Promise<void>;
@@ -2156,7 +2156,7 @@ export declare class PerpetualsClient {
2156
2156
  getAddLiquidityAmountAndFeeSync: (amountIn: BN, poolAccount: PoolAccount, inputTokenPrice: OraclePrice, inputTokenEmaPrice: OraclePrice, inputTokenCustodyAccount: CustodyAccount, lpTokenSupplyAmount: BN, poolAumUsdMax: BN, poolConfig: PoolConfig) => AddLiquidityAmountAndFee;
2157
2157
  getRemoveLiquidityAmountAndFeeSync: (lpAmountIn: BN, poolAccount: PoolAccount, outputTokenPrice: OraclePrice, outputTokenEmaPrice: OraclePrice, outputTokenCustodyAccount: CustodyAccount, lpTokenSupply: BN, poolAumUsdMax: BN, poolConfig: PoolConfig) => RemoveLiquidityAmountAndFee;
2158
2158
  private getNewRatioHelper;
2159
- getFeeHelper: (action: FeesAction, amountAdd: BN, amountRemove: BN, inputTokenCustodyAccount: CustodyAccount, maxPrice: BN, poolAumUsdMax: BN, poolAccount: PoolAccount, poolConfig: PoolConfig) => {
2159
+ getFeeHelper: (action: FeesAction, amountAdd: BN, amountRemove: BN, inputTokenCustodyAccount: CustodyAccount, maxOraclePrice: OraclePrice, poolAumUsdMax: BN, poolAccount: PoolAccount, poolConfig: PoolConfig) => {
2160
2160
  feeBps: BN;
2161
2161
  feeAmount: BN;
2162
2162
  };
@@ -2170,8 +2170,7 @@ export declare class PerpetualsClient {
2170
2170
  getLeverageSync: (sizeUsd: BN, collateralAmount: BN, collateralMinOraclePrice: OraclePrice, collateralTokenDecimals: number, pnlUsd: BN) => BN;
2171
2171
  getLeverageAtAmountEntryWithSwapSync: (positionAccount: PositionAccount | null, inputDeltaAmount: BN, sizeDeltaAmount: BN, side: Side, poolAccount: PoolAccount, inputTokenPrice: OraclePrice, inputTokenEmaPrice: OraclePrice, inputTokenCustodyAccount: CustodyAccount, swapOutTokenPrice: OraclePrice, swapOutTokenEmaPrice: OraclePrice, swapOutTokenCustodyAccount: CustodyAccount, collateralTokenPrice: OraclePrice, collateralTokenEmaPrice: OraclePrice, collateralTokenCustodyAccount: CustodyAccount, targetTokenPrice: OraclePrice, targetTokenEmaPrice: OraclePrice, targetTokenCustodyAccount: CustodyAccount, swapPoolAumUsdMax: BN, poolConfigPosition: PoolConfig, poolConfigSwap: PoolConfig, pnlUsd: BN) => BN;
2172
2172
  getEntryPriceAndFeeSync: (positionAccount: PositionAccount | null, marketCorrelation: boolean, collateralDeltaAmount: BN, sizeDeltaAmount: BN, side: Side, targetPrice: OraclePrice, targetEmaPrice: OraclePrice, targetCustodyAccount: CustodyAccount, collateralPrice: OraclePrice, collateralEmaPrice: OraclePrice, collateralCustodyAccount: CustodyAccount, currentTimestamp: BN, discountBps?: BN) => EntryPriceAndFee;
2173
- getEntryPriceUsdSync: (side: Side, targetPrice: OraclePrice, targetEmaPrice: OraclePrice, targetCustodyAccount: CustodyAccount) => BN;
2174
- getPriceAfterSlippageOld(isEntry: boolean, slippageBps: BN, targetPrice: OraclePrice, targetEmaPrice: OraclePrice, side: Side, custody: CustodyAccount): ContractOraclePrice;
2173
+ getEntryPriceUsdSync: (side: Side, targetPrice: OraclePrice, targetEmaPrice: OraclePrice, targetCustodyAccount: CustodyAccount) => OraclePrice;
2175
2174
  getPriceAfterSlippage(isEntry: boolean, slippageBps: BN, targetPrice: OraclePrice, side: Side): ContractOraclePrice;
2176
2175
  getExitFeeSync: (positionAccount: PositionAccount, targetCustody: CustodyAccount, collateralCustodyAccount: CustodyAccount, collateralPrice: OraclePrice, collateralEmaPrice: OraclePrice, discountBps?: BN) => {
2177
2176
  exitFeeAmount: BN;
@@ -2192,8 +2191,8 @@ export declare class PerpetualsClient {
2192
2191
  getMaxWithdrawableAmountSync: (positionAccount: PositionAccount, targetPrice: OraclePrice, targetEmaPrice: OraclePrice, targetCustodyAccount: CustodyAccount, collateralPrice: OraclePrice, collateralEmaPrice: OraclePrice, collateralCustodyAccount: CustodyAccount, currentTimestamp: BN, poolConfig: PoolConfig, errorBandwidthPercentageUi?: number) => BN;
2193
2192
  getCumulativeLockFeeSync: (custodyAccount: CustodyAccount, currentTimestamp: BN) => BN;
2194
2193
  getLockFeeAndUnsettledUsdForPosition: (position: PositionAccount, collateralCustodyAccount: CustodyAccount, currentTimestamp: BN) => BN;
2195
- getLiquidationPriceSync: (collateralAmount: BN, sizeAmount: BN, entryPriceUsd: BN, lockAndUnsettledFeeUsd: BN, marketCorrelation: boolean, side: Side, custodyAccount: CustodyAccount, collateralPrice: OraclePrice, collateralEmaPrice: OraclePrice, collateralCustodyAccount: CustodyAccount, positionAccount: PositionAccount) => BN;
2196
- getMaxProfitPriceSync: (entryPriceUsd: BN, marketCorrelation: boolean, side: Side, positionAccount: PositionAccount) => BN;
2194
+ getLiquidationPriceSync: (collateralAmount: BN, sizeAmount: BN, entryOraclePrice: OraclePrice, lockAndUnsettledFeeUsd: BN, marketCorrelation: boolean, side: Side, custodyAccount: CustodyAccount, collateralPrice: OraclePrice, collateralEmaPrice: OraclePrice, collateralCustodyAccount: CustodyAccount, positionAccount: PositionAccount) => OraclePrice;
2195
+ getMaxProfitPriceSync: (entryPrice: OraclePrice, marketCorrelation: boolean, side: Side, positionAccount: PositionAccount) => OraclePrice;
2197
2196
  getPnlSync: (positionAccount: PositionAccount, targetTokenPrice: OraclePrice, targetTokenEmaPrice: OraclePrice, targetCustodyAccount: CustodyAccount, collateralPrice: OraclePrice, collateralEmaPrice: OraclePrice, collateralCustodyAccount: CustodyAccount, currentTimestamp: BN, delay: BN, poolConfig: PoolConfig) => {
2198
2197
  profitUsd: BN;
2199
2198
  lossUsd: BN;