Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: LBP pallet #11

Merged
merged 95 commits into from Jun 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
95 commits
Select commit Hold shift + click to select a range
3310201
LBP initial commit
Roznovjak Apr 20, 2021
8985a0a
implement LBP types and storage
Roznovjak Apr 20, 2021
abc5ac9
implement initial LBP events and common methods
Roznovjak Apr 21, 2021
e161102
add create_pool method and test
Roznovjak Apr 22, 2021
49318e1
add additional create_pool tests
Roznovjak Apr 22, 2021
7092e5c
add weightinfo method
Roznovjak Apr 22, 2021
9fedfbc
fix build
Roznovjak Apr 22, 2021
d6bebec
add update_pool_data method and test
Roznovjak Apr 22, 2021
38d72cd
add add/remove_liquidity methods and tests
Roznovjak Apr 23, 2021
2032860
add destroy_pool and tests
Roznovjak Apr 23, 2021
19a177c
add initial_weights param
Roznovjak Apr 27, 2021
0e96f6b
fix failing test
Roznovjak Apr 27, 2021
3266a0f
use generic balance type in LBP
Roznovjak Apr 29, 2021
ea42372
change lbp weight type
Roznovjak Apr 29, 2021
34020fd
implement pause/unpause pool
martinfridrich Apr 30, 2021
f0239de
Merge branch 'feat/lbp' of github.com:galacticcouncil/HydraDX-node in…
martinfridrich Apr 30, 2021
cbaccac
WIP add weight calculation
Roznovjak May 3, 2021
a059a65
lbp: update weight calculation
Roznovjak May 5, 2021
a0f272a
update weights only once per block
Roznovjak May 6, 2021
122db3f
change assert_err to assert_noop
Roznovjak May 6, 2021
4aa0d07
lbp: add limit for max sale duration
Roznovjak May 6, 2021
815c8d5
rework lbp weight calculation and add tests
Roznovjak May 10, 2021
5bf8950
make lbp weight function configurable
Roznovjak May 11, 2021
050f5ab
add weight_update test
Roznovjak May 11, 2021
b1e1dee
Merge remote-tracking branch 'hydradx-node/feat/lbp' into feat/lbp
Roznovjak May 12, 2021
b493e33
fix build
Roznovjak May 12, 2021
2731309
remove max_weight limit
Roznovjak May 13, 2021
8a1e65b
impl buy/sell, without tests
martinfridrich May 14, 2021
3690e35
Merge branch 'main' into feat/lbp
Roznovjak May 14, 2021
a87a9a9
initial lbp benchmarks
Roznovjak May 15, 2021
c3db696
refactor create_pool params
Roznovjak May 18, 2021
ca60f12
add configurable restriction on who can create LBPs
Roznovjak May 19, 2021
3de5357
update cargo file
Roznovjak May 19, 2021
1a5f21a
update lbp events
Roznovjak May 19, 2021
8784df0
add description to lbp errors
Roznovjak May 19, 2021
e968e27
add docs to lbp weight function
Roznovjak May 19, 2021
c97819c
refactor lbp tests
Roznovjak May 19, 2021
e6cc8aa
added tests for buy/sell + fixed bugs found by tests
martinfridrich May 20, 2021
26213fc
move weight_funtion to math crate and various small improvements
Roznovjak May 20, 2021
b50731d
Merge branch 'feat/lbp' of github.com:galacticcouncil/Basilisk-node i…
martinfridrich May 20, 2021
6934ef0
Merge branch 'feat/lbp' of github.com:galacticcouncil/Basilisk-node i…
martinfridrich May 20, 2021
bf0e69b
create pool puased by default
martinfridrich May 20, 2021
3b4a575
incorporate suggestions
Roznovjak May 20, 2021
f8b1ac7
refactor update_pool_data and add some missing tests
Roznovjak May 20, 2021
fd81abd
added events check to buy/sell tests
martinfridrich May 21, 2021
6d459ba
Merge branch 'feat/lbp' of github.com:galacticcouncil/Basilisk-node i…
martinfridrich May 21, 2021
b636b25
improve some lbp tests
Roznovjak May 21, 2021
dba903e
throw error if pool_update is noop
Roznovjak May 21, 2021
271fa3b
update weights in weight_update function
Roznovjak May 21, 2021
e041299
add benchmarks
Roznovjak May 23, 2021
7f3485c
use try_mutate_exists instead of try_mutate
Roznovjak May 24, 2021
bbcda8d
refactor lbp storage
Roznovjak May 25, 2021
95f5f0e
Merge branch 'master' into feat/lbp
Roznovjak May 25, 2021
e66a3fa
add missing config param in orml_tokens
Roznovjak May 25, 2021
35a9e72
disambiguate asset to amount mapping in public calls
Roznovjak May 27, 2021
9465126
remove const weight function
Roznovjak May 27, 2021
5b780e7
do not modify storage in get_spot_price_unchecked and refactor weight…
Roznovjak May 27, 2021
4310f17
create pool unpaused
Roznovjak May 28, 2021
ca43416
add destroy_pool_before_start test
Roznovjak May 28, 2021
c4145d6
Merge branch 'master' into feat/lbp
mrq1911 May 30, 2021
cf3144f
remove lbp deposit
Roznovjak May 31, 2021
d81260c
allow adding liquidity to running lbp
Roznovjak May 31, 2021
0510e6a
small adjustments
Roznovjak Jun 2, 2021
ec8f98a
allow LBP in call filter
Roznovjak Jun 4, 2021
fb5fead
remove remove_liquidity and replace it by destroy_pool
Roznovjak Jun 4, 2021
54f6a7d
run tests
mrq1911 Jun 7, 2021
ee25b38
Merge branch 'master' into feat/lbp
mrq1911 Jun 7, 2021
916ab09
always checkout branch, not merge
mrq1911 Jun 7, 2021
b58efe0
Merge remote-tracking branch 'origin/feat/lbp' into feat/lbp
mrq1911 Jun 7, 2021
c781450
add comments to lbp public methods
Roznovjak Jun 7, 2021
1ceb263
fix build
Roznovjak Jun 7, 2021
6cd66de
make fee configurable for every pool
Roznovjak Jun 7, 2021
f9fdd94
fix build
Roznovjak Jun 8, 2021
fa99672
remove owner check from add_liquidity
Roznovjak Jun 8, 2021
be67364
remove pool_id from add_liquidity
Roznovjak Jun 8, 2021
e37b9df
add calculate_weights test
Roznovjak Jun 8, 2021
4e498ff
disallow zero lbp weights and add some missing tests
Roznovjak Jun 8, 2021
f081b24
Merge branch 'master' into feat/lbp
Roznovjak Jun 8, 2021
c276fd6
Merge branch 'master' into feat/lbp
mrq1911 Jun 8, 2021
17e5023
Merge branch 'master' into feat/lbp
mrq1911 Jun 9, 2021
a3a1721
Merge branch 'master' into feat/lbp
Roznovjak Jun 9, 2021
89cd19a
Merge branch 'master' into feat/lbp
mrq1911 Jun 9, 2021
52b9871
fix benchmarks
Roznovjak Jun 10, 2021
ce2471d
Merge branch 'feat/lbp' of https://github.com/galacticcouncil/Basilis…
Roznovjak Jun 10, 2021
6369622
add missing test
Roznovjak Jun 10, 2021
5e60d0c
satisfy clippy
Roznovjak Jun 10, 2021
b1df488
Merge branch 'master' into feat/lbp
Roznovjak Jun 13, 2021
8ae19f6
fix: update last_weights in update_pool
Roznovjak Jun 14, 2021
e908e25
update hydra-dx-math dependency
Roznovjak Jun 15, 2021
75bfc5c
bump runtime version
Roznovjak Jun 15, 2021
153e8ef
move some deps to dev
mrq1911 Jun 16, 2021
92116e6
test benchmarks workflow
mrq1911 Jun 16, 2021
8ca8861
Merge branch 'master' into feat/lbp
mrq1911 Jun 16, 2021
a1c5e80
update lbp weights
enthusiastmartin Jun 16, 2021
e56f03b
fix lbp weights - incorrect struct name due to use of old hbs template
enthusiastmartin Jun 16, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 11 additions & 2 deletions .github/workflows/tests.yml
Expand Up @@ -19,6 +19,10 @@ jobs:
outputs:
runner: ${{ steps.determine-runner.outputs.runner }}
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}
- id: determine-runner
name: Determine runner
run: if $IS_LOCAL; then echo "::set-output name=runner::${{ github.sha }}"; else echo "::set-output name=runner::ubuntu-latest"; fi;
Expand Down Expand Up @@ -79,6 +83,9 @@ jobs:
default: true
- name: Tests
run: time cargo test --all --release --verbose --locked
- name: Test benchmarks
run: cargo test --release --features runtime-benchmarks -p pallet-lbp
working-directory: node
- name: Build release
run: time cargo build --release --verbose
- name: Version info
Expand Down Expand Up @@ -107,8 +114,10 @@ jobs:
EC2_SECRET: ${{ secrets.EC2_PWD }}
S3_BACKEND_KEY_NAME: tf-state-${{ github.sha }}
steps:
- name: checkout code
uses: actions/checkout@v2.1.0
- uses: actions/checkout@v2
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}
- name: setup node
uses: actions/setup-node@v2
with:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -29,6 +29,7 @@ rococo-local.json
rococo-local-raw.json
*.log

*.orig
scripts/polkadot-launch/
node_modules/
_actions/
Expand Down
47 changes: 45 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

69 changes: 69 additions & 0 deletions pallets/lbp/Cargo.toml
@@ -0,0 +1,69 @@
[package]
authors = ['GalacticCouncil']
description = 'HydraDX Liquidity Bootstrapping Pool Pallet'
edition = '2018'
homepage = 'https://github.com/galacticcouncil/Basilisk-node'
license = 'Apache 2.0'
name = 'pallet-lbp'
repository = 'https://github.com/galacticcouncil/Basilisk-node'
version = '1.0.0'

[package.metadata.docs.rs]
targets = ['x86_64-unknown-linux-gnu']

[build-dependencies]
wasm-builder-runner = {package = 'substrate-wasm-builder-runner', version = '1.0.5'}

# alias "parity-scale-code" to "codec"
[dependencies.codec]
default-features = false
features = ['derive']
package = 'parity-scale-codec'
version = '2.0.0'

[dependencies]
primitive-types = {default-features = false, version = '0.8.0'}
serde = {features = ['derive'], optional = true, version = '1.0.101'}

hydra-dx-math = {default-features = false, version = "2.0.0"}

## Local dependencies
primitives = { default-features = false, version = '4.1.0' }

## ORML dependencies
orml-traits = {default-features = false, version = "0.4.1-dev"}

## Substrate dependencies
frame-benchmarking = {default-features = false, optional = true, version = '3.0.0'}
frame-support = {default-features = false, version = '3.0.0'}
frame-system = {default-features = false, version = '3.0.0'}
frame-system-benchmarking = {default-features = false, optional = true, version = '3.0.0'}
sp-std = {default-features = false, version = '3.0.0'}

# Needed for benchmarks
orml-tokens = {default-features = false, version = "0.4.1-dev"}
sp-core = {default-features = false, version = '3.0.0'}
sp-runtime = {default-features = false, version = '3.0.0'}

[dev-dependencies]
sp-io = {default-features = false, version = '3.0.0'}

[features]
default = ['std']
runtime-benchmarks = [
"frame-benchmarking",
"frame-system/runtime-benchmarks",
"frame-support/runtime-benchmarks",
]
std = [
'serde',
'codec/std',
'frame-support/std',
'frame-system/std',
'orml-tokens/std',
'orml-traits/std',
'sp-runtime/std',
'sp-core/std',
'sp-std/std',
'primitives/std',
]