-
-
Save fxfactorial/ec10cc67a16a20591d4518b4551872e3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Point struct { | |
GasPriceX *big.Int | |
EthProfitY *big.Int | |
} | |
func (b *Bot) MaxProfitPossible(p1, p2 Point) *big.Int { | |
rise := new(big.Int).Sub(p2.EthProfitY, p1.EthProfitY) | |
run := new(big.Int).Sub(p2.GasPriceX, p1.GasPriceX) | |
slope := new(big.Float).Quo( | |
new(big.Float).SetInt(rise), | |
new(big.Float).SetInt(run), | |
) | |
intercept := new(big.Float).Sub( | |
new(big.Float).SetInt(p2.EthProfitY), | |
new(big.Float).Mul(slope, | |
new(big.Float).SetInt(p2.GasPriceX)), | |
) | |
intercept.Mul(intercept, big.NewFloat(-1)) | |
reciprocoal := new(big.Float).Quo( | |
new(big.Float).SetInt(run), | |
new(big.Float).SetInt(rise), | |
) | |
thing := new(big.Float).Mul(intercept, reciprocoal) | |
result := new(big.Int) | |
thing.Int(result) | |
return result | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment