Skip to content

Commit

Permalink
Merge pull request #140 from securesecrets/develop
Browse files Browse the repository at this point in the history
silk basket query
  • Loading branch information
AustinWoetzel authored Apr 26, 2024
2 parents 5b0f43c + cb72124 commit 7b2cc4e
Show file tree
Hide file tree
Showing 20 changed files with 1,637 additions and 9 deletions.
5 changes: 5 additions & 0 deletions .changeset/spicy-boats-join.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@shadeprotocol/shadejs": minor
---

silk basket query
1 change: 1 addition & 0 deletions docs/.vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export default defineConfig({
{ text: 'stkd-SCRT', link: '/queries/derivativeScrt' },
{ text: 'Shade Staking', link: '/queries/shadeStaking' },
{ text: 'Batch Query', link: '/queries/batch-query' },
{ text: 'Silk', link: '/queries/silk' },
{ text: 'Snip20', link: '/queries/snip20' },
]
},
Expand Down
19 changes: 10 additions & 9 deletions docs/contracts.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,19 @@
This page contains a list of deployed contracts.

## Mainnet
| Contract | Address | Code Hash |
|-------------------- |----------------------------------------------- |------------------------------------------------------------------ |
| ShadeSwap Factory | secret1ja0hcwvy76grqkpgwznxukgd7t8a8anmmx05pp | 2ad4ed2a4a45fd6de3daca9541ba82c26bb66c76d1c3540de39b509abd26538e |
| ShadeSwap Router | secret1pjhdug87nxzv0esxasmeyfsucaj98pw4334wyc | 448e3f6d801e453e838b7a5fbaa4dd93b84d0f1011245f0d5745366dadaf3e85 |
| Batch Query Router | secret15mkmad8ac036v4nrpcc7nk8wyr578egt077syt | 1c7e86ba4fdb6760e70bf08a7df7f44b53eb0b23290e3e69ca96140810d4f432 |
| Oracle | secret10n2xl5jmez6r9umtdrth78k0vwmce0l5m9f5dm | 32c4710842b97a526c243a68511b15f58d6e72a388af38a7221ff3244c754e91 |
| stkd-scrt | secret1k6u0cy4feepm6pehnz804zmwakuwdapm69tuc4 | f6be719b3c6feb498d3554ca0398eb6b7e7db262acb33f84a8f12106da6bbb09 |
| Shade Staking | secret1y6px5x7jzrk8hyvy67f06ytn8v0jwculypwxws | 2a1ae7fd2be82931cb11d0ce82b2e243507f2006074e2f316da661beb1abe3c3 |
| Contract | Address | Code Hash |
|----------------------------- |----------------------------------------------- |------------------------------------------------------------------ |
| ShadeSwap Factory | secret1ja0hcwvy76grqkpgwznxukgd7t8a8anmmx05pp | 2ad4ed2a4a45fd6de3daca9541ba82c26bb66c76d1c3540de39b509abd26538e |
| ShadeSwap Router | secret1pjhdug87nxzv0esxasmeyfsucaj98pw4334wyc | 448e3f6d801e453e838b7a5fbaa4dd93b84d0f1011245f0d5745366dadaf3e85 |
| Batch Query Router | secret15mkmad8ac036v4nrpcc7nk8wyr578egt077syt | 1c7e86ba4fdb6760e70bf08a7df7f44b53eb0b23290e3e69ca96140810d4f432 |
| Oracle | secret10n2xl5jmez6r9umtdrth78k0vwmce0l5m9f5dm | 32c4710842b97a526c243a68511b15f58d6e72a388af38a7221ff3244c754e91 |
| stkd-scrt | secret1k6u0cy4feepm6pehnz804zmwakuwdapm69tuc4 | f6be719b3c6feb498d3554ca0398eb6b7e7db262acb33f84a8f12106da6bbb09 |
| Shade Staking | secret1y6px5x7jzrk8hyvy67f06ytn8v0jwculypwxws | 2a1ae7fd2be82931cb11d0ce82b2e243507f2006074e2f316da661beb1abe3c3 |
| Lend Vault Registry (V1) | secret18y86hldtdp9ndj0jekcch49kwr0gwy7upe3ffw | 148a525ec7bffedfc41cbc5339bf22d9e310d49b65831a269c86774fb732948c |
| Lend Vault Registry (V2) | secret1qxk2scacpgj2mmm0af60674afl9e6qneg7yuny | ac5d501827d9a337a618ca493fcbf1323b20771378774a6bf466cb66361bf021 |
| Lend Vault Registry (V3) | secret1wj2czeeknya2n6jag7kpfxlm28dw7q96dgqmfs | d837f716de3732a4118fbcb6d4cd0ef1d84ee83fef924f27b7c2a821f8528b39 |
| Lend Stability Pool | secret1wdxqz26acf2e6rsac8007pd53ak7n8tgeqr46w | 4dcdce6a2f88ef2912b9988119b345b096909aa4ba3881eff19358d983c40210 |
| Lend Stability Pool | secret1wdxqz26acf2e6rsac8007pd53ak7n8tgeqr46w | 4dcdce6a2f88ef2912b9988119b345b096909aa4ba3881eff19358d983c40210 |
| Index Oracle (SILK) | secret1552yh3rplmyrjwhcxrq0egg35uy6zwjtszecf0 | 8d2b439383091ecb7806757a2b202e0056e542ade67951a0d5c352e74ce416cc |

::: tip
The ShadeSwap pairs contracts are accessible via the factory registered pairs query.
Expand Down
140 changes: 140 additions & 0 deletions docs/queries/silk.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
# Silk Peg Examples

This page demonstrates how to query the Silk peg and information about the basket of currencies that make up the Silk peg.

## Silk Basket
Query info for the silk basket

**input**
```ts
/**
* query the silk basket data
*
* silkBasketExpectedOracleKeys is set to optional because if oracle keys are
* known in advance it will increase the efficiency of the response, but even if
* keys are unknown or incorrectly passed in compared to the true state of the
* basket this query will self-correct using a retry on the actual keys found.
*/
function querySilkBasket({
queryRouterContractAddress,
queryRouterCodeHash,
lcdEndpoint,
chainId,
oracleContractAddress,
oracleCodeHash,
silkBasketExpectedOracleKeys,
silkIndexOracleContractAddress,
silkIndexOracleCodeHash,
minBlockHeightValidationOptions,
}:{
queryRouterContractAddress: string,
queryRouterCodeHash?: string,
lcdEndpoint?: string,
chainId?: string,
oracleContractAddress: string,
oracleCodeHash: string,
silkBasketExpectedOracleKeys?: string[]
silkIndexOracleContractAddress: string,
silkIndexOracleCodeHash: string,
minBlockHeightValidationOptions?: MinBlockHeightValidationOptions,
}): Promise<SilkBasket>
```

**output**
```ts
type SilkBasket = {
symbol: string, // silk peg oracle key
oracleRouterContract: Contract,
staleInterval: number, // seconds before stale oracle would cause a peg freeze.
peg: {
value: string, // current value of the peg
initialValue: string, // starting value of the peg
isFrozen: boolean,
lastUpdatedAt: Date,
},
basket: BasketItem[],
blockHeight: number,
}
type BasketItem = {
symbol: string, // oracle key
amount: string, // fixed amount of the currency that makes up the peg
price?: string, // price of the currency
weight: {
initial: string, // expressed as decimal percent
current?: string,
}
}
```

```md
{
symbol: 'SILK Peg',
oracleRouterContract: {
address: 'secret10n2xl5jmez6r9umtdrth78k0vwmce0l5m9f5dm',
codeHash: '32c4710842b97a526c243a68511b15f58d6e72a388af38a7221ff3244c754e91',
},
staleInterval: 3600,
peg: {
value: '1.149881971',
initialValue: '1.05',
isFrozen: false,
lastUpdatedAt: new Date(1714053218000),
},
basket: [{
symbol: 'CAD',
amount: '0.107192209875052435',
price: '0.731678675',
weight: {
current: '0.068207221323326828',
initial: '0.077167854630036405',
},
},
{
symbol: 'USD',
amount: '0.353843538457366364',
price: '1',
weight: {
current: '0.307721616114778065',
initial: '0.337301580837853137',
},
},
{
symbol: 'JPY',
amount: '15.684456395164345505',
price: '0.006425558',
weight: {
current: '0.087644981665339478',
initial: '0.103589679459286984',
},
},
{
symbol: 'BTC',
amount: '0.000002334689261109',
price: '64526.1',
weight: {
current: '0.131012048654205263',
initial: '0.068084956080984917',
},
},
{
symbol: 'EUR',
amount: '0.223108470434723066',
price: '1.072833942',
weight: {
current: '0.20815905098669853',
initial: '0.232086119065448055',
},
},
{
symbol: 'XAU',
amount: '0.000099333104038645',
price: '2332.0433247',
weight: {
current: '0.201454677990644557',
initial: '0.181769809926390499',
},
}],
blockHeight: 123456789,
}
```
12 changes: 12 additions & 0 deletions src/contracts/definitions/silkBasket.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import {
test,
expect,
} from 'vitest';
import { msgGetSilkBasket } from './silkBasket';

test('it tests the form of the silk basket message', () => {
const output = {
get_index_data: {},
};
expect(msgGetSilkBasket()).toStrictEqual(output);
});
10 changes: 10 additions & 0 deletions src/contracts/definitions/silkBasket.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/**
* message for the getting the silk basket data
*/
const msgGetSilkBasket = () => ({
get_index_data: {},
});

export {
msgGetSilkBasket,
};
Loading

0 comments on commit 7b2cc4e

Please sign in to comment.