@sonarwatch/portfolio-plugins 0.12.37 → 0.12.39
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +1847 -1839
- package/README.md +3 -3
- package/package.json +1 -1
- package/src/plugins/balancer/helpers/pools.js +21 -21
- package/src/plugins/drift/constants.d.ts +1 -0
- package/src/plugins/drift/constants.js +2 -1
- package/src/plugins/drift/constants.js.map +1 -1
- package/src/plugins/drift/depositsFetcher.js +63 -1
- package/src/plugins/drift/depositsFetcher.js.map +1 -1
- package/src/plugins/drift/filters.d.ts +1 -0
- package/src/plugins/drift/filters.js +4 -1
- package/src/plugins/drift/filters.js.map +1 -1
- package/src/plugins/drift/index.js +2 -1
- package/src/plugins/drift/index.js.map +1 -1
- package/src/plugins/drift/perpHelpers/amm.d.ts +74 -0
- package/src/plugins/drift/perpHelpers/amm.js +567 -0
- package/src/plugins/drift/perpHelpers/amm.js.map +1 -0
- package/src/plugins/drift/perpHelpers/assert.d.ts +1 -0
- package/src/plugins/drift/perpHelpers/assert.js +10 -0
- package/src/plugins/drift/perpHelpers/assert.js.map +1 -0
- package/src/plugins/drift/perpHelpers/constants.d.ts +27 -0
- package/src/plugins/drift/perpHelpers/constants.js +35 -0
- package/src/plugins/drift/perpHelpers/constants.js.map +1 -0
- package/src/plugins/drift/perpHelpers/convert.d.ts +0 -0
- package/src/plugins/drift/perpHelpers/convert.js +2 -0
- package/src/plugins/drift/perpHelpers/convert.js.map +1 -0
- package/src/plugins/drift/perpHelpers/getOraclePrice.d.ts +4 -0
- package/src/plugins/drift/perpHelpers/getOraclePrice.js +61 -0
- package/src/plugins/drift/perpHelpers/getOraclePrice.js.map +1 -0
- package/src/plugins/drift/perpHelpers/getPerpMarket.d.ts +4 -0
- package/src/plugins/drift/perpHelpers/getPerpMarket.js +33 -0
- package/src/plugins/drift/perpHelpers/getPerpMarket.js.map +1 -0
- package/src/plugins/drift/perpHelpers/margin.d.ts +10 -0
- package/src/plugins/drift/perpHelpers/margin.js +82 -0
- package/src/plugins/drift/perpHelpers/margin.js.map +1 -0
- package/src/plugins/drift/perpHelpers/math.d.ts +4 -0
- package/src/plugins/drift/perpHelpers/math.js +29 -0
- package/src/plugins/drift/perpHelpers/math.js.map +1 -0
- package/src/plugins/drift/perpHelpers/oracle.d.ts +6 -0
- package/src/plugins/drift/perpHelpers/oracle.js +54 -0
- package/src/plugins/drift/perpHelpers/oracle.js.map +1 -0
- package/src/plugins/drift/perpHelpers/orders.d.ts +2 -0
- package/src/plugins/drift/perpHelpers/orders.js +9 -0
- package/src/plugins/drift/perpHelpers/orders.js.map +1 -0
- package/src/plugins/drift/perpHelpers/position.d.ts +44 -0
- package/src/plugins/drift/perpHelpers/position.js +184 -0
- package/src/plugins/drift/perpHelpers/position.js.map +1 -0
- package/src/plugins/drift/perpHelpers/prelaunchOracle.d.ts +3 -0
- package/src/plugins/drift/perpHelpers/prelaunchOracle.js +20 -0
- package/src/plugins/drift/perpHelpers/prelaunchOracle.js.map +1 -0
- package/src/plugins/drift/perpHelpers/pyth.d.ts +5 -0
- package/src/plugins/drift/perpHelpers/pyth.js +42 -0
- package/src/plugins/drift/perpHelpers/pyth.js.map +1 -0
- package/src/plugins/drift/perpHelpers/repeg.d.ts +14 -0
- package/src/plugins/drift/perpHelpers/repeg.js +162 -0
- package/src/plugins/drift/perpHelpers/repeg.js.map +1 -0
- package/src/plugins/drift/perpHelpers/switchboard.d.ts +3 -0
- package/src/plugins/drift/perpHelpers/switchboard.js +31 -0
- package/src/plugins/drift/perpHelpers/switchboard.js.map +1 -0
- package/src/plugins/drift/perpHelpers/types.d.ts +28 -0
- package/src/plugins/drift/perpHelpers/types.js +19 -0
- package/src/plugins/drift/perpHelpers/types.js.map +1 -0
- package/src/plugins/drift/prepMarketsJob.d.ts +3 -0
- package/src/plugins/drift/prepMarketsJob.js +38 -0
- package/src/plugins/drift/prepMarketsJob.js.map +1 -0
- package/src/plugins/drift/struct.d.ts +82 -76
- package/src/plugins/drift/struct.js +79 -74
- package/src/plugins/drift/struct.js.map +1 -1
- package/src/plugins/drift/types.d.ts +1 -0
- package/src/plugins/jupiter/exchange/perpetualFetcher.js +3 -6
- package/src/plugins/jupiter/exchange/perpetualFetcher.js.map +1 -1
- package/src/plugins/jupiter/exchange/valueAverageFetcher.js.map +1 -1
- package/src/plugins/jupiter/helpers.d.ts +2 -2
- package/src/plugins/jupiter/helpers.js.map +1 -1
- package/src/plugins/sushiswap/helpers.js +24 -24
- package/src/plugins/uniswap-v2/helpers.js +22 -22
- package/src/plugins/zeta/airdropFetcher.js +14 -14
- package/src/utils/sei/constants.js +8 -8
- package/src/utils/sei/getQueryBalanceByOwner.js +4 -4
@@ -0,0 +1,184 @@
|
|
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.hasOpenOrders = exports.isEmptyPosition = exports.positionCurrentDirection = exports.findDirectionToClose = exports.calculateCostBasis = exports.calculateEntryPrice = exports.calculateBreakEvenPrice = exports.positionIsAvailable = exports.calculatePositionFundingPNL = exports.calculatePositionPNL = exports.calculateBaseAssetValue = void 0;
|
7
|
+
const bn_js_1 = __importDefault(require("bn.js"));
|
8
|
+
const constants_1 = require("./constants");
|
9
|
+
const types_1 = require("./types");
|
10
|
+
const amm_1 = require("./amm");
|
11
|
+
const margin_1 = require("./margin");
|
12
|
+
function calculateBaseAssetValue(market, userPosition, oraclePriceData, useSpread = true, skipUpdate = false) {
|
13
|
+
if (userPosition.baseAssetAmount.eq(constants_1.ZERO)) {
|
14
|
+
return constants_1.ZERO;
|
15
|
+
}
|
16
|
+
const directionToClose = findDirectionToClose(userPosition);
|
17
|
+
let prepegAmm;
|
18
|
+
if (!skipUpdate) {
|
19
|
+
if (market.amm.baseSpread > 0 && useSpread) {
|
20
|
+
const { baseAssetReserve, quoteAssetReserve, sqrtK, newPeg } = (0, amm_1.calculateUpdatedAMMSpreadReserves)(market.amm, directionToClose, oraclePriceData);
|
21
|
+
prepegAmm = {
|
22
|
+
baseAssetReserve,
|
23
|
+
quoteAssetReserve,
|
24
|
+
sqrtK,
|
25
|
+
pegMultiplier: newPeg,
|
26
|
+
};
|
27
|
+
}
|
28
|
+
else {
|
29
|
+
prepegAmm = (0, amm_1.calculateUpdatedAMM)(market.amm, oraclePriceData);
|
30
|
+
}
|
31
|
+
}
|
32
|
+
else {
|
33
|
+
prepegAmm = market.amm;
|
34
|
+
}
|
35
|
+
const [newQuoteAssetReserve] = (0, amm_1.calculateAmmReservesAfterSwap)(prepegAmm, 'base', userPosition.baseAssetAmount.abs(), (0, amm_1.getSwapDirection)('base', directionToClose));
|
36
|
+
switch (directionToClose) {
|
37
|
+
case types_1.PositionDirection.SHORT:
|
38
|
+
return prepegAmm.quoteAssetReserve
|
39
|
+
.sub(newQuoteAssetReserve)
|
40
|
+
.mul(prepegAmm.pegMultiplier)
|
41
|
+
.div(constants_1.AMM_TIMES_PEG_TO_QUOTE_PRECISION_RATIO);
|
42
|
+
case types_1.PositionDirection.LONG:
|
43
|
+
return newQuoteAssetReserve
|
44
|
+
.sub(prepegAmm.quoteAssetReserve)
|
45
|
+
.mul(prepegAmm.pegMultiplier)
|
46
|
+
.div(constants_1.AMM_TIMES_PEG_TO_QUOTE_PRECISION_RATIO)
|
47
|
+
.add(constants_1.ONE);
|
48
|
+
default:
|
49
|
+
throw new Error('Failed to calculateBaseAssetValue');
|
50
|
+
}
|
51
|
+
}
|
52
|
+
exports.calculateBaseAssetValue = calculateBaseAssetValue;
|
53
|
+
/**
|
54
|
+
* calculatePositionPNL
|
55
|
+
* = BaseAssetAmount * (Avg Exit Price - Avg Entry Price)
|
56
|
+
* @param market
|
57
|
+
* @param PerpPosition
|
58
|
+
* @param withFunding (adds unrealized funding payment pnl to result)
|
59
|
+
* @param oraclePriceData
|
60
|
+
* @returns BaseAssetAmount : Precision QUOTE_PRECISION
|
61
|
+
*/
|
62
|
+
function calculatePositionPNL(market, perpPosition, oraclePriceData, withFunding = false) {
|
63
|
+
if (perpPosition.baseAssetAmount.eq(constants_1.ZERO)) {
|
64
|
+
return perpPosition.quoteAssetAmount;
|
65
|
+
}
|
66
|
+
const baseAssetValue = (0, margin_1.calculateBaseAssetValueWithOracle)(market, perpPosition, oraclePriceData);
|
67
|
+
const baseAssetValueSign = perpPosition.baseAssetAmount.isNeg()
|
68
|
+
? new bn_js_1.default(-1)
|
69
|
+
: new bn_js_1.default(1);
|
70
|
+
let pnl = baseAssetValue
|
71
|
+
.mul(baseAssetValueSign)
|
72
|
+
.add(perpPosition.quoteAssetAmount);
|
73
|
+
if (withFunding) {
|
74
|
+
const fundingRatePnL = calculatePositionFundingPNL(market, perpPosition);
|
75
|
+
pnl = pnl.add(fundingRatePnL);
|
76
|
+
}
|
77
|
+
return pnl;
|
78
|
+
}
|
79
|
+
exports.calculatePositionPNL = calculatePositionPNL;
|
80
|
+
/**
|
81
|
+
*
|
82
|
+
* @param market
|
83
|
+
* @param PerpPosition
|
84
|
+
* @returns // QUOTE_PRECISION
|
85
|
+
*/
|
86
|
+
function calculatePositionFundingPNL(market, perpPosition) {
|
87
|
+
if (perpPosition.baseAssetAmount.eq(constants_1.ZERO)) {
|
88
|
+
return constants_1.ZERO;
|
89
|
+
}
|
90
|
+
let ammCumulativeFundingRate;
|
91
|
+
if (perpPosition.baseAssetAmount.gt(constants_1.ZERO)) {
|
92
|
+
ammCumulativeFundingRate = market.amm.cumulativeFundingRateLong;
|
93
|
+
}
|
94
|
+
else {
|
95
|
+
ammCumulativeFundingRate = market.amm.cumulativeFundingRateShort;
|
96
|
+
}
|
97
|
+
const perPositionFundingRate = ammCumulativeFundingRate
|
98
|
+
.sub(perpPosition.lastCumulativeFundingRate)
|
99
|
+
.mul(perpPosition.baseAssetAmount)
|
100
|
+
.div(constants_1.AMM_RESERVE_PRECISION)
|
101
|
+
.div(constants_1.FUNDING_RATE_BUFFER_PRECISION)
|
102
|
+
.mul(new bn_js_1.default(-1));
|
103
|
+
return perPositionFundingRate;
|
104
|
+
}
|
105
|
+
exports.calculatePositionFundingPNL = calculatePositionFundingPNL;
|
106
|
+
function positionIsAvailable(position) {
|
107
|
+
return (position.baseAssetAmount.eq(constants_1.ZERO) &&
|
108
|
+
position.openOrders === 0 &&
|
109
|
+
position.quoteAssetAmount.eq(constants_1.ZERO) &&
|
110
|
+
position.lpShares.eq(constants_1.ZERO));
|
111
|
+
}
|
112
|
+
exports.positionIsAvailable = positionIsAvailable;
|
113
|
+
/**
|
114
|
+
*
|
115
|
+
* @param userPosition
|
116
|
+
* @returns Precision: PRICE_PRECISION (10^6)
|
117
|
+
*/
|
118
|
+
function calculateBreakEvenPrice(userPosition) {
|
119
|
+
if (userPosition.baseAssetAmount.eq(constants_1.ZERO)) {
|
120
|
+
return constants_1.ZERO;
|
121
|
+
}
|
122
|
+
return userPosition.quoteBreakEvenAmount
|
123
|
+
.mul(constants_1.PRICE_PRECISION)
|
124
|
+
.mul(constants_1.AMM_TO_QUOTE_PRECISION_RATIO)
|
125
|
+
.div(userPosition.baseAssetAmount)
|
126
|
+
.abs();
|
127
|
+
}
|
128
|
+
exports.calculateBreakEvenPrice = calculateBreakEvenPrice;
|
129
|
+
/**
|
130
|
+
*
|
131
|
+
* @param userPosition
|
132
|
+
* @returns Precision: PRICE_PRECISION (10^6)
|
133
|
+
*/
|
134
|
+
function calculateEntryPrice(userPosition) {
|
135
|
+
if (userPosition.baseAssetAmount.eq(constants_1.ZERO)) {
|
136
|
+
return constants_1.ZERO;
|
137
|
+
}
|
138
|
+
return userPosition.quoteEntryAmount
|
139
|
+
.mul(constants_1.PRICE_PRECISION)
|
140
|
+
.mul(constants_1.AMM_TO_QUOTE_PRECISION_RATIO)
|
141
|
+
.div(userPosition.baseAssetAmount)
|
142
|
+
.abs();
|
143
|
+
}
|
144
|
+
exports.calculateEntryPrice = calculateEntryPrice;
|
145
|
+
/**
|
146
|
+
*
|
147
|
+
* @param userPosition
|
148
|
+
* @returns Precision: PRICE_PRECISION (10^10)
|
149
|
+
*/
|
150
|
+
function calculateCostBasis(userPosition, includeSettledPnl = false) {
|
151
|
+
if (userPosition.baseAssetAmount.eq(constants_1.ZERO)) {
|
152
|
+
return constants_1.ZERO;
|
153
|
+
}
|
154
|
+
return userPosition.quoteAssetAmount
|
155
|
+
.add(includeSettledPnl ? userPosition.settledPnl : constants_1.ZERO)
|
156
|
+
.mul(constants_1.PRICE_PRECISION)
|
157
|
+
.mul(constants_1.AMM_TO_QUOTE_PRECISION_RATIO)
|
158
|
+
.div(userPosition.baseAssetAmount)
|
159
|
+
.abs();
|
160
|
+
}
|
161
|
+
exports.calculateCostBasis = calculateCostBasis;
|
162
|
+
function findDirectionToClose(userPosition) {
|
163
|
+
return userPosition.baseAssetAmount.gt(constants_1.ZERO)
|
164
|
+
? types_1.PositionDirection.SHORT
|
165
|
+
: types_1.PositionDirection.LONG;
|
166
|
+
}
|
167
|
+
exports.findDirectionToClose = findDirectionToClose;
|
168
|
+
function positionCurrentDirection(userPosition) {
|
169
|
+
return userPosition.baseAssetAmount.gte(constants_1.ZERO)
|
170
|
+
? types_1.PositionDirection.LONG
|
171
|
+
: types_1.PositionDirection.SHORT;
|
172
|
+
}
|
173
|
+
exports.positionCurrentDirection = positionCurrentDirection;
|
174
|
+
function isEmptyPosition(userPosition) {
|
175
|
+
return userPosition.baseAssetAmount.eq(constants_1.ZERO) && userPosition.openOrders === 0;
|
176
|
+
}
|
177
|
+
exports.isEmptyPosition = isEmptyPosition;
|
178
|
+
function hasOpenOrders(position) {
|
179
|
+
return (position.openOrders !== 0 ||
|
180
|
+
!position.openBids.eq(constants_1.ZERO) ||
|
181
|
+
!position.openAsks.eq(constants_1.ZERO));
|
182
|
+
}
|
183
|
+
exports.hasOpenOrders = hasOpenOrders;
|
184
|
+
//# sourceMappingURL=position.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"position.js","sourceRoot":"","sources":["../../../../../../../packages/plugins/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AwB,CACtC,YAA0B;IAE1B,OAAO,YAAY,CAAC,eAAe,CAAC,GAAG,CAAC,gBAAI,CAAC;QAC3C,CAAC,CAAC,yBAAiB,CAAC,IAAI;QACxB,CAAC,CAAC,yBAAiB,CAAC,KAAK,CAAC;AAC9B,CAAC;AAND,4DAMC;AAED,SAAgB,eAAe,CAAC,YAA0B;IACxD,OAAO,YAAY,CAAC,eAAe,CAAC,EAAE,CAAC,gBAAI,CAAC,IAAI,YAAY,CAAC,UAAU,KAAK,CAAC,CAAC;AAChF,CAAC;AAFD,0CAEC;AAED,SAAgB,aAAa,CAAC,QAAsB;IAClD,OAAO,CACL,QAAQ,CAAC,UAAU,KAAK,CAAC;QACzB,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC,gBAAI,CAAC;QAC3B,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC,gBAAI,CAAC,CAC5B,CAAC;AACJ,CAAC;AAND,sCAMC"}
|
@@ -0,0 +1,20 @@
|
|
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.getPreLaunchOraclePriceDataFromBuffer = void 0;
|
7
|
+
const bn_js_1 = __importDefault(require("bn.js"));
|
8
|
+
const struct_1 = require("../struct");
|
9
|
+
function getPreLaunchOraclePriceDataFromBuffer(buffer) {
|
10
|
+
const [prelaunchOracle] = struct_1.preLaunchOracleStruct.deserialize(buffer);
|
11
|
+
return {
|
12
|
+
price: new bn_js_1.default(prelaunchOracle.price.toString(10), 10),
|
13
|
+
slot: new bn_js_1.default(prelaunchOracle.ammLastUpdateSlot.toString(10), 10),
|
14
|
+
confidence: new bn_js_1.default(prelaunchOracle.confidence.toString(10), 10),
|
15
|
+
hasSufficientNumberOfDataPoints: true,
|
16
|
+
maxPrice: new bn_js_1.default(prelaunchOracle.maxPrice.toString(10), 10),
|
17
|
+
};
|
18
|
+
}
|
19
|
+
exports.getPreLaunchOraclePriceDataFromBuffer = getPreLaunchOraclePriceDataFromBuffer;
|
20
|
+
//# sourceMappingURL=prelaunchOracle.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"prelaunchOracle.js","sourceRoot":"","sources":["../../../../../../../packages/plugins/src/plugins/drift/perpHelpers/prelaunchOracle.ts"],"names":[],"mappings":";;;;;;AAAA,kDAAuB;AAEvB,sCAAkD;AAElD,SAAgB,qCAAqC,CACnD,MAAc;IAEd,MAAM,CAAC,eAAe,CAAC,GAAG,8BAAqB,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;IAEpE,OAAO;QACL,KAAK,EAAE,IAAI,eAAE,CAAC,eAAe,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QACrD,IAAI,EAAE,IAAI,eAAE,CAAC,eAAe,CAAC,iBAAiB,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QAChE,UAAU,EAAE,IAAI,eAAE,CAAC,eAAe,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QAC/D,+BAA+B,EAAE,IAAI;QACrC,QAAQ,EAAE,IAAI,eAAE,CAAC,eAAe,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;KAC5D,CAAC;AACJ,CAAC;AAZD,sFAYC"}
|
@@ -0,0 +1,5 @@
|
|
1
|
+
/// <reference types="node" />
|
2
|
+
import BN from 'bn.js';
|
3
|
+
import { OraclePriceData } from './types';
|
4
|
+
export declare function getPythOraclePriceDataFromBuffer(buffer: Buffer, multiple: BN, stableCoin: boolean): OraclePriceData;
|
5
|
+
export declare function convertPythPrice(price: number, exponent: number, multiple: BN): BN;
|
@@ -0,0 +1,42 @@
|
|
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.convertPythPrice = exports.getPythOraclePriceDataFromBuffer = void 0;
|
7
|
+
/* eslint-disable no-param-reassign */
|
8
|
+
const bn_js_1 = __importDefault(require("bn.js"));
|
9
|
+
const helpers_1 = require("../../../utils/solana/pyth/helpers");
|
10
|
+
const constants_1 = require("./constants");
|
11
|
+
function getPythOraclePriceDataFromBuffer(buffer, multiple, stableCoin) {
|
12
|
+
const priceData = (0, helpers_1.parsePriceData)(buffer);
|
13
|
+
const confidence = convertPythPrice(priceData.confidence || 0, priceData.exponent, multiple);
|
14
|
+
const minPublishers = Math.min(priceData.numComponentPrices, 3);
|
15
|
+
let price = convertPythPrice(priceData.aggregate.price, priceData.exponent, multiple);
|
16
|
+
if (stableCoin) {
|
17
|
+
price = getStableCoinPrice(price, confidence);
|
18
|
+
}
|
19
|
+
return {
|
20
|
+
price,
|
21
|
+
slot: new bn_js_1.default(priceData.lastSlot.toString()),
|
22
|
+
confidence,
|
23
|
+
twap: convertPythPrice(priceData.emaPrice.value, priceData.exponent, multiple),
|
24
|
+
twapConfidence: convertPythPrice(priceData.emaConfidence.value, priceData.exponent, multiple),
|
25
|
+
hasSufficientNumberOfDataPoints: priceData.numQuoters >= minPublishers,
|
26
|
+
};
|
27
|
+
}
|
28
|
+
exports.getPythOraclePriceDataFromBuffer = getPythOraclePriceDataFromBuffer;
|
29
|
+
function convertPythPrice(price, exponent, multiple) {
|
30
|
+
exponent = Math.abs(exponent);
|
31
|
+
const pythPrecision = constants_1.TEN.pow(new bn_js_1.default(exponent).abs()).div(multiple);
|
32
|
+
return new bn_js_1.default(price * Math.pow(10, exponent)).mul(constants_1.PRICE_PRECISION).div(pythPrecision);
|
33
|
+
}
|
34
|
+
exports.convertPythPrice = convertPythPrice;
|
35
|
+
const fiveBPS = new bn_js_1.default(500);
|
36
|
+
function getStableCoinPrice(price, confidence) {
|
37
|
+
if (price.sub(constants_1.QUOTE_PRECISION).abs().lt(bn_js_1.default.min(confidence, fiveBPS))) {
|
38
|
+
return constants_1.QUOTE_PRECISION;
|
39
|
+
}
|
40
|
+
return price;
|
41
|
+
}
|
42
|
+
//# sourceMappingURL=pyth.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"pyth.js","sourceRoot":"","sources":["../../../../../../../packages/plugins/src/plugins/drift/perpHelpers/pyth.ts"],"names":[],"mappings":";;;;;;AAAA,sCAAsC;AACtC,kDAAuB;AACvB,gEAAoE;AACpE,2CAAoE;AAGpE,SAAgB,gCAAgC,CAC9C,MAAc,EACd,QAAY,EACZ,UAAmB;IAEnB,MAAM,SAAS,GAAG,IAAA,wBAAc,EAAC,MAAM,CAAC,CAAC;IACzC,MAAM,UAAU,GAAG,gBAAgB,CACjC,SAAS,CAAC,UAAU,IAAI,CAAC,EACzB,SAAS,CAAC,QAAQ,EAClB,QAAQ,CACT,CAAC;IACF,MAAM,aAAa,GAAG,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,kBAAkB,EAAE,CAAC,CAAC,CAAC;IAChE,IAAI,KAAK,GAAG,gBAAgB,CAC1B,SAAS,CAAC,SAAS,CAAC,KAAK,EACzB,SAAS,CAAC,QAAQ,EAClB,QAAQ,CACT,CAAC;IACF,IAAI,UAAU,EAAE,CAAC;QACf,KAAK,GAAG,kBAAkB,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;IAChD,CAAC;IAED,OAAO;QACL,KAAK;QACL,IAAI,EAAE,IAAI,eAAE,CAAC,SAAS,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC;QAC3C,UAAU;QACV,IAAI,EAAE,gBAAgB,CACpB,SAAS,CAAC,QAAQ,CAAC,KAAK,EACxB,SAAS,CAAC,QAAQ,EAClB,QAAQ,CACT;QACD,cAAc,EAAE,gBAAgB,CAC9B,SAAS,CAAC,aAAa,CAAC,KAAK,EAC7B,SAAS,CAAC,QAAQ,EAClB,QAAQ,CACT;QACD,+BAA+B,EAAE,SAAS,CAAC,UAAU,IAAI,aAAa;KACvE,CAAC;AACJ,CAAC;AArCD,4EAqCC;AAED,SAAgB,gBAAgB,CAC9B,KAAa,EACb,QAAgB,EAChB,QAAY;IAEZ,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IAC9B,MAAM,aAAa,GAAG,eAAG,CAAC,GAAG,CAAC,IAAI,eAAE,CAAC,QAAQ,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IACpE,OAAO,IAAI,eAAE,CAAC,KAAK,GAAG,SAAA,EAAE,EAAI,QAAQ,CAAA,CAAC,CAAC,GAAG,CAAC,2BAAe,CAAC,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;AAChF,CAAC;AARD,4CAQC;AAED,MAAM,OAAO,GAAG,IAAI,eAAE,CAAC,GAAG,CAAC,CAAC;AAC5B,SAAS,kBAAkB,CAAC,KAAS,EAAE,UAAc;IACnD,IAAI,KAAK,CAAC,GAAG,CAAC,2BAAe,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,eAAE,CAAC,GAAG,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC,EAAE,CAAC;QACrE,OAAO,2BAAe,CAAC;IACzB,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
@@ -0,0 +1,14 @@
|
|
1
|
+
import BN from 'bn.js';
|
2
|
+
import { AMM } from '../struct';
|
3
|
+
export declare function calculateAdjustKCost(amm: AMM, numerator: BN, denomenator: BN): BN;
|
4
|
+
/**
|
5
|
+
* Helper function calculating adjust pegMultiplier (repeg) cost
|
6
|
+
*
|
7
|
+
* @param amm
|
8
|
+
* @param newPeg
|
9
|
+
* @returns cost : Precision QUOTE_ASSET_PRECISION
|
10
|
+
*/
|
11
|
+
export declare function calculateRepegCost(amm: AMM, newPeg: BN): BN;
|
12
|
+
export declare function calculateBudgetedKBN(x: BN, y: BN, budget: BN, Q: BN, d: BN): [BN, BN];
|
13
|
+
export declare function calculateBudgetedK(amm: AMM, cost: BN): [BN, BN];
|
14
|
+
export declare function calculateBudgetedPeg(amm: AMM, budget: BN, targetPrice: BN): BN;
|
@@ -0,0 +1,162 @@
|
|
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.calculateBudgetedPeg = exports.calculateBudgetedK = exports.calculateBudgetedKBN = exports.calculateRepegCost = exports.calculateAdjustKCost = void 0;
|
7
|
+
/* eslint-disable @typescript-eslint/naming-convention */
|
8
|
+
const bn_js_1 = __importDefault(require("bn.js"));
|
9
|
+
const constants_1 = require("./constants");
|
10
|
+
const assert_1 = require("./assert");
|
11
|
+
function calculateAdjustKCost(amm, numerator, denomenator) {
|
12
|
+
// const k = market.amm.sqrtK.mul(market.amm.sqrtK);
|
13
|
+
const x = amm.baseAssetReserve;
|
14
|
+
const y = amm.quoteAssetReserve;
|
15
|
+
const d = amm.baseAssetAmountWithAmm;
|
16
|
+
const Q = amm.pegMultiplier;
|
17
|
+
const quoteScale = y.mul(d).mul(Q); // .div(AMM_RESERVE_PRECISION);
|
18
|
+
const p = numerator.mul(constants_1.PRICE_PRECISION).div(denomenator);
|
19
|
+
const cost = quoteScale
|
20
|
+
.mul(constants_1.PERCENTAGE_PRECISION)
|
21
|
+
.mul(constants_1.PERCENTAGE_PRECISION)
|
22
|
+
.div(x.add(d))
|
23
|
+
.sub(quoteScale
|
24
|
+
.mul(p)
|
25
|
+
.mul(constants_1.PERCENTAGE_PRECISION)
|
26
|
+
.mul(constants_1.PERCENTAGE_PRECISION)
|
27
|
+
.div(constants_1.PRICE_PRECISION)
|
28
|
+
.div(x.mul(p).div(constants_1.PRICE_PRECISION).add(d)))
|
29
|
+
.div(constants_1.PERCENTAGE_PRECISION)
|
30
|
+
.div(constants_1.PERCENTAGE_PRECISION)
|
31
|
+
.div(constants_1.AMM_TO_QUOTE_PRECISION_RATIO)
|
32
|
+
.div(constants_1.PEG_PRECISION);
|
33
|
+
return cost.mul(new bn_js_1.default(-1));
|
34
|
+
}
|
35
|
+
exports.calculateAdjustKCost = calculateAdjustKCost;
|
36
|
+
// /**
|
37
|
+
// * Helper function calculating adjust k cost
|
38
|
+
// * @param amm
|
39
|
+
// * @param numerator
|
40
|
+
// * @param denomenator
|
41
|
+
// * @returns cost : Precision QUOTE_ASSET_PRECISION
|
42
|
+
// */
|
43
|
+
// export function calculateAdjustKCost2(
|
44
|
+
// amm: AMM,
|
45
|
+
// numerator: BN,
|
46
|
+
// denomenator: BN
|
47
|
+
// ): BN {
|
48
|
+
// // const k = market.amm.sqrtK.mul(market.amm.sqrtK);
|
49
|
+
// const directionToClose = amm.baseAssetAmountWithAmm.gt(ZERO)
|
50
|
+
// ? PositionDirection.SHORT
|
51
|
+
// : PositionDirection.LONG;
|
52
|
+
// const [newQuoteAssetReserve, _newBaseAssetReserve] =
|
53
|
+
// calculateAmmReservesAfterSwap(
|
54
|
+
// amm,
|
55
|
+
// 'base',
|
56
|
+
// amm.baseAssetAmountWithAmm.abs(),
|
57
|
+
// getSwapDirection('base', directionToClose)
|
58
|
+
// );
|
59
|
+
// }
|
60
|
+
/**
|
61
|
+
* Helper function calculating adjust pegMultiplier (repeg) cost
|
62
|
+
*
|
63
|
+
* @param amm
|
64
|
+
* @param newPeg
|
65
|
+
* @returns cost : Precision QUOTE_ASSET_PRECISION
|
66
|
+
*/
|
67
|
+
function calculateRepegCost(amm, newPeg) {
|
68
|
+
const dqar = amm.quoteAssetReserve.sub(amm.terminalQuoteAssetReserve);
|
69
|
+
const cost = dqar
|
70
|
+
.mul(newPeg.sub(amm.pegMultiplier))
|
71
|
+
.div(constants_1.AMM_TO_QUOTE_PRECISION_RATIO)
|
72
|
+
.div(constants_1.PEG_PRECISION);
|
73
|
+
return cost;
|
74
|
+
}
|
75
|
+
exports.calculateRepegCost = calculateRepegCost;
|
76
|
+
function calculateBudgetedKBN(x, y, budget, Q, d) {
|
77
|
+
(0, assert_1.assert)(Q.gt(new bn_js_1.default(0)));
|
78
|
+
const C = budget.mul(new bn_js_1.default(-1));
|
79
|
+
let dSign = new bn_js_1.default(1);
|
80
|
+
if (d.lt(new bn_js_1.default(0))) {
|
81
|
+
dSign = new bn_js_1.default(-1);
|
82
|
+
}
|
83
|
+
const pegged_y_d_d = y
|
84
|
+
.mul(d)
|
85
|
+
.mul(d)
|
86
|
+
.mul(Q)
|
87
|
+
.div(constants_1.AMM_RESERVE_PRECISION)
|
88
|
+
.div(constants_1.AMM_RESERVE_PRECISION)
|
89
|
+
.div(constants_1.PEG_PRECISION);
|
90
|
+
const numer1 = pegged_y_d_d;
|
91
|
+
const numer2 = C.mul(d)
|
92
|
+
.div(constants_1.QUOTE_PRECISION)
|
93
|
+
.mul(x.add(d))
|
94
|
+
.div(constants_1.AMM_RESERVE_PRECISION)
|
95
|
+
.mul(dSign);
|
96
|
+
const denom1 = C.mul(x)
|
97
|
+
.mul(x.add(d))
|
98
|
+
.div(constants_1.AMM_RESERVE_PRECISION)
|
99
|
+
.div(constants_1.QUOTE_PRECISION);
|
100
|
+
const denom2 = pegged_y_d_d;
|
101
|
+
// protocol is spending to increase k
|
102
|
+
if (C.lt(constants_1.ZERO)) {
|
103
|
+
// thus denom1 is negative and solution is unstable
|
104
|
+
if (denom1.abs().gt(denom2.abs())) {
|
105
|
+
// console.log('denom1 > denom2', denom1.toString(), denom2.toString());
|
106
|
+
// console.log('budget cost exceeds stable K solution');
|
107
|
+
return [new bn_js_1.default(10000), new bn_js_1.default(1)];
|
108
|
+
}
|
109
|
+
}
|
110
|
+
const numerator = numer1.sub(numer2).div(constants_1.AMM_TO_QUOTE_PRECISION_RATIO);
|
111
|
+
const denominator = denom1.add(denom2).div(constants_1.AMM_TO_QUOTE_PRECISION_RATIO);
|
112
|
+
return [numerator, denominator];
|
113
|
+
}
|
114
|
+
exports.calculateBudgetedKBN = calculateBudgetedKBN;
|
115
|
+
function calculateBudgetedK(amm, cost) {
|
116
|
+
// wolframalpha.com
|
117
|
+
// (1/(x+d) - p/(x*p+d))*y*d*Q = C solve for p
|
118
|
+
// p = (d(y*d*Q - C(x+d))) / (C*x(x+d) + y*d*d*Q)
|
119
|
+
// numer
|
120
|
+
// = y*d*d*Q - Cxd - Cdd
|
121
|
+
// = y/x*Q*d*d - Cd - Cd/x
|
122
|
+
// = mark - C/d - C/(x)
|
123
|
+
// = mark/C - 1/d - 1/x
|
124
|
+
// denom
|
125
|
+
// = C*x*x + C*x*d + y*d*d*Q
|
126
|
+
// = x/d**2 + 1 / d + mark/C
|
127
|
+
// todo: assumes k = x * y
|
128
|
+
// otherwise use: (y(1-p) + (kp^2/(x*p+d)) - k/(x+d)) * Q = C solve for p
|
129
|
+
const x = amm.baseAssetReserve;
|
130
|
+
const y = amm.quoteAssetReserve;
|
131
|
+
const d = amm.baseAssetAmountWithAmm;
|
132
|
+
const Q = amm.pegMultiplier;
|
133
|
+
const [numerator, denominator] = calculateBudgetedKBN(x, y, cost, Q, d);
|
134
|
+
return [numerator, denominator];
|
135
|
+
}
|
136
|
+
exports.calculateBudgetedK = calculateBudgetedK;
|
137
|
+
function calculateBudgetedPeg(amm, budget, targetPrice) {
|
138
|
+
let perPegCost = amm.quoteAssetReserve
|
139
|
+
.sub(amm.terminalQuoteAssetReserve)
|
140
|
+
.div(constants_1.AMM_RESERVE_PRECISION.div(constants_1.PRICE_PRECISION));
|
141
|
+
if (perPegCost.gt(constants_1.ZERO)) {
|
142
|
+
perPegCost = perPegCost.add(constants_1.ONE);
|
143
|
+
}
|
144
|
+
else if (perPegCost.lt(constants_1.ZERO)) {
|
145
|
+
perPegCost = perPegCost.sub(constants_1.ONE);
|
146
|
+
}
|
147
|
+
const targetPeg = targetPrice
|
148
|
+
.mul(amm.baseAssetReserve)
|
149
|
+
.div(amm.quoteAssetReserve)
|
150
|
+
.div(constants_1.PRICE_DIV_PEG);
|
151
|
+
const pegChangeDirection = targetPeg.sub(amm.pegMultiplier);
|
152
|
+
const useTargetPeg = (perPegCost.lt(constants_1.ZERO) && pegChangeDirection.gt(constants_1.ZERO)) ||
|
153
|
+
(perPegCost.gt(constants_1.ZERO) && pegChangeDirection.lt(constants_1.ZERO));
|
154
|
+
if (perPegCost.eq(constants_1.ZERO) || useTargetPeg) {
|
155
|
+
return targetPeg;
|
156
|
+
}
|
157
|
+
const budgetDeltaPeg = budget.mul(constants_1.PEG_PRECISION).div(perPegCost);
|
158
|
+
const newPeg = bn_js_1.default.max(constants_1.ONE, amm.pegMultiplier.add(budgetDeltaPeg));
|
159
|
+
return newPeg;
|
160
|
+
}
|
161
|
+
exports.calculateBudgetedPeg = calculateBudgetedPeg;
|
162
|
+
//# sourceMappingURL=repeg.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"repeg.js","sourceRoot":"","sources":["../../../../../../../packages/plugins/src/plugins/drift/perpHelpers/repeg.ts"],"names":[],"mappings":";;;;;;AAAA,yDAAyD;AACzD,kDAAuB;AACvB,2CAUqB;AAErB,qCAAkC;AAElC,SAAgB,oBAAoB,CAClC,GAAQ,EACR,SAAa,EACb,WAAe;IAEf,oDAAoD;IACpD,MAAM,CAAC,GAAG,GAAG,CAAC,gBAAgB,CAAC;IAC/B,MAAM,CAAC,GAAG,GAAG,CAAC,iBAAiB,CAAC;IAEhC,MAAM,CAAC,GAAG,GAAG,CAAC,sBAAsB,CAAC;IACrC,MAAM,CAAC,GAAG,GAAG,CAAC,aAAa,CAAC;IAE5B,MAAM,UAAU,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,+BAA+B;IAEnE,MAAM,CAAC,GAAG,SAAS,CAAC,GAAG,CAAC,2BAAe,CAAC,CAAC,GAAG,CAAC,WAAW,CA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AAC,GAAG,CAAC,yBAAa,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IACjE,MAAM,MAAM,GAAG,eAAE,CAAC,GAAG,CAAC,eAAG,EAAE,GAAG,CAAC,aAAa,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC,CAAC;IAElE,OAAO,MAAM,CAAC;AAChB,CAAC;AAlCD,oDAkCC"}
|
@@ -0,0 +1,31 @@
|
|
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.getSwitchboardOraclePriceDataFromBuffer = void 0;
|
7
|
+
const bn_js_1 = __importDefault(require("bn.js"));
|
8
|
+
const constants_1 = require("./constants");
|
9
|
+
const structs_1 = require("../../switchboard/structs");
|
10
|
+
function getSwitchboardOraclePriceDataFromBuffer(buffer) {
|
11
|
+
const [aggregatorAccountData] = structs_1.aggregatorAccountStruct.deserialize(buffer);
|
12
|
+
const price = convertSwitchboardDecimal(aggregatorAccountData.latestConfirmedRound.result);
|
13
|
+
const confidence = bn_js_1.default.max(convertSwitchboardDecimal(aggregatorAccountData.latestConfirmedRound.stdDeviation), price.divn(1000));
|
14
|
+
const hasSufficientNumberOfDataPoints = aggregatorAccountData.latestConfirmedRound.numSuccess >=
|
15
|
+
aggregatorAccountData.minOracleResults;
|
16
|
+
const slot = new bn_js_1.default(aggregatorAccountData.latestConfirmedRound.roundOpenSlot.toString());
|
17
|
+
return {
|
18
|
+
price,
|
19
|
+
slot,
|
20
|
+
confidence,
|
21
|
+
hasSufficientNumberOfDataPoints,
|
22
|
+
};
|
23
|
+
}
|
24
|
+
exports.getSwitchboardOraclePriceDataFromBuffer = getSwitchboardOraclePriceDataFromBuffer;
|
25
|
+
function convertSwitchboardDecimal(switchboardDecimal) {
|
26
|
+
const switchboardPrecision = constants_1.TEN.pow(new bn_js_1.default(switchboardDecimal.scale));
|
27
|
+
return new bn_js_1.default(switchboardDecimal.mantissa.toString(10), 10)
|
28
|
+
.mul(constants_1.PRICE_PRECISION)
|
29
|
+
.div(switchboardPrecision);
|
30
|
+
}
|
31
|
+
//# sourceMappingURL=switchboard.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"switchboard.js","sourceRoot":"","sources":["../../../../../../../packages/plugins/src/plugins/drift/perpHelpers/switchboard.ts"],"names":[],"mappings":";;;;;;AAAA,kDAAuB;AAGvB,2CAAmD;AACnD,uDAAoE;AAEpE,SAAgB,uCAAuC,CACrD,MAAc;IAEd,MAAM,CAAC,qBAAqB,CAAC,GAAG,iCAAuB,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;IAE5E,MAAM,KAAK,GAAG,yBAAyB,CACrC,qBAAqB,CAAC,oBAAoB,CAAC,MAAM,CAClD,CAAC;IAEF,MAAM,UAAU,GAAG,eAAE,CAAC,GAAG,CACvB,yBAAyB,CACvB,qBAAqB,CAAC,oBAAoB,CAAC,YAAY,CACxD,EACD,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CACjB,CAAC;IAEF,MAAM,+BAA+B,GACnC,qBAAqB,CAAC,oBAAoB,CAAC,UAAU;QACrD,qBAAqB,CAAC,gBAAgB,CAAC;IAEzC,MAAM,IAAI,GAAG,IAAI,eAAE,CACjB,qBAAqB,CAAC,oBAAoB,CAAC,aAAa,CAAC,QAAQ,EAAE,CACpE,CAAC;IACF,OAAO;QACL,KAAK;QACL,IAAI;QACJ,UAAU;QACV,+BAA+B;KAChC,CAAC;AACJ,CAAC;AA7BD,0FA6BC;AAED,SAAS,yBAAyB,CAAC,kBAGlC;IACC,MAAM,oBAAoB,GAAG,eAAG,CAAC,GAAG,CAAC,IAAI,eAAE,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC,CAAC;IACvE,OAAO,IAAI,eAAE,CAAC,kBAAkB,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;SACxD,GAAG,CAAC,2BAAe,CAAC;SACpB,GAAG,CAAC,oBAAoB,CAAC,CAAC;AAC/B,CAAC"}
|
@@ -0,0 +1,28 @@
|
|
1
|
+
import BN from 'bn.js';
|
2
|
+
export type OraclePriceData = {
|
3
|
+
price: BN;
|
4
|
+
slot: BN;
|
5
|
+
confidence: BN;
|
6
|
+
hasSufficientNumberOfDataPoints: boolean;
|
7
|
+
twap?: BN;
|
8
|
+
twapConfidence?: BN;
|
9
|
+
maxPrice?: BN;
|
10
|
+
};
|
11
|
+
export declare class PositionDirection {
|
12
|
+
static readonly LONG: {
|
13
|
+
long: {};
|
14
|
+
};
|
15
|
+
static readonly SHORT: {
|
16
|
+
short: {};
|
17
|
+
};
|
18
|
+
}
|
19
|
+
export declare class SwapDirection {
|
20
|
+
static readonly ADD: {
|
21
|
+
add: {};
|
22
|
+
};
|
23
|
+
static readonly REMOVE: {
|
24
|
+
remove: {};
|
25
|
+
};
|
26
|
+
}
|
27
|
+
export type AssetType = 'quote' | 'base';
|
28
|
+
export declare function isVariant(object: object, type: string): boolean;
|
@@ -0,0 +1,19 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.isVariant = exports.SwapDirection = exports.PositionDirection = void 0;
|
4
|
+
class PositionDirection {
|
5
|
+
}
|
6
|
+
exports.PositionDirection = PositionDirection;
|
7
|
+
PositionDirection.LONG = { long: {} };
|
8
|
+
PositionDirection.SHORT = { short: {} };
|
9
|
+
class SwapDirection {
|
10
|
+
}
|
11
|
+
exports.SwapDirection = SwapDirection;
|
12
|
+
SwapDirection.ADD = { add: {} };
|
13
|
+
SwapDirection.REMOVE = { remove: {} };
|
14
|
+
function isVariant(object, type) {
|
15
|
+
// eslint-disable-next-line no-prototype-builtins
|
16
|
+
return object.hasOwnProperty(type);
|
17
|
+
}
|
18
|
+
exports.isVariant = isVariant;
|
19
|
+
//# sourceMappingURL=types.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../../packages/plugins/src/plugins/drift/perpHelpers/types.ts"],"names":[],"mappings":";;;AAaA,MAAa,iBAAiB;;AAA9B,8CAGC;AAFiB,sBAAI,GAAG,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC;AACpB,uBAAK,GAAG,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC;AAGxC,MAAa,aAAa;;AAA1B,sCAGC;AAFiB,iBAAG,GAAG,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC;AAClB,oBAAM,GAAG,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC;AAK1C,SAAgB,SAAS,CAAC,MAAc,EAAE,IAAY;IACpD,iDAAiD;IACjD,OAAO,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;AACrC,CAAC;AAHD,8BAGC"}
|
@@ -0,0 +1,38 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
|
+
});
|
10
|
+
};
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
12
|
+
const portfolio_core_1 = require("@sonarwatch/portfolio-core");
|
13
|
+
const constants_1 = require("./constants");
|
14
|
+
const struct_1 = require("./struct");
|
15
|
+
const clients_1 = require("../../utils/clients");
|
16
|
+
const solana_1 = require("../../utils/solana");
|
17
|
+
const filters_1 = require("./filters");
|
18
|
+
const getOraclePrice_1 = require("./perpHelpers/getOraclePrice");
|
19
|
+
const executor = (cache) => __awaiter(void 0, void 0, void 0, function* () {
|
20
|
+
const client = (0, clients_1.getClientSolana)();
|
21
|
+
const marketAccounts = yield (0, solana_1.getParsedProgramAccounts)(client, struct_1.perpMarketStruct, constants_1.driftProgram, filters_1.perpMarketsFilters);
|
22
|
+
const indexes = marketAccounts.map((m) => [m.marketIndex, m.pubkey.toString()]);
|
23
|
+
yield cache.setItem(constants_1.perpMarketsIndexesKey, indexes, {
|
24
|
+
prefix: constants_1.platformId,
|
25
|
+
networkId: portfolio_core_1.NetworkId.solana,
|
26
|
+
});
|
27
|
+
for (let i = 0; i < marketAccounts.length; i++) {
|
28
|
+
const acc = marketAccounts[i];
|
29
|
+
yield (0, getOraclePrice_1.getOraclePrice)(acc.amm.oracle.toString(), acc.amm.oracleSource, client);
|
30
|
+
}
|
31
|
+
});
|
32
|
+
const job = {
|
33
|
+
id: `${constants_1.platformId}-perp-markets`,
|
34
|
+
executor,
|
35
|
+
label: 'normal',
|
36
|
+
};
|
37
|
+
exports.default = job;
|
38
|
+
//# sourceMappingURL=prepMarketsJob.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"prepMarketsJob.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/drift/prepMarketsJob.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,+DAAuD;AAGvD,2CAA8E;AAC9E,qCAA4C;AAC5C,iDAAsD;AACtD,+CAA8D;AAC9D,uCAA+C;AAC/C,iEAA8D;AAE9D,MAAM,QAAQ,GAAgB,CAAO,KAAY,EAAE,EAAE;IACnD,MAAM,MAAM,GAAG,IAAA,yBAAe,GAAE,CAAC;IAEjC,MAAM,cAAc,GAAG,MAAM,IAAA,iCAAwB,EACnD,MAAM,EACN,yBAAgB,EAChB,wBAAY,EACZ,4BAAkB,CACnB,CAAC;IACF,MAAM,OAAO,GAA4B,cAAc,CAAC,GAAG,CACzD,CAAC,CAAC,EAAE,E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