diff --git a/.changeset/fast-brooms-search.md b/.changeset/fast-brooms-search.md new file mode 100644 index 0000000..9a360a3 --- /dev/null +++ b/.changeset/fast-brooms-search.md @@ -0,0 +1,5 @@ +--- +"@shadeprotocol/shadejs": patch +--- + +lend stability pool query diff --git a/.changeset/unlucky-pandas-develop.md b/.changeset/unlucky-pandas-develop.md new file mode 100644 index 0000000..85420f4 --- /dev/null +++ b/.changeset/unlucky-pandas-develop.md @@ -0,0 +1,5 @@ +--- +"@shadeprotocol/shadejs": patch +--- + +lend contracts in docs diff --git a/docs/contracts.md b/docs/contracts.md index 1e73146..1f27673 100644 --- a/docs/contracts.md +++ b/docs/contracts.md @@ -11,6 +11,10 @@ This page contains a list of deployed contracts. | 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 | ::: tip The ShadeSwap pairs contracts are accessible via the factory registered pairs query. diff --git a/docs/queries/lend.md b/docs/queries/lend.md index 3d7bdb6..ceed8c5 100644 --- a/docs/queries/lend.md +++ b/docs/queries/lend.md @@ -129,4 +129,39 @@ async function queryVault({ **output** -See "Vault" type in the all vaults output. \ No newline at end of file +See "Vault" type in the all vaults output. + + +## Stability Pool +Query info for the stability pool data + +**input** +```ts +function queryStabilityPoolInfo({ + queryRouterContractAddress, + queryRouterCodeHash, + lcdEndpoint, + chainId, + stabilityPoolContractAddress, + stabilityPoolCodeHash, + minBlockHeightValidationOptions, +}:{ + queryRouterContractAddress: string, + queryRouterCodeHash?: string, + lcdEndpoint?: string, + chainId?: string, + stabilityPoolContractAddress: string, + stabilityPoolCodeHash: string, + minBlockHeightValidationOptions?: MinBlockHeightValidationOptions, +}): Promise +``` + +**output** +```ts +type StabilityPoolInfo = { + silkDeposited: string, + bondAmount: string, // this is value used for calculation + // purposes. It does not represent a token amount. + blockHeight: number, +} +``` \ No newline at end of file diff --git a/src/contracts/definitions/lend/index.ts b/src/contracts/definitions/lend/index.ts new file mode 100644 index 0000000..ffe5105 --- /dev/null +++ b/src/contracts/definitions/lend/index.ts @@ -0,0 +1,2 @@ +export * from './vaultRegistry'; +export * from './stabilityPool'; diff --git a/src/contracts/definitions/lend/stabilityPool.test.ts b/src/contracts/definitions/lend/stabilityPool.test.ts new file mode 100644 index 0000000..fa42bfc --- /dev/null +++ b/src/contracts/definitions/lend/stabilityPool.test.ts @@ -0,0 +1,12 @@ +import { + test, + expect, +} from 'vitest'; +import { msgGetStabilityPoolInfo } from './stabilityPool'; + +test('it tests the form of the stability pool info message', () => { + const output = { + get_pool_info: {}, + }; + expect(msgGetStabilityPoolInfo()).toStrictEqual(output); +}); diff --git a/src/contracts/definitions/lend/stabilityPool.ts b/src/contracts/definitions/lend/stabilityPool.ts new file mode 100644 index 0000000..a3bc59c --- /dev/null +++ b/src/contracts/definitions/lend/stabilityPool.ts @@ -0,0 +1,10 @@ +/** + * message for the getting the stability pool data + */ +const msgGetStabilityPoolInfo = () => ({ + get_pool_info: {}, +}); + +export { + msgGetStabilityPoolInfo, +}; diff --git a/src/contracts/definitions/lend.test.ts b/src/contracts/definitions/lend/vaultRegistry.test.ts similarity index 99% rename from src/contracts/definitions/lend.test.ts rename to src/contracts/definitions/lend/vaultRegistry.test.ts index d03763f..cccd8d2 100644 --- a/src/contracts/definitions/lend.test.ts +++ b/src/contracts/definitions/lend/vaultRegistry.test.ts @@ -9,7 +9,7 @@ import { msgGetVaultUserPositions, msgBorrow, msgWithdraw, -} from './lend'; +} from './vaultRegistry'; test('it tests the form of the vault info message', () => { const inputVaultId = '1'; diff --git a/src/contracts/definitions/lend.ts b/src/contracts/definitions/lend/vaultRegistry.ts similarity index 100% rename from src/contracts/definitions/lend.ts rename to src/contracts/definitions/lend/vaultRegistry.ts diff --git a/src/contracts/services/lend/index.ts b/src/contracts/services/lend/index.ts new file mode 100644 index 0000000..ffe5105 --- /dev/null +++ b/src/contracts/services/lend/index.ts @@ -0,0 +1,2 @@ +export * from './vaultRegistry'; +export * from './stabilityPool'; diff --git a/src/contracts/services/lend/stabilityPool.test.ts b/src/contracts/services/lend/stabilityPool.test.ts new file mode 100644 index 0000000..bc0add3 --- /dev/null +++ b/src/contracts/services/lend/stabilityPool.test.ts @@ -0,0 +1,87 @@ +import { + test, + expect, + vi, + beforeAll, +} from 'vitest'; +import stabilityPoolInfoResponse from '~/test/mocks/lend/stabilityPool/stabilityPoolInfoResponse.json'; +import { stabilityPoolInfoParsed } from '~/test/mocks/lend/stabilityPool/stabilityPoolInfoParsed'; +import { batchStabilityPoolResponseUnparsed } from '~/test/mocks/lend/stabilityPool/stabilityPoolInfoBatchResponse'; +import { of } from 'rxjs'; +import { MinBlockHeightValidationOptions } from '~/types'; +import { + parseStabilityPoolResponse, + parseStabilityPoolResponseFromQueryRouter, + queryStabilityPoolInfo$, + queryStabilityPoolInfo, +} from './stabilityPool'; + +const batchQuery$ = vi.hoisted(() => vi.fn()); + +beforeAll(() => { + vi.mock('~/contracts/definitions/lend/stabilityPool', () => ({ + msgGetStabilityPoolInfo: vi.fn(() => 'GET_STABILITY_POOL_MSG'), + })); + + vi.mock('~/contracts/services/batchQuery', () => ({ + batchQuery$, + })); +}); + +test('it can parse the stability pool response', () => { + expect(parseStabilityPoolResponse( + stabilityPoolInfoResponse, + 1, + )).toStrictEqual(stabilityPoolInfoParsed); +}); + +test('it can parse the stability pool response via the query router', () => { + expect(parseStabilityPoolResponseFromQueryRouter( + batchStabilityPoolResponseUnparsed, + )).toStrictEqual(stabilityPoolInfoParsed); +}); + +test('it can call stability pool info service', async () => { + const input = { + queryRouterContractAddress: 'QUERY_ROUTER_CONTRACT_ADDRESS', + queryRouterCodeHash: 'QUERY_ROUTER_CODE_HASH', + lcdEndpoint: 'LCD_ENDPOINT', + chainId: 'CHAIN_ID', + stabilityPoolContractAddress: 'STABILITY_POOL_CONTRACT_ADDRESS', + stabilityPoolCodeHash: 'STABILITY_POOL_CODE_HASH', + minBlockHeightValidationOptions: 'BLOCK_HEIGHT_VALIDATION_OPTIONS' as unknown as MinBlockHeightValidationOptions, + }; + // observables function + batchQuery$.mockReturnValueOnce(of(batchStabilityPoolResponseUnparsed)); + let output; + queryStabilityPoolInfo$(input).subscribe({ + next: (response) => { + output = response; + }, + }); + + const batchQueryInput = { + contractAddress: input.queryRouterContractAddress, + codeHash: input.queryRouterCodeHash, + lcdEndpoint: input.lcdEndpoint, + chainId: input.chainId, + queries: [{ + id: input.stabilityPoolContractAddress, + contract: { + address: input.stabilityPoolContractAddress, + codeHash: input.stabilityPoolCodeHash, + }, + queryMsg: 'GET_STABILITY_POOL_MSG', + }], // array of length 1 for single query + minBlockHeightValidationOptions: input.minBlockHeightValidationOptions, + }; + expect(batchQuery$).toHaveBeenCalledWith(batchQueryInput); + + expect(output).toStrictEqual(stabilityPoolInfoParsed); + + // async/await function + batchQuery$.mockReturnValueOnce(of(batchStabilityPoolResponseUnparsed)); + const response = await queryStabilityPoolInfo(input); + expect(batchQuery$).toHaveBeenCalledWith(batchQueryInput); + expect(response).toStrictEqual(stabilityPoolInfoParsed); +}); diff --git a/src/contracts/services/lend/stabilityPool.ts b/src/contracts/services/lend/stabilityPool.ts new file mode 100644 index 0000000..f5a8115 --- /dev/null +++ b/src/contracts/services/lend/stabilityPool.ts @@ -0,0 +1,140 @@ +import { + MinBlockHeightValidationOptions, + BatchQueryParams, + NormalizationFactor, + BatchQueryParsedResponse, + BatchItemResponseStatus, +} from '~/types'; +import { msgGetStabilityPoolInfo } from '~/contracts/definitions'; +import { + map, + first, + firstValueFrom, +} from 'rxjs'; +import { StabilityPoolInfo, StabilityPoolResponse } from '~/types/contracts/lend'; +import { convertCoinFromUDenom } from '~/lib/utils'; +import { batchQuery$ } from '../batchQuery'; + +/** + * parses the direct contract query into the data model + */ +const parseStabilityPoolResponse = ( + response: StabilityPoolResponse, + blockHeight: number, +): StabilityPoolInfo => ({ + silkDeposited: convertCoinFromUDenom( + response.pool_info.total_silk_deposited, + NormalizationFactor.LEND, + ).toString(), + bondAmount: convertCoinFromUDenom( + response.pool_info.total_bond_amount, + NormalizationFactor.LEND, + ).toString(), + blockHeight, +}); + +/** + * parses the query router response into the data model + */ +function parseStabilityPoolResponseFromQueryRouter( + batchQueryResponse: BatchQueryParsedResponse, +): StabilityPoolInfo { + const responseCount = batchQueryResponse.length; + if (responseCount !== 1) { + throw new Error(`${responseCount} responses found, one response is expected`); + } + + const response = batchQueryResponse[0]; + + // handle error state + if (response.status === BatchItemResponseStatus.ERROR) { + throw new Error(response.response); + } + + return { + ...parseStabilityPoolResponse( + response.response, + response.blockHeight, + ), + }; +} + +/** + * query the stability pool info + */ +function queryStabilityPoolInfo$({ + queryRouterContractAddress, + queryRouterCodeHash, + lcdEndpoint, + chainId, + stabilityPoolContractAddress, + stabilityPoolCodeHash, + minBlockHeightValidationOptions, +}:{ + queryRouterContractAddress: string, + queryRouterCodeHash?: string, + lcdEndpoint?: string, + chainId?: string, + stabilityPoolContractAddress: string, + stabilityPoolCodeHash: string, + minBlockHeightValidationOptions?: MinBlockHeightValidationOptions, +}) { + const query:BatchQueryParams = { + id: stabilityPoolContractAddress, + contract: { + address: stabilityPoolContractAddress, + codeHash: stabilityPoolCodeHash, + }, + queryMsg: msgGetStabilityPoolInfo(), + }; + + return batchQuery$({ + contractAddress: queryRouterContractAddress, + codeHash: queryRouterCodeHash, + lcdEndpoint, + chainId, + queries: [query], // array of length 1 for single query + minBlockHeightValidationOptions, + }).pipe( + map(parseStabilityPoolResponseFromQueryRouter), + first(), + ); +} + +/** + * query the stability pool info + */ +function queryStabilityPoolInfo({ + queryRouterContractAddress, + queryRouterCodeHash, + lcdEndpoint, + chainId, + stabilityPoolContractAddress, + stabilityPoolCodeHash, + minBlockHeightValidationOptions, +}:{ + queryRouterContractAddress: string, + queryRouterCodeHash?: string, + lcdEndpoint?: string, + chainId?: string, + stabilityPoolContractAddress: string, + stabilityPoolCodeHash: string, + minBlockHeightValidationOptions?: MinBlockHeightValidationOptions, +}) { + return firstValueFrom(queryStabilityPoolInfo$({ + queryRouterContractAddress, + queryRouterCodeHash, + lcdEndpoint, + chainId, + stabilityPoolContractAddress, + stabilityPoolCodeHash, + minBlockHeightValidationOptions, + })); +} + +export { + queryStabilityPoolInfo, + queryStabilityPoolInfo$, + parseStabilityPoolResponse, + parseStabilityPoolResponseFromQueryRouter, +}; diff --git a/src/contracts/services/lend.test.ts b/src/contracts/services/lend/vaultRegistry.test.ts similarity index 97% rename from src/contracts/services/lend.test.ts rename to src/contracts/services/lend/vaultRegistry.test.ts index 57131f3..cf03241 100644 --- a/src/contracts/services/lend.test.ts +++ b/src/contracts/services/lend/vaultRegistry.test.ts @@ -11,8 +11,8 @@ import vaultV2Response from '~/test/mocks/lend/vaultV2Response.json'; import vaultsV2Response from '~/test/mocks/lend/vaultsV2Response.json'; import vaultV3Response from '~/test/mocks/lend/vaultV3Response.json'; import vaultsV3Response from '~/test/mocks/lend/vaultsV3Response.json'; -import { VaultVersion } from '~/types/contracts/lend/model'; -import { VaultResponse, VaultsResponse } from '~/types/contracts/lend/response'; +import { VaultVersion } from '~/types/contracts/lend/vaultRegistry/model'; +import { VaultResponse, VaultsResponse } from '~/types/contracts/lend/vaultRegistry/response'; import { vaultV1Parsed, vaultsV1Parsed, @@ -36,13 +36,13 @@ import { queryVaults, queryVault$, queryVault, -} from './lend'; +} from './vaultRegistry'; const sendSecretClientContractQuery$ = vi.hoisted(() => vi.fn()); const batchQuery$ = vi.hoisted(() => vi.fn()); beforeAll(() => { - vi.mock('~/contracts/definitions/lend', () => ({ + vi.mock('~/contracts/definitions/lend/vaultRegistry', () => ({ msgGetVaults: vi.fn(() => 'GET_VAULTS_MSG'), msgGetVault: vi.fn(() => 'GET_VAULT_MSG'), })); diff --git a/src/contracts/services/lend.ts b/src/contracts/services/lend/vaultRegistry.ts similarity index 97% rename from src/contracts/services/lend.ts rename to src/contracts/services/lend/vaultRegistry.ts index e8bdeae..503bc15 100644 --- a/src/contracts/services/lend.ts +++ b/src/contracts/services/lend/vaultRegistry.ts @@ -14,7 +14,7 @@ import { VaultResponse, VaultsResponse, NormalizationFactor, -} from '~/types/contracts/lend/response'; +} from '~/types/contracts/lend/vaultRegistry/response'; import { convertCoinFromUDenom, getActiveQueryClient$, @@ -22,15 +22,16 @@ import { import { Vaults, Vault, - BatchVaults, VaultVersion, + BatchVaults, + VaultVersion, LendVaultRegistryContract, -} from '~/types/contracts/lend/model'; +} from '~/types/contracts/lend/vaultRegistry/model'; +import { sendSecretClientContractQuery$ } from '~/client/services/clientServices'; +import BigNumber from 'bignumber.js'; import { msgGetVault, msgGetVaults, -} from '~/contracts/definitions/lend'; -import { sendSecretClientContractQuery$ } from '~/client/services/clientServices'; -import BigNumber from 'bignumber.js'; +} from '~/contracts/definitions/lend/vaultRegistry'; /** * Parse lend vault response diff --git a/src/test/mocks/lend/batchVaultsParsed.ts b/src/test/mocks/lend/batchVaultsParsed.ts index 51f39de..5ec3c3c 100644 --- a/src/test/mocks/lend/batchVaultsParsed.ts +++ b/src/test/mocks/lend/batchVaultsParsed.ts @@ -1,8 +1,8 @@ import { BatchVaults, VaultVersion, -} from '~/types/contracts/lend/model'; -import { LendContractStatus } from '~/types/contracts/lend/response'; +} from '~/types/contracts/lend/vaultRegistry/model'; +import { LendContractStatus } from '~/types/contracts/lend/vaultRegistry/response'; const batchVaultsParsed: BatchVaults = [ { diff --git a/src/test/mocks/lend/stabilityPool/stabilityPoolInfoBatchResponse.ts b/src/test/mocks/lend/stabilityPool/stabilityPoolInfoBatchResponse.ts new file mode 100644 index 0000000..43a2f6d --- /dev/null +++ b/src/test/mocks/lend/stabilityPool/stabilityPoolInfoBatchResponse.ts @@ -0,0 +1,166 @@ +import { BatchQueryParsedResponse } from '~/types'; + +const batchStabilityPoolResponseUnparsed: BatchQueryParsedResponse = [ + { + id: 'secret1wdxqz26acf2e6rsac8007pd53ak7n8tgeqr46w', + response: { + silk: { + contract: { + address: 'secret1fl449muk5yq8dlad7a22nje4p5d2pnsgymhjfd', + code_hash: '638a3e1d50175fbcb8373cf801565283e3eb23d88a9b7b7f99fcc5eb1e6b561e', + }, + decimals: 6, + quote_symbol: 'SILK Peg', + }, + pool_info: { + assets: [ + { + contract: { + address: 'secret1k6u0cy4feepm6pehnz804zmwakuwdapm69tuc4', + code_hash: 'f6be719b3c6feb498d3554ca0398eb6b7e7db262acb33f84a8f12106da6bbb09', + }, + decimals: 6, + quote_symbol: 'stkd-SCRT', + }, + { + contract: { + address: 'secret155w9uxruypsltvqfygh5urghd5v0zc6f9g69sq', + code_hash: '638a3e1d50175fbcb8373cf801565283e3eb23d88a9b7b7f99fcc5eb1e6b561e', + }, + decimals: 6, + quote_symbol: 'Stride ATOM', + }, + { + contract: { + address: 'secret1jrp6z8v679yaq65rndsr970mhaxzgfkymvc58g', + code_hash: '638a3e1d50175fbcb8373cf801565283e3eb23d88a9b7b7f99fcc5eb1e6b561e', + }, + decimals: 6, + quote_symbol: 'Stride OSMO', + }, + { + contract: { + address: 'secret1vkq022x4q8t8kx9de3r84u669l65xnwf2lg3e6', + code_hash: '638a3e1d50175fbcb8373cf801565283e3eb23d88a9b7b7f99fcc5eb1e6b561e', + }, + decimals: 6, + quote_symbol: 'USDC', + }, + { + contract: { + address: 'secret1wk5j2cntwg2fgklf0uta3tlkvt87alfj7kepuw', + code_hash: '638a3e1d50175fbcb8373cf801565283e3eb23d88a9b7b7f99fcc5eb1e6b561e', + }, + decimals: 6, + quote_symbol: 'USDT', + }, + { + contract: { + address: 'secret153wu605vvp934xhd4k9dtd640zsep5jkesstdm', + code_hash: '638a3e1d50175fbcb8373cf801565283e3eb23d88a9b7b7f99fcc5eb1e6b561e', + }, + decimals: 8, + quote_symbol: 'SHD', + }, + { + contract: { + address: 'secret19e75l25r6sa6nhdf4lggjmgpw0vmpfvsw5cnpe', + code_hash: '638a3e1d50175fbcb8373cf801565283e3eb23d88a9b7b7f99fcc5eb1e6b561e', + }, + decimals: 6, + quote_symbol: 'ATOM', + }, + { + contract: { + address: 'secret150jec8mc2hzyyqak4umv6cfevelr0x9p0mjxgg', + code_hash: '638a3e1d50175fbcb8373cf801565283e3eb23d88a9b7b7f99fcc5eb1e6b561e', + }, + decimals: 6, + quote_symbol: 'OSMO', + }, + { + contract: { + address: 'secret139qfh3nmuzfgwsx2npnmnjl4hrvj3xq5rmq8a0', + code_hash: '638a3e1d50175fbcb8373cf801565283e3eb23d88a9b7b7f99fcc5eb1e6b561e', + }, + decimals: 18, + quote_symbol: 'ETH', + }, + { + contract: { + address: 'secret1guyayjwg5f84daaxl7w84skd8naxvq8vz9upqx', + code_hash: '638a3e1d50175fbcb8373cf801565283e3eb23d88a9b7b7f99fcc5eb1e6b561e', + }, + decimals: 8, + quote_symbol: 'BTC', + }, + { + contract: { + address: 'secret16vjfe24un4z7d3sp9vd0cmmfmz397nh2njpw3e', + code_hash: '638a3e1d50175fbcb8373cf801565283e3eb23d88a9b7b7f99fcc5eb1e6b561e', + }, + decimals: 6, + quote_symbol: 'Persistence ATOM', + }, + { + contract: { + address: 'secret148jzxkagwe0xulf8jt3sw4nuh2shdh788z3gyd', + code_hash: '638a3e1d50175fbcb8373cf801565283e3eb23d88a9b7b7f99fcc5eb1e6b561e', + }, + decimals: 18, + quote_symbol: 'Lido Staked ETH', + }, + { + contract: { + address: 'secret1k0jntykt7e4g3y88ltc60czgjuqdy4c9e8fzek', + code_hash: 'af74387e276be8874f07bec3a87023ee49b0e7ebe08178c49d0a49c3c98ed60e', + }, + decimals: 6, + quote_symbol: 'SCRT', + }, + { + contract: { + address: 'secret14706vxakdzkz9a36872cs62vpl5qd84kpwvpew', + code_hash: '638a3e1d50175fbcb8373cf801565283e3eb23d88a9b7b7f99fcc5eb1e6b561e', + }, + decimals: 18, + quote_symbol: 'INJ', + }, + { + contract: { + address: 'secret1eurddal3m0tphtapad9awgzcuxwz8ptrdx7h4n', + code_hash: '638a3e1d50175fbcb8373cf801565283e3eb23d88a9b7b7f99fcc5eb1e6b561e', + }, + decimals: 18, + quote_symbol: 'Stride INJ', + }, + { + contract: { + address: 'secret1s9h6mrp4k9gll4zfv5h78ll68hdq8ml7jrnn20', + code_hash: '638a3e1d50175fbcb8373cf801565283e3eb23d88a9b7b7f99fcc5eb1e6b561e', + }, + decimals: 6, + quote_symbol: 'TIA', + }, + { + contract: { + address: 'secret1l5d0vncwnlln0tz0m4tp9rgm740xl7th6es0q0', + code_hash: '638a3e1d50175fbcb8373cf801565283e3eb23d88a9b7b7f99fcc5eb1e6b561e', + }, + decimals: 6, + quote_symbol: 'Stride TIA', + }, + ], + total_silk_deposited: '642062556277909419164475', + total_bond_amount: '987898469318211575638733356414279', + bond_scaling: '0', + epoch: '2', + }, + }, + blockHeight: 1, + }, +]; + +export { + batchStabilityPoolResponseUnparsed, +}; diff --git a/src/test/mocks/lend/stabilityPool/stabilityPoolInfoParsed.ts b/src/test/mocks/lend/stabilityPool/stabilityPoolInfoParsed.ts new file mode 100644 index 0000000..d18e874 --- /dev/null +++ b/src/test/mocks/lend/stabilityPool/stabilityPoolInfoParsed.ts @@ -0,0 +1,9 @@ +const stabilityPoolInfoParsed = { + silkDeposited: '642062.556277909419164475', + bondAmount: '987898469318211.575638733356414279', + blockHeight: 1, +}; + +export { + stabilityPoolInfoParsed, +}; diff --git a/src/test/mocks/lend/stabilityPool/stabilityPoolInfoResponse.json b/src/test/mocks/lend/stabilityPool/stabilityPoolInfoResponse.json new file mode 100644 index 0000000..91e2671 --- /dev/null +++ b/src/test/mocks/lend/stabilityPool/stabilityPoolInfoResponse.json @@ -0,0 +1,154 @@ +{ + "silk": { + "contract": { + "address": "secret1fl449muk5yq8dlad7a22nje4p5d2pnsgymhjfd", + "code_hash": "638a3e1d50175fbcb8373cf801565283e3eb23d88a9b7b7f99fcc5eb1e6b561e" + }, + "decimals": 6, + "quote_symbol": "SILK Peg" + }, + "pool_info": { + "assets": [ + { + "contract": { + "address": "secret1k6u0cy4feepm6pehnz804zmwakuwdapm69tuc4", + "code_hash": "f6be719b3c6feb498d3554ca0398eb6b7e7db262acb33f84a8f12106da6bbb09" + }, + "decimals": 6, + "quote_symbol": "stkd-SCRT" + }, + { + "contract": { + "address": "secret155w9uxruypsltvqfygh5urghd5v0zc6f9g69sq", + "code_hash": "638a3e1d50175fbcb8373cf801565283e3eb23d88a9b7b7f99fcc5eb1e6b561e" + }, + "decimals": 6, + "quote_symbol": "Stride ATOM" + }, + { + "contract": { + "address": "secret1jrp6z8v679yaq65rndsr970mhaxzgfkymvc58g", + "code_hash": "638a3e1d50175fbcb8373cf801565283e3eb23d88a9b7b7f99fcc5eb1e6b561e" + }, + "decimals": 6, + "quote_symbol": "Stride OSMO" + }, + { + "contract": { + "address": "secret1vkq022x4q8t8kx9de3r84u669l65xnwf2lg3e6", + "code_hash": "638a3e1d50175fbcb8373cf801565283e3eb23d88a9b7b7f99fcc5eb1e6b561e" + }, + "decimals": 6, + "quote_symbol": "USDC" + }, + { + "contract": { + "address": "secret1wk5j2cntwg2fgklf0uta3tlkvt87alfj7kepuw", + "code_hash": "638a3e1d50175fbcb8373cf801565283e3eb23d88a9b7b7f99fcc5eb1e6b561e" + }, + "decimals": 6, + "quote_symbol": "USDT" + }, + { + "contract": { + "address": "secret153wu605vvp934xhd4k9dtd640zsep5jkesstdm", + "code_hash": "638a3e1d50175fbcb8373cf801565283e3eb23d88a9b7b7f99fcc5eb1e6b561e" + }, + "decimals": 8, + "quote_symbol": "SHD" + }, + { + "contract": { + "address": "secret19e75l25r6sa6nhdf4lggjmgpw0vmpfvsw5cnpe", + "code_hash": "638a3e1d50175fbcb8373cf801565283e3eb23d88a9b7b7f99fcc5eb1e6b561e" + }, + "decimals": 6, + "quote_symbol": "ATOM" + }, + { + "contract": { + "address": "secret150jec8mc2hzyyqak4umv6cfevelr0x9p0mjxgg", + "code_hash": "638a3e1d50175fbcb8373cf801565283e3eb23d88a9b7b7f99fcc5eb1e6b561e" + }, + "decimals": 6, + "quote_symbol": "OSMO" + }, + { + "contract": { + "address": "secret139qfh3nmuzfgwsx2npnmnjl4hrvj3xq5rmq8a0", + "code_hash": "638a3e1d50175fbcb8373cf801565283e3eb23d88a9b7b7f99fcc5eb1e6b561e" + }, + "decimals": 18, + "quote_symbol": "ETH" + }, + { + "contract": { + "address": "secret1guyayjwg5f84daaxl7w84skd8naxvq8vz9upqx", + "code_hash": "638a3e1d50175fbcb8373cf801565283e3eb23d88a9b7b7f99fcc5eb1e6b561e" + }, + "decimals": 8, + "quote_symbol": "BTC" + }, + { + "contract": { + "address": "secret16vjfe24un4z7d3sp9vd0cmmfmz397nh2njpw3e", + "code_hash": "638a3e1d50175fbcb8373cf801565283e3eb23d88a9b7b7f99fcc5eb1e6b561e" + }, + "decimals": 6, + "quote_symbol": "Persistence ATOM" + }, + { + "contract": { + "address": "secret148jzxkagwe0xulf8jt3sw4nuh2shdh788z3gyd", + "code_hash": "638a3e1d50175fbcb8373cf801565283e3eb23d88a9b7b7f99fcc5eb1e6b561e" + }, + "decimals": 18, + "quote_symbol": "Lido Staked ETH" + }, + { + "contract": { + "address": "secret1k0jntykt7e4g3y88ltc60czgjuqdy4c9e8fzek", + "code_hash": "af74387e276be8874f07bec3a87023ee49b0e7ebe08178c49d0a49c3c98ed60e" + }, + "decimals": 6, + "quote_symbol": "SCRT" + }, + { + "contract": { + "address": "secret14706vxakdzkz9a36872cs62vpl5qd84kpwvpew", + "code_hash": "638a3e1d50175fbcb8373cf801565283e3eb23d88a9b7b7f99fcc5eb1e6b561e" + }, + "decimals": 18, + "quote_symbol": "INJ" + }, + { + "contract": { + "address": "secret1eurddal3m0tphtapad9awgzcuxwz8ptrdx7h4n", + "code_hash": "638a3e1d50175fbcb8373cf801565283e3eb23d88a9b7b7f99fcc5eb1e6b561e" + }, + "decimals": 18, + "quote_symbol": "Stride INJ" + }, + { + "contract": { + "address": "secret1s9h6mrp4k9gll4zfv5h78ll68hdq8ml7jrnn20", + "code_hash": "638a3e1d50175fbcb8373cf801565283e3eb23d88a9b7b7f99fcc5eb1e6b561e" + }, + "decimals": 6, + "quote_symbol": "TIA" + }, + { + "contract": { + "address": "secret1l5d0vncwnlln0tz0m4tp9rgm740xl7th6es0q0", + "code_hash": "638a3e1d50175fbcb8373cf801565283e3eb23d88a9b7b7f99fcc5eb1e6b561e" + }, + "decimals": 6, + "quote_symbol": "Stride TIA" + } + ], + "total_silk_deposited": "642062556277909419164475", + "total_bond_amount": "987898469318211575638733356414279", + "bond_scaling": "0", + "epoch": "2" + } +} \ No newline at end of file diff --git a/src/test/mocks/lend/vaultV1Parsed.ts b/src/test/mocks/lend/vaultV1Parsed.ts index e7bc166..6cbde44 100644 --- a/src/test/mocks/lend/vaultV1Parsed.ts +++ b/src/test/mocks/lend/vaultV1Parsed.ts @@ -2,8 +2,8 @@ import { Vault, VaultVersion, Vaults, -} from '~/types/contracts/lend/model'; -import { LendContractStatus } from '~/types/contracts/lend/response'; +} from '~/types/contracts/lend/vaultRegistry/model'; +import { LendContractStatus } from '~/types/contracts/lend/vaultRegistry/response'; const vaultV1Parsed: Vault = { id: '1', diff --git a/src/test/mocks/lend/vaultV2Parsed.ts b/src/test/mocks/lend/vaultV2Parsed.ts index 6d5da1f..d53a7f8 100644 --- a/src/test/mocks/lend/vaultV2Parsed.ts +++ b/src/test/mocks/lend/vaultV2Parsed.ts @@ -2,8 +2,8 @@ import { Vault, Vaults, VaultVersion, -} from '~/types/contracts/lend/model'; -import { LendContractStatus } from '~/types/contracts/lend/response'; +} from '~/types/contracts/lend/vaultRegistry/model'; +import { LendContractStatus } from '~/types/contracts/lend/vaultRegistry/response'; const vaultV2Parsed: Vault = { id: '1', diff --git a/src/test/mocks/lend/vaultV3Parsed.ts b/src/test/mocks/lend/vaultV3Parsed.ts index 33a8e54..ab89892 100644 --- a/src/test/mocks/lend/vaultV3Parsed.ts +++ b/src/test/mocks/lend/vaultV3Parsed.ts @@ -2,8 +2,8 @@ import { Vault, Vaults, VaultVersion, -} from '~/types/contracts/lend/model'; -import { LendContractStatus } from '~/types/contracts/lend/response'; +} from '~/types/contracts/lend/vaultRegistry/model'; +import { LendContractStatus } from '~/types/contracts/lend/vaultRegistry/response'; const vaultV3Parsed: Vault = { id: '1', diff --git a/src/types/contracts/lend/index.ts b/src/types/contracts/lend/index.ts index ed9aa71..ffe5105 100644 --- a/src/types/contracts/lend/index.ts +++ b/src/types/contracts/lend/index.ts @@ -1,2 +1,2 @@ -export * from './model'; -export * from './response'; +export * from './vaultRegistry'; +export * from './stabilityPool'; diff --git a/src/types/contracts/lend/stabilityPool/index.ts b/src/types/contracts/lend/stabilityPool/index.ts new file mode 100644 index 0000000..ed9aa71 --- /dev/null +++ b/src/types/contracts/lend/stabilityPool/index.ts @@ -0,0 +1,2 @@ +export * from './model'; +export * from './response'; diff --git a/src/types/contracts/lend/stabilityPool/model.ts b/src/types/contracts/lend/stabilityPool/model.ts new file mode 100644 index 0000000..5351ec8 --- /dev/null +++ b/src/types/contracts/lend/stabilityPool/model.ts @@ -0,0 +1,9 @@ +type StabilityPoolInfo = { + silkDeposited: string, + bondAmount: string, + blockHeight: number, +} + +export type { + StabilityPoolInfo, +}; diff --git a/src/types/contracts/lend/stabilityPool/response.ts b/src/types/contracts/lend/stabilityPool/response.ts new file mode 100644 index 0000000..50f9566 --- /dev/null +++ b/src/types/contracts/lend/stabilityPool/response.ts @@ -0,0 +1,22 @@ +import { ContractData } from '~/types/contracts/shared'; + +type StabilityPoolContractData = { + contract: ContractData, + decimals: number, + quote_symbol: string, +} + +type StabilityPoolResponse = { + silk: StabilityPoolContractData, + pool_info: { + assets: StabilityPoolContractData[], + total_silk_deposited: string, + total_bond_amount: string, + bond_scaling: string, + epoch: string, + } +} + +export type { + StabilityPoolResponse, +}; diff --git a/src/types/contracts/lend/vaultRegistry/index.ts b/src/types/contracts/lend/vaultRegistry/index.ts new file mode 100644 index 0000000..ed9aa71 --- /dev/null +++ b/src/types/contracts/lend/vaultRegistry/index.ts @@ -0,0 +1,2 @@ +export * from './model'; +export * from './response'; diff --git a/src/types/contracts/lend/model.ts b/src/types/contracts/lend/vaultRegistry/model.ts similarity index 100% rename from src/types/contracts/lend/model.ts rename to src/types/contracts/lend/vaultRegistry/model.ts diff --git a/src/types/contracts/lend/response.ts b/src/types/contracts/lend/vaultRegistry/response.ts similarity index 100% rename from src/types/contracts/lend/response.ts rename to src/types/contracts/lend/vaultRegistry/response.ts