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.

def addLiquidity(
    token_address: address, 
    erc20_token_amount: uint256, 
    deadline: timestamp
) -> bool

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

def removeLiquidity(
    token_address: address, 
    stableswap_token_amount: uint256, 
    erc20_min_output_amount: uint256, 
    deadline: timestamp
) -> bool

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

def swapTokens(
    input_token: address,
    output_token: address, 
    erc20_input_amount: uint256, 
    erc20_min_output_amount: uint256, 
    deadline: timestamp
) -> bool

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

@constant
def tokenExchangeRateAfterFees(
    input_token_address: address, 
    output_token_address: address
) -> uint256

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

@constant
def tokenOutputAmountAfterFees(
    input_token_amount: uint256, 
    input_token_address: address, 
    output_token_address: address
) -> uint256

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

@constant
def poolOwnership(user_address: address) -> decimal

Parameter

Type

Description

user_address

address

Address of a user

Returns

fixed168x10 (uint168)

Share of total liquidity belonging to the user

fees

@constant
def fees(fee_name: string[32]) -> decimal

Parameter

Type

Description

fee_name

string

'ownerFee' or 'tradeFee'

Returns

fixed168x10 (uint168)

Fee value (i.e. 0.001 means 0.1%)

inputTokens

inputTokens: public(map(address, bool))

Parameter

Type

Description

address

address

Address of ERC20 token

Returns

bool

True if an address is in the list of available input tokens

outputTokens

outputTokens: public(map(address, bool))

Parameter

Type

Description

address

address

Address of ERC20 token

Returns

bool

True if an address is in the list of available output tokens

priceOracleAddress

priceOracleAddress: public(address)

Returns

address

Address of a priceoracle contract

Last updated