Skip to content
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

fix find market #411

Merged
merged 6 commits into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
17 changes: 16 additions & 1 deletion contracts/FIND.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import "Sender"
import "ProfileCache"
import "FindUtils"
import "PublicPriceOracle"
import "BandOracle"

/*
///FIND
Expand Down Expand Up @@ -58,7 +59,7 @@ access(all) contract FIND {
//////////////////////////////////////////
// Get the latest FLOW/USD price
//This uses the FLOW/USD increment.fi oracle
access(all) fun getLatestPrice(): UFix64 {
access(all) fun getLatestPriceOld(): UFix64 {
let lastResult = PublicPriceOracle.getLatestPrice(oracleAddr: self.getFlowUSDOracleAddress())
let lastBlockNum = PublicPriceOracle.getLatestBlockHeight(oracleAddr: self.getFlowUSDOracleAddress())

Expand All @@ -70,6 +71,20 @@ access(all) contract FIND {
return lastResult
}

//this uses band oracle
access(all) fun getLatestPrice(): UFix64 {

let acct = FIND.account
let vaultRef = acct.storage.borrow<auth(FungibleToken.Withdraw) &FlowToken.Vault>(from: /storage/flowTokenVault) ?? panic("Cannot borrow reference to signer's FLOW vault")
let payment <- vaultRef.withdraw(amount: BandOracle.getFee())
let baseSymbol="FLOW"
let quoteSymbol="USDC"
let quote =BandOracle.getReferenceData (baseSymbol: baseSymbol, quoteSymbol: quoteSymbol, payment: <- payment)

return quote.fixedPointRate
}



access(all) fun convertFLOWToUSD(_ amount: UFix64): UFix64 {
return amount * self.getLatestPrice()
Expand Down
9 changes: 8 additions & 1 deletion contracts/FindViews.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,14 @@ access(all) contract FindViews {
return false
}

let nft= self.cap.borrow()!.borrowNFT(self.id)
let collection = self.cap.borrow()!

let collectionType=collection.getType()
if collectionType.isRecovered {
return false
}

let nft= collection.borrowNFT(self.id)

if nft ==nil {
return false
Expand Down
7 changes: 7 additions & 0 deletions flow.json
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,13 @@
"migrationnet": "0x8232ce4a3aff4e94"
}
},
"BandOracle": {
"source": "./contracts/community/BandOracle.cdc",
"aliases": {
"mainnet": "0x6801a6222ebf784a",
"testnet": "0x2c71de7af78d1adf"
}
},
"ExampleNFT": "./contracts/standard/ExampleNFT.cdc",
"ProfileCache": "./contracts/ProfileCache.cdc",
"FIND": "./contracts/FIND.cdc",
Expand Down
5 changes: 5 additions & 0 deletions scripts/getNamePriceInFlow.cdc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import "FIND"

access(all) fun main(_ name:String):UFix64 {
return FIND.calculateCostInFlow(name)
}