Skip to content

Multi VRGDA via Libraries & Structs - #13

Closed
saucepoint wants to merge 33 commits into
transmissions11:masterfrom
saucepoint:master
Closed

Multi VRGDA via Libraries & Structs#13
saucepoint wants to merge 33 commits into
transmissions11:masterfrom
saucepoint:master

Conversation

@saucepoint

@saucepointsaucepoint commented Sep 6, 2022

Copy link
Copy Markdown

Closes#12


Creation & usage of multiple VRGDAs occur via structs and libraries.

This offers wonderful ergonomics because the structs and libraries hide all of parameters & math that power the VRGDAs:

using LinearVRGDALibfor LinearVRGDAx;
using LogisticVRGDALibfor LogisticVRGDAx;
// define 2 VRGDAs to price the resources
LinearVRGDAx internal linearAuction = LinearVRGDALib.createLinearVRGDA(1e18, 0.2e18, 1e18);
LogisticVRGDAx internal logAuction = LogisticVRGDALib.createLogisticVRGDA(1e18, 0.2e18, 1000e18, 1000e18);
// purchase resources according to VRGDAsfunction buyResources(uint256amountA, uint256amountB) publicpayable {
int256 timeSinceStart =toWadUnsafe(block.timestamp- startTime);
// use linear VRGDA to price resource Auint256 pricePerA = linearAuction.getVRGDAPrice(timeSinceStart, resourceASold);
// use logistic VRGDA to price resource Buint256 pricePerB = logAuction.getVRGDAPrice(timeSinceStart, resourceBSold);
....
}

Yep! We can have two independent VRGDAs, that rely on different function families, all in the same contract 🤓


  • Support Multiple VRGDAs in a single contract
  • Example implementation (MultiNFT.sol)
  • Preliminary tests
  • Library + Struct-based LinearVRGDA
  • Library + Struct-based LogisticVRGDA
  • Library + Struct-based LogisticToLinearVRGDA
  • Testing of the new implementation against existing tests

Tangentially relevant gif

multi21

@transmissions11

Copy link
Copy Markdown
Owner

really appreciate the PR!

agree there needs to be some changes on the devex of hooking up to multiple VRGDAs.

i'm not sure a stateful solution like this is the way to go about it tho, i was more thinking of just abstracting things out into a lib (effectively like how we did it in Monaco)

#12

@saucepoint

Copy link
Copy Markdown
Author

i see -- will stare at the code a bit more and play around to see how multiple VRGDAs could interact with a lib

saucepointand others added 22 commits September 6, 2022 17:23
Libraried VRGDA + Support Multi VRGDA
* ✨ LogisticToLinearVRGDA
* 📝 Typo
* merge in master, remove base files as originally intended
* example implementation of a composite VRGDA
* conversion of logisticToLinear NFT to use library
* contract based logisticToLinear replaced with composite VRGDA in examples
* convert mock contract to use library; add fixes to log2lin lib
* add 1 wad for log2lin to follow the logistic behavior
* snapshot
Co-authored-by: t11s <greenfeatherhelp@gmail.com>
@saucepointsaucepoint changed the title Multi VRGDAMulti VRGDA via Libraries & StructsSep 8, 2022
@saucepoint

Copy link
Copy Markdown
Author

Letting this marinate a bit, my fork feels a little too opinionated. Gonna close the PR and will likely just maintain a repo for multi VRGDAs

Sign up for freeto 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.

♻️ Separate VRGDA logic into libs

2 participants

@saucepoint@transmissions11