0x

0x batchFillLimitOrders 不適用於小剩餘FillableTakerAmount

  • June 15, 2022

我在使用該batchFillLimitOrders功能填寫訂單時遇到問題remainingFillableTakerAmount

我正在使用下面列出的輸入參數呼叫以下程式碼:

const response = await exchange
     .batchFillLimitOrders(fillOrders, signatures, takerAssetFillAmounts, true)
     .awaitTransactionSuccessAsync({ from: orderData.maker })
     .catch((err) => console.error('Error logged ' + JSON.stringify(err)))

第一個輸入參數:訂單對象

[
{
 chainId: 3
 expiry: "1657831517"
 feeRecipient: "0x0000000000000000000000000000000000000000"
 maker: "0x4c12ab430e078c56010c46f9391c60be50781b07"
 makerAmount: "270000000000000000000"
 makerToken: "0x134e62bd2ee247d4186a1fdbaa9e076cb26c1355"
 pool: "0x0000000000000000000000000000000000000000000000000000000000000000"
 remainingFillableTakerAmount: "9998758480790449"
 salt: "1655239517688"
 sender: "0x0000000000000000000000000000000000000000"
 taker: "0x0000000000000000000000000000000000000000"
 takerAmount: "10000000000000000"
 takerToken: "0x03582cb41f2fd982e1b531d633b6de049d56f2a0"
 takerTokenFeeAmount: "0"
 verifyingContract: "0xdef1c0ded9bec7f1a1670819833240f027b25eff"
},
{
 chainId: 3
 expiry: "1656397720"
 feeRecipient: "0x0000000000000000000000000000000000000000"
 maker: "0x2db4625a9ece077cb432d1a84b85b03c15721be6"
 makerAmount: "225300000000000000000"
 makerToken: "0x134e62bd2ee247d4186a1fdbaa9e076cb26c1355"
 pool: "0x0000000000000000000000000000000000000000000000000000000000000000"
 remainingFillableTakerAmount: "1"
 salt: "1655188120250"
 sender: "0x0000000000000000000000000000000000000000"
 taker: "0x0000000000000000000000000000000000000000"
 takerAmount: "100000000000000000"
 takerToken: "0x03582cb41f2fd982e1b531d633b6de049d56f2a0"
 takerTokenFeeAmount: "0"
 verifyingContract: "0xdef1c0ded9bec7f1a1670819833240f027b25eff"
},
{
 chainId: 3
 expiry: "1655274128"
 feeRecipient: "0x0000000000000000000000000000000000000000"
 maker: "0x2a65ae527c6ff4665e048b0e0883c486a7ba4dbc"
 makerAmount: "67200000000000000000"
 makerToken: "0x134e62bd2ee247d4186a1fdbaa9e076cb26c1355"
 pool: "0x0000000000000000000000000000000000000000000000000000000000000000"
 remainingFillableTakerAmount: "2922902068498283"
 salt: "1655230928557"
 sender: "0x0000000000000000000000000000000000000000"
 taker: "0x0000000000000000000000000000000000000000"
 takerAmount: "3000000000000000"
 takerToken: "0x03582cb41f2fd982e1b531d633b6de049d56f2a0"
 takerTokenFeeAmount: "0"
 verifyingContract: "0xdef1c0ded9bec7f1a1670819833240f027b25eff"
}
]

第二個輸入參數:簽名

[
{
 r: "0x30feaab607cbc25f0f672f42f91bfc9c2946d14ba46014808196aade6b9bf63d"
 s: "0x4e56d337898ac32854588023f1347ac0904e2bcc887598f9495b3b3b96ec6fd0"
 signatureType: 2
 v: 27
},
{
 r: "0x41bd89be774e218d88801f474d38344eeb76e2c6603e41869a0041d91aba21ec"
 s: "0x75e28c241a60f9b83ac88d696819218728998805615ab67843e7044acab33476"
 signatureType: 2
 v: 27
},
{
 r: "0x214b1450334bafa9b3e1c48c3e31f82916662e4b53045b8515655074edadfdbc"
 s: "0x7d1005a5473a886ba0b6aae64d88a9d30fe8e88a957332eb155e97b1e69ddacc"
 signatureType: 2
 v: 28
}
]

第三個輸入參數:TakerAssetFillAmounts

[
'9998758480790449',
'1',
'1241519209550'
]

我收到的錯誤消息:

{"code":-32603,"message":"execution reverted","data":{"originalError":{"code":3,"data":"0x1d44aa5dc35b019348a46f24084407a1a39c446af5cfef56fe27d475d0285d3861f0fe0a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002385d15f7143b1","message":"execution reverted"}}}

奇怪的是,如果我從每個 TakerAssetFillAmount 元素中減去 1,它就會起作用,即如果我將以下內容作為第三個參數傳遞:

[
'9998758480790448',
'0',
'1241519209549'
]

這讓我假設 0x 協議本身或 0x API 中可能存在一些舍入問題。

我查看了該batchFillLimitOrder函式的智能合約實現,我懷疑它最終catch沒有拋出任何有意義的錯誤消息。

在此處輸入圖像描述

這個問題的後果是我無法擺脫我們在 0x 協議之上建構的以下訂單簿中的灰塵交易:https ://app.diva.finance/91/long

這裡有人可以幫忙嗎?

我可能遺漏了一些東西,但您是否嘗試過查看您的第二個訂單是否有任何特定內容(剩餘FillableTakerAmount:“1”)。

例如,這行得通嗎?

[
'9998758480790449',
'1',
'1241519209550'
]

此外,您能否再次檢查其中一個代幣的批准或餘額是否不足?一個模擬你的訂單拋出ERC20: transfer amount超過balance的錯誤。

引用自:https://ethereum.stackexchange.com/questions/130227