Skip to content

Commit

Permalink
Reconcile merge with main 2
Browse files Browse the repository at this point in the history
  • Loading branch information
jgur-psyops committed Dec 23, 2024
1 parent de33b65 commit 7d5fe37
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 20 deletions.
12 changes: 6 additions & 6 deletions programs/marginfi/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,14 @@ pub enum MarginfiError {
IllegalAction,
#[msg("Token22 Banks require mint account as first remaining account")] // 6046
T22MintRequired,
#[msg("Staked SOL accounts can only deposit staked assets and borrow SOL")] // 6047
AssetTagMismatch,
#[msg("Stake pool validation failed: check the stake pool, mint, or sol pool")] // 6048
StakePoolValidationFailed,
#[msg("Invalid ATA for global fee account")] // 6049
#[msg("Invalid ATA for global fee account")] // 6047
InvalidFeeAta,
#[msg("Use add pool permissionless instead")] // 6050
#[msg("Use add pool permissionless instead")] // 6048
AddedStakedPoolManually,
#[msg("Staked SOL accounts can only deposit staked assets and borrow SOL")] // 6049
AssetTagMismatch,
#[msg("Stake pool validation failed: check the stake pool, mint, or sol pool")] // 6050
StakePoolValidationFailed,
}

impl From<MarginfiError> for ProgramError {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ pub fn lending_pool_configure_bank(
bank.configure(&bank_config)?;

if bank_config.oracle.is_some() {
bank.config.validate_oracle_setup(ctx.remaining_accounts, None, None, None)?;
bank.config
.validate_oracle_setup(ctx.remaining_accounts, None, None, None)?;
}

emit!(LendingPoolBankConfigureEvent {
Expand Down
2 changes: 1 addition & 1 deletion tests/01_initGroup.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ describe("Init group", () => {
assertI80F48Approx(settingsAcc.assetWeightMaint, 0.9);
assertBNEqual(settingsAcc.depositLimit, 1_000_000_000_000);
assertBNEqual(settingsAcc.totalAssetValueInitLimit, 150_000_000);
assert.equal(settingsAcc.oracleMaxAge, 10);
assert.equal(settingsAcc.oracleMaxAge, 60);
assert.deepEqual(settingsAcc.riskTier, { collateral: {} });
});

Expand Down
11 changes: 7 additions & 4 deletions tests/s02_addBank.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ describe("Init group and add banks with asset category flags", () => {
assertI80F48Approx(settingsAcc.assetWeightMaint, 0.9);
assertBNEqual(settingsAcc.depositLimit, 1_000_000_000_000);
assertBNEqual(settingsAcc.totalAssetValueInitLimit, 150_000_000);
assert.equal(settingsAcc.oracleMaxAge, 10);
assert.equal(settingsAcc.oracleMaxAge, 60);
assert.deepEqual(settingsAcc.riskTier, { collateral: {} });
});

Expand Down Expand Up @@ -193,7 +193,8 @@ describe("Init group and add banks with asset category flags", () => {
tx.recentBlockhash = await getBankrunBlockhash(bankrunContext);
tx.sign(groupAdmin.wallet, bankKeypair);
let result = await banksClient.tryProcessTransaction(tx);
assertBankrunTxFailed(result, "0x17a2");
// AddedStakedPoolManually
assertBankrunTxFailed(result, "0x17a0");
});

it("(attacker) Add bank (validator 0) with bad accounts + bad metadata - should fail", async () => {
Expand Down Expand Up @@ -270,7 +271,8 @@ describe("Init group and add banks with asset category flags", () => {
tx.sign(users[0].wallet);

let result = await banksClient.tryProcessTransaction(tx);
assertBankrunTxFailed(result, "0x17a0");
// StakePoolValidationFailed
assertBankrunTxFailed(result, "0x17a2");
}
}
}
Expand Down Expand Up @@ -336,7 +338,8 @@ describe("Init group and add banks with asset category flags", () => {
tx.sign(users[0].wallet);

let result = await banksClient.tryProcessTransaction(tx);
assertBankrunTxFailed(result, "0x17a0");
// StakePoolValidationFailed
assertBankrunTxFailed(result, "0x17a2");
}
}

Expand Down
11 changes: 5 additions & 6 deletions tests/s03_deposit.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@ import {
users,
validators,
} from "./rootHooks";
import {
assertBankrunTxFailed,
assertKeysEqual,
} from "./utils/genericTests";
import { assertBankrunTxFailed, assertKeysEqual } from "./utils/genericTests";
import { assert } from "chai";
import { accountInit, depositIx } from "./utils/user-instructions";
import { LST_ATA, USER_ACCOUNT } from "./utils/mocks";
Expand Down Expand Up @@ -129,7 +126,8 @@ describe("Deposit funds (included staked assets)", () => {
tx.recentBlockhash = await getBankrunBlockhash(bankrunContext);
tx.sign(user.wallet);
let result = await banksClient.tryProcessTransaction(tx);
assertBankrunTxFailed(result, "0x179f");
// AssetTagMismatch
assertBankrunTxFailed(result, "0x17a1");

// Verify the deposit failed and the entry does not exist
const userAcc = await bankrunProgram.account.marginfiAccount.fetch(
Expand Down Expand Up @@ -214,7 +212,8 @@ describe("Deposit funds (included staked assets)", () => {
tx.recentBlockhash = await getBankrunBlockhash(bankrunContext);
tx.sign(user.wallet);
let result = await banksClient.tryProcessTransaction(tx);
assertBankrunTxFailed(result, "0x179f");
// AssetTagMismatch
assertBankrunTxFailed(result, "0x17a1");

// Verify the deposit failed and the entry does not exist
const userAcc = await bankrunProgram.account.marginfiAccount.fetch(
Expand Down
3 changes: 2 additions & 1 deletion tests/s04_borrow.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ describe("Deposit funds (included staked assets)", () => {
tx.recentBlockhash = await getBankrunBlockhash(bankrunContext);
tx.sign(user.wallet);
let result = await banksClient.tryProcessTransaction(tx);
assertBankrunTxFailed(result, "0x179f");
// AssetTagMismatch
assertBankrunTxFailed(result, "0x17a1");

// Verify the deposit worked and the entry does not exist
const userAcc = await bankrunProgram.account.marginfiAccount.fetch(
Expand Down
2 changes: 1 addition & 1 deletion tests/utils/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ export const defaultStakedInterestSettings = (oracle: PublicKey) => {
assetWeightMaint: bigNumberToWrappedI80F48(0.9),
depositLimit: new BN(1_000_000_000_000), // 1000 SOL
totalAssetValueInitLimit: new BN(150_000_000),
oracleMaxAge: 10,
oracleMaxAge: 60,
riskTier: {
collateral: undefined,
},
Expand Down

0 comments on commit 7d5fe37

Please sign in to comment.