On devnet, I have created an OpenBook market with the sdk (sdk-examples repo) utilsCreateMarket.ts script. Then with the OpenBook market ID I was able to successfully run the sdk ammCreatePool.ts script. I was also able to run the ammAddLiquidity.ts script.
Finally I have been trying unsuccessfully to run the swapOnlyAmm.ts script with the Raydium pool ID. It is failing with this output.
if !AmmStatus::from_u64(amm.status).swap_permission() {
msg!(&format!("swap_base_in: status {}", amm.status));
let clock = Clock::get()?;
if amm.status == AmmStatus::OrderBookOnly.into_u64()
&& (clock.unix_timestamp as u64) >= amm.state_data.orderbook_to_init_time
{
amm.status = AmmStatus::Initialized.into_u64();
msg!("swap_base_in: OrderBook to Initialized");
} else {
return Err(AmmError::InvalidStatus.into());
}
} else if amm.status == AmmStatus::WaitingTrade.into_u64() {
let clock = Clock::get()?;
if (clock.unix_timestamp as u64) < amm.state_data.pool_open_time {
return Err(AmmError::InvalidStatus.into());
} else {
amm.status = AmmStatus::SwapOnly.into_u64();
msg!("swap_base_in: WaitingTrade to SwapOnly");
}
}
I can see that the status of my pool is 7 which is AmmStatus::WaitingTrade.
So I can see that my call will end up in this else if block
else if amm.status == AmmStatus::WaitingTrade.into_u64() {
let clock = Clock::get()?;
if (clock.unix_timestamp as u64) < amm.state_data.pool_open_time {
return Err(AmmError::InvalidStatus.into());
} else {
amm.status = AmmStatus::SwapOnly.into_u64();
msg!("swap_base_in: WaitingTrade to SwapOnly");
}
}
So here I can see that I should get this error if the cluster clock time is < the pool open time. Here is the issue. The cluster clock time is higher than the pool open time for me. You can see the pool open time in here
Converting to human readable form yields a poolOpenTime of 1712099312557. That time was an hour ago...
This is all from my 2nd attempt. I had the same issue before and the poolOpenTime was 18 hours in the past and still threw the same error.
So then I thought maybe the cluster time is way out of sync, but I checked and it's synced with reality.
I've reverse engineered everything and have no idea why I can't swap. It should see that the poolOpenTime is less than the current cluster time and change to AmmStatus::SwapOnly, allowing my swap to go through. Any thoughts appreciated 🤝
On devnet, I have created an OpenBook market with the sdk (sdk-examples repo)
utilsCreateMarket.ts
script. Then with the OpenBook market ID I was able to successfully run the sdkammCreatePool.ts
script. I was also able to run theammAddLiquidity.ts
script.Finally I have been trying unsuccessfully to run the
swapOnlyAmm.ts
script with the Raydium pool ID. It is failing with this output.I have reverse engineered this amm program to find where this error is thrown in
process_swap_base_in
instruction. https://github.com/raydium-io/raydium-amm/blob/18bed23de5a29b038a93db493fafd5ff4ee5386b/program/src/processor.rs#L2328-L2348I can see that the status of my pool is 7 which is![image](https://github.com/raydium-io/raydium-sdk/assets/25042987/225985b7-2c19-4d90-a504-7a8af8217c9d)
AmmStatus::WaitingTrade
.So I can see that my call will end up in this
else if
blockSo here I can see that I should get this error if the cluster clock time is < the pool open time. Here is the issue. The cluster clock time is higher than the pool open time for me. You can see the pool open time in here
Converting to human readable form yields a![image](https://github.com/raydium-io/raydium-sdk/assets/25042987/59644f30-8367-423a-8434-3cc4754ff785)
poolOpenTime
of1712099312557
. That time was an hour ago... This is all from my 2nd attempt. I had the same issue before and thepoolOpenTime
was 18 hours in the past and still threw the same error.So then I thought maybe the cluster time is way out of sync, but I checked and it's synced with reality.
I've reverse engineered everything and have no idea why I can't swap. It should see that the
poolOpenTime
is less than the current cluster time and change toAmmStatus::SwapOnly
, allowing my swap to go through. Any thoughts appreciated 🤝