@steerprotocol/strategy-utils 2.0.5 → 2.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/assembly/utils/index.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { Position } from "./types";
|
|
2
|
-
|
|
3
|
-
export function getTickSpacing(poolFee: i32): i32 {
|
|
4
|
-
let spacing = 0;
|
|
5
|
-
switch (poolFee) {
|
|
6
|
-
case 100:
|
|
7
|
-
spacing = 1;
|
|
8
|
-
break;
|
|
9
|
-
case 500:
|
|
10
|
-
spacing = 10;
|
|
11
|
-
break;
|
|
12
|
-
case 3000:
|
|
13
|
-
spacing = 60;
|
|
14
|
-
break;
|
|
15
|
-
default:
|
|
16
|
-
spacing = 200;
|
|
17
|
-
}
|
|
18
|
-
return spacing;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
// Function shaped for making positions with the UniLiquidityManager contract for ease
|
|
22
|
-
export function renderULMResult(
|
|
23
|
-
positions: Array<Position>,
|
|
24
|
-
totalLiquidity1e4: number
|
|
25
|
-
): string {
|
|
26
|
-
// Construct necessary object
|
|
27
|
-
const lowerTicks: Array<i32> = [];
|
|
28
|
-
const upperTicks: Array<i32> = [];
|
|
29
|
-
const weights: Array<i32> = [];
|
|
30
|
-
|
|
31
|
-
for (let i = 0; i < positions.length; i++) {
|
|
32
|
-
lowerTicks.push(positions[i].startTick);
|
|
33
|
-
upperTicks.push(positions[i].endTick);
|
|
34
|
-
weights.push(positions[i].weight);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
return (
|
|
38
|
-
`{"functionName":"tend(uint256,(int24[],int24[],uint16[]),bytes)",
|
|
39
|
-
"typesArray":["uint256","tuple(int24[],int24[],uint16[])","bytes"],
|
|
40
|
-
"valuesArray":[` +
|
|
41
|
-
totalLiquidity1e4.toString() +
|
|
42
|
-
`, [[` +
|
|
43
|
-
lowerTicks.toString() +
|
|
44
|
-
"],[" +
|
|
45
|
-
upperTicks.toString() +
|
|
46
|
-
"],[" +
|
|
47
|
-
weights.toString() +
|
|
48
|
-
`]], "0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff000000000000000000000000ffffffffffffffffffffffffffffffffffffffff"]
|
|
49
|
-
}`
|
|
50
|
-
);
|
|
51
|
-
// The bytes value here is a placeholder for encoding that gets replaced with time-sensitive data upon execution. It will actually be the swap amount for re-balancing (int256) and slippage limit (uint160)
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
// TODO: Might need to be rewritten for assets
|
|
55
|
-
// Price must be in the native token
|
|
56
|
-
// token0 for token1
|
|
57
|
-
export function getTickFromPrice(price: f32): f32 {
|
|
58
|
-
const tick = Math.log(price) / Math.log(f32(1.0001));
|
|
59
|
-
return f32(tick);
|
|
60
|
-
}
|