OneClick Contracts
OneClick Contracts zaps multiple actions into one transaction. You can use this function to enhance your user experience with Sharwa.
provideETH
provideETH
Use this function when you need to provide ETH to a margin account.
Wrap ETH to WETH
Deposit WETH to a margin account
Example on TS:
await OneClickMarginTrading.provideETH(
1, //margin account id
{value: parseEther("0.001")} // ETH amount
)
borrowSwap
borrowSwap
Use this function when you need to open Long or Short position in one transaction.
Borrow Token "A"
Swap token "A" for token "B"
For example, borrow ETH
and sell it for USDC
to open a Short position on ETH
within one transaction.
Example on TS:
await OneClickMarginTrading.borrowSwap(
1, //margin account iD
await USDC.getAddress() // token address to sell
await WETH.getAddress(), // token address to buy
parseUnits("3", await USDC.decimals()), // token amount to sell
0 // minumum token to receive (slippage control)
)
swapRepay
swapRepay
Use this function when you want to close a position and repay the debt in one transaction.
Swap token "A" for token "B"
Repay the debt for token "B"
Example: Borrow USDC and swap it for ETH. Then fix the profits by selling ETH for USDC and repaying the debt in one transaction.
await OneClickMarginTrading.swapRepay(
1, // margin account ID
await WETH.getAddress(), // token address to sell
await USDC.getAddress(), // token address to buy
parseUnits("3", await USDC.decimals()), // token amount to sell
0 // min. token to receive (slippage control)
)
withdrawProvideERC721
withdrawProvideERC721
Use this function when you want to purchase an option on Hegic using collateral from your margin account
Withdraw token "A" from a margin account
Swap token "A" for USDC.e
Purchase an option on Hegic
Deposit Hegic Option (ERC-721) to the margin account
Example: purchase an option position using collateral from the margin account.
await OneClickMarginTrading.withdrawBuyProvideERC721(
1, // margin account id
await USDC.getAddress(), // token address to pay
HegicStrategy_CALL_100_ETH_1, // address of hegic strategy
parseUnits("0.00001", 18), // amount of options to buy
MaxUint256, // ma
60*60*24*7, //option period in seconds
[] // additional parameters for a strategy
)
transferBuyProvideERC721
transferBuyProvideERC721
Use this function when you want to purchase an option on Hegic using funds from your wallet and deposit the purchased option to the margin account.
Swaps token "A" from the user's wallet (works only with WETH, WBTC and USDC)
Swaps token "A" for USDC.e
Purchase an option on Hegic
Provide Hegic Option (ERC-721) to a margin account
Example: purchase an option option position to hedge your margin account using funds from your wallet.
await OneClickMarginTrading.transferBuyProvideERC721(
1, //margin account id
await USDC.getAddress(), // token address which is used as a payment
HegicStrategy_CALL_100_ETH_1, //address of a hegic strategy
parseUnits("0.00001", 18), //amount of options
MaxUint256, //maximum premium that you'll be charged in USDC.e (slippage)
60*60*24*7, //option period in seconds
[] //additional parameters for a strategy
)
Last updated