Skip to content

Watch OSM contracts and transform LogValue events#10

Merged
gslaughl merged 1 commit intostagingfrom
transform-log-value-events
Nov 27, 2019
Merged

Watch OSM contracts and transform LogValue events#10
gslaughl merged 1 commit intostagingfrom
transform-log-value-events

Conversation

@gslaughl
Copy link
Copy Markdown
Contributor

No description provided.


var models []event.InsertionModel
for _, logValueEntity := range entities {
bigIntVal := new(big.Int).SetBytes(logValueEntity.Val[:]) // TODO: verify this is a good type
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't quite sure what type to make the val value. It's not obvious from the contract what it's being used for, but since the OSM contracts are oracles (presumably about collateral evaluations), I figured an int would be a good choice, and the resulting bigint values don't seem too objectionable.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Contract says val uint128 so big.Int is fine :)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is true but in general I'm a fan of using https://github.com/makerdao/vdb-mcd-transformers/blob/staging/transformers/shared/utilities.go#L67 or https://github.com/makerdao/vdb-mcd-transformers/blob/staging/transformers/shared/utilities.go#L62 depending on whether it's an int or uint, since that distinction can cause sneaky 🐛

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks 🤦‍♂ I always forget we have these nice conversion utils!

Copy link
Copy Markdown
Contributor

@m0ar m0ar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good!

Wondering how much sense it makes to track prices of non-deployed collateral types, but I'll check in with Wouter/Nik.

Copy link
Copy Markdown
Contributor

@elizabethengelman elizabethengelman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! :shipit:

Just a couple of clarifying questions.

Expect(NewCdpSignature()).To(Equal("0xd6be0bc178658a382ff4f91c8c68b542aa6b71685b8fe427966b87745c3ea7a2"))
})

It("generates log note signature", func() {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this say log value instead of log note?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, nice catch! So used to working with LogNote events that I kept typing that on accident :P

abi = '[{"constant":false,"inputs":[],"name":"flap","outputs":[{"internalType":"uint256","name":"id","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"hump","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"rad","type":"uint256"}],"name":"kiss","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"bytes32","name":"what","type":"bytes32"},{"internalType":"uint256","name":"data","type":"uint256"}],"name":"file","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"Ash","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"vat","outputs":[{"internalType":"contract VatLike","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"flopper","outputs":[{"internalType":"contract FlopLike","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"flapper","outputs":[{"internalType":"contract FlapLike","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"wait","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"usr","type":"address"}],"name":"rely","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"bump","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"cage","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"tab","type":"uint256"}],"name":"fess","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"live","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"usr","type":"address"}],"name":"deny","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[],"name":"flop","outputs":[{"internalType":"uint256","name":"id","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"wards","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"sump","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"sin","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"Sin","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"era","type":"uint256"}],"name":"flog","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"dump","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"rad","type":"uint256"}],"name":"heal","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"vat_","type":"address"},{"internalType":"address","name":"flapper_","type":"address"},{"internalType":"address","name":"flopper_","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":true,"inputs":[{"indexed":true,"internalType":"bytes4","name":"sig","type":"bytes4"},{"indexed":true,"internalType":"address","name":"usr","type":"address"},{"indexed":true,"internalType":"bytes32","name":"arg1","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"arg2","type":"bytes32"},{"indexed":false,"internalType":"bytes","name":"data","type":"bytes"}],"name":"LogNote","type":"event"}]'
deployed = 14374540
[contract.OSM_ETH]
address = "0x75dd74e8afe8110c8320ed397cccff3b8134d981"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these from release 0.2.15? I think we'll want to make sure to update these, depending on when the 0.2.16 PR is merged in.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Conveniently they don't change between versions, although all of them besides ETH and BAT are removed from the 0.2.16 changelog. It sounds like we might want to remove all the collateral types besides those 2 anyway.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still true for 0.2.17?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep :D

type = "eth_event"
repository = "github.com/makerdao/vdb-mcd-transformers"
migrations = "db/migrations"
contracts = ["OSM_ETH", "OSM_REP", "OSM_ZRX", "OSM_OMG", "OSM_BAT", "OSM_DGD", "OSM_GNT"]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do these contracts correspond to the PIP_* addresses or the VAL_ *addresses in the changelog? They're mostly the same, except that there is a PIP_SAI address, but not a VAL_SAI one, and I'm wondering if we should include one for Sai.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question-- it took me a while to realize that the addresses I wanted were even in the changelog, so I actually got them by looking in etherscan and just grabbing every pip_ value that was passed to the Spotter.file method. So I guess these addresses are more closely linked with the PIP_* addresses.

I was also curious about the Sai situation, but in the changelog the PIP_SAI address is 0x0000000000000000000000000000000000000001 (not a real address ofc), and interestingly that's also what's passed to Spotter.file. So I assume there's not really an oracle in the system for Sai.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah iirc we just assume sai/dai always == $1. Not sure why an address would be declared for its spotter, though, if that's the case... 🤔

elizabethengelman pushed a commit that referenced this pull request Nov 21, 2019
Discard logs created during tests
elizabethengelman pushed a commit that referenced this pull request Nov 21, 2019
@gslaughl gslaughl force-pushed the transform-log-value-events branch from 2eabf6d to 9ac5a46 Compare November 26, 2019 23:50
@gslaughl gslaughl merged commit 888d8d2 into staging Nov 27, 2019
@gslaughl gslaughl deleted the transform-log-value-events branch November 27, 2019 00:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants