Skip to content
Merged
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
21 changes: 3 additions & 18 deletions cadence/tests/test_helpers.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -692,35 +692,20 @@ fun equalAmounts(a: UFix64, b: UFix64, tolerance: UFix64): Bool {
return b - a <= tolerance
}

/// Sets a single BandOracle price
///
access(all)
fun setBandOraclePrice(signer: Test.TestAccount, symbol: String, price: UFix64) {
// BandOracle uses 1e9 multiplier for prices
// e.g., $1.00 = 1_000_000_000, $0.50 = 500_000_000
let priceAsUInt64 = UInt64(price * 1_000_000_000.0)
let symbolsRates: {String: UInt64} = { symbol: priceAsUInt64 }

let setRes = _executeTransaction(
"../../lib/FlowCreditMarket/FlowActions/cadence/tests/transactions/band-oracle/update_data.cdc",
[ symbolsRates ],
signer
)
Test.expect(setRes, Test.beSucceeded())
}

/// Sets multiple BandOracle prices at once
///
access(all)
fun setBandOraclePrices(signer: Test.TestAccount, symbolPrices: {String: UFix64}) {
let symbolsRates: {String: UInt64} = {}
for symbol in symbolPrices.keys {
// BandOracle uses 1e9 multiplier for prices
// e.g., $1.00 = 1_000_000_000, $0.50 = 500_000_000
let price = symbolPrices[symbol]!
symbolsRates[symbol] = UInt64(price * 1_000_000_000.0)
}

let setRes = _executeTransaction(
"../../lib/FlowCreditMarket/FlowActions/cadence/tests/transactions/band-oracle/update_data.cdc",
"../../lib/FlowALP/FlowActions/cadence/tests/transactions/band-oracle/update_data.cdc",
[ symbolsRates ],
signer
)
Expand Down