Marketmaker now automatically redeems MNGO on pulse.
This commit is contained in:
parent
09bdfe3b9f
commit
20672e17d1
|
@ -66,6 +66,11 @@ class MarketInstructionBuilder(metaclass=abc.ABCMeta):
|
|||
raise NotImplementedError(
|
||||
"MarketInstructionBuilder.build_crank_instructions() is not implemented on the base type.")
|
||||
|
||||
@abc.abstractmethod
|
||||
def build_redeem_instructions(self) -> CombinableInstructions:
|
||||
raise NotImplementedError(
|
||||
"MarketInstructionBuilder.build_redeem_instructions() is not implemented on the base type.")
|
||||
|
||||
def __repr__(self) -> str:
|
||||
return f"{self}"
|
||||
|
||||
|
@ -93,5 +98,8 @@ class NullMarketInstructionBuilder(MarketInstructionBuilder):
|
|||
def build_crank_instructions(self, addresses_to_crank: typing.Sequence[PublicKey], limit: Decimal = Decimal(32)) -> CombinableInstructions:
|
||||
return CombinableInstructions.empty()
|
||||
|
||||
def build_redeem_instructions(self) -> CombinableInstructions:
|
||||
return CombinableInstructions.empty()
|
||||
|
||||
def __str__(self) -> str:
|
||||
return f"« 𝙽𝚞𝚕𝚕𝙼𝚊𝚛𝚔𝚎𝚝𝙸𝚗𝚜𝚝𝚛𝚞𝚌𝚝𝚒𝚘𝚗𝙱𝚞𝚒𝚕𝚍𝚎𝚛 {self.symbol} »"
|
||||
|
|
|
@ -87,7 +87,8 @@ class MarketMaker:
|
|||
|
||||
crank = self.market_instruction_builder.build_crank_instructions([])
|
||||
settle = self.market_instruction_builder.build_settle_instructions()
|
||||
(payer + cancellations + place_orders + crank + settle).execute(context)
|
||||
redeem = self.market_instruction_builder.build_redeem_instructions()
|
||||
(payer + cancellations + place_orders + crank + settle + redeem).execute(context)
|
||||
|
||||
self.pulse_complete.on_next(datetime.now())
|
||||
except Exception as exception:
|
||||
|
|
|
@ -23,9 +23,10 @@ from .combinableinstructions import CombinableInstructions
|
|||
from .context import Context
|
||||
from .group import Group
|
||||
from .marketinstructionbuilder import MarketInstructionBuilder
|
||||
from .instructions import build_cancel_perp_order_instructions, build_mango_consume_events_instructions, build_place_perp_order_instructions
|
||||
from .instructions import build_cancel_perp_order_instructions, build_mango_consume_events_instructions, build_place_perp_order_instructions, build_redeem_accrued_mango_instructions
|
||||
from .orders import Order
|
||||
from .perpmarket import PerpMarket
|
||||
from .tokeninfo import TokenInfo
|
||||
from .wallet import Wallet
|
||||
|
||||
|
||||
|
@ -46,6 +47,7 @@ class PerpMarketInstructionBuilder(MarketInstructionBuilder):
|
|||
self.group: Group = group
|
||||
self.account: Account = account
|
||||
self.perp_market: PerpMarket = perp_market
|
||||
self.mngo_token_info: TokenInfo = self.group.find_token_info_by_symbol("MNGO")
|
||||
|
||||
@staticmethod
|
||||
def load(context: Context, wallet: Wallet, group: Group, account: Account, perp_market: PerpMarket) -> "PerpMarketInstructionBuilder":
|
||||
|
@ -71,5 +73,8 @@ class PerpMarketInstructionBuilder(MarketInstructionBuilder):
|
|||
raise Exception(f"PerpMarket {self.perp_market.symbol} has not been loaded.")
|
||||
return build_mango_consume_events_instructions(self.context, self.group, self.perp_market.underlying_perp_market, account_addresses, limit)
|
||||
|
||||
def build_redeem_instructions(self) -> CombinableInstructions:
|
||||
return build_redeem_accrued_mango_instructions(self.context, self.wallet, self.perp_market, self.group, self.account, self.mngo_token_info)
|
||||
|
||||
def __str__(self) -> str:
|
||||
return """« 𝙿𝚎𝚛𝚙𝙼𝚊𝚛𝚔𝚎𝚝𝙸𝚗𝚜𝚝𝚛𝚞𝚌𝚝𝚒𝚘𝚗𝚜 »"""
|
||||
|
|
|
@ -136,5 +136,8 @@ class SerumMarketInstructionBuilder(MarketInstructionBuilder):
|
|||
self.open_orders_address = create_open_orders.signers[0].public_key()
|
||||
return create_open_orders
|
||||
|
||||
def build_redeem_instructions(self) -> CombinableInstructions:
|
||||
return CombinableInstructions.empty()
|
||||
|
||||
def __str__(self) -> str:
|
||||
return """« 𝚂𝚎𝚛𝚞𝚖𝙼𝚊𝚛𝚔𝚎𝚝𝙸𝚗𝚜𝚝𝚛𝚞𝚌𝚝𝚒𝚘𝚗𝙱𝚞𝚒𝚕𝚍𝚎𝚛 »"""
|
||||
|
|
|
@ -114,6 +114,9 @@ class SpotMarketInstructionBuilder(MarketInstructionBuilder):
|
|||
|
||||
return build_serum_consume_events_instructions(self.context, self.spot_market.address, self.raw_market.state.event_queue(), limited_open_orders_addresses, int(limit))
|
||||
|
||||
def build_redeem_instructions(self) -> CombinableInstructions:
|
||||
return CombinableInstructions.empty()
|
||||
|
||||
def build_create_openorders_instructions(self) -> CombinableInstructions:
|
||||
return build_spot_openorders_instructions(self.context, self.wallet, self.group, self.account, self.raw_market)
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ def test_token_lookup():
|
|||
"decimals": 6,
|
||||
}]
|
||||
}
|
||||
actual = mango.SplTokenLookup(data)
|
||||
actual = mango.SplTokenLookup("test-filename", data)
|
||||
assert actual is not None
|
||||
assert actual.logger is not None
|
||||
assert actual.find_by_symbol("ETH") is not None
|
||||
|
|
Loading…
Reference in New Issue