-
-
Notifications
You must be signed in to change notification settings - Fork 14
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
modify: fix formula bug #410
Conversation
func NormalToMicroDenom(amount sdk.Dec) math.Int { | ||
return amount.Mul(sdk.MustNewDecFromStr("1000000")).TruncateInt() | ||
} | ||
|
||
func (m PerpetualFuturesPosition) CalcReturningAmountAtClose(closedRate sdk.Dec) (returningAmount math.Int, lossToLP math.Int) { | ||
func (m PerpetualFuturesPosition) CalcReturningAmountAtClose(baseUSDRate, quoteUSDRate sdk.Dec) (returningAmount math.Int, lossToLP math.Int) { |
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.
全体的に、xxxUSDRateではなくxxxMetricsRateのほうが良いと思います。
一応USDというのはハードコーディングされてるわけではなくてParamsでmetricsのtickerが"USD"だと指定されているだけなので。
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.
はい、それにしたいです
ただ、debugするときに
sdk.decで引き釣りまわすと、これは何のrateかわからなくなることが多々あります
MetricsRateTypeを作って
{
MetricsUnit: denom
rate 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.
↑を書き換えるタイミングで変数名を直すのはどうでしょうか?
POC開始したらすぐに直す予定です
} | ||
|
||
// func (m PerpetualFuturesPosition) RequiredMarginInMetrics(requiredMarginInQuote, quoteUSDRate sdk.Dec) sdk.Dec { | ||
func (m PerpetualFuturesPosition) RequiredMarginInMetrics(baseUSDRate, quoteUSDRate sdk.Dec) 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.
ここではmarginMetricsRateひとつだけを引数にうけとるようにして、
MarginMetricsRate(baseMetricsRate, quoteMetricsRate sdk.Dec) sdk.Dec
みたいな関数つくってそこでif分岐させるのはどうでしょうか。将来的にはbaseまたはquote以外のdenomもmarginにいれられるようにする拡張というのもありえなくはないので。
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.
こちらもPOC開始後対応でよいですか?
Issueは作っておきます
modify: fix query
No description provided.