Skip to content

Commit

Permalink
V3.0.0 - Rebalancing Light (#111)
Browse files Browse the repository at this point in the history
* feat: moved function validation from lib.rs to each instruction file (#91)

* feat: moved function validation from lib.rs to each instruction file

* Integration Tests and CI improvements (#92)

* Several small improvments

* Test now use container wallet without any ties to other executions. The previous wallet  now became the bank.

* Update devnet id

* feat: moved function validation from lib.rs to each instruction file (#91)

* feat: moved function validation from lib.rs to each instruction file

* cleanup

* Update CI

* Fix sol transfer

* Remove fees from the moved amount

* Fix CI

* Update CI

* CI

* CI

* CI

* ci

* trigger build

* Update CI

* CI

* Remove small values in test that are offsetted by the rent and fee until we implement payer/signer in the mint/redeem

* Fees

* Actually wait for TX to be confirmed before going further to prevent unreliable results

* Move await to the API

* Increase fee offset toprevent issues
Increase crank interval for devnet
Cleanup

* - Upgrade to latest UXD Client
- fix collapsed group
- fix display in insurance tests

* - fix authority typo

* Test close

* fix lamports

* Fix Cleanup

* Sol not lamports in CI transfer

* Remove small amount tests

* remove unneeded provider

Co-authored-by: Lexington Brill <[email protected]>

* Use a fresh provider each time for test

* 2.0.1 - Improve computing + IDL update for typo (#95)

* + Cleanup
+ remove msg!
+ improve computing used mango anchor wrapper

* Update version due to IDL change

* Fix typo "roty"

* Update client to 4.16

* Update UXD-client to 4.17.0

* fixed version uxd-client

* commented emit

* - Remove warning with unused import
- Comment about commenting out the events emits

* Add missing error (It was using the other slippage error, which is not the correct one!)

Co-authored-by: cnek <[email protected]>

* Multi Collateral Testing (#99)

* Not all tests passing, need to improve the ones with the redeemable_soft cap cause it's different for SOL, BTC and ETH

* Update client

* Update mangoDepositoryIntegrationSuite.ts

* Fixing tests

* Added more test cases

* Add BTC and ETH to CI market making

* Update uxd-client

* Update tests

* unit test + prop test (#98)

* prop test trial

* test limit_price from mango_utils (#88)

* test limit_price

* minor

* limit price test 2 (#94)

* wip

* wip

* i80f48 cal test

* rm

* updated workflow file

Co-authored-by: Acammm <[email protected]>

* Have the SOL tests back

* Fix missing insurance parameter in tests

* Feature/add payer to mint and redeem (#100)

* Add a payer to mint and redeem

* Working

* Add changelog + update version

* Trigger CI

* Trigger CI

* Update UXD-Client

* Update UXD-Client

* ETH integration tests. (#102)

* Eth testing

* Missing return for ETH

* Fix CI with multiple MM accounts (#105)

* Update solana version to latest cluster-version

* New accounts on mango

* enhancement/soteria_ci (#108)

* try 2. copy pasted from drift

* no cd

* working

* Rebalancing-lite (#107)

* WIP No tests - no settlement of PNL (maybe todo)

* FIx stack blowup + 3.0.0 idl

* Controller not mutable in the migrate IX

* Update IDL

* Remove uneeded mut of controller in some instances (harmeless but useless)
+ update IDL

* Add sec checks to depository account in migrate

* Add depository version check for the rebalance call + upgrade idl

* Migrate + tests OK

* Fix migrate test

* Use BOX to prevent stackoverflow

* Working tests pre rebalance testing

* wip rebalancing

* Mocha awsome
+ reog tests.. (not the place but I was having some issues. Too much work, easier to pack)

Rebalancing tests WIP

* Provider -> Connection
Readme

* Payer .publicKey

* More refactoring. Almost there

* Fix readme

* Working tests for rebalancing

* Updates devnets and Readme

* Working

* Upgrade tests

* Improve tests

* Remove print

* Update changelog

* Tag version as beta. Add tests

* Fix tests

* Unlock regular tests

* Upgrade anchor version

* Fix slippage display

* Fix tests

* Update Mango + fix tests

* Use functions

* v2.1.0 - Hotfix/mango-taker-fee-changes (#112)

* Dependencies update to match mango
- update to mango v3.3.5
- update solana to 1.9.1 (to do as mango, they use 1.9.1)
- update anchor-lang to 0.20.1 (required by mango)
- update anchor-spl to 0.20.1 (required by mango)

* Owner now passed as signer always.
Remove the additional owner passed twice.

This was done to support multisig in a previous version of their code IIRC

It's not deprecated and breaking since their last update as they have a new optional account that takes the first spot.

* Upgrade version to 2.1.0

* Add changelog

* Update cargo lock and dependencies after rebasing

* Improve integration tests
- better redeem and mint maths
- rebalancing improved

* Remove only tests

* Fix the redeem min amount test (#114)

* reversed sub/add

* naming

* acammm/move-unit-tests-to-another-ci (#115)

* Separate workflows + tweaks

* Update unit tests CI

* Split test and test-bpf
+ simplications

* Cleanup + add lint and audit

* Add color on audit + fix cluster

* Update funding for e2e tests

* Remove anchor test from CI too costy and failish

* Fix errors from cargo fmt -- --check

* Disable clippy

* Add flag for fixing clippy

* trigger anchor test

* Trigger ci anchor test

* Test fund.sh

* Test fund.sh

* Fix env variable capitalization

* Test fund.sh

* Test fund.sh

* Trigger ci

* reduce funding amount

* update uxd-client to 5.0.0-beta3
send extras to bank instead of faucet

* Add suites in describe for easy skip (#116)

* Fix and rework the ci so that it's faster and more reliable (#117)

* Update CI to use 2 wallets for MM and deployments

* Fix env variable name

* Trigger ci

* Use current cluster version

* Solana version change

* Update wrap up code in ci

* Workspace lint lingo

* Improved performances for CI

* Fix CI

* Fix CI

* Fix CI

* fix ci

* Solana install fix

* Fix ci

* Fix ci

* Fix CI

* Fix ci

* dev do something

* hehe

* Fix CI

* Add some clippy stuff

* ci trigger

* Without the trigger of audit and all

* Please clippy

* Please clippy

* CI

* clippy

* more ci

* ci fix

* Updated

* Fix ci

* Mega CI

* CI

* ibakkk

* Fix ci

* Fix rebalancing

* Update CI

* Upgrade readme

* Ok

* CI

* Ci

* ci

* Ci

* Update ci

* build up

* CI

* Optim for solana cache in tests

* ww

* qq

* bpf

* Rebalancing print issues hwen negative

* Fix bpf

* ci

* Fix Tests

* trigger ci

* CI

* ci

* CI

* CI fix

* Anchor

* Skip BTC Test in the BTC CI

* Acammm/unit tests -- Add more unit tests feat @cnek (#118)

* cleanup regression tests

* Add prop tests

* misc

* Order unit test

* Cleanup

* fix warning

* Add more tests

* Remive todos

* Add tests for order_delta

* Update number format for readability

* Refactor tests names

* restructure

* fixed fmt

* minor udates on  assertion

* run rustup updates

* fixed up

* fixed up

Co-authored-by: cnek <[email protected]>

* Acammm/upgrade anchor 0.21.0 (cherry picking @cnek work) (#120)

* Updgrade anchor version

* updated anchor

* Updated Anchor + use new ci program due to layout change between last rebalancing implementation

* And use a new program ID

* Please Clippy and fmt

* Add back some prints + cleanup old ones

* Fix cargo.toml

* Update IDL and uxd-client

* fmt

Co-authored-by: cnek <[email protected]>

* Update doc and client

* Changelog

* Fix CI triggers

* Upgrade CI resident program

* Add sleep to keep alive the MM job in CI

* - Fix the mint redeem amount
- add badge for ci on mangomarkets
- remove size from  Order as it's unused
- tests tweaks

* Remove the sleep on MM bots in CI

* Fix cargo tests

* Moves bots to other jobs

* Update tests names

* Trigger CI

* Disable Anchor Events in mint and redeem for computing savings

* Fix clippy + update rust toolchain version in CI

* Reduce sol used by e2e tests

* - new default test
- add logs to mint and redeem

* - get_best_order_for_quote_lot_amount and get_best_order_for_base_lot_quantity now return the correct error when order not found
- get_best_order_for_base_lot_quantity not return the order with the proper side (was unused)
- Tests E2E tweaks
- More explicit names for order books related operations

* Added comments for each input accounts (#122)

* acammm/lighter-minting (#123)

* - take 0 slippage as invalid for simplification for now. Front end dont take 0 as input.
- the minting now just do an euclidian division to remove the oddlots and place that order with the worst price.
- It does check afterward for slippage
- updated unit tests

* Cleanups

* Fix tests + some comments

* Fix Comment type @cnek

* Add comments for accounts #

* - fix rebalancing sides
- simplify PerpInfo

* Typos

* Add PnL settlement

* Save computing for redeem

* Trigger CI

* Trigger CI

* Latest mocha for dependabot alerts

* Fix polarity issue and overflow of i128 + fix tests for rebalancing

* Upgrade resident program ID (CI), and add a script to do so

* acammm/proper-support-mango-ref-fees (#124)

* - fix rebalancing positive PnL tests
- remove euclidian division (seems to have a very tiny leftover sometimes not sure why
- support for new ref fees

* Add a payer in the wrapped sol call to not mess with the tests
- add logs in mint since a lot of computing left (and no CPI possible due to size)

* Remove janky calculus with micro leftovers

* Fix tests + rebalancing

* Use right test in anchor.toml

* User https://api.devnet.solana.com

* Update CI

* Save computing for rebalancing

* fmt

* Mint/redeem a bit amove min size to not fail CI on price changes

* Remove useless I80F48 conversion

* Add missing initialisation for the total amount rebalanced + test improvments

* Add badges

* Add badges

Co-authored-by: Lexington Brill <[email protected]>
Co-authored-by: cnek <[email protected]>
  • Loading branch information
3 people authored Feb 20, 2022
1 parent c266578 commit 69d6fa3
Show file tree
Hide file tree
Showing 103 changed files with 7,992 additions and 2,299 deletions.
678 changes: 678 additions & 0 deletions .github/workflows/ci-anchor-test.yml

Large diffs are not rendered by default.

47 changes: 47 additions & 0 deletions .github/workflows/ci-cargo-audit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# CI job for scanning Cargo dependencies for vulnerabilities and report/fail job based on criticality.
# Critically vulnerable dependencies with fix available will mark the run as failed (X)

name: Cargo Audit

on:
push:
branches: main

env:
CARGO_TERM_COLOR: always

# Optimization option by targeting direct paths to only scan when there are changes to dependencies in the push/PR
# Can also be used to limit testing to specific programs

# push:
# paths:
# - 'Cargo.toml'
# - 'Cargo.lock'
# pull_request:
# paths:
# - 'Cargo.toml'
# - 'Cargo.lock'

# Example of running scheduled scans at 6AM UTC every Monday to regularly check for vulnerable dependencies
# schedule:
# - cron: '0 6 * * 1'

# Run the job
jobs:
cargo-audit:
name: Cargo Vulnerability Scanner
runs-on: ubuntu-latest
steps:
# Check out GitHub repo
- uses: actions/checkout@v2

# Install cargo audit
- name: Install Cargo Audit
uses: actions-rs/[email protected]
with:
crate: cargo-audit
version: latest

# Run cargo audit using args from .cargo/audit.toml (ignores, etc.)
- name: Run Cargo Audit
run: cargo audit -c always
106 changes: 106 additions & 0 deletions .github/workflows/ci-cargo-lint-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
name: Lint and Test

on:
push:
branches: [main, v*.*]

env:
CARGO_TERM_COLOR: always
SOLANA_VERSION: 1.9.7
RUST_TOOLCHAIN: nightly-2022-02-01

defaults:
run:
working-directory: ./

jobs:

fmt:
runs-on: ubuntu-latest
name: cargo fmt
steps:
# Checkout Repo
- uses: actions/checkout@v2
# Installs Rust
- name: Cache dependencies
uses: Swatinem/rust-cache@v1
- name: Rust toolchain installation
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ env.RUST_TOOLCHAIN }}
override: true
profile: minimal
components: rustfmt, clippy
- name: Run fmt
run: cargo fmt -- --check

clippy:
runs-on: ubuntu-latest
name: cargo clippy
steps:
# Checkout Repo
- uses: actions/checkout@v2
# Installs Rust
- name: Cache dependencies
uses: Swatinem/rust-cache@v1
- name: Rust toolchain installation
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ env.RUST_TOOLCHAIN }}
override: true
profile: minimal
components: rustfmt, clippy
# The style and complexity lints have not been processed yet.
- name: Run clippy
run: cargo clippy -- --deny=warnings --allow=clippy::style --allow=clippy::complexity

tests:
runs-on: ubuntu-latest
name: Run tests
steps:
# Checkout Repo
- uses: actions/checkout@v2
# Installs Rust
- name: Cache Rust
uses: Swatinem/rust-cache@v1
- name: Rust toolchain installation
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ env.RUST_TOOLCHAIN }}
override: true
profile: minimal
components: rustfmt, clippy
- name: Rust toolchain update
run: |
rustup update
- name: Rust override set nightly
run: |
rustup override set nightly
- name: Cache dependencies
uses: Swatinem/rust-cache@v1

# Install Solana
- name: Install Linux dependencies
run: |
sudo apt-get update
sudo apt-get install -y pkg-config build-essential libudev-dev
- name: Cache Solana binaries
uses: actions/cache@v2
with:
path: ~/.cache/solana
key: ${{ runner.os }}-${{ env.SOLANA_VERSION }}
- name: Install Solana
run: |
sh -c "$(curl -sSfL https://release.solana.com/v${{ env.SOLANA_VERSION }}/install)"
echo "$HOME/.local/share/solana/install/active_release/bin" >> $GITHUB_PATH
export PATH="/home/runner/.local/share/solana/install/active_release/bin:$PATH"
solana --version
echo "Generating keypair..."
solana-keygen new -o "$HOME/.config/solana/id.json" --no-passphrase --silent
# Run tests
- name: Run unit tests
run: cargo test --lib
- name: Build program
run: cargo build-bpf
- name: Run tests
run: cargo test-bpf
58 changes: 58 additions & 0 deletions .github/workflows/ci-soteria.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Soteria

on:
push:
branches: [ main ]

env:
CARGO_TERM_COLOR: always
SOLANA_VERSION: 1.8.12
PROGRAM_PATH: programs/

jobs:

soteria-scan:
name: Soteria Scan
runs-on: ubuntu-latest
steps:
# Install Solana
- name: Cache Solana Version
uses: actions/cache@v2
id: solana-cache
with:
path: |
~/.rustup
~/.cache/solana
~/.local/share/solana
key: solana-v${{ env.SOLANA_VERSION }}
- name: Download Solana
if: steps.solana-cache.outputs.cache-hit != 'true' # Skip this step if matched cached version is available
run: |
echo Downloading Solana v${{ env.SOLANA_VERSION }}... 🧬
sh -c "$(curl -sSfL https://release.solana.com/v${{ env.SOLANA_VERSION }}/install)"
echo "$HOME/.local/share/solana/install/active_release/bin" >> $GITHUB_PATH
export PATH="/home/runner/.local/share/solana/install/active_release/bin:$PATH"
echo Configuring bpf toolchain...
(cd /home/runner/.local/share/solana/install/active_release/bin/sdk/bpf/scripts; ./install.sh)
shell: bash
# Install Soteria
- name: Cache Soteria Build
uses: Swatinem/rust-cache@v1
with:
target-dir: ${{ env.PROGRAM_PATH }}.coderrect/build # Cache build files for performance
- name: Download Soteria # Always grab the latest version
run: |
echo Downloading Soteria... 🔬
sh -c "$(curl -k https://supercompiler.xyz/install)"
export PATH=$PWD/soteria-linux-develop/bin/:$PATH
echo "$PWD/soteria-linux-develop/bin" >> $GITHUB_PATH
shell: bash
# Soteria
- name: Checkout changes
uses: actions/checkout@v2
- name: Run Soteria
run: |
echo Running Soteria... 👾
soteria -analyzeAll .
echo Done!
shell: bash
153 changes: 0 additions & 153 deletions .github/workflows/main.yml

This file was deleted.

10 changes: 8 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
!/target/deploy
/target/deploy/*.so
!/target/deploy/uxd-keypair.json
!/target/deploy/ci-resident-keypair.json
!/target/deploy/ci-resident-upgrade-authority.json
!/target/deploy/bank-keypair.json
!/target/idl/
!/target/idl/uxd.json
!/target/types
Expand All @@ -13,9 +16,12 @@ test-ledger/
/programs/uxd/.coderrect/**
/programs/uxd/target/**
/programs/uxd/Cargo.lock
# Only used for devnet. Mainnet is under dao control
UXDQDbkAeGMPR7gqDykDNu22D9DnYrKdvZhvNmMu6QX.json
yarn-error.log
programs/uxd/src/lib.rs.bak
.gitignore
Anchor.toml.bak
mochawesome-report
.DS_Store
README.md.bak
scripts/swap_ci_resident_program_id.sh.bak
.github/workflows/ci-anchor-test.yml.bak
Loading

0 comments on commit 69d6fa3

Please sign in to comment.