Skip to content

Commit

Permalink
sync changes, add github action (#7)
Browse files Browse the repository at this point in the history
* sync changes, add github action

* fix cli

* fix ci for sdk

* fix ci for sdk

* fix ci for sdk
  • Loading branch information
andrewsource147 authored Jan 12, 2024
1 parent 2f490c2 commit 8257f2d
Show file tree
Hide file tree
Showing 51 changed files with 7,396 additions and 5,109 deletions.
10 changes: 10 additions & 0 deletions .github/actions/setup-anchor/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: "Setup anchor-cli"
description: "Setup node js and anchor cli"
runs:
using: "composite"
steps:
- uses: actions/setup-node@v2
with:
node-version: ${{ env.NODE_VERSION }}
- run: npm install -g @coral-xyz/anchor-cli@${{ env.ANCHOR_CLI_VERSION }} yarn
shell: bash
7 changes: 7 additions & 0 deletions .github/actions/setup-dep/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
name: "Setup"
description: "Setup program dependencies"
runs:
using: "composite"
steps:
- run: sudo apt-get update && sudo apt-get install -y pkg-config build-essential libudev-dev
shell: bash
21 changes: 21 additions & 0 deletions .github/actions/setup-solana/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: "Setup Solana"
description: "Setup Solana"
runs:
using: "composite"
steps:
- uses: actions/cache@v2
name: Cache Solana Tool Suite
id: cache-solana
with:
path: |
~/.cache/solana/
~/.local/share/solana/
key: solana-${{ runner.os }}-v0000-${{ env.SOLANA_CLI_VERSION }}
- run: sh -c "$(curl -sSfL https://release.solana.com/v${{ env.SOLANA_CLI_VERSION }}/install)"
shell: bash
- run: echo "$HOME/.local/share/solana/install/active_release/bin/" >> $GITHUB_PATH
shell: bash
- run: solana-keygen new --no-bip39-passphrase
shell: bash
- run: solana config set --url localhost
shell: bash
46 changes: 46 additions & 0 deletions .github/workflows/ci-pr-main-cli.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Lb Clmm Cli

on:
pull_request:
branches:
- main

env:
SOLANA_CLI_VERSION: 1.16.1
NODE_VERSION: 18.14.2
ANCHOR_CLI_VERSION: 0.28.0

jobs:
cli_changed_files:
runs-on: ubuntu-latest
outputs:
cli: ${{steps.changed-files-specific.outputs.any_changed}}
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Get specific changed files
id: changed-files-specific
uses: tj-actions/[email protected]
with:
files: |
cli
cli_build:
runs-on: ubuntu-latest
needs: cli_changed_files
if: needs.cli_changed_files.outputs.cli == 'true'
steps:
- uses: actions/checkout@v2
- uses: ./.github/actions/setup-solana
- uses: ./.github/actions/setup-dep
- uses: ./.github/actions/setup-anchor
# Install rust + toolchain
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
components: clippy
# Cache rust, cargo
- uses: Swatinem/rust-cache@v1
- run: cargo build -p cli
shell: bash
46 changes: 46 additions & 0 deletions .github/workflows/ci-pr-main-market-making.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Lb Clmm Cli

on:
pull_request:
branches:
- main

env:
SOLANA_CLI_VERSION: 1.16.1
NODE_VERSION: 18.14.2
ANCHOR_CLI_VERSION: 0.28.0

jobs:
market_making_changed_files:
runs-on: ubuntu-latest
outputs:
market_making: ${{steps.changed-files-specific.outputs.any_changed}}
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Get specific changed files
id: changed-files-specific
uses: tj-actions/[email protected]
with:
files: |
market_making
market_making_build:
runs-on: ubuntu-latest
needs: market_making_changed_files
if: needs.market_making_changed_files.outputs.market_making == 'true'
steps:
- uses: actions/checkout@v2
- uses: ./.github/actions/setup-solana
- uses: ./.github/actions/setup-dep
- uses: ./.github/actions/setup-anchor
# Install rust + toolchain
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
components: clippy
# Cache rust, cargo
- uses: Swatinem/rust-cache@v1
- run: cargo build -p market_making
shell: bash
46 changes: 46 additions & 0 deletions .github/workflows/ci-pr-main-program.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Lb Clmm Program

on:
pull_request:
branches:
- main

env:
SOLANA_CLI_VERSION: 1.16.1
NODE_VERSION: 18.14.2
ANCHOR_CLI_VERSION: 0.28.0

jobs:
program_changed_files:
runs-on: ubuntu-latest
outputs:
program: ${{steps.changed-files-specific.outputs.any_changed}}
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Get specific changed files
id: changed-files-specific
uses: tj-actions/[email protected]
with:
files: |
programs/lb_clmm
lb_clmm_anchor_build:
runs-on: ubuntu-latest
needs: program_changed_files
if: needs.program_changed_files.outputs.program == 'true'
steps:
- uses: actions/checkout@v2
- uses: ./.github/actions/setup-solana
- uses: ./.github/actions/setup-dep
- uses: ./.github/actions/setup-anchor
# Install rust + toolchain
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
components: clippy
# Cache rust, cargo
- uses: Swatinem/rust-cache@v1
- run: anchor build
shell: bash
54 changes: 54 additions & 0 deletions .github/workflows/ci-pr-main-sdk.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Lb Clmm SDK

on:
pull_request:
branches:
- main

env:
SOLANA_CLI_VERSION: 1.16.1
NODE_VERSION: 18.14.2
ANCHOR_CLI_VERSION: 0.28.0

jobs:
sdk_changed_files:
runs-on: ubuntu-latest
outputs:
sdk: ${{steps.changed-files-specific.outputs.any_changed}}
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Get specific changed files
id: changed-files-specific
uses: tj-actions/[email protected]
with:
files: |
ts-client
sdk_test:
runs-on: ubuntu-latest
needs: sdk_changed_files
if: needs.sdk_changed_files.outputs.sdk == 'true'
steps:
- uses: actions/checkout@v2
- uses: ./.github/actions/setup-solana
- uses: ./.github/actions/setup-dep
- uses: ./.github/actions/setup-anchor
# Install rust + toolchain
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
components: clippy
# Cache node_modules
- uses: actions/cache@v2
id: cache-node-modules
with:
path: ./ts-client/node_modules
key: ${{ runner.os }}-${{ hashFiles('./package-lock.json') }}
- run: anchor build -- --features localnet
shell: bash
- run: anchor localnet -- --features localnet & sleep 2
shell: bash
- run: cd ts-client && npm install && npm run test
shell: bash
2 changes: 1 addition & 1 deletion cli/src/instructions/add_liquidity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ pub fn add_liquidity<C: Deref<Target = impl Signer> + Clone>(
reserve_y: lb_pair_state.reserve_y,
token_x_mint: lb_pair_state.token_x_mint,
token_y_mint: lb_pair_state.token_y_mint,
owner: program.payer(),
sender: program.payer(),
user_token_x,
user_token_y,
// TODO: token 2022
Expand Down
2 changes: 1 addition & 1 deletion cli/src/instructions/claim_fee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ pub fn claim_fee<C: Deref<Target = impl Signer> + Clone>(
bin_array_lower,
bin_array_upper,
lb_pair: position_state.lb_pair,
owner: program.payer(),
sender: program.payer(),
position,
reserve_x: lb_pair_state.reserve_x,
reserve_y: lb_pair_state.reserve_y,
Expand Down
2 changes: 1 addition & 1 deletion cli/src/instructions/claim_reward.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ pub fn claim_reward<C: Deref<Target = impl Signer> + Clone>(
token_program: anchor_spl::token::ID,
position,
user_token_account,
owner: program.payer(),
sender: program.payer(),
event_authority,
program: lb_clmm::ID,
};
Expand Down
2 changes: 1 addition & 1 deletion cli/src/instructions/close_position.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub fn close_position<C: Deref<Target = impl Signer> + Clone>(
bin_array_lower,
bin_array_upper,
lb_pair: position_state.lb_pair,
owner: position_state.owner,
sender: position_state.owner,
rent_receiver: position_state.owner,
position,
event_authority,
Expand Down
6 changes: 5 additions & 1 deletion cli/src/instructions/initialize_lb_pair.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use std::ops::Deref;

use anchor_client::solana_client::rpc_config::RpcSendTransactionConfig;
use anchor_client::solana_sdk::signature::Keypair;
use anchor_client::{solana_sdk::pubkey::Pubkey, solana_sdk::signer::Signer, Program};

use anchor_spl::token::Mint;
Expand Down Expand Up @@ -62,15 +63,17 @@ pub fn initialize_lb_pair<C: Deref<Target = impl Signer> + Clone>(
let (preset_parameter, _bump) = derive_preset_parameter_pda(bin_step);

if permission {
let base_kp = Keypair::new();
let accounts = accounts::InitializePermissionLbPair {
base: base_kp.pubkey(),
lb_pair,
bin_array_bitmap_extension: None,
reserve_x,
reserve_y,
token_mint_x,
token_mint_y,
oracle,
funder: program.payer(),
admin: program.payer(),
preset_parameter,
rent: anchor_client::solana_sdk::sysvar::rent::ID,
system_program: anchor_client::solana_sdk::system_program::ID,
Expand All @@ -88,6 +91,7 @@ pub fn initialize_lb_pair<C: Deref<Target = impl Signer> + Clone>(
let signature = request_builder
.accounts(accounts)
.args(ix)
.signer(&base_kp)
.send_with_spinner_and_config(transaction_config);

println!("Initialize Permission LB pair {lb_pair}. Signature: {signature:#?}");
Expand Down
2 changes: 1 addition & 1 deletion cli/src/instructions/remove_liquidity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ pub fn remove_liquidity<C: Deref<Target = impl Signer> + Clone>(
reserve_y: lb_pair_state.reserve_y,
token_x_mint: lb_pair_state.token_x_mint,
token_y_mint: lb_pair_state.token_y_mint,
owner: program.payer(),
sender: program.payer(),
user_token_x,
user_token_y,
token_x_program: anchor_spl::token::ID,
Expand Down
6 changes: 3 additions & 3 deletions cli/src/instructions/remove_liquidity_by_price_range.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ pub fn remove_liquidity_by_price_range<C: Deref<Target = impl Signer> + Clone>(
reserve_y: lb_pair_state.reserve_y,
token_x_mint: lb_pair_state.token_x_mint,
token_y_mint: lb_pair_state.token_y_mint,
owner: program.payer(),
sender: program.payer(),
user_token_x,
user_token_y,
token_x_program: anchor_spl::token::ID,
Expand All @@ -141,7 +141,7 @@ pub fn remove_liquidity_by_price_range<C: Deref<Target = impl Signer> + Clone>(
bin_array_lower,
bin_array_upper,
lb_pair,
owner: program.payer(),
sender: program.payer(),
position,
reserve_x: lb_pair_state.reserve_x,
reserve_y: lb_pair_state.reserve_y,
Expand All @@ -164,7 +164,7 @@ pub fn remove_liquidity_by_price_range<C: Deref<Target = impl Signer> + Clone>(
bin_array_lower,
bin_array_upper,
rent_receiver: program.payer(),
owner: program.payer(),
sender: program.payer(),
event_authority,
program: lb_clmm::ID,
}
Expand Down
4 changes: 2 additions & 2 deletions cli/src/instructions/seed_liquidity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ pub fn seed_liquidity<C: Deref<Target = impl Signer> + Clone>(
bin_array_bitmap_extension: None,
bin_array_lower,
bin_array_upper,
owner: program.payer(),
sender: program.payer(),
event_authority,
program: lb_clmm::ID,
reserve_x: lb_pair_state.reserve_x,
Expand Down Expand Up @@ -289,7 +289,7 @@ pub fn seed_liquidity<C: Deref<Target = impl Signer> + Clone>(
bin_array_bitmap_extension: None,
bin_array_lower,
bin_array_upper,
owner: program.payer(),
sender: program.payer(),
event_authority,
program: lb_clmm::ID,
reserve_x: lb_pair_state.reserve_x,
Expand Down
8 changes: 4 additions & 4 deletions market_making/src/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ impl Core {
reserve_y: lb_pair_state.reserve_y,
token_x_mint: lb_pair_state.token_x_mint,
token_y_mint: lb_pair_state.token_y_mint,
owner: payer.pubkey(),
sender: payer.pubkey(),
user_token_x,
user_token_y,
token_x_program: anchor_spl::token::ID,
Expand All @@ -249,7 +249,7 @@ impl Core {
bin_array_lower,
bin_array_upper,
lb_pair,
owner: payer.pubkey(),
sender: payer.pubkey(),
position,
reserve_x: lb_pair_state.reserve_x,
reserve_y: lb_pair_state.reserve_y,
Expand All @@ -272,7 +272,7 @@ impl Core {
bin_array_lower,
bin_array_upper,
rent_receiver: payer.pubkey(),
owner: payer.pubkey(),
sender: payer.pubkey(),
event_authority,
program: lb_clmm::ID,
}
Expand Down Expand Up @@ -528,7 +528,7 @@ impl Core {
bin_array_bitmap_extension,
bin_array_lower,
bin_array_upper,
owner: payer.pubkey(),
sender: payer.pubkey(),
event_authority,
program: lb_clmm::ID,
reserve_x: lb_pair_state.reserve_x,
Expand Down
Loading

0 comments on commit 8257f2d

Please sign in to comment.