Skip to content

Instantly share code, notes, and snippets.

@killerstorm
Created September 7, 2020 08:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save killerstorm/f621e5b9435a738e76dc88fbc3661872 to your computer and use it in GitHub Desktop.
Save killerstorm/f621e5b9435a738e76dc88fbc3661872 to your computer and use it in GitHub Desktop.

Intro

This is an instruction for Hedget auction users which would allow them to interact with auction even if the web site goes down. We do not expect web site to go down, but shit happens, so just in case, there's this instruction. This instruction is for power users. If you're unexperienced, there's a high chance you might screw up.

First thing to note: DO NOT SEND ANY FUNDS TO A CONTRACT DIRECTLY. Bids are placed by calling a contact function. If you send ERC20 tokens to the contract directly, they will be considered a donation to Hedget Foundation.

To be able to interact with contract, you need to be whitelisted in the contract, which is called "Register" in UI. This can only be done using Hedget backend, while it's technically possible to 'register' without using official UI I will not explain how to do it since it's pointless. So please use UI to register before you interact with the contract.

A note about interacting with contracts in general: If a transaction would fail (e.g. if numbers you entered are incorrect, or you violate some rule, etc) MetaMask would indicate it, and also it might suggest an enormous fee like 1.5 ETH. It might even say it fails because you aren't paying this fee. This is a problem of Ethereum wallet software: when transaction fails, sometimes it cannot estimate how much gas it needs, so it assumes it needs to send maximum possible amount of gas, just in case. So if fee is completely out of whack, DO NOT pay it. It will just burn your money, the transaction will fail. Fees for interacting with contracts mentioned in this article will be relatively small, e.g. create_bid usually needs around 126,883 gas, which is about 0.013 ETH at 100 Gwei gas price.

Interacting with contracts

There are several options for interacting with contract. Many wallets have this ability directly. For MetaMask users probably the best option is to use Etherscan, e.g.: https://etherscan.io/dapp/0xf8e30096dd15ce4f47310a20edd505b42a633808#writeContract

To do this, first click "Connect to Web3" in the top right corner, perform the usual connection procedure, and then you can interact.

So, USDT auction contract: https://etherscan.io/dapp/0xf8e30096dd15ce4f47310a20edd505b42a633808#writeContract

CHR auction contract: https://etherscan.io/dapp/0x12f41b4bb7d5e5a2148304caafeb26d9edb7ef4a#writeContract

Again, do NOT send anything to these addresses directly, use a form to interact with the contract.

Making bids

Approve

Before placing a bid, you need to approve spending from your address to auction address. You can do this using token contract interaction:

To approve, open Contract->Write contract list, select "approve" from a list, you will see a form with two fields.

In the first field, enter the address of auction you want to approve:

  • 0xf8e30096dd15ce4f47310a20edd505b42a633808 for USDT
  • 0x12f41b4bb7d5e5a2148304caafeb26d9edb7ef4a for CHR

In the second field, enter the amount you planning to spend multiplied by 1,000,000 (one million). For example, 1000000000000 (12 zeros) will mean 1 million tokens (CHR or USDT). You can enter a bigger amount than you have in your wallet, the number doesn't have to be precise. E.g. you can enter a number with 15 zeros to approve 1 billion tokens.

After approve transaction is confirmed, you can place a bid.

Placing and updating bids

If you have not placed bid before, you need to call create_bid. Note that it is only possible before submission phase ends, which is September 7 20:00 UTC. After that it will always fail.

If you placed a bid before, you need to call update_bid. Interval between calls to update_bid must be at least 1 hour. Also at least one hour from calling create_bid and calling update_bid.

To call create_bid and update_bid you need to enter amount and price. They need to be formatted in a particular way:

  • amount should be multiplied by 1 million
  • price should be multiplied by 100

A number you enter in the field must be an integer. Fractions are not allowed.

So e.g. suppose you want to use price 1.23. You should enter 123. You can't use price like 1.234 because 123.4 is not an integer.

The amount is the amount of HGET you want to get. For example, 11 HGET is 11000000.

Minimal bid amount is 10 HGET, i.e. 10000000 in smart contract units.

create_bid rules are simple -- there's min price, max price and min amount.

update_bid rules are more complex. In all phases:

  • you cannot decrease your collateral. collateral is calculated as price * amount. You can increase it, but you can't decrease it.
  • you can't decrease the price.

In the main phase (i.e. after submission phase) additional rules apply:

  • you can't increase amount. you can decrease it, but it must be at least min amount
  • max price increase is subject to a daily limit

The price at the end of submission phase becomes a base_price. We use it to calculate allowed price increase. Each day (counted from 20:00 UTC on September 7) you can increase price by a certain amount:

  • on day 1, by 0.9 * base_price
  • on day 2, by 0.7 * base_price
  • on day 3, by 0.5 * base_price
  • on day 4, by 0.3 * base_price
  • on day 5, by 0.1 * base_price

So, for example, suppose your base price is 345 in smart contract units (i.e. 3.45 in familiar units). On day 1, you can increase price by 0.9 * 345 = 310 (it is rounded down). So max bid price you can use on day 1 is 310 + 345 = 655.

But suppose you only increased it to 600. Then on day two, you can increase by 0.7 * 345 = 241. So maximum would be 600 + 241 = 841.

You can update bid price multiple times during a day as long as you stay within the limit.

Withdrawing

After the auction is over, you can withdraw. Auction ends 20:00 UTC on September 12. However, withdrawing can only be done after threshold price is set by auction organizer. This should happen within 1 hour after the auction ends, but you should wait for the annoucement.

You can check that threshold price is set by going to Read contract tab and looking for threshold_price, if it's above zero then it's set.

Function withdraw takes single argument -- address, and it will transfer both HGET tokens and unused collateral (CHR or USDT).

Fallback withdraw

If something goes very very wrong threshold price might not be set. In that case, you can get back your funds after September 15 20:00 UTC, by calling returnCollateral function with your address.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment