@paraswap/dex-lib 2.34.0 → 2.35.0
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/build/abi/api3-proxy.json +46 -0
- package/build/abi/api3-server-v1.json +463 -0
- package/build/abi/quick-perps/fast-price-events.json +70 -0
- package/build/abi/quick-perps/fast-price-feed.json +741 -0
- package/build/abi/quick-perps/reader.json +313 -0
- package/build/abi/quick-perps/vault-price-feed.json +323 -0
- package/build/abi/quick-perps/vault.json +1953 -0
- package/build/composed-event-subscriber.js +8 -2
- package/build/composed-event-subscriber.js.map +1 -1
- package/build/config.js +2 -2
- package/build/dex/index.js +2 -0
- package/build/dex/index.js.map +1 -1
- package/build/dex/quick-perps/config.d.ts +11 -0
- package/build/dex/quick-perps/config.js +27 -0
- package/build/dex/quick-perps/config.js.map +1 -0
- package/build/dex/quick-perps/fast-price-feed.d.ts +26 -0
- package/build/dex/quick-perps/fast-price-feed.js +176 -0
- package/build/dex/quick-perps/fast-price-feed.js.map +1 -0
- package/build/dex/quick-perps/pool.d.ts +21 -0
- package/build/dex/quick-perps/pool.js +210 -0
- package/build/dex/quick-perps/pool.js.map +1 -0
- package/build/dex/quick-perps/quick-perps.d.ts +52 -0
- package/build/dex/quick-perps/quick-perps.js +205 -0
- package/build/dex/quick-perps/quick-perps.js.map +1 -0
- package/build/dex/quick-perps/types.d.ts +98 -0
- package/build/dex/quick-perps/types.js +3 -0
- package/build/dex/quick-perps/types.js.map +1 -0
- package/build/dex/quick-perps/usdq.d.ts +15 -0
- package/build/dex/quick-perps/usdq.js +61 -0
- package/build/dex/quick-perps/usdq.js.map +1 -0
- package/build/dex/quick-perps/vault-price-feed.d.ts +43 -0
- package/build/dex/quick-perps/vault-price-feed.js +194 -0
- package/build/dex/quick-perps/vault-price-feed.js.map +1 -0
- package/build/dex/quick-perps/vault-utils.d.ts +8 -0
- package/build/dex/quick-perps/vault-utils.js +41 -0
- package/build/dex/quick-perps/vault-utils.js.map +1 -0
- package/build/dex/quick-perps/vault.d.ts +46 -0
- package/build/dex/quick-perps/vault.js +166 -0
- package/build/dex/quick-perps/vault.js.map +1 -0
- package/build/lib/api3-feed.d.ts +26 -0
- package/build/lib/api3-feed.js +82 -0
- package/build/lib/api3-feed.js.map +1 -0
- package/package.json +1 -1
- package/src/abi/api3-proxy.json +46 -0
- package/src/abi/api3-server-v1.json +463 -0
- package/src/abi/quick-perps/fast-price-events.json +70 -0
- package/src/abi/quick-perps/fast-price-feed.json +741 -0
- package/src/abi/quick-perps/reader.json +313 -0
- package/src/abi/quick-perps/vault-price-feed.json +323 -0
- package/src/abi/quick-perps/vault.json +1953 -0
- package/src/composed-event-subscriber.ts +16 -11
- package/src/config.ts +2 -2
- package/src/dex/index.ts +2 -0
- package/src/dex/quick-perps/config.ts +31 -0
- package/src/dex/quick-perps/fast-price-feed.ts +279 -0
- package/src/dex/quick-perps/pool.ts +372 -0
- package/src/dex/quick-perps/quick-perps-e2e.test.ts +65 -0
- package/src/dex/quick-perps/quick-perps-events.test.ts +101 -0
- package/src/dex/quick-perps/quick-perps-integration.test.ts +153 -0
- package/src/dex/quick-perps/quick-perps.ts +292 -0
- package/src/dex/quick-perps/types.ts +97 -0
- package/src/dex/quick-perps/usdq.ts +83 -0
- package/src/dex/quick-perps/vault-price-feed.ts +322 -0
- package/src/dex/quick-perps/vault-utils.ts +53 -0
- package/src/dex/quick-perps/vault.ts +290 -0
- package/src/lib/api3-feed.ts +140 -0
- package/tests/constants-e2e.ts +29 -0
- package/tests/tenderly-simulation.ts +46 -2
- package/tests/utils-e2e.ts +18 -10
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { Interface } from '@ethersproject/abi';
|
|
2
|
+
import { Token, Address, ExchangePrices, PoolPrices, AdapterExchangeParam, SimpleExchangeParam, PoolLiquidity, Logger } from '../../types';
|
|
3
|
+
import { SwapSide, Network } from '../../constants';
|
|
4
|
+
import { IDex } from '../idex';
|
|
5
|
+
import { IDexHelper } from '../../dex-helper/idex-helper';
|
|
6
|
+
import { QuickPerpsData, DexParams } from './types';
|
|
7
|
+
import { QuickPerpsEventPool } from './pool';
|
|
8
|
+
import { SimpleExchange } from '../simple-exchange';
|
|
9
|
+
export declare class QuickPerps extends SimpleExchange implements IDex<QuickPerpsData> {
|
|
10
|
+
protected network: Network;
|
|
11
|
+
protected dexHelper: IDexHelper;
|
|
12
|
+
protected adapters: {
|
|
13
|
+
[side: string]: {
|
|
14
|
+
name: string;
|
|
15
|
+
index: number;
|
|
16
|
+
}[] | null;
|
|
17
|
+
};
|
|
18
|
+
protected params: DexParams;
|
|
19
|
+
protected pool: QuickPerpsEventPool | null;
|
|
20
|
+
protected supportedTokensMap: {
|
|
21
|
+
[address: string]: boolean;
|
|
22
|
+
};
|
|
23
|
+
protected supportedTokens: Token[];
|
|
24
|
+
readonly hasConstantPriceLargeAmounts = false;
|
|
25
|
+
readonly needWrapNative = true;
|
|
26
|
+
readonly isFeeOnTransferSupported = false;
|
|
27
|
+
static dexKeysWithNetwork: {
|
|
28
|
+
key: string;
|
|
29
|
+
networks: Network[];
|
|
30
|
+
}[];
|
|
31
|
+
static erc20Interface: Interface;
|
|
32
|
+
vaultUSDBalance: number;
|
|
33
|
+
logger: Logger;
|
|
34
|
+
constructor(network: Network, dexKey: string, dexHelper: IDexHelper, adapters?: {
|
|
35
|
+
[side: string]: {
|
|
36
|
+
name: string;
|
|
37
|
+
index: number;
|
|
38
|
+
}[] | null;
|
|
39
|
+
}, params?: DexParams);
|
|
40
|
+
initializePricing(blockNumber: number): Promise<void>;
|
|
41
|
+
getAdapters(side: SwapSide): {
|
|
42
|
+
name: string;
|
|
43
|
+
index: number;
|
|
44
|
+
}[] | null;
|
|
45
|
+
getPoolIdentifiers(srcToken: Token, destToken: Token, side: SwapSide, blockNumber: number): Promise<string[]>;
|
|
46
|
+
getPricesVolume(srcToken: Token, destToken: Token, amounts: bigint[], side: SwapSide, blockNumber: number, limitPools?: string[]): Promise<null | ExchangePrices<QuickPerpsData>>;
|
|
47
|
+
getCalldataGasCost(poolPrices: PoolPrices<QuickPerpsData>): number | number[];
|
|
48
|
+
getAdapterParam(srcToken: string, destToken: string, srcAmount: string, destAmount: string, data: QuickPerpsData, side: SwapSide): AdapterExchangeParam;
|
|
49
|
+
getSimpleParam(srcToken: string, destToken: string, srcAmount: string, destAmount: string, data: QuickPerpsData, side: SwapSide): SimpleExchangeParam;
|
|
50
|
+
updatePoolState(): Promise<void>;
|
|
51
|
+
getTopPoolsForToken(_tokenAddress: Address, limit: number): Promise<PoolLiquidity[]>;
|
|
52
|
+
}
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.QuickPerps = void 0;
|
|
30
|
+
const abi_1 = require("@ethersproject/abi");
|
|
31
|
+
const constants_1 = require("../../constants");
|
|
32
|
+
const CALLDATA_GAS_COST = __importStar(require("../../calldata-gas-cost"));
|
|
33
|
+
const utils_1 = require("../../utils");
|
|
34
|
+
const pool_1 = require("./pool");
|
|
35
|
+
const simple_exchange_1 = require("../simple-exchange");
|
|
36
|
+
const config_1 = require("./config");
|
|
37
|
+
const vault_1 = require("./vault");
|
|
38
|
+
const erc20_json_1 = __importDefault(require("../../abi/erc20.json"));
|
|
39
|
+
const QuickPerpsGasCost = 300 * 1000;
|
|
40
|
+
class QuickPerps extends simple_exchange_1.SimpleExchange {
|
|
41
|
+
constructor(network, dexKey, dexHelper, adapters = config_1.Adapters[network], params = config_1.QuickPerpsConfig[dexKey][network]) {
|
|
42
|
+
super(dexHelper, dexKey);
|
|
43
|
+
this.network = network;
|
|
44
|
+
this.dexHelper = dexHelper;
|
|
45
|
+
this.adapters = adapters;
|
|
46
|
+
this.params = params;
|
|
47
|
+
this.pool = null;
|
|
48
|
+
this.supportedTokensMap = {};
|
|
49
|
+
// supportedTokens is only used by the pooltracker
|
|
50
|
+
this.supportedTokens = [];
|
|
51
|
+
this.hasConstantPriceLargeAmounts = false;
|
|
52
|
+
this.needWrapNative = true;
|
|
53
|
+
this.isFeeOnTransferSupported = false;
|
|
54
|
+
this.vaultUSDBalance = 0;
|
|
55
|
+
this.logger = dexHelper.getLogger(dexKey);
|
|
56
|
+
}
|
|
57
|
+
async initializePricing(blockNumber) {
|
|
58
|
+
const config = await pool_1.QuickPerpsEventPool.getConfig(this.params, blockNumber, this.dexHelper.multiContract);
|
|
59
|
+
config.tokenAddresses.forEach((token) => (this.supportedTokensMap[token] = true));
|
|
60
|
+
this.pool = new pool_1.QuickPerpsEventPool(this.dexKey, this.network, this.dexHelper, config);
|
|
61
|
+
await this.pool.initialize(blockNumber);
|
|
62
|
+
}
|
|
63
|
+
// Returns the list of contract adapters (name and index)
|
|
64
|
+
// for a buy/sell. Return null if there are no adapters.
|
|
65
|
+
getAdapters(side) {
|
|
66
|
+
return this.adapters[side];
|
|
67
|
+
}
|
|
68
|
+
// Returns list of pool identifiers that can be used
|
|
69
|
+
// for a given swap. poolIdentifiers must be unique
|
|
70
|
+
// across DEXes.
|
|
71
|
+
async getPoolIdentifiers(srcToken, destToken, side, blockNumber) {
|
|
72
|
+
if (side === constants_1.SwapSide.BUY || !this.pool)
|
|
73
|
+
return [];
|
|
74
|
+
const srcAddress = this.dexHelper.config
|
|
75
|
+
.wrapETH(srcToken)
|
|
76
|
+
.address.toLowerCase();
|
|
77
|
+
const destAddress = this.dexHelper.config
|
|
78
|
+
.wrapETH(destToken)
|
|
79
|
+
.address.toLowerCase();
|
|
80
|
+
if (srcAddress !== destAddress &&
|
|
81
|
+
this.supportedTokensMap[srcAddress] &&
|
|
82
|
+
this.supportedTokensMap[destAddress]) {
|
|
83
|
+
return [`${this.dexKey}_${srcAddress}`, `${this.dexKey}_${destAddress}`];
|
|
84
|
+
}
|
|
85
|
+
return [];
|
|
86
|
+
}
|
|
87
|
+
// Returns pool prices for amounts.
|
|
88
|
+
// If limitPools is defined only pools in limitPools
|
|
89
|
+
// should be used. If limitPools is undefined then
|
|
90
|
+
// any pools can be used.
|
|
91
|
+
async getPricesVolume(srcToken, destToken, amounts, side, blockNumber, limitPools) {
|
|
92
|
+
if (side === constants_1.SwapSide.BUY || !this.pool)
|
|
93
|
+
return null;
|
|
94
|
+
const srcAddress = this.dexHelper.config
|
|
95
|
+
.wrapETH(srcToken)
|
|
96
|
+
.address.toLowerCase();
|
|
97
|
+
const destAddress = this.dexHelper.config
|
|
98
|
+
.wrapETH(destToken)
|
|
99
|
+
.address.toLowerCase();
|
|
100
|
+
if (srcAddress === destAddress ||
|
|
101
|
+
!(this.supportedTokensMap[srcAddress] &&
|
|
102
|
+
this.supportedTokensMap[destAddress]))
|
|
103
|
+
return null;
|
|
104
|
+
const srcPoolIdentifier = `${this.dexKey}_${srcAddress}`;
|
|
105
|
+
const destPoolIdentifier = `${this.dexKey}_${destAddress}`;
|
|
106
|
+
const pools = [srcPoolIdentifier, destPoolIdentifier];
|
|
107
|
+
if (limitPools && pools.some(p => !limitPools.includes(p)))
|
|
108
|
+
return null;
|
|
109
|
+
const unitVolume = (0, utils_1.getBigIntPow)(srcToken.decimals);
|
|
110
|
+
const prices = await this.pool.getAmountOut(srcAddress, destAddress, [unitVolume, ...amounts], blockNumber);
|
|
111
|
+
if (!prices)
|
|
112
|
+
return null;
|
|
113
|
+
return [
|
|
114
|
+
{
|
|
115
|
+
prices: prices.slice(1),
|
|
116
|
+
unit: prices[0],
|
|
117
|
+
gasCost: QuickPerpsGasCost,
|
|
118
|
+
exchange: this.dexKey,
|
|
119
|
+
data: {},
|
|
120
|
+
poolAddresses: [this.params.vault],
|
|
121
|
+
},
|
|
122
|
+
];
|
|
123
|
+
}
|
|
124
|
+
// Returns estimated gas cost of calldata for this DEX in multiSwap
|
|
125
|
+
getCalldataGasCost(poolPrices) {
|
|
126
|
+
return CALLDATA_GAS_COST.DEX_NO_PAYLOAD;
|
|
127
|
+
}
|
|
128
|
+
getAdapterParam(srcToken, destToken, srcAmount, destAmount, data, side) {
|
|
129
|
+
return {
|
|
130
|
+
targetExchange: this.params.vault,
|
|
131
|
+
payload: '0x',
|
|
132
|
+
networkFee: '0',
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
getSimpleParam(srcToken, destToken, srcAmount, destAmount, data, side) {
|
|
136
|
+
return {
|
|
137
|
+
callees: [srcToken, this.params.vault],
|
|
138
|
+
calldata: [
|
|
139
|
+
QuickPerps.erc20Interface.encodeFunctionData('transfer', [
|
|
140
|
+
this.params.vault,
|
|
141
|
+
srcAmount,
|
|
142
|
+
]),
|
|
143
|
+
vault_1.Vault.interface.encodeFunctionData('swap', [
|
|
144
|
+
srcToken,
|
|
145
|
+
destToken,
|
|
146
|
+
this.augustusAddress,
|
|
147
|
+
]),
|
|
148
|
+
],
|
|
149
|
+
values: ['0', '0'],
|
|
150
|
+
networkFee: '0',
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
async updatePoolState() {
|
|
154
|
+
if (!this.supportedTokens.length) {
|
|
155
|
+
const tokenAddresses = await pool_1.QuickPerpsEventPool.getWhitelistedTokens(this.params.vault, 'latest', this.dexHelper.multiContract);
|
|
156
|
+
const decimalsCallData = QuickPerps.erc20Interface.encodeFunctionData('decimals');
|
|
157
|
+
const tokenBalanceMultiCall = tokenAddresses.map(t => ({
|
|
158
|
+
target: t,
|
|
159
|
+
callData: decimalsCallData,
|
|
160
|
+
}));
|
|
161
|
+
const res = (await this.dexHelper.multiContract.methods
|
|
162
|
+
.aggregate(tokenBalanceMultiCall)
|
|
163
|
+
.call()).returnData;
|
|
164
|
+
const tokenDecimals = res.map((r) => parseInt(QuickPerps.erc20Interface
|
|
165
|
+
.decodeFunctionResult('decimals', r)[0]
|
|
166
|
+
.toString()));
|
|
167
|
+
this.supportedTokens = tokenAddresses.map((t, i) => ({
|
|
168
|
+
address: t,
|
|
169
|
+
decimals: tokenDecimals[i],
|
|
170
|
+
}));
|
|
171
|
+
}
|
|
172
|
+
const erc20BalanceCalldata = QuickPerps.erc20Interface.encodeFunctionData('balanceOf', [this.params.vault]);
|
|
173
|
+
const tokenBalanceMultiCall = this.supportedTokens.map(t => ({
|
|
174
|
+
target: t.address,
|
|
175
|
+
callData: erc20BalanceCalldata,
|
|
176
|
+
}));
|
|
177
|
+
const res = (await this.dexHelper.multiContract.methods
|
|
178
|
+
.aggregate(tokenBalanceMultiCall)
|
|
179
|
+
.call()).returnData;
|
|
180
|
+
const tokenBalances = res.map((r) => BigInt(QuickPerps.erc20Interface
|
|
181
|
+
.decodeFunctionResult('balanceOf', r)[0]
|
|
182
|
+
.toString()));
|
|
183
|
+
const tokenBalancesUSD = await Promise.all(this.supportedTokens.map((t, i) => this.dexHelper.getTokenUSDPrice(t, tokenBalances[i])));
|
|
184
|
+
this.vaultUSDBalance = tokenBalancesUSD.reduce((sum, curr) => sum + curr);
|
|
185
|
+
}
|
|
186
|
+
// Returns list of top pools based on liquidity. Max
|
|
187
|
+
// limit number pools should be returned.
|
|
188
|
+
async getTopPoolsForToken(_tokenAddress, limit) {
|
|
189
|
+
const tokenAddress = _tokenAddress.toLowerCase();
|
|
190
|
+
if (!this.supportedTokens.some(t => t.address === tokenAddress))
|
|
191
|
+
return [];
|
|
192
|
+
return [
|
|
193
|
+
{
|
|
194
|
+
exchange: this.dexKey,
|
|
195
|
+
address: this.params.vault,
|
|
196
|
+
connectorTokens: this.supportedTokens.filter(t => t.address !== tokenAddress),
|
|
197
|
+
liquidityUSD: this.vaultUSDBalance,
|
|
198
|
+
},
|
|
199
|
+
];
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
exports.QuickPerps = QuickPerps;
|
|
203
|
+
QuickPerps.dexKeysWithNetwork = (0, utils_1.getDexKeysWithNetwork)(config_1.QuickPerpsConfig);
|
|
204
|
+
QuickPerps.erc20Interface = new abi_1.Interface(erc20_json_1.default);
|
|
205
|
+
//# sourceMappingURL=quick-perps.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"quick-perps.js","sourceRoot":"","sources":["../../../src/dex/quick-perps/quick-perps.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4CAA+C;AAY/C,+CAAoD;AACpD,2EAA6D;AAC7D,uCAAkE;AAIlE,iCAA6C;AAC7C,wDAAoD;AACpD,qCAAsD;AACtD,mCAAgC;AAChC,sEAA4C;AAE5C,MAAM,iBAAiB,GAAG,GAAG,GAAG,IAAI,CAAC;AAErC,MAAa,UAAW,SAAQ,gCAAc;IAmB5C,YACY,OAAgB,EAC1B,MAAc,EACJ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,MAAM,OAAO,CAAC,GAAG,CACxC,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAChC,IAAI,CAAC,SAAS,CAAC,gBAAgB,CAAC,CAAC,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC,CACrD,CACF,CAAC;QACF,IAAI,CAAC,eAAe,GAAG,gBAAgB,CAAC,MAAM,CAC5C,CAAC,GAAW,EAAE,IAAY,EAAE,EAAE,CAAC,GAAG,GAAG,IAAI,CAC1C,CAAC;IACJ,CAAC;IAED,oDAAoD;IACpD,yCAAyC;IACzC,KAAK,CAAC,mBAAmB,CACvB,aAAsB,EACtB,KAAa;QAEb,MAAM,YAAY,GAAG,aAAa,CAAC,WAAW,EAAE,CAAC;QACjD,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,KAAK,YAAY,CAAC;YAAE,OAAO,EAAE,CAAC;QAC3E,OAAO;YACL;gBACE,QAAQ,EAAE,IAAI,CAAC,MAAM;gBACrB,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,KAAK;gBAC1B,eAAe,EAAE,IAAI,CAAC,eAAe,CAAC,MAAM,CAC1C,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,KAAK,YAAY,CAChC;gBACD,YAAY,EAAE,IAAI,CAAC,eAAe;aACnC;SACF,CAAC;IACJ,CAAC;;AAxQH,gCAyQC;AA/Pe,6BAAkB,GAC9B,IAAA,6BAAqB,EAAC,yBAAgB,CAAC,CAAC;AAE5B,yBAAc,GAAG,IAAI,eAAS,CAAC,oBAAQ,CAAC,CAAC"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { Address } from '../../types';
|
|
2
|
+
import { Api3FeedSubscriberState } from '../../lib/api3-feed';
|
|
3
|
+
export declare type PoolState = {
|
|
4
|
+
primaryPrices: {
|
|
5
|
+
[poolAddress: string]: Api3FeedSubscriberState;
|
|
6
|
+
};
|
|
7
|
+
secondaryPrices: FastPriceFeedState;
|
|
8
|
+
vault: VaultState;
|
|
9
|
+
usdq: USDQState;
|
|
10
|
+
};
|
|
11
|
+
export declare type FastPriceFeedState = {
|
|
12
|
+
lastUpdatedAt: number;
|
|
13
|
+
prices: {
|
|
14
|
+
[tokenAddress: string]: bigint;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
export declare type VaultState = {
|
|
18
|
+
usdqAmounts: {
|
|
19
|
+
[tokenAddress: string]: bigint;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
export declare type USDQState = {
|
|
23
|
+
totalSupply: bigint;
|
|
24
|
+
};
|
|
25
|
+
export declare type QuickPerpsData = {};
|
|
26
|
+
export declare type DexParams = {
|
|
27
|
+
vault: Address;
|
|
28
|
+
reader: Address;
|
|
29
|
+
priceFeed: Address;
|
|
30
|
+
fastPriceFeed: Address;
|
|
31
|
+
fastPriceEvents: Address;
|
|
32
|
+
usdq: Address;
|
|
33
|
+
};
|
|
34
|
+
export declare type FastPriceFeedConfig = {
|
|
35
|
+
priceDuration: number;
|
|
36
|
+
maxDeviationBasisPoints: bigint;
|
|
37
|
+
favorFastPrice: Record<string, boolean>;
|
|
38
|
+
spreadBasisPointsIfInactive: bigint;
|
|
39
|
+
spreadBasisPointsIfChainError: bigint;
|
|
40
|
+
maxPriceUpdateDelay: number;
|
|
41
|
+
};
|
|
42
|
+
export declare type VaultPriceFeedConfig = {
|
|
43
|
+
isSecondaryPriceEnabled: boolean;
|
|
44
|
+
strictStableTokens: {
|
|
45
|
+
[address: string]: boolean;
|
|
46
|
+
};
|
|
47
|
+
spreadBasisPoints: {
|
|
48
|
+
[address: string]: bigint;
|
|
49
|
+
};
|
|
50
|
+
adjustmentBasisPoints: {
|
|
51
|
+
[address: string]: bigint;
|
|
52
|
+
};
|
|
53
|
+
isAdjustmentAdditive: {
|
|
54
|
+
[address: string]: boolean;
|
|
55
|
+
};
|
|
56
|
+
priceDecimals: {
|
|
57
|
+
[address: string]: number;
|
|
58
|
+
};
|
|
59
|
+
maxStrictPriceDeviation: bigint;
|
|
60
|
+
};
|
|
61
|
+
export declare type VaultConfig = {
|
|
62
|
+
tokenDecimals: {
|
|
63
|
+
[address: string]: number;
|
|
64
|
+
};
|
|
65
|
+
stableTokens: {
|
|
66
|
+
[address: string]: boolean;
|
|
67
|
+
};
|
|
68
|
+
tokenWeights: {
|
|
69
|
+
[address: string]: bigint;
|
|
70
|
+
};
|
|
71
|
+
stableSwapFeeBasisPoints: bigint;
|
|
72
|
+
swapFeeBasisPoints: bigint;
|
|
73
|
+
stableTaxBasisPoints: bigint;
|
|
74
|
+
taxBasisPoints: bigint;
|
|
75
|
+
hasDynamicFees: bigint;
|
|
76
|
+
includeAmmPrice: boolean;
|
|
77
|
+
useSwapPricing: boolean;
|
|
78
|
+
totalTokenWeights: bigint;
|
|
79
|
+
};
|
|
80
|
+
export declare type PoolConfig = {
|
|
81
|
+
vaultAddress: Address;
|
|
82
|
+
readerAddress: Address;
|
|
83
|
+
priceFeed: Address;
|
|
84
|
+
fastPriceFeed: Address;
|
|
85
|
+
fastPriceEvents: Address;
|
|
86
|
+
usdqAddress: Address;
|
|
87
|
+
tokenAddresses: Address[];
|
|
88
|
+
vaultConfig: VaultConfig;
|
|
89
|
+
vaultPriceFeedConfig: VaultPriceFeedConfig;
|
|
90
|
+
fastPriceFeedConfig: FastPriceFeedConfig;
|
|
91
|
+
api3ServerV1: {
|
|
92
|
+
[address: string]: {
|
|
93
|
+
proxy: Address;
|
|
94
|
+
api3ServerV1: Address;
|
|
95
|
+
dataFeedId: string;
|
|
96
|
+
};
|
|
97
|
+
};
|
|
98
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/dex/quick-perps/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Interface } from '@ethersproject/abi';
|
|
2
|
+
import { DeepReadonly } from 'ts-essentials';
|
|
3
|
+
import { PartialEventSubscriber } from '../../composed-event-subscriber';
|
|
4
|
+
import { Address, MultiCallInput, MultiCallOutput, Logger, Log, BlockHeader } from '../../types';
|
|
5
|
+
import { USDQState } from './types';
|
|
6
|
+
import { Lens } from '../../lens';
|
|
7
|
+
export declare class USDQ<State> extends PartialEventSubscriber<State, USDQState> {
|
|
8
|
+
private usdqAddress;
|
|
9
|
+
static readonly interface: Interface;
|
|
10
|
+
constructor(usdqAddress: Address, lens: Lens<DeepReadonly<State>, DeepReadonly<USDQState>>, logger: Logger);
|
|
11
|
+
getTotalSupply(state: DeepReadonly<State>): bigint;
|
|
12
|
+
processLog(state: DeepReadonly<USDQState>, log: Readonly<Log>, blockHeader: Readonly<BlockHeader>): DeepReadonly<USDQState> | null;
|
|
13
|
+
getGenerateStateMultiCallInputs(): MultiCallInput[];
|
|
14
|
+
generateState(multicallOutputs: MultiCallOutput[], blockNumber?: number | 'latest'): DeepReadonly<USDQState>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
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.USDQ = void 0;
|
|
7
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
8
|
+
const abi_1 = require("@ethersproject/abi");
|
|
9
|
+
const composed_event_subscriber_1 = require("../../composed-event-subscriber");
|
|
10
|
+
const erc20_json_1 = __importDefault(require("../../abi/erc20.json"));
|
|
11
|
+
const constants_1 = require("../../constants");
|
|
12
|
+
class USDQ extends composed_event_subscriber_1.PartialEventSubscriber {
|
|
13
|
+
constructor(usdqAddress, lens, logger) {
|
|
14
|
+
super([usdqAddress], lens, logger);
|
|
15
|
+
this.usdqAddress = usdqAddress;
|
|
16
|
+
}
|
|
17
|
+
getTotalSupply(state) {
|
|
18
|
+
return this.lens.get()(state).totalSupply;
|
|
19
|
+
}
|
|
20
|
+
processLog(state, log, blockHeader) {
|
|
21
|
+
try {
|
|
22
|
+
const parsed = USDQ.interface.parseLog(log);
|
|
23
|
+
const _state = lodash_1.default.cloneDeep(state);
|
|
24
|
+
switch (parsed.name) {
|
|
25
|
+
case 'Transfer': {
|
|
26
|
+
const fromAddress = parsed.args.src;
|
|
27
|
+
const toAddress = parsed.args.dst;
|
|
28
|
+
if (fromAddress === constants_1.NULL_ADDRESS) {
|
|
29
|
+
_state.totalSupply += BigInt(parsed.args.wad.toString());
|
|
30
|
+
}
|
|
31
|
+
else if (toAddress === constants_1.NULL_ADDRESS) {
|
|
32
|
+
_state.totalSupply -= BigInt(parsed.args.wad.toString());
|
|
33
|
+
}
|
|
34
|
+
return _state;
|
|
35
|
+
}
|
|
36
|
+
default:
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
catch (e) {
|
|
41
|
+
this.logger.error('Failed to parse log', e);
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
getGenerateStateMultiCallInputs() {
|
|
46
|
+
return [
|
|
47
|
+
{
|
|
48
|
+
target: this.usdqAddress,
|
|
49
|
+
callData: USDQ.interface.encodeFunctionData('totalSupply'),
|
|
50
|
+
},
|
|
51
|
+
];
|
|
52
|
+
}
|
|
53
|
+
generateState(multicallOutputs, blockNumber) {
|
|
54
|
+
return {
|
|
55
|
+
totalSupply: BigInt(USDQ.interface.decodeFunctionResult('totalSupply', multicallOutputs[0])[0]),
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
exports.USDQ = USDQ;
|
|
60
|
+
USDQ.interface = new abi_1.Interface(erc20_json_1.default);
|
|
61
|
+
//# sourceMappingURL=usdq.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usdq.js","sourceRoot":"","sources":["../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C,EAAE;YACV,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,qBAAqB,EAAE,CAAC,CAAC,CAAC;YAC5C,OAAO,IAAI,CAAC;SACb;IACH,CAAC;IAEM,+BAA+B;QACpC,OAAO;YACL;gBACE,MAAM,EAAE,IAAI,CAAC,WAAW;gBACxB,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC,kBAAkB,CAAC,aAAa,CAAC;aAC3D;SACF,CAAC;IACJ,CAAC;IAEM,aAAa,CAClB,gBAAmC,EACnC,WAA+B;QAE/B,OAAO;YACL,WAAW,EAAE,MAAM,CACjB,IAAI,CAAC,SAAS,CAAC,oBAAoB,CACjC,aAAa,EACb,gBAAgB,CAAC,CAAC,CAAC,CACpB,CAAC,CAAC,CAAC,CACL;SACF,CAAC;IACJ,CAAC;;AAhEH,oBAiEC;AAhEiB,cAAS,GAAG,IAAI,eAAS,CAAC,oBAAQ,CAAC,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Interface } from '@ethersproject/abi';
|
|
2
|
+
import { Address, MultiCallInput, MultiCallOutput } from '../../types';
|
|
3
|
+
import { VaultPriceFeedConfig } from './types';
|
|
4
|
+
import { FastPriceFeed } from './fast-price-feed';
|
|
5
|
+
import { DeepReadonly } from 'ts-essentials';
|
|
6
|
+
import { Api3FeedSubscriber } from '../../lib/api3-feed';
|
|
7
|
+
export declare class VaultPriceFeed<State> {
|
|
8
|
+
protected primaryPrices: {
|
|
9
|
+
[token: string]: Api3FeedSubscriber<State>;
|
|
10
|
+
};
|
|
11
|
+
protected secondaryPrice: FastPriceFeed<State>;
|
|
12
|
+
BASIS_POINTS_DIVISOR: bigint;
|
|
13
|
+
PRICE_PRECISION: bigint;
|
|
14
|
+
ONE_USD: bigint;
|
|
15
|
+
static interface: Interface;
|
|
16
|
+
protected isSecondaryPriceEnabled: boolean;
|
|
17
|
+
protected strictStableTokens: {
|
|
18
|
+
[address: string]: boolean;
|
|
19
|
+
};
|
|
20
|
+
protected spreadBasisPoints: {
|
|
21
|
+
[address: string]: bigint;
|
|
22
|
+
};
|
|
23
|
+
protected adjustmentBasisPoints: {
|
|
24
|
+
[address: string]: bigint;
|
|
25
|
+
};
|
|
26
|
+
protected isAdjustmentAdditive: {
|
|
27
|
+
[address: string]: boolean;
|
|
28
|
+
};
|
|
29
|
+
protected priceDecimals: {
|
|
30
|
+
[address: string]: number;
|
|
31
|
+
};
|
|
32
|
+
protected maxStrictPriceDeviation: bigint;
|
|
33
|
+
constructor(config: VaultPriceFeedConfig, primaryPrices: {
|
|
34
|
+
[token: string]: Api3FeedSubscriber<State>;
|
|
35
|
+
}, secondaryPrice: FastPriceFeed<State>);
|
|
36
|
+
getPrice(state: DeepReadonly<State>, _token: Address, _maximize: boolean, _includeAmmPrice: boolean, _useSwapPricing: boolean): bigint;
|
|
37
|
+
getPriceV1(state: DeepReadonly<State>, _token: Address, _maximize: boolean, _includeAmmPrice: boolean): bigint;
|
|
38
|
+
getAmmPrice(state: DeepReadonly<State>, token: Address): bigint;
|
|
39
|
+
getPrimaryPrice(state: DeepReadonly<State>, _token: Address, _maximize: boolean): bigint;
|
|
40
|
+
getSecondaryPrice(state: DeepReadonly<State>, _token: Address, _referencePrice: bigint, _maximize: boolean): bigint;
|
|
41
|
+
static getConfigMulticallInputs(vaultPriceFeedAddress: Address, tokenAddresses: Address[]): MultiCallInput[];
|
|
42
|
+
static getConfig(multicallOutputs: MultiCallOutput[], tokenAddress: Address[]): VaultPriceFeedConfig;
|
|
43
|
+
}
|