-
Notifications
You must be signed in to change notification settings - Fork 286
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
[Feature][market] swap constant product #233
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #233 +/- ##
===========================================
+ Coverage 67.71% 68.52% +0.81%
===========================================
Files 70 71 +1
Lines 3026 3117 +91
===========================================
+ Hits 2049 2136 +87
+ Misses 869 866 -3
- Partials 108 115 +7 |
586e532
to
886d454
Compare
80d41c4
to
c72cd91
Compare
217a346
to
0a1cea0
Compare
Codecov is down; can we do something about that? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly stylistic changes; consider making comments, function decomposition more informative and intuitive.
|
||
// AfterValidatorBonded register voting info for a validator | ||
func (k Keeper) AfterPriceUpdated(ctx sdk.Context, denom string, price sdk.Dec) { | ||
if denom == core.MicroSDRDenom { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add comment as to why SDR has an exception
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed
) | ||
|
||
// AfterValidatorBonded register voting info for a validator | ||
func (k Keeper) AfterPriceUpdated(ctx sdk.Context, denom string, price sdk.Dec) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AfterPriceUpdated --> AfterPriceUpdate
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed
"github.com/terra-project/core/x/market/internal/types" | ||
) | ||
|
||
// AfterValidatorBonded register voting info for a validator |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Match Comment to function name
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed
} | ||
|
||
func TestGetDecSwapCoin(t *testing.T) { | ||
func TestApplyDeltaRegression(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Regression? Add comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
return Hooks{k} | ||
} | ||
|
||
// Implements StakingHooks |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AfterPriceUpdate
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed
return | ||
} | ||
|
||
// ComputeInternalSwap returns the amount of asked DecCoin should be returned for a given offerCoin at the effective |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we still need this function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not necessary, but for convenience.
In swap process and treasury module, ComputeInternalSwap is used to convert a denom to another at the effective exchange rate without spread.
x/market/internal/types/pool_info.go
Outdated
sdk "github.com/cosmos/cosmos-sdk/types" | ||
) | ||
|
||
// PoolInfo defines information to describe each denomination pool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment is not informative; "describe each denomination pool" to describe an "info pool" is not sufficiently descriptive
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed
x/market/internal/types/pool_info.go
Outdated
RegressionAmount: regressionAmount, | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add // Extends fmt.Stringer comment to help the linter
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
x/oracle/abci.go
Outdated
@@ -56,6 +56,8 @@ func EndBlocker(ctx sdk.Context, k Keeper) { | |||
// TODO - update tax-cap | |||
// Set price to the store | |||
k.SetLunaPrice(ctx, denom, mod) | |||
k.AfterPriceUpdated(ctx, denom, mod) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Name of function could be improved; perhaps "PriceUpdateCleanup", or consider decomposing the cleanup functions into identifiable chunks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed
@@ -33,3 +33,8 @@ type SupplyKeeper interface { | |||
type StakingHooks interface { | |||
AfterValidatorBonded(ctx sdk.Context, consAddr sdk.ConsAddress, valAddr sdk.ValAddress) // Must be called when a validator is bonded | |||
} | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need oracle hooks?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To keep oracle swap rate for safe base pool update, but removed. It will retry until success when there is no oracle price.
Ignoring codecov warning for now |
2f8b877
to
4e6ba3d
Compare
4e6ba3d
to
1272bd6
Compare
2f951ed
to
d4e6dc5
Compare
…nt product to compute luna pool
d4e6dc5
to
e3fb247
Compare
…erraPool, where CP = BasePool*BasePool
* clear all epoch dependent historical info when exporting for zero height
…Pool by the amount of delta/PoolRecoveryPerio
1a13bf8
to
037bb91
Compare
…na issuance systematically
…rra-project/core into feature/swap-constant-product
client/lcd/swagger-ui/swagger.yaml
Outdated
get: | ||
summary: Get prev day issuance | ||
summary: Get TERRA pool amount |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Get the current size of the Terra swap pool, denominated in usdr
client/lcd/swagger-ui/swagger.yaml
Outdated
@@ -1497,9 +1497,9 @@ paths: | |||
$ref: "#/definitions/Coin" | |||
500: | |||
description: Internal Server Error | |||
/market/prev_day_issuance: | |||
/market/terra_pool: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
terra_pool --> terra_swap_pool
client/lcd/swagger-ui/swagger.yaml
Outdated
description: Internal Server Error | ||
/market/luna_pool: | ||
get: | ||
summary: Get LUNA pool amount |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Get the current size of the Luna swap pool, denominated in uluna
client/lcd/swagger-ui/swagger.yaml
Outdated
description: Internal Server Error | ||
/market/last_update_height: | ||
get: | ||
summary: Get last pool update height |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Get the last swap pool reset height
client/lcd/swagger-ui/swagger.yaml
Outdated
description: Bad Request | ||
500: | ||
description: Internal Server Error | ||
/market/last_update_height: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
last_cp_update_height
Summary of changes
As proposed here and #226 , apply constant product to swap feature.
New EndPoint
/market/eq_terra_pool
/market/pool_info/{denom}
Report of required housekeeping
(FOR ADMIN) Before merging