Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding examples #4

Merged
merged 10 commits into from
Sep 12, 2023
Merged

adding examples #4

merged 10 commits into from
Sep 12, 2023

Conversation

ibadia
Copy link
Contributor

@ibadia ibadia commented Sep 12, 2023

No description provided.

@ibadia ibadia requested a review from a team September 12, 2023 11:24
import {
ORDER_STATUS,
ORDER_SIDE,
// MinifiedCandleStick,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// MinifiedCandleStick,

true,
Networks.TESTNET_SUI,
dummyAccountKey,
"ED25519"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"ED25519"
"ED25519" // valid values ED25519 and Secp256k1

@@ -0,0 +1,50 @@
/**
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This whole example is redundant, already covered in post_cancel_order.ts so can be deleted

import {
ORDER_STATUS,
ORDER_SIDE,
// MinifiedCandleStick,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// MinifiedCandleStick,

examples/8.post_order.ts Outdated Show resolved Hide resolved
examples/8.post_order.ts Outdated Show resolved Hide resolved
console.log("Signed Order Created:", signedOrder);
}

main().then().catch(console.warn);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
main().then().catch(console.warn);
main().then().catch(console.error);

@@ -0,0 +1,23 @@
/**
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not think we need to put any example for showing user how to query your usdc balance from usdc contract

@@ -0,0 +1,29 @@
/**
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Users wont be able to mint usdc on our contracts anyways, so example should be removed

@@ -0,0 +1,25 @@
/**
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please merge this example with 1.initialisation example
in that show both ways of creating a client i.e. write mode and read mode

@@ -0,0 +1,37 @@
/**
* Gets user open position on provided(all) markets
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Gets user open position on provided(all) markets
* Query user orders

import {
ORDER_STATUS,
ORDER_SIDE,
// MinifiedCandleStick,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// MinifiedCandleStick,

);
}

main().then().catch(console.warn);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
main().then().catch(console.warn);
main().then().catch(console.error);

await client.init();
console.log(await client.getPublicAddress());

// deposits 10 USDC to margin bank, uses default USDC/MarginBank Contracts
Copy link
Contributor

@yasir7ca yasir7ca Sep 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// deposits 10 USDC to margin bank, uses default USDC/MarginBank Contracts
// deposits 1000 USDC to Bluefin margin bank

@@ -0,0 +1,31 @@
/**
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these three examples can be merged into one

  • deposit usdc to margin bank
  • query usdc balance from margin bank
  • withdraw usdc from margin bank

@@ -0,0 +1,44 @@
/**
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment out of place

import {
ORDER_STATUS,
ORDER_SIDE,
// MinifiedCandleStick,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// MinifiedCandleStick,

); //passing isTermAccepted = true for compliance and authorizarion
await client.init();
// ADD margin - will add 10 margin to ETH-PERP position
console.log(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This example wont work, to adjust margin we have to have an open position. Either we mention in the comment that user has open position then can run the add/remove margin as follows

"ED25519"
); //passing isTermAccepted = true for compliance and authorizarion
await client.init();
let symbol = "ETH-PERP";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the purpose of example use different markets for both orders. Place on order on ETH-PERP and other on BTC-PERP

leverage: 3,
});

// posts order for cancellation on exchange
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// posts order for cancellation on exchange
// cancel order by posted order hash

console.log(cancellationResponse.data);
}

main().then().catch(console.warn);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
main().then().catch(console.warn);
main().then().catch(console.error);

); //passing isTermAccepted = true for compliance and authorizarion
await client.init();

// will use margin bank contract from contractAddresses (initialized above)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// will use margin bank contract from contractAddresses (initialized above)

);
}

main().then().catch(console.warn);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
main().then().catch(console.warn);
main().then().catch(console.error);

"USDC Deposited to MarginBank: ",
await client.depositToMarginBank(10)
);
console.log(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a get call in between deposit and withdraw to query margin bank balance

@ibadia ibadia merged commit 413e085 into main Sep 12, 2023
3 checks passed
@ibadia ibadia deleted the examples branch September 12, 2023 13:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants