arnaucube
arnaucube/hermez-nodePublic Self-hosted repository
hermez-node/eth/auction.go
eth/auction.goRaw
  1package eth
  2
  3import (
  4	"fmt"
  5	"math/big"
  6
  7	"github.com/ethereum/go-ethereum/accounts/abi/bind"
  8	ethCommon "github.com/ethereum/go-ethereum/common"
  9	"github.com/ethereum/go-ethereum/core/types"
 10	"github.com/ethereum/go-ethereum/ethclient"
 11	HermezAuctionProtocol "github.com/hermeznetwork/hermez-node/eth/contracts/auction"
 12	"github.com/hermeznetwork/hermez-node/log"
 13)
 14
 15// AuctionConstants are the constants of the Rollup Smart Contract
 16type AuctionConstants struct {
 17	// Blocks to wait before starting with the first slot
 18	DelayGenesis uint16
 19	// Blocks per slot
 20	BlocksPerSlot uint8
 21	// Minimum bid when no one has bid yet
 22	InitialMinimalBidding *big.Int
 23	// First block where the first slot begins
 24	GenesisBlockNum int64
 25	// Hermez Governanze Token smartcontract address who controls some parameters and collects HEZ fee
 26	GovernanceAddress ethCommon.Address
 27	// ERC777 token with which the bids will be made
 28	TokenHEZ ethCommon.Address
 29	// HermezRollup smartcontract address
 30	HermezRollup ethCommon.Address
 31}
 32
 33// SlotState is the state of a slot
 34type SlotState struct {
 35	Forger       ethCommon.Address
 36	BidAmount    *big.Int
 37	ClosedMinBid *big.Int
 38	Fulfilled    bool
 39}
 40
 41// NewSlotState returns an empty SlotState
 42func NewSlotState() *SlotState {
 43	return &SlotState{
 44		Forger:       ethCommon.Address{},
 45		BidAmount:    big.NewInt(0),
 46		ClosedMinBid: big.NewInt(0),
 47		Fulfilled:    false,
 48	}
 49}
 50
 51// Coordinator is the details of the Coordinator identified by the forger address
 52type Coordinator struct {
 53	WithdrawalAddress ethCommon.Address
 54	URL               string
 55}
 56
 57// AuctionVariables are the variables of the Auction Smart Contract
 58type AuctionVariables struct {
 59	// Boot Coordinator Address
 60	DonationAddress ethCommon.Address
 61	// Boot Coordinator Address
 62	BootCoordinator ethCommon.Address
 63	// The minimum bid value in a series of 6 slots
 64	DefaultSlotSetBid [6]*big.Int
 65	// Distance (#slots) to the closest slot to which you can bid ( 2 Slots = 2 * 40 Blocks = 20 min )
 66	ClosedAuctionSlots uint16
 67	// Distance (#slots) to the farthest slot to which you can bid (30 days = 4320 slots )
 68	OpenAuctionSlots uint16
 69	// How the HEZ tokens deposited by the slot winner are distributed (Burn: 40% - Donation: 40% - HGT: 20%)
 70	AllocationRatio [3]uint16
 71	// Minimum outbid (percentage) over the previous one to consider it valid
 72	Outbidding uint16
 73	// Number of blocks at the end of a slot in which any coordinator can forge if the winner has not forged one before
 74	SlotDeadline uint8
 75}
 76
 77// AuctionState represents the state of the Rollup in the Smart Contract
 78type AuctionState struct {
 79	// Mapping to control slot state
 80	Slots map[int64]*SlotState
 81	// Mapping to control balances pending to claim
 82	PendingBalances map[ethCommon.Address]*big.Int
 83	// Mapping to register all the coordinators. The address used for the mapping is the forger address
 84	Coordinators map[ethCommon.Address]*Coordinator
 85}
 86
 87// AuctionEventNewBid is an event of the Auction Smart Contract
 88type AuctionEventNewBid struct {
 89	Slot              int64
 90	BidAmount         *big.Int
 91	CoordinatorForger ethCommon.Address
 92}
 93
 94// AuctionEventNewSlotDeadline is an event of the Auction Smart Contract
 95type AuctionEventNewSlotDeadline struct {
 96	NewSlotDeadline uint8
 97}
 98
 99// AuctionEventNewClosedAuctionSlots is an event of the Auction Smart Contract
100type AuctionEventNewClosedAuctionSlots struct {
101	NewClosedAuctionSlots uint16
102}
103
104// AuctionEventNewOutbidding is an event of the Auction Smart Contract
105type AuctionEventNewOutbidding struct {
106	NewOutbidding uint16
107}
108
109// AuctionEventNewDonationAddress is an event of the Auction Smart Contract
110type AuctionEventNewDonationAddress struct {
111	NewDonationAddress ethCommon.Address
112}
113
114// AuctionEventNewBootCoordinator is an event of the Auction Smart Contract
115type AuctionEventNewBootCoordinator struct {
116	NewBootCoordinator ethCommon.Address
117}
118
119// AuctionEventNewOpenAuctionSlots is an event of the Auction Smart Contract
120type AuctionEventNewOpenAuctionSlots struct {
121	NewOpenAuctionSlots uint16
122}
123
124// AuctionEventNewAllocationRatio is an event of the Auction Smart Contract
125type AuctionEventNewAllocationRatio struct {
126	NewAllocationRatio [3]uint16
127}
128
129// AuctionEventNewCoordinator is an event of the Auction Smart Contract
130type AuctionEventNewCoordinator struct {
131	ForgerAddress     ethCommon.Address
132	WithdrawalAddress ethCommon.Address
133	URL               string
134}
135
136// AuctionEventCoordinatorUpdated is an event of the Auction Smart Contract
137type AuctionEventCoordinatorUpdated struct {
138	ForgerAddress     ethCommon.Address
139	WithdrawalAddress ethCommon.Address
140	URL               string
141}
142
143// AuctionEventNewForgeAllocated is an event of the Auction Smart Contract
144type AuctionEventNewForgeAllocated struct {
145	Forger           ethCommon.Address
146	CurrentSlot      int64
147	BurnAmount       *big.Int
148	DonationAmount   *big.Int
149	GovernanceAmount *big.Int
150}
151
152// AuctionEventNewDefaultSlotSetBid is an event of the Auction Smart Contract
153type AuctionEventNewDefaultSlotSetBid struct {
154	SlotSet          int64
155	NewInitialMinBid *big.Int
156}
157
158// AuctionEventNewForge is an event of the Auction Smart Contract
159type AuctionEventNewForge struct {
160	Forger      ethCommon.Address
161	CurrentSlot int64
162}
163
164// AuctionEventHEZClaimed is an event of the Auction Smart Contract
165type AuctionEventHEZClaimed struct {
166	Owner  ethCommon.Address
167	Amount *big.Int
168}
169
170// AuctionEvents is the list of events in a block of the Auction Smart Contract
171type AuctionEvents struct { //nolint:structcheck
172	NewBid                []AuctionEventNewBid
173	NewSlotDeadline       []AuctionEventNewSlotDeadline
174	NewClosedAuctionSlots []AuctionEventNewClosedAuctionSlots
175	NewOutbidding         []AuctionEventNewOutbidding
176	NewDonationAddress    []AuctionEventNewDonationAddress
177	NewBootCoordinator    []AuctionEventNewBootCoordinator
178	NewOpenAuctionSlots   []AuctionEventNewOpenAuctionSlots
179	NewAllocationRatio    []AuctionEventNewAllocationRatio
180	NewCoordinator        []AuctionEventNewCoordinator
181	CoordinatorUpdated    []AuctionEventCoordinatorUpdated
182	NewForgeAllocated     []AuctionEventNewForgeAllocated
183	NewDefaultSlotSetBid  []AuctionEventNewDefaultSlotSetBid
184	NewForge              []AuctionEventNewForge
185	HEZClaimed            []AuctionEventHEZClaimed
186}
187
188// NewAuctionEvents creates an empty AuctionEvents with the slices initialized.
189func NewAuctionEvents() AuctionEvents {
190	return AuctionEvents{
191		NewBid:                make([]AuctionEventNewBid, 0),
192		NewSlotDeadline:       make([]AuctionEventNewSlotDeadline, 0),
193		NewClosedAuctionSlots: make([]AuctionEventNewClosedAuctionSlots, 0),
194		NewOutbidding:         make([]AuctionEventNewOutbidding, 0),
195		NewDonationAddress:    make([]AuctionEventNewDonationAddress, 0),
196		NewBootCoordinator:    make([]AuctionEventNewBootCoordinator, 0),
197		NewOpenAuctionSlots:   make([]AuctionEventNewOpenAuctionSlots, 0),
198		NewAllocationRatio:    make([]AuctionEventNewAllocationRatio, 0),
199		NewCoordinator:        make([]AuctionEventNewCoordinator, 0),
200		CoordinatorUpdated:    make([]AuctionEventCoordinatorUpdated, 0),
201		NewForgeAllocated:     make([]AuctionEventNewForgeAllocated, 0),
202		NewDefaultSlotSetBid:  make([]AuctionEventNewDefaultSlotSetBid, 0),
203		NewForge:              make([]AuctionEventNewForge, 0),
204		HEZClaimed:            make([]AuctionEventHEZClaimed, 0),
205	}
206}
207
208// AuctionInterface is the inteface to to Auction Smart Contract
209type AuctionInterface interface {
210	//
211	// Smart Contract Methods
212	//
213
214	// Getter/Setter, where Setter is onlyOwner
215	AuctionSetSlotDeadline(newDeadline uint8) (*types.Transaction, error)
216	AuctionGetSlotDeadline() (uint8, error)
217	AuctionSetOpenAuctionSlots(newOpenAuctionSlots uint16) (*types.Transaction, error)
218	AuctionGetOpenAuctionSlots() (uint16, error)
219	AuctionSetClosedAuctionSlots(newClosedAuctionSlots uint16) (*types.Transaction, error)
220	AuctionGetClosedAuctionSlots() (uint16, error)
221	AuctionSetOutbidding(newOutbidding uint16) (*types.Transaction, error)
222	AuctionGetOutbidding() (uint16, error)
223	AuctionSetAllocationRatio(newAllocationRatio [3]uint16) (*types.Transaction, error)
224	AuctionGetAllocationRatio() ([3]uint16, error)
225	AuctionSetDonationAddress(newDonationAddress ethCommon.Address) (*types.Transaction, error)
226	AuctionGetDonationAddress() (*ethCommon.Address, error)
227	AuctionSetBootCoordinator(newBootCoordinator ethCommon.Address) (*types.Transaction, error)
228	AuctionGetBootCoordinator() (*ethCommon.Address, error)
229	AuctionChangeDefaultSlotSetBid(slotSet int64, newInitialMinBid *big.Int) (*types.Transaction, error)
230
231	// Coordinator Management
232	AuctionRegisterCoordinator(forgerAddress ethCommon.Address, URL string) (*types.Transaction, error)
233	AuctionIsRegisteredCoordinator(forgerAddress ethCommon.Address) (bool, error)
234	AuctionUpdateCoordinatorInfo(forgerAddress ethCommon.Address, newWithdrawAddress ethCommon.Address, newURL string) (*types.Transaction, error)
235
236	// Slot Info
237	AuctionGetCurrentSlotNumber() (int64, error)
238	AuctionGetMinBidBySlot(slot int64) (*big.Int, error)
239	AuctionGetDefaultSlotSetBid(slotSet uint8) (*big.Int, error)
240
241	// Bidding
242	// AuctionTokensReceived(operator, from, to ethCommon.Address, amount *big.Int,
243	// 	userData, operatorData []byte) error // Only called from another smart contract
244	AuctionBid(slot int64, bidAmount *big.Int, forger ethCommon.Address) (*types.Transaction, error)
245	AuctionMultiBid(startingSlot int64, endingSlot int64, slotSet [6]bool,
246		maxBid, closedMinBid, budget *big.Int, forger ethCommon.Address) (*types.Transaction, error)
247
248	// Forge
249	AuctionCanForge(forger ethCommon.Address) (bool, error)
250	// AuctionForge(forger ethCommon.Address) (bool, error) // Only called from another smart contract
251
252	// Fees
253	AuctionClaimHEZ() (*types.Transaction, error)
254
255	//
256	// Smart Contract Status
257	//
258
259	AuctionConstants() (*AuctionConstants, error)
260	AuctionEventsByBlock(blockNum int64) (*AuctionEvents, *ethCommon.Hash, error)
261}
262
263//
264// Implementation
265//
266
267// AuctionClient is the implementation of the interface to the Auction Smart Contract in ethereum.
268type AuctionClient struct {
269	client  *EthereumClient
270	address ethCommon.Address
271}
272
273// NewAuctionClient creates a new AuctionClient
274func NewAuctionClient(client *EthereumClient, address ethCommon.Address) *AuctionClient {
275	return &AuctionClient{
276		client:  client,
277		address: address,
278	}
279}
280
281// AuctionSetSlotDeadline is the interface to call the smart contract function
282func (c *AuctionClient) AuctionSetSlotDeadline(newDeadline uint8) (*types.Transaction, error) {
283	var tx *types.Transaction
284	var err error
285	if tx, err = c.client.CallAuth(
286		1000000,
287		func(ec *ethclient.Client, auth *bind.TransactOpts) (*types.Transaction, error) {
288			auction, err := HermezAuctionProtocol.NewHermezAuctionProtocol(c.address, ec)
289			if err != nil {
290				return nil, err
291			}
292			return auction.SetSlotDeadline(auth, newDeadline)
293		},
294	); err != nil {
295		return nil, fmt.Errorf("Failed setting slotDeadline: %w", err)
296	}
297	return tx, nil
298}
299
300// AuctionGetSlotDeadline is the interface to call the smart contract function
301func (c *AuctionClient) AuctionGetSlotDeadline() (uint8, error) {
302	var slotDeadline uint8
303	if err := c.client.Call(func(ec *ethclient.Client) error {
304		auction, err := HermezAuctionProtocol.NewHermezAuctionProtocol(c.address, ec)
305		if err != nil {
306			return err
307		}
308		slotDeadline, err = auction.GetSlotDeadline(nil)
309		return err
310	}); err != nil {
311		return 0, err
312	}
313	return slotDeadline, nil
314}
315
316// AuctionSetOpenAuctionSlots is the interface to call the smart contract function
317func (c *AuctionClient) AuctionSetOpenAuctionSlots(newOpenAuctionSlots uint16) (*types.Transaction, error) {
318	var tx *types.Transaction
319	var err error
320	if tx, err = c.client.CallAuth(
321		1000000,
322		func(ec *ethclient.Client, auth *bind.TransactOpts) (*types.Transaction, error) {
323			auction, err := HermezAuctionProtocol.NewHermezAuctionProtocol(c.address, ec)
324			if err != nil {
325				return nil, err
326			}
327			return auction.SetOpenAuctionSlots(auth, newOpenAuctionSlots)
328		},
329	); err != nil {
330		return nil, fmt.Errorf("Failed setting openAuctionSlots: %w", err)
331	}
332	return tx, nil
333}
334
335// AuctionGetOpenAuctionSlots is the interface to call the smart contract function
336func (c *AuctionClient) AuctionGetOpenAuctionSlots() (uint16, error) {
337	var openAuctionSlots uint16
338	if err := c.client.Call(func(ec *ethclient.Client) error {
339		auction, err := HermezAuctionProtocol.NewHermezAuctionProtocol(c.address, ec)
340		if err != nil {
341			return err
342		}
343		openAuctionSlots, err = auction.GetOpenAuctionSlots(nil)
344		return err
345	}); err != nil {
346		return 0, err
347	}
348	return openAuctionSlots, nil
349}
350
351// AuctionSetClosedAuctionSlots is the interface to call the smart contract function
352func (c *AuctionClient) AuctionSetClosedAuctionSlots(newClosedAuctionSlots uint16) (*types.Transaction, error) {
353	var tx *types.Transaction
354	var err error
355	if tx, err = c.client.CallAuth(
356		1000000,
357		func(ec *ethclient.Client, auth *bind.TransactOpts) (*types.Transaction, error) {
358			auction, err := HermezAuctionProtocol.NewHermezAuctionProtocol(c.address, ec)
359			if err != nil {
360				return nil, err
361			}
362			return auction.SetClosedAuctionSlots(auth, newClosedAuctionSlots)
363		},
364	); err != nil {
365		return nil, fmt.Errorf("Failed setting closedAuctionSlots: %w", err)
366	}
367	return tx, nil
368}
369
370// AuctionGetClosedAuctionSlots is the interface to call the smart contract function
371func (c *AuctionClient) AuctionGetClosedAuctionSlots() (uint16, error) {
372	var closedAuctionSlots uint16
373	if err := c.client.Call(func(ec *ethclient.Client) error {
374		auction, err := HermezAuctionProtocol.NewHermezAuctionProtocol(c.address, ec)
375		if err != nil {
376			return err
377		}
378		closedAuctionSlots, err = auction.GetClosedAuctionSlots(nil)
379		return err
380	}); err != nil {
381		return 0, err
382	}
383	return closedAuctionSlots, nil
384}
385
386// AuctionSetOutbidding is the interface to call the smart contract function
387func (c *AuctionClient) AuctionSetOutbidding(newOutbidding uint8) (*types.Transaction, error) {
388	var tx *types.Transaction
389	var err error
390	if tx, err = c.client.CallAuth(
391		1000000,
392		func(ec *ethclient.Client, auth *bind.TransactOpts) (*types.Transaction, error) {
393			auction, err := HermezAuctionProtocol.NewHermezAuctionProtocol(c.address, ec)
394			if err != nil {
395				return nil, err
396			}
397			return auction.SetOutbidding(auth, newOutbidding)
398		},
399	); err != nil {
400		return nil, fmt.Errorf("Failed setting setOutbidding: %w", err)
401	}
402	return tx, nil
403}
404
405// AuctionGetOutbidding is the interface to call the smart contract function
406func (c *AuctionClient) AuctionGetOutbidding() (uint16, error) {
407	// TODO: Update
408	// var outbidding uint8
409	// if err := c.client.Call(func(ec *ethclient.Client) error {
410	// 	auction, err := HermezAuctionProtocol.NewHermezAuctionProtocol(c.address, ec)
411	// 	if err != nil {
412	// 		return err
413	// 	}
414	// 	outbidding, err = auction.GetOutbidding(nil)
415	// 	return err
416	// }); err != nil {
417	// 	return 0, err
418	// }
419	// return outbidding, nil
420	log.Error("TODO")
421	return 0, errTODO
422}
423
424// AuctionSetAllocationRatio is the interface to call the smart contract function
425func (c *AuctionClient) AuctionSetAllocationRatio(newAllocationRatio [3]uint8) (*types.Transaction, error) {
426	var tx *types.Transaction
427	var err error
428	if tx, err = c.client.CallAuth(
429		1000000,
430		func(ec *ethclient.Client, auth *bind.TransactOpts) (*types.Transaction, error) {
431			auction, err := HermezAuctionProtocol.NewHermezAuctionProtocol(c.address, ec)
432			if err != nil {
433				return nil, err
434			}
435			return auction.SetAllocationRatio(auth, newAllocationRatio)
436		},
437	); err != nil {
438		return nil, fmt.Errorf("Failed setting allocationRatio: %w", err)
439	}
440	return tx, nil
441}
442
443// AuctionGetAllocationRatio is the interface to call the smart contract function
444func (c *AuctionClient) AuctionGetAllocationRatio() ([3]uint16, error) {
445	// TODO: Update
446	// var allocationRation [3]uint8
447	// if err := c.client.Call(func(ec *ethclient.Client) error {
448	// 	auction, err := HermezAuctionProtocol.NewHermezAuctionProtocol(c.address, ec)
449	// 	if err != nil {
450	// 		return err
451	// 	}
452	// 	allocationRation, err = auction.GetAllocationRatio(nil)
453	// 	return err
454	// }); err != nil {
455	// 	return [3]uint8{}, err
456	// }
457	// return allocationRation, nil
458	log.Error("TODO")
459	return [3]uint16{}, errTODO
460}
461
462// AuctionSetDonationAddress is the interface to call the smart contract function
463func (c *AuctionClient) AuctionSetDonationAddress(newDonationAddress ethCommon.Address) (*types.Transaction, error) {
464	var tx *types.Transaction
465	var err error
466	if tx, err = c.client.CallAuth(
467		1000000,
468		func(ec *ethclient.Client, auth *bind.TransactOpts) (*types.Transaction, error) {
469			auction, err := HermezAuctionProtocol.NewHermezAuctionProtocol(c.address, ec)
470			if err != nil {
471				return nil, err
472			}
473			return auction.SetDonationAddress(auth, newDonationAddress)
474		},
475	); err != nil {
476		return nil, fmt.Errorf("Failed setting donationAddress: %w", err)
477	}
478	return tx, nil
479}
480
481// AuctionGetDonationAddress is the interface to call the smart contract function
482func (c *AuctionClient) AuctionGetDonationAddress() (*ethCommon.Address, error) {
483	var donationAddress ethCommon.Address
484	if err := c.client.Call(func(ec *ethclient.Client) error {
485		auction, err := HermezAuctionProtocol.NewHermezAuctionProtocol(c.address, ec)
486		if err != nil {
487			return err
488		}
489		donationAddress, err = auction.GetDonationAddress(nil)
490		return err
491	}); err != nil {
492		return nil, err
493	}
494	return &donationAddress, nil
495}
496
497// AuctionSetBootCoordinator is the interface to call the smart contract function
498func (c *AuctionClient) AuctionSetBootCoordinator(newBootCoordinator ethCommon.Address) (*types.Transaction, error) {
499	var tx *types.Transaction
500	var err error
501	if tx, err = c.client.CallAuth(
502		1000000,
503		func(ec *ethclient.Client, auth *bind.TransactOpts) (*types.Transaction, error) {
504			auction, err := HermezAuctionProtocol.NewHermezAuctionProtocol(c.address, ec)
505			if err != nil {
506				return nil, err
507			}
508			return auction.SetBootCoordinator(auth, newBootCoordinator)
509		},
510	); err != nil {
511		return nil, fmt.Errorf("Failed setting bootCoordinator: %w", err)
512	}
513	return tx, nil
514}
515
516// AuctionGetBootCoordinator is the interface to call the smart contract function
517func (c *AuctionClient) AuctionGetBootCoordinator() (*ethCommon.Address, error) {
518	var bootCoordinator ethCommon.Address
519	if err := c.client.Call(func(ec *ethclient.Client) error {
520		auction, err := HermezAuctionProtocol.NewHermezAuctionProtocol(c.address, ec)
521		if err != nil {
522			return err
523		}
524		bootCoordinator, err = auction.GetBootCoordinator(nil)
525		return err
526	}); err != nil {
527		return nil, err
528	}
529	return &bootCoordinator, nil
530}
531
532// AuctionChangeEpochMinBid is the interface to call the smart contract function
533func (c *AuctionClient) AuctionChangeEpochMinBid(slotEpoch int64, newInitialMinBid *big.Int) (*types.Transaction, error) {
534	var tx *types.Transaction
535	var err error
536	if tx, err = c.client.CallAuth(
537		1000000,
538		func(ec *ethclient.Client, auth *bind.TransactOpts) (*types.Transaction, error) {
539			auction, err := HermezAuctionProtocol.NewHermezAuctionProtocol(c.address, ec)
540			if err != nil {
541				return nil, err
542			}
543			slotEpochToSend := big.NewInt(slotEpoch)
544			fmt.Println(slotEpochToSend)
545			fmt.Println(newInitialMinBid)
546			return auction.ChangeEpochMinBid(auth, slotEpochToSend, newInitialMinBid)
547		},
548	); err != nil {
549		return nil, fmt.Errorf("Failed changing epoch minBid: %w", err)
550	}
551	fmt.Println(tx)
552	return tx, nil
553}
554
555// AuctionRegisterCoordinator is the interface to call the smart contract function
556func (c *AuctionClient) AuctionRegisterCoordinator(forgerAddress ethCommon.Address, URL string) (*types.Transaction, error) {
557	var tx *types.Transaction
558	var err error
559	if tx, err = c.client.CallAuth(
560		1000000,
561		func(ec *ethclient.Client, auth *bind.TransactOpts) (*types.Transaction, error) {
562			auction, err := HermezAuctionProtocol.NewHermezAuctionProtocol(c.address, ec)
563			if err != nil {
564				return nil, err
565			}
566			return auction.RegisterCoordinator(auth, forgerAddress, URL)
567		},
568	); err != nil {
569		return nil, fmt.Errorf("Failed register coordinator: %w", err)
570	}
571	return tx, nil
572}
573
574// AuctionIsRegisteredCoordinator is the interface to call the smart contract function
575func (c *AuctionClient) AuctionIsRegisteredCoordinator(forgerAddress ethCommon.Address) (bool, error) {
576	var registered bool
577	if err := c.client.Call(func(ec *ethclient.Client) error {
578		auction, err := HermezAuctionProtocol.NewHermezAuctionProtocol(c.address, ec)
579		if err != nil {
580			return err
581		}
582		registered, err = auction.IsRegisteredCoordinator(nil, forgerAddress)
583		return err
584	}); err != nil {
585		return false, err
586	}
587	return registered, nil
588}
589
590// AuctionUpdateCoordinatorInfo is the interface to call the smart contract function
591func (c *AuctionClient) AuctionUpdateCoordinatorInfo(forgerAddress ethCommon.Address, newWithdrawAddress ethCommon.Address, newURL string) (*types.Transaction, error) {
592	var tx *types.Transaction
593	var err error
594	if tx, err = c.client.CallAuth(
595		1000000,
596		func(ec *ethclient.Client, auth *bind.TransactOpts) (*types.Transaction, error) {
597			auction, err := HermezAuctionProtocol.NewHermezAuctionProtocol(c.address, ec)
598			if err != nil {
599				return nil, err
600			}
601			return auction.UpdateCoordinatorInfo(auth, forgerAddress, newWithdrawAddress, newURL)
602		},
603	); err != nil {
604		return nil, fmt.Errorf("Failed update coordinator info: %w", err)
605	}
606	return tx, nil
607}
608
609// AuctionGetCurrentSlotNumber is the interface to call the smart contract function
610func (c *AuctionClient) AuctionGetCurrentSlotNumber() (int64, error) {
611	var _currentSlotNumber *big.Int
612	if err := c.client.Call(func(ec *ethclient.Client) error {
613		auction, err := HermezAuctionProtocol.NewHermezAuctionProtocol(c.address, ec)
614		if err != nil {
615			return err
616		}
617		_currentSlotNumber, err = auction.GetCurrentSlotNumber(nil)
618		return err
619	}); err != nil {
620		return 0, err
621	}
622	currentSlotNumber := _currentSlotNumber.Int64()
623	return currentSlotNumber, nil
624}
625
626// AuctionGetMinBidBySlot is the interface to call the smart contract function
627func (c *AuctionClient) AuctionGetMinBidBySlot(slot int64) (*big.Int, error) {
628	var minBid *big.Int
629	if err := c.client.Call(func(ec *ethclient.Client) error {
630		auction, err := HermezAuctionProtocol.NewHermezAuctionProtocol(c.address, ec)
631		if err != nil {
632			return err
633		}
634		slotToSend := big.NewInt(slot)
635		minBid, err = auction.GetMinBidBySlot(nil, slotToSend)
636		return err
637	}); err != nil {
638		return big.NewInt(0), err
639	}
640	return minBid, nil
641}
642
643// AuctionGetDefaultSlotSetBid is the interface to call the smart contract function
644func (c *AuctionClient) AuctionGetDefaultSlotSetBid(slotSet uint8) (*big.Int, error) {
645	// TODO: Update
646	// 	var DefaultSlotSetBid *big.Int
647	// 	if err := c.client.Call(func(ec *ethclient.Client) error {
648	// 		auction, err := HermezAuctionProtocol.NewHermezAuctionProtocol(c.address, ec)
649	// 		if err != nil {
650	// 			return err
651	// 		}
652	// 		defaultSlotSetBid, err = auction.GetDefaultSlotSetBid(nil, slotSet)
653	// 		return err
654	// 	}); err != nil {
655	// 		return big.NewInt(0), err
656	// 	}
657	// 	return defaultSlotSetBid, nil
658
659	log.Error("TODO")
660	return nil, errTODO
661}
662
663// AuctionTokensReceived is the interface to call the smart contract function
664// func (c *AuctionClient) AuctionTokensReceived(operator, from, to ethCommon.Address, amount *big.Int, userData, operatorData []byte) error {
665// 	return errTODO
666// }
667
668// AuctionBid is the interface to call the smart contract function
669func (c *AuctionClient) AuctionBid(slot int64, bidAmount *big.Int, forger ethCommon.Address) (*types.Transaction, error) {
670	log.Error("TODO")
671	return nil, errTODO
672}
673
674// AuctionMultiBid is the interface to call the smart contract function
675func (c *AuctionClient) AuctionMultiBid(startingSlot int64, endingSlot int64, slotSet [6]bool, maxBid, closedMinBid, budget *big.Int, forger ethCommon.Address) (*types.Transaction, error) {
676	log.Error("TODO")
677	return nil, errTODO
678}
679
680// AuctionCanForge is the interface to call the smart contract function
681func (c *AuctionClient) AuctionCanForge(forger ethCommon.Address) (bool, error) {
682	log.Error("TODO")
683	return false, errTODO
684}
685
686// AuctionForge is the interface to call the smart contract function
687// func (c *AuctionClient) AuctionForge(forger ethCommon.Address) (bool, error) {
688// 	return false, errTODO
689// }
690
691// AuctionClaimHEZ is the interface to call the smart contract function
692func (c *AuctionClient) AuctionClaimHEZ() (*types.Transaction, error) {
693	log.Error("TODO")
694	return nil, errTODO
695}
696
697// AuctionConstants returns the Constants of the Auction Smart Contract
698func (c *AuctionClient) AuctionConstants() (*AuctionConstants, error) {
699	log.Error("TODO")
700	return nil, errTODO
701}
702
703// AuctionEventsByBlock returns the events in a block that happened in the Auction Smart Contract
704func (c *AuctionClient) AuctionEventsByBlock(blockNum int64) (*AuctionEvents, *ethCommon.Hash, error) {
705	log.Error("TODO")
706	return nil, nil, errTODO
707}