drift-labs / driftpy

python sdk to interact with drift v2
https://drift-2.gitbook.io/driftpy-for-dummies/
58 stars 39 forks source link

Withdraw Failed #167

Open wkshare opened 4 months ago

wkshare commented 4 months ago

Code:

spot_market_index = 0 # USDC
#amount_in_spot_market_precision = drift_client.convert_to_spot_precision(spot_market_index, 100) # $100

user_token_account = drift_client.get_associated_token_account_public_key(0)

try:
    tx_sig_and_slot = await drift_client.withdraw(
        100**7,
        0,
        user_token_account
    )
    print(f"Withdrew successfully: {tx_sig_and_slot.tx_sig}")
except Exception as e:
    print(f"Failed to withdraw: {e}")

Error Information:

Failed to withdraw: SendTransactionPreflightFailureMessage { message: "Transaction simulation failed: Error processing Instruction 2: custom program error: 0x1793", data: RpcSimulateTransactionResult(RpcSimulateTransactionResult { err: Some(InstructionError(2, Custom(6035))), logs: Some(["Program ComputeBudget111111111111111111111111111111 invoke [1]", "Program ComputeBudget111111111111111111111111111111 success", "Program ComputeBudget111111111111111111111111111111 invoke [1]", "Program ComputeBudget111111111111111111111111111111 success", "Program dRiftyHA39MWEi3m9aunc5MzRF1JYuBsbn6VPcn33UH invoke [1]", "Program log: Instruction: Withdraw", "Program data: t7rLuuG7X4LfD1xmAAAAAAUA+onLEdRtDwAAAAAAAAAAAPDO4WsCAAAAAAAAAAAAAACLo0QgpSIEAAAAAAAAAAAAI2zpigIAAAAAAAAAAAAAAGCuCgBADQMAoCUmAA==", "Program log: Invalid Spot 14 Oracle: Stale (oracle_delay=148)", "Program log: Invalid Spot 6 Oracle: Stale (oracle_delay=19)", "Program log: Error InvalidOracle thrown at programs/drift/src/math/margin.rs:593", "Program log: User attempting to withdraw with outstanding liabilities when an oracle is invalid", "Program log: AnchorError occurred. Error Code: InvalidOracle. Error Number: 6035. Error Message: InvalidOracle.", "Program dRiftyHA39MWEi3m9aunc5MzRF1JYuBsbn6VPcn33UH consumed 298791 of 299700 compute units", "Program dRiftyHA39MWEi3m9aunc5MzRF1JYuBsbn6VPcn33UH failed: custom program error: 0x1793"]), accounts: None, units_consumed: Some(300), return_data: None, inner_instructions: None }) }
wkshare commented 4 months ago

How to refresh oracle???? @soundsonacid

wkshare commented 4 months ago

"Program log: User attempting to withdraw with outstanding liabilities when an oracle is invalid" how to fix this error?