Merge remote-tracking branch 'origin/dev' into main
This commit is contained in:
commit
478b794034
|
@ -112,26 +112,3 @@ jobs:
|
|||
name: cu-per-ix-clean
|
||||
path: cu-per-ix-clean.log
|
||||
|
||||
# Push clean logs to git if main/dev branch
|
||||
push-logs:
|
||||
name: Push logs
|
||||
if: |
|
||||
(github.actor != 'github-actions[bot]' && github.ref_name == 'main') ||
|
||||
(github.actor != 'github-actions[bot]' && github.ref_name == 'dev')
|
||||
runs-on: ubuntu-latest
|
||||
needs: [lint, tests, process-logs]
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v2
|
||||
- name: Download clean log
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: cu-per-ix-clean
|
||||
path: ./
|
||||
- name: Push log to git
|
||||
run: |
|
||||
git config --global user.name "github-actions[bot]"
|
||||
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
||||
git add -A
|
||||
git commit -m "chore: push cu test logs"
|
||||
git push
|
||||
|
|
|
@ -1,89 +0,0 @@
|
|||
2022-05-24,Benchmark,9227
|
||||
2022-05-24,CloseAccount,4758
|
||||
2022-05-24,CreateAccount,19936
|
||||
2022-05-24,CreateAccount,22945
|
||||
2022-05-24,Deposit,28554
|
||||
2022-05-24,InitializeAccount,17310
|
||||
2022-05-24,InitializeAccount,18436
|
||||
2022-05-24,InitializeAccount,26053
|
||||
2022-05-24,InitializeAccount,28027
|
||||
2022-05-24,InitializeAccount,29977
|
||||
2022-05-24,InitializeAccount,31927
|
||||
2022-05-24,InitializeAccount,34110
|
||||
2022-05-24,InitializeAccount,42249
|
||||
2022-05-24,InitializeAccount,5129
|
||||
2022-05-24,InitializeAccount,60693
|
||||
2022-05-24,InitializeAccount,62216
|
||||
2022-05-24,LiqTokenWithToken,57878
|
||||
2022-05-24,LiqTokenWithToken,61771
|
||||
2022-05-24,PerpCancelAllOrders,11415
|
||||
2022-05-24,PerpCancelOrder,8951
|
||||
2022-05-24,PerpCancelOrderByClientOrderId,8958
|
||||
2022-05-24,PerpConsumeEvents,6388
|
||||
2022-05-24,PerpCreateMarket,23251
|
||||
2022-05-24,PerpPlaceOrder,20751
|
||||
2022-05-24,PerpPlaceOrder,20884
|
||||
2022-05-24,PerpPlaceOrder,21451
|
||||
2022-05-24,PerpPlaceOrder,22082
|
||||
2022-05-24,PerpPlaceOrder,23137
|
||||
2022-05-24,RegisterToken,16936
|
||||
2022-05-24,RegisterToken,21810
|
||||
2022-05-24,Revoke,93211
|
||||
2022-05-24,Revoke,97264
|
||||
2022-05-24,Revoke,97673
|
||||
2022-05-24,Serum3CancelOrder,24472
|
||||
2022-05-24,Serum3CreateOpenOrders,26373
|
||||
2022-05-24,Serum3CreateOpenOrders,26470
|
||||
2022-05-24,Serum3CreateOpenOrders,26475
|
||||
2022-05-24,Serum3CreateOpenOrders,26481
|
||||
2022-05-24,Serum3CreateOpenOrders,26493
|
||||
2022-05-24,Serum3CreateOpenOrders,26567
|
||||
2022-05-24,Serum3CreateOpenOrders,32487
|
||||
2022-05-24,Serum3CreateOpenOrders,34000
|
||||
2022-05-24,Serum3RegisterMarket,22781
|
||||
2022-05-24,Serum3RegisterMarket,25781
|
||||
2022-05-24,Serum3RegisterMarket,39281
|
||||
2022-05-24,SetStubOracle,20310
|
||||
2022-05-24,SetStubOracle,56193
|
||||
2022-05-24,Transfer,18810
|
||||
2022-05-24,Transfer,21281
|
||||
2022-05-24,Transfer,22297
|
||||
2022-05-24,Transfer,22338
|
||||
2022-05-24,Transfer,25862
|
||||
2022-05-24,Transfer,25910
|
||||
2022-05-24,Transfer,26380
|
||||
2022-05-24,Transfer,26390
|
||||
2022-05-24,Transfer,26565
|
||||
2022-05-24,Transfer,26708
|
||||
2022-05-24,Transfer,27631
|
||||
2022-05-24,Transfer,27793
|
||||
2022-05-24,Transfer,27829
|
||||
2022-05-24,Transfer,27850
|
||||
2022-05-24,Transfer,28695
|
||||
2022-05-24,Transfer,28761
|
||||
2022-05-24,Transfer,29298
|
||||
2022-05-24,Transfer,29883
|
||||
2022-05-24,Transfer,30194
|
||||
2022-05-24,Transfer,30492
|
||||
2022-05-24,Transfer,30632
|
||||
2022-05-24,Transfer,30851
|
||||
2022-05-24,Transfer,32444
|
||||
2022-05-24,Transfer,32708
|
||||
2022-05-24,Transfer,33238
|
||||
2022-05-24,Transfer,35581
|
||||
2022-05-24,Transfer,36070
|
||||
2022-05-24,Transfer,38114
|
||||
2022-05-24,Transfer,40066
|
||||
2022-05-24,Transfer,40535
|
||||
2022-05-24,Transfer,44193
|
||||
2022-05-24,Transfer,45726
|
||||
2022-05-24,Transfer,48659
|
||||
2022-05-24,Transfer,50696
|
||||
2022-05-24,Transfer,55672
|
||||
2022-05-24,Transfer,58002
|
||||
2022-05-24,Transfer,59888
|
||||
2022-05-24,Transfer,60667
|
||||
2022-05-24,Transfer,65981
|
||||
2022-05-24,Transfer,89560
|
||||
2022-05-24,Transfer,89889
|
||||
2022-05-24,UpdateIndex,20940
|
|
@ -36,30 +36,32 @@ pub struct MarginTrade<'info> {
|
|||
}
|
||||
|
||||
struct AllowedVault {
|
||||
// index of the vault in cpi_ais
|
||||
/// index of the vault in cpi_ais
|
||||
vault_cpi_ai_index: usize,
|
||||
// index of the bank in health_ais
|
||||
/// index of the bank in health_ais
|
||||
bank_health_ai_index: usize,
|
||||
// raw index into account.tokens
|
||||
/// raw index into account.tokens
|
||||
raw_token_index: usize,
|
||||
// vault amount before cpi
|
||||
/// vault amount before cpi
|
||||
pre_amount: u64,
|
||||
// withdraw request
|
||||
/// requested withdraw amount
|
||||
withdraw_amount: u64,
|
||||
// amount of withdraw request that is a loan
|
||||
/// amount of withdraw request that is a loan
|
||||
loan_amount: I80F48,
|
||||
}
|
||||
|
||||
#[derive(AnchorDeserialize, AnchorSerialize, Clone, Copy)]
|
||||
pub struct MarginTradeWithdraw {
|
||||
/// Account index of the vault to withdraw from in the target_accounts section.
|
||||
/// Meaning that the first account after target_program_id would have index 0.
|
||||
pub index: u8,
|
||||
/// Requested withdraw amount.
|
||||
pub amount: u64,
|
||||
}
|
||||
|
||||
/// - `num_health_accounts` is the number of health accounts that remaining_accounts starts with.
|
||||
/// - `withdraws` is a list of tuples containing the index to a vault in target_accounts and the
|
||||
/// amount that the target program shall be allowed to withdraw
|
||||
/// - `cpi_data` is the bytes to call the target_program_id with
|
||||
/// - `withdraws` is a list of MarginTradeWithdraw requests.
|
||||
/// - `cpi_data` is the bytes to call the target_program_id with.
|
||||
pub fn margin_trade<'key, 'accounts, 'remaining, 'info>(
|
||||
ctx: Context<'key, 'accounts, 'remaining, 'info, MarginTrade<'info>>,
|
||||
num_health_accounts: usize,
|
||||
|
@ -90,7 +92,8 @@ pub fn margin_trade<'key, 'accounts, 'remaining, 'info>(
|
|||
allowed_banks.insert(ai.key, bank);
|
||||
}
|
||||
Err(Error::AnchorError(error))
|
||||
if error.error_code_number == ErrorCode::AccountDiscriminatorMismatch as u32 =>
|
||||
if error.error_code_number == ErrorCode::AccountDiscriminatorMismatch as u32
|
||||
|| error.error_code_number == ErrorCode::AccountOwnedByWrongProgram as u32 =>
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
@ -123,7 +126,14 @@ pub fn margin_trade<'key, 'accounts, 'remaining, 'info>(
|
|||
if ai.owner != &TokenAccount::owner() {
|
||||
return None;
|
||||
}
|
||||
let token_account = Account::<TokenAccount>::try_from(ai).unwrap();
|
||||
|
||||
// Skip mints and other accounts that may be owned by the spl_token program
|
||||
let maybe_token_account = Account::<TokenAccount>::try_from(ai);
|
||||
if maybe_token_account.is_err() {
|
||||
return None;
|
||||
}
|
||||
|
||||
let token_account = maybe_token_account.unwrap();
|
||||
if token_account.owner != ctx.accounts.group.key() {
|
||||
return None;
|
||||
}
|
||||
|
|
|
@ -114,7 +114,9 @@ impl<'a, 'b> ScanningAccountRetriever<'a, 'b> {
|
|||
}
|
||||
Err(Error::AnchorError(error))
|
||||
if error.error_code_number
|
||||
== ErrorCode::AccountDiscriminatorMismatch as u32 =>
|
||||
== ErrorCode::AccountDiscriminatorMismatch as u32
|
||||
|| error.error_code_number
|
||||
== ErrorCode::AccountOwnedByWrongProgram as u32 =>
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue