Factory
The Factory smart contract oversees the full functionality of token pair registration and transactions in KLAYswap. It is also a token contract for KLAYswap's KSP governance token that complies with the KIP7 standard, and a smart contract that implements all functions related to KSP mining.
Github Link: (Will be updated after official launch)
Events
Read-Only Functions
State-Changing Functions
event Transfer(address indexed from, address indexed to, uint amount);
- Event for the movement and burning of KSP tokens
event Approval(address indexed holder, address indexed spender, uint amount);
- Event for KSP token approval
event ChangeCreateFee(uint _createFee);
- An event to change the Pool Contract Creation Fee when adding a new liquidity pool pair
event ChangeTeamWallet(address _teamWallet);
- Event to change the development team wallet
event ClaimTeamAward(uint award, uint totalAward);
- Event to claim the development and stabilization commission
event ChangeNextOwner(address nextOwner);
- Event to pre-register new owner
- owner will be governance smart contract (In Intial period before KSP distributed, DEV team have owner permission)
event ChangeOwner(address owner);
- Event that completes changing the owner
event CreatePool(address tokenA, uint amountA, address tokenB, uint amountB, uint fee, address exchange, uint exid);
- Event to create new liquidity pool
- parameters
tokenA
: A token address in pairamountA
: A token amount in pooltokenB
: B token address in pairamountB
: B token amount in poolfee
: pool fee rateexchange
: exchange contract address of this poolexid
: exchange id
event ExchangePos(address tokenA, uint amountA, address tokenB, uint amountB);
- Positive exchange Event
- parameters
tokenA
: User input tokenA addressamountA
: User input tokenA amounttokenB
: User get tokenB addressamountB
: User get tokenB amount
event ExchangeNeg(address tokenA, uint amountA, address tokenB, uint amountB);
- Negative exchange Event
- parameters
tokenA
: User input tokenA addressamountA
: User input tokenA amounttokenB
: User get tokenB addressamountB
: User get tokenB amountB
- KlaySwap Protocol
- KSP
- 18
- 126144000000000000000000000 = 126144000 KSP
- There is only one case in which the total supply can be changed:
- A decrease due to fee payments for adding new liquidity pairs
- The amount of KSP held in each address
- Status of approval to spender for each address
- Governance Contract Address
- The next Governance Contract Address set in advance.
- The total mining amount
- This cannot be changed after a contract is deployed
- The block unit that proceeds with halving
- This cannot be changed after a contract is deployed
- The block number that starts mining
- The block number that makes KSP token transfers possible
- The ratio of the mined amount given to the developement team for the first two years.
- List of liquidity pool pairings
- Each item saves the smart contract address of the liquidity pool
- Returns if the contract for the given liquidiy pool pair exists
- The contract address corresponding to the tokenA, tokenB pair
- When the addresses of tokenA and tokenB are inputted, this returns the contract address of the corresponding pairing
- Returns the same contract address regardless of the order of the liquidity pool pairing tokens:tokenToPool[tokenA][tokenB] == tokenToPool[tokenB][tokenA]
- The amount of KSP that must be paired to create a new liquidity pool pair
- The address to which the development team can claim their reward
- The team reward amount that has already been claimed
function mined() public view returns (uint)
- Returns the KSP amount mined so far
- This amount includes the quantity already claimed and the quantity to be claimed
- The teamAward quantity is exempted from this amount
function estimatePos(address inToken, uint inAmount, address outToken) private view returns (uint)
- Returns the possible quantity received for a POS transaction.
- Parameters
inToken
: token address for paymentinAmount
: amount of tokens for paymentoutToken
: token address for receiving
estimateNeg
function estimateNeg(address inToken, address outToken, uint outAmount) private view returns (uint)
- Function to return the amount of tokens that need to be paid for a NEG transaction.
- Parameters
inToken
: token address for paymentoutToken
: token address for receivingoutAmount
: amount of tokens to receive
function getPoolCount() public view returns (uint)
- Returns the current number of registered liquidity pools.
function getPoolAddress(uint idx) public view returns (address)
- Returns the liquidity pair contract address of the pair's index.
function transfer(address _to, uint _value) public returns (bool)
- KIP7 Standard
- Method to transfer KSP tokens
function transferFrom(address _from, address _to, uint _value) public returns (bool)
- KIP7 Standard
- Method to transfer tokens on behalf of the approved wallet
function approve(address _spender, uint _value) public returns (bool)
- KIP7 Standard
- Method to approve a transfer as much as value to spender
function changeNextOwner(address _nextOwner) public
- Method to set the next Owner in advance before changing Owner
- only owner
function changeOwner() public
- Method for the next Owner to change the actual Owner
- only nextOwner
function changeCreateFee(uint _createFee) public
- Method that changes KSP fees when liquidity pairs are added
- only Owner
function changeTeamWallet(address _teamWallet) public
- Method to change the developer wallet
- only owner
function changePoolFee(address tokenA, address tokenB, uint fee) public
- Method to change transaction fees for each liquidity pair
- only owner
function changeMiningRate(address[] memory tokenA, address[] memory tokenB, uint[] memory rate) public
- Method to change the mining weight per liquidity pair
- All pairs for mining must be changed at once
- The rate of each pair is between 1 and 100
- The sum of rates for all pairs is 100
- only owner
- Parameters
tokenA
: list of addresses of the first token pairtokenB
: list of addresses of the second token pairrate
: list of mining rate for a pair
function claimTeamAward() public
- Method to claim the accrued quantity that the developer has
- only teamWallet
function createKlayPool(address token, uint amount, uint fee) public payable
- A method called to add a liquidity pair with one side as KLAY
- The wallet that calls this must have KSP greater than or equal to createFee
- Token for when the KLAY-KIP7 pair to be registered has never been registered before
- Parameters
token
: KIP7 token address to add liquidityamount
: the amount of tokens (KIP7) to be provided for the initial liquidityfee
: Sets the initial fee value for liquidity pairs- A value between 0 and 100
- Meaning: 0 -> 0%, 100 -> 1%
msg.value
: KLAY quantity to initially supply liquidity- Delivers the transaction value without specifying otherwise
function createKctPool(address tokenA, uint amountA, address tokenB, uint amountB, uint fee) public
- Method called to add liquidity pair in case of KIP7 token pair
- The wallet calling the KSP above createFee must have it.
- parameter
tokenA
: The address of the first tokenamountA
: The quantity of the first token that supplies the initial liquiditytokenB
: The address of the second tokenamountB
: The quantity of the second token that supplies the initial liquidityfee
: Sets the initial fee value for liquidity pairs
function exchangeKlayPos(address token, uint amount, address[] memory path) public payable
- Method to call when token to be paid is KLAY and a POS transaction is desired
- Parameters
token
: Address of the KIP7 to be recievedamount
: the minimum amount tokens that you want to receive- If the amount of tokens to be received is lower than this amount, the Tx will fail.
path
: list of token addresses to go through for routing transactions- If routing transaction is not needed, submit empty list
msg.value
: KLAY quantity to be paid
function exchangeKctPos(address tokenA, uint amountA, address tokenB, uint amountB, address[] memory path) public
- Method called when the token to be paid is KIP7 and a POS transaction is desired
- Parameters
tokenA
: address of token to be paidamountA
: the amount of tokens to be paidtokenB
: address of token to be received- When KLAY, it is 0x0
amountB
: the minimum amount of tokens that you want to receive- If the amount of tokens to be received is lower than this amount, the Tx will fail.
path
:list of token addresses to go through for routing transactions- If routing transaction is not needed, submit empty list
function exchangeKlayNeg(address token, uint amount, address[] memory path) public payable
- Method for executing a NEG transaction by paying KLAY
- Parameters
token
: address of tokens to be receivedamount
: quantity of tokens to be receivedpath
: list of token addresses to go through for routing transactions- If routing transaction is not needed, submit empty list
msg.value
: maximum amount of payable KLAY- If more KLAY than the corresponding quantity needs to be paid, theTx will fail
- the difference with KLAY used in the actual transaction is returned to msg.sender
function exchangeKctNeg(address tokenA, uint amountA, address tokenB, uint amountB, address[] memory path) public
- Method for executing NEG transaction by paying KIP7
- Parameters
tokenA
: address of token to be paidamountA
: the maximum amount of tokenA that can be paid- If more tokenA than the corresponding amount is needed, the Tx will fail.
tokenB
: address of the token to be received- For KLAY: 0x0
amountB
: the amount of tokens to be receivedpath
: list of token addresses to go through for routing transactions- If routing transaction is not needed, submit empty list
Last modified 7mo ago