Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions ride/factory_v2.ride
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,14 @@ func keyMinBalance(poolAddress: String, assetId: String)
func keyMinBalanceDefault(assetId: String)
= makeString(["%s%s", "minBalanceDefault", assetId], SEP)

#------------------------
# SWAP FUNCTIONS
#------------------------

func keySwapProtocolFee() = ["%s", "protocolFee"].makeString(SEP)
func keySwapPoolFee() = ["%s", "poolFee"].makeString(SEP)
func keyFeeCollectorAddress() = ["%s", "feeCollectorAddress"].makeString(SEP)

#------------------------
# GLOBAL FUNCTIONS
#------------------------
Expand Down
10 changes: 7 additions & 3 deletions ride/swap.ride
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ let factoryContract = addressFromStringValue(getStringOrFail(fc()))
func protocolFee() = ["%s", "protocolFee"].makeString(SEP)
func poolFee() = ["%s", "poolFee"].makeString(SEP)

func getStringOrFailFromAddress(address: Address, key: String) = address.getString(key).valueOrErrorMessage(makeString(["mandatory ", address.toString(), ".", key, " is not defined"], ""))
func getStringOrFailFromAddress(address: Address, key: String) = {
address.getString(key).valueOrErrorMessage(
makeString(["mandatory ", address.toString(), ".", key, " is not defined"], "")
)
}

let keyFeeCollectorAddress = "%s__feeCollectorAddress"
let feeCollectorAddress = factoryContract.getStringOrFailFromAddress(keyFeeCollectorAddress).addressFromStringValue()
Expand Down Expand Up @@ -78,8 +82,8 @@ func getAccBalance(assetId: String) = {

# %d%d__poolFee__protocolFee
func getSwapFees(poolAddressStr: String) = {
let poolFeeDefault = this.getInteger(poolFee()).value()
let protocolFeeDefault = this.getInteger(protocolFee()).value()
let poolFeeDefault = factoryContract.getIntegerValue(poolFee())
let protocolFeeDefault = factoryContract.getIntegerValue(protocolFee())

match factoryContract.invoke("getSwapFeeREADONLY", [poolAddressStr], []) {
case fees: (Int, Int) => (fees._1, fees._2)
Expand Down
Loading