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

[DEPRECATED] Credix Minting/Redeeming/CollectProfit #203

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
e5fccf1
up
crypto-vincent Oct 18, 2022
946d269
up
crypto-vincent Oct 26, 2022
f1e7081
typingtyping
crypto-vincent Oct 26, 2022
b56923c
more-progress
crypto-vincent Oct 31, 2022
62010eb
merge-main
crypto-vincent Nov 2, 2022
0eaca7f
up
crypto-vincent Nov 2, 2022
0529c7b
merge-mapl-i
crypto-vincent Nov 2, 2022
3159941
getting-ready
crypto-vincent Nov 2, 2022
c75ad80
nit
crypto-vincent Nov 7, 2022
f55836f
Merge branch 'main' into vbrunet/2022_10_18-credix
crypto-vincent Nov 16, 2022
7cfc00f
up
crypto-vincent Nov 16, 2022
36ff756
Merge branch 'vbrunet/2022_10_31-maple-mint' into vbrunet/2022_10_18-…
crypto-vincent Nov 16, 2022
011a838
it-compiles
crypto-vincent Nov 16, 2022
f8bf26b
merge
crypto-vincent Nov 16, 2022
5ebdf58
nit
crypto-vincent Nov 16, 2022
177d97b
up
crypto-vincent Nov 16, 2022
dac9dfe
nits
crypto-vincent Nov 17, 2022
a2bd3b2
importing-utils
crypto-vincent Nov 17, 2022
4a6788b
up
crypto-vincent Nov 17, 2022
53e965a
progress
crypto-vincent Nov 17, 2022
a8f7d96
Merge branch 'vbrunet/2022_10_31-maple-mint' into vbrunet/2022_10_18-…
crypto-vincent Nov 17, 2022
7ab598c
test
crypto-vincent Nov 17, 2022
19f96af
it-compiles
crypto-vincent Nov 17, 2022
be25fc8
more-testing
crypto-vincent Nov 18, 2022
7a5ca7b
testing
crypto-vincent Nov 18, 2022
ef09338
up
crypto-vincent Nov 18, 2022
6eb71d5
it-werks-doing-cleanups
crypto-vincent Nov 21, 2022
4cd46b0
up
crypto-vincent Nov 21, 2022
854ae03
up
crypto-vincent Nov 21, 2022
fd4682b
nit
crypto-vincent Nov 21, 2022
90cda1e
up
crypto-vincent Nov 22, 2022
3668942
profit-fetching
crypto-vincent Nov 23, 2022
7155bae
up
crypto-vincent Nov 23, 2022
37d7117
nits
crypto-vincent Nov 23, 2022
1bf40d4
pr-comments
crypto-vincent Nov 24, 2022
dc32b9e
fix-test
crypto-vincent Nov 24, 2022
588f4d7
added-nice-logs-for-understanding-the-results
crypto-vincent Nov 24, 2022
a742a99
nit1
crypto-vincent Nov 28, 2022
7494e42
up
crypto-vincent Nov 28, 2022
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
85 changes: 85 additions & 0 deletions .github/workflows/ci-anchor-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -371,3 +371,88 @@ jobs:
run: |
solana transfer --keypair ${{ env.RUNNER_WALLET_PATH }} ${{ env.BANK_WALLET_PATH }} $(echo $(solana balance --keypair ${{ env.RUNNER_WALLET_PATH }} | awk '{print $1}') - ${{ env.TRANSACTION_FEE_OFFSET }} | bc)



anchor-test-credix-lp:
name: Credix lp mint and edit depository
runs-on: ubuntu-latest
timeout-minutes: 5
needs: [anchor-test-maple-pool]
steps:
# Checkout
- uses: actions/checkout@v2
# Install Rust
- name: Rust toolchain installation
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
override: true
profile: minimal
# Install solana
- name: Cache Solana Tool Suite
uses: actions/cache@v2
id: cache-solana
with:
path: |
~/.cache/solana/
~/.local/share/solana/
key: solana-${{ runner.os }}-v0000-${{ env.SOLANA_VERSION }}
- name: install solana
if: steps.cache-solana.outputs.cache-hit != 'true'
run: |
sudo apt-get update
sudo apt-get install -y pkg-config build-essential libudev-dev
sh -c "$(curl -sSfL https://release.solana.com/v${{ env.SOLANA_VERSION }}/install)"
- name: Add Solana to PATH
run: echo "/home/runner/.local/share/solana/install/active_release/bin:$PATH" >> $GITHUB_PATH
- name: Setup solana
run: |
solana --version
solana config set -u d
solana config set --url ${{ env.DEVNET_RPC}}
- name: Node 14 installation
uses: actions/setup-node@v2
with:
node-version: '14'
- name: Cache dependencies
uses: actions/cache@v2
with:
path: ~/.npm
key: npm-${{ hashFiles('package-lock.json') }}
restore-keys: npm-
# Create Keypair
- name: Create Runner keypair and funds it
run: |
solana-keygen new -o ${{ env.RUNNER_WALLET_PATH }} --no-passphrase --silent
solana transfer --keypair ${{ env.BANK_WALLET_PATH }} $(solana-keygen pubkey ${{ env.RUNNER_WALLET_PATH }}) 1 --allow-unfunded-recipient
solana balance
# Cargo caching
- name: Cache Cargo registry + index
uses: actions/cache@v2
id: cache-anchor
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
key: cargo-${{ runner.os }}-v0000-${{ hashFiles('**/Cargo.lock') }}
- name: Cache target folder
uses: actions/cache@v2
id: cache-programs
with:
path: |
./target/debug
./target/release
./target/bpfel-unknown-unknown
key: solana-${{ runner.os }}-v0000-${{ hashFiles('**/programs/**/*.rs') }}-${{ hashFiles('**/programs/**/*.toml') }}
- name: Anchor Test (skip build and deploy)
run: |
npm ci --ignore-scripts
./scripts/swap_ci_resident_program_id.sh
sed -i.bak "s/${{ env.TEST_DEV }}/${{ env.TEST_CI_MAPLE_POOL }}/g" ./Anchor.toml
npx @project-serum/anchor-cli@${{ env.ANCHOR_VERSION }} test --skip-local-validator --skip-build --skip-deploy
- name: Returning funded runner wallet SOLs to the bank
run: |
solana transfer --keypair ${{ env.RUNNER_WALLET_PATH }} ${{ env.BANK_WALLET_PATH }} $(echo $(solana balance --keypair ${{ env.RUNNER_WALLET_PATH }} | awk '{print $1}') - ${{ env.TRANSACTION_FEE_OFFSET }} | bc)

4 changes: 2 additions & 2 deletions Anchor.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ wallet = "~/.config/solana/id.json"
uxd = "UXD8m9cvwk4RcSxnX2HZ9VudQCEeDH6fRnB4CAP57Dr"

[programs.devnet]
uxd = "H4fDUuiTmRNrUVCaswDNFXAe1vR2UEgpdV8iQkzEn2C3"
uxd = "BxYr5TawwhG81hJFrQPyVmcQRhPXfSF759XmhWQH5TKt"

[registry]
url = "https://anchor.projectserum.com"

[scripts]
# The quick version for development - Keep this version as the CI swap this line for its needs
test = "npx ts-mocha -p ./tsconfig.json -t 500000 tests/test_development.ts --reporter mochawesome --require mochawesome/register --reporter-options quiet=true,reportTitle=uxdprogram-test_integration --trace-warnings"
test = "npx ts-mocha -p ./tsconfig.json -t 500000 tests/test_ci_credix_lp.ts --reporter mochawesome --require mochawesome/register --reporter-options quiet=true,reportTitle=uxdprogram-test_integration --trace-warnings"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pls revert this to test_development, ci search for this file name and replace with different ci test files for the anchor test job

Copy link
Contributor Author

@crypto-vincent crypto-vincent Nov 24, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed king, I also need to revert the local keys, this branch is an all-inclusive branch, ill make a polished-ready-to-audit PR with minimal changes

# Longer version
# test = "npx ts-mocha -p ./tsconfig.json -t 500000 tests/test_integration.ts --reporter mochawesome --require mochawesome/register --reporter-options quiet=true,reportTitle=uxdprogram-test_integration --trace-warnings"
108 changes: 106 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions programs/uxd/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ mercurial-vault = { git="https://github.com/mercurial-finance/vault-sdk", featur
mercurial-amm = { git="https://github.com/mercurial-finance/mercurial-dynamic-amm-sdk", features= ["cpi"], rev="8c93e541af252dd0f3fbae56a8eb730adb86feee" }

syrup-cpi = "0.2.0"
credix_client = { version="0.4.0", features = ["pre-mainnet"] }

fixed = "^1.9.0"
num-traits = "0.2.14"
Expand Down
27 changes: 27 additions & 0 deletions programs/uxd/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,16 @@ pub enum UxdError {
RedeemableMercurialVaultAmountUnderManagementCap,
#[msg("Minting amount would go past the maple pool depository Redeemable Amount Under Management Cap.")]
RedeemableMaplePoolAmountUnderManagementCap,
#[msg("Minting amount would go past the credix lp depository Redeemable Amount Under Management Cap.")]
RedeemableCredixLpAmountUnderManagementCap,
#[msg("Operation not allowed due to being over the Mango Redeemable soft Cap.")]
MangoDepositoriesSoftCapOverflow,
#[msg("Cannot register more mango depositories, the limit has been reached.")]
MaxNumberOfMangoDepositoriesRegisteredReached,
#[msg("Cannot register more maple pool depositories, the limit has been reached.")]
MaxNumberOfMaplePoolDepositoriesRegisteredReached,
#[msg("Cannot register more credix lp depositories, the limit has been reached.")]
MaxNumberOfCredixLpDepositoriesRegisteredReached,
#[msg("The amount to withdraw from the Insurance Fund must be superior to zero..")]
InvalidInsuranceAmount,
#[msg("The Quote ATA from authority doesn't have enough balance.")]
Expand Down Expand Up @@ -106,6 +110,8 @@ pub enum UxdError {
MercurialVaultDoNotMatchCollateral,
#[msg("The provided collateral do not match the provided maple pool token.")]
MaplePoolDoNotMatchCollateral,
#[msg("The provided collateral do not match the provided credix lp token.")]
CredixLpDoNotMatchCollateral,
#[msg("Collateral mint should be different than redeemable mint.")]
CollateralMintEqualToRedeemableMint,
#[msg("Provided collateral mint is not allowed.")]
Expand Down Expand Up @@ -139,6 +145,10 @@ pub enum UxdError {
InvalidCollateralMint,
#[msg("The provided collateral locker does not match the depository's collateral locker.")]
InvalidCollateralLocker,
#[msg("The provided shares locker does not match the depository's shares locker.")]
InvalidSharesLocker,
#[msg("The provided treasury collateral does not match the depository's treasury collateral.")]
InvalidTreasuryCollateral,
#[msg("The provided quote mint does not match the depository's quote mint.")]
InvalidQuoteMint,
#[msg("The Mango Account isn't the Depository one.")]
Expand Down Expand Up @@ -172,6 +182,23 @@ pub enum UxdError {
#[msg("The provided maple lender shares does not match the Depository's one.")]
InvalidMapleLenderShares,

#[msg("The Credix ProgramState isn't the Depository one.")]
InvalidCredixProgramState,
#[msg("The Credix GlobalMarketState isn't the Depository one.")]
InvalidCredixGlobalMarketState,
#[msg("The Credix SigningAuthority isn't the Depository one.")]
InvalidCredixSigningAuthority,
#[msg("The Credix LiquidityCollateral isn't the Depository one.")]
InvalidCredixLiquidityCollateral,
#[msg("The Credix SharesMint isn't the Depository one.")]
InvalidCredixSharesMint,
#[msg("The Credix Pass isn't the Depository one.")]
InvalidCredixPass,
#[msg("The Credix Multisig isn't the ProgramState one.")]
InvalidCredixMultisig,
#[msg("The Credix TreasuryCollateral isn't the GlobalMarketState one.")]
InvalidCredixTreasuryCollateral,

#[msg("Default - Check the source code for more info.")]
Default,
}
Loading