@drift-labs/sdk 0.1.30-master.0 → 0.1.30-master.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.
- package/lib/accounts/bulkAccountLoader.d.ts +2 -2
- package/lib/accounts/bulkAccountLoader.js +21 -24
- package/lib/accounts/pollingClearingHouseAccountSubscriber.d.ts +15 -0
- package/lib/accounts/pollingClearingHouseAccountSubscriber.js +50 -23
- package/lib/clearingHouse.d.ts +0 -1
- package/lib/clearingHouse.js +0 -14
- package/lib/constants/accounts.d.ts +15 -0
- package/lib/constants/accounts.js +18 -0
- package/lib/constants/markets.js +11 -8
- package/lib/factory/clearingHouse.d.ts +14 -4
- package/lib/factory/clearingHouse.js +23 -6
- package/lib/idl/clearing_house.json +2 -33
- package/lib/index.d.ts +0 -1
- package/lib/index.js +0 -1
- package/lib/math/amm.d.ts +20 -0
- package/lib/math/amm.js +151 -1
- package/lib/util/promiseTimeout.d.ts +1 -0
- package/lib/util/promiseTimeout.js +14 -0
- package/package.json +1 -1
- package/src/accounts/bulkAccountLoader.ts +22 -32
- package/src/accounts/pollingClearingHouseAccountSubscriber.ts +73 -30
- package/src/clearingHouse.ts +0 -13
- package/src/constants/accounts.ts +26 -0
- package/src/constants/markets.ts +11 -8
- package/src/factory/clearingHouse.ts +47 -7
- package/src/idl/clearing_house.json +2 -33
- package/src/index.ts +0 -1
- package/src/math/amm.ts +212 -1
- package/src/util/promiseTimeout.ts +14 -0
- package/lib/math/repeg.d.ts +0 -32
- package/lib/math/repeg.js +0 -178
- package/src/accounts/pollingClearingHouseAccountSubscriber.js +0 -210
- package/src/accounts/pollingClearingHouseAccountSubscriber.js.map +0 -1
- package/src/accounts/pollingOracleSubscriber.js +0 -65
- package/src/accounts/pollingOracleSubscriber.js.map +0 -1
- package/src/accounts/pollingTokenAccountSubscriber.js +0 -65
- package/src/accounts/pollingTokenAccountSubscriber.js.map +0 -1
- package/src/accounts/utils.js +0 -8
- package/src/accounts/utils.js.map +0 -1
- package/src/accounts/webSocketAccountSubscriber.js +0 -64
- package/src/accounts/webSocketAccountSubscriber.js.map +0 -1
- package/src/accounts/webSocketClearingHouseAccountSubscriber.js +0 -212
- package/src/accounts/webSocketClearingHouseAccountSubscriber.js.map +0 -1
- package/src/assert/assert.js +0 -10
- package/src/assert/assert.js.map +0 -1
- package/src/constants/markets.js +0 -167
- package/src/constants/markets.js.map +0 -1
- package/src/constants/numericConstants.js +0 -22
- package/src/constants/numericConstants.js.map +0 -1
- package/src/math/conversion.js +0 -16
- package/src/math/conversion.js.map +0 -1
- package/src/math/funding.js +0 -223
- package/src/math/funding.js.map +0 -1
- package/src/math/insuranceFund.js +0 -23
- package/src/math/insuranceFund.js.map +0 -1
- package/src/math/market.js +0 -30
- package/src/math/market.js.map +0 -1
- package/src/math/orders.js +0 -73
- package/src/math/orders.js.map +0 -1
- package/src/math/position.js +0 -121
- package/src/math/position.js.map +0 -1
- package/src/math/repeg.ts +0 -253
- package/src/math/trade.js +0 -182
- package/src/math/trade.js.map +0 -1
- package/src/math/utils.js +0 -27
- package/src/math/utils.js.map +0 -1
- package/src/oracles/switchboardClient.js +0 -60
- package/src/oracles/switchboardClient.js.map +0 -1
- package/src/oracles/types.js +0 -3
- package/src/oracles/types.js.map +0 -1
- package/src/token/index.js +0 -39
- package/src/token/index.js.map +0 -1
- package/src/tx/defaultTxSender.js +0 -13
- package/src/tx/defaultTxSender.js.map +0 -1
- package/src/tx/types.js +0 -3
- package/src/tx/types.js.map +0 -1
- package/src/tx/utils.js +0 -9
- package/src/tx/utils.js.map +0 -1
- package/src/util/computeUnits.js +0 -17
- package/src/util/computeUnits.js.map +0 -1
- package/src/util/tps.js +0 -17
- package/src/util/tps.js.map +0 -1
package/src/math/position.js
DELETED
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isEmptyPosition = exports.positionCurrentDirection = exports.findDirectionToClose = exports.calculateEntryPrice = exports.calculatePositionFundingPNL = exports.calculatePositionPNL = exports.calculateBaseAssetValue = void 0;
|
|
4
|
-
const __1 = require("../");
|
|
5
|
-
const numericConstants_1 = require("../constants/numericConstants");
|
|
6
|
-
const types_1 = require("../types");
|
|
7
|
-
const amm_1 = require("./amm");
|
|
8
|
-
/**
|
|
9
|
-
* calculateBaseAssetValue
|
|
10
|
-
* = market value of closing entire position
|
|
11
|
-
* @param market
|
|
12
|
-
* @param userPosition
|
|
13
|
-
* @returns Base Asset Value. : Precision QUOTE_PRECISION
|
|
14
|
-
*/
|
|
15
|
-
function calculateBaseAssetValue(market, userPosition) {
|
|
16
|
-
if (userPosition.baseAssetAmount.eq(numericConstants_1.ZERO)) {
|
|
17
|
-
return numericConstants_1.ZERO;
|
|
18
|
-
}
|
|
19
|
-
const directionToClose = findDirectionToClose(userPosition);
|
|
20
|
-
const [newQuoteAssetReserve, _] = (0, amm_1.calculateAmmReservesAfterSwap)(market.amm, 'base', userPosition.baseAssetAmount.abs(), (0, amm_1.getSwapDirection)('base', directionToClose));
|
|
21
|
-
switch (directionToClose) {
|
|
22
|
-
case types_1.PositionDirection.SHORT:
|
|
23
|
-
return market.amm.quoteAssetReserve
|
|
24
|
-
.sub(newQuoteAssetReserve)
|
|
25
|
-
.mul(market.amm.pegMultiplier)
|
|
26
|
-
.div(numericConstants_1.AMM_TIMES_PEG_TO_QUOTE_PRECISION_RATIO);
|
|
27
|
-
case types_1.PositionDirection.LONG:
|
|
28
|
-
return newQuoteAssetReserve
|
|
29
|
-
.sub(market.amm.quoteAssetReserve)
|
|
30
|
-
.mul(market.amm.pegMultiplier)
|
|
31
|
-
.div(numericConstants_1.AMM_TIMES_PEG_TO_QUOTE_PRECISION_RATIO)
|
|
32
|
-
.add(numericConstants_1.ONE);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
exports.calculateBaseAssetValue = calculateBaseAssetValue;
|
|
36
|
-
/**
|
|
37
|
-
* calculatePositionPNL
|
|
38
|
-
* = BaseAssetAmount * (Avg Exit Price - Avg Entry Price)
|
|
39
|
-
* @param market
|
|
40
|
-
* @param marketPosition
|
|
41
|
-
* @param withFunding (adds unrealized funding payment pnl to result)
|
|
42
|
-
* @returns BaseAssetAmount : Precision QUOTE_PRECISION
|
|
43
|
-
*/
|
|
44
|
-
function calculatePositionPNL(market, marketPosition, withFunding = false) {
|
|
45
|
-
if (marketPosition.baseAssetAmount.eq(numericConstants_1.ZERO)) {
|
|
46
|
-
return numericConstants_1.ZERO;
|
|
47
|
-
}
|
|
48
|
-
const baseAssetValue = calculateBaseAssetValue(market, marketPosition);
|
|
49
|
-
let pnl;
|
|
50
|
-
if (marketPosition.baseAssetAmount.gt(numericConstants_1.ZERO)) {
|
|
51
|
-
pnl = baseAssetValue.sub(marketPosition.quoteAssetAmount);
|
|
52
|
-
}
|
|
53
|
-
else {
|
|
54
|
-
pnl = marketPosition.quoteAssetAmount.sub(baseAssetValue);
|
|
55
|
-
}
|
|
56
|
-
if (withFunding) {
|
|
57
|
-
const fundingRatePnL = calculatePositionFundingPNL(market, marketPosition).div(numericConstants_1.PRICE_TO_QUOTE_PRECISION);
|
|
58
|
-
pnl = pnl.add(fundingRatePnL);
|
|
59
|
-
}
|
|
60
|
-
return pnl;
|
|
61
|
-
}
|
|
62
|
-
exports.calculatePositionPNL = calculatePositionPNL;
|
|
63
|
-
/**
|
|
64
|
-
*
|
|
65
|
-
* @param market
|
|
66
|
-
* @param marketPosition
|
|
67
|
-
* @returns // TODO-PRECISION
|
|
68
|
-
*/
|
|
69
|
-
function calculatePositionFundingPNL(market, marketPosition) {
|
|
70
|
-
if (marketPosition.baseAssetAmount.eq(numericConstants_1.ZERO)) {
|
|
71
|
-
return numericConstants_1.ZERO;
|
|
72
|
-
}
|
|
73
|
-
let ammCumulativeFundingRate;
|
|
74
|
-
if (marketPosition.baseAssetAmount.gt(numericConstants_1.ZERO)) {
|
|
75
|
-
ammCumulativeFundingRate = market.amm.cumulativeFundingRateLong;
|
|
76
|
-
}
|
|
77
|
-
else {
|
|
78
|
-
ammCumulativeFundingRate = market.amm.cumulativeFundingRateShort;
|
|
79
|
-
}
|
|
80
|
-
const perPositionFundingRate = ammCumulativeFundingRate
|
|
81
|
-
.sub(marketPosition.lastCumulativeFundingRate)
|
|
82
|
-
.mul(marketPosition.baseAssetAmount)
|
|
83
|
-
.div(numericConstants_1.AMM_RESERVE_PRECISION)
|
|
84
|
-
.div(numericConstants_1.FUNDING_PAYMENT_PRECISION)
|
|
85
|
-
.mul(new __1.BN(-1));
|
|
86
|
-
return perPositionFundingRate;
|
|
87
|
-
}
|
|
88
|
-
exports.calculatePositionFundingPNL = calculatePositionFundingPNL;
|
|
89
|
-
/**
|
|
90
|
-
*
|
|
91
|
-
* @param userPosition
|
|
92
|
-
* @returns Precision: MARK_PRICE_PRECISION (10^10)
|
|
93
|
-
*/
|
|
94
|
-
function calculateEntryPrice(userPosition) {
|
|
95
|
-
if (userPosition.baseAssetAmount.eq(numericConstants_1.ZERO)) {
|
|
96
|
-
return numericConstants_1.ZERO;
|
|
97
|
-
}
|
|
98
|
-
return userPosition.quoteAssetAmount
|
|
99
|
-
.mul(numericConstants_1.MARK_PRICE_PRECISION)
|
|
100
|
-
.mul(numericConstants_1.AMM_TO_QUOTE_PRECISION_RATIO)
|
|
101
|
-
.div(userPosition.baseAssetAmount)
|
|
102
|
-
.abs();
|
|
103
|
-
}
|
|
104
|
-
exports.calculateEntryPrice = calculateEntryPrice;
|
|
105
|
-
function findDirectionToClose(userPosition) {
|
|
106
|
-
return userPosition.baseAssetAmount.gt(numericConstants_1.ZERO)
|
|
107
|
-
? types_1.PositionDirection.SHORT
|
|
108
|
-
: types_1.PositionDirection.LONG;
|
|
109
|
-
}
|
|
110
|
-
exports.findDirectionToClose = findDirectionToClose;
|
|
111
|
-
function positionCurrentDirection(userPosition) {
|
|
112
|
-
return userPosition.baseAssetAmount.gte(numericConstants_1.ZERO)
|
|
113
|
-
? types_1.PositionDirection.LONG
|
|
114
|
-
: types_1.PositionDirection.SHORT;
|
|
115
|
-
}
|
|
116
|
-
exports.positionCurrentDirection = positionCurrentDirection;
|
|
117
|
-
function isEmptyPosition(userPosition) {
|
|
118
|
-
return (userPosition.baseAssetAmount.eq(numericConstants_1.ZERO) && userPosition.openOrders.eq(numericConstants_1.ZERO));
|
|
119
|
-
}
|
|
120
|
-
exports.isEmptyPosition = isEmptyPosition;
|
|
121
|
-
//# sourceMappingURL=position.js.map
|
package/src/math/position.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"position.js","sourceRoot":"","sources":["position.ts"],"names":[],"mappings":";;;AAAA,2BAAyB;AACzB,oEASuC;AACvC,oCAAmE;AACnE,+BAAwE;AAExE;;;;;;GAMG;AACH,SAAgB,uBAAuB,CACtC,MAAc,EACd,YAA0B;IAE1B,IAAI,YAAY,CAAC,eAAe,CAAC,EAAE,CAAC,uBAAI,CAAC,EAAE;QAC1C,OAAO,uBAAI,CAAC;KACZ;IAED,MAAM,gBAAgB,GAAG,oBAAoB,CAAC,YAAY,CAAC,CAAC;IAE5D,MAAM,CAAC,oBAAoB,EAAE,CAAC,CAAC,GAAG,IAAA,mCAA6B,EAC9D,MAAM,CAAC,GAAG,EACV,MAAM,EACN,YAAY,CAAC,eAAe,CAAC,GAAG,EAAE,EAClC,IAAA,sBAAgB,EAAC,MAAM,EAAE,gBAAgB,CAAC,CAC1C,CAAC;IAEF,QAAQ,gBAAgB,EAAE;QACzB,KAAK,yBAAiB,CAAC,KAAK;YAC3B,OAAO,MAAM,CAAC,GAAG,CAAC,iBAAiB;iBACjC,GAAG,CAAC,oBAAoB,CAAC;iBACzB,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,aAAa,CAAC;iBAC7B,GAAG,CAAC,yDAAsC,CAAC,CAAC;QAE/C,KAAK,yBAAiB,CAAC,IAAI;YAC1B,OAAO,oBAAoB;iBACzB,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,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AC,uBAAI,CAAC,IAAI,YAAY,CAAC,UAAU,CAAC,EAAE,CAAC,uBAAI,CAAC,CACzE,CAAC;AACH,CAAC;AAJD,0CAIC"}
|
package/src/math/repeg.ts
DELETED
|
@@ -1,253 +0,0 @@
|
|
|
1
|
-
import { BN } from '@project-serum/anchor';
|
|
2
|
-
import {
|
|
3
|
-
MARK_PRICE_PRECISION,
|
|
4
|
-
AMM_RESERVE_PRECISION,
|
|
5
|
-
PEG_PRECISION,
|
|
6
|
-
AMM_TO_QUOTE_PRECISION_RATIO,
|
|
7
|
-
QUOTE_PRECISION,
|
|
8
|
-
ZERO,
|
|
9
|
-
} from '../constants/numericConstants';
|
|
10
|
-
import { calculateBaseAssetValue } from './position';
|
|
11
|
-
import { calculateTerminalPrice } from './amm';
|
|
12
|
-
|
|
13
|
-
import { Market } from '../types';
|
|
14
|
-
import { calculatePositionPNL, calculateMarkPrice, convertToNumber } from '..';
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Helper function calculating adjust k cost
|
|
18
|
-
* @param market
|
|
19
|
-
* @param marketIndex
|
|
20
|
-
* @param numerator
|
|
21
|
-
* @param denomenator
|
|
22
|
-
* @returns cost : Precision QUOTE_ASSET_PRECISION
|
|
23
|
-
*/
|
|
24
|
-
export function calculateAdjustKCost(
|
|
25
|
-
market: Market,
|
|
26
|
-
marketIndex: BN,
|
|
27
|
-
numerator: BN,
|
|
28
|
-
denomenator: BN
|
|
29
|
-
): BN {
|
|
30
|
-
const netUserPosition = {
|
|
31
|
-
baseAssetAmount: market.baseAssetAmount,
|
|
32
|
-
lastCumulativeFundingRate: market.amm.cumulativeFundingRate,
|
|
33
|
-
marketIndex: new BN(marketIndex),
|
|
34
|
-
quoteAssetAmount: ZERO,
|
|
35
|
-
openOrders: ZERO,
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
const currentValue = calculateBaseAssetValue(market, netUserPosition);
|
|
39
|
-
|
|
40
|
-
const marketNewK = Object.assign({}, market);
|
|
41
|
-
marketNewK.amm = Object.assign({}, market.amm);
|
|
42
|
-
|
|
43
|
-
marketNewK.amm.baseAssetReserve = market.amm.baseAssetReserve
|
|
44
|
-
.mul(numerator)
|
|
45
|
-
.div(denomenator);
|
|
46
|
-
marketNewK.amm.quoteAssetReserve = market.amm.quoteAssetReserve
|
|
47
|
-
.mul(numerator)
|
|
48
|
-
.div(denomenator);
|
|
49
|
-
marketNewK.amm.sqrtK = market.amm.sqrtK.mul(numerator).div(denomenator);
|
|
50
|
-
|
|
51
|
-
netUserPosition.quoteAssetAmount = currentValue;
|
|
52
|
-
|
|
53
|
-
const cost = calculatePositionPNL(marketNewK, netUserPosition);
|
|
54
|
-
|
|
55
|
-
return cost;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Helper function calculating adjust pegMultiplier (repeg) cost
|
|
60
|
-
*
|
|
61
|
-
* @param market
|
|
62
|
-
* @param marketIndex
|
|
63
|
-
* @param newPeg
|
|
64
|
-
* @returns cost : Precision QUOTE_ASSET_PRECISION
|
|
65
|
-
*/
|
|
66
|
-
export function calculateRepegCost(
|
|
67
|
-
market: Market,
|
|
68
|
-
marketIndex: BN,
|
|
69
|
-
newPeg: BN
|
|
70
|
-
): BN {
|
|
71
|
-
const netUserPosition = {
|
|
72
|
-
baseAssetAmount: market.baseAssetAmount,
|
|
73
|
-
lastCumulativeFundingRate: market.amm.cumulativeFundingRate,
|
|
74
|
-
marketIndex: new BN(marketIndex),
|
|
75
|
-
quoteAssetAmount: new BN(0),
|
|
76
|
-
openOrders: ZERO,
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
const currentValue = calculateBaseAssetValue(market, netUserPosition);
|
|
80
|
-
netUserPosition.quoteAssetAmount = currentValue;
|
|
81
|
-
const prevMarketPrice = calculateMarkPrice(market);
|
|
82
|
-
const marketNewPeg = Object.assign({}, market);
|
|
83
|
-
marketNewPeg.amm = Object.assign({}, market.amm);
|
|
84
|
-
|
|
85
|
-
// const marketNewPeg = JSON.parse(JSON.stringify(market));
|
|
86
|
-
marketNewPeg.amm.pegMultiplier = newPeg;
|
|
87
|
-
|
|
88
|
-
console.log(
|
|
89
|
-
'Price moves from',
|
|
90
|
-
convertToNumber(prevMarketPrice),
|
|
91
|
-
'to',
|
|
92
|
-
convertToNumber(calculateMarkPrice(marketNewPeg))
|
|
93
|
-
);
|
|
94
|
-
|
|
95
|
-
const cost = calculatePositionPNL(marketNewPeg, netUserPosition);
|
|
96
|
-
|
|
97
|
-
return cost;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
* Helper function calculating adjust pegMultiplier (repeg) cost
|
|
102
|
-
*
|
|
103
|
-
* @param market
|
|
104
|
-
* @param marketIndex
|
|
105
|
-
* @param newPeg
|
|
106
|
-
* @returns cost : Precision QUOTE_ASSET_PRECISION
|
|
107
|
-
*/
|
|
108
|
-
export function calculateReserveRebalanceCost(
|
|
109
|
-
market: Market,
|
|
110
|
-
marketIndex: BN
|
|
111
|
-
): BN {
|
|
112
|
-
const netUserPosition = {
|
|
113
|
-
baseAssetAmount: market.baseAssetAmount,
|
|
114
|
-
lastCumulativeFundingRate: market.amm.cumulativeFundingRate,
|
|
115
|
-
marketIndex: new BN(marketIndex),
|
|
116
|
-
quoteAssetAmount: new BN(0),
|
|
117
|
-
openOrders: ZERO,
|
|
118
|
-
};
|
|
119
|
-
|
|
120
|
-
const currentValue = calculateBaseAssetValue(market, netUserPosition);
|
|
121
|
-
netUserPosition.quoteAssetAmount = currentValue;
|
|
122
|
-
const prevMarketPrice = calculateMarkPrice(market);
|
|
123
|
-
const marketNewPeg = Object.assign({}, market);
|
|
124
|
-
marketNewPeg.amm = Object.assign({}, market.amm);
|
|
125
|
-
|
|
126
|
-
// const marketNewPeg = JSON.parse(JSON.stringify(market));
|
|
127
|
-
const newPeg = calculateTerminalPrice(market)
|
|
128
|
-
.mul(PEG_PRECISION)
|
|
129
|
-
.div(MARK_PRICE_PRECISION);
|
|
130
|
-
// const newPeg = prevMarketPrice.mul(PEG_PRECISION).div(MARK_PRICE_PRECISION);
|
|
131
|
-
|
|
132
|
-
const newBaseReserve = market.amm.baseAssetReserve.add(
|
|
133
|
-
market.baseAssetAmount
|
|
134
|
-
);
|
|
135
|
-
const newQuoteReserve = market.amm.sqrtK
|
|
136
|
-
.mul(market.amm.sqrtK)
|
|
137
|
-
.div(newBaseReserve);
|
|
138
|
-
console.log(
|
|
139
|
-
'current reserves on close, quote:',
|
|
140
|
-
convertToNumber(newQuoteReserve, AMM_RESERVE_PRECISION),
|
|
141
|
-
'base:',
|
|
142
|
-
convertToNumber(newBaseReserve, AMM_RESERVE_PRECISION)
|
|
143
|
-
);
|
|
144
|
-
|
|
145
|
-
let newSqrtK;
|
|
146
|
-
if (newPeg.lt(market.amm.pegMultiplier)) {
|
|
147
|
-
newSqrtK = newBaseReserve;
|
|
148
|
-
} else {
|
|
149
|
-
newSqrtK = newQuoteReserve;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
marketNewPeg.amm.baseAssetReserve = newSqrtK.sub(market.baseAssetAmount); // newSqrtK.sub(market.baseAssetAmount);
|
|
153
|
-
marketNewPeg.amm.quoteAssetReserve = newSqrtK
|
|
154
|
-
.mul(newSqrtK)
|
|
155
|
-
.div(marketNewPeg.amm.baseAssetReserve);
|
|
156
|
-
marketNewPeg.amm.sqrtK = newSqrtK;
|
|
157
|
-
marketNewPeg.amm.pegMultiplier = newPeg;
|
|
158
|
-
|
|
159
|
-
console.log(
|
|
160
|
-
'Price moves from',
|
|
161
|
-
convertToNumber(prevMarketPrice),
|
|
162
|
-
'to',
|
|
163
|
-
convertToNumber(calculateMarkPrice(marketNewPeg))
|
|
164
|
-
);
|
|
165
|
-
|
|
166
|
-
const cost = calculatePositionPNL(marketNewPeg, netUserPosition);
|
|
167
|
-
|
|
168
|
-
return cost;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
export function calculateBudgetedK(market: Market, cost: BN): [BN, BN] {
|
|
172
|
-
// wolframalpha.com
|
|
173
|
-
// (1/(x+d) - p/(x*p+d))*y*d*Q = C solve for p
|
|
174
|
-
// p = (d(y*d*Q - C(x+d))) / (C*x(x+d) + y*y*d*Q)
|
|
175
|
-
|
|
176
|
-
// todo: assumes k = x * y
|
|
177
|
-
// otherwise use: (y(1-p) + (kp^2/(x*p+d)) - k/(x+d)) * Q = C solve for p
|
|
178
|
-
|
|
179
|
-
// const k = market.amm.sqrtK.mul(market.amm.sqrtK);
|
|
180
|
-
const x = market.amm.baseAssetReserve;
|
|
181
|
-
const y = market.amm.quoteAssetReserve;
|
|
182
|
-
|
|
183
|
-
const d = market.baseAssetAmount;
|
|
184
|
-
const Q = market.amm.pegMultiplier;
|
|
185
|
-
|
|
186
|
-
const C = cost.mul(new BN(-1));
|
|
187
|
-
|
|
188
|
-
const numer1 = y.mul(d).mul(Q).div(AMM_RESERVE_PRECISION).div(PEG_PRECISION);
|
|
189
|
-
const numer2 = C.mul(x.add(d)).div(QUOTE_PRECISION);
|
|
190
|
-
const denom1 = C.mul(x)
|
|
191
|
-
.mul(x.add(d))
|
|
192
|
-
.div(AMM_RESERVE_PRECISION)
|
|
193
|
-
.div(QUOTE_PRECISION);
|
|
194
|
-
const denom2 = y
|
|
195
|
-
.mul(d)
|
|
196
|
-
.mul(d)
|
|
197
|
-
.mul(Q)
|
|
198
|
-
.div(AMM_RESERVE_PRECISION)
|
|
199
|
-
.div(AMM_RESERVE_PRECISION)
|
|
200
|
-
.div(PEG_PRECISION);
|
|
201
|
-
|
|
202
|
-
const numerator = d
|
|
203
|
-
.mul(numer1.add(numer2))
|
|
204
|
-
.div(AMM_RESERVE_PRECISION)
|
|
205
|
-
.div(AMM_RESERVE_PRECISION)
|
|
206
|
-
.div(AMM_TO_QUOTE_PRECISION_RATIO);
|
|
207
|
-
const denominator = denom1
|
|
208
|
-
.add(denom2)
|
|
209
|
-
.div(AMM_RESERVE_PRECISION)
|
|
210
|
-
.div(AMM_TO_QUOTE_PRECISION_RATIO);
|
|
211
|
-
console.log(numerator, denominator);
|
|
212
|
-
// const p = (numerator).div(denominator);
|
|
213
|
-
|
|
214
|
-
// const formulaCost = (numer21.sub(numer20).sub(numer1)).mul(market.amm.pegMultiplier).div(AMM_TIMES_PEG_TO_QUOTE_PRECISION_RATIO)
|
|
215
|
-
// console.log(convertToNumber(formulaCost, QUOTE_PRECISION))
|
|
216
|
-
|
|
217
|
-
return [numerator, denominator];
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
export function calculateBudgetedPeg(market: Market, cost: BN): BN {
|
|
221
|
-
// wolframalpha.com
|
|
222
|
-
// (1/(x+d) - p/(x*p+d))*y*d*Q = C solve for p
|
|
223
|
-
// p = (d(y*d*Q - C(x+d))) / (C*x(x+d) + y*y*d*Q)
|
|
224
|
-
|
|
225
|
-
// todo: assumes k = x * y
|
|
226
|
-
// otherwise use: (y(1-p) + (kp^2/(x*p+d)) - k/(x+d)) * Q = C solve for p
|
|
227
|
-
|
|
228
|
-
const k = market.amm.sqrtK.mul(market.amm.sqrtK);
|
|
229
|
-
const x = market.amm.baseAssetReserve;
|
|
230
|
-
const y = market.amm.quoteAssetReserve;
|
|
231
|
-
|
|
232
|
-
const d = market.baseAssetAmount;
|
|
233
|
-
const Q = market.amm.pegMultiplier;
|
|
234
|
-
|
|
235
|
-
const C = cost.mul(new BN(-1));
|
|
236
|
-
|
|
237
|
-
const deltaQuoteAssetReserves = y.sub(k.div(x.add(d)));
|
|
238
|
-
const deltaPegMultiplier = C.mul(MARK_PRICE_PRECISION).div(
|
|
239
|
-
deltaQuoteAssetReserves.div(AMM_TO_QUOTE_PRECISION_RATIO)
|
|
240
|
-
);
|
|
241
|
-
// .mul(PEG_PRECISION)
|
|
242
|
-
// .div(QUOTE_PRECISION);
|
|
243
|
-
console.log(
|
|
244
|
-
Q.toNumber(),
|
|
245
|
-
'change by',
|
|
246
|
-
deltaPegMultiplier.toNumber() / MARK_PRICE_PRECISION.toNumber()
|
|
247
|
-
);
|
|
248
|
-
const newPeg = Q.sub(
|
|
249
|
-
deltaPegMultiplier.mul(PEG_PRECISION).div(MARK_PRICE_PRECISION)
|
|
250
|
-
);
|
|
251
|
-
|
|
252
|
-
return newPeg;
|
|
253
|
-
}
|
package/src/math/trade.js
DELETED
|
@@ -1,182 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.calculateTargetPriceTrade = exports.calculateTradeAcquiredAmounts = exports.calculateTradeSlippage = void 0;
|
|
4
|
-
const types_1 = require("../types");
|
|
5
|
-
const anchor_1 = require("@project-serum/anchor");
|
|
6
|
-
const assert_1 = require("../assert/assert");
|
|
7
|
-
const numericConstants_1 = require("../constants/numericConstants");
|
|
8
|
-
const market_1 = require("./market");
|
|
9
|
-
const amm_1 = require("./amm");
|
|
10
|
-
const utils_1 = require("./utils");
|
|
11
|
-
const MAXPCT = new anchor_1.BN(1000); //percentage units are [0,1000] => [0,1]
|
|
12
|
-
/**
|
|
13
|
-
* Calculates avg/max slippage (price impact) for candidate trade
|
|
14
|
-
* @param direction
|
|
15
|
-
* @param amount
|
|
16
|
-
* @param market
|
|
17
|
-
* @return [pctAvgSlippage, pctMaxSlippage, entryPrice, newPrice]
|
|
18
|
-
*
|
|
19
|
-
* 'pctAvgSlippage' => the percentage change to entryPrice (average est slippage in execution) : Precision MARK_PRICE_PRECISION
|
|
20
|
-
*
|
|
21
|
-
* 'pctMaxSlippage' => the percentage change to maxPrice (highest est slippage in execution) : Precision MARK_PRICE_PRECISION
|
|
22
|
-
*
|
|
23
|
-
* 'entryPrice' => the average price of the trade : Precision MARK_PRICE_PRECISION
|
|
24
|
-
*
|
|
25
|
-
* 'newPrice' => the price of the asset after the trade : Precision MARK_PRICE_PRECISION
|
|
26
|
-
*/
|
|
27
|
-
function calculateTradeSlippage(direction, amount, market, inputAssetType = 'quote') {
|
|
28
|
-
const oldPrice = (0, market_1.calculateMarkPrice)(market);
|
|
29
|
-
if (amount.eq(numericConstants_1.ZERO)) {
|
|
30
|
-
return [numericConstants_1.ZERO, numericConstants_1.ZERO, oldPrice, oldPrice];
|
|
31
|
-
}
|
|
32
|
-
const [acquiredBase, acquiredQuote] = calculateTradeAcquiredAmounts(direction, amount, market, inputAssetType);
|
|
33
|
-
const entryPrice = (0, amm_1.calculatePrice)(acquiredBase, acquiredQuote, market.amm.pegMultiplier).mul(new anchor_1.BN(-1));
|
|
34
|
-
const newPrice = (0, amm_1.calculatePrice)(market.amm.baseAssetReserve.sub(acquiredBase), market.amm.quoteAssetReserve.sub(acquiredQuote), market.amm.pegMultiplier);
|
|
35
|
-
if (direction == types_1.PositionDirection.SHORT) {
|
|
36
|
-
(0, assert_1.assert)(newPrice.lt(oldPrice));
|
|
37
|
-
}
|
|
38
|
-
else {
|
|
39
|
-
(0, assert_1.assert)(oldPrice.lt(newPrice));
|
|
40
|
-
}
|
|
41
|
-
const pctMaxSlippage = newPrice
|
|
42
|
-
.sub(oldPrice)
|
|
43
|
-
.mul(numericConstants_1.MARK_PRICE_PRECISION)
|
|
44
|
-
.div(oldPrice)
|
|
45
|
-
.abs();
|
|
46
|
-
const pctAvgSlippage = entryPrice
|
|
47
|
-
.sub(oldPrice)
|
|
48
|
-
.mul(numericConstants_1.MARK_PRICE_PRECISION)
|
|
49
|
-
.div(oldPrice)
|
|
50
|
-
.abs();
|
|
51
|
-
return [pctAvgSlippage, pctMaxSlippage, entryPrice, newPrice];
|
|
52
|
-
}
|
|
53
|
-
exports.calculateTradeSlippage = calculateTradeSlippage;
|
|
54
|
-
/**
|
|
55
|
-
* Calculates acquired amounts for trade executed
|
|
56
|
-
* @param direction
|
|
57
|
-
* @param amount
|
|
58
|
-
* @param market
|
|
59
|
-
* @return
|
|
60
|
-
* | 'acquiredBase' => positive/negative change in user's base : BN TODO-PRECISION
|
|
61
|
-
* | 'acquiredQuote' => positive/negative change in user's quote : BN TODO-PRECISION
|
|
62
|
-
*/
|
|
63
|
-
function calculateTradeAcquiredAmounts(direction, amount, market, inputAssetType = 'quote') {
|
|
64
|
-
if (amount.eq(numericConstants_1.ZERO)) {
|
|
65
|
-
return [numericConstants_1.ZERO, numericConstants_1.ZERO];
|
|
66
|
-
}
|
|
67
|
-
const swapDirection = (0, amm_1.getSwapDirection)(inputAssetType, direction);
|
|
68
|
-
const [newQuoteAssetReserve, newBaseAssetReserve] = (0, amm_1.calculateAmmReservesAfterSwap)(market.amm, inputAssetType, amount, swapDirection);
|
|
69
|
-
const acquiredBase = market.amm.baseAssetReserve.sub(newBaseAssetReserve);
|
|
70
|
-
let acquiredQuote = market.amm.quoteAssetReserve.sub(newQuoteAssetReserve);
|
|
71
|
-
if (inputAssetType === 'base' && (0, types_1.isVariant)(swapDirection, 'remove')) {
|
|
72
|
-
acquiredQuote = acquiredQuote.sub(numericConstants_1.ONE);
|
|
73
|
-
}
|
|
74
|
-
return [acquiredBase, acquiredQuote];
|
|
75
|
-
}
|
|
76
|
-
exports.calculateTradeAcquiredAmounts = calculateTradeAcquiredAmounts;
|
|
77
|
-
/**
|
|
78
|
-
* calculateTargetPriceTrade
|
|
79
|
-
* simple function for finding arbitraging trades
|
|
80
|
-
* @param market
|
|
81
|
-
* @param targetPrice
|
|
82
|
-
* @param pct optional default is 100% gap filling, can set smaller.
|
|
83
|
-
* @returns trade direction/size in order to push price to a targetPrice,
|
|
84
|
-
*
|
|
85
|
-
* [
|
|
86
|
-
* direction => direction of trade required, TODO-PRECISION
|
|
87
|
-
* tradeSize => size of trade required, TODO-PRECISION
|
|
88
|
-
* entryPrice => the entry price for the trade, TODO-PRECISION
|
|
89
|
-
* targetPrice => the target price TODO-PRECISION
|
|
90
|
-
* ]
|
|
91
|
-
*/
|
|
92
|
-
function calculateTargetPriceTrade(market, targetPrice, pct = MAXPCT, outputAssetType = 'quote') {
|
|
93
|
-
(0, assert_1.assert)(market.amm.baseAssetReserve.gt(numericConstants_1.ZERO));
|
|
94
|
-
(0, assert_1.assert)(targetPrice.gt(numericConstants_1.ZERO));
|
|
95
|
-
(0, assert_1.assert)(pct.lte(MAXPCT) && pct.gt(numericConstants_1.ZERO));
|
|
96
|
-
const markPriceBefore = (0, market_1.calculateMarkPrice)(market);
|
|
97
|
-
if (targetPrice.gt(markPriceBefore)) {
|
|
98
|
-
const priceGap = targetPrice.sub(markPriceBefore);
|
|
99
|
-
const priceGapScaled = priceGap.mul(pct).div(MAXPCT);
|
|
100
|
-
targetPrice = markPriceBefore.add(priceGapScaled);
|
|
101
|
-
}
|
|
102
|
-
else {
|
|
103
|
-
const priceGap = markPriceBefore.sub(targetPrice);
|
|
104
|
-
const priceGapScaled = priceGap.mul(pct).div(MAXPCT);
|
|
105
|
-
targetPrice = markPriceBefore.sub(priceGapScaled);
|
|
106
|
-
}
|
|
107
|
-
let direction;
|
|
108
|
-
let tradeSize;
|
|
109
|
-
let baseSize;
|
|
110
|
-
const baseAssetReserveBefore = market.amm.baseAssetReserve;
|
|
111
|
-
const quoteAssetReserveBefore = market.amm.quoteAssetReserve;
|
|
112
|
-
const peg = market.amm.pegMultiplier;
|
|
113
|
-
const invariant = market.amm.sqrtK.mul(market.amm.sqrtK);
|
|
114
|
-
const k = invariant.mul(numericConstants_1.MARK_PRICE_PRECISION);
|
|
115
|
-
let baseAssetReserveAfter;
|
|
116
|
-
let quoteAssetReserveAfter;
|
|
117
|
-
const biasModifier = new anchor_1.BN(1);
|
|
118
|
-
let markPriceAfter;
|
|
119
|
-
if (markPriceBefore.gt(targetPrice)) {
|
|
120
|
-
// overestimate y2
|
|
121
|
-
baseAssetReserveAfter = (0, utils_1.squareRootBN)(k.div(targetPrice).mul(peg).div(numericConstants_1.PEG_PRECISION).sub(biasModifier)).sub(new anchor_1.BN(1));
|
|
122
|
-
quoteAssetReserveAfter = k
|
|
123
|
-
.div(numericConstants_1.MARK_PRICE_PRECISION)
|
|
124
|
-
.div(baseAssetReserveAfter);
|
|
125
|
-
markPriceAfter = (0, amm_1.calculatePrice)(baseAssetReserveAfter, quoteAssetReserveAfter, peg);
|
|
126
|
-
direction = types_1.PositionDirection.SHORT;
|
|
127
|
-
tradeSize = quoteAssetReserveBefore
|
|
128
|
-
.sub(quoteAssetReserveAfter)
|
|
129
|
-
.mul(peg)
|
|
130
|
-
.div(numericConstants_1.PEG_PRECISION)
|
|
131
|
-
.div(numericConstants_1.AMM_TO_QUOTE_PRECISION_RATIO);
|
|
132
|
-
baseSize = baseAssetReserveAfter.sub(baseAssetReserveBefore);
|
|
133
|
-
}
|
|
134
|
-
else if (markPriceBefore.lt(targetPrice)) {
|
|
135
|
-
// underestimate y2
|
|
136
|
-
baseAssetReserveAfter = (0, utils_1.squareRootBN)(k.div(targetPrice).mul(peg).div(numericConstants_1.PEG_PRECISION).add(biasModifier)).add(new anchor_1.BN(1));
|
|
137
|
-
quoteAssetReserveAfter = k
|
|
138
|
-
.div(numericConstants_1.MARK_PRICE_PRECISION)
|
|
139
|
-
.div(baseAssetReserveAfter);
|
|
140
|
-
markPriceAfter = (0, amm_1.calculatePrice)(baseAssetReserveAfter, quoteAssetReserveAfter, peg);
|
|
141
|
-
direction = types_1.PositionDirection.LONG;
|
|
142
|
-
tradeSize = quoteAssetReserveAfter
|
|
143
|
-
.sub(quoteAssetReserveBefore)
|
|
144
|
-
.mul(peg)
|
|
145
|
-
.div(numericConstants_1.PEG_PRECISION)
|
|
146
|
-
.div(numericConstants_1.AMM_TO_QUOTE_PRECISION_RATIO);
|
|
147
|
-
baseSize = baseAssetReserveBefore.sub(baseAssetReserveAfter);
|
|
148
|
-
}
|
|
149
|
-
else {
|
|
150
|
-
// no trade, market is at target
|
|
151
|
-
direction = types_1.PositionDirection.LONG;
|
|
152
|
-
tradeSize = numericConstants_1.ZERO;
|
|
153
|
-
return [direction, tradeSize, targetPrice, targetPrice];
|
|
154
|
-
}
|
|
155
|
-
let tp1 = targetPrice;
|
|
156
|
-
let tp2 = markPriceAfter;
|
|
157
|
-
let originalDiff = targetPrice.sub(markPriceBefore);
|
|
158
|
-
if (direction == types_1.PositionDirection.SHORT) {
|
|
159
|
-
tp1 = markPriceAfter;
|
|
160
|
-
tp2 = targetPrice;
|
|
161
|
-
originalDiff = markPriceBefore.sub(targetPrice);
|
|
162
|
-
}
|
|
163
|
-
const entryPrice = tradeSize
|
|
164
|
-
.mul(numericConstants_1.AMM_TO_QUOTE_PRECISION_RATIO)
|
|
165
|
-
.mul(numericConstants_1.MARK_PRICE_PRECISION)
|
|
166
|
-
.div(baseSize.abs());
|
|
167
|
-
(0, assert_1.assert)(tp1.sub(tp2).lte(originalDiff), 'Target Price Calculation incorrect');
|
|
168
|
-
(0, assert_1.assert)(tp2.lte(tp1) || tp2.sub(tp1).abs() < 100000, 'Target Price Calculation incorrect' +
|
|
169
|
-
tp2.toString() +
|
|
170
|
-
'>=' +
|
|
171
|
-
tp1.toString() +
|
|
172
|
-
'err: ' +
|
|
173
|
-
tp2.sub(tp1).abs().toString());
|
|
174
|
-
if (outputAssetType == 'quote') {
|
|
175
|
-
return [direction, tradeSize, entryPrice, targetPrice];
|
|
176
|
-
}
|
|
177
|
-
else {
|
|
178
|
-
return [direction, baseSize, entryPrice, targetPrice];
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
exports.calculateTargetPriceTrade = calculateTargetPriceTrade;
|
|
182
|
-
//# sourceMappingURL=trade.js.map
|
package/src/math/trade.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"trade.js","sourceRoot":"","sources":["trade.ts"],"names":[],"mappings":";;;AAAA,oCAAgE;AAChE,kDAA2C;AAC3C,6CAA0C;AAC1C,oEAMuC;AACvC,qCAA8C;AAC9C,+BAKe;AACf,mCAAuC;AAEvC,MAAM,MAAM,GAAG,IAAI,WAAE,CAAC,IAAI,CAAC,CAAC,CAAC,wCAAwC;AAerE;;;;;;;;;;;;;;GAcG;AACH,SAAgB,sBAAsB,CACrC,SAA4B,EAC5B,MAAU,EACV,MAAc,EACd,iBAA4B,OAAO;IAEnC,MAAM,QAAQ,GA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C,QAAQ,EAAE;QACd,IAAI;QACJ,GAAG,CAAC,QAAQ,EAAE;QACd,OAAO;QACP,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAC9B,CAAC;IACF,IAAI,eAAe,IAAI,OAAO,EAAE;QAC/B,OAAO,CAAC,SAAS,EAAE,SAAS,EAAE,UAAU,EAAE,WAAW,CAAC,CAAC;KACvD;SAAM;QACN,OAAO,CAAC,SAAS,EAAE,QAAQ,EAAE,UAAU,EAAE,WAAW,CAAC,CAAC;KACtD;AACF,CAAC;AArHD,8DAqHC"}
|
package/src/math/utils.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.squareRootBN = void 0;
|
|
4
|
-
const __1 = require("../");
|
|
5
|
-
const squareRootBN = (n, closeness = new __1.BN(1)) => {
|
|
6
|
-
// Assuming the sqrt of n as n only
|
|
7
|
-
let x = n;
|
|
8
|
-
// The closed guess will be stored in the root
|
|
9
|
-
let root;
|
|
10
|
-
// To count the number of iterations
|
|
11
|
-
let count = 0;
|
|
12
|
-
const TWO = new __1.BN(2);
|
|
13
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
14
|
-
while (count < Number.MAX_SAFE_INTEGER) {
|
|
15
|
-
count++;
|
|
16
|
-
// Calculate more closed x
|
|
17
|
-
root = x.add(n.div(x)).div(TWO);
|
|
18
|
-
// Check for closeness
|
|
19
|
-
if (x.sub(root).abs().lte(closeness))
|
|
20
|
-
break;
|
|
21
|
-
// Update root
|
|
22
|
-
x = root;
|
|
23
|
-
}
|
|
24
|
-
return root;
|
|
25
|
-
};
|
|
26
|
-
exports.squareRootBN = squareRootBN;
|
|
27
|
-
//# sourceMappingURL=utils.js.map
|
package/src/math/utils.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["utils.ts"],"names":[],"mappings":";;;AAAA,2BAAyB;AAElB,MAAM,YAAY,GAAG,CAAC,CAAC,EAAE,SAAS,GAAG,IAAI,MAAE,CAAC,CAAC,CAAC,EAAE,EAAE;IACxD,mCAAmC;IACnC,IAAI,CAAC,GAAG,CAAC,CAAC;IAEV,8CAA8C;IAC9C,IAAI,IAAI,CAAC;IAET,oCAAoC;IACpC,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,MAAM,GAAG,GAAG,IAAI,MAAE,CAAC,CAAC,CAAC,CAAC;IAEtB,6DAA6D;IAC7D,OAAO,KAAK,GAAG,MAAM,CAAC,gBAAgB,EAAE;QACvC,KAAK,EAAE,CAAC;QAER,0BAA0B;QAC1B,IAAI,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAEhC,sBAAsB;QACtB,IAAI,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,SAAS,CAAC;YAAE,MAAM;QAE5C,cAAc;QACd,CAAC,GAAG,IAAI,CAAC;KACT;IAED,OAAO,IAAI,CAAC;AACb,CAAC,CAAC;AA1BW,QAAA,YAAY,gBA0BvB"}
|
|
@@ -1,60 +0,0 @@
|
|
|
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.SwitchboardClient = void 0;
|
|
7
|
-
const switchboard_v2_1 = require("@switchboard-xyz/switchboard-v2");
|
|
8
|
-
const web3_js_1 = require("@solana/web3.js");
|
|
9
|
-
const anchor_1 = require("@project-serum/anchor");
|
|
10
|
-
const numericConstants_1 = require("../constants/numericConstants");
|
|
11
|
-
const wallet_1 = require("../wallet");
|
|
12
|
-
const switchboard_v2_json_1 = __importDefault(require("../idl/switchboard_v2.json"));
|
|
13
|
-
// cache switchboard program for every client object since itll always be the same
|
|
14
|
-
const programMap = new Map();
|
|
15
|
-
class SwitchboardClient {
|
|
16
|
-
constructor(connection, env) {
|
|
17
|
-
this.connection = connection;
|
|
18
|
-
this.env = env;
|
|
19
|
-
}
|
|
20
|
-
async getOraclePriceData(pricePublicKey) {
|
|
21
|
-
const accountInfo = await this.connection.getAccountInfo(pricePublicKey);
|
|
22
|
-
return this.getOraclePriceDataFromBuffer(accountInfo.data);
|
|
23
|
-
}
|
|
24
|
-
async getOraclePriceDataFromBuffer(buffer) {
|
|
25
|
-
const program = await this.getProgram();
|
|
26
|
-
const aggregatorAccountData = program.account.aggregatorAccountData.coder.accounts.decode('AggregatorAccountData', buffer);
|
|
27
|
-
const price = convertSwitchboardDecimal(aggregatorAccountData.latestConfirmedRound.result);
|
|
28
|
-
const confidence = convertSwitchboardDecimal(aggregatorAccountData.latestConfirmedRound
|
|
29
|
-
.stdDeviation);
|
|
30
|
-
const slot = aggregatorAccountData.latestConfirmedRound.roundOpenSlot;
|
|
31
|
-
return {
|
|
32
|
-
price,
|
|
33
|
-
slot,
|
|
34
|
-
confidence,
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
async getProgram() {
|
|
38
|
-
if (programMap.has(this.env)) {
|
|
39
|
-
return programMap.get(this.env);
|
|
40
|
-
}
|
|
41
|
-
const program = await getSwitchboardProgram(this.env, this.connection);
|
|
42
|
-
programMap.set(this.env, program);
|
|
43
|
-
return program;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
exports.SwitchboardClient = SwitchboardClient;
|
|
47
|
-
async function getSwitchboardProgram(env, connection) {
|
|
48
|
-
const DEFAULT_KEYPAIR = web3_js_1.Keypair.fromSeed(new Uint8Array(32).fill(1));
|
|
49
|
-
const programId = (0, switchboard_v2_1.getSwitchboardPid)(env);
|
|
50
|
-
const wallet = new wallet_1.Wallet(DEFAULT_KEYPAIR);
|
|
51
|
-
const provider = new anchor_1.Provider(connection, wallet, {});
|
|
52
|
-
return new anchor_1.Program(switchboard_v2_json_1.default, programId, provider);
|
|
53
|
-
}
|
|
54
|
-
function convertSwitchboardDecimal(switchboardDecimal) {
|
|
55
|
-
const switchboardPrecision = numericConstants_1.TEN.pow(new anchor_1.BN(switchboardDecimal.scale));
|
|
56
|
-
return switchboardDecimal.mantissa
|
|
57
|
-
.mul(numericConstants_1.MARK_PRICE_PRECISION)
|
|
58
|
-
.div(switchboardPrecision);
|
|
59
|
-
}
|
|
60
|
-
//# sourceMappingURL=switchboardClient.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"switchboardClient.js","sourceRoot":"","sources":["switchboardClient.ts"],"names":[],"mappings":";;;;;;AAAA,oEAGyC;AACzC,6CAAiE;AAEjE,kDAAmE;AACnE,oEAA0E;AAE1E,sCAAmC;AACnC,qFAA0D;AAE1D,kFAAkF;AAClF,MAAM,UAAU,GAAG,IAAI,GAAG,EAAmB,CAAC;AAE9C,MAAa,iBAAiB;IAI7B,YAAmB,UAAsB,EAAE,GAAa;QACvD,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;IAChB,CAAC;IAEM,KAAK,CAAC,kBAAkB,CAC9B,cAAyB;QAEzB,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,cAAc,CAAC,CAAC;QACzE,OAAO,IAAI,CAAC,4BAA4B,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IAC5D,CAAC;IAEM,KAAK,CAAC,4BAA4B,CACxC,MAAc;QAEd,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,UAAU,EAAE,CAAC;QAExC,MAAM,qBAAqB,GAC1B,OAAO,CAAC,OAAO,CAAC,qBAAqB,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAC1D,uBAAuB,EACvB,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