Open sreekar998 opened 3 months ago
I am trying to get to where you're at, but I can't get past the add-custody
CLI command. It's failing with a
SendTransactionError: failed to send transaction: Transaction simulation failed: Error processing Instruction 0: Program failed to complete at Connection.sendEncodedTransaction (/Users/jake/Github/perps-dex/app/node_modules/@solana/web3.js/src/connection.ts:5860:13) at processTicksAndRejections (node:internal/process/task_queues:95:5) at async Connection.sendRawTransaction (/Users/jake/Github/perps-dex/app/node_modules/@solana/web3.js/src/connection.ts:5819:20) at async sendAndConfirmRawTransaction (/Users/jake/Github/perps-dex/app/node_modules/@coral-xyz/anchor/src/provider.ts:318:21) at async AnchorProvider.sendAndConfirm (/Users/jake/Github/perps-dex/app/node_modules/@coral-xyz/anchor/src/provider.ts:149:14) at async MethodsBuilder.rpc [as _rpcFn] (/Users/jake/Github/perps-dex/app/node_modules/@coral-xyz/anchor/src/program/namespace/rpc.ts:29:16) { logs: [ 'Program BmGHT8ie43LUYfshidXt4unQQDC5cBgbY8EyEcQJ2CSJ invoke [1]', 'Program log: Instruction: AddCustody', 'Program BmGHT8ie43LUYfshidXt4unQQDC5cBgbY8EyEcQJ2CSJ consumed 9363 of 200000 compute units', 'Program BmGHT8ie43LUYfshidXt4unQQDC5cBgbY8EyEcQJ2CSJ failed: Access violation in stack frame 5 at address 0x200005ff8 of size 8' ], programErrorStack: ProgramErrorStack { stack: [ [PublicKey [PublicKey(BmGHT8ie43LUYfshidXt4unQQDC5cBgbY8EyEcQJ2CSJ)]] ] } }
On another note, it doesn't seem like this repo is really supported much anymore?
@sreekar998 I would be very appreciative to know how you managed to get the add-custody
CLI command to work, thanks.
@jakerumbles , I encountered a similar error and was able to resolve it by downgrading the Solana CLI version to 1.17.7. After redeploying the project with the new build, the issue got resolved. Give it a try; it might work for you as well
Thanks @ManavPanchal, trying this out now. Although I think you meant to say something like v1.17.7 as the latest release is 1.18.7.
It worked with v1.17.7!
Thanks @ManavPanchal, you are my hero today 😂
I will also add for anyone else here, the above fix seems to have solved at least most of the test issues in this repository. Tons were failing, but once I downgraded the solana cli and rebuilt, tests started succeeding left and right.
I'm also getting the same error on opening a short position
It appears there could be an issue on sending accounts params as it's reverting from struct checks.
Open position struct
pub struct OpenPosition<'info> {
#[account(mut)]
pub owner: Signer<'info>,
#[account(
mut,
constraint = funding_account.mint == collateral_custody.mint,
has_one = owner
)]
pub funding_account: Box<Account<'info, TokenAccount>>,
/// CHECK: empty PDA, authority for token accounts
#[account(
seeds = [b"transfer_authority"],
bump = perpetuals.transfer_authority_bump
)]
pub transfer_authority: AccountInfo<'info>,
#[account(
seeds = [b"perpetuals"],
bump = perpetuals.perpetuals_bump
)]
pub perpetuals: Box<Account<'info, Perpetuals>>,
#[account(
mut,
seeds = [b"pool",
pool.name.as_bytes()],
bump = pool.bump
)]
pub pool: Box<Account<'info, Pool>>,
#[account(
init,
payer = owner,
space = Position::LEN,
seeds = [b"position",
owner.key().as_ref(),
pool.key().as_ref(),
custody.key().as_ref(),
&[params.side as u8]],
bump
)]
pub position: Box<Account<'info, Position>>,
#[account(
mut,
seeds = [b"custody",
pool.key().as_ref(),
custody.mint.as_ref()],
bump = custody.bump
)]
pub custody: Box<Account<'info, Custody>>,
/// CHECK: oracle account for the position token
#[account(
constraint = custody_oracle_account.key() == custody.oracle.oracle_account
)]
pub custody_oracle_account: AccountInfo<'info>,
#[account(
mut,
seeds = [b"custody",
pool.key().as_ref(),
collateral_custody.mint.as_ref()],
bump = collateral_custody.bump
)]
pub collateral_custody: Box<Account<'info, Custody>>,
/// CHECK: oracle account for the collateral token
#[account(
constraint = collateral_custody_oracle_account.key() == collateral_custody.oracle.oracle_account
)]
pub collateral_custody_oracle_account: AccountInfo<'info>,
#[account(
mut,
seeds = [b"custody_token_account",
pool.key().as_ref(),
collateral_custody.mint.as_ref()],
bump = collateral_custody.token_account_bump
)]
pub collateral_custody_token_account: Box<Account<'info, TokenAccount>>,
system_program: Program<'info, System>,
token_program: Program<'info, Token>,
}
}
I also cross checked all the constraints from transaction but I couldn't identify any constraint violations within the transaction itself.
I'm utilizing a CLI command to open the short position:
npx ts-node src/cli.ts -k ../keys/signer.json open-position DemoPool Gh9ZwEmdLJ8DscKNTkTqPbNwLNNBjuSzaG9Vp2KGtKJr So11111111111111111111111111111111111111112 short --price 185634694 --collateral 100000000 --size 200000000
Still working to get to the shoring and longing that you guys are on. I'm stuck on add-liquidity
now. The CLI shows it was successful because I am submitting it raw without simulation but on-chain on devnet it is failing. Did you guys encounter an error lie this when trying to add liquidity?
I have no idea what this gSbePebfvPy7tRqimPoVecS2UsBvYv46ynrzWocc92s
program address is. My perpetuals program address is jqmbaTKnPaBodQVayx7V6qsbFKCtSJRqEk8DjHQhAUm
.
You can see it here https://solscan.io/tx/zJQKDVBhnLk6NQ9kAzmq2m6LSChkef7VgxQ7Lj55xFdGe8uCAad8QJtnMok2P3j5yWxnVbHky3zYM72Gymqsk63?cluster=custom&customUrl=https%3A%2F%2Fapi.devnet.solana.com
I added custody like this
npx ts-node src/cli.ts -k ~/.config/solana/perps-admin.json add-custody TestPool1 So11111111111111111111111111111111111111112 J83w4HKfqxwcq3BEMMkPFSppX3gqekLyLJBexebFVkix
and I tried to add liquidity like this
npx ts-node src/cli.ts -k /Users/jake/.config/solana/id.json add-liquidity TestPool1 So11111111111111111111111111111111111111112 --amount-in 2 --min-amount-out 1
EDIT I got past this error by removing and re-adding the wrapped SOL custody with --oracletype pyth
this time. I didn't use it because I was following the readme so that's an error with the readme.
I was able to successfully open the long position. The parameters that I used for long in the cli was: npx ts-node src/cli.ts -k ../keys/admin.json open-position TestPool1 So11111111111111111111111111111111111111112 So11111111111111111111111111111111111111112 long --price 125008462 --collateral 100000000 --size 200000000 Done
The parameters that I used for short is: npx ts-node src/cli.ts -k ../keys/admin.json open-position TestPool1 So11111111111111111111111111111111111111112 So11111111111111111111111111111111111111112 short --price 125008462 --collateral 100000000 --size 200000000 Error Code: ConstraintSeeds. Error Number: 2006. Error Message: A seeds constraint was violated.
I tried to use sol and usdc for short: npx ts-node src/cli.ts -k ../keys/admin.json open-position TestPool1 So11111111111111111111111111111111111111112 Gh9ZwEmdLJ8DscKNTkTqPbNwLNNBjuSzaG9Vp2KGtKJr short --price 125008462 --collateral 100000000 --size 200000000 Error: funding_account a raw constraint was violated.
I am using same parameters for long and short. Long is getting succesful, short is reverting. Is there anything that I am missing?