makerdao / auction-demo-keeper

Apache License 2.0
32 stars 19 forks source link

Race condition #43

Open liberuum opened 3 years ago

liberuum commented 3 years ago

When multiple ilks are defined, when looping through them and finding an opportunity, the keeper has trouble executing the tx. transact.js gets some misplaced parameters:

------------------ COLLATERAL WBTC-A INITIALIZED ------------------

Checking auction opportunities for LINK-A
Checking auction opportunities for YFI-A
LINK-A Active auctions qty: 1
Checking auction opportunities for WBTC-A
YFI-A Active auctions qty: 0
WBTC-A Active auctions qty: 0

            LINK-A auction 183

            Auction Tab: 137.62149325402117137
            Auction Lot: 6.355503766985869936
            Auction Gem Price: 42.259975563330691103
            Gem price with profit: 43.31647495241395838

            -- Uniswap --
            Dai Proceeds from a full sell on Uniswap: 37.630594714030584315 Dai
            Proceeds - minProfit: 34.19005738268006

            -- OasisDEX --
            OasisDEXAvailability: amt of collateral avl to buy 12.43905128834937702

            Lot sale amt - lot: 6.355503766985869936
            costOfLot: 275.29801973261599367
            maxPrice 42.259975563330691103 Dai
            minProfit: 3.440537331350529284 Dai
            profitAddr: -----

Cannot read property 'toHexString' of null

Executing Take_Transaction 

previousNonce:  null
TypeError: Cannot set property 'nonce' of undefined
    at file:///Users/petcat/Documents/MakerDAO/AuctionDemoKeeper/auction-demo-keeper/src/transact.js:91:33
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async Transact.sign_and_send (file:///Users/petcat/Documents/MakerDAO/AuctionDemoKeeper/auction-demo-keeper/src/transact.js:87:5)
    at async Transact.transact_async (file:///Users/petcat/Documents/MakerDAO/AuctionDemoKeeper/auction-demo-keeper/src/transact.js:148:20)
    at async Clipper.execute (file:///Users/petcat/Documents/MakerDAO/AuctionDemoKeeper/auction-demo-keeper/src/clipper.js:149:24)
    at async keeper._opportunityCheck (file:///Users/petcat/Documents/MakerDAO/AuctionDemoKeeper/auction-demo-keeper/src/keeper.js:141:15)