Skip to content

♻️ Better bound implementation#220

Merged
transmissions11 merged 8 commits intotransmissions11:mainfrom
ZeroEkkusu:bound
May 2, 2022
Merged

♻️ Better bound implementation#220
transmissions11 merged 8 commits intotransmissions11:mainfrom
ZeroEkkusu:bound

Conversation

@ZeroEkkusu
Copy link
Contributor

Description

Change the implementation of bound to perfectly bound the input every time:

Logic

x ----> result

0 ------> `min`
1 ------> `min` + 1
2 ------> `min` + 2
...
n ------> `max`
n + 1 --> `min`
n + 2 --> `min` + 1
...

Examples

You can find numerous examples here.

Checklist

Ensure you completed all of the steps below before submitting your pull request:

  • Ran forge snapshot?
  • Ran npm run lint?
  • Ran forge test?

Pull requests with an incomplete checklist will be thrown out.

@transmissions11
Copy link
Owner

great work! can you run npm run lint?

@ZeroEkkusu
Copy link
Contributor Author

great work! can you run npm run lint?

first time using it. i ran it and got this; didn't change anything.

00x@ubuntu:~/Documents/00x/solmate$ npm run lint

> @rari-capital/solmate@6.2.0 lint
> prettier --write src/**/*.sol

src/auth/Auth.sol 248ms
...

@transmissions11
Copy link
Owner

first time using it. i ran it and got this; didn't change anything.

ah yup yup looks like the script wasn't setup properly, good find!

@mds1
Copy link
Contributor

mds1 commented May 2, 2022

Since afaik solmate now relies on forge, instead of upstreaming this why not just use the forge-std version directly? Similarly, in solmate's DSTestPlus we can remove assertFalse, assertApproxEq, and assertRelApproxEq and use the forge-std versions there too.

Right now you cannot have contract MyDSTestPlus is SolmatesDSTestPlus, Test because of duplicate assertFalse definitions in solmate and forge-std, so IMO we should remove duplication of methods between solmate and forge-std

@ZeroEkkusu
Copy link
Contributor Author

ZeroEkkusu commented May 2, 2022

Solmate will continue using DSTest until #214 get merged.

There are no conflicts atm.

we should remove duplication of methods

This should be addressed in #214 as well.

@transmissions11 transmissions11 changed the title fix: change bound implementation ♻️ Better bound implementation May 2, 2022
@transmissions11 transmissions11 merged commit 4197b52 into transmissions11:main May 2, 2022
@transmissions11
Copy link
Owner

great work thank you so much @ZeroEkkusu !!

@transmissions11
Copy link
Owner

transmissions11 commented May 2, 2022

@mds1 will remove bound once we switch to use forge-std, gotta finish reviewing andreas' PR

regardless, having in here in the meantime is nice for historical reasons

@ZeroEkkusu ZeroEkkusu deleted the bound branch May 2, 2022 18:52
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.

3 participants