Created
October 22, 2024 00:33
-
-
Save sodiray/36e1ed85f705d27ece1b754e1e776d31 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // As needed, add imports | |
| export const createGMXClient = () => { | |
| // As needed, create shared resources or | |
| // shared functions | |
| // _placeDeposit = async () => { ... } | |
| /** | |
| * When called, the function should place an order, using the given | |
| * arguments, with the GMX V2 contract and return an identifier for | |
| * the order. | |
| * | |
| * @note using https://gmx-docs.io/docs/api/contracts-v2#creating-an-order | |
| * | |
| * @returns an order object that just has an id | |
| */ | |
| const placeOrder = async (order: { | |
| stopLoss: number | |
| takeProfit: number | |
| size: number | |
| entry: 'market' | number | |
| leverage: number | |
| position: 'short' | 'long' | |
| token: 'SOL' | 'ETH' | 'BTC' | |
| }) => { | |
| // TODO: Place order with GMX contract onchain | |
| return { | |
| order: { | |
| id: 'TODO' | |
| } | |
| } | |
| } | |
| /** | |
| * When called, the function should get a list of all the currently | |
| * open positions fro the GMX V2 contract and return them. | |
| * | |
| * @returns a list of positions | |
| */ | |
| const listPositions = async () => { | |
| // TODO: List orders from GMX contract onchain | |
| return { | |
| positions: [] // TODO | |
| } | |
| } | |
| /** | |
| * When called, the function should close out a position that's currenlty | |
| * open. | |
| * | |
| * @note using https://gmx-docs.io/docs/api/contracts-v2#creating-an-order | |
| */ | |
| const exitPosition = async (args: { | |
| amountToClose: number | |
| token: 'SOL' | 'ETH' | 'BTC' | |
| }) => { | |
| // TODO: Exit position with GMX contract onchain | |
| } | |
| return { | |
| placeOrder, | |
| listPositions, | |
| exitPosition | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment