Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions KIPs/kip-249.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def filter_tx(txs, bidTargetTxs, earlyDeadline):
The auction result will be `BidDetails`.

```py
auction_type_hash = keccak256("AuctionTx(bytes32 targetTxHash,uint256 blockNumber,address sender,address to,uint256 nonce,uint256 bid,uint256 callGasLimit,bytes data)")
auction_type_hash = keccak256("AuctionTx(bytes32 targetTxHash,uint256 blockNumber,address sender,address to,uint256 nonce,uint256 bid,uint256 maxGasPrice,uint256 callGasLimit,bytes data)")
```

Please note that it’s not the transaction, but the bid.
Expand All @@ -134,6 +134,7 @@ class BidDetails:
call_gas_limit: bytes # The gas limit of backrun logic
call_data: bytes # The call data of backrun logic
bid_amount: bytes # The bid amount in Kei
max_gas_price: int # The searcher-signed ceiling on the BidTx effective gas price
from_signature: bytes # ECDSA.sign the hash typed data V4 with auction_type_hash based on EIP-712 by searcher's private key.
auc_signature: bytes # ECDSA.sign the from_signature based on EIP-191 by auctioneer's private key
```
Expand All @@ -144,7 +145,7 @@ The EIP-712 domain and types for the `from_signature` are as follows:
# Domain
domain = {
"name": "KAIA_AUCTION",
"version": "0.0.1",
"version": "0.0.2",
"chainId": chain_id,
"verifyingContract": entrypoint_addr,
}
Expand All @@ -158,6 +159,7 @@ types = {
{"name": "to", "type": "address"},
{"name": "nonce", "type": "uint256"},
{"name": "bid", "type": "uint256"},
{"name": "maxGasPrice", "type": "uint256"},
{"name": "callGasLimit", "type": "uint256"},
{"name": "data", "type": "bytes"},
]
Expand All @@ -174,6 +176,7 @@ The proposer verifies the `BidDetails` in the following order.
5. The `bid.sender` must not be in the winner list of the same block number if the new bid doesn't have the same target block and hash as the previous bid.
6. The `bid.from_signature` and `bid.auc_signature` must be valid.
1. The auctioneer address will come from the AuctionEntryPoint contract.
7. The effective gas price of the BidTx must be less or equal to `bid.max_gas_price`.

---

Expand Down Expand Up @@ -220,7 +223,7 @@ The AuctionEntrypoint is a singleton smart contract that implements a function t
| :----------------------------------------------: |
| The execution sequence of BidTx |

The AuctionEntryPoint will verify auctionTx and will return/revert the transaction. Since the BidTx is bundled, the propose won’t pay the gas fee if it’s reverted, otherwise it will pay the gas fee.
The AuctionEntryPoint will verify auctionTx and will return/revert the transaction. Since the BidTx is bundled, the propose won’t pay the gas fee if it’s reverted, otherwise it will pay the gas fee. The AuctionEntryPoint reverts before the backrun call if less than `callGasLimit` gas remains, so a searcher is charged only when the backrun receives the signed `callGasLimit`.

```solidity
interface IAuctionEntryPoint {
Expand All @@ -233,6 +236,7 @@ interface IAuctionEntryPoint {
address to;
uint256 nonce;
uint256 bid;
uint256 maxGasPrice;
uint256 callGasLimit;
bytes data;
bytes auctioneerSig;
Expand Down Expand Up @@ -358,7 +362,7 @@ Once the searchers deposit the KAIA into AuctionDepositVault, the auctioneer nod
The auctioneer node will implement the following json-rpc APIs for searchers. Please note that the detail of the API usage will be shared with the auctioneer implementation.

- `http://<auctioneer-node-url>/api/v1/auction/send`
- Input: `{target_tx_hash, target_tx_raw, block_num, sender, nonce, to_addr, call_gas_limit, call_data, bid_amount, from_signature}`
- Input: `{target_tx_hash, target_tx_raw, block_num, sender, nonce, to_addr, call_gas_limit, call_data, bid_amount, max_gas_price, from_signature}`
- Output: {error}

After receiving the bid, the auctioneer verifies the the `Bid` in the following order:
Expand All @@ -374,6 +378,7 @@ After receiving the bid, the auctioneer verifies the the `Bid` in the following
8. Verify if the searcher has enough deposit balance to pay the `bidAmount` and `gasFee`.
- The `gasFee` is estimated by summing up the `Bid.callGasLimit` and `GAS_BUFFER` that covers the gas fee for the `BidTx`.
- The `effetiveGasPrice` is estimated from the target transaction's `maxFeePerGas` and `maxPriorityFeePerGas`.
9. Verify the `effetiveGasPrice <= Bid.maxGasPrice`.

If the validation passes, the auctioneer will insert the bid into auction.

Expand Down
Loading