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 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
10 changes: 5 additions & 5 deletions Overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ addons - .find leases can support add ons to the name itself.

// depositWithTagAndMessage sends fund from sender to user with / without profile and emit very good events
// for users with profile, it supports as much FT as they've set up wallets in profile
// for users without profile, we support flow and FUSD at the moment but it can be extended pretty easily
// for users without profile, we support flow at the moment but it can be extended pretty easily
access(all) fun depositWithTagAndMessage(to:String, message:String, tag: String, vault: @FungibleToken.Vault, from: &Sender.Token)
```

Expand Down Expand Up @@ -179,9 +179,9 @@ transaction(
// This is the find name to be purchased
name: String,
// Amount needed :
// 3 characters : 500 FUSD,
// 4 characters : 100 FUSD,
// 5 characters or above : 5 FUSD
// 3 characters : 500 USD,
// 4 characters : 100 USD,
// 5 characters or above : 5 USD
amount: UFix64
)

Expand Down Expand Up @@ -376,7 +376,7 @@ access(all) struct AccountInformation {
## FungibleToken

FungibleTokens are exposed under Find Profile contracts.
As soon as a user adds his/her wallet to Profile, it can be viewable in Profile report. By default we always add FUSD / USDC / Flow token for non-Dapper Users if they initiate their account on .find page.
As soon as a user adds his/her wallet to Profile, it can be viewable in Profile report.

## NonFungibleToken

Expand Down
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
4 changes: 0 additions & 4 deletions contracts/Profile.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -524,10 +524,6 @@ access(all) contract Profile {
var ref : &{FungibleToken.Receiver}? = nil
if FindUtils.contains(identifier, element: "FlowToken.Vault") {
ref = self.owner!.capabilities.borrow<&{FungibleToken.Receiver}>(/public/flowTokenReceiver)
} else if FindUtils.contains(identifier, element: "FiatToken.Vault") {
ref = self.owner!.capabilities.borrow<&{FungibleToken.Receiver}>(/public/USDCVaultReceiver)
} else if FindUtils.contains(identifier, element: "FUSD.Vault") {
ref = self.owner!.capabilities.borrow<&{FungibleToken.Receiver}>(/public/fusdReceiver)
} else if FindUtils.contains(identifier, element: "FlowUtilityToken.Vault") {
ref = self.owner!.capabilities.borrow<&{FungibleToken.Receiver}>(/public/flowUtilityTokenReceiver)
} else if FindUtils.contains(identifier, element: "DapperUtilityCoin.Vault") {
Expand Down
Loading
Loading