Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mm #68

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

mm #68

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 18 additions & 18 deletions .github/workflows/build-all.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
name: Build-All

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

env:
CARGO_TERM_COLOR: always

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Build
run: ./scripts/build-all.sh
name: Build-All
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
env:
CARGO_TERM_COLOR: always
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Build
run: ./scripts/build-all.sh
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
.anchor
.anchor
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# **Clockwork examples**

This repo contains example automated smart-contracts built with the [**Clockwork SDK**](https://docs.clockwork.xyz).
- [**Hello Clockwork**](https://github.com/clockwork-xyz/examples/tree/main/hello_clockwork) – Prints "Hello world" and the current timestamp every 60 seconds
- [**Recurring payments**](https://github.com/clockwork-xyz/examples/tree/main/payments) – Executes an SPL token transfer on a user-defined schedule.
- [**Token distributor**](https://github.com/clockwork-xyz/examples/tree/main/distributor) – Mints a new token and sends it to a target user every 60 seconds.
- [**Dollar cost averaging**](https://github.com/clockwork-xyz/examples/tree/main/investments) – Executes a swap on Serum on a user-defined schedule.
- [**Serum crank**](https://github.com/clockwork-xyz/examples/tree/main/serum_crank) – Indefinitely processes open orders on a permissioned Serum market.
- [**Subscriptions**](https://github.com/clockwork-xyz/examples/tree/main/subscriptions) – Allow users to subscribe to subscriptions by paying on a recurrent schedule.

# **Clockwork examples**
This repo contains example automated smart-contracts built with the [**Clockwork SDK**](https://docs.clockwork.xyz).
- [**Hello Clockwork**](https://github.com/clockwork-xyz/examples/tree/main/hello_clockwork) – Prints "Hello world" and the current timestamp every 60 seconds
- [**Recurring payments**](https://github.com/clockwork-xyz/examples/tree/main/payments) – Executes an SPL token transfer on a user-defined schedule.
- [**Token distributor**](https://github.com/clockwork-xyz/examples/tree/main/distributor) – Mints a new token and sends it to a target user every 60 seconds.
- [**Dollar cost averaging**](https://github.com/clockwork-xyz/examples/tree/main/investments) – Executes a swap on Serum on a user-defined schedule.
- [**Serum crank**](https://github.com/clockwork-xyz/examples/tree/main/serum_crank) – Indefinitely processes open orders on a permissioned Serum market.
- [**Subscriptions**](https://github.com/clockwork-xyz/examples/tree/main/subscriptions) – Allow users to subscribe to subscriptions by paying on a recurrent schedule.
2 changes: 1 addition & 1 deletion SOLANA_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.4.12
1.4.12
2 changes: 1 addition & 1 deletion distributor/client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ clockwork-client = { version = "1.4.2" }
clockwork-utils = { version = "1.4.2" }
distributor = { path = "../programs/distributor", features = ["no-entrypoint"], version = "0.1.0" }
solana-cli-config = "1.10.4"
solana-sdk = "1.14.12"
solana-sdk = "*"

[features]
localnet = []
2 changes: 1 addition & 1 deletion hello_clockwork/client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ clockwork-client = { version = "1.4.2" }
clockwork-utils = { version = "1.4.2" }
anchor-lang = "0.26.0"
solana-cli-config = "1.10.4"
solana-sdk = "1.14.12"
solana-sdk = "*"

[features]
localnet = []
7 changes: 7 additions & 0 deletions openbook_arb/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

.anchor
.DS_Store
target
**/*.rs.bk
node_modules
test-ledger
8 changes: 8 additions & 0 deletions openbook_arb/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

.anchor
.DS_Store
target
node_modules
dist
build
test-ledger
16 changes: 16 additions & 0 deletions openbook_arb/Anchor.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[features]
seeds = false
skip-lint = false

[programs.mainnet]
openbook_dca = "B9JNaF9toUNv2Dkj8WEUMMybzfrFwREq7YMno2ht3Uhj"

[registry]
url = "https://api.apr.dev"

[provider]
cluster = "mainnet"
wallet = "~/.config/solana/id.json"

[scripts]
test = "yarn run ts-mocha -p ./tsconfig.json -t 1000000 tests/**/*.ts"
14 changes: 14 additions & 0 deletions openbook_arb/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[workspace]
members = [
"client",
"programs/*"
]

[profile.release]
overflow-checks = true
lto = "fat"
codegen-units = 1
[profile.release.build-override]
opt-level = 3
incremental = false
codegen-units = 1
27 changes: 27 additions & 0 deletions openbook_arb/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# **Openbook DCA Program**

## Prerequisites
- Make sure you have both the [solana cli](https://docs.solana.com/cli/install-solana-cli-tools) and [anchor cli](https://project-serum.github.io/anchor/getting-started/installation.html#build-from-source-for-other-operating-systems) installed on your computer.
- clone the [clockwork repo](https://github.com/clockwork-xyz/clockwork/) locally to your machine

## Localnet
### Openbook DCA
- run `anchor build` in the root directory of `openbook_dca`
- run `solana address -k target/deploy/openbook_dca-keypair.json` to get your program's ID
- copy that ID and replace it with the Program ID in `id.rs`
- run `anchor build` again
### Openbook Crank
- navigate to the `openbook_crank` directory of the examples repo
- run `anchor build` in the root directory of `openbook_crank`
- run `solana address -k target/deploy/openbook_crank-keypair.json` to get your program's ID
- copy that ID and replace it with the Program ID in `id.rs`
- run `anchor build` again
### Deployment
- be sure to set your solana config to devnet with `solana config set --url http://localhost:8899`
- if you have the [clockwork repo](https://github.com/clockwork-xyz/clockwork/#getting-started) and you've followed the [getting started](https://github.com/clockwork-xyz/clockwork/#getting-started) guide on how to build from source you can run the following command
```bash
clockwork localnet --bpf-program 9xQeWvG816bUx9EPjHmaT23yvVM2ZWbrrpZb9PusVFin <PATH TO THIS FILE>/clockwork-xyz/examples/openbook_dca/dex/serum_dex.so --bpf-program <PATH TO THIS FILE>/clockwork-xyz/examples/openbook_crank/target/deploy/openbook_crank-keypair.json <PATH TO THIS FILE>/clockwork-xyz/examples/openbook_dca/target/deploy/openbook_crank.so --bpf-program <PATH TO THIS FILE>/clockwork-xyz/examples/openbook_dca/target/deploy/openbook_dca-keypair.json <PATH TO THIS FILE>/clockwork-xyz/examples/openbook_dca/target/deploy/openbook_dca.so
```
### Client
- navigate to the `client` directory
- run `cargo run`
12 changes: 12 additions & 0 deletions openbook_arb/client/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[package]
name = "dca-client"
version = "0.1.0"
edition = "2021"

[dependencies]
openbook-dca = { path = "../programs/openbook_dca", features = ["no-entrypoint"], version = "0.1.0" }
clockwork-client = "1.4.2"
anchor-spl = { version = "0.26.0", features = ["dex"] }
anchor-lang = "0.26.0"
solana-sdk = "1.14.12"
solana-cli-config = "1.14.12"
Loading