Skip to content

Commit

Permalink
Merge pull request #8 from Inflow-Music-Co/FUSD_Support
Browse files Browse the repository at this point in the history
Fusd support
  • Loading branch information
0xmovses authored Mar 3, 2022
2 parents f2bebc2 + 642907a commit a885ea4
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 17 deletions.
Binary file added .DS_Store
Binary file not shown.
12 changes: 8 additions & 4 deletions contracts/Controller.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,20 @@ pub contract Controller {

// Paths
pub let AdminStoragePath: StoragePath
pub var SocialTokenResourceStoragePath: StoragePath
pub let SocialTokenResourceStoragePath: StoragePath

pub let SpecialCapabilityPrivatePath: PrivatePath
pub let SocialTokenResourcePrivatePath: PrivatePath

// A structure that contains all the data related to the Token
pub struct TokenStructure {
pub struct TokenStructure {
pub var tokenId: String
pub var symbol: String
pub var issuedSupply: UFix64
pub var maxSupply: UFix64
pub var artist: Address
pub var slope: UFix64
pub var feeSplitterDetail: {Address: FeeStructure}
access(contract) var feeSplitterDetail: {Address: FeeStructure}
pub var reserve: UFix64
pub var tokenResourceStoragePath: StoragePath
pub var tokenResourcePublicPath: PublicPath
Expand Down Expand Up @@ -73,7 +73,7 @@ pub struct TokenStructure {
emit incrementReserve(newReserve)
}

pub fun decrementReserve(_ newReserve: UFix64){
pub fun decrementReserve(_ newReserve: UFix64) {
pre {
newReserve != nil: "reserve must not be null"
newReserve > 0.0 : "reserve must be greater than zero"
Expand Down Expand Up @@ -104,6 +104,10 @@ pub struct TokenStructure {
}
self.feeSplitterDetail = feeSplitterDetail
}

pub fun getFeeSplitterDetail(): {Address: FeeStructure}{
return self.feeSplitterDetail
}
}

pub resource interface SpecialCapability {
Expand Down
12 changes: 8 additions & 4 deletions contracts/SocialToken.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub contract SocialToken: FungibleToken {
// a variable that store admin capability to utilize methods of controller contract
access(contract) let adminRef : Capability<&{Controller.SocialTokenResourcePublic}>
// a variable which will store the structure of FUSDPool
pub var collateralPool: FUSDPool
access(contract) var collateralPool: FUSDPool

pub resource interface SocialTokenPublic {
pub fun getTokenId(): String
Expand Down Expand Up @@ -146,9 +146,13 @@ pub contract SocialToken: FungibleToken {
access(contract) fun distributeFee(_ tokenId : String, _ fusdPayment: @FungibleToken.Vault): @FungibleToken.Vault {
let amount = fusdPayment.balance
let tokenDetails = Controller.getTokenDetails(tokenId)
for address in tokenDetails.feeSplitterDetail.keys {
let feeStructer = tokenDetails.feeSplitterDetail[address]
let tempAmmount = amount * feeStructer!.percentage
let detailData = tokenDetails.getFeeSplitterDetail()

assert(detailData.length < 10, message: "Maximum Limit Reached. Please update Fee Structure")
for address in detailData.keys {
let feeStructuredetail = tokenDetails.getFeeSplitterDetail()
let feeStructure = feeStructuredetail[address]
let tempAmmount = amount * feeStructure!.percentage
let tempraryVault <- fusdPayment.withdraw(amount:tempAmmount)
let account = getAccount(address)
let depositSigner= account.getCapability<&FUSD.Vault{FungibleToken.Receiver}>(/public/fusdReceiver)
Expand Down
3 changes: 3 additions & 0 deletions tasks/mint_2000_burn_1300_tokens/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ func main() {
//Register Token for a new account
flow.TransactionFromFile("register_token").SignProposeAndPayAs("account").StringArgument("TestSymbol").UFix64Argument("10000000.00").AccountArgument("first").RunPrintEventsFull()

//add setfeeSplitterDetail for given Token
flow.TransactionFromFile("setfeeSplitterDetail").SignProposeAndPayAs("account").StringArgument("TestSymbol_0x1cf0e2f2f715450").AccountArgument("first").RunPrintEventsFull()

//--------------------------------------------------//
//-- SETUP Admin and Add Capability of Controller --//
//--------------------------------------------------//
Expand Down
3 changes: 3 additions & 0 deletions tasks/mint_5000_burn_3500_tokens/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ func main() {
//Register Token for a new account
flow.TransactionFromFile("register_token").SignProposeAndPayAs("account").StringArgument("TestSymbol").UFix64Argument("10000000.00").AccountArgument("first").RunPrintEventsFull()

//add setfeeSplitterDetail for given Token
flow.TransactionFromFile("setfeeSplitterDetail").SignProposeAndPayAs("account").StringArgument("TestSymbol_0x1cf0e2f2f715450").AccountArgument("first").RunPrintEventsFull()

//--------------------------------------------------//
//-- SETUP Admin and Add Capability of Controller --//
//--------------------------------------------------//
Expand Down
15 changes: 7 additions & 8 deletions tasks/mint_burn_instant/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,16 @@ func main() {
// First Account Mints and deposits in one transaction
flow.TransactionFromFile("mint_fusd").SignProposeAndPayAs("first").UFix64Argument("2500000000.00").AccountArgument("second").RunPrintEventsFull()


//-------------------------------------------------//
//--------- Register Account -----------//
//-------------------------------------------------//

//Register Token for a new account
flow.TransactionFromFile("register_token").SignProposeAndPayAs("account").StringArgument("TestSymbol").UFix64Argument("10000000.00").AccountArgument("first").RunPrintEventsFull()
//add setfeeSplitterDetail for given Token

//add setfeeSplitterDetail for given Token
flow.TransactionFromFile("setfeeSplitterDetail").SignProposeAndPayAs("account").StringArgument("TestSymbol_0x1cf0e2f2f715450").AccountArgument("first").RunPrintEventsFull()

//--------------------------------------------------//
//-- SETUP Admin and Add Capability of Controller --//
//--------------------------------------------------//
Expand All @@ -64,11 +63,11 @@ func main() {

mintQuote := flow.ScriptFromFile("get_social_mint_quote").UFix64Argument("10000000.00").StringArgument("TestSymbol_0x1cf0e2f2f715450").RunFailOnError()
log.Printf(" ------ Social Mint Quote ----- %s", mintQuote)

//Log balance
fusdFirstAccountBalance := flow.ScriptFromFile("get_fusd_balance").AccountArgument("second").RunFailOnError()
log.Printf("FUSD balance of account 'first account' %s", fusdFirstAccountBalance)

// mint social Tokens
flow.TransactionFromFile("mint_social_token").SignProposeAndPayAs("second").StringArgument("TestSymbol_0x1cf0e2f2f715450").UFix64Argument("10000000.00").UFix64Argument(mintQuote.String()).RunPrintEventsFull()

Expand All @@ -94,11 +93,11 @@ func main() {

// burn social Tokens
flow.TransactionFromFile("burn_social_token").SignProposeAndPayAs("second").StringArgument("TestSymbol_0x1cf0e2f2f715450").UFix64Argument("10000000.00000000").RunPrintEventsFull()

//reserve before burning social tokens
reserve = flow.ScriptFromFile("get_reserve").StringArgument("TestSymbol_0x1cf0e2f2f715450").RunFailOnError()
log.Printf(" ------ reserve after buring social tokens----- %s", reserve)

// Get the balance of all accounts
ArtistAccountBalanceFUSD := flow.ScriptFromFile("get_fusd_balance").AccountArgument("second").RunFailOnError()
log.Printf(" ------ User FUSD Balance after burning ----- %s", ArtistAccountBalanceFUSD)
Expand Down
2 changes: 1 addition & 1 deletion transactions/register_token_Inflow.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ transaction (symbol: String, maxSupply: UFix64, artistAddress: Address){
let socialMinterPublicPath = /public/InflowSymbol_0x5Minter
let socialBurnerStoragePath = /storage/InflowSymbol_0x5Burner
let socialBurnerPublicPath = /public/InflowSymbol_0x5Burner
adminResource.registerToken(symbol, maxSupply, feeSplitterDetail, artistAddress,
adminResource.registerToken(symbol, maxSupply, artistAddress,
tokenStoragePath, tokenPublicPath,
socialMinterStoragePath, socialMinterPublicPath,
socialBurnerStoragePath, socialBurnerPublicPath
Expand Down

0 comments on commit a885ea4

Please sign in to comment.