コード例 #1
0
def init_liquidity_provider(app_logger=None):
    global logger
    if app_logger:
        logger = app_logger

    logger.info("Configure and create storage")
    storage.configure_storage()
    storage.create_storage()

    chain_id = diem_types.ChainId(
        value=serde_types.uint8(os.environ["CHAIN_ID"]))
    custody_private_keys = os.getenv("CUSTODY_PRIVATE_KEYS")

    global _liquidity_provider_factory
    if chain_id == chain_ids.TESTNET and custody_private_keys is None:
        _liquidity_provider_factory = FaucetLiquidityProvider
    else:
        logger.info("Custody init")
        Custody.init(chain_id)
        _liquidity_provider_factory = DDLiquidityProvider
コード例 #2
0
 def deserialize_u8(self) -> st.uint8:
     return st.uint8(int.from_bytes(self.read(1), byteorder="little", signed=False))
コード例 #3
0
 def from_int(id: int) -> "ChainId":
     return ChainId(value=st.uint8(id))
コード例 #4
0
 def from_bytes(addr: bytes) -> "AccountAddress":
     """Create an account address from bytes."""
     if len(addr) != AccountAddress.LENGTH:
         raise ValueError("Incorrect length for an account address")
     return AccountAddress(value=tuple(st.uint8(x)
                                       for x in addr))  # pyre-ignore
コード例 #5
0
from diem_utils.types.liquidity.trade import Direction, TradeId, TradeData
from diem_utils.vasp import Vasp
from . import storage
from .fx import get_rate
from .storage import (
    create_quote,
    create_trade,
    find_trade,
    find_quote,
    create_new_settlement,
    get_all_unsettled_debts,
    settle_debt,
)

JSON_RPC_URL = os.environ["JSON_RPC_URL"]
CHAIN_ID = diem_types.ChainId(value=serde_types.uint8(os.environ["CHAIN_ID"]))

LP_IBAN_ADDRESS = "US89 3704 0044 0532 0130 00"
TBD = ""
logger = logging.getLogger(__name__)


class LiquidityProvider(Vasp):
    def __init__(self):
        liquidity_custody_account_name = os.getenv(
            "LIQUIDITY_CUSTODY_ACCOUNT_NAME", "liquidity")
        super().__init__(jsonrpc.Client(JSON_RPC_URL),
                         liquidity_custody_account_name)

    @classmethod
    def init_lp(cls, app_logger=None):