Closed canercandan closed 2 years ago
LGTM
Tests:
$ gC v0.14.0
Note: switching to 'v0.14.0'.
$ make install
$ sifnoded version
0.14.0
$ ./register-all-tokens.mjs -p localnet --select=rowan,cusdc
$ ./create-pools.mjs -p localnet --select=cusdc
$ ./pools.mjs -p localnet
$ sifnoded q clp pools $'--node=http://localhost:26657' $'--chain-id=localnet'
clp_module_address: sif1pjm228rsgwqf23arkx7lm9ypkyma7mzr3y2n85
height: "10"
pagination:
next_key: null
total: "0"
pools:
- external_asset:
symbol: cusdc
external_asset_balance: "610316557165"
native_asset_balance: "81285119183944010790286697"
pool_units: "81285119183944010790286697"
reward_period_native_distributed: "0"
swap_price_external: "133.185177805963498467"
swap_price_native: "0.007508343018897287"
$ ./upgrade-software.mjs -p localnet --version 0.17.0 --waitNBlocks 20
$ sifnoded tx gov submit-proposal software-upgrade 0.17.0 --deposit=1000000000rowan --upgrade-height=31 --title=v0.17.0 --description=v0.17.0 $'--keyring-backend=test' $'--node=http://localhost:26657' $'--chain-id=localnet' $'--from=account-sif1syavy2npfyt9tcncdtsdzf7kny9lh777yqc2nd' -y $'--fees=100000000000000000rowan' $'--broadcast-mode=block'
$ ./vote-prosposal.mjs -p localnet --id 1
$ sifnoded tx gov vote 1 yes $'--keyring-backend=test' $'--node=http://localhost:26657' $'--chain-id=localnet' $'--from=account-sif1syavy2npfyt9tcncdtsdzf7kny9lh777yqc2nd' -y $'--fees=100000000000000000rowan' $'--broadcast-mode=block'
$ ./clp-params.mjs -p localnet
$ sifnoded q clp params $'--node=http://localhost:26657' $'--chain-id=localnet'
Error: rpc error: code = Unknown desc =
github.com/cosmos/cosmos-sdk/baseapp.(*BaseApp).Query.func1
/home/caner/go/pkg/mod/github.com/cosmos/cosmos-sdk@v0.45.6/baseapp/abci.go:409
runtime.gopanic
/usr/local/go/src/runtime/panic.go:838
github.com/cosmos/cosmos-sdk/x/params/types.Subspace.Get
/home/caner/go/pkg/mod/github.com/cosmos/cosmos-sdk@v0.45.6/x/params/types/subspace.go:109
github.com/cosmos/cosmos-sdk/x/params/types.Subspace.GetParamSet
/home/caner/go/pkg/mod/github.com/cosmos/cosmos-sdk@v0.45.6/x/params/types/subspace.go:222
github.com/Sifchain/sifnode/x/clp/keeper.Keeper.GetParams
/home/caner/Dev/sifchain/sifnode/x/clp/keeper/params.go:19
github.com/Sifchain/sifnode/x/clp/keeper.Querier.GetParams
/home/caner/Dev/sifchain/sifnode/x/clp/keeper/grpc_query.go:238
github.com/Sifchain/sifnode/x/clp/types._Query_GetParams_Handler
/home/caner/Dev/sifchain/sifnode/x/clp/types/querier.pb.go:1729
[...]
$ ./add-liquidity.mjs -p localnet --symbol cusdc --externalAmount 100000000 --nativeAmount 13318517780596400000000
$ sifnoded tx clp add-liquidity --symbol=cusdc --nativeAmount=13318517780596400000000 --externalAmount=100000000 $'--keyring-backend=test' $'--node=http://localhost:26657' $'--chain-id=localnet' $'--from=account-sif1syavy2npfyt9tcncdtsdzf7kny9lh777yqc2nd' -y $'--fees=100000000000000000rowan' $'--broadcast-mode=block'
$ ./update-margin-params.mjs -p localnet --whitelistingEnabled=false
$ sifnoded tx margin update-params --health-gain-factor=0.000000022 --interest-rate-decrease=0.000000000333333333 --interest-rate-increase=0.000000000333333333 --interest-rate-max=0.00000021 --interest-rate-min=0.00000001 --leverage-max=5.0 --epoch-length=1 --removal-queue-threshold=0.35 --max-open-positions=10000 --force-close-fund-percentage=1.0 --force-close-fund-address=sif1ze8zn7e0apsaj4z5xte5he5kemaalk7s6c9kq7 --incremental-interest-payment-enabled=true --incremental-interest-payment-fund-percentage=0.35 --incremental-interest-payment-fund-address=sif1ze8zn7e0apsaj4z5xte5he5kemaalk7s6c9kq7 --pool-open-threshold=0.65 --sq-modifier=10000000000000000000000000 --safety-factor=1.05 --whitelisting-enabled=false $'--keyring-backend=test' $'--node=http://localhost:26657' $'--chain-id=localnet' $'--from=account-sif1syavy2npfyt9tcncdtsdzf7kny9lh777yqc2nd' -y $'--fees=100000000000000000rowan' $'--broadcast-mode=block'
$ ./update-margin-pools.mjs -p localnet --pools cusdc
$ sifnoded tx margin update-pools /tmp/margin-pools/pools.json --closed-pools=/tmp/margin-pools/closedPools.json $'--keyring-backend=test' $'--node=http://localhost:26657' $'--chain-id=localnet' $'--from=account-sif1syavy2npfyt9tcncdtsdzf7kny9lh777yqc2nd' -y $'--fees=100000000000000000rowan' $'--broadcast-mode=block'
$ ./margin-params.mjs -p localnet
$ sifnoded q margin params $'--node=http://localhost:26657' $'--chain-id=localnet'
params:
closed_pools: []
epoch_length: "1"
force_close_fund_address: sif1ze8zn7e0apsaj4z5xte5he5kemaalk7s6c9kq7
force_close_fund_percentage: "1.000000000000000000"
health_gain_factor: "0.000000022000000000"
incremental_interest_payment_enabled: true
incremental_interest_payment_fund_address: sif1ze8zn7e0apsaj4z5xte5he5kemaalk7s6c9kq7
incremental_interest_payment_fund_percentage: "0.350000000000000000"
interest_rate_decrease: "0.000000000333333333"
interest_rate_increase: "0.000000000333333333"
interest_rate_max: "0.000000210000000000"
interest_rate_min: "0.000000010000000000"
leverage_max: "5.000000000000000000"
max_open_positions: "10000"
pool_open_threshold: "0.650000000000000000"
pools:
- cusdc
removal_queue_threshold: "0.350000000000000000"
safety_factor: "1.050000000000000000"
sq_modifier: "10000000000000000000000000.000000000000000000"
whitelisting_enabled: false
$ ./add-liquidity.mjs -p localnet --symbol cusdc --externalAmount 100000000 --nativeAmount 13318517780596400000000
$ sifnoded tx clp add-liquidity --symbol=cusdc --nativeAmount=13318517780596400000000 --externalAmount=100000000 $'--keyring-backend=test' $'--node=http://localhost:26657' $'--chain-id=localnet' $'--from=account-sif1syavy2npfyt9tcncdtsdzf7kny9lh777yqc2nd' -y $'--fees=100000000000000000rowan' $'--broadcast-mode=block'
raw_log: "recovered: UnmarshalJSON cannot decode empty bytes\nstack:\ngoroutine 31
[running]:\nruntime/debug.Stack()\n\t/usr/local/go/src/runtime/debug/stack.go:24
+0x65\ngithub.com/cosmos/cosmos-sdk/baseapp.newDefaultRecoveryMiddleware.func1({0x1a771a0,
0xc000fd2750})\n\t/home/caner/go/pkg/mod/github.com/cosmos/cosmos-sdk@v0.45.6/baseapp/recovery.go:71
+0x27\ngithub.com/cosmos/cosmos-sdk/baseapp.newRecoveryMiddleware.func1({0x1a771a0?,
0xc000fd2750?})\n\t/home/caner/go/pkg/mod/github.com/cosmos/cosmos-sdk@v0.45.6/baseapp/recovery.go:39
+0x30\ngithub.com/cosmos/cosmos-sdk/baseapp.processRecovery({0x1a771a0, 0xc000fd2750},
0xc004a82900?)\n\t/home/caner/go/pkg/mod/github.com/cosmos/cosmos-sdk@v0.45.6/baseapp/recovery.go:28
+0x37\ngithub.com/cosmos/cosmos-sdk/baseapp.processRecovery({0x1a771a0, 0xc000fd2750},
0x265bf00?)\n\t/home/caner/go/pkg/mod/github.com/cosmos/cosmos-sdk@v0.45.6/baseapp/recovery.go:33
+0x5e\ngithub.com/cosmos/cosmos-sdk/baseapp.(*BaseApp).runTx.func1()\n\t/home/caner/go/pkg/mod/github.com/cosmos/cosmos-sdk@v0.45.6/baseapp/baseapp.go:608
+0xfd\npanic({0x1a771a0, 0xc000fd2750})\n\t/usr/local/go/src/runtime/panic.go:838
+0x207\ngithub.com/cosmos/cosmos-sdk/x/params/types.Subspace.Get({{0x265a7d0, 0xc000596d70},
0xc0001fa020, {0x2639f88, 0xc000d26e50}, {0x2639fd8, 0xc000d27300}, {0xc0005bb680,
0x3, 0x19}, ...}, ...)\n\t/home/caner/go/pkg/mod/github.com/cosmos/cosmos-sdk@v0.45.6/x/params/types/subspace.go:109
+0x307\ngithub.com/Sifchain/sifnode/x/clp/keeper.Keeper.IsRemovalQueueEnabled(...)\n\t/home/caner/Dev/sifchain/sifnode/x/clp/keeper/params.go:14\ngithub.com/Sifchain/sifnode/x/clp/keeper.msgServer.AddLiquidity({{{0x2639f88,
0xc000d27170}, {0x265a7d0, 0xc000596d70}, {0x7fd79043f580, 0xc001042dc0}, {0x263bb08,
0xc000550630}, {0x7fd79043f5d0, 0xc0004d4a00}, ...}}, ...)\n\t/home/caner/Dev/sifchain/sifnode/x/clp/keeper/msg_server.go:720
[...]
$ ./upgrade-software.mjs -p localnet --version 1.0-beta.11 --waitNBlocks 20
$ sifnoded tx gov submit-proposal software-upgrade 1.0-beta.11 --deposit=1000000000rowan --upgrade-height=31 --title=v1.0-beta.11 --description=v1.0-beta.11 $'--keyring-backend=test' $'--node=http://localhost:26657' $'--chain-id=localnet' $'--from=account-sif1syavy2npfyt9tcncdtsdzf7kny9lh777yqc2nd' -y $'--fees=100000000000000000rowan' $'--broadcast-mode=block'
$ ./vote-prosposal.mjs -p localnet --id 2
$ sifnoded tx gov vote 2 yes $'--keyring-backend=test' $'--node=http://localhost:26657' $'--chain-id=localnet' $'--from=account-sif1syavy2npfyt9tcncdtsdzf7kny9lh777yqc2nd' -y $'--fees=100000000000000000rowan' $'--broadcast-mode=block'
$ ./add-liquidity.mjs -p localnet --symbol cusdc --externalAmount 100000000 --nativeAmount 13318517780596400000000
$ sifnoded tx clp add-liquidity --symbol=cusdc --nativeAmount=13318517780596400000000 --externalAmount=100000000 $'--keyring-backend=test' $'--node=http://localhost:26657' $'--chain-id=localnet' $'--from=account-sif1syavy2npfyt9tcncdtsdzf7kny9lh777yqc2nd' -y $'--fees=100000000000000000rowan' $'--broadcast-mode=block'
raw_log: "recovered: UnmarshalJSON cannot decode empty bytes\nstack:\ngoroutine 31
[running]:\nruntime/debug.Stack()\n\t/usr/local/go/src/runtime/debug/stack.go:24
+0x65\ngithub.com/cosmos/cosmos-sdk/baseapp.newDefaultRecoveryMiddleware.func1({0x1a771a0,
0xc000fd2750})\n\t/home/caner/go/pkg/mod/github.com/cosmos/cosmos-sdk@v0.45.6/baseapp/recovery.go:71
+0x27\ngithub.com/cosmos/cosmos-sdk/baseapp.newRecoveryMiddleware.func1({0x1a771a0?,
0xc000fd2750?})\n\t/home/caner/go/pkg/mod/github.com/cosmos/cosmos-sdk@v0.45.6/baseapp/recovery.go:39
+0x30\ngithub.com/cosmos/cosmos-sdk/baseapp.processRecovery({0x1a771a0, 0xc000fd2750},
0xc004a82900?)\n\t/home/caner/go/pkg/mod/github.com/cosmos/cosmos-sdk@v0.45.6/baseapp/recovery.go:28
+0x37\ngithub.com/cosmos/cosmos-sdk/baseapp.processRecovery({0x1a771a0, 0xc000fd2750},
0x265bf00?)\n\t/home/caner/go/pkg/mod/github.com/cosmos/cosmos-sdk@v0.45.6/baseapp/recovery.go:33
+0x5e\ngithub.com/cosmos/cosmos-sdk/baseapp.(*BaseApp).runTx.func1()\n\t/home/caner/go/pkg/mod/github.com/cosmos/cosmos-sdk@v0.45.6/baseapp/baseapp.go:608
+0xfd\npanic({0x1a771a0, 0xc000fd2750})\n\t/usr/local/go/src/runtime/panic.go:838
+0x207\ngithub.com/cosmos/cosmos-sdk/x/params/types.Subspace.Get({{0x265a7d0, 0xc000596d70},
0xc0001fa020, {0x2639f88, 0xc000d26e50}, {0x2639fd8, 0xc000d27300}, {0xc0005bb680,
0x3, 0x19}, ...}, ...)\n\t/home/caner/go/pkg/mod/github.com/cosmos/cosmos-sdk@v0.45.6/x/params/types/subspace.go:109
+0x307\ngithub.com/Sifchain/sifnode/x/clp/keeper.Keeper.IsRemovalQueueEnabled(...)\n\t/home/caner/Dev/sifchain/sifnode/x/clp/keeper/params.go:14\ngithub.com/Sifchain/sifnode/x/clp/keeper.msgServer.AddLiquidity({{{0x2639f88,
0xc000d27170}, {0x265a7d0, 0xc000596d70}, {0x7fd79043f580, 0xc001042dc0}, {0x263bb08,
0xc000550630}, {0x7fd79043f5d0, 0xc0004d4a00}, ...}}, ...)\n\t/home/caner/Dev/sifchain/sifnode/x/clp/keeper/msg_server.go:720
[...]
$ ./upgrade-software.mjs -p localnet --version 1.0-beta.12 --waitNBlocks 20
$ sifnoded tx gov submit-proposal software-upgrade 1.0-beta.12 --deposit=1000000000rowan --upgrade-height=31 --title=v1.0-beta.12 --description=v1.0-beta.12 $'--keyring-backend=test' $'--node=http://localhost:26657' $'--chain-id=localnet' $'--from=account-sif1syavy2npfyt9tcncdtsdzf7kny9lh777yqc2nd' -y $'--fees=100000000000000000rowan' $'--broadcast-mode=block'
$ ./vote-prosposal.mjs -p localnet --id 3
$ sifnoded tx gov vote 3 yes $'--keyring-backend=test' $'--node=http://localhost:26657' $'--chain-id=localnet' $'--from=account-sif1syavy2npfyt9tcncdtsdzf7kny9lh777yqc2nd' -y $'--fees=100000000000000000rowan' $'--broadcast-mode=block'
$ ./clp-params.mjs -p localnet
$ sifnoded q clp params $'--node=http://localhost:26657' $'--chain-id=localnet'
params:
enable_removal_queue: false
min_create_pool_threshold: "100"
symmetry_ratio_threshold: "0.000500000000000000"
symmetry_threshold: "0.000050000000000000"
$ ./add-liquidity.mjs -p localnet --symbol cusdc --externalAmount 100000000 --nativeAmount 13318517780596400000000
$ sifnoded tx clp add-liquidity --symbol=cusdc --nativeAmount=13318517780596400000000 --externalAmount=100000000 $'--keyring-backend=test' $'--node=http://localhost:26657' $'--chain-id=localnet' $'--from=account-sif1syavy2npfyt9tcncdtsdzf7kny9lh777yqc2nd' -y $'--fees=100000000000000000rowan' $'--broadcast-mode=block'
[...]
type: added_liquidity
[...]
$ ./update-margin-params.mjs -p localnet --whitelistingEnabled=false --epochLength 100
$ sifnoded tx margin update-params --health-gain-factor=0.000000022 --interest-rate-decrease=0.000000000333333333 --interest-rate-increase=0.000000000333333333 --interest-rate-max=0.00000021 --interest-rate-min=0.00000001 --leverage-max=5.0 --epoch-length=100 --removal-queue-threshold=0.35 --max-open-positions=10000 --force-close-fund-percentage=1.0 --force-close-fund-address=sif1ze8zn7e0apsaj4z5xte5he5kemaalk7s6c9kq7 --incremental-interest-payment-enabled=true --incremental-interest-payment-fund-percentage=0.35 --incremental-interest-payment-fund-address=sif1ze8zn7e0apsaj4z5xte5he5kemaalk7s6c9kq7 --pool-open-threshold=0.65 --sq-modifier=10000000000000000000000000 --safety-factor=1.05 --whitelisting-enabled=false $'--keyring-backend=test' $'--node=http://localhost:26657' $'--chain-id=localnet' $'--from=account-sif1syavy2npfyt9tcncdtsdzf7kny9lh777yqc2nd' -y $'--fees=100000000000000000rowan' $'--broadcast-mode=block'
$ ./margin-params.mjs -p localnet
$ sifnoded q margin params $'--node=http://localhost:26657' $'--chain-id=localnet'
params:
closed_pools: []
epoch_length: "100"
[...]
$ ./open-mtp.mjs -p localnet
$ sifnoded q auth account $(sifnoded keys show account-sif1syavy2npfyt9tcncdtsdzf7kny9lh777yqc2nd -a $'--keyring-backend=test') $'--node=http://localhost:26657' $'--chain-id=localnet' --output=json | jq -r '{account_number: .account_number, sequence: .sequence}'
{ β retrieving account number and sequence
"account_number": "0",
"sequence": "16"
}
$ sifnoded tx margin open --borrow_asset=rowan --collateral_asset=cusdc --collateral_amount=1000000000 --position=long --leverage=10 $'--keyring-backend=test' $'--node=http://localhost:26657' $'--chain-id=localnet' $'--from=account-sif1syavy2npfyt9tcncdtsdzf7kny9lh777yqc2nd' -y $'--fees=100000000000000000rowan' $'--broadcast-mode=block' --account-number=0 --sequence=16
[...]
- attributes:
- key: id
value: "1"
- key: position
value: LONG
- key: address
value: sif1syavy2npfyt9tcncdtsdzf7kny9lh777yqc2nd
- key: collateral_asset
value: cusdc
- key: collateral_amount
value: "1000000000"
- key: custody_asset
value: rowan
- key: custody_amount
value: "658534851801842252230877"
- key: leverage
value: "5.000000000000000000"
- key: liabilities
value: "4000000000"
- key: interest_paid_collateral
value: "0"
- key: interest_paid_custody
value: "0"
- key: interest_unpaid_collateral
value: "0"
- key: health
value: "1.222516981250000000"
type: margin/mtp_open
[...]
Codecov Report
11.11% <0.00%> (ΓΈ)
3.17% <0.00%> (-0.11%)
75.00% <100.00%> (+0.71%)