Skip to content
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

no constraints on oracle price #46

Open
Waltermelon-lang opened this issue Nov 14, 2022 · 4 comments
Open

no constraints on oracle price #46

Waltermelon-lang opened this issue Nov 14, 2022 · 4 comments
Assignees
Labels
enhancement New feature or request

Comments

@Waltermelon-lang
Copy link
Collaborator

Waltermelon-lang commented Nov 14, 2022

Currently there are no constraints to a change in the oracle price.
I would like a constraint MaxOracleChange from the previous price and minimal interval 1 hour.

MaxOracleChange = 40%
MinOracleInterval = 1 hour
PreviousOraclePrice = xxx
Blockheight/TimestampPreviousOraclePrice = xxx

OracleChange = positive((newOraclePrice -oldOraclePrice)/ oldOraclePrice * 100)
if (OracleChange > MaxOracleChange & someWayToSaveleyCheckTheTimeIsMoreThanSay40Min ) {
if (newOraclePrice < oldOraclePrice){
newOraclePrice = oldOraclePrice * ((100-MaxOracleChange)/100)
} else {
newOraclePrice = oldOraclePrice * ((100+MaxOracleChange)/100)
}
}

I would also like to consider a minimum deposit of say 5 usdc and a minimum position of also say 5 usdc to ensure that nobody can clog the smart contract without active addresses that need to be checked for liquidation all the time.

@Waltermelon-lang Waltermelon-lang changed the title oracle price could be compromised if the contract changes owner no constraints on oracle price Nov 14, 2022
@Morteza3123
Copy link
Collaborator

Thanks for chainlink nft prices we don't have to pay link token or even gas to call price, but by your point we need to pay gas for checking new oracle price and save it in variable. And also if we ignore big changes of oracle price maybe we stay in an oracle price that is far from real oracle price. But I consider it by more information.

@Waltermelon-lang
Copy link
Collaborator Author

I expect us not having to pay for NFT prices to be a temporary thing.
I am not sure how much more gas costs we can expect based on adding on more variable to the smart contract, and I do expect 40% to be a pretty wide range for a movement within an hour. To compare, I just checked and FTX fell from 12.78 to 7.41 in an hour, so that was 42% drop. Perhaps we can put the oracle to 60%

@Morteza3123
Copy link
Collaborator

Smart contract has some call functions that are working with the oracle, for example checking that new price in the good range or not. we get nft price directly from chainlink and use it in our call function. If we want to check new oracle price we can save it in the setFundingFee function (Because we have to pay gas). So we can have saved oracle price for each hour. And for each call we check the new oracle price with the saved oracle price (that we save it each hour in setFundingFee) to prevent big changes. But for that many lines of the code should have this checkpoint. I suggest doing it after mvp (as you said).

@Waltermelon-lang
Copy link
Collaborator Author

Waltermelon-lang commented May 30, 2023

  • Lets make the setFundingFee function what the name suggests: to set the fundingfee (fraction)
  • If you can make a function for me where I need I can set the oracle price by calling this smart contract function, that would be nice. I set/call it for free (just the gas costs) so I can do it every 10 min for example. Also let me know how the JSON object I can return from the api should look like in order to set this price.
  • We need to limit max users per contract + min deposit
  • We can create a shortlist of people who are close to liquidation and only check for those. -> if we only allow for a limited price movement away from the oracle price, the liquiations are also limited to the same movement amount.
  • Finally: when we check the oracle price in the contract, I would like to make sure the oracle price is not too old. Therefore, the contract cannot trade on old prices. Lets add a blockheight/timestamp and compare, such that we always the updated value is always the latest.

@Waltermelon-lang Waltermelon-lang added optimization won't break the code, but can improve it enhancement New feature or request and removed after mvp optimization won't break the code, but can improve it labels Jun 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants