makerdao / developerguides

Developer guides to integrate with MakerDAO's smart contracts, SDKs, APIs, products, and partners
Apache License 2.0
647 stars 229 forks source link

frob Transaction failed in mcd-seth-01.md #69

Closed nsouch closed 4 years ago

nsouch commented 4 years ago

The frob() call failed while running the example of drawing DAI from BAT (mcd-seth-01.md).

The transactionHash is :

0x145283dbfc249b2c2c36b466d4362446f233f30e527e08effdcdf652fabac946

since it is mentionned that

This guide works under the Kovan 1.0.2 Release of the system.

could it be a compatibility issue ? shall I send more information ?

liberuum commented 4 years ago

Hi, Seeing from your txhash, you should frob with at least 20 Dai. As 20 Dai is the minimum amount you could draw from the system. I'd recommend you draw 25 Dai.

nsouch commented 4 years ago

Hi, thx for your help.

new attempt failed for 25 Dai. TxHash :

0x7a749ea7bfa1663c20da5275518f3c694ee7dd9d8876aa1017ce96231fa649fb

liberuum commented 4 years ago

Hmm, try to use that on the latest kovan deployment: https://changelog.makerdao.com/releases/kovan/1.0.9/contracts.json

nsouch commented 4 years ago

But the addresses involded in the guide are not different between 1.0.2 and 1.0.9.

There's maybe the MCD_FLIP_BAT_A (not called by the guide but is related to BAT). ILK_REGISTRY is new, otherwise many new collaterals are introduced and SAI is removed.

liberuum commented 4 years ago

Make sure that your $dink and $dart values are set correct. Due to seth being updated, the conversion might be a different one than in the guide. You can set dink=$(seth --to-uint256 $(seth --to-wei 150 eth)) and dart=$(seth --to-uint256 $(seth --to-wei 25 eth)) For me it worked fine doing above. My tx: https://kovan.etherscan.io/tx/0x72c244fd38a64b48313017311c073cfbe09eb4fb3b2919b37b1897f615ec731b

nsouch commented 4 years ago

the frob() call succeeded with your dart calculation but the DAI balance seems incorrect :)

$ seth --to-fix 45 $(seth --to-dec $(seth call $MCD_VAT 'dai(address)(uint256)' $urn))

57280581651.654777643580824758089718844654393534456004608

Note that the rate was curious too : 327388.476393033923681366870037784 Did I miss something ? What's your rate ?

liberuum commented 4 years ago

Try removing the `$(seth --to-dec ) command. latest version of seth converts straight to a decimal number now. That's why :D

So the full list of commands without the seth --to-dec would look like this:

art=$(seth --from-wei $(seth call $MCD_VAT 'urns(bytes32,address)(uint256,uint256)' $ilk $urn | sed -n 2p))
rate=$(seth --to-fix 27 $(seth call $MCD_VAT 'ilks(bytes32)(uint256,uint256,uint256,uint256,uint256)' $ilk | sed -n 2p))
debt=$(bc<<<"$art*$rate")
debtWadRound=$(seth --to-uint256 $(bc<<<"$art*$rate*10^18/1+1"))
nsouch commented 4 years ago

--to-dec was the problem and drawing 25 instead of 20. rate is rather 1.024393872125548319941739518

thx a lot