Stablecoinswap API
Contract is written in Vyper (0.1.0b9)

addLiquidity

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
1
def addLiquidity(
2
token_address: address,
3
erc20_token_amount: uint256,
4
deadline: timestamp
5
) -> bool
Copied!
1
contract.methods.addLiquidity(token_address, amount, deadline).send({ from: user_address }, callback)
Copied!
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.

removeLiquidity

Smart Contract
Web3
1
def removeLiquidity(
2
token_address: address,
3
stableswap_token_amount: uint256,
4
erc20_min_output_amount: uint256,
5
deadline: timestamp
6
) -> bool
Copied!
1
contract.methods.removeLiquidity(token_address, amount, min_output_amount, deadline).send({ from: user_address }, callback)
Copied!
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.

swapTokens

Smart Contract
Web3
1
def swapTokens(
2
input_token: address,
3
output_token: address,
4
erc20_input_amount: uint256,
5
erc20_min_output_amount: uint256,
6
deadline: timestamp
7
) -> bool
Copied!
1
contract.methods.swapTokens(input_token_address, output_token_address, input_amount, min_output_amount, deadline).send({ from: this.currentAddress() }, callback)
Copied!
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.

tokenExchangeRateAfterFees

Smart Contract
Web3
1
@constant
2
def tokenExchangeRateAfterFees(
3
input_token_address: address,
4
output_token_address: address
5
) -> uint256
Copied!
1
contract.methods.tokenExchangeRateAfterFees(input_token_address, output_token_address).call()
Copied!
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.

tokenOutputAmountAfterFees

Smart Contract
Web3
1
@constant
2
def tokenOutputAmountAfterFees(
3
input_token_amount: uint256,
4
input_token_address: address,
5
output_token_address: address
6
) -> uint256
Copied!
1
contract.methods.tokenOutputAmountAfterFees(amount, input_token_address, output_token_address).call()
Copied!
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

poolOwnership

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

fees

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

inputTokens

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

outputTokens

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

priceOracleAddress

Smart Contract
Web3
1
priceOracleAddress: public(address)
Copied!
1
contract.methods.priceOracleAddress().call()
Copied!
Returns
address
Address of a priceoracle contract
Last modified 2yr ago