Stablecoinswap API
Contract is written in Vyper (0.1.0b9)

Adding liquidity is free. However, removing liquidity bears the same fee as the swap operation. This is to prevent users from bypassing the trading fee by depositing liquidity in one token and instantly withdrawing it in another token.
Smart Contract
Web3
def addLiquidity(
token_address: address,
erc20_token_amount: uint256,
deadline: timestamp
) -> bool
contract.methods.addLiquidity(token_address, amount, deadline).send({ from: user_address }, callback)
Parameter
Type
Description
token_address
address
Address of ERC20 token to add
erc20_token_amount
uint256
How many ERC20 tokens to add
deadline
uint256
Transaction deadline
Returns
uint256
The amount of STL tokens received by the sender.

Smart Contract
Web3
def removeLiquidity(
token_address: address,
stableswap_token_amount: uint256,
erc20_min_output_amount: uint256,
deadline: timestamp
) -> bool
contract.methods.removeLiquidity(token_address, amount, min_output_amount, deadline).send({ from: user_address }, callback)
Parameter
Type
Description
token_address
address
Address of ERC20 token to remove
stableswap_token_amount
uint256
Amount of STL tokens to redeem
erc20_min_output_amount
uint256
Minimum ERC20 tokens output amount
deadline
uint256
Transaction deadline
Returns
uint256
The amount of erc20 tokens received by the sender.

Smart Contract
Web3
def swapTokens(
input_token: address,
output_token: address,
erc20_input_amount: uint256,
erc20_min_output_amount: uint256,
deadline: timestamp
) -> bool
contract.methods.swapTokens(input_token_address, output_token_address, input_amount, min_output_amount, deadline).send({ from: this.currentAddress() }, callback)
Parameter
Type
Description
input_token
address
Address of input ERC20 token
output_token
address
Address of output ERC20 token
erc20_input_amount
uint256
Amount of ERC20 input tokens sold
erc20_min_output_amount
uint256
Minimum ERC20 output tokens to buy
deadline
uint256
Transaction deadline
Returns
uint256
The amount of erc20 tokens received by the sender.

Smart Contract
Web3
@constant
def tokenExchangeRateAfterFees(
input_token_address: address,
output_token_address: address
) -> uint256
contract.methods.tokenExchangeRateAfterFees(input_token_address, output_token_address).call()
Parameter
Type
Description
input_token_address
address
Address of ERC20 token to sell
output_token_address
address
Address of ERC20 token to buy
Returns
uint265
Exchange rate multiplied by 10^22.
Note that due to rounding, the fees could be slightly higher for the tokens with smaller decimal precision and/or if the exchange amount is too low.

Smart Contract
Web3
@constant
def tokenOutputAmountAfterFees(
input_token_amount: uint256,
input_token_address: address,
output_token_address: address
) -> uint256
contract.methods.tokenOutputAmountAfterFees(amount, input_token_address, output_token_address).call()
Parameter
Type
Description
input_token_amount
uint256
Amount of ERC20 token to sell
input_token_address
address
Address of ERC20 token to sell
output_token_address
address
Address of ERC20 token to buy
Returns
uint256
How many tokens can be bought for a given amount of input tokens

Smart Contract
Web3
@constant
def poolOwnership(user_address: address) -> decimal
contract.methods.poolOwnership(address).call()
Parameter
Type
Description
user_address
address
Address of a user
Returns
fixed168x10 (uint168)
Share of total liquidity belonging to the user

Smart Contract
Web3
@constant
def fees(fee_name: string[32]) -> decimal
contract.methods.fees(fee_name).call()
Parameter
Type
Description
fee_name
string
'ownerFee' or 'tradeFee'
Returns
fixed168x10 (uint168)
Fee value (i.e. 0.001 means 0.1%)

Smart Contract
Web3
inputTokens: public(map(address, bool))
contract.methods.inputTokens(address).call()
Parameter
Type
Description
address
address
Address of ERC20 token
Returns
bool
True if an address is in the list of available input tokens

Smart Contract
Web3
outputTokens: public(map(address, bool))
contract.methods.outputTokens(address).call()
Parameter
Type
Description
address
address
Address of ERC20 token
Returns
bool
True if an address is in the list of available output tokens

Smart Contract
Web3
priceOracleAddress: public(address)
contract.methods.priceOracleAddress().call()
Returns
address
Address of a priceoracle contract
Copy link
On this page
addLiquidity
removeLiquidity
swapTokens
tokenExchangeRateAfterFees
tokenOutputAmountAfterFees
poolOwnership
fees
inputTokens
outputTokens
priceOracleAddress