Skip to main content

Example OYL SDK calls

This page provides some examples of OYL SDK calls to interact with the AMM contracts.

Create Pools

oyl alkane create-pool -data 4,65522,1,2,201,2,200,1000,2000 -tokens "2:201:1000,2:200:2000" -p signet -feeRate 3

This creates a pool, assuming the factory proxy is deployed at id 4,65522, with the liquidity pair being alkanes 2,201 and 2,200, and inputs 1000 alks of token 2,201 and 2000 alks of token 2,200.

Add Liquidity

oyl alkane add-liquidity -data 4,65522,11,2,201,2,200,1000,2000,100,200,950000 -tokens "2:201:1000,2:200:2000" -p signet -feeRate 3

This adds liquidity to a pool, assuming the factory proxy is deployed at id 4,65522, with the liquidity pair being alkanes 2,201 and 2,200, and inputs 1000 alks of token 2,201 and 2000 alks of token 2,200, and with a minimum usage of 100 alks of token 2,201 and 200 alks of token 2,200. The transaction will expire after block height 950000.

Remove Liquidity

oyl alkane remove-liquidity -data 4,65522,11,2,201,2,200,1000,100,200,950000  -tokens "2:300:1000" -p signet -feeRate 3

This removes liquidity from a pool, assuming the factory proxy is deployed at id 4,65522, and the pool for 2,201 and 2,200 is deployed at 2,300. It will attempt to liquidate 1000 alks of the LP token. The minimum received back is 100 alks of token 2,201 and 200 alks of token 2,200. The transaction will expire after block height 950000.

Swap Exact Tokens for Tokens

oyl alkane swap -data 4,65522,13,2,2,201,2,200,500,450,950000 -tokens "2:201:500" -p signet -feeRate 3

This swaps an exact amount of input tokens for a minimum amount of output tokens. It assumes the factory proxy is deployed at id 4,65522. It will swap 500 alks of token 2,201 for at least 450 alks of token 2,200. The transaction will expire after block height 950000.

Swap Tokens for Exact Tokens

oyl alkane swap -data 4,65522,14,2,2,201,2,200,500,550,950000 -tokens "2:201:550" -p signet -feeRate 3

This swaps a variable amount of input tokens for an exact amount of output tokens. It assumes the factory proxy is deployed at id 4,65522. It will swap a maximum of 550 alks of token 2,201 to get exactly 500 alks of token 2,200. The transaction will expire after block height 950000.