-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement vault liquidation core logic #460
Comments
Edge case for price logs:
options:
|
what should it do?
|
Yes, I think it's more helpful long-term. I actually forgot that we previously agreed to write tests using specific vault on a specific block, so I created a separate issue for this: #464
Would it be the same slot address for all collateral types? |
does not seem so. i found a contract that differs from the one at https://github.com/makerdao/osm/blob/master/src/osm.sol regarding the slot address of the https://etherscan.io/address/0x25D03C2C928ADE19ff9f4FFECc07d991d0df054B#code
it apparently executes the eth_getLogs https://github.com/ethers-io/ethers.js/blob/ec1b9583039a14a0e0fa15d0a2a6082a2f41cf5b/packages/providers/src.ts/json-rpc-provider.ts#L604 sadly the docs here are not of much help (not too much description)
i dont think it makes much sense to increase it geometrically, instead i would propose to shift the
so i would say we request as follows: let windowNumber = 0
const maxLogs = 2000
let events = []
const latestBlockNumber = getLatestBlockNumber()
while(events.length === 0 && latestBlockNumber > (windowNumber+1)*maxLogs){
events = contract.queryFilter(filter, -(1 + windowNumber)*maxLogs, -windowNumber*maxLogs)
} But even then we potentially risk to have a contract that has no events yet. What shall we do then?
then in this pr i will not add a simulation but instead just do the tests with specific block numbers. Later in the linked pr i will add the simulations |
According to the docs the topics are also send to the RPC endpoint and are filtered on their side.
This doesn't contradict each other. If we need only one last event of the kind and it's updated every ~hour, we might want to first request a very small page of a few blocks and only then increase it to the limit and start pagination. Regarding the original edge case, how many pages would it take to fetch the last event?
Good point, maybe we can check the deployment block # of the contract to be the latest block to fetch?
Can you determine the slot address automatically? Or what is the current process for this?
Please also make a simulation with fixed block number, same as you're using for a test, so it's manually testable too and is usable on the frontend/bot. Regarding the implementation order, I propose to implement separate service to cache vaults and fetch data from DICU in another PR after the rest is tested and merged, so we can validate core logic and unblock UI integration earlier. Do you have any objections? |
6 pages, it's possible to fetch 100k events per request
i can't imagine such a move in the current issue:
good optimization move, but still does not solve the original problem where there could be no events at all in the logs.
no objections |
As far as I know, the source code doesn't guarantee the order, but the compiler. That's why I am asking, what is the current process, how do you determine the slot address? I can imagine that it can be a simple trail and error loop: modify slot 0, check the public method, modify slot 1, check the method output, etc. Maybe there is already a package for this?
Well, we can set this price to
Oh wow, wouldn't expect this to be difficult. If it doesn't work generically on etherium, you can use I want to first find a solution that works generically and only later optimize for less requests. The worst-case scenario is the hardcoded slot numbers inside our COLLATERALS.ts file, that we need to somehow keep updated with every new change of the |
You:
Earlier, also you:
Which of this is true? |
not me, but the error message :)
the truth is that i've tried to set the page size to 100k and it works: so the error message is apparently incorrect :o |
up until now i've been using the approach that is most commonly met all over the place (yt guides, googlable articles): count from top to bottom starting from the first declaration, skip structs' definitions. Trial and error obviously also works.
did not find one within 6 min search. Also it does not make sense to me. We (humans) know that there's a private variable that represents "current price" and in the src code it is defined as
so i interpet this as "Set the type to
actually as i looked deeper into this: the UpdateAddress has no indexed values so we can't filter there :D. Seems like we have to filter page by page |
Yes, the other option is to keep the type, set
Agreed
Ahh, I don't know why PE is doing that. Let's still proceed with this, but after you implement it, please count how many requests is the overhead for all vaults. |
please rephrase the question to avoid the misinterpretation from my side. |
There were two proposed solutions to the situation with private variables: We went with A so far, but I want to know in the end, how much overhead (in terms of requests per minute) A brings over B. |
The overhead now is 225 requests. potentially can go up to 250 Also after going over every entry in our
So it seems like going over and hardcoding things is inevitable. Might as well find and hardcode the slots instead of hardcoding the event names :) regarding the missing oracles: without those there will be no price and consequently we won't be able to tell if the vault is liquidatable right now or in the near future. This is the case for example with 15093 vault where the cdp manager claims the type to be |
Where is it then?
What would be the mechanism to validate slot hasn't changed/still valid? The mechanism to validate the events is simple: to fetch at least one event. |
spot contract contains them as well. i guess it's a more reliable option since it's used in the price update mechanisms unlike the osm-mom contract.
this definitely requires a simulation in place since the inner state is not exposed. I see it as follows:
If we have a wrong |
One more edge case that speaks for hardcoding: not all contracts comply with osm abi, some reference dsthing as their oracles. Should i lay out the proposal? So i guess we have to come up with a config that determines how the prices are being read. |
Yes, please. Also, please try to better explain what is the edge case, I can't follow atm |
3 following links lead to the oracles of different collateral types: https://etherscan.io/address/0xf45ae69cca1b9b043dae2c83a5b65bc605bec5f5#code Upon closer examination you can find a variety of differences. Some of those are:
So i would have to manually configure at least 3 of these types of oracles and fetch prices based on the oracle configurations. |
Thanks! Does this affect our ability to generically fetch BOTH current and next prices or only the next one? Do you want to propose how to extend COLLATERALS config with some parameters on osm types/slots/something else? |
Missed it in the previous iterations: we actually should cover the case where we have no prices available anyway because there's also a flag that indicates wether the price is valid (if it's not, the contracts that depend on the oracle will not update their parameters & transaction fails ) I propose to do this first:
If this does not cover, then we're forced to manually go over the contracts where this approach has failed and hardcode the slots for them. Potentially all the collateral types could have different slots so it's a lot of "manual labor" |
Alright, so it's another edge case, but this doesn't answer my first question. Do those different contracts complicates fetching of the current price, next price or both?
What is the |
differing contracts complicate fetching any value from them since the slot layout is different everywhere.
since they're 3 types of contracts that i've seen that supposedly have the same slot layout per type, i would think that having less duplication is more adequate.
yes, but this seems to cover for theoretical (as of now) case where each collateral has unique set of values. If they don't , then it clutters the config. I can nevertheless just put the values right into the config if you'd like. On top of that (as a weak hypothetical case) if 3 types are distinguishable we may utilise the type id for future logic. |
I am still lacking the technicality where which value is located and which of them are private, which of them are not private, but still affected, so please be more specific! Does it affect ALL values of the VaultTransaction type?
Again, I was asking to be more specific and provide the missing parts, since
Obviously, not always, sometimes less duplication is overoptimization. But we can also discuss it after the code is there.
I can't strongly suggest one over the other at the moment |
types are as follows
all of the relevant values are private for for
no, i'm currently only speaking about the oracle prices which are part of the code related points (the rest) i agree with |
Additional changes that turns out are needed: the vault type needs to receive fields:
where |
Unfortunately, I can't follow. Also, looking at the types, I can see that there is a new
|
|
Goal
The PM is able to see specific vault and liquidate it using store actions
Context
After the conclusion of the related investigation issue, where the implementation proposal was outlined, we would implement this functionality in this issue. Current issue may also keep the discussion on the new edge cases.
The basic outline of the proposal:
Assets
Tasks
The text was updated successfully, but these errors were encountered: