accounting table locks
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
import asyncio
|
import asyncio
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from sqlalchemy import select, func
|
from sqlalchemy import select, func, text
|
||||||
from typing_extensions import Optional
|
from typing_extensions import Optional
|
||||||
from web3.exceptions import ContractLogicError
|
from web3.exceptions import ContractLogicError
|
||||||
from web3.types import EventData
|
from web3.types import EventData
|
||||||
@@ -212,6 +212,9 @@ async def adjust_balance(account: DbAccount, token=NATIVE_TOKEN, subcategory=Acc
|
|||||||
|
|
||||||
|
|
||||||
async def reconcile(account: DbAccount, block_id: Optional[str] = None, last_accounting_row_id: Optional[int] = None):
|
async def reconcile(account: DbAccount, block_id: Optional[str] = None, last_accounting_row_id: Optional[int] = None):
|
||||||
|
# First we lock all the relevant tables to ensure consistency
|
||||||
|
db.session.execute(text("LOCK TABLE account, accounting, reconciliation IN EXCLUSIVE MODE"))
|
||||||
|
|
||||||
# Fetch the latest reconciliation for the account
|
# Fetch the latest reconciliation for the account
|
||||||
latest_recon = db.session.execute(
|
latest_recon = db.session.execute(
|
||||||
select(Reconciliation).where(
|
select(Reconciliation).where(
|
||||||
|
|||||||
12
src/dexorder/bin/refill.py
Normal file
12
src/dexorder/bin/refill.py
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
import logging
|
||||||
|
|
||||||
|
from dexorder.bin.executable import execute
|
||||||
|
|
||||||
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
async def main():
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
execute(main())
|
||||||
@@ -51,3 +51,6 @@ class Config:
|
|||||||
stablecoins: list[str] = field(default_factory=list) # primary stablecoins which are marked to $1
|
stablecoins: list[str] = field(default_factory=list) # primary stablecoins which are marked to $1
|
||||||
quotecoins: list[str] = field(default_factory=list) # quote tokens like WETH that have stablecoin markets
|
quotecoins: list[str] = field(default_factory=list) # quote tokens like WETH that have stablecoin markets
|
||||||
nativecoin: Optional[str] = None # used for accounting of native values. e.g. address of WETH
|
nativecoin: Optional[str] = None # used for accounting of native values. e.g. address of WETH
|
||||||
|
|
||||||
|
# account: target_balance
|
||||||
|
refill: dict[str,str] = field(default_factory=dict)
|
||||||
|
|||||||
@@ -195,8 +195,6 @@ async def mark_to_market_adj_dec(token: str, amount: dec, adjust_decimals=True)
|
|||||||
"""
|
"""
|
||||||
Returns the current USD value for the amount of token.
|
Returns the current USD value for the amount of token.
|
||||||
"""
|
"""
|
||||||
if not accounting_initialized:
|
|
||||||
await initialize_accounting()
|
|
||||||
if adjust_decimals:
|
if adjust_decimals:
|
||||||
amount = await adj_dec(token, amount)
|
amount = await adj_dec(token, amount)
|
||||||
return mark_to_market(token, amount)
|
return mark_to_market(token, amount)
|
||||||
|
|||||||
Reference in New Issue
Block a user