-
-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
40 additions
and
0 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
blockchain_integration/pi_network/features/pi-coin-listing-and-liquidity/PiCoinListing.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
pragma solidity ^0.8.0; | ||
|
||
import "./ExchangeManager.sol"; | ||
import "./LiquidityProvider.sol"; | ||
|
||
contract PiCoinListing { | ||
using ExchangeManager for address; | ||
using LiquidityProvider for address; | ||
|
||
// Mapping of exchanges | ||
mapping (address => Exchange) public exchanges; | ||
|
||
// Struct to represent an exchange | ||
struct Exchange { | ||
address exchangeAddress; | ||
string exchangeName; | ||
bool listed; | ||
} | ||
|
||
// Event emitted when Pi Coin is listed on an exchange | ||
event PiCoinListed(address indexed exchangeAddress, string exchangeName); | ||
|
||
// Function to list Pi Coin on an exchange | ||
function listPiCoinOnExchange(address _exchangeAddress, string memory _exchangeName) public { | ||
Exchange storage exchange = exchanges[_exchangeAddress]; | ||
exchange.exchangeAddress = _exchangeAddress; | ||
exchange.exchangeName = _exchangeName; | ||
exchange.listed = true; | ||
emit PiCoinListed(_exchangeAddress, _exchangeName); | ||
} | ||
|
||
// Function to get the list of exchanges where Pi Coin is listed | ||
function getExchanges() public view returns (Exchange[] memory) { | ||
Exchange[] memory exchangeList = new Exchange[](exchanges.length); | ||
for (address exchangeAddress in exchanges) { | ||
exchangeList.push(exchanges[exchangeAddress]); | ||
} | ||
return exchangeList; | ||
} | ||
} |