Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
f30ede0
struct less solution to viaIR
Padraic-O-Mhuiris Feb 10, 2023
e5093a1
add workflow for coverage
Padraic-O-Mhuiris Feb 10, 2023
7e73423
add node in workflow
Padraic-O-Mhuiris Feb 10, 2023
0109629
update
Padraic-O-Mhuiris Feb 10, 2023
4771c68
update
Padraic-O-Mhuiris Feb 10, 2023
7507379
update
Padraic-O-Mhuiris Feb 10, 2023
c28148b
use codecov
Padraic-O-Mhuiris Feb 10, 2023
5b57682
remove comments
Padraic-O-Mhuiris Feb 10, 2023
852f21c
update
Padraic-O-Mhuiris Feb 10, 2023
e2ff78f
added comment?
Padraic-O-Mhuiris Feb 10, 2023
874d7c8
update
Padraic-O-Mhuiris Feb 10, 2023
146dd6a
remove comment
Padraic-O-Mhuiris Feb 10, 2023
885fadf
filter test and script files
Padraic-O-Mhuiris Feb 10, 2023
19778e2
add to README
Padraic-O-Mhuiris Feb 10, 2023
8a41e97
comment
Padraic-O-Mhuiris Feb 10, 2023
604ce90
update
Padraic-O-Mhuiris Feb 10, 2023
7144f16
fix
Padraic-O-Mhuiris Feb 10, 2023
2259cb3
update
Padraic-O-Mhuiris Feb 10, 2023
52f9b89
linting
Padraic-O-Mhuiris Feb 10, 2023
866189a
update
Padraic-O-Mhuiris Feb 10, 2023
22bc766
use coveralls instead of codecov
Padraic-O-Mhuiris Feb 10, 2023
85d5470
update
Padraic-O-Mhuiris Feb 10, 2023
4172cf8
test
Padraic-O-Mhuiris Feb 10, 2023
60935a0
update
Padraic-O-Mhuiris Feb 10, 2023
96889da
fix
Padraic-O-Mhuiris Feb 10, 2023
1e7af28
add comments to .gitignore
Padraic-O-Mhuiris Feb 13, 2023
d2d8e49
fix coverage badge link
Padraic-O-Mhuiris Feb 13, 2023
7ce781f
add test badge
Padraic-O-Mhuiris Feb 13, 2023
a0de0f4
Update contracts/libraries/HyperdriveMath.sol
Padraic-O-Mhuiris Feb 13, 2023
b860fc6
Update contracts/libraries/HyperdriveMath.sol
Padraic-O-Mhuiris Feb 13, 2023
da99d3c
Update contracts/libraries/HyperdriveMath.sol
Padraic-O-Mhuiris Feb 13, 2023
c92173c
relabel parameters in consistency with HyperdriveMath
Padraic-O-Mhuiris Feb 13, 2023
3495bbc
added comments for _k
Padraic-O-Mhuiris Feb 13, 2023
5612bfb
add comments back in
Padraic-O-Mhuiris Feb 13, 2023
e99dc4e
prettier
Padraic-O-Mhuiris Feb 13, 2023
30e8a1c
fix
Padraic-O-Mhuiris Feb 13, 2023
749d0e0
workflows
Padraic-O-Mhuiris Feb 13, 2023
396e2b8
calculateOutGivenIn tests
Padraic-O-Mhuiris Feb 13, 2023
969eb01
use tau instead of t
Padraic-O-Mhuiris Feb 14, 2023
d793f99
update flake
Padraic-O-Mhuiris Feb 14, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
on: ["push", "pull_request"]

name: hyperdrive

jobs:
test:
name: coverage
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: recursive

- name: install node
uses: actions/setup-node@v3
with:
node-version: 14.x

- name: install packages
uses: borales/actions-yarn@v4
with:
cmd: install # will run `yarn install` command
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} # if needed

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1

- name: Run coverage
run: |
forge coverage --report lcov
sudo apt-get install lcov
lcov --remove lcov.info -o lcov.info 'test/*' 'script/*'

- name: Coveralls
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
path-to-lcov: "./lcov.info"
parallel: true

finish:
needs: test
runs-on: ubuntu-latest
steps:
- name: Coveralls Finished
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
parallel-finished: true
6 changes: 3 additions & 3 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
on: [push]
on: ["push", "pull_request"]

name: lint
name: hyperdrive

jobs:
build:
name: solidity
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
on: [push]
on: ["push", "pull_request"]

name: test
name: hyperdrive

jobs:
check:
name: solidity
name: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,8 @@ forge-cache/
node_modules/
yarn-error.log

# nix/shell extension - https://direnv.net/
.direnv

# code coverage
lcov.info
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[![Tests](https://github.com/element-fi/hyperdrive/actions/workflows/test.yml/badge.svg)](https://github.com/element-fi/hyperdrive/actions/workflows/test.yml)
[![Coverage](https://coveralls.io/repos/github/element-fi/hyperdrive/badge.svg?t=US78Aq)](https://coveralls.io/github/element-fi/hyperdrive)

# Hyperdrive

Hyperdrive is an automated market maker that enables fixed-rate markets to be
Expand Down
51 changes: 33 additions & 18 deletions contracts/libraries/HyperdriveMath.sol
Original file line number Diff line number Diff line change
Expand Up @@ -133,15 +133,20 @@ library HyperdriveMath {
// timeRemaining*amountIn shares to purchase newly minted bonds on a
// YieldSpace curve configured to timeRemaining = 1.
uint256 curveIn = _amountIn.mulDown(_timeRemaining);

// TODO: Revisit this assumption. It seems like LPs can bake this into the
// fee schedule rather than adding a hidden fee.
//
// Calculate the curved part of the trade assuming that the flat part of
// the trade was applied to the share and bond reserves.
_shareReserves = _shareReserves.add(flat);
_bondReserves = _bondReserves.sub(flat.mulDown(_sharePrice));
uint256 curveOut = YieldSpaceMath.calculateOutGivenIn(
// Credit the share reserves by the flat trade.
_shareReserves.add(flat),
// Debit the bond reserves by the flat trade.
_bondReserves.sub(flat.mulDown(_sharePrice)),
_shareReserves,
_bondReserves,
_bondReserveAdjustment,
curveIn,
FixedPointMath.ONE_18,
_timeStretch,
FixedPointMath.ONE_18.sub(_timeStretch),
_sharePrice,
_initialSharePrice,
_isBondOut
Expand All @@ -162,15 +167,20 @@ library HyperdriveMath {
uint256 curveIn = _amountIn.mulDown(_timeRemaining).divDown(
_sharePrice
);

// TODO: Revisit this assumption. It seems like LPs can bake this into the
// fee schedule rather than adding a hidden fee.
//
// Calculate the curved part of the trade assuming that the flat part of
// the trade was applied to the share and bond reserves.
_shareReserves = _shareReserves.sub(flat);
_bondReserves = _bondReserves.add(flat.mulDown(_sharePrice));
uint256 curveOut = YieldSpaceMath.calculateOutGivenIn(
// Debit the share reserves by the flat trade.
_shareReserves.sub(flat),
// Credit the bond reserves by the flat trade.
_bondReserves.add(flat.mulDown(_sharePrice)),
_shareReserves,
_bondReserves,
_bondReserveAdjustment,
curveIn,
FixedPointMath.ONE_18,
_timeStretch,
FixedPointMath.ONE_18.sub(_timeStretch),
_sharePrice,
_initialSharePrice,
_isBondOut
Expand Down Expand Up @@ -230,15 +240,20 @@ library HyperdriveMath {
uint256 curveOut = _amountOut.mulDown(_timeRemaining).divDown(
_sharePrice
);

// TODO: Revisit this assumption. It seems like LPs can bake this into the
// fee schedule rather than adding a hidden fee.
//
// Calculate the curved part of the trade assuming that the flat part of
// the trade was applied to the share and bond reserves.
_shareReserves = _shareReserves.add(flat);
_bondReserves = _bondReserves.sub(flat.mulDown(_sharePrice));
uint256 curveIn = YieldSpaceMath.calculateInGivenOut(
// Credit the share reserves by the flat trade.
_shareReserves.add(flat),
// Debit the bond reserves by the flat trade.
_bondReserves.sub(flat.mulDown(_sharePrice)),
_shareReserves,
_bondReserves,
_bondReserveAdjustment,
curveOut,
FixedPointMath.ONE_18,
_timeStretch,
FixedPointMath.ONE_18.sub(_timeStretch),
_sharePrice,
_initialSharePrice,
false
Expand Down
Loading