Open dpaiton opened 7 months ago
Related to https://github.com/delvtech/hyperdrive-rs/issues/30 where we suggest a higher-level API for the calculate_targeted_*
functions.
I like returning deltas in an object that specifies entity and unit. For now I'm listing every item, but for a high level API it makes sense to group some of these (like combining curve and flat fees). Maybe not show fees at all? | Entity | Base | Bonds | Shares |
---|---|---|---|---|
user | -100 | 104.95 | -100 | |
pool | 99.9952 | -104.955 | 99.9952 | |
user_curve_fee | 0.0475964 | 0 | 0.00475964 | |
user_flat_fee | 0 | 0 | 0 | |
lp_curve_fee | 0.0428367 | 0 | 0.0428367 | |
lp_flat_fee | 0 | 0 | 0 | |
governance_fee | 0.00475964 | 0 | 0.00475964 | |
governance_flat | 0 | 0 | 0 |
really explicit parsing of the return object makes it hard to footgun:
result = function(...)
result.user_or_pool.deltas_or_fees.unit ...
I like enabling user-facing functions to take either unit as input:
maybe instead of saying we have 3 action types, we could simplify to we have 2 action types (calc and execute) with the additional permutation of perspective being a choice (user or pool). this choice can be applied to any amount passed in: user_bond_amount
or pool_bond_amount
instead of bond_amount
.
We would like to establish a high-level Rust API. I will update the current proposal here, people should feel free to comment to suggest changes. Reacts would be helpful for those who agree with any opinion expressed.
API state space
We have 8 hyperdrive actions:
We have 3 hyperdrive units:
We have 2 hyperdrive entities:
We have 3 typical actions:
Function signatures
We should establish a single convention for how to name functions.
Data structures
Output signatures could have a unified
Result
data structure that always contains every value (even if it's sometimes zero). e.g.result.pool.share_delta
vsresult.user.base_delta