@steerprotocol/strategy-utils 2.0.5 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/asconfig.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "targets": {
3
3
  "debug": {
4
- "binaryFile": "build/untouched.wasm",
5
- "textFile": "build/untouched.wat",
4
+ "outFile": "build/debug.wasm",
5
+ "textFile": "build/debug.wat",
6
6
  "sourceMap": true,
7
7
  "debug": true
8
8
  },
9
9
  "release": {
10
- "binaryFile": "build/optimized.wasm",
11
- "textFile": "build/optimized.wat",
10
+ "outFile": "build/release.wasm",
11
+ "textFile": "build/release.wat",
12
12
  "sourceMap": true,
13
13
  "optimizeLevel": 3,
14
14
  "shrinkLevel": 0,
@@ -16,5 +16,8 @@
16
16
  "noAssert": false
17
17
  }
18
18
  },
19
- "options": {}
19
+ "options": {
20
+ "bindings": "esm",
21
+ "transform": ["json-as/transform"]
22
+ }
20
23
  }
@@ -1,7 +1,6 @@
1
1
  export * from './Math';
2
2
  export * from './MovingAverages';
3
3
  export * from './Ranges';
4
- export * from './UniswapLiquidityUtils';
5
4
  export * from './SlidingWindow';
6
5
  export * from './console';
7
6
  export * from './types';
@@ -1,4 +1,4 @@
1
- import * as JSON from '@serial-as/json'
1
+ import { JSON } from 'json-as/assembly';
2
2
 
3
3
  @serializable
4
4
  export class Candle{
package/index.html ADDED
@@ -0,0 +1,10 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <script type="module">
5
+ import { initialize, execute } from "./build/release.js";
6
+ document.body.innerText = 'Implementation missing, please fix index.html';;
7
+ </script>
8
+ </head>
9
+ <body></body>
10
+ </html>
package/package.json CHANGED
@@ -1,14 +1,15 @@
1
1
  {
2
2
  "name": "@steerprotocol/strategy-utils",
3
- "version": "2.0.5",
3
+ "version": "2.1.0",
4
4
  "description": "Strategy utilities library for Steer Protocol strategies",
5
5
  "main": "assembly/index.ts",
6
6
  "types": "assembly/index.ts",
7
7
  "scripts": {
8
8
  "test": "yarn jest",
9
- "asbuild:untouched": "asc assembly/index.ts --target debug --exportRuntime --transform as-bind --transform @serial-as/transform",
10
- "asbuild:optimized": "asc assembly/index.ts --target release --exportRuntime --transform as-bind --transform @serial-as/transform",
11
- "asbuild": "npm run asbuild:untouched && npm run asbuild:optimized",
9
+ "asbuild:debug": "asc assembly/index.ts --target debug",
10
+ "asbuild:release": "asc assembly/index.ts --target release",
11
+ "asbuild": "npm run asbuild:debug && npm run asbuild:release",
12
+ "start": "npx serve .",
12
13
  "docs": "typedoc --tsconfig ./tsconfig.json",
13
14
  "strategy": "yarn asbuild && yarn test",
14
15
  "semantic-release": "semantic-release",
@@ -17,23 +18,22 @@
17
18
  "author": "Derek Barrera <derekbarrera@gmail.com>",
18
19
  "license": "ISC",
19
20
  "dependencies": {
20
- "@assemblyscript/loader": "0.19.9",
21
21
  "@babel/preset-typescript": "^7.14.5",
22
22
  "@semantic-release/changelog": "^5.0.1",
23
23
  "@semantic-release/git": "^9.0.0",
24
- "@serial-as/json": "1.0.2",
25
24
  "@steerprotocol/base-strategy": "^0.0.2",
26
- "as-bind": "^0.8.0",
27
- "assemblyscript-json": "^1.1.0",
25
+ "as-bignum": "^0.2.23",
28
26
  "commitizen": "^4.2.4",
29
27
  "conventional-changelog-conventionalcommits": "^4.6.0",
30
- "typescript": "^4.3.5"
28
+ "json-as": "^0.5.20",
29
+ "typescript": "^4.3.5",
30
+ "visitor-as": "^0.11.4"
31
31
  },
32
32
  "devDependencies": {
33
33
  "@babel/preset-env": "^7.14.8",
34
34
  "@types/jest": "^27.0.1",
35
35
  "@types/node": "^16.11.11",
36
- "assemblyscript": "0.19.9",
36
+ "assemblyscript": "^0.27.0",
37
37
  "babel-core": "^6.26.3",
38
38
  "babel-jest": "^27.0.6",
39
39
  "cz-conventional-changelog": "3.3.0",
@@ -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
- }