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

bug: Duplicate reentrancy guard in ExchangeRouter and [*]Handler #624

Open
0xted97 opened this issue Mar 13, 2024 · 0 comments · May be fixed by #625
Open

bug: Duplicate reentrancy guard in ExchangeRouter and [*]Handler #624

0xted97 opened this issue Mar 13, 2024 · 0 comments · May be fixed by #625
Labels
bug Something isn't working

Comments

@0xted97
Copy link

0xted97 commented Mar 13, 2024

Bug Report

Satoru version:

6ebc1a4

Current behavior:

ReentrancyGuard: reentrant call when create_order, cancel_order, simulate_execute_order, create_deposit, cancel_deposit, simulate_execute_deposit, create_withdrawal, cancel_withdrawal, simulate_execute_withdrawal.
Duplicate reentrancy in ExchangeRouter and [*]Handler

Expected behavior:

User can request create and cancel order, deposit and withdrawal via ExchangeRouter contract

Steps to reproduce:
const createDepositCalldata: Call[] = [
{
contractAddress: depositParams.initial_long_token_address,
entrypoint: "approve",
calldata: [
contractAddresses.Router,
depositParams.initial_long_token_amount.toString(),
"0"
]
},
{
contractAddress: depositParams.initial_short_token_address,
entrypoint: "approve",
calldata: CallData.compile({
spender: contractAddresses.Router,
amount: uint256.UINT_128_MAX,
value: 0
})
},
{
contractAddress: contractAddresses.ExchangeRouter,
entrypoint: "send_tokens",
calldata: [
depositParams.initial_long_token_address,
contractAddresses.DepositVault,
depositParams.initial_long_token_amount.toString()
]
},
{
contractAddress: contractAddresses.ExchangeRouter,
entrypoint: "send_tokens",
calldata: [
depositParams.initial_short_token_address,
contractAddresses.DepositVault,
BigInt(depositParams.initial_short_token_amount),
],
},
{
contractAddress: contractAddresses.DepositHandler,
entrypoint: "create_deposit",
calldata: [
account.address,
depositParams.receiver,
depositParams.callback_contract,
depositParams.ui_fee_receiver,
depositParams.market_token_address,
depositParams.initial_long_token_address,
depositParams.initial_short_token_address,
depositParams.long_token_swap_path,
depositParams.short_token_swap_path,
depositParams.min_market_tokens.toString(),
depositParams.execution_fee.toString(),
depositParams.callback_gas_limit.toString()
]
}
];
const account = new Account(provider, senderAddress, privateKey);
const tx = await account.execute(createDepositCalldata);

Related code:

image

Other information:

@0xted97 0xted97 added the bug Something isn't working label Mar 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant