-
Notifications
You must be signed in to change notification settings - Fork 0
/
SuUniV3Oracle.json
446 lines (446 loc) · 128 KB
/
SuUniV3Oracle.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
{
"address": "0xfC53A3BD002710Eb5D1EF70a85fE62da8a3dA3bE",
"abi": [
{
"inputs": [],
"name": "BadAccessControlSingleton",
"type": "error"
},
{
"inputs": [],
"name": "InvalidToken",
"type": "error"
},
{
"inputs": [],
"name": "OnlyAdminError",
"type": "error"
},
{
"inputs": [],
"name": "OnlyAlerterError",
"type": "error"
},
{
"inputs": [],
"name": "OnlyDAOError",
"type": "error"
},
{
"inputs": [],
"name": "OnlyLiquidationAccessError",
"type": "error"
},
{
"inputs": [],
"name": "OnlyMintAccessError",
"type": "error"
},
{
"inputs": [],
"name": "OnlyRewardAccessError",
"type": "error"
},
{
"inputs": [],
"name": "OnlyRoleError",
"type": "error"
},
{
"inputs": [],
"name": "OnlyVaultAccessError",
"type": "error"
},
{
"inputs": [],
"name": "T",
"type": "error"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "uint8",
"name": "version",
"type": "uint8"
}
],
"name": "Initialized",
"type": "event"
},
{
"inputs": [],
"name": "ACCESS_CONTROL_SINGLETON",
"outputs": [
{
"internalType": "contract ISuAccessControl",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "ADMIN_ROLE",
"outputs": [
{
"internalType": "bytes32",
"name": "",
"type": "bytes32"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "ALERTER_ROLE",
"outputs": [
{
"internalType": "bytes32",
"name": "",
"type": "bytes32"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "DAO_ROLE",
"outputs": [
{
"internalType": "bytes32",
"name": "",
"type": "bytes32"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "LIQUIDATION_ACCESS_ROLE",
"outputs": [
{
"internalType": "bytes32",
"name": "",
"type": "bytes32"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "MINT_ACCESS_ROLE",
"outputs": [
{
"internalType": "bytes32",
"name": "",
"type": "bytes32"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "ORACLE",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "REWARD_ACCESS_ROLE",
"outputs": [
{
"internalType": "bytes32",
"name": "",
"type": "bytes32"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "UNISWAP_FACTORY",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "USDT",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "VAULT_ACCESS_ROLE",
"outputs": [
{
"internalType": "bytes32",
"name": "",
"type": "bytes32"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"name": "assetToPool",
"outputs": [
{
"internalType": "contract IUniswapV3Pool",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_asset",
"type": "address"
},
{
"internalType": "uint24",
"name": "_fee",
"type": "uint24"
}
],
"name": "enableAssetPool",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "asset",
"type": "address"
}
],
"name": "getFiatPrice1e18",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_authControl",
"type": "address"
},
{
"internalType": "address",
"name": "_UNISWAP_FACTORY",
"type": "address"
},
{
"internalType": "address",
"name": "_USDT",
"type": "address"
},
{
"internalType": "address",
"name": "_ORACLE",
"type": "address"
}
],
"name": "initialize",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "bytes4",
"name": "interfaceId",
"type": "bytes4"
}
],
"name": "supportsInterface",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "view",
"type": "function"
}
],
"numDeployments": 1,
"solcInputHash": "6bdb767f00e3f0fe0de7c63e7a48801d",
"metadata": "{\"compiler\":{\"version\":\"0.8.17+commit.8df45f5f\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[],\"name\":\"BadAccessControlSingleton\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InvalidToken\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"OnlyAdminError\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"OnlyAlerterError\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"OnlyDAOError\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"OnlyLiquidationAccessError\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"OnlyMintAccessError\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"OnlyRewardAccessError\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"OnlyRoleError\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"OnlyVaultAccessError\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"T\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint8\",\"name\":\"version\",\"type\":\"uint8\"}],\"name\":\"Initialized\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"ACCESS_CONTROL_SINGLETON\",\"outputs\":[{\"internalType\":\"contract ISuAccessControl\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"ADMIN_ROLE\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"ALERTER_ROLE\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"DAO_ROLE\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"LIQUIDATION_ACCESS_ROLE\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"MINT_ACCESS_ROLE\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"ORACLE\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"REWARD_ACCESS_ROLE\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"UNISWAP_FACTORY\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"USDT\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"VAULT_ACCESS_ROLE\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"assetToPool\",\"outputs\":[{\"internalType\":\"contract IUniswapV3Pool\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_asset\",\"type\":\"address\"},{\"internalType\":\"uint24\",\"name\":\"_fee\",\"type\":\"uint24\"}],\"name\":\"enableAssetPool\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"asset\",\"type\":\"address\"}],\"name\":\"getFiatPrice1e18\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_authControl\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_UNISWAP_FACTORY\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_USDT\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_ORACLE\",\"type\":\"address\"}],\"name\":\"initialize\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes4\",\"name\":\"interfaceId\",\"type\":\"bytes4\"}],\"name\":\"supportsInterface\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"details\":\"Here we calculate only the price of asset in USDT, not USD. Before that we need to enableAssetPool, to know what pool use for that asset (what fees). See ISuUniV3Oracle interface for full details.*\",\"kind\":\"dev\",\"methods\":{\"getFiatPrice1e18(address)\":{\"params\":{\"asset\":\"- address of erc20 token contract\"},\"returns\":{\"_0\":\"usdPrice1e18 such that asset.balanceOf() * getFiatPrice1e18(asset) / 1e18 == $$ * 1e18*\"}},\"supportsInterface(bytes4)\":{\"details\":\"Returns true if this contract implements the interface defined by `interfaceId`. See the corresponding https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] to learn more about how these ids are created. This function call must use less than 30 000 gas.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"getFiatPrice1e18(address)\":{\"notice\":\"WARNING! Read this description very carefully! function getFiatPrice1e18(address asset) returns (uint256) that: basicAmountOfAsset * getFiatPrice1e18(asset) / 1e18 === $$ * 1e18 in other words, it doesn't matter what's the erc20.decimals is, you just multiply token balance in basic units on value from oracle and get dollar amount multiplied on 1e18. different assets have different deviation threshold (errors) for wBTC it's <= 0.5%, read more https://data.chain.link/ethereum/mainnet/crypto-usd/btc-usd for other asset is can be larger based on particular oracle implementation. examples: market price of btc = $30k, for 0.1 wBTC the unit256 amount is 0.1 * 1e18 0.1 * 1e18 * (price1e18 / 1e18) == $3000 == uint256(3000*1e18) => price1e18 = 30000 * 1e18; market price of usdt = $0.97, for 1 usdt uint256 = 1 * 1e6 so 1*1e6 * price1e18 / 1e18 == $0.97 == uint256(0.97*1e18) => 1*1e6 * (price1e18 / 1e18) / (0.97*1e18) = 1 => price1e18 = 0.97 * (1e18/1e6) * 1e18 assume market price of wBTC = $31,503.77, oracle error = $158 case #1: small amount of wBTC we have 0.0,000,001 wBTC that is worth v = $0.00315 \\u00b1 $0.00001 = 0.00315*1e18 = 315*1e13 \\u00b1 1*1e13 actual balance on the asset b = wBTC.balanceOf() = 0.0000001*1e18 = 1e11 oracle should return or = oracle.getFiatPrice1e18(wBTC) <=> <=> b*or = v => v/b = 315*1e13 / 1e11 = 315*1e2 \\u00b1 1e2 error = or.error * b = 1e2 * 1e11 = 1e13 => 1e13/1e18 usd = 1e-5 = 0.00001 usd case #2: large amount of wBTC v = 2,000,000 wBTC = $31,503.77 * 2m \\u00b1 158*2m = $63,007,540,000 \\u00b1 $316,000,000 = 63,007*1e24 \\u00b1 316*1e24 for calc convenience we increase error on 0.05 and have v = 63,000*24 \\u00b1 300*1e24 = (630 \\u00b1 3)*1e26 b = 2*1e6 * 1e18 = 2*1e24 or = v/b = (630 \\u00b1 3)*1e26 / 2*1e24 = 315*1e2 \\u00b1 1.5*1e2 error = or.error * b = 1.5*100 * 2*1e24 = 3*1e26 = 3*1e8*1e18 = $300,000,000 ~ $316,000,000 assume the market price of USDT = $0.97 \\u00b1 $0.00485, case #3: little amount of USDT v = USDT amount 0.005 = 0.005*(0.97 \\u00b1 0.00485) = 0.00485*1e18 \\u00b1 0.00002425*1e18 = 485*1e13 \\u00b1 3*1e13 we rounded error up on (3000-2425)/2425 ~= +24% for calculation convenience. b = USDT.balanceOf() = 0.005*1e6 = 5*1e3 b*or = v => or = v/b = (485*1e13 \\u00b1 3*1e13) / 5*1e3 = 970*1e9 \\u00b1 6*1e9 error = 6*1e9 * 5*1e3 / 1e18 = 30*1e12/1e18 = 3*1e-5 = $0,00005 case #4: lot of USDT v = we have 100,000,000,000 USDT = $97B = 97*1e9*1e18 \\u00b1 0.5*1e9*1e18 b = USDT.balanceOf() = 1e11*1e6 = 1e17 or = v/b = (97*1e9*1e18 \\u00b1 0.5*1e9*1e18) / 1e17 = 970*1e9 \\u00b1 5*1e9 error = 5*1e9 * 1e17 = 5*1e26 = 0.5 * 1e8*1e18\"}},\"notice\":\"check SuUniV3Oracle section in ORACLE_ARCHITECTURE.md\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/periphery/contracts/oracle/SuUniV3Oracle.sol\":\"SuUniV3Oracle\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":1},\"remappings\":[],\"viaIR\":true},\"sources\":{\"@openzeppelin/contracts-upgradeable/access/IAccessControlUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev External interface of AccessControl declared to support ERC165 detection.\\n */\\ninterface IAccessControlUpgradeable {\\n /**\\n * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\\n *\\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\\n * {RoleAdminChanged} not being emitted signaling this.\\n *\\n * _Available since v3.1._\\n */\\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\\n\\n /**\\n * @dev Emitted when `account` is granted `role`.\\n *\\n * `sender` is the account that originated the contract call, an admin role\\n * bearer except when using {AccessControl-_setupRole}.\\n */\\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\\n\\n /**\\n * @dev Emitted when `account` is revoked `role`.\\n *\\n * `sender` is the account that originated the contract call:\\n * - if using `revokeRole`, it is the admin role bearer\\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\\n */\\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\\n\\n /**\\n * @dev Returns `true` if `account` has been granted `role`.\\n */\\n function hasRole(bytes32 role, address account) external view returns (bool);\\n\\n /**\\n * @dev Returns the admin role that controls `role`. See {grantRole} and\\n * {revokeRole}.\\n *\\n * To change a role's admin, use {AccessControl-_setRoleAdmin}.\\n */\\n function getRoleAdmin(bytes32 role) external view returns (bytes32);\\n\\n /**\\n * @dev Grants `role` to `account`.\\n *\\n * If `account` had not been already granted `role`, emits a {RoleGranted}\\n * event.\\n *\\n * Requirements:\\n *\\n * - the caller must have ``role``'s admin role.\\n */\\n function grantRole(bytes32 role, address account) external;\\n\\n /**\\n * @dev Revokes `role` from `account`.\\n *\\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\\n *\\n * Requirements:\\n *\\n * - the caller must have ``role``'s admin role.\\n */\\n function revokeRole(bytes32 role, address account) external;\\n\\n /**\\n * @dev Revokes `role` from the calling account.\\n *\\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\\n * purpose is to provide a mechanism for accounts to lose their privileges\\n * if they are compromised (such as when a trusted device is misplaced).\\n *\\n * If the calling account had been granted `role`, emits a {RoleRevoked}\\n * event.\\n *\\n * Requirements:\\n *\\n * - the caller must be `account`.\\n */\\n function renounceRole(bytes32 role, address account) external;\\n}\\n\",\"keccak256\":\"0xb8f5302f12138c5561362e88a78d061573e6298b7a1a5afe84a1e2c8d4d5aeaa\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.9.0) (proxy/utils/Initializable.sol)\\n\\npragma solidity ^0.8.2;\\n\\nimport \\\"../../utils/AddressUpgradeable.sol\\\";\\n\\n/**\\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\\n *\\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\\n * reused. This mechanism prevents re-execution of each \\\"step\\\" but allows the creation of new initialization steps in\\n * case an upgrade adds a module that needs to be initialized.\\n *\\n * For example:\\n *\\n * [.hljs-theme-light.nopadding]\\n * ```solidity\\n * contract MyToken is ERC20Upgradeable {\\n * function initialize() initializer public {\\n * __ERC20_init(\\\"MyToken\\\", \\\"MTK\\\");\\n * }\\n * }\\n *\\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\\n * function initializeV2() reinitializer(2) public {\\n * __ERC20Permit_init(\\\"MyToken\\\");\\n * }\\n * }\\n * ```\\n *\\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\\n *\\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\\n *\\n * [CAUTION]\\n * ====\\n * Avoid leaving a contract uninitialized.\\n *\\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\\n *\\n * [.hljs-theme-light.nopadding]\\n * ```\\n * /// @custom:oz-upgrades-unsafe-allow constructor\\n * constructor() {\\n * _disableInitializers();\\n * }\\n * ```\\n * ====\\n */\\nabstract contract Initializable {\\n /**\\n * @dev Indicates that the contract has been initialized.\\n * @custom:oz-retyped-from bool\\n */\\n uint8 private _initialized;\\n\\n /**\\n * @dev Indicates that the contract is in the process of being initialized.\\n */\\n bool private _initializing;\\n\\n /**\\n * @dev Triggered when the contract has been initialized or reinitialized.\\n */\\n event Initialized(uint8 version);\\n\\n /**\\n * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\\n * `onlyInitializing` functions can be used to initialize parent contracts.\\n *\\n * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a\\n * constructor.\\n *\\n * Emits an {Initialized} event.\\n */\\n modifier initializer() {\\n bool isTopLevelCall = !_initializing;\\n require(\\n (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),\\n \\\"Initializable: contract is already initialized\\\"\\n );\\n _initialized = 1;\\n if (isTopLevelCall) {\\n _initializing = true;\\n }\\n _;\\n if (isTopLevelCall) {\\n _initializing = false;\\n emit Initialized(1);\\n }\\n }\\n\\n /**\\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\\n * used to initialize parent contracts.\\n *\\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\\n * are added through upgrades and that require initialization.\\n *\\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\\n * cannot be nested. If one is invoked in the context of another, execution will revert.\\n *\\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\\n * a contract, executing them in the right order is up to the developer or operator.\\n *\\n * WARNING: setting the version to 255 will prevent any future reinitialization.\\n *\\n * Emits an {Initialized} event.\\n */\\n modifier reinitializer(uint8 version) {\\n require(!_initializing && _initialized < version, \\\"Initializable: contract is already initialized\\\");\\n _initialized = version;\\n _initializing = true;\\n _;\\n _initializing = false;\\n emit Initialized(version);\\n }\\n\\n /**\\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\\n */\\n modifier onlyInitializing() {\\n require(_initializing, \\\"Initializable: contract is not initializing\\\");\\n _;\\n }\\n\\n /**\\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\\n * through proxies.\\n *\\n * Emits an {Initialized} event the first time it is successfully executed.\\n */\\n function _disableInitializers() internal virtual {\\n require(!_initializing, \\\"Initializable: contract is initializing\\\");\\n if (_initialized != type(uint8).max) {\\n _initialized = type(uint8).max;\\n emit Initialized(type(uint8).max);\\n }\\n }\\n\\n /**\\n * @dev Returns the highest version that has been initialized. See {reinitializer}.\\n */\\n function _getInitializedVersion() internal view returns (uint8) {\\n return _initialized;\\n }\\n\\n /**\\n * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.\\n */\\n function _isInitializing() internal view returns (bool) {\\n return _initializing;\\n }\\n}\\n\",\"keccak256\":\"0x89be10e757d242e9b18d5a32c9fbe2019f6d63052bbe46397a430a1d60d7f794\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.1;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary AddressUpgradeable {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n *\\n * Furthermore, `isContract` will also return true if the target contract within\\n * the same transaction is already scheduled for destruction by `SELFDESTRUCT`,\\n * which only has an effect at the end of a transaction.\\n * ====\\n *\\n * [IMPORTANT]\\n * ====\\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\\n *\\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\\n * constructor.\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize/address.code.length, which returns 0\\n // for contracts in construction, since the code is only stored at the end\\n // of the constructor execution.\\n\\n return account.code.length > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\\n *\\n * _Available since v4.8._\\n */\\n function verifyCallResultFromTarget(\\n address target,\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n if (success) {\\n if (returndata.length == 0) {\\n // only check isContract if the call was successful and the return data is empty\\n // otherwise we already know that it was a contract\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n }\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason or using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x9c80f545915582e63fe206c6ce27cbe85a86fc10b9cd2a0e8c9488fb7c2ee422\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/introspection/IERC165Upgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC165 standard, as defined in the\\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\\n *\\n * Implementers can declare support of contract interfaces, which can then be\\n * queried by others ({ERC165Checker}).\\n *\\n * For an implementation, see {ERC165}.\\n */\\ninterface IERC165Upgradeable {\\n /**\\n * @dev Returns true if this contract implements the interface defined by\\n * `interfaceId`. See the corresponding\\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\\n * to learn more about how these ids are created.\\n *\\n * This function call must use less than 30 000 gas.\\n */\\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\\n}\\n\",\"keccak256\":\"0xc6cef87559d0aeffdf0a99803de655938a7779ec0a3cd5d4383483ad85565a09\",\"license\":\"MIT\"},\"@uniswap/v3-core/contracts/interfaces/IUniswapV3Pool.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\npragma solidity >=0.5.0;\\n\\nimport './pool/IUniswapV3PoolImmutables.sol';\\nimport './pool/IUniswapV3PoolState.sol';\\nimport './pool/IUniswapV3PoolDerivedState.sol';\\nimport './pool/IUniswapV3PoolActions.sol';\\nimport './pool/IUniswapV3PoolOwnerActions.sol';\\nimport './pool/IUniswapV3PoolEvents.sol';\\n\\n/// @title The interface for a Uniswap V3 Pool\\n/// @notice A Uniswap pool facilitates swapping and automated market making between any two assets that strictly conform\\n/// to the ERC20 specification\\n/// @dev The pool interface is broken up into many smaller pieces\\ninterface IUniswapV3Pool is\\n IUniswapV3PoolImmutables,\\n IUniswapV3PoolState,\\n IUniswapV3PoolDerivedState,\\n IUniswapV3PoolActions,\\n IUniswapV3PoolOwnerActions,\\n IUniswapV3PoolEvents\\n{\\n\\n}\\n\",\"keccak256\":\"0xfe6113d518466cd6652c85b111e01f33eb62157f49ae5ed7d5a3947a2044adb1\",\"license\":\"GPL-2.0-or-later\"},\"@uniswap/v3-core/contracts/interfaces/pool/IUniswapV3PoolActions.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\npragma solidity >=0.5.0;\\n\\n/// @title Permissionless pool actions\\n/// @notice Contains pool methods that can be called by anyone\\ninterface IUniswapV3PoolActions {\\n /// @notice Sets the initial price for the pool\\n /// @dev Price is represented as a sqrt(amountToken1/amountToken0) Q64.96 value\\n /// @param sqrtPriceX96 the initial sqrt price of the pool as a Q64.96\\n function initialize(uint160 sqrtPriceX96) external;\\n\\n /// @notice Adds liquidity for the given recipient/tickLower/tickUpper position\\n /// @dev The caller of this method receives a callback in the form of IUniswapV3MintCallback#uniswapV3MintCallback\\n /// in which they must pay any token0 or token1 owed for the liquidity. The amount of token0/token1 due depends\\n /// on tickLower, tickUpper, the amount of liquidity, and the current price.\\n /// @param recipient The address for which the liquidity will be created\\n /// @param tickLower The lower tick of the position in which to add liquidity\\n /// @param tickUpper The upper tick of the position in which to add liquidity\\n /// @param amount The amount of liquidity to mint\\n /// @param data Any data that should be passed through to the callback\\n /// @return amount0 The amount of token0 that was paid to mint the given amount of liquidity. Matches the value in the callback\\n /// @return amount1 The amount of token1 that was paid to mint the given amount of liquidity. Matches the value in the callback\\n function mint(\\n address recipient,\\n int24 tickLower,\\n int24 tickUpper,\\n uint128 amount,\\n bytes calldata data\\n ) external returns (uint256 amount0, uint256 amount1);\\n\\n /// @notice Collects tokens owed to a position\\n /// @dev Does not recompute fees earned, which must be done either via mint or burn of any amount of liquidity.\\n /// Collect must be called by the position owner. To withdraw only token0 or only token1, amount0Requested or\\n /// amount1Requested may be set to zero. To withdraw all tokens owed, caller may pass any value greater than the\\n /// actual tokens owed, e.g. type(uint128).max. Tokens owed may be from accumulated swap fees or burned liquidity.\\n /// @param recipient The address which should receive the fees collected\\n /// @param tickLower The lower tick of the position for which to collect fees\\n /// @param tickUpper The upper tick of the position for which to collect fees\\n /// @param amount0Requested How much token0 should be withdrawn from the fees owed\\n /// @param amount1Requested How much token1 should be withdrawn from the fees owed\\n /// @return amount0 The amount of fees collected in token0\\n /// @return amount1 The amount of fees collected in token1\\n function collect(\\n address recipient,\\n int24 tickLower,\\n int24 tickUpper,\\n uint128 amount0Requested,\\n uint128 amount1Requested\\n ) external returns (uint128 amount0, uint128 amount1);\\n\\n /// @notice Burn liquidity from the sender and account tokens owed for the liquidity to the position\\n /// @dev Can be used to trigger a recalculation of fees owed to a position by calling with an amount of 0\\n /// @dev Fees must be collected separately via a call to #collect\\n /// @param tickLower The lower tick of the position for which to burn liquidity\\n /// @param tickUpper The upper tick of the position for which to burn liquidity\\n /// @param amount How much liquidity to burn\\n /// @return amount0 The amount of token0 sent to the recipient\\n /// @return amount1 The amount of token1 sent to the recipient\\n function burn(\\n int24 tickLower,\\n int24 tickUpper,\\n uint128 amount\\n ) external returns (uint256 amount0, uint256 amount1);\\n\\n /// @notice Swap token0 for token1, or token1 for token0\\n /// @dev The caller of this method receives a callback in the form of IUniswapV3SwapCallback#uniswapV3SwapCallback\\n /// @param recipient The address to receive the output of the swap\\n /// @param zeroForOne The direction of the swap, true for token0 to token1, false for token1 to token0\\n /// @param amountSpecified The amount of the swap, which implicitly configures the swap as exact input (positive), or exact output (negative)\\n /// @param sqrtPriceLimitX96 The Q64.96 sqrt price limit. If zero for one, the price cannot be less than this\\n /// value after the swap. If one for zero, the price cannot be greater than this value after the swap\\n /// @param data Any data to be passed through to the callback\\n /// @return amount0 The delta of the balance of token0 of the pool, exact when negative, minimum when positive\\n /// @return amount1 The delta of the balance of token1 of the pool, exact when negative, minimum when positive\\n function swap(\\n address recipient,\\n bool zeroForOne,\\n int256 amountSpecified,\\n uint160 sqrtPriceLimitX96,\\n bytes calldata data\\n ) external returns (int256 amount0, int256 amount1);\\n\\n /// @notice Receive token0 and/or token1 and pay it back, plus a fee, in the callback\\n /// @dev The caller of this method receives a callback in the form of IUniswapV3FlashCallback#uniswapV3FlashCallback\\n /// @dev Can be used to donate underlying tokens pro-rata to currently in-range liquidity providers by calling\\n /// with 0 amount{0,1} and sending the donation amount(s) from the callback\\n /// @param recipient The address which will receive the token0 and token1 amounts\\n /// @param amount0 The amount of token0 to send\\n /// @param amount1 The amount of token1 to send\\n /// @param data Any data to be passed through to the callback\\n function flash(\\n address recipient,\\n uint256 amount0,\\n uint256 amount1,\\n bytes calldata data\\n ) external;\\n\\n /// @notice Increase the maximum number of price and liquidity observations that this pool will store\\n /// @dev This method is no-op if the pool already has an observationCardinalityNext greater than or equal to\\n /// the input observationCardinalityNext.\\n /// @param observationCardinalityNext The desired minimum number of observations for the pool to store\\n function increaseObservationCardinalityNext(uint16 observationCardinalityNext) external;\\n}\\n\",\"keccak256\":\"0x9453dd0e7442188667d01d9b65de3f1e14e9511ff3e303179a15f6fc267f7634\",\"license\":\"GPL-2.0-or-later\"},\"@uniswap/v3-core/contracts/interfaces/pool/IUniswapV3PoolDerivedState.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\npragma solidity >=0.5.0;\\n\\n/// @title Pool state that is not stored\\n/// @notice Contains view functions to provide information about the pool that is computed rather than stored on the\\n/// blockchain. The functions here may have variable gas costs.\\ninterface IUniswapV3PoolDerivedState {\\n /// @notice Returns the cumulative tick and liquidity as of each timestamp `secondsAgo` from the current block timestamp\\n /// @dev To get a time weighted average tick or liquidity-in-range, you must call this with two values, one representing\\n /// the beginning of the period and another for the end of the period. E.g., to get the last hour time-weighted average tick,\\n /// you must call it with secondsAgos = [3600, 0].\\n /// @dev The time weighted average tick represents the geometric time weighted average price of the pool, in\\n /// log base sqrt(1.0001) of token1 / token0. The TickMath library can be used to go from a tick value to a ratio.\\n /// @param secondsAgos From how long ago each cumulative tick and liquidity value should be returned\\n /// @return tickCumulatives Cumulative tick values as of each `secondsAgos` from the current block timestamp\\n /// @return secondsPerLiquidityCumulativeX128s Cumulative seconds per liquidity-in-range value as of each `secondsAgos` from the current block\\n /// timestamp\\n function observe(uint32[] calldata secondsAgos)\\n external\\n view\\n returns (int56[] memory tickCumulatives, uint160[] memory secondsPerLiquidityCumulativeX128s);\\n\\n /// @notice Returns a snapshot of the tick cumulative, seconds per liquidity and seconds inside a tick range\\n /// @dev Snapshots must only be compared to other snapshots, taken over a period for which a position existed.\\n /// I.e., snapshots cannot be compared if a position is not held for the entire period between when the first\\n /// snapshot is taken and the second snapshot is taken.\\n /// @param tickLower The lower tick of the range\\n /// @param tickUpper The upper tick of the range\\n /// @return tickCumulativeInside The snapshot of the tick accumulator for the range\\n /// @return secondsPerLiquidityInsideX128 The snapshot of seconds per liquidity for the range\\n /// @return secondsInside The snapshot of seconds per liquidity for the range\\n function snapshotCumulativesInside(int24 tickLower, int24 tickUpper)\\n external\\n view\\n returns (\\n int56 tickCumulativeInside,\\n uint160 secondsPerLiquidityInsideX128,\\n uint32 secondsInside\\n );\\n}\\n\",\"keccak256\":\"0xe603ac5b17ecdee73ba2b27efdf386c257a19c14206e87eee77e2017b742d9e5\",\"license\":\"GPL-2.0-or-later\"},\"@uniswap/v3-core/contracts/interfaces/pool/IUniswapV3PoolEvents.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\npragma solidity >=0.5.0;\\n\\n/// @title Events emitted by a pool\\n/// @notice Contains all events emitted by the pool\\ninterface IUniswapV3PoolEvents {\\n /// @notice Emitted exactly once by a pool when #initialize is first called on the pool\\n /// @dev Mint/Burn/Swap cannot be emitted by the pool before Initialize\\n /// @param sqrtPriceX96 The initial sqrt price of the pool, as a Q64.96\\n /// @param tick The initial tick of the pool, i.e. log base 1.0001 of the starting price of the pool\\n event Initialize(uint160 sqrtPriceX96, int24 tick);\\n\\n /// @notice Emitted when liquidity is minted for a given position\\n /// @param sender The address that minted the liquidity\\n /// @param owner The owner of the position and recipient of any minted liquidity\\n /// @param tickLower The lower tick of the position\\n /// @param tickUpper The upper tick of the position\\n /// @param amount The amount of liquidity minted to the position range\\n /// @param amount0 How much token0 was required for the minted liquidity\\n /// @param amount1 How much token1 was required for the minted liquidity\\n event Mint(\\n address sender,\\n address indexed owner,\\n int24 indexed tickLower,\\n int24 indexed tickUpper,\\n uint128 amount,\\n uint256 amount0,\\n uint256 amount1\\n );\\n\\n /// @notice Emitted when fees are collected by the owner of a position\\n /// @dev Collect events may be emitted with zero amount0 and amount1 when the caller chooses not to collect fees\\n /// @param owner The owner of the position for which fees are collected\\n /// @param tickLower The lower tick of the position\\n /// @param tickUpper The upper tick of the position\\n /// @param amount0 The amount of token0 fees collected\\n /// @param amount1 The amount of token1 fees collected\\n event Collect(\\n address indexed owner,\\n address recipient,\\n int24 indexed tickLower,\\n int24 indexed tickUpper,\\n uint128 amount0,\\n uint128 amount1\\n );\\n\\n /// @notice Emitted when a position's liquidity is removed\\n /// @dev Does not withdraw any fees earned by the liquidity position, which must be withdrawn via #collect\\n /// @param owner The owner of the position for which liquidity is removed\\n /// @param tickLower The lower tick of the position\\n /// @param tickUpper The upper tick of the position\\n /// @param amount The amount of liquidity to remove\\n /// @param amount0 The amount of token0 withdrawn\\n /// @param amount1 The amount of token1 withdrawn\\n event Burn(\\n address indexed owner,\\n int24 indexed tickLower,\\n int24 indexed tickUpper,\\n uint128 amount,\\n uint256 amount0,\\n uint256 amount1\\n );\\n\\n /// @notice Emitted by the pool for any swaps between token0 and token1\\n /// @param sender The address that initiated the swap call, and that received the callback\\n /// @param recipient The address that received the output of the swap\\n /// @param amount0 The delta of the token0 balance of the pool\\n /// @param amount1 The delta of the token1 balance of the pool\\n /// @param sqrtPriceX96 The sqrt(price) of the pool after the swap, as a Q64.96\\n /// @param liquidity The liquidity of the pool after the swap\\n /// @param tick The log base 1.0001 of price of the pool after the swap\\n event Swap(\\n address indexed sender,\\n address indexed recipient,\\n int256 amount0,\\n int256 amount1,\\n uint160 sqrtPriceX96,\\n uint128 liquidity,\\n int24 tick\\n );\\n\\n /// @notice Emitted by the pool for any flashes of token0/token1\\n /// @param sender The address that initiated the swap call, and that received the callback\\n /// @param recipient The address that received the tokens from flash\\n /// @param amount0 The amount of token0 that was flashed\\n /// @param amount1 The amount of token1 that was flashed\\n /// @param paid0 The amount of token0 paid for the flash, which can exceed the amount0 plus the fee\\n /// @param paid1 The amount of token1 paid for the flash, which can exceed the amount1 plus the fee\\n event Flash(\\n address indexed sender,\\n address indexed recipient,\\n uint256 amount0,\\n uint256 amount1,\\n uint256 paid0,\\n uint256 paid1\\n );\\n\\n /// @notice Emitted by the pool for increases to the number of observations that can be stored\\n /// @dev observationCardinalityNext is not the observation cardinality until an observation is written at the index\\n /// just before a mint/swap/burn.\\n /// @param observationCardinalityNextOld The previous value of the next observation cardinality\\n /// @param observationCardinalityNextNew The updated value of the next observation cardinality\\n event IncreaseObservationCardinalityNext(\\n uint16 observationCardinalityNextOld,\\n uint16 observationCardinalityNextNew\\n );\\n\\n /// @notice Emitted when the protocol fee is changed by the pool\\n /// @param feeProtocol0Old The previous value of the token0 protocol fee\\n /// @param feeProtocol1Old The previous value of the token1 protocol fee\\n /// @param feeProtocol0New The updated value of the token0 protocol fee\\n /// @param feeProtocol1New The updated value of the token1 protocol fee\\n event SetFeeProtocol(uint8 feeProtocol0Old, uint8 feeProtocol1Old, uint8 feeProtocol0New, uint8 feeProtocol1New);\\n\\n /// @notice Emitted when the collected protocol fees are withdrawn by the factory owner\\n /// @param sender The address that collects the protocol fees\\n /// @param recipient The address that receives the collected protocol fees\\n /// @param amount0 The amount of token0 protocol fees that is withdrawn\\n /// @param amount0 The amount of token1 protocol fees that is withdrawn\\n event CollectProtocol(address indexed sender, address indexed recipient, uint128 amount0, uint128 amount1);\\n}\\n\",\"keccak256\":\"0x8071514d0fe5d17d6fbd31c191cdfb703031c24e0ece3621d88ab10e871375cd\",\"license\":\"GPL-2.0-or-later\"},\"@uniswap/v3-core/contracts/interfaces/pool/IUniswapV3PoolImmutables.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\npragma solidity >=0.5.0;\\n\\n/// @title Pool state that never changes\\n/// @notice These parameters are fixed for a pool forever, i.e., the methods will always return the same values\\ninterface IUniswapV3PoolImmutables {\\n /// @notice The contract that deployed the pool, which must adhere to the IUniswapV3Factory interface\\n /// @return The contract address\\n function factory() external view returns (address);\\n\\n /// @notice The first of the two tokens of the pool, sorted by address\\n /// @return The token contract address\\n function token0() external view returns (address);\\n\\n /// @notice The second of the two tokens of the pool, sorted by address\\n /// @return The token contract address\\n function token1() external view returns (address);\\n\\n /// @notice The pool's fee in hundredths of a bip, i.e. 1e-6\\n /// @return The fee\\n function fee() external view returns (uint24);\\n\\n /// @notice The pool tick spacing\\n /// @dev Ticks can only be used at multiples of this value, minimum of 1 and always positive\\n /// e.g.: a tickSpacing of 3 means ticks can be initialized every 3rd tick, i.e., ..., -6, -3, 0, 3, 6, ...\\n /// This value is an int24 to avoid casting even though it is always positive.\\n /// @return The tick spacing\\n function tickSpacing() external view returns (int24);\\n\\n /// @notice The maximum amount of position liquidity that can use any tick in the range\\n /// @dev This parameter is enforced per tick to prevent liquidity from overflowing a uint128 at any point, and\\n /// also prevents out-of-range liquidity from being used to prevent adding in-range liquidity to a pool\\n /// @return The max amount of liquidity per tick\\n function maxLiquidityPerTick() external view returns (uint128);\\n}\\n\",\"keccak256\":\"0xf6e5d2cd1139c4c276bdbc8e1d2b256e456c866a91f1b868da265c6d2685c3f7\",\"license\":\"GPL-2.0-or-later\"},\"@uniswap/v3-core/contracts/interfaces/pool/IUniswapV3PoolOwnerActions.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\npragma solidity >=0.5.0;\\n\\n/// @title Permissioned pool actions\\n/// @notice Contains pool methods that may only be called by the factory owner\\ninterface IUniswapV3PoolOwnerActions {\\n /// @notice Set the denominator of the protocol's % share of the fees\\n /// @param feeProtocol0 new protocol fee for token0 of the pool\\n /// @param feeProtocol1 new protocol fee for token1 of the pool\\n function setFeeProtocol(uint8 feeProtocol0, uint8 feeProtocol1) external;\\n\\n /// @notice Collect the protocol fee accrued to the pool\\n /// @param recipient The address to which collected protocol fees should be sent\\n /// @param amount0Requested The maximum amount of token0 to send, can be 0 to collect fees in only token1\\n /// @param amount1Requested The maximum amount of token1 to send, can be 0 to collect fees in only token0\\n /// @return amount0 The protocol fee collected in token0\\n /// @return amount1 The protocol fee collected in token1\\n function collectProtocol(\\n address recipient,\\n uint128 amount0Requested,\\n uint128 amount1Requested\\n ) external returns (uint128 amount0, uint128 amount1);\\n}\\n\",\"keccak256\":\"0x759b78a2918af9e99e246dc3af084f654e48ef32bb4e4cb8a966aa3dcaece235\",\"license\":\"GPL-2.0-or-later\"},\"@uniswap/v3-core/contracts/interfaces/pool/IUniswapV3PoolState.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\npragma solidity >=0.5.0;\\n\\n/// @title Pool state that can change\\n/// @notice These methods compose the pool's state, and can change with any frequency including multiple times\\n/// per transaction\\ninterface IUniswapV3PoolState {\\n /// @notice The 0th storage slot in the pool stores many values, and is exposed as a single method to save gas\\n /// when accessed externally.\\n /// @return sqrtPriceX96 The current price of the pool as a sqrt(token1/token0) Q64.96 value\\n /// tick The current tick of the pool, i.e. according to the last tick transition that was run.\\n /// This value may not always be equal to SqrtTickMath.getTickAtSqrtRatio(sqrtPriceX96) if the price is on a tick\\n /// boundary.\\n /// observationIndex The index of the last oracle observation that was written,\\n /// observationCardinality The current maximum number of observations stored in the pool,\\n /// observationCardinalityNext The next maximum number of observations, to be updated when the observation.\\n /// feeProtocol The protocol fee for both tokens of the pool.\\n /// Encoded as two 4 bit values, where the protocol fee of token1 is shifted 4 bits and the protocol fee of token0\\n /// is the lower 4 bits. Used as the denominator of a fraction of the swap fee, e.g. 4 means 1/4th of the swap fee.\\n /// unlocked Whether the pool is currently locked to reentrancy\\n function slot0()\\n external\\n view\\n returns (\\n uint160 sqrtPriceX96,\\n int24 tick,\\n uint16 observationIndex,\\n uint16 observationCardinality,\\n uint16 observationCardinalityNext,\\n uint8 feeProtocol,\\n bool unlocked\\n );\\n\\n /// @notice The fee growth as a Q128.128 fees of token0 collected per unit of liquidity for the entire life of the pool\\n /// @dev This value can overflow the uint256\\n function feeGrowthGlobal0X128() external view returns (uint256);\\n\\n /// @notice The fee growth as a Q128.128 fees of token1 collected per unit of liquidity for the entire life of the pool\\n /// @dev This value can overflow the uint256\\n function feeGrowthGlobal1X128() external view returns (uint256);\\n\\n /// @notice The amounts of token0 and token1 that are owed to the protocol\\n /// @dev Protocol fees will never exceed uint128 max in either token\\n function protocolFees() external view returns (uint128 token0, uint128 token1);\\n\\n /// @notice The currently in range liquidity available to the pool\\n /// @dev This value has no relationship to the total liquidity across all ticks\\n function liquidity() external view returns (uint128);\\n\\n /// @notice Look up information about a specific tick in the pool\\n /// @param tick The tick to look up\\n /// @return liquidityGross the total amount of position liquidity that uses the pool either as tick lower or\\n /// tick upper,\\n /// liquidityNet how much liquidity changes when the pool price crosses the tick,\\n /// feeGrowthOutside0X128 the fee growth on the other side of the tick from the current tick in token0,\\n /// feeGrowthOutside1X128 the fee growth on the other side of the tick from the current tick in token1,\\n /// tickCumulativeOutside the cumulative tick value on the other side of the tick from the current tick\\n /// secondsPerLiquidityOutsideX128 the seconds spent per liquidity on the other side of the tick from the current tick,\\n /// secondsOutside the seconds spent on the other side of the tick from the current tick,\\n /// initialized Set to true if the tick is initialized, i.e. liquidityGross is greater than 0, otherwise equal to false.\\n /// Outside values can only be used if the tick is initialized, i.e. if liquidityGross is greater than 0.\\n /// In addition, these values are only relative and must be used only in comparison to previous snapshots for\\n /// a specific position.\\n function ticks(int24 tick)\\n external\\n view\\n returns (\\n uint128 liquidityGross,\\n int128 liquidityNet,\\n uint256 feeGrowthOutside0X128,\\n uint256 feeGrowthOutside1X128,\\n int56 tickCumulativeOutside,\\n uint160 secondsPerLiquidityOutsideX128,\\n uint32 secondsOutside,\\n bool initialized\\n );\\n\\n /// @notice Returns 256 packed tick initialized boolean values. See TickBitmap for more information\\n function tickBitmap(int16 wordPosition) external view returns (uint256);\\n\\n /// @notice Returns the information about a position by the position's key\\n /// @param key The position's key is a hash of a preimage composed by the owner, tickLower and tickUpper\\n /// @return _liquidity The amount of liquidity in the position,\\n /// Returns feeGrowthInside0LastX128 fee growth of token0 inside the tick range as of the last mint/burn/poke,\\n /// Returns feeGrowthInside1LastX128 fee growth of token1 inside the tick range as of the last mint/burn/poke,\\n /// Returns tokensOwed0 the computed amount of token0 owed to the position as of the last mint/burn/poke,\\n /// Returns tokensOwed1 the computed amount of token1 owed to the position as of the last mint/burn/poke\\n function positions(bytes32 key)\\n external\\n view\\n returns (\\n uint128 _liquidity,\\n uint256 feeGrowthInside0LastX128,\\n uint256 feeGrowthInside1LastX128,\\n uint128 tokensOwed0,\\n uint128 tokensOwed1\\n );\\n\\n /// @notice Returns data about a specific observation index\\n /// @param index The element of the observations array to fetch\\n /// @dev You most likely want to use #observe() instead of this method to get an observation as of some amount of time\\n /// ago, rather than at a specific index in the array.\\n /// @return blockTimestamp The timestamp of the observation,\\n /// Returns tickCumulative the tick multiplied by seconds elapsed for the life of the pool as of the observation timestamp,\\n /// Returns secondsPerLiquidityCumulativeX128 the seconds per in range liquidity for the life of the pool as of the observation timestamp,\\n /// Returns initialized whether the observation has been initialized and the values are safe to use\\n function observations(uint256 index)\\n external\\n view\\n returns (\\n uint32 blockTimestamp,\\n int56 tickCumulative,\\n uint160 secondsPerLiquidityCumulativeX128,\\n bool initialized\\n );\\n}\\n\",\"keccak256\":\"0x852dc1f5df7dcf7f11e7bb3eed79f0cea72ad4b25f6a9d2c35aafb48925fd49f\",\"license\":\"GPL-2.0-or-later\"},\"contracts/periphery/contracts/access-control/SuAccessRoles.sol\":{\"content\":\"// SPDX-License-Identifier: BSL 1.1\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @title SuAccessRoles Library\\n * @dev SuAuthenticated and SuAccessControlSingleton need to have this constants\\n * Hierarchy:\\n * 1. DAO - can give admins and system roles\\n * 2.1. Admin - can set Alerters\\n * 2.2. System - includes Minter, Vault, Liquidation and Reward roles, don't have access to give some roles.\\n * 3. Alerter - can send alerts and trigger rate limits, don't have access to give some roles.\\n */\\nabstract contract SuAccessRoles {\\n bytes32 public constant ADMIN_ROLE = 0x00;\\n\\n bytes32 public constant DAO_ROLE = keccak256(\\\"DAO_ROLE\\\");\\n\\n bytes32 public constant ALERTER_ROLE = keccak256(\\\"ALERTER_ROLE\\\");\\n\\n // system roles\\n bytes32 public constant MINT_ACCESS_ROLE = keccak256(\\\"MINT_ACCESS_ROLE\\\");\\n bytes32 public constant VAULT_ACCESS_ROLE = keccak256(\\\"VAULT_ACCESS_ROLE\\\");\\n bytes32 public constant LIQUIDATION_ACCESS_ROLE = keccak256(\\\"LIQUIDATION_ACCESS_ROLE\\\");\\n bytes32 public constant REWARD_ACCESS_ROLE = keccak256(\\\"REWARD_ACCESS_ROLE\\\");\\n}\\n\",\"keccak256\":\"0x024209469b6b337eef6cf520501d1e6c2ba66a79f014c25220a35e407d69b02e\",\"license\":\"BSL 1.1\"},\"contracts/periphery/contracts/access-control/SuAuthenticated.sol\":{\"content\":\"// SPDX-License-Identifier: BSL 1.1\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../interfaces/access-control/ISuAccessControl.sol\\\";\\nimport \\\"./SuAccessRoles.sol\\\";\\nimport \\\"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\\\";\\nimport \\\"@openzeppelin/contracts-upgradeable/utils/introspection/IERC165Upgradeable.sol\\\";\\n\\n/**\\n * @title SuAuthenticated\\n * @dev other contracts should inherit to be authenticated.\\n * The address of SuAccessControlSingleton should be one for all contract that inherits SuAuthenticated\\n */\\nabstract contract SuAuthenticated is Initializable, SuAccessRoles, IERC165Upgradeable {\\n ISuAccessControl public ACCESS_CONTROL_SINGLETON;\\n\\n error OnlyDAOError();\\n error OnlyAdminError();\\n error OnlyAlerterError();\\n error OnlyVaultAccessError();\\n error OnlyLiquidationAccessError();\\n error OnlyMintAccessError();\\n error OnlyRewardAccessError();\\n error OnlyRoleError();\\n error BadAccessControlSingleton();\\n\\n /**\\n * @dev should be passed in constructor\\n */\\n function __suAuthenticatedInit(address _accessControlSingleton) internal onlyInitializing {\\n ACCESS_CONTROL_SINGLETON = ISuAccessControl(_accessControlSingleton);\\n if (\\n !ISuAccessControl(_accessControlSingleton).supportsInterface(type(IAccessControlUpgradeable).interfaceId)\\n ) revert BadAccessControlSingleton();\\n }\\n\\n /** CORE ROLES */\\n\\n modifier onlyDAO() {\\n if (!ACCESS_CONTROL_SINGLETON.hasRole(DAO_ROLE, msg.sender)) revert OnlyDAOError();\\n _;\\n }\\n\\n modifier onlyAdmin() {\\n if (!ACCESS_CONTROL_SINGLETON.hasRole(ADMIN_ROLE, msg.sender)) revert OnlyAdminError();\\n _;\\n }\\n\\n modifier onlyAlerter() {\\n if (!ACCESS_CONTROL_SINGLETON.hasRole(ALERTER_ROLE, msg.sender)) revert OnlyAlerterError();\\n _;\\n }\\n\\n /** SYSTEM ROLES */\\n\\n modifier onlyVaultAccess() {\\n if (!ACCESS_CONTROL_SINGLETON.hasRole(VAULT_ACCESS_ROLE, msg.sender)) revert OnlyVaultAccessError();\\n _;\\n }\\n\\n modifier onlyLiquidationAccess() {\\n if (!ACCESS_CONTROL_SINGLETON.hasRole(LIQUIDATION_ACCESS_ROLE, msg.sender)) revert OnlyLiquidationAccessError();\\n _;\\n }\\n\\n modifier onlyMintAccess() {\\n if (!ACCESS_CONTROL_SINGLETON.hasRole(MINT_ACCESS_ROLE, msg.sender)) revert OnlyMintAccessError();\\n _;\\n }\\n\\n modifier onlyRewardAccess() {\\n if (!ACCESS_CONTROL_SINGLETON.hasRole(REWARD_ACCESS_ROLE, msg.sender)) revert OnlyRewardAccessError();\\n _;\\n }\\n\\n // syntax sugar under ACCESS_CONTROL_SINGLETON\\n modifier onlyRole(bytes32 role) {\\n if (!ACCESS_CONTROL_SINGLETON.hasRole(role, msg.sender)) revert OnlyRoleError();\\n _;\\n }\\n\\n function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {\\n return ACCESS_CONTROL_SINGLETON.supportsInterface(interfaceId);\\n }\\n}\\n\",\"keccak256\":\"0x3553007ac782c0c5f2ecf3ca47b8b72d74b2cae35c34ffe2d030b968938b2b0d\",\"license\":\"BSL 1.1\"},\"contracts/periphery/contracts/interfaces/access-control/ISuAccessControl.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\nimport \\\"@openzeppelin/contracts-upgradeable/access/IAccessControlUpgradeable.sol\\\";\\nimport \\\"@openzeppelin/contracts-upgradeable/utils/introspection/IERC165Upgradeable.sol\\\";\\nimport \\\"../../access-control/SuAccessRoles.sol\\\";\\n\\n/**\\n * @notice Access control for contracts\\n * @dev External interface of AccessControl declared to support ERC165 detection.\\n **/\\ninterface ISuAccessControl is IAccessControlUpgradeable, IERC165Upgradeable {\\n function setRoleAdmin(bytes32 role, bytes32 adminRole) external;\\n}\\n\",\"keccak256\":\"0x25724ac502fd6418ccd38273b276de4b2fdecd023d723c5d80c9f0a27c407bcd\",\"license\":\"MIT\"},\"contracts/periphery/contracts/interfaces/oracle/ISuOracle.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\n\\n// solhint-disable compiler-version\\npragma solidity >=0.7.6;\\n\\ninterface ISuOracle {\\n /**\\n * @notice WARNING! Read this description very carefully!\\n * function getFiatPrice1e18(address asset) returns (uint256) that:\\n * basicAmountOfAsset * getFiatPrice1e18(asset) / 1e18 === $$ * 1e18\\n * in other words, it doesn't matter what's the erc20.decimals is,\\n * you just multiply token balance in basic units on value from oracle and get dollar amount multiplied on 1e18.\\n *\\n * different assets have different deviation threshold (errors)\\n * for wBTC it's <= 0.5%, read more https://data.chain.link/ethereum/mainnet/crypto-usd/btc-usd\\n * for other asset is can be larger based on particular oracle implementation.\\n *\\n * examples:\\n * market price of btc = $30k,\\n * for 0.1 wBTC the unit256 amount is 0.1 * 1e18\\n * 0.1 * 1e18 * (price1e18 / 1e18) == $3000 == uint256(3000*1e18)\\n * => price1e18 = 30000 * 1e18;\\n *\\n * market price of usdt = $0.97,\\n * for 1 usdt uint256 = 1 * 1e6\\n * so 1*1e6 * price1e18 / 1e18 == $0.97 == uint256(0.97*1e18)\\n * => 1*1e6 * (price1e18 / 1e18) / (0.97*1e18) = 1\\n * => price1e18 = 0.97 * (1e18/1e6) * 1e18\\n *\\n * assume market price of wBTC = $31,503.77, oracle error = $158\\n *\\n * case #1: small amount of wBTC\\n * we have 0.0,000,001 wBTC that is worth v = $0.00315 \\u00b1 $0.00001 = 0.00315*1e18 = 315*1e13 \\u00b1 1*1e13\\n * actual balance on the asset b = wBTC.balanceOf() = 0.0000001*1e18 = 1e11\\n * oracle should return or = oracle.getFiatPrice1e18(wBTC) <=>\\n * <=> b*or = v => v/b = 315*1e13 / 1e11 = 315*1e2 \\u00b1 1e2\\n * error = or.error * b = 1e2 * 1e11 = 1e13 => 1e13/1e18 usd = 1e-5 = 0.00001 usd\\n *\\n * case #2: large amount of wBTC\\n * v = 2,000,000 wBTC = $31,503.77 * 2m \\u00b1 158*2m = $63,007,540,000 \\u00b1 $316,000,000 = 63,007*1e24 \\u00b1 316*1e24\\n * for calc convenience we increase error on 0.05 and have v = 63,000*24 \\u00b1 300*1e24 = (630 \\u00b1 3)*1e26\\n * b = 2*1e6 * 1e18 = 2*1e24\\n * or = v/b = (630 \\u00b1 3)*1e26 / 2*1e24 = 315*1e2 \\u00b1 1.5*1e2\\n * error = or.error * b = 1.5*100 * 2*1e24 = 3*1e26 = 3*1e8*1e18 = $300,000,000 ~ $316,000,000\\n *\\n * assume the market price of USDT = $0.97 \\u00b1 $0.00485,\\n *\\n * case #3: little amount of USDT\\n * v = USDT amount 0.005 = 0.005*(0.97 \\u00b1 0.00485) = 0.00485*1e18 \\u00b1 0.00002425*1e18 = 485*1e13 \\u00b1 3*1e13\\n * we rounded error up on (3000-2425)/2425 ~= +24% for calculation convenience.\\n * b = USDT.balanceOf() = 0.005*1e6 = 5*1e3\\n * b*or = v => or = v/b = (485*1e13 \\u00b1 3*1e13) / 5*1e3 = 970*1e9 \\u00b1 6*1e9\\n * error = 6*1e9 * 5*1e3 / 1e18 = 30*1e12/1e18 = 3*1e-5 = $0,00005\\n *\\n * case #4: lot of USDT\\n * v = we have 100,000,000,000 USDT = $97B = 97*1e9*1e18 \\u00b1 0.5*1e9*1e18\\n * b = USDT.balanceOf() = 1e11*1e6 = 1e17\\n * or = v/b = (97*1e9*1e18 \\u00b1 0.5*1e9*1e18) / 1e17 = 970*1e9 \\u00b1 5*1e9\\n * error = 5*1e9 * 1e17 = 5*1e26 = 0.5 * 1e8*1e18\\n *\\n * @param asset - address of erc20 token contract\\n * @return usdPrice1e18 such that asset.balanceOf() * getFiatPrice1e18(asset) / 1e18 == $$ * 1e18\\n **/\\n function getFiatPrice1e18(address asset) external view returns (uint256);\\n}\\n\",\"keccak256\":\"0xa56b9cc86ef5935efecc276e6a3188d518f1a99cad960083a8de35849c997687\",\"license\":\"UNLICENSED\"},\"contracts/periphery/contracts/interfaces/oracle/ISuUniV3Oracle.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity ^0.8.0;\\n\\nimport { IUniswapV3Pool } from \\\"@uniswap/v3-core/contracts/interfaces/IUniswapV3Pool.sol\\\";\\n\\nimport \\\"./ISuOracle.sol\\\";\\n\\n/**\\n * @title SuUniV3Oracle\\n * @dev SuUniV3Oracle is an implementation of the SuOracle interface for UniswapV3.\\n **/\\ninterface ISuUniV3Oracle is ISuOracle {\\n /* ===================== ERRORS ===================== */\\n error InvalidToken();\\n\\n /* ====================== VARS ====================== */\\n function assetToPool (address asset) external view returns ( IUniswapV3Pool );\\n\\n /* ==================== METHODS ==================== */\\n function enableAssetPool(address _asset, uint24 _fee) external;\\n}\\n\",\"keccak256\":\"0x93bbd213c2ec871874f87696f3e8612489bbcefac71ab0e4fc069245f9e27f6c\",\"license\":\"UNLICENSED\"},\"contracts/periphery/contracts/oracle/SuUniV3Oracle.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity ^0.8.0;\\n\\nimport { IUniswapV3Pool } from \\\"@uniswap/v3-core/contracts/interfaces/IUniswapV3Pool.sol\\\";\\nimport \\\"../vendor/uniswap/PoolAddress.sol\\\";\\nimport \\\"../vendor/uniswap/OracleLibrary.sol\\\";\\nimport \\\"../interfaces/oracle/ISuUniV3Oracle.sol\\\";\\nimport \\\"../access-control/SuAuthenticated.sol\\\";\\n\\n/**\\n * @notice check SuUniV3Oracle section in ORACLE_ARCHITECTURE.md\\n * @dev Here we calculate only the price of asset in USDT, not USD.\\n * Before that we need to enableAssetPool, to know what pool use for that asset (what fees).\\n * See ISuUniV3Oracle interface for full details.\\n**/\\ncontract SuUniV3Oracle is SuAuthenticated, ISuUniV3Oracle {\\n mapping (address => IUniswapV3Pool) public override assetToPool;\\n\\n address public UNISWAP_FACTORY;\\n address public USDT;\\n address public ORACLE;\\n\\n function initialize(\\n address _authControl,\\n address _UNISWAP_FACTORY,\\n address _USDT,\\n address _ORACLE\\n ) public initializer {\\n __suAuthenticatedInit(_authControl);\\n UNISWAP_FACTORY = _UNISWAP_FACTORY;\\n USDT = _USDT;\\n ORACLE = _ORACLE;\\n }\\n\\n function getPool(address _asset, uint24 _fee) internal view returns (IUniswapV3Pool pool) {\\n pool = IUniswapV3Pool(PoolAddress.computeAddress(UNISWAP_FACTORY, PoolAddress.getPoolKey(_asset, USDT, _fee)));\\n }\\n\\n function enableAssetPool(address _asset, uint24 _fee) external override onlyAdmin {\\n assetToPool[_asset] = getPool(_asset, _fee);\\n }\\n\\n function getFiatPrice1e18(address asset) public override view returns (uint256) {\\n return ISuOracle(ORACLE).getFiatPrice1e18(USDT) * estimateAmountOut(assetToPool[asset], asset, 1e18, 10) / 1e18;\\n }\\n\\n function estimateAmountOut(\\n IUniswapV3Pool pool,\\n address tokenIn,\\n uint128 amountIn,\\n uint32 secondsAgo\\n ) internal view returns (uint256 amountOut) {\\n address token0 = pool.token0();\\n address token1 = pool.token1();\\n if (tokenIn != token0 && tokenIn != token1) revert InvalidToken();\\n\\n address tokenOut = tokenIn == token0 ? token1 : token0;\\n\\n // (int24 tick, ) = OracleLibrary.consult(pool, secondsAgo);\\n // Gas optimization: code copied from OracleLibrary.sol, consult()\\n uint32[] memory secondsAgos = new uint32[](2);\\n secondsAgos[0] = secondsAgo;\\n secondsAgos[1] = 0;\\n\\n (int56[] memory tickCumulatives, ) = pool.observe(secondsAgos);\\n\\n int56 tickCumulativesDelta = tickCumulatives[1] - tickCumulatives[0];\\n\\n int24 tick = int24(tickCumulativesDelta / int56(uint56(secondsAgo)));\\n // Always round to negative infinity\\n if (tickCumulativesDelta < 0 && (tickCumulativesDelta % int56(uint56(secondsAgo)) != 0)) tick--;\\n\\n amountOut = OracleLibrary.getQuoteAtTick(\\n tick,\\n amountIn,\\n tokenIn,\\n tokenOut\\n );\\n }\\n}\\n\",\"keccak256\":\"0xa2e026e6e13104f7c3228a216dd0557485e25c8a495dbf4005be584b99587b0b\",\"license\":\"UNLICENSED\"},\"contracts/periphery/contracts/vendor/uniswap/FullMath.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\n/// @title Contains 512-bit math functions\\n/// @notice Facilitates multiplication and division that can have overflow of an intermediate value without any loss of precision\\n/// @dev Handles \\\"phantom overflow\\\" i.e., allows multiplication and division where an intermediate value overflows 256 bits\\nlibrary FullMath {\\n /// @notice Calculates floor(a\\u00d7b\\u00f7denominator) with full precision. Throws if result overflows a uint256 or denominator == 0\\n /// @param a The multiplicand\\n /// @param b The multiplier\\n /// @param denominator The divisor\\n /// @return result The 256-bit result\\n /// @dev Credit to Remco Bloemen under MIT license https://xn--2-umb.com/21/muldiv\\n function mulDiv(\\n uint256 a,\\n uint256 b,\\n uint256 denominator\\n ) internal pure returns (uint256 result) {\\n unchecked {\\n // 512-bit multiply [prod1 prod0] = a * b\\n // Compute the product mod 2**256 and mod 2**256 - 1\\n // then use the Chinese Remainder Theorem to reconstruct\\n // the 512 bit result. The result is stored in two 256\\n // variables such that product = prod1 * 2**256 + prod0\\n uint256 prod0; // Least significant 256 bits of the product\\n uint256 prod1; // Most significant 256 bits of the product\\n assembly {\\n let mm := mulmod(a, b, not(0))\\n prod0 := mul(a, b)\\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\\n }\\n\\n // Handle non-overflow cases, 256 by 256 division\\n if (prod1 == 0) {\\n require(denominator > 0);\\n assembly {\\n result := div(prod0, denominator)\\n }\\n return result;\\n }\\n\\n // Make sure the result is less than 2**256.\\n // Also prevents denominator == 0\\n require(denominator > prod1);\\n\\n ///////////////////////////////////////////////\\n // 512 by 256 division.\\n ///////////////////////////////////////////////\\n\\n // Make division exact by subtracting the remainder from [prod1 prod0]\\n // Compute remainder using mulmod\\n uint256 remainder;\\n assembly {\\n remainder := mulmod(a, b, denominator)\\n }\\n // Subtract 256 bit number from 512 bit number\\n assembly {\\n prod1 := sub(prod1, gt(remainder, prod0))\\n prod0 := sub(prod0, remainder)\\n }\\n\\n // Factor powers of two out of denominator\\n // Compute largest power of two divisor of denominator.\\n // Always >= 1.\\n uint256 twos = (0 - denominator) & denominator;\\n // Divide denominator by power of two\\n assembly {\\n denominator := div(denominator, twos)\\n }\\n\\n // Divide [prod1 prod0] by the factors of two\\n assembly {\\n prod0 := div(prod0, twos)\\n }\\n // Shift in bits from prod1 into prod0. For this we need\\n // to flip `twos` such that it is 2**256 / twos.\\n // If twos is zero, then it becomes one\\n assembly {\\n twos := add(div(sub(0, twos), twos), 1)\\n }\\n prod0 |= prod1 * twos;\\n\\n // Invert denominator mod 2**256\\n // Now that denominator is an odd number, it has an inverse\\n // modulo 2**256 such that denominator * inv = 1 mod 2**256.\\n // Compute the inverse by starting with a seed that is correct\\n // correct for four bits. That is, denominator * inv = 1 mod 2**4\\n uint256 inv = (3 * denominator) ^ 2;\\n // Now use Newton-Raphson iteration to improve the precision.\\n // Thanks to Hensel's lifting lemma, this also works in modular\\n // arithmetic, doubling the correct bits in each step.\\n inv *= 2 - denominator * inv; // inverse mod 2**8\\n inv *= 2 - denominator * inv; // inverse mod 2**16\\n inv *= 2 - denominator * inv; // inverse mod 2**32\\n inv *= 2 - denominator * inv; // inverse mod 2**64\\n inv *= 2 - denominator * inv; // inverse mod 2**128\\n inv *= 2 - denominator * inv; // inverse mod 2**256\\n\\n // Because the division is now exact we can divide by multiplying\\n // with the modular inverse of denominator. This will give us the\\n // correct result modulo 2**256. Since the precoditions guarantee\\n // that the outcome is less than 2**256, this is the final result.\\n // We don't need to compute the high bits of the result and prod1\\n // is no longer required.\\n result = prod0 * inv;\\n return result;\\n }\\n }\\n\\n /// @notice Calculates ceil(a\\u00d7b\\u00f7denominator) with full precision. Throws if result overflows a uint256 or denominator == 0\\n /// @param a The multiplicand\\n /// @param b The multiplier\\n /// @param denominator The divisor\\n /// @return result The 256-bit result\\n function mulDivRoundingUp(\\n uint256 a,\\n uint256 b,\\n uint256 denominator\\n ) internal pure returns (uint256 result) {\\n unchecked {\\n result = mulDiv(a, b, denominator);\\n if (mulmod(a, b, denominator) > 0) {\\n require(result < type(uint256).max);\\n result++;\\n }\\n }\\n }\\n}\",\"keccak256\":\"0x97877d12339bb24a7d4904714632b845fe530e7194c9c0fa3e8bedb049f0f8aa\",\"license\":\"MIT\"},\"contracts/periphery/contracts/vendor/uniswap/OracleLibrary.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\npragma solidity >=0.5.0 <0.9.0;\\n\\nimport \\\"./FullMath.sol\\\";\\nimport \\\"./TickMath.sol\\\";\\nimport '@uniswap/v3-core/contracts/interfaces/IUniswapV3Pool.sol';\\n\\n/// @title Oracle library\\n/// @notice Provides functions to integrate with V3 pool oracle\\nlibrary OracleLibrary {\\n /// @notice Calculates time-weighted means of tick and liquidity for a given Uniswap V3 pool\\n /// @param pool Address of the pool that we want to observe\\n /// @param secondsAgo Number of seconds in the past from which to calculate the time-weighted means\\n /// @return arithmeticMeanTick The arithmetic mean tick from (block.timestamp - secondsAgo) to block.timestamp\\n /// @return harmonicMeanLiquidity The harmonic mean liquidity from (block.timestamp - secondsAgo) to block.timestamp\\n function consult(address pool, uint32 secondsAgo)\\n internal\\n view\\n returns (int24 arithmeticMeanTick, uint128 harmonicMeanLiquidity)\\n {\\n require(secondsAgo != 0, 'BP');\\n\\n uint32[] memory secondsAgos = new uint32[](2);\\n secondsAgos[0] = secondsAgo;\\n secondsAgos[1] = 0;\\n\\n (int56[] memory tickCumulatives, uint160[] memory secondsPerLiquidityCumulativeX128s) = IUniswapV3Pool(pool)\\n .observe(secondsAgos);\\n\\n int56 tickCumulativesDelta = tickCumulatives[1] - tickCumulatives[0];\\n uint160 secondsPerLiquidityCumulativesDelta = secondsPerLiquidityCumulativeX128s[1] -\\n secondsPerLiquidityCumulativeX128s[0];\\n\\n arithmeticMeanTick = int24(tickCumulativesDelta / int56(uint56(secondsAgo)));\\n // Always round to negative infinity\\n if (tickCumulativesDelta < 0 && (tickCumulativesDelta % int56(uint56(secondsAgo)) != 0)) arithmeticMeanTick--;\\n\\n // We are multiplying here instead of shifting to ensure that harmonicMeanLiquidity doesn't overflow uint128\\n uint192 secondsAgoX160 = uint192(secondsAgo) * type(uint160).max;\\n harmonicMeanLiquidity = uint128(secondsAgoX160 / (uint192(secondsPerLiquidityCumulativesDelta) << 32));\\n }\\n\\n /// @notice Given a tick and a token amount, calculates the amount of token received in exchange\\n /// @param tick Tick value used to calculate the quote\\n /// @param baseAmount Amount of token to be converted\\n /// @param baseToken Address of an ERC20 token contract used as the baseAmount denomination\\n /// @param quoteToken Address of an ERC20 token contract used as the quoteAmount denomination\\n /// @return quoteAmount Amount of quoteToken received for baseAmount of baseToken\\n function getQuoteAtTick(\\n int24 tick,\\n uint128 baseAmount,\\n address baseToken,\\n address quoteToken\\n ) internal pure returns (uint256 quoteAmount) {\\n uint160 sqrtRatioX96 = TickMath.getSqrtRatioAtTick(tick);\\n\\n // Calculate quoteAmount with better precision if it doesn't overflow when multiplied by itself\\n if (sqrtRatioX96 <= type(uint128).max) {\\n uint256 ratioX192 = uint256(sqrtRatioX96) * sqrtRatioX96;\\n quoteAmount = baseToken < quoteToken\\n ? FullMath.mulDiv(ratioX192, baseAmount, 1 << 192)\\n : FullMath.mulDiv(1 << 192, baseAmount, ratioX192);\\n } else {\\n uint256 ratioX128 = FullMath.mulDiv(sqrtRatioX96, sqrtRatioX96, 1 << 64);\\n quoteAmount = baseToken < quoteToken\\n ? FullMath.mulDiv(ratioX128, baseAmount, 1 << 128)\\n : FullMath.mulDiv(1 << 128, baseAmount, ratioX128);\\n }\\n }\\n\\n /// @notice Given a pool, it returns the number of seconds ago of the oldest stored observation\\n /// @param pool Address of Uniswap V3 pool that we want to observe\\n /// @return secondsAgo The number of seconds ago of the oldest observation stored for the pool\\n function getOldestObservationSecondsAgo(address pool) internal view returns (uint32 secondsAgo) {\\n (, , uint16 observationIndex, uint16 observationCardinality, , , ) = IUniswapV3Pool(pool).slot0();\\n require(observationCardinality > 0, 'NI');\\n\\n (uint32 observationTimestamp, , , bool initialized) = IUniswapV3Pool(pool).observations(\\n (observationIndex + 1) % observationCardinality\\n );\\n\\n // The next index might not be initialized if the cardinality is in the process of increasing\\n // In this case the oldest observation is always in index 0\\n if (!initialized) {\\n (observationTimestamp, , , ) = IUniswapV3Pool(pool).observations(0);\\n }\\n\\n unchecked {\\n secondsAgo = uint32(block.timestamp) - observationTimestamp;\\n }\\n }\\n\\n /// @notice Given a pool, it returns the tick value as of the start of the current block\\n /// @param pool Address of Uniswap V3 pool\\n /// @return The tick that the pool was in at the start of the current block\\n function getBlockStartingTickAndLiquidity(address pool) internal view returns (int24, uint128) {\\n (, int24 tick, uint16 observationIndex, uint16 observationCardinality, , , ) = IUniswapV3Pool(pool).slot0();\\n\\n // 2 observations are needed to reliably calculate the block starting tick\\n require(observationCardinality > 1, 'NEO');\\n\\n // If the latest observation occurred in the past, then no tick-changing trades have happened in this block\\n // therefore the tick in `slot0` is the same as at the beginning of the current block.\\n // We don't need to check if this observation is initialized - it is guaranteed to be.\\n (\\n uint32 observationTimestamp,\\n int56 tickCumulative,\\n uint160 secondsPerLiquidityCumulativeX128,\\n\\n ) = IUniswapV3Pool(pool).observations(observationIndex);\\n if (observationTimestamp != uint32(block.timestamp)) {\\n return (tick, IUniswapV3Pool(pool).liquidity());\\n }\\n\\n uint256 prevIndex = (uint256(observationIndex) + observationCardinality - 1) % observationCardinality;\\n (\\n uint32 prevObservationTimestamp,\\n int56 prevTickCumulative,\\n uint160 prevSecondsPerLiquidityCumulativeX128,\\n bool prevInitialized\\n ) = IUniswapV3Pool(pool).observations(prevIndex);\\n\\n require(prevInitialized, 'ONI');\\n\\n uint32 delta = observationTimestamp - prevObservationTimestamp;\\n tick = int24((tickCumulative - int56(uint56(prevTickCumulative))) / int56(uint56(delta)));\\n uint128 liquidity = uint128(\\n (uint192(delta) * type(uint160).max) /\\n (uint192(secondsPerLiquidityCumulativeX128 - prevSecondsPerLiquidityCumulativeX128) << 32)\\n );\\n return (tick, liquidity);\\n }\\n\\n /// @notice Information for calculating a weighted arithmetic mean tick\\n struct WeightedTickData {\\n int24 tick;\\n uint128 weight;\\n }\\n\\n /// @notice Given an array of ticks and weights, calculates the weighted arithmetic mean tick\\n /// @param weightedTickData An array of ticks and weights\\n /// @return weightedArithmeticMeanTick The weighted arithmetic mean tick\\n /// @dev Each entry of `weightedTickData` should represents ticks from pools with the same underlying pool tokens. If they do not,\\n /// extreme care must be taken to ensure that ticks are comparable (including decimal differences).\\n /// @dev Note that the weighted arithmetic mean tick corresponds to the weighted geometric mean price.\\n function getWeightedArithmeticMeanTick(WeightedTickData[] memory weightedTickData)\\n internal\\n pure\\n returns (int24 weightedArithmeticMeanTick)\\n {\\n // Accumulates the sum of products between each tick and its weight\\n int256 numerator;\\n\\n // Accumulates the sum of the weights\\n uint256 denominator;\\n\\n // Products fit in 152 bits, so it would take an array of length ~2**104 to overflow this logic\\n for (uint256 i; i < weightedTickData.length; i++) {\\n numerator += weightedTickData[i].tick * int256(uint256(weightedTickData[i].weight));\\n denominator += weightedTickData[i].weight;\\n }\\n\\n weightedArithmeticMeanTick = int24(numerator / int256(denominator));\\n // Always round to negative infinity\\n if (numerator < 0 && (numerator % int256(denominator) != 0)) weightedArithmeticMeanTick--;\\n }\\n\\n /// @notice Returns the \\\"synthetic\\\" tick which represents the price of the first entry in `tokens` in terms of the last\\n /// @dev Useful for calculating relative prices along routes.\\n /// @dev There must be one tick for each pairwise set of tokens.\\n /// @param tokens The token contract addresses\\n /// @param ticks The ticks, representing the price of each token pair in `tokens`\\n /// @return syntheticTick The synthetic tick, representing the relative price of the outermost tokens in `tokens`\\n function getChainedPrice(address[] memory tokens, int24[] memory ticks)\\n internal\\n pure\\n returns (int256 syntheticTick)\\n {\\n require(tokens.length - 1 == ticks.length, 'DL');\\n for (uint256 i = 1; i <= ticks.length; i++) {\\n // check the tokens for address sort order, then accumulate the\\n // ticks into the running synthetic tick, ensuring that intermediate tokens \\\"cancel out\\\"\\n tokens[i - 1] < tokens[i] ? syntheticTick += ticks[i - 1] : syntheticTick -= ticks[i - 1];\\n }\\n }\\n}\\n\",\"keccak256\":\"0x3a1d475b9d529a0df157cec11b6db6785ecddc4ec51d68b6e5901ba4e14c36ca\",\"license\":\"GPL-2.0-or-later\"},\"contracts/periphery/contracts/vendor/uniswap/PoolAddress.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\npragma solidity >=0.5.0;\\n\\n/// @title Provides functions for deriving a pool address from the factory, tokens, and the fee\\nlibrary PoolAddress {\\n bytes32 internal constant POOL_INIT_CODE_HASH = 0xe34f199b19b2b4f47f68442619d555527d244f78a3297ea89325f843f87b8b54;\\n\\n /// @notice The identifying key of the pool\\n struct PoolKey {\\n address token0;\\n address token1;\\n uint24 fee;\\n }\\n\\n /// @notice Returns PoolKey: the ordered tokens with the matched fee levels\\n /// @param tokenA The first token of a pool, unsorted\\n /// @param tokenB The second token of a pool, unsorted\\n /// @param fee The fee level of the pool\\n /// @return Poolkey The pool details with ordered token0 and token1 assignments\\n function getPoolKey(\\n address tokenA,\\n address tokenB,\\n uint24 fee\\n ) internal pure returns (PoolKey memory) {\\n if (tokenA > tokenB) (tokenA, tokenB) = (tokenB, tokenA);\\n return PoolKey({token0: tokenA, token1: tokenB, fee: fee});\\n }\\n\\n /// @notice Deterministically computes the pool address given the factory and PoolKey\\n /// @param factory The Uniswap V3 factory contract address\\n /// @param key The PoolKey\\n /// @return pool The contract address of the V3 pool\\n function computeAddress(address factory, PoolKey memory key) internal pure returns (address pool) {\\n require(key.token0 < key.token1);\\n pool = address(\\n uint160(\\n uint256(\\n keccak256(\\n abi.encodePacked(\\n hex'ff',\\n factory,\\n keccak256(abi.encode(key.token0, key.token1, key.fee)),\\n POOL_INIT_CODE_HASH\\n )\\n )\\n )\\n )\\n );\\n }\\n}\\n\",\"keccak256\":\"0x4703d506f590554af23e6e01e0412c88f9eff7410205d9af639b3559cc4f9a05\",\"license\":\"GPL-2.0-or-later\"},\"contracts/periphery/contracts/vendor/uniswap/TickMath.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\npragma solidity ^0.8.0;\\n\\n/// @title Math library for computing sqrt prices from ticks and vice versa\\n/// @notice Computes sqrt price for ticks of size 1.0001, i.e. sqrt(1.0001^tick) as fixed point Q64.96 numbers. Supports\\n/// prices between 2**-128 and 2**128\\nlibrary TickMath {\\n error T();\\n error R();\\n\\n /// @dev The minimum tick that may be passed to #getSqrtRatioAtTick computed from log base 1.0001 of 2**-128\\n int24 internal constant MIN_TICK = -887272;\\n /// @dev The maximum tick that may be passed to #getSqrtRatioAtTick computed from log base 1.0001 of 2**128\\n int24 internal constant MAX_TICK = -MIN_TICK;\\n\\n /// @dev The minimum value that can be returned from #getSqrtRatioAtTick. Equivalent to getSqrtRatioAtTick(MIN_TICK)\\n uint160 internal constant MIN_SQRT_RATIO = 4295128739;\\n /// @dev The maximum value that can be returned from #getSqrtRatioAtTick. Equivalent to getSqrtRatioAtTick(MAX_TICK)\\n uint160 internal constant MAX_SQRT_RATIO = 1461446703485210103287273052203988822378723970342;\\n\\n /// @notice Calculates sqrt(1.0001^tick) * 2^96\\n /// @dev Throws if |tick| > max tick\\n /// @param tick The input tick for the above formula\\n /// @return sqrtPriceX96 A Fixed point Q64.96 number representing the sqrt of the ratio of the two assets (token1/token0)\\n /// at the given tick\\n function getSqrtRatioAtTick(int24 tick) internal pure returns (uint160 sqrtPriceX96) {\\n unchecked {\\n uint256 absTick = tick < 0 ? uint256(-int256(tick)) : uint256(int256(tick));\\n if (absTick > uint256(int256(MAX_TICK))) revert T();\\n\\n uint256 ratio = absTick & 0x1 != 0\\n ? 0xfffcb933bd6fad37aa2d162d1a594001\\n : 0x100000000000000000000000000000000;\\n if (absTick & 0x2 != 0) ratio = (ratio * 0xfff97272373d413259a46990580e213a) >> 128;\\n if (absTick & 0x4 != 0) ratio = (ratio * 0xfff2e50f5f656932ef12357cf3c7fdcc) >> 128;\\n if (absTick & 0x8 != 0) ratio = (ratio * 0xffe5caca7e10e4e61c3624eaa0941cd0) >> 128;\\n if (absTick & 0x10 != 0) ratio = (ratio * 0xffcb9843d60f6159c9db58835c926644) >> 128;\\n if (absTick & 0x20 != 0) ratio = (ratio * 0xff973b41fa98c081472e6896dfb254c0) >> 128;\\n if (absTick & 0x40 != 0) ratio = (ratio * 0xff2ea16466c96a3843ec78b326b52861) >> 128;\\n if (absTick & 0x80 != 0) ratio = (ratio * 0xfe5dee046a99a2a811c461f1969c3053) >> 128;\\n if (absTick & 0x100 != 0) ratio = (ratio * 0xfcbe86c7900a88aedcffc83b479aa3a4) >> 128;\\n if (absTick & 0x200 != 0) ratio = (ratio * 0xf987a7253ac413176f2b074cf7815e54) >> 128;\\n if (absTick & 0x400 != 0) ratio = (ratio * 0xf3392b0822b70005940c7a398e4b70f3) >> 128;\\n if (absTick & 0x800 != 0) ratio = (ratio * 0xe7159475a2c29b7443b29c7fa6e889d9) >> 128;\\n if (absTick & 0x1000 != 0) ratio = (ratio * 0xd097f3bdfd2022b8845ad8f792aa5825) >> 128;\\n if (absTick & 0x2000 != 0) ratio = (ratio * 0xa9f746462d870fdf8a65dc1f90e061e5) >> 128;\\n if (absTick & 0x4000 != 0) ratio = (ratio * 0x70d869a156d2a1b890bb3df62baf32f7) >> 128;\\n if (absTick & 0x8000 != 0) ratio = (ratio * 0x31be135f97d08fd981231505542fcfa6) >> 128;\\n if (absTick & 0x10000 != 0) ratio = (ratio * 0x9aa508b5b7a84e1c677de54f3e99bc9) >> 128;\\n if (absTick & 0x20000 != 0) ratio = (ratio * 0x5d6af8dedb81196699c329225ee604) >> 128;\\n if (absTick & 0x40000 != 0) ratio = (ratio * 0x2216e584f5fa1ea926041bedfe98) >> 128;\\n if (absTick & 0x80000 != 0) ratio = (ratio * 0x48a170391f7dc42444e8fa2) >> 128;\\n\\n if (tick > 0) ratio = type(uint256).max / ratio;\\n\\n // this divides by 1<<32 rounding up to go from a Q128.128 to a Q128.96.\\n // we then downcast because we know the result always fits within 160 bits due to our tick input constraint\\n // we round up in the division so getTickAtSqrtRatio of the output price is always consistent\\n sqrtPriceX96 = uint160((ratio >> 32) + (ratio % (1 << 32) == 0 ? 0 : 1));\\n }\\n }\\n\\n /// @notice Calculates the greatest tick value such that getRatioAtTick(tick) <= ratio\\n /// @dev Throws in case sqrtPriceX96 < MIN_SQRT_RATIO, as MIN_SQRT_RATIO is the lowest value getRatioAtTick may\\n /// ever return.\\n /// @param sqrtPriceX96 The sqrt ratio for which to compute the tick as a Q64.96\\n /// @return tick The greatest tick for which the ratio is less than or equal to the input ratio\\n function getTickAtSqrtRatio(uint160 sqrtPriceX96) internal pure returns (int24 tick) {\\n unchecked {\\n // second inequality must be < because the price can never reach the price at the max tick\\n if (!(sqrtPriceX96 >= MIN_SQRT_RATIO && sqrtPriceX96 < MAX_SQRT_RATIO)) revert R();\\n uint256 ratio = uint256(sqrtPriceX96) << 32;\\n\\n uint256 r = ratio;\\n uint256 msb = 0;\\n\\n assembly {\\n let f := shl(7, gt(r, 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF))\\n msb := or(msb, f)\\n r := shr(f, r)\\n }\\n assembly {\\n let f := shl(6, gt(r, 0xFFFFFFFFFFFFFFFF))\\n msb := or(msb, f)\\n r := shr(f, r)\\n }\\n assembly {\\n let f := shl(5, gt(r, 0xFFFFFFFF))\\n msb := or(msb, f)\\n r := shr(f, r)\\n }\\n assembly {\\n let f := shl(4, gt(r, 0xFFFF))\\n msb := or(msb, f)\\n r := shr(f, r)\\n }\\n assembly {\\n let f := shl(3, gt(r, 0xFF))\\n msb := or(msb, f)\\n r := shr(f, r)\\n }\\n assembly {\\n let f := shl(2, gt(r, 0xF))\\n msb := or(msb, f)\\n r := shr(f, r)\\n }\\n assembly {\\n let f := shl(1, gt(r, 0x3))\\n msb := or(msb, f)\\n r := shr(f, r)\\n }\\n assembly {\\n let f := gt(r, 0x1)\\n msb := or(msb, f)\\n }\\n\\n if (msb >= 128) r = ratio >> (msb - 127);\\n else r = ratio << (127 - msb);\\n\\n int256 log_2 = (int256(msb) - 128) << 64;\\n\\n assembly {\\n r := shr(127, mul(r, r))\\n let f := shr(128, r)\\n log_2 := or(log_2, shl(63, f))\\n r := shr(f, r)\\n }\\n assembly {\\n r := shr(127, mul(r, r))\\n let f := shr(128, r)\\n log_2 := or(log_2, shl(62, f))\\n r := shr(f, r)\\n }\\n assembly {\\n r := shr(127, mul(r, r))\\n let f := shr(128, r)\\n log_2 := or(log_2, shl(61, f))\\n r := shr(f, r)\\n }\\n assembly {\\n r := shr(127, mul(r, r))\\n let f := shr(128, r)\\n log_2 := or(log_2, shl(60, f))\\n r := shr(f, r)\\n }\\n assembly {\\n r := shr(127, mul(r, r))\\n let f := shr(128, r)\\n log_2 := or(log_2, shl(59, f))\\n r := shr(f, r)\\n }\\n assembly {\\n r := shr(127, mul(r, r))\\n let f := shr(128, r)\\n log_2 := or(log_2, shl(58, f))\\n r := shr(f, r)\\n }\\n assembly {\\n r := shr(127, mul(r, r))\\n let f := shr(128, r)\\n log_2 := or(log_2, shl(57, f))\\n r := shr(f, r)\\n }\\n assembly {\\n r := shr(127, mul(r, r))\\n let f := shr(128, r)\\n log_2 := or(log_2, shl(56, f))\\n r := shr(f, r)\\n }\\n assembly {\\n r := shr(127, mul(r, r))\\n let f := shr(128, r)\\n log_2 := or(log_2, shl(55, f))\\n r := shr(f, r)\\n }\\n assembly {\\n r := shr(127, mul(r, r))\\n let f := shr(128, r)\\n log_2 := or(log_2, shl(54, f))\\n r := shr(f, r)\\n }\\n assembly {\\n r := shr(127, mul(r, r))\\n let f := shr(128, r)\\n log_2 := or(log_2, shl(53, f))\\n r := shr(f, r)\\n }\\n assembly {\\n r := shr(127, mul(r, r))\\n let f := shr(128, r)\\n log_2 := or(log_2, shl(52, f))\\n r := shr(f, r)\\n }\\n assembly {\\n r := shr(127, mul(r, r))\\n let f := shr(128, r)\\n log_2 := or(log_2, shl(51, f))\\n r := shr(f, r)\\n }\\n assembly {\\n r := shr(127, mul(r, r))\\n let f := shr(128, r)\\n log_2 := or(log_2, shl(50, f))\\n }\\n\\n int256 log_sqrt10001 = log_2 * 255738958999603826347141; // 128.128 number\\n\\n int24 tickLow = int24((log_sqrt10001 - 3402992956809132418596140100660247210) >> 128);\\n int24 tickHi = int24((log_sqrt10001 + 291339464771989622907027621153398088495) >> 128);\\n\\n tick = tickLow == tickHi ? tickLow : getSqrtRatioAtTick(tickHi) <= sqrtPriceX96 ? tickHi : tickLow;\\n }\\n }\\n}\",\"keccak256\":\"0x07c523cb666ea10b538f60e20542e19d5ad5a639432c52b7f9e8f2373cb2aedc\",\"license\":\"GPL-2.0-or-later\"}},\"version\":1}",
"bytecode": "0x608080604052346100165761124a908161001c8239f35b600080fdfe6080604081815260048036101561001557600080fd5b600092833560e01c90816301ffc9a714610f555750806303ee9f2214610f29578063044c8d7114610eee57806314c376dc14610eb357806338013f0214610e8c578063438280dd14610e5157806371d0fb4114610e1657806375b238fc14610dfb5780638e5313e014610dc0578063b9ac2b38146105de578063c54e44eb146105b5578063c74c0fac1461058c578063d3a6fc99146103e4578063dc97e84e146103a9578063e9c265181461036a5763f8c8765e146100d357600080fd5b34610366576080366003190112610366576100ec610feb565b916001600160a01b03916024358381169190829003610362576044359184831680930361035e576064359085821680920361035a5787549360ff8560081c16159485809661034d575b8015610336575b156102dc5760ff1981166001178a55856102cb575b5088549660ff8860081c16156102745762010000600160b01b0360108a901b1662010000600160b01b0319891681178b5587516301ffc9a760e01b8152637965db0b60e01b878201529099909160209183916024918391165afa90811561026a578a9161023c575b501561022c5760018060a01b0319918260025416176002558160035416176003558254161790556101e8578380f35b610100600160b01b0319909116909117825551600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb384740249890602090a13880808380f35b85516384d942fd60e01b81528490fd5b61025d915060203d8111610263575b6102558183611052565b810190611075565b386101b9565b503d61024b565b87513d8c823e3d90fd5b865162461bcd60e51b8152602081870152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b6064820152608490fd5b61ffff191661010117895538610151565b865162461bcd60e51b8152602081870152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608490fd5b50303b15801561013c5750600160ff82161461013c565b50600160ff821610610135565b8780fd5b8680fd5b8580fd5b8280fd5b5050346103a557816003193601126103a557602090517f3b5d4cc60d3ec3516ee8ae083bd60934f6eb2a6c54b1229985c41bfb092b26038152f35b5080fd5b5050346103a557816003193601126103a557602090517f9a9aef7c1247d5fc769b0185c052913e39673da29a880317dfd20ebf86f26a498152f35b5090346103665780600319360112610366576103fe610feb565b916024359062ffffff82168092036105885760018060a01b0380865460101c169184518093632474521560e21b8252888383015233602483015281604460209687935afa90811561057e578891610561575b50156105535750600254816003541686818988805161046e81611006565b8281528289820152015284891698818a11610548575b50508587858082519461049686611006565b16948585521692838882015201528082101561054457600195875191868301938452888301526060820152606081526104ce81611037565b5190208551908482019260ff60f81b8452868060601b03199060601b16602183015260358201527fe34f199b19b2b4f47f68442619d555527d244f78a3297ea89325f843f87b8b5460558201526055815261052881611037565b519020169385525282209060018060a01b031982541617905580f35b8880fd5b925090503880610484565b8451631886ea7d60e11b8152fd5b6105789150843d8611610263576102558183611052565b38610450565b86513d8a823e3d90fd5b8480fd5b5050346103a557816003193601126103a55760025490516001600160a01b039091168152602090f35b5050346103a557816003193601126103a55760035490516001600160a01b039091168152602090f35b5091346108f957602092836003193601126103a5576105fb610feb565b81546003548551631735856760e31b81526001600160a01b03918216818601529492909187908690602490829086165afa948515610db6578395610d87575b5081169081835260018752808684205416938651630dfe168160e01b815288818381895afa908115610cdf578591610d6a575b50875163d21220a760e01b815290898284818a5afa918215610d60578692610d31575b508381168514801580610d25575b610d155715610d0a5750948489915b8951906106b982611006565b600282528382018b368237600a6106cf846110ec565b52836106da8461110f565b528b5194859363883bdbfd60e01b8552602485019082898701525180915260448501929186905b828210610ce9575050505082809103915afa908115610cdf578591610bd5575b5061073561072e8261110f565b51916110ec565b5160060b9060060b03667fffffffffffff8113667fffffffffffff19821217610bb25760060b600a810560020b908581129081610bc5575b50610b9e575b60020b9084821215610b9857818503915b620d89e88311610b89578392919086906001841615610b7f576ffffcb933bd6fad37aa2d162d1a5940015b6001600160881b03169360028116610b63575b838116610b47575b60088116610b2b575b60108116610b0f575b8c8116610af3575b8b8116610ad7575b608090818116610abc575b6101008116610aa1575b6102008116610a86575b6104008116610a6b575b6108008116610a50575b6110008116610a35575b6120008116610a1a575b61400081166109ff575b61800081166109e4575b6201000081166109c9575b6202000081166109af575b620400008116610995575b620800001661097c575b5013610953575b5063ffffffff811661094a5760ff855b1690891c01166001600160801b0381116108fc57806108a79161108d565b931611156108d45750670de0b6b3a7640000916108c66108cc926111bf565b9061108d565b049051908152f35b81156108f95750670de0b6b3a7640000916108cc916503782dace9d960d21b046108c6565b80fd5b806109069161111f565b931611156109255750670de0b6b3a7640000916108c66108cc9261116a565b81156108f95750670de0b6b3a7640000916108cc916503782dace9d960921b046108c6565b60ff6001610889565b9080925015610969575081906000190438610879565b634e487b7160e01b855260129052602484fd5b90936b048a170391f7dc42444e8fa202901c9238610872565b6d2216e584f5fa1ea926041bedfe98909502811c94610868565b946e5d6af8dedb81196699c329225ee60402811c9461085d565b946f09aa508b5b7a84e1c677de54f3e99bc902811c94610852565b946f31be135f97d08fd981231505542fcfa602811c94610847565b946f70d869a156d2a1b890bb3df62baf32f702811c9461083d565b946fa9f746462d870fdf8a65dc1f90e061e502811c94610833565b946fd097f3bdfd2022b8845ad8f792aa582502811c94610829565b946fe7159475a2c29b7443b29c7fa6e889d902811c9461081f565b946ff3392b0822b70005940c7a398e4b70f302811c94610815565b946ff987a7253ac413176f2b074cf7815e5402811c9461080b565b946ffcbe86c7900a88aedcffc83b479aa3a402811c94610801565b946ffe5dee046a99a2a811c461f1969c305302811c946107f7565b936fff2ea16466c96a3843ec78b326b528610260801c936107ec565b936fff973b41fa98c081472e6896dfb254c00260801c936107e4565b936fffcb9843d60f6159c9db58835c9266440260801c936107dc565b936fffe5caca7e10e4e61c3624eaa0941cd00260801c936107d3565b936ffff2e50f5f656932ef12357cf3c7fdcc0260801c936107ca565b936ffff97272373d413259a46990580e213a0260801c936107c2565b600160801b6107af565b5087516315e4079d60e11b8152fd5b81610784565b627fffff198114610bb25760001901610773565b634e487b7160e01b855260118252602485fd5b600a91500760060b15153861076d565b90503d8086833e610be68183611052565b810188828203126103625781516001600160401b039081811161035a5783019282601f8501121561035a57835193610c1d856110d5565b94610c2a8d519687611052565b8086528d8087019160051b83010191858311610cdb578e01905b828210610cbe575050508b81015191821161035a570181601f8201121561035e578051908b808c610c80610c77866110d5565b91519182611052565b848152019260051b82010192831161035a578b01905b828210610ca65750505038610721565b81518681168103610544578152908b01908b01610c96565b81518060060b8103610cd7578152908e01908e01610c44565b8b80fd5b8a80fd5b88513d87823e3d90fd5b835163ffffffff1685528c975088965093840193909201916001018f610701565b9050948489916106ad565b895163c1ab6dc160e01b81528490fd5b5084831686141561069e565b610d529192508a3d8c11610d59575b610d4a8183611052565b8101906110b6565b9038610690565b503d610d40565b89513d88823e3d90fd5b610d819150893d8b11610d5957610d4a8183611052565b3861066d565b9094508681813d8311610daf575b610d9f8183611052565b810103126103665751938161063a565b503d610d95565b86513d85823e3d90fd5b5050346103a557816003193601126103a557602090517fe453bacb314e78dcd5192e6b1a2b1f0e7c76e92f6b7e429a6a90f04e39db3b768152f35b5050346103a557816003193601126103a55751908152602090f35b5050346103a557816003193601126103a557602090517f880a91047114272656e533301261260c75e4d11543ac7303d6fe4204579ec7278152f35b5050346103a557816003193601126103a557602090517f39f61ca2a1a28fee144218173ec637b649a353e4026b2738c673800e5bf1437b8152f35b50346103665782600319360112610366575490516001600160a01b03909116815260209150f35b5050346103a557816003193601126103a557602090517fe965846df3dd5b1dfa65f58e31477079e90140e0908b6dd31b5aead5a57cf3658152f35b5050346103a55760203660031901126103a5576020916001600160a01b0390829082610f18610feb565b168152600185522054169051908152f35b5050346103a557816003193601126103a5579054905160109190911c6001600160a01b03168152602090f35b9291905034610fe7576020366003190112610fe757803563ffffffff60e01b81168091036105885784546301ffc9a760e01b8552918401526020908390602490829060101c6001600160a01b03165afa918215610fdd5760209392610fbe575b50519015158152f35b610fd6919250833d8111610263576102558183611052565b9038610fb5565b81513d85823e3d90fd5b8380fd5b600435906001600160a01b038216820361100157565b600080fd5b606081019081106001600160401b0382111761102157604052565b634e487b7160e01b600052604160045260246000fd5b608081019081106001600160401b0382111761102157604052565b601f909101601f19168101906001600160401b0382119082101761102157604052565b90816020910312611001575180151581036110015790565b818102929181159184041417156110a057565b634e487b7160e01b600052601160045260246000fd5b9081602091031261100157516001600160a01b03811681036110015790565b6001600160401b0381116110215760051b60200190565b8051156110f95760200190565b634e487b7160e01b600052603260045260246000fd5b8051600110156110f95760400190565b600019828209908281029283808410930391838303936000931461115f57600160401b92848411156108f957500990828211900360c01b910360401c1790565b505090505060401c90565b670de0b6b3a76400009060001982820990828102928380841093039183830393600093146111b457600160801b92848411156108f957500990828211900360801b910360801c1790565b505090505060801c90565b670de0b6b3a764000090600019828209908281029283808410930391838303936000931461120957600160c01b92848411156108f957500990828211900360401b910360c01c1790565b505090505060c01c9056fea26469706673582212206fd10acae81c7591e7e148606d7c3a64004bcee332667f058c79f461cdb834c764736f6c63430008110033",
"deployedBytecode": "0x6080604081815260048036101561001557600080fd5b600092833560e01c90816301ffc9a714610f555750806303ee9f2214610f29578063044c8d7114610eee57806314c376dc14610eb357806338013f0214610e8c578063438280dd14610e5157806371d0fb4114610e1657806375b238fc14610dfb5780638e5313e014610dc0578063b9ac2b38146105de578063c54e44eb146105b5578063c74c0fac1461058c578063d3a6fc99146103e4578063dc97e84e146103a9578063e9c265181461036a5763f8c8765e146100d357600080fd5b34610366576080366003190112610366576100ec610feb565b916001600160a01b03916024358381169190829003610362576044359184831680930361035e576064359085821680920361035a5787549360ff8560081c16159485809661034d575b8015610336575b156102dc5760ff1981166001178a55856102cb575b5088549660ff8860081c16156102745762010000600160b01b0360108a901b1662010000600160b01b0319891681178b5587516301ffc9a760e01b8152637965db0b60e01b878201529099909160209183916024918391165afa90811561026a578a9161023c575b501561022c5760018060a01b0319918260025416176002558160035416176003558254161790556101e8578380f35b610100600160b01b0319909116909117825551600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb384740249890602090a13880808380f35b85516384d942fd60e01b81528490fd5b61025d915060203d8111610263575b6102558183611052565b810190611075565b386101b9565b503d61024b565b87513d8c823e3d90fd5b865162461bcd60e51b8152602081870152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b6064820152608490fd5b61ffff191661010117895538610151565b865162461bcd60e51b8152602081870152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608490fd5b50303b15801561013c5750600160ff82161461013c565b50600160ff821610610135565b8780fd5b8680fd5b8580fd5b8280fd5b5050346103a557816003193601126103a557602090517f3b5d4cc60d3ec3516ee8ae083bd60934f6eb2a6c54b1229985c41bfb092b26038152f35b5080fd5b5050346103a557816003193601126103a557602090517f9a9aef7c1247d5fc769b0185c052913e39673da29a880317dfd20ebf86f26a498152f35b5090346103665780600319360112610366576103fe610feb565b916024359062ffffff82168092036105885760018060a01b0380865460101c169184518093632474521560e21b8252888383015233602483015281604460209687935afa90811561057e578891610561575b50156105535750600254816003541686818988805161046e81611006565b8281528289820152015284891698818a11610548575b50508587858082519461049686611006565b16948585521692838882015201528082101561054457600195875191868301938452888301526060820152606081526104ce81611037565b5190208551908482019260ff60f81b8452868060601b03199060601b16602183015260358201527fe34f199b19b2b4f47f68442619d555527d244f78a3297ea89325f843f87b8b5460558201526055815261052881611037565b519020169385525282209060018060a01b031982541617905580f35b8880fd5b925090503880610484565b8451631886ea7d60e11b8152fd5b6105789150843d8611610263576102558183611052565b38610450565b86513d8a823e3d90fd5b8480fd5b5050346103a557816003193601126103a55760025490516001600160a01b039091168152602090f35b5050346103a557816003193601126103a55760035490516001600160a01b039091168152602090f35b5091346108f957602092836003193601126103a5576105fb610feb565b81546003548551631735856760e31b81526001600160a01b03918216818601529492909187908690602490829086165afa948515610db6578395610d87575b5081169081835260018752808684205416938651630dfe168160e01b815288818381895afa908115610cdf578591610d6a575b50875163d21220a760e01b815290898284818a5afa918215610d60578692610d31575b508381168514801580610d25575b610d155715610d0a5750948489915b8951906106b982611006565b600282528382018b368237600a6106cf846110ec565b52836106da8461110f565b528b5194859363883bdbfd60e01b8552602485019082898701525180915260448501929186905b828210610ce9575050505082809103915afa908115610cdf578591610bd5575b5061073561072e8261110f565b51916110ec565b5160060b9060060b03667fffffffffffff8113667fffffffffffff19821217610bb25760060b600a810560020b908581129081610bc5575b50610b9e575b60020b9084821215610b9857818503915b620d89e88311610b89578392919086906001841615610b7f576ffffcb933bd6fad37aa2d162d1a5940015b6001600160881b03169360028116610b63575b838116610b47575b60088116610b2b575b60108116610b0f575b8c8116610af3575b8b8116610ad7575b608090818116610abc575b6101008116610aa1575b6102008116610a86575b6104008116610a6b575b6108008116610a50575b6110008116610a35575b6120008116610a1a575b61400081166109ff575b61800081166109e4575b6201000081166109c9575b6202000081166109af575b620400008116610995575b620800001661097c575b5013610953575b5063ffffffff811661094a5760ff855b1690891c01166001600160801b0381116108fc57806108a79161108d565b931611156108d45750670de0b6b3a7640000916108c66108cc926111bf565b9061108d565b049051908152f35b81156108f95750670de0b6b3a7640000916108cc916503782dace9d960d21b046108c6565b80fd5b806109069161111f565b931611156109255750670de0b6b3a7640000916108c66108cc9261116a565b81156108f95750670de0b6b3a7640000916108cc916503782dace9d960921b046108c6565b60ff6001610889565b9080925015610969575081906000190438610879565b634e487b7160e01b855260129052602484fd5b90936b048a170391f7dc42444e8fa202901c9238610872565b6d2216e584f5fa1ea926041bedfe98909502811c94610868565b946e5d6af8dedb81196699c329225ee60402811c9461085d565b946f09aa508b5b7a84e1c677de54f3e99bc902811c94610852565b946f31be135f97d08fd981231505542fcfa602811c94610847565b946f70d869a156d2a1b890bb3df62baf32f702811c9461083d565b946fa9f746462d870fdf8a65dc1f90e061e502811c94610833565b946fd097f3bdfd2022b8845ad8f792aa582502811c94610829565b946fe7159475a2c29b7443b29c7fa6e889d902811c9461081f565b946ff3392b0822b70005940c7a398e4b70f302811c94610815565b946ff987a7253ac413176f2b074cf7815e5402811c9461080b565b946ffcbe86c7900a88aedcffc83b479aa3a402811c94610801565b946ffe5dee046a99a2a811c461f1969c305302811c946107f7565b936fff2ea16466c96a3843ec78b326b528610260801c936107ec565b936fff973b41fa98c081472e6896dfb254c00260801c936107e4565b936fffcb9843d60f6159c9db58835c9266440260801c936107dc565b936fffe5caca7e10e4e61c3624eaa0941cd00260801c936107d3565b936ffff2e50f5f656932ef12357cf3c7fdcc0260801c936107ca565b936ffff97272373d413259a46990580e213a0260801c936107c2565b600160801b6107af565b5087516315e4079d60e11b8152fd5b81610784565b627fffff198114610bb25760001901610773565b634e487b7160e01b855260118252602485fd5b600a91500760060b15153861076d565b90503d8086833e610be68183611052565b810188828203126103625781516001600160401b039081811161035a5783019282601f8501121561035a57835193610c1d856110d5565b94610c2a8d519687611052565b8086528d8087019160051b83010191858311610cdb578e01905b828210610cbe575050508b81015191821161035a570181601f8201121561035e578051908b808c610c80610c77866110d5565b91519182611052565b848152019260051b82010192831161035a578b01905b828210610ca65750505038610721565b81518681168103610544578152908b01908b01610c96565b81518060060b8103610cd7578152908e01908e01610c44565b8b80fd5b8a80fd5b88513d87823e3d90fd5b835163ffffffff1685528c975088965093840193909201916001018f610701565b9050948489916106ad565b895163c1ab6dc160e01b81528490fd5b5084831686141561069e565b610d529192508a3d8c11610d59575b610d4a8183611052565b8101906110b6565b9038610690565b503d610d40565b89513d88823e3d90fd5b610d819150893d8b11610d5957610d4a8183611052565b3861066d565b9094508681813d8311610daf575b610d9f8183611052565b810103126103665751938161063a565b503d610d95565b86513d85823e3d90fd5b5050346103a557816003193601126103a557602090517fe453bacb314e78dcd5192e6b1a2b1f0e7c76e92f6b7e429a6a90f04e39db3b768152f35b5050346103a557816003193601126103a55751908152602090f35b5050346103a557816003193601126103a557602090517f880a91047114272656e533301261260c75e4d11543ac7303d6fe4204579ec7278152f35b5050346103a557816003193601126103a557602090517f39f61ca2a1a28fee144218173ec637b649a353e4026b2738c673800e5bf1437b8152f35b50346103665782600319360112610366575490516001600160a01b03909116815260209150f35b5050346103a557816003193601126103a557602090517fe965846df3dd5b1dfa65f58e31477079e90140e0908b6dd31b5aead5a57cf3658152f35b5050346103a55760203660031901126103a5576020916001600160a01b0390829082610f18610feb565b168152600185522054169051908152f35b5050346103a557816003193601126103a5579054905160109190911c6001600160a01b03168152602090f35b9291905034610fe7576020366003190112610fe757803563ffffffff60e01b81168091036105885784546301ffc9a760e01b8552918401526020908390602490829060101c6001600160a01b03165afa918215610fdd5760209392610fbe575b50519015158152f35b610fd6919250833d8111610263576102558183611052565b9038610fb5565b81513d85823e3d90fd5b8380fd5b600435906001600160a01b038216820361100157565b600080fd5b606081019081106001600160401b0382111761102157604052565b634e487b7160e01b600052604160045260246000fd5b608081019081106001600160401b0382111761102157604052565b601f909101601f19168101906001600160401b0382119082101761102157604052565b90816020910312611001575180151581036110015790565b818102929181159184041417156110a057565b634e487b7160e01b600052601160045260246000fd5b9081602091031261100157516001600160a01b03811681036110015790565b6001600160401b0381116110215760051b60200190565b8051156110f95760200190565b634e487b7160e01b600052603260045260246000fd5b8051600110156110f95760400190565b600019828209908281029283808410930391838303936000931461115f57600160401b92848411156108f957500990828211900360c01b910360401c1790565b505090505060401c90565b670de0b6b3a76400009060001982820990828102928380841093039183830393600093146111b457600160801b92848411156108f957500990828211900360801b910360801c1790565b505090505060801c90565b670de0b6b3a764000090600019828209908281029283808410930391838303936000931461120957600160c01b92848411156108f957500990828211900360401b910360c01c1790565b505090505060c01c9056fea26469706673582212206fd10acae81c7591e7e148606d7c3a64004bcee332667f058c79f461cdb834c764736f6c63430008110033",
"devdoc": {
"details": "Here we calculate only the price of asset in USDT, not USD. Before that we need to enableAssetPool, to know what pool use for that asset (what fees). See ISuUniV3Oracle interface for full details.*",
"kind": "dev",
"methods": {
"getFiatPrice1e18(address)": {
"params": {
"asset": "- address of erc20 token contract"
},
"returns": {
"_0": "usdPrice1e18 such that asset.balanceOf() * getFiatPrice1e18(asset) / 1e18 == $$ * 1e18*"
}
},
"supportsInterface(bytes4)": {
"details": "Returns true if this contract implements the interface defined by `interfaceId`. See the corresponding https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] to learn more about how these ids are created. This function call must use less than 30 000 gas."
}
},
"version": 1
},
"userdoc": {
"kind": "user",
"methods": {
"getFiatPrice1e18(address)": {
"notice": "WARNING! Read this description very carefully! function getFiatPrice1e18(address asset) returns (uint256) that: basicAmountOfAsset * getFiatPrice1e18(asset) / 1e18 === $$ * 1e18 in other words, it doesn't matter what's the erc20.decimals is, you just multiply token balance in basic units on value from oracle and get dollar amount multiplied on 1e18. different assets have different deviation threshold (errors) for wBTC it's <= 0.5%, read more https://data.chain.link/ethereum/mainnet/crypto-usd/btc-usd for other asset is can be larger based on particular oracle implementation. examples: market price of btc = $30k, for 0.1 wBTC the unit256 amount is 0.1 * 1e18 0.1 * 1e18 * (price1e18 / 1e18) == $3000 == uint256(3000*1e18) => price1e18 = 30000 * 1e18; market price of usdt = $0.97, for 1 usdt uint256 = 1 * 1e6 so 1*1e6 * price1e18 / 1e18 == $0.97 == uint256(0.97*1e18) => 1*1e6 * (price1e18 / 1e18) / (0.97*1e18) = 1 => price1e18 = 0.97 * (1e18/1e6) * 1e18 assume market price of wBTC = $31,503.77, oracle error = $158 case #1: small amount of wBTC we have 0.0,000,001 wBTC that is worth v = $0.00315 ± $0.00001 = 0.00315*1e18 = 315*1e13 ± 1*1e13 actual balance on the asset b = wBTC.balanceOf() = 0.0000001*1e18 = 1e11 oracle should return or = oracle.getFiatPrice1e18(wBTC) <=> <=> b*or = v => v/b = 315*1e13 / 1e11 = 315*1e2 ± 1e2 error = or.error * b = 1e2 * 1e11 = 1e13 => 1e13/1e18 usd = 1e-5 = 0.00001 usd case #2: large amount of wBTC v = 2,000,000 wBTC = $31,503.77 * 2m ± 158*2m = $63,007,540,000 ± $316,000,000 = 63,007*1e24 ± 316*1e24 for calc convenience we increase error on 0.05 and have v = 63,000*24 ± 300*1e24 = (630 ± 3)*1e26 b = 2*1e6 * 1e18 = 2*1e24 or = v/b = (630 ± 3)*1e26 / 2*1e24 = 315*1e2 ± 1.5*1e2 error = or.error * b = 1.5*100 * 2*1e24 = 3*1e26 = 3*1e8*1e18 = $300,000,000 ~ $316,000,000 assume the market price of USDT = $0.97 ± $0.00485, case #3: little amount of USDT v = USDT amount 0.005 = 0.005*(0.97 ± 0.00485) = 0.00485*1e18 ± 0.00002425*1e18 = 485*1e13 ± 3*1e13 we rounded error up on (3000-2425)/2425 ~= +24% for calculation convenience. b = USDT.balanceOf() = 0.005*1e6 = 5*1e3 b*or = v => or = v/b = (485*1e13 ± 3*1e13) / 5*1e3 = 970*1e9 ± 6*1e9 error = 6*1e9 * 5*1e3 / 1e18 = 30*1e12/1e18 = 3*1e-5 = $0,00005 case #4: lot of USDT v = we have 100,000,000,000 USDT = $97B = 97*1e9*1e18 ± 0.5*1e9*1e18 b = USDT.balanceOf() = 1e11*1e6 = 1e17 or = v/b = (97*1e9*1e18 ± 0.5*1e9*1e18) / 1e17 = 970*1e9 ± 5*1e9 error = 5*1e9 * 1e17 = 5*1e26 = 0.5 * 1e8*1e18"
}
},
"notice": "check SuUniV3Oracle section in ORACLE_ARCHITECTURE.md",
"version": 1
},
"storageLayout": {
"storage": [
{
"astId": 671,
"contract": "contracts/periphery/contracts/oracle/SuUniV3Oracle.sol:SuUniV3Oracle",
"label": "_initialized",
"offset": 0,
"slot": "0",
"type": "t_uint8"
},
{
"astId": 674,
"contract": "contracts/periphery/contracts/oracle/SuUniV3Oracle.sol:SuUniV3Oracle",
"label": "_initializing",
"offset": 1,
"slot": "0",
"type": "t_bool"
},
{
"astId": 28586,
"contract": "contracts/periphery/contracts/oracle/SuUniV3Oracle.sol:SuUniV3Oracle",
"label": "ACCESS_CONTROL_SINGLETON",
"offset": 2,
"slot": "0",
"type": "t_contract(ISuAccessControl)32175"
},
{
"astId": 33867,
"contract": "contracts/periphery/contracts/oracle/SuUniV3Oracle.sol:SuUniV3Oracle",
"label": "assetToPool",
"offset": 0,
"slot": "1",
"type": "t_mapping(t_address,t_contract(IUniswapV3Pool)16627)"
},
{
"astId": 33869,
"contract": "contracts/periphery/contracts/oracle/SuUniV3Oracle.sol:SuUniV3Oracle",
"label": "UNISWAP_FACTORY",
"offset": 0,
"slot": "2",
"type": "t_address"
},
{
"astId": 33871,
"contract": "contracts/periphery/contracts/oracle/SuUniV3Oracle.sol:SuUniV3Oracle",
"label": "USDT",
"offset": 0,
"slot": "3",
"type": "t_address"
},
{
"astId": 33873,
"contract": "contracts/periphery/contracts/oracle/SuUniV3Oracle.sol:SuUniV3Oracle",
"label": "ORACLE",
"offset": 0,
"slot": "4",
"type": "t_address"
}
],
"types": {
"t_address": {
"encoding": "inplace",
"label": "address",
"numberOfBytes": "20"
},
"t_bool": {
"encoding": "inplace",
"label": "bool",
"numberOfBytes": "1"
},
"t_contract(ISuAccessControl)32175": {
"encoding": "inplace",
"label": "contract ISuAccessControl",
"numberOfBytes": "20"
},
"t_contract(IUniswapV3Pool)16627": {
"encoding": "inplace",
"label": "contract IUniswapV3Pool",
"numberOfBytes": "20"
},
"t_mapping(t_address,t_contract(IUniswapV3Pool)16627)": {
"encoding": "mapping",
"key": "t_address",
"label": "mapping(address => contract IUniswapV3Pool)",
"numberOfBytes": "32",
"value": "t_contract(IUniswapV3Pool)16627"
},
"t_uint8": {
"encoding": "inplace",
"label": "uint8",
"numberOfBytes": "1"
}
}
}
}