@velocity-exchange/sdk 0.2.2 → 0.2.4
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/CHANGELOG.md +12 -0
- package/lib/browser/adminClient.d.ts +4 -2
- package/lib/browser/adminClient.js +21 -4
- package/lib/browser/config.js +1 -1
- package/lib/browser/constants/numericConstants.d.ts +1 -0
- package/lib/browser/constants/numericConstants.js +2 -1
- package/lib/browser/constants/spotMarkets.js +1 -1
- package/lib/browser/idl/velocity.d.ts +61 -9
- package/lib/browser/idl/velocity.json +61 -9
- package/lib/browser/index.d.ts +1 -0
- package/lib/browser/index.js +1 -0
- package/lib/browser/math/funding.js +20 -4
- package/lib/browser/math/liquidation.d.ts +14 -0
- package/lib/browser/math/liquidation.js +14 -0
- package/lib/browser/math/spotMarket.d.ts +6 -0
- package/lib/browser/math/spotMarket.js +16 -1
- package/lib/browser/tx/forwardOnlyTxSender.d.ts +37 -0
- package/lib/browser/tx/forwardOnlyTxSender.js +92 -0
- package/lib/browser/types.d.ts +77 -9
- package/lib/browser/userMap/userMap.js +5 -1
- package/lib/node/adminClient.d.ts +4 -2
- package/lib/node/adminClient.d.ts.map +1 -1
- package/lib/node/adminClient.js +21 -4
- package/lib/node/config.js +1 -1
- package/lib/node/constants/numericConstants.d.ts +1 -0
- package/lib/node/constants/numericConstants.d.ts.map +1 -1
- package/lib/node/constants/numericConstants.js +2 -1
- package/lib/node/constants/spotMarkets.js +1 -1
- package/lib/node/idl/velocity.d.ts +61 -9
- package/lib/node/idl/velocity.d.ts.map +1 -1
- package/lib/node/idl/velocity.json +61 -9
- package/lib/node/index.d.ts +1 -0
- package/lib/node/index.d.ts.map +1 -1
- package/lib/node/index.js +1 -0
- package/lib/node/math/funding.d.ts.map +1 -1
- package/lib/node/math/funding.js +20 -4
- package/lib/node/math/liquidation.d.ts +14 -0
- package/lib/node/math/liquidation.d.ts.map +1 -1
- package/lib/node/math/liquidation.js +14 -0
- package/lib/node/math/spotMarket.d.ts +6 -0
- package/lib/node/math/spotMarket.d.ts.map +1 -1
- package/lib/node/math/spotMarket.js +16 -1
- package/lib/node/tx/forwardOnlyTxSender.d.ts +38 -0
- package/lib/node/tx/forwardOnlyTxSender.d.ts.map +1 -0
- package/lib/node/tx/forwardOnlyTxSender.js +92 -0
- package/lib/node/types.d.ts +77 -9
- package/lib/node/types.d.ts.map +1 -1
- package/lib/node/userMap/userMap.d.ts.map +1 -1
- package/lib/node/userMap/userMap.js +5 -1
- package/package.json +1 -1
- package/src/adminClient.ts +53 -3
- package/src/config.ts +1 -1
- package/src/constants/numericConstants.ts +1 -0
- package/src/constants/spotMarkets.ts +1 -1
- package/src/idl/velocity.json +61 -9
- package/src/idl/velocity.ts +61 -9
- package/src/index.ts +1 -0
- package/src/math/funding.ts +23 -5
- package/src/math/liquidation.ts +14 -0
- package/src/math/spotMarket.ts +28 -2
- package/src/tx/forwardOnlyTxSender.ts +145 -0
- package/src/types.ts +84 -9
- package/src/userMap/userMap.ts +5 -1
- package/tests/amm/test.ts +2 -2
- package/tests/dlob/helpers.ts +26 -4
|
@@ -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": "
|
|
20697
|
+
"name": "funding_clamp_threshold",
|
|
20654
20698
|
"docs": [
|
|
20655
|
-
"
|
|
20656
|
-
"
|
|
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
|
-
|
|
20660
|
-
|
|
20661
|
-
|
|
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",
|
package/lib/node/index.d.ts
CHANGED
|
@@ -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';
|
package/lib/node/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,EAAE,EAAE,MAAM,qBAAqB,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,IAAI,MAAM,qBAAqB,CAAC;AAEvC,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,sBAAsB,CAAC;AACrC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,SAAS,CAAC;AACxB,cAAc,kBAAkB,CAAC;AACjC,cAAc,qDAAqD,CAAC;AACpE,cAAc,yDAAyD,CAAC;AACxE,OAAO,EAAE,4BAA4B,EAAE,MAAM,yCAAyC,CAAC;AACvF,OAAO,EAAE,iCAAiC,EAAE,MAAM,8CAA8C,CAAC;AACjG,OAAO,EAAE,qCAAqC,EAAE,MAAM,kDAAkD,CAAC;AACzG,OAA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;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,eAAe,CAAC;AAC9B,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC;AACvC,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC;AACtC,cAAc,cAAc,CAAC;AAC7B,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,iCAAiC,CAAC;AAChD,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,uCAAuC,CAAC;AACtD,cAAc,yBAAyB,CAAC;AACxC,cAAc,4CAA4C,CAAC;AAC3D,cAAc,aAAa,CAAC;AAC5B,cAAc,iCAAiC,CAAC;AAChD,cAAc,QAAQ,CAAC;AAEvB,OAAO,EAAE,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC"}
|
package/lib/node/index.js
CHANGED
|
@@ -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);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"funding.d.ts","sourceRoot":"","sources":["../../../src/math/funding.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"funding.d.ts","sourceRoot":"","sources":["../../../src/math/funding.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,sBAAsB,CAAC;AAY1C,OAAO,EAAE,iBAAiB,EAAa,MAAM,UAAU,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAoHtE;;;;;;GAMG;AACH,wBAAgB,gCAAgC,CAC/C,MAAM,EAAE,iBAAiB,EACzB,iBAAiB,CAAC,EAAE,iBAAiB,EACrC,eAAe,CAAC,EAAE,eAAe,EACjC,SAAS,CAAC,EAAE,EAAE,EACd,GAAG,CAAC,EAAE,EAAE,GACN,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CA8ItB;AAcD;;;GAGG;AACH,wBAAgB,iCAAiC,CAChD,MAAM,EAAE,iBAAiB,EACzB,iBAAiB,EAAE,iBAAiB,EACpC,eAAe,EAAE,eAAe,EAChC,MAAM,EAAE,MAAM,GAAG,MAAM,GACrB;IACF,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,EAAE,MAAM,CAAC;IACxB,2BAA2B,EAAE,MAAM,CAAC;CACpC,CAoDA;AAiBD;;;;;;GAMG;AACH,wBAAgB,6BAA6B,CAC5C,MAAM,EAAE,iBAAiB,EACzB,iBAAiB,CAAC,EAAE,iBAAiB,EACrC,eAAe,CAAC,EAAE,eAAe,EACjC,SAAS,CAAC,EAAE,EAAE,EACd,GAAG,CAAC,EAAE,EAAE,GACN,CAAC,EAAE,EAAE,EAAE,CAAC,CAgBV;AAED;;;;;;GAMG;AACH,wBAAgB,yCAAyC,CACxD,MAAM,EAAE,iBAAiB,EACzB,iBAAiB,CAAC,EAAE,iBAAiB,EACrC,eAAe,CAAC,EAAE,eAAe,EACjC,SAAS,CAAC,EAAE,EAAE,EACd,GAAG,CAAC,EAAE,EAAE,GACN,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAiBlB;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,iBAAiB,GAAG,EAAE,CAQlE"}
|
package/lib/node/math/funding.js
CHANGED
|
@@ -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
|
-
|
|
82
|
+
// dead-zone threshold (per-market bps) as a price delta off the oracle twap
|
|
83
|
+
const clampThreshold = oracleTwap
|
|
83
84
|
.abs()
|
|
84
|
-
.
|
|
85
|
-
|
|
86
|
-
|
|
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
|
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
import { BN } from '../isomorphic/anchor';
|
|
2
|
+
/**
|
|
3
|
+
* @param ifLiquidationFee Since PR#75 the program sizes liquidations against the
|
|
4
|
+
* COMBINED insurance-fund + protocol liquidation fee budget:
|
|
5
|
+
* `market.ifLiquidationFee + market.protocolLiquidationFee` (split IF-first
|
|
6
|
+
* on-chain). Pass that sum here to match on-chain sizing; passing
|
|
7
|
+
* `market.ifLiquidationFee` alone under-sizes the estimate.
|
|
8
|
+
*/
|
|
2
9
|
export declare function calculateBaseAssetAmountToCoverMarginShortage(marginShortage: BN, marginRatio: number, liquidationFee: number, ifLiquidationFee: number, oraclePrice: BN, quoteOraclePrice: BN): BN | undefined;
|
|
10
|
+
/**
|
|
11
|
+
* @param ifLiquidationFee Since PR#75 the program sizes liquidations against the
|
|
12
|
+
* COMBINED insurance-fund + protocol liquidation fee budget:
|
|
13
|
+
* `market.ifLiquidationFee + market.protocolLiquidationFee` (split IF-first
|
|
14
|
+
* on-chain). Pass that sum here to match on-chain sizing; passing
|
|
15
|
+
* `market.ifLiquidationFee` alone under-sizes the estimate.
|
|
16
|
+
*/
|
|
3
17
|
export declare function calculateLiabilityTransferToCoverMarginShortage(marginShortage: BN, assetWeight: number, assetLiquidationMultiplier: number, liabilityWeight: number, liabilityLiquidationMultiplier: number, liabilityDecimals: number, liabilityPrice: BN, ifLiquidationFee: number): BN | undefined;
|
|
4
18
|
export declare function calculateAssetTransferForLiabilityTransfer(assetAmount: BN, assetLiquidationMultiplier: number, assetDecimals: number, assetPrice: BN, liabilityAmount: BN, liabilityLiquidationMultiplier: number, liabilityDecimals: number, liabilityPrice: BN): BN | undefined;
|
|
5
19
|
export declare function calculateMaxPctToLiquidate(userLastActiveSlot: BN, userLiquidationMarginFreed: BN, marginShortage: BN, slot: BN, initialPctToLiquidate: BN, liquidationDuration: BN): BN;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"liquidation.d.ts","sourceRoot":"","sources":["../../../src/math/liquidation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,sBAAsB,CAAC;AAa1C,wBAAgB,6CAA6C,CAC5D,cAAc,EAAE,EAAE,EAClB,WAAW,EAAE,MAAM,EACnB,cAAc,EAAE,MAAM,EACtB,gBAAgB,EAAE,MAAM,EACxB,WAAW,EAAE,EAAE,EACf,gBAAgB,EAAE,EAAE,GAClB,EAAE,GAAG,SAAS,CAqBhB;AAED,wBAAgB,+CAA+C,CAC9D,cAAc,EAAE,EAAE,EAClB,WAAW,EAAE,MAAM,EACnB,0BAA0B,EAAE,MAAM,EAClC,eAAe,EAAE,MAAM,EACvB,8BAA8B,EAAE,MAAM,EACtC,iBAAiB,EAAE,MAAM,EACzB,cAAc,EAAE,EAAE,EAClB,gBAAgB,EAAE,MAAM,GACtB,EAAE,GAAG,SAAS,CA8ChB;AAED,wBAAgB,0CAA0C,CACzD,WAAW,EAAE,EAAE,EACf,0BAA0B,EAAE,MAAM,EAClC,aAAa,EAAE,MAAM,EACrB,UAAU,EAAE,EAAE,EACd,eAAe,EAAE,EAAE,EACnB,8BAA8B,EAAE,MAAM,EACtC,iBAAiB,EAAE,MAAM,EACzB,cAAc,EAAE,EAAE,GAChB,EAAE,GAAG,SAAS,CAkDhB;AAED,wBAAgB,0BAA0B,CACzC,kBAAkB,EAAE,EAAE,EACtB,0BAA0B,EAAE,EAAE,EAC9B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B,EAAE,EAAE,EACzB,mBAAmB,EAAE,EAAE,GACrB,EAAE,CA+BJ;AAED,wBAAgB,iBAAiB,CAChC,sCAAsC,EAAE,EAAE,EAC1C,0BAA0B,EAAE,EAAE,GAC5B,EAAE,CAIJ"}
|
|
@@ -3,6 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getMarginShortage = exports.calculateMaxPctToLiquidate = exports.calculateAssetTransferForLiabilityTransfer = exports.calculateLiabilityTransferToCoverMarginShortage = exports.calculateBaseAssetAmountToCoverMarginShortage = void 0;
|
|
4
4
|
const anchor_1 = require("../isomorphic/anchor");
|
|
5
5
|
const numericConstants_1 = require("../constants/numericConstants");
|
|
6
|
+
/**
|
|
7
|
+
* @param ifLiquidationFee Since PR#75 the program sizes liquidations against the
|
|
8
|
+
* COMBINED insurance-fund + protocol liquidation fee budget:
|
|
9
|
+
* `market.ifLiquidationFee + market.protocolLiquidationFee` (split IF-first
|
|
10
|
+
* on-chain). Pass that sum here to match on-chain sizing; passing
|
|
11
|
+
* `market.ifLiquidationFee` alone under-sizes the estimate.
|
|
12
|
+
*/
|
|
6
13
|
function calculateBaseAssetAmountToCoverMarginShortage(marginShortage, marginRatio, liquidationFee, ifLiquidationFee, oraclePrice, quoteOraclePrice) {
|
|
7
14
|
const marginRatioBN = new anchor_1.BN(marginRatio)
|
|
8
15
|
.mul(numericConstants_1.LIQUIDATION_FEE_PRECISION)
|
|
@@ -20,6 +27,13 @@ function calculateBaseAssetAmountToCoverMarginShortage(marginShortage, marginRat
|
|
|
20
27
|
.sub(oraclePrice.mul(new anchor_1.BN(ifLiquidationFee)).div(numericConstants_1.LIQUIDATION_FEE_PRECISION)));
|
|
21
28
|
}
|
|
22
29
|
exports.calculateBaseAssetAmountToCoverMarginShortage = calculateBaseAssetAmountToCoverMarginShortage;
|
|
30
|
+
/**
|
|
31
|
+
* @param ifLiquidationFee Since PR#75 the program sizes liquidations against the
|
|
32
|
+
* COMBINED insurance-fund + protocol liquidation fee budget:
|
|
33
|
+
* `market.ifLiquidationFee + market.protocolLiquidationFee` (split IF-first
|
|
34
|
+
* on-chain). Pass that sum here to match on-chain sizing; passing
|
|
35
|
+
* `market.ifLiquidationFee` alone under-sizes the estimate.
|
|
36
|
+
*/
|
|
23
37
|
function calculateLiabilityTransferToCoverMarginShortage(marginShortage, assetWeight, assetLiquidationMultiplier, liabilityWeight, liabilityLiquidationMultiplier, liabilityDecimals, liabilityPrice, ifLiquidationFee) {
|
|
24
38
|
if (assetWeight >= liabilityWeight) {
|
|
25
39
|
// undefined is max
|
|
@@ -2,4 +2,10 @@ 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;
|
|
5
11
|
//# sourceMappingURL=spotMarket.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spotMarket.d.ts","sourceRoot":"","sources":["../../../src/math/spotMarket.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,sBAAsB,CAAC;AAC1C,OAAO,EAEN,cAAc,EACd,eAAe,EACf,iBAAiB,EACjB,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"spotMarket.d.ts","sourceRoot":"","sources":["../../../src/math/spotMarket.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,sBAAsB,CAAC;AAC1C,OAAO,EAEN,cAAc,EACd,eAAe,EACf,iBAAiB,EACjB,MAAM,UAAU,CAAC;AASlB,wBAAgB,yBAAyB,CACxC,KAAK,EAAE,MAAM,GAAG,EAAE,EAClB,UAAU,EAAE,iBAAiB,GAC3B,EAAE,CAMJ;AAED,wBAAgB,8BAA8B,CAC7C,MAAM,EAAE,iBAAiB,EACzB,WAAW,EAAE,EAAE,EACf,cAAc,EAAE,cAAc,EAC9B,IAAI,EAAE,EAAE,EACR,WAAW,EAAE,eAAe,EAC5B,iBAAiB,SAAI,GACnB,MAAM,CA0BR;AAED;;;;GAIG;AACH,wBAAgB,4BAA4B,CAAC,MAAM,EAAE,iBAAiB,MAerE"}
|
|
@@ -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,38 @@
|
|
|
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 {};
|
|
38
|
+
//# sourceMappingURL=forwardOnlyTxSender.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"forwardOnlyTxSender.d.ts","sourceRoot":"","sources":["../../../src/tx/forwardOnlyTxSender.ts"],"names":[],"mappings":";;AAAA,OAAO,EACN,cAAc,EACd,UAAU,EAEV,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC7D,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAMnC,KAAK,gBAAgB,GAAG;IACvB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACrB,CAAC;AAEF,qBAAa,mBAAoB,SAAQ,YAAY;IACpD,UAAU,EAAE,UAAU,CAAC;IACvB,MAAM,EAAE,OAAO,CAAC;IAChB,IAAI,EAAE,cAAc,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,qBAAqB,EAAE,UAAU,EAAE,CAAC;IACpC,WAAW,SAAK;gBAEG,EAClB,UAAU,EACV,MAAM,EACN,IAAsD,EACtD,OAAyB,EACzB,UAA0B,EAC1B,oBAAiD,EACjD,2BAAgC,EAChC,SAAS,EACT,eAAe,EACf,+BAA+B,EAC/B,iBAAiB,EACjB,mBAA0B,GAC1B,EAAE;QACF,UAAU,EAAE,UAAU,CAAC;QACvB,MAAM,EAAE,OAAO,CAAC;QAChB,IAAI,CAAC,EAAE,cAAc,CAAC;QACtB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,oBAAoB,CAAC,EAAE,oBAAoB,CAAC;QAC5C,2BAA2B,CAAC,EAAE,CAAC,CAAC,eAAe,EAAE,MAAM,KAAK,IAAI,CAAC,EAAE,CAAC;QACpE,SAAS,CAAC,EAAE,SAAS,CAAC;QACtB,eAAe,CAAC,EAAE,OAAO,CAAC;QAC1B,+BAA+B,CAAC,EAAE,MAAM,CAAC;QACzC,iBAAiB,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,MAAM,CAAC;QACjD,mBAAmB,CAAC,EAAE,OAAO,CAAC;KAC9B;IAuBK,KAAK,CAAC,SAAS,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC;IAOvD,2BAA2B,CAC1B,KAAK,EAAE,MAAM,GAAG,UAAU,EAC1B,KAAK,EAAE,cAAc,GACnB,IAAI;IAMD,kBAAkB,CACvB,cAAc,EAAE,MAAM,GAAG,UAAU,EACnC,IAAI,EAAE,cAAc,GAClB,OAAO,CAAC,YAAY,CAAC;CAgDxB"}
|
|
@@ -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;
|
package/lib/node/types.d.ts
CHANGED
|
@@ -464,6 +464,8 @@ export type DepositRecord = {
|
|
|
464
464
|
depositRecordId: BN;
|
|
465
465
|
explanation: DepositExplanation;
|
|
466
466
|
transferUser?: PublicKey;
|
|
467
|
+
signer?: PublicKey;
|
|
468
|
+
userTokenAmountAfter: BN;
|
|
467
469
|
};
|
|
468
470
|
export type SpotInterestRecord = {
|
|
469
471
|
ts: BN;
|
|
@@ -551,13 +553,14 @@ export type LiquidationRecord = {
|
|
|
551
553
|
marginFreed: BN;
|
|
552
554
|
liquidationId: number;
|
|
553
555
|
bankrupt: boolean;
|
|
554
|
-
canceledOrderIds:
|
|
556
|
+
canceledOrderIds: number[];
|
|
555
557
|
liquidatePerp: LiquidatePerpRecord;
|
|
556
558
|
liquidateSpot: LiquidateSpotRecord;
|
|
557
559
|
liquidateBorrowForPerpPnl: LiquidateBorrowForPerpPnlRecord;
|
|
558
560
|
liquidatePerpPnlForDeposit: LiquidatePerpPnlForDepositRecord;
|
|
559
561
|
perpBankruptcy: PerpBankruptcyRecord;
|
|
560
562
|
spotBankruptcy: SpotBankruptcyRecord;
|
|
563
|
+
bitFlags: number;
|
|
561
564
|
};
|
|
562
565
|
export declare class LiquidationType {
|
|
563
566
|
static readonly LIQUIDATE_PERP: {
|
|
@@ -584,11 +587,12 @@ export type LiquidatePerpRecord = {
|
|
|
584
587
|
oraclePrice: BN;
|
|
585
588
|
baseAssetAmount: BN;
|
|
586
589
|
quoteAssetAmount: BN;
|
|
587
|
-
userOrderId:
|
|
588
|
-
liquidatorOrderId:
|
|
590
|
+
userOrderId: number;
|
|
591
|
+
liquidatorOrderId: number;
|
|
589
592
|
fillRecordId: BN;
|
|
590
593
|
liquidatorFee: BN;
|
|
591
594
|
ifFee: BN;
|
|
595
|
+
protocolFee: BN;
|
|
592
596
|
};
|
|
593
597
|
export type LiquidateSpotRecord = {
|
|
594
598
|
assetMarketIndex: number;
|
|
@@ -598,6 +602,7 @@ export type LiquidateSpotRecord = {
|
|
|
598
602
|
liabilityPrice: BN;
|
|
599
603
|
liabilityTransfer: BN;
|
|
600
604
|
ifFee: BN;
|
|
605
|
+
protocolFee: BN;
|
|
601
606
|
};
|
|
602
607
|
export type LiquidateBorrowForPerpPnlRecord = {
|
|
603
608
|
perpMarketIndex: number;
|
|
@@ -691,6 +696,9 @@ export type OrderActionRecord = {
|
|
|
691
696
|
takerExistingBaseAssetAmount: BN | null;
|
|
692
697
|
makerExistingQuoteEntryAmount: BN | null;
|
|
693
698
|
makerExistingBaseAssetAmount: BN | null;
|
|
699
|
+
triggerPrice: BN | null;
|
|
700
|
+
builderIdx: number | null;
|
|
701
|
+
builderFee: BN | null;
|
|
694
702
|
};
|
|
695
703
|
export type SwapRecord = {
|
|
696
704
|
ts: BN;
|
|
@@ -733,8 +741,6 @@ export type LPSwapRecord = {
|
|
|
733
741
|
inConstituentIndex: number;
|
|
734
742
|
outOraclePrice: BN;
|
|
735
743
|
inOraclePrice: BN;
|
|
736
|
-
outMint: PublicKey;
|
|
737
|
-
inMint: PublicKey;
|
|
738
744
|
lastAum: BN;
|
|
739
745
|
lastAumSlot: BN;
|
|
740
746
|
inMarketCurrentWeight: BN;
|
|
@@ -756,7 +762,6 @@ export type LPMintRedeemRecord = {
|
|
|
756
762
|
constituentIndex: number;
|
|
757
763
|
oraclePrice: BN;
|
|
758
764
|
mint: PublicKey;
|
|
759
|
-
lpMint: PublicKey;
|
|
760
765
|
lpAmount: BN;
|
|
761
766
|
lpFee: BN;
|
|
762
767
|
lpPrice: BN;
|
|
@@ -796,6 +801,7 @@ export type LPBorrowLendDepositRecord = {
|
|
|
796
801
|
export type StateAccount = {
|
|
797
802
|
coldAdmin: PublicKey;
|
|
798
803
|
warmAdmin: PublicKey;
|
|
804
|
+
pauseAdmin: PublicKey;
|
|
799
805
|
hotAmmCrank: PublicKey;
|
|
800
806
|
hotLpCache: PublicKey;
|
|
801
807
|
hotLpSwap: PublicKey;
|
|
@@ -832,6 +838,7 @@ export type StateAccount = {
|
|
|
832
838
|
liquidationDuration: number;
|
|
833
839
|
maxInitializeUserFee: number;
|
|
834
840
|
featureBitFlags: number;
|
|
841
|
+
lpPoolFeatureBitFlags: number;
|
|
835
842
|
};
|
|
836
843
|
export type PerpMarketAccount = {
|
|
837
844
|
status: MarketStatus;
|
|
@@ -873,6 +880,7 @@ export type PerpMarketAccount = {
|
|
|
873
880
|
feeAdjustment: number;
|
|
874
881
|
pausedOperations: number;
|
|
875
882
|
lastFillPrice: BN;
|
|
883
|
+
poolId: number;
|
|
876
884
|
hedgeConfig: {
|
|
877
885
|
poolId: number;
|
|
878
886
|
status: number;
|
|
@@ -901,6 +909,8 @@ export type PerpMarketAccount = {
|
|
|
901
909
|
lastFundingRateShort: BN;
|
|
902
910
|
lastFundingRateTs: BN;
|
|
903
911
|
netUnsettledFundingPnl: BN;
|
|
912
|
+
fundingClampThreshold: number;
|
|
913
|
+
fundingRampSlope: number;
|
|
904
914
|
orderStepSize: BN;
|
|
905
915
|
orderTickSize: BN;
|
|
906
916
|
};
|
|
@@ -959,6 +969,7 @@ export type SpotMarketAccount = {
|
|
|
959
969
|
maxTokenDeposits: BN;
|
|
960
970
|
lastInterestTs: BN;
|
|
961
971
|
lastTwapTs: BN;
|
|
972
|
+
expiryTs: BN;
|
|
962
973
|
initialAssetWeight: number;
|
|
963
974
|
maintenanceAssetWeight: number;
|
|
964
975
|
initialLiabilityWeight: number;
|
|
@@ -1017,12 +1028,21 @@ export type AMM = {
|
|
|
1017
1028
|
totalMmFee: BN;
|
|
1018
1029
|
totalFeeMinusDistributions: BN;
|
|
1019
1030
|
totalFeeWithdrawn: BN;
|
|
1031
|
+
askBaseAssetReserve: BN;
|
|
1032
|
+
askQuoteAssetReserve: BN;
|
|
1033
|
+
bidBaseAssetReserve: BN;
|
|
1034
|
+
bidQuoteAssetReserve: BN;
|
|
1020
1035
|
lastUpdateSlot: BN;
|
|
1021
1036
|
netRevenueSinceLastFunding: BN;
|
|
1022
1037
|
lastCumulativeFundingRateLong: BN;
|
|
1023
1038
|
lastCumulativeFundingRateShort: BN;
|
|
1039
|
+
lastOracleReservePriceSpreadPct: BN;
|
|
1040
|
+
lastSpreadUpdateSlot: BN;
|
|
1024
1041
|
baseSpread: number;
|
|
1025
1042
|
maxSpread: number;
|
|
1043
|
+
longSpread: number;
|
|
1044
|
+
shortSpread: number;
|
|
1045
|
+
referencePriceOffset: number;
|
|
1026
1046
|
maxFillReserveFraction: number;
|
|
1027
1047
|
maxSlippageRatio: number;
|
|
1028
1048
|
curveUpdateIntensity: number;
|
|
@@ -1091,6 +1111,8 @@ export type UserStatsAccount = {
|
|
|
1091
1111
|
};
|
|
1092
1112
|
referrer: PublicKey;
|
|
1093
1113
|
referrerStatus: number;
|
|
1114
|
+
disableUpdatePerpBidAskTwap: number;
|
|
1115
|
+
pausedOperations: number;
|
|
1094
1116
|
authority: PublicKey;
|
|
1095
1117
|
ifStakedQuoteAssetAmount: BN;
|
|
1096
1118
|
delegatePermissions: number;
|
|
@@ -1373,8 +1395,8 @@ export type FeeTier = {
|
|
|
1373
1395
|
refereeFeeDenominator: number;
|
|
1374
1396
|
};
|
|
1375
1397
|
export type OrderFillerRewardStructure = {
|
|
1376
|
-
rewardNumerator:
|
|
1377
|
-
rewardDenominator:
|
|
1398
|
+
rewardNumerator: number;
|
|
1399
|
+
rewardDenominator: number;
|
|
1378
1400
|
timeBasedRewardLowerBound: BN;
|
|
1379
1401
|
};
|
|
1380
1402
|
export type OracleGuardRails = {
|
|
@@ -1407,6 +1429,22 @@ export type PrelaunchOracle = {
|
|
|
1407
1429
|
lastUpdateSlot: BN;
|
|
1408
1430
|
perpMarketIndex: number;
|
|
1409
1431
|
};
|
|
1432
|
+
export type PrelaunchOracleParams = {
|
|
1433
|
+
perpMarketIndex: number;
|
|
1434
|
+
price: BN | null;
|
|
1435
|
+
maxPrice: BN | null;
|
|
1436
|
+
};
|
|
1437
|
+
export type PythLazerOracle = {
|
|
1438
|
+
price: BN;
|
|
1439
|
+
publishTime: BN;
|
|
1440
|
+
postedSlot: BN;
|
|
1441
|
+
exponent: number;
|
|
1442
|
+
conf: BN;
|
|
1443
|
+
};
|
|
1444
|
+
export type UpdatePerpMarketSummaryStatsParams = {
|
|
1445
|
+
netUnsettledFundingPnl: BN | null;
|
|
1446
|
+
updateAmmSummaryStats: boolean | null;
|
|
1447
|
+
};
|
|
1410
1448
|
export type MarginCategory = 'Initial' | 'Maintenance';
|
|
1411
1449
|
export type InsuranceFundStake = {
|
|
1412
1450
|
costBasis: BN;
|
|
@@ -1414,6 +1452,7 @@ export type InsuranceFundStake = {
|
|
|
1414
1452
|
authority: PublicKey;
|
|
1415
1453
|
ifShares: BN;
|
|
1416
1454
|
ifBase: BN;
|
|
1455
|
+
lastValidTs: BN;
|
|
1417
1456
|
lastWithdrawRequestShares: BN;
|
|
1418
1457
|
lastWithdrawRequestValue: BN;
|
|
1419
1458
|
lastWithdrawRequestTs: BN;
|
|
@@ -1487,6 +1526,9 @@ export type SignedMsgUserOrdersAccount = {
|
|
|
1487
1526
|
authorityPubkey: PublicKey;
|
|
1488
1527
|
signedMsgOrderData: SignedMsgOrderId[];
|
|
1489
1528
|
};
|
|
1529
|
+
export type SignedMsgWsDelegatesAccount = {
|
|
1530
|
+
delegates: PublicKey[];
|
|
1531
|
+
};
|
|
1490
1532
|
export type RevenueShareAccount = {
|
|
1491
1533
|
authority: PublicKey;
|
|
1492
1534
|
totalReferrerRewards: BN;
|
|
@@ -1517,8 +1559,23 @@ export type BuilderInfo = {
|
|
|
1517
1559
|
maxFeeTenthBps: number;
|
|
1518
1560
|
padding: number[];
|
|
1519
1561
|
};
|
|
1562
|
+
export type PerpMarketFeeSweepRecord = {
|
|
1563
|
+
ts: BN;
|
|
1564
|
+
marketIndex: number;
|
|
1565
|
+
ifSwept: BN;
|
|
1566
|
+
protocolSwept: BN;
|
|
1567
|
+
ammProvisionTokenized: BN;
|
|
1568
|
+
};
|
|
1569
|
+
export type ProtocolFeeWithdrawRecord = {
|
|
1570
|
+
ts: BN;
|
|
1571
|
+
marketIndex: number;
|
|
1572
|
+
isPerp: boolean;
|
|
1573
|
+
spotMarketIndex: number;
|
|
1574
|
+
amount: BN;
|
|
1575
|
+
recipientTokenAccount: PublicKey;
|
|
1576
|
+
};
|
|
1520
1577
|
export type RevenueShareSettleRecord = {
|
|
1521
|
-
ts:
|
|
1578
|
+
ts: BN;
|
|
1522
1579
|
builder: PublicKey | null;
|
|
1523
1580
|
referrer: PublicKey | null;
|
|
1524
1581
|
feeSettled: BN;
|
|
@@ -1581,6 +1638,8 @@ export type LPPoolAccount = {
|
|
|
1581
1638
|
bump: number;
|
|
1582
1639
|
gammaExecution: number;
|
|
1583
1640
|
xi: number;
|
|
1641
|
+
targetOracleDelayFeeBpsPer10Slots: number;
|
|
1642
|
+
targetPositionDelayFeeBpsPer10Slots: number;
|
|
1584
1643
|
};
|
|
1585
1644
|
export type ConstituentSpotBalance = {
|
|
1586
1645
|
scaledBalance: BN;
|
|
@@ -1673,6 +1732,7 @@ export type CacheInfo = {
|
|
|
1673
1732
|
marketIndex: number;
|
|
1674
1733
|
};
|
|
1675
1734
|
export type AmmCache = {
|
|
1735
|
+
bump: number;
|
|
1676
1736
|
cache: CacheInfo[];
|
|
1677
1737
|
};
|
|
1678
1738
|
export type AccountLiquidatableStatus = {
|
|
@@ -1688,5 +1748,13 @@ export declare class TransferFeeAndPnlPoolDirection {
|
|
|
1688
1748
|
pnlToFeePool: {};
|
|
1689
1749
|
};
|
|
1690
1750
|
}
|
|
1751
|
+
export type TransferFeeAndPnlPoolRecord = {
|
|
1752
|
+
ts: BN;
|
|
1753
|
+
slot: BN;
|
|
1754
|
+
perpMarketIndexWithFeePool: number;
|
|
1755
|
+
perpMarketIndexWithPnlPool: number;
|
|
1756
|
+
direction: TransferFeeAndPnlPoolDirection;
|
|
1757
|
+
amount: BN;
|
|
1758
|
+
};
|
|
1691
1759
|
export {};
|
|
1692
1760
|
//# sourceMappingURL=types.d.ts.map
|