Skip to content
This repository has been archived by the owner on Dec 29, 2023. It is now read-only.

Commit

Permalink
docs: docs and js script update
Browse files Browse the repository at this point in the history
  • Loading branch information
politeWall committed Dec 21, 2023
1 parent 56c4fcd commit 94569cb
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 60 deletions.
118 changes: 58 additions & 60 deletions front_end_script/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -397,29 +397,20 @@ stake_request(
stake_request(
3000000,
"uelys",
"elysvaloper17wc3s7am5qgjk4pm0k96kg6laxq8hkyq0dzq5n",
"elysvaloper17wc3s7am5qgjk4pm0k96kg6laxq8hkyq0dzq5n"
);
```
```js
stake_request(
3000000,
"ueden",
);
stake_request(3000000, "ueden");
```
```js
stake_request(
3000000,
"uedenb",
);
stake_request(3000000, "uedenb");
```
```js
stake_request(
3000000,
"uusdc",
);
stake_request(3000000, "uusdc");
```
### 15. unstakeRequest (amount, asset, validator_address?)
Expand Down Expand Up @@ -448,29 +439,20 @@ unstake_request(
unstake_request(
3000000,
"uelys",
"elysvaloper17wc3s7am5qgjk4pm0k96kg6laxq8hkyq0dzq5n",
"elysvaloper17wc3s7am5qgjk4pm0k96kg6laxq8hkyq0dzq5n"
);
```
```js
unstake_request(
3000000,
"ueden",
);
unstake_request(3000000, "ueden");
```
```js
unstake_request(
3000000,
"uedenb",
);
unstake_request(3000000, "uedenb");
```
```js
unstake_request(
3000000,
"uusdc",
);
unstake_request(3000000, "uusdc");
```
### 16. elysRedelegationRequest (validator_src_address, validator_dst_address, amount)
Expand All @@ -489,7 +471,7 @@ you can use this function to re-delegate token.
elys_redelegation_request(
"validator_src_address",
"validator_dst_address",
"amount",
"amount"
);
```
Expand All @@ -499,7 +481,7 @@ elys_redelegation_request(
elys_redelegation_request(
"elysvaloper12tzylat4udvjj56uuhu3vj2n4vgp7cf9pwcqcs",
"elysvaloper17wc3s7am5qgjk4pm0k96kg6laxq8hkyq0dzq5n",
{ denom: "uelys", amount: "20000" },
{ denom: "uelys", amount: "20000" }
);
```
Expand All @@ -516,11 +498,7 @@ you can use this function to cancel unbonding.
#### Usage
```js
elys_cancel_unstake_request(
"validator_address",
"amount",
"creation_height",
);
elys_cancel_unstake_request("validator_address", "amount", "creation_height");
```
#### Example
Expand All @@ -529,7 +507,7 @@ elys_cancel_unstake_request(
elys_cancel_unstake_request(
"elysvaloper12tzylat4udvjj56uuhu3vj2n4vgp7cf9pwcqcs",
{ denom: "uelys", amount: "20000" },
100000,
100000
);
```
Expand All @@ -544,17 +522,13 @@ you can use this function to vest eden token
#### Usage
```js
eden_vest_request(
"amount",
);
eden_vest_request("amount");
```
#### Example
```js
eden_vest_request(
{ denom: "uelys", amount: "20000" },
);
eden_vest_request({ denom: "uelys", amount: "20000" });
```
### 19. edenCancelVestRequest (amount)
Expand All @@ -568,17 +542,13 @@ you can use this function to cancel vesting of eden.
#### Usage
```js
eden_cancel_vest_request(
"amount",
);
eden_cancel_vest_request("amount");
```
#### Example
```js
eden_cancel_vest_request(
{ denom: "uelys", amount: "20000" },
);
eden_cancel_vest_request({ denom: "uelys", amount: "20000" });
```
### 20. claimRewardsRequest (amount)
Expand All @@ -592,20 +562,19 @@ you can use this function to claim rewards.
#### Usage
```js
claim_rewards_request(
"withdraw_type",
);
claim_rewards_request("withdraw_type");
```
#### Example
```js
claim_rewards_request(
1, // Earntype_UsdcProgram
1 // Earntype_UsdcProgram
);
```
#### Enum types
```
pub enum EarnType {
AllProgram = 0,
Expand All @@ -627,16 +596,14 @@ you can use this function to claim validator's commission.
#### Usage
```js
claim_validator_commission_request(
"validator_address",
);
claim_validator_commission_request("validator_address");
```
#### Example
```js
claim_validator_commission_request(
"elysvaloper12tzylat4udvjj56uuhu3vj2n4vgp7cf9pwcqcs",
"elysvaloper12tzylat4udvjj56uuhu3vj2n4vgp7cf9pwcqcs"
);
```
Expand All @@ -658,7 +625,7 @@ amm_join_pool_request(
"pool_id",
"max_amounts_in",
"share_amount_out",
"no_remaining",
"no_remaining"
);
```
Expand All @@ -667,9 +634,12 @@ amm_join_pool_request(
```js
amm_join_pool_request(
1,
[{denom: "uelys", amount: "20000"}, {denom: "usdc", amount: "10000"}],
[
{ denom: "uelys", amount: "20000" },
{ denom: "usdc", amount: "10000" },
],
10000,
true,
true
);
```
Expand All @@ -691,7 +661,7 @@ amm_exit_pool_request(
"pool_id",
"min_amounts_out",
"share_amount_in",
"token_out_denom",
"token_out_denom"
);
```
Expand All @@ -700,9 +670,12 @@ amm_exit_pool_request(
```js
amm_exit_pool_request(
1,
[{denom: "uelys", amount: "20000"}, {denom: "usdc", amount: "10000"}],
[
{ denom: "uelys", amount: "20000" },
{ denom: "usdc", amount: "10000" },
],
10000,
"uelys",
"uelys"
);
```
Expand Down Expand Up @@ -753,6 +726,31 @@ get_liquidity_pools(
"{"offset":0, "limit":10, "count_total": false, "reverse": false}}}",
);
```
### 24. marginGetPositionsForAddress(address, pagination)
Query margin position using address
- `address` (String) addres of the user
- `pagination` (PageRequest)
#### Usage.
```js
marginGetPositionsForAddress("address", "pagination");
```
#### Exemple
```js
marginGetPositionsForAddress("elys1x5fehwug2vtkyn4vpunwkfn9zxkpxl8jg0lwuu", {
offset: 0,
limit: 10,
count_total: false,
reverse: true,
});
```
## Configuration
Before using these functions, you need to configure the following parameters in the script:
Expand Down
21 changes: 21 additions & 0 deletions front_end_script/upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -381,3 +381,24 @@ async function marginOpenEstimation(
);
console.log(`Result: `, result);
}

async function marginGetPositionsForAddress(address, pagination) {
const sender_wallet = await DirectSecp256k1HdWallet.fromMnemonic(
sender.mnemonic,
{ prefix: "elys" }
);
const sender_client = await SigningCosmWasmClient.connectWithSigner(
rpcEndpoint,
sender_wallet
);
const result = await sender_client.queryContractSmart(
trade_shield_contract_addr,
{
margin_get_position_for_address: {
address: address,
pagination: pagination,
},
}
);
console.log(`Result: `, result);
}

0 comments on commit 94569cb

Please sign in to comment.