Fixed problem depositing and withdrawing shared quote token.
This commit is contained in:
parent
88b3f31101
commit
dce252ee1f
|
@ -42,10 +42,8 @@ deposit_value = mango.InstrumentValue(token, args.quantity)
|
||||||
deposit_token_account = mango.TokenAccount(
|
deposit_token_account = mango.TokenAccount(
|
||||||
token_account.account_info, token_account.version, token_account.owner, deposit_value)
|
token_account.account_info, token_account.version, token_account.owner, deposit_value)
|
||||||
|
|
||||||
slot = group.slot_by_instrument(token)
|
token_info = group.token_info_by_instrument(token)
|
||||||
if slot.base_token_info is None:
|
root_bank = token_info.load_root_bank(context)
|
||||||
raise Exception(f"Could not find root bank token info for symbol '{args.symbol}'.")
|
|
||||||
root_bank = slot.base_token_info.load_root_bank(context)
|
|
||||||
node_bank = root_bank.pick_node_bank(context)
|
node_bank = root_bank.pick_node_bank(context)
|
||||||
|
|
||||||
signers: mango.CombinableInstructions = mango.CombinableInstructions.from_wallet(wallet)
|
signers: mango.CombinableInstructions = mango.CombinableInstructions.from_wallet(wallet)
|
||||||
|
|
|
@ -41,10 +41,8 @@ withdrawal_value = mango.InstrumentValue(token, args.quantity)
|
||||||
withdrawal_token_account = mango.TokenAccount(
|
withdrawal_token_account = mango.TokenAccount(
|
||||||
token_account.account_info, token_account.version, token_account.owner, withdrawal_value)
|
token_account.account_info, token_account.version, token_account.owner, withdrawal_value)
|
||||||
|
|
||||||
slot = group.slot_by_instrument(token)
|
token_info = group.token_info_by_instrument(token)
|
||||||
if slot.base_token_info is None:
|
root_bank = token_info.load_root_bank(context)
|
||||||
raise Exception(f"Could not find root bank token info for symbol '{args.symbol}'.")
|
|
||||||
root_bank = slot.base_token_info.load_root_bank(context)
|
|
||||||
node_bank = root_bank.pick_node_bank(context)
|
node_bank = root_bank.pick_node_bank(context)
|
||||||
|
|
||||||
signers: mango.CombinableInstructions = mango.CombinableInstructions.from_wallet(wallet)
|
signers: mango.CombinableInstructions = mango.CombinableInstructions.from_wallet(wallet)
|
||||||
|
|
|
@ -368,6 +368,13 @@ class Group(AddressableAccount):
|
||||||
if slot is not None:
|
if slot is not None:
|
||||||
return slot
|
return slot
|
||||||
|
|
||||||
|
raise Exception(f"Could not find slot for {instrument} in group {self.address}")
|
||||||
|
|
||||||
|
def token_info_by_instrument(self, instrument: Instrument) -> TokenInfo:
|
||||||
|
for token_info in self.tokens:
|
||||||
|
if token_info.token == instrument:
|
||||||
|
return token_info
|
||||||
|
|
||||||
raise Exception(f"Could not find token {instrument} in group {self.address}")
|
raise Exception(f"Could not find token {instrument} in group {self.address}")
|
||||||
|
|
||||||
def token_price_from_cache(self, cache: Cache, token: Instrument) -> InstrumentValue:
|
def token_price_from_cache(self, cache: Cache, token: Instrument) -> InstrumentValue:
|
||||||
|
|
Loading…
Reference in New Issue