Comments (9)
I can open up a PR if you want to include it.
from yearn-vaults.
I can open up a PR if you want to include it.
Yes please!
from yearn-vaults.
The first part of this issue is solved by #299
from yearn-vaults.
I have created an in-memory set data-structure with simple hash function which can be used to remove duplicates from an array.
You can checkout the gist at: https://gist.github.com/Niraj-Kamdar/25d47ae6773ea702cc583a1403627cdd
I will profile it for gas cost and if it seems better than the current solution then we can replace it.
from yearn-vaults.
@Niraj-Kamdar in our case, this needs to be on our vault, it's written in Vyper.
from yearn-vaults.
I think I will be able to convert this into a Vyper code.
from yearn-vaults.
I have created an in-memory set data-structure with simple hash function which can be used to remove duplicates from an array.
You can checkout the gist at: https://gist.github.com/Niraj-Kamdar/25d47ae6773ea702cc583a1403627cddI will profile it for gas cost and if it seems better than the current solution then we can replace it.
Thanks for sharing! As @steffenix said, in order to work for us it would need to be implemented in Vyper. but could also explore the idea of set membership to maintain proper use of the queue.
from yearn-vaults.
I will try to convert it into vyper and make it work out for yearn vault
from yearn-vaults.
I have converted the code in Vyper and benchmarked it and it seems promising:
Without Set (current):
TestStrategy <Contract>
└─ constructor - avg: 2927246 avg (confirmed): 2927246 low: 2926947 high: 2927375
Vault <Contract>
├─ constructor - avg: 4650568 avg (confirmed): 4650568 low: 4650568 high: 4650568
├─ initialize - avg: 354550 avg (confirmed): 354550 low: 354468 high: 354579
├─ addStrategy - avg: 197132 avg (confirmed): 205796 low: 23914 high: 220661
├─ setWithdrawalQueue - avg: 115595 avg (confirmed): 289094 low: 28438 high: 289094
├─ removeStrategyFromQueue - avg: 85318 avg (confirmed): 146051 low: 24588 high: 146051
├─ setDepositLimit - avg: 43852 avg (confirmed): 43852 low: 43852 high: 43852
├─ addStrategyToQueue - avg: 41719 avg (confirmed): 87202 low: 24562 high: 87202
├─ setManagement - avg: 28659 avg (confirmed): 28659 low: 28659 high: 28659
└─ withdrawalQueue - avg: 23955 avg (confirmed): 23955 low: 23955 high: 23967
With Set (proposed solution)
TestStrategy <Contract>
└─ constructor - avg: 2927246 avg (confirmed): 2927246 low: 2926947 high: 2927375
Vault <Contract>
├─ constructor - avg: 4774516 avg (confirmed): 4774516 low: 4774516 high: 4774516
├─ initialize - avg: 354550 avg (confirmed): 354550 low: 354468 high: 354579
├─ addStrategy - avg: 197132 avg (confirmed): 205796 low: 23914 high: 220661
├─ removeStrategyFromQueue - avg: 85318 avg (confirmed): 146051 low: 24588 high: 146051
├─ setWithdrawalQueue - avg: 79069 avg (confirmed): 200065 low: 28438 high: 200065
├─ setDepositLimit - avg: 43852 avg (confirmed): 43852 low: 43852 high: 43852
├─ addStrategyToQueue - avg: 41719 avg (confirmed): 87202 low: 24562 high: 87202
├─ setManagement - avg: 28659 avg (confirmed): 28659 low: 28659 high: 28659
└─ withdrawalQueue - avg: 23955 avg (confirmed): 23955 low: 23955 high: 23967
As you can see, in proposed solution setWithdrawalQueue
is only consuming 79069 compared to 115595 gas cost of current solution. This ofcourse comes with slightly high gas cost of constructor from 4650568 to 4774516.
from yearn-vaults.
Related Issues (20)
- add minShares to vault withdrawals HOT 14
- Add Slither Support to CI HOT 8
- Revoke should allow vault management role to call HOT 3
- Migrate SPECIFICATION.md to yearn-devdocs
- Add Events for Deposits and Withdrawals
- What happened with the yETH or yWETH token? HOT 1
- Add Events in HealthCheck HOT 3
- Add Event in Sweep Function HOT 2
- Add Event in SetLockedProfitDegradation HOT 1
- Add availableLiquidity to baseStrategy HOT 1
- Update token balance to vault share calculation in unit test
- Fix: NewPendingGovernance event should use _governance
- Discuss: Update vaults to make them 4626 compatible HOT 2
- Depositor obtains BaseWrapper balance on pull deposit HOT 1
- make permit eip-2612 compliant HOT 1
- minshares not parsing HOT 1
- brownie verification issue on Arbiscan
- Hi
- Question about withdrawal behavior when Aave Utilization Rate is at 100% HOT 2
- Replace Black with Ruff HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from yearn-vaults.