You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
open long
close long
open short
close short
add liquidity
remove liquidity
redeem withdraw shares
checkpoint
We have 3 hyperdrive units:
base
shares
bonds
We have 2 hyperdrive entities:
user (wallet)
generally communicates in "base" and "bonds"
pool (reserves)
generally communicates in "shares" and "bonds"
We have 3 typical actions:
preview a trade from a user's perspective
output is deltas to be applied to user's wallet
preview a trade from pool's perspective
output is deltas to be applied to a pool's reserves
"action"
actually performs the trade & updates state
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 vs result.user.base_delta
The text was updated successfully, but these errors were encountered:
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.
dpaiton
changed the title
Implement a high-level rust api
DESIGN: Implement a high-level rust api
May 3, 2024
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
The text was updated successfully, but these errors were encountered: