Skip to content Search Apps Documentation Source Content Run Reset Eval Playground File Folder Download Copy Actions State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

Community realm. Read the code first. Community realm, deployed by its author. Read the code before you interact or send coins.

Playground

fee.gno

package fee

const Denom int64 = 10000

// ProtocolFee is (price * bps) / Denom without overflowing int64 on price*bps.
func ProtocolFee(price, bps int64) int64 {
	if price < 0 {
		panic("fee: negative price")
	}
	if bps < 0 || bps > Denom {
		panic("fee: bps")
	}
	q := price / Denom
	r := price % Denom
	return q*bps + r*bps/Denom
}

// SellerProceeds is the ugnot the seller receives after the protocol fee.
func SellerProceeds(price, bps int64) int64 {
	return price - ProtocolFee(price, bps)
}

gnomod.toml

module = "gno.land/p/g1n4pl5uc4yt5r96m9w6fmdznx3x0jyg8l6arhmt/bazaar/fee/v1"
gno = "0.9"

[addpkg]
  creator = "g1n4pl5uc4yt5r96m9w6fmdznx3x0jyg8l6arhmt"
  height = 35676
  max_deposit = "20000000ugnot"