Skip to content

Commit e53277f

Browse files
ReadMe
1 parent 14c200e commit e53277f

2 files changed

Lines changed: 18 additions & 45 deletions

File tree

README.md

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@ AssemblyScript based Strategy Template for the Steer Protocol.
33

44
Start building on [Steer Protocol](https://steer.finance) with our AssemblyScript template. Expand your smart contract capabilities with off-chain compute! More info can be found here: [Documentation](https://docs.steer.finance/steer-apps/writing-an-app)
55

6-
## Tip!
6+
This is a template example of how to make a liquidity provision strategy that acts similarly to a stop loss. The strategist picks a percent and recent candles are passed into the strategy. From the recent price, a position is made with the upper tick set to the current price, and the lower tick at the precent down from the current price, like a stop loss. This would likely not be a great strategy for most assets/situations, be smart if you want to use this strategy.
77

8-
[Use our one-click in-browser development environment](https://bit.ly/3BsQ3DT)
8+
## Parameters
9+
10+
This strategy only accepts one parameter from the data connectors: any OHLC type object.
911

1012
## Project Structure
1113
Apps have three external functions that are used by the Steer system. Additional methods, classes, or varaibles can be used in conjunction with these required functions for any desired behavior. For more information please see the app interface. This design means, that as a developer, you only need to implement the methods which are required for the app to work.
@@ -23,12 +25,23 @@ Below are the significant files and folders which you will want to get familiar
2325
```
2426

2527
## Project Setup
26-
Once the template has been cloned, you will need to install the project dependencies. This can be done via the following command:
28+
Once the repository has been cloned, you will need to install the project dependencies. This can be done via the following command:
2729

2830
```yarn install```
2931

3032
INFO
3133
You will notice that there is a post-install script which will compile the ./assembly source folder and populate the ./build folder. This is done to make it easier to run the tests. We will cover this later.
3234

33-
Once you have set up your project, you can begin defining your app.
35+
After making chenges to the assemblyscript code, compile and build the wasm files with the command:
36+
37+
```yarn asbuild```
38+
39+
You will find a number of webassembly related files in the ./build folder.
40+
41+
The testing suite can be found the ./tests source folder, unit tests are written in index.test.ts and can be configured there.
42+
43+
To run the testing suite, run:
44+
45+
```yarn test```
3446

47+
For more in depth testing of the strategy and performance try using Steer's backtesting toolkit to simulate realistic conditions.

tests/index.test.ts

Lines changed: 1 addition & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,7 @@
1-
import { config, prices, config_payload, prices2 } from "./utils";
1+
import { config, config_payload, prices2 } from "./utils";
22
import fs from 'fs';
33
import { WasmModule, loadWasm } from "@steerprotocol/app-loader";
44

5-
// We use untouched so that we can run the un-optimized version of the wasm which will provide better stacktraces
6-
// const myModule = require("../untouchLoader");
7-
8-
interface DataModel {
9-
open: number;
10-
high: number;
11-
close: number;
12-
low: number;
13-
}
14-
15-
// function generateRandomData(amount: number): DataModel[] {
16-
// const data: DataModel[] = [];
17-
18-
// for (let i = 0; i < amount; i++) {
19-
// const open = Math.random() * 1000
20-
// const high = Math.random() * 1000
21-
// const close = Math.random() * 1000
22-
// const low = Math.random() * 1000
23-
24-
// data.push({ open, high, close, low });
25-
// }
26-
27-
// return data;
28-
// }
29-
30-
31-
325
describe("WASM Module", () => {
336
let myModule: WasmModule;
347

@@ -41,29 +14,17 @@ describe("WASM Module", () => {
4114
const result = myModule.config();
4215
// Pull the result from memory and parse the result
4316
const parsedResult = JSON.parse(result);
44-
4517
// The result should match the given config
4618
expect(parsedResult).toStrictEqual(JSON.parse(config));
4719
});
4820

4921
test("can run execute", async () => {
50-
51-
52-
5322
// The actual strategy instantiation and execution
5423
myModule.initialize(config_payload);
55-
// Here we pin the array to the WASM memory
56-
// let priceMemoryRef = myModule.__pin(
57-
// myModule.__newString(JSON.stringify(prices))
58-
// );
59-
6024
// Call the config function on the strategy bundle
6125
const result = myModule["execute(param_1: string)"](JSON.stringify(prices2));
62-
63-
// console.log(result)
6426
// Pull the result from memory and parse the result
6527
const parsedResult = JSON.parse(result);
66-
6728
// The result should match the given config
6829
expect(JSON.stringify(parsedResult)).toStrictEqual(
6930
`{\"functionName\":\"tend(uint256,(int24[],int24[],uint16[]),bytes)\",\"typesArray\":[\"uint256\",\"tuple(int24[],int24[],uint16[])\",\"bytes\"],\"valuesArray\":[10000,[[492120],[492720],[100]],\"0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff000000000000000000000000ffffffffffffffffffffffffffffffffffffffff\"]}`
@@ -72,4 +33,3 @@ describe("WASM Module", () => {
7233
});
7334
});
7435

75-
// `{"bins":[{"lowerBound":"-276330","upperBound":"-276320","weight":"1"}]}`

0 commit comments

Comments
 (0)