diff --git a/src/ao/messaging/getData.ts b/src/ao/messaging/getData.ts index 62dae32..6874977 100644 --- a/src/ao/messaging/getData.ts +++ b/src/ao/messaging/getData.ts @@ -19,7 +19,10 @@ interface MessageTags { type GetDataRes = DryRunResult; -export async function getData(messageTags: MessageTags, config?: Services): Promise { +export async function getData( + messageTags: MessageTags, + config?: Services, +): Promise { const convertedMessageTags = Object.entries(messageTags) .map(([name, value]) => ({ name, diff --git a/src/ao/utils/tokenAddressData.ts b/src/ao/utils/tokenAddressData.ts index d50c7e3..a470e67 100644 --- a/src/ao/utils/tokenAddressData.ts +++ b/src/ao/utils/tokenAddressData.ts @@ -25,139 +25,263 @@ export const lqdTokenAddress = "n2MhPK0O3yEvY2zW73sqcmWqDktJxAifJDrri4qireI"; export const tokenData: Record = { QAR: { name: "Quantum Arweave", - icon: "8VLMb0c9NATl4iczfwpMDe1Eh8kFWIUpSlIkcGfDFzM", - ticker: "QAR", - address: "NG-0lVX882MG5nhARrSzyprEK6ejonHpdUmaaMPsHE8", - oTicker: "oQAR", - oAddress: "fODpFVOb5weX9Yc-26AA82m2MhmT7N9L0TkynOsruK0", - controllerAddress, cleanTicker: "qAR", - denomination: BigInt(12), collateralEnabled: true, - baseDenomination: BigInt(12), - deprecated: true, + address: "NG-0lVX882MG5nhARrSzyprEK6ejonHpdUmaaMPsHE8", + icon: "8VLMb0c9NATl4iczfwpMDe1Eh8kFWIUpSlIkcGfDFzM", + denomination: BigInt(12), + // + oAddress: "fODpFVOb5weX9Yc-26AA82m2MhmT7N9L0TkynOsruK0", oIcon: "i_U-jhdMMaib2hK51qPrKXbLo6cx2Nt58_gNz5FA4sw", + // + deprecated: true, borrowingDisabled: true, borrowingDisabledReason: "Deprecated token.", + // + get oTicker() { + return `o${this.cleanTicker.toUpperCase()}`; + }, + get ticker() { + return this.cleanTicker.toUpperCase(); + }, + get baseDenomination() { + return this.denomination; + }, + controllerAddress, }, WAR: { name: "Wrapped Arweave", - icon: "ICMLzIKdVMedibwgOy014I4yan_F8h2ZhORhRG5dgzs", - ticker: "WAR", - address: "xU9zFkq3X2ZQ6olwNVvr1vUWIjc3kXTWr7xKQD6dh10", - oTicker: "oWAR", - oAddress: "rAc0aP0g9NXYUXAbvlLjPH_XxyQy6eYmwSuIcf6ukuw", - controllerAddress, cleanTicker: "wAR", - denomination: BigInt(12), collateralEnabled: true, - baseDenomination: BigInt(12), - deprecated: false, + address: "xU9zFkq3X2ZQ6olwNVvr1vUWIjc3kXTWr7xKQD6dh10", + icon: "ICMLzIKdVMedibwgOy014I4yan_F8h2ZhORhRG5dgzs", + denomination: BigInt(12), + // + oAddress: "rAc0aP0g9NXYUXAbvlLjPH_XxyQy6eYmwSuIcf6ukuw", oIcon: "lTWBOBtEZ2JvTAHfvoPq5aXRWTVouv7jZ-6B9HTwosU", + // + deprecated: false, borrowingDisabled: true, borrowingDisabledReason: "AO airdrop.", + // + get oTicker() { + return `o${this.cleanTicker.toUpperCase()}`; + }, + get ticker() { + return this.cleanTicker.toUpperCase(); + }, + get baseDenomination() { + return this.denomination; + }, + controllerAddress, }, WUSDC: { name: "Wrapped USD Circle", - icon: "iNYk0bDqUiH0eLT2rbYjYAI5i126R4ye8iAZb55IaIM", - ticker: "WUSDC", - address: "7zH9dlMNoxprab9loshv3Y7WG45DOny_Vrq9KrXObdQ", - oTicker: "oWUSDC", - oAddress: "4MW7uLFtttSLWM-yWEqV9TGD6fSIDrqa4lbTgYL2qHg", - controllerAddress, cleanTicker: "wUSDC", - denomination: BigInt(6), collateralEnabled: true, - baseDenomination: BigInt(6), - deprecated: false, + address: "7zH9dlMNoxprab9loshv3Y7WG45DOny_Vrq9KrXObdQ", + icon: "iNYk0bDqUiH0eLT2rbYjYAI5i126R4ye8iAZb55IaIM", + denomination: BigInt(6), + // + oAddress: "4MW7uLFtttSLWM-yWEqV9TGD6fSIDrqa4lbTgYL2qHg", oIcon: "7EEISJIzxC-3RPhgvRc-lAZnP7st1b79_ER4Sc5P_MU", + // + deprecated: false, borrowingDisabled: false, borrowingDisabledReason: "", + // + get oTicker() { + return `o${this.cleanTicker.toUpperCase()}`; + }, + get ticker() { + return this.cleanTicker.toUpperCase(); + }, + get baseDenomination() { + return this.denomination; + }, + controllerAddress, }, WUSDT: { name: "Wrapped USD Tether", - icon: "JaxupVYerLRZWLd32llz_3CG8sCQaNhn2hAWm51U_7s", - ticker: "WUSDT", - address: "7j3jUyFpTuepg_uu_sJnwLE6KiTVuA9cLrkfOp2MFlo", - oTicker: "oWUSDT", - oAddress: "9B9J1O5FDoMsFZGJUSOa6TwivsH7LYIfiaizPn7fUHs", - controllerAddress, cleanTicker: "wUSDT", - denomination: BigInt(18), collateralEnabled: true, - baseDenomination: BigInt(18), - deprecated: false, + address: "7j3jUyFpTuepg_uu_sJnwLE6KiTVuA9cLrkfOp2MFlo", + icon: "JaxupVYerLRZWLd32llz_3CG8sCQaNhn2hAWm51U_7s", + denomination: BigInt(18), + // + oAddress: "9B9J1O5FDoMsFZGJUSOa6TwivsH7LYIfiaizPn7fUHs", oIcon: "bkAnKOF4NhqPHnccDhPyOzBws42zNE-u9WtxCPdaABU", + // + deprecated: false, borrowingDisabled: false, borrowingDisabledReason: "", + // + get oTicker() { + return `o${this.cleanTicker.toUpperCase()}`; + }, + get ticker() { + return this.cleanTicker.toUpperCase(); + }, + get baseDenomination() { + return this.denomination; + }, + controllerAddress, }, WETH: { name: "Wrapped Ethereum", - icon: "Bi7iqzLQXN-wVD3nM8TYGfTI9g7HgGtiD0XuruoQTJk", - ticker: "WETH", - address: "cBgS-V_yGhOe9P1wCIuNSgDA_JS8l4sE5iFcPTr0TD0", - oTicker: "oWETH", - oAddress: "rNa0hdxEZjz_TAUoI85OcPRul_BzoS6Py_3vamJKpr4", - controllerAddress, cleanTicker: "wETH", - denomination: BigInt(18), collateralEnabled: true, - baseDenomination: BigInt(18), - deprecated: false, + address: "cBgS-V_yGhOe9P1wCIuNSgDA_JS8l4sE5iFcPTr0TD0", + icon: "Bi7iqzLQXN-wVD3nM8TYGfTI9g7HgGtiD0XuruoQTJk", + denomination: BigInt(18), + // + oAddress: "rNa0hdxEZjz_TAUoI85OcPRul_BzoS6Py_3vamJKpr4", oIcon: "z1nnBgzGpt-eXHrjD5A9KrQX6dK8E1ONDuBIqB94VTA", + // + deprecated: false, borrowingDisabled: false, borrowingDisabledReason: "", + // + get oTicker() { + return `o${this.cleanTicker.toUpperCase()}`; + }, + get ticker() { + return this.cleanTicker.toUpperCase(); + }, + get baseDenomination() { + return this.denomination; + }, + controllerAddress, }, USDA: { name: "Astro USD", - icon: "seXozJrsP0OgI0gvAnr8zmfxiHHb5iSlI9wMI8SdamE", - ticker: "USDA", - address: "FBt9A5GA_KXMMSxA2DJ0xZbAq8sLLU2ak-YJe9zDvg8", - oTicker: "oUSDA", - oAddress: "qX9KiT3p_KnV5RE7Dddghwc0uC5t-kvsVgjq2iLAi8s", - controllerAddress, cleanTicker: "USDA", - denomination: BigInt(12), collateralEnabled: false, - baseDenomination: BigInt(12), - deprecated: false, + address: "FBt9A5GA_KXMMSxA2DJ0xZbAq8sLLU2ak-YJe9zDvg8", + icon: "seXozJrsP0OgI0gvAnr8zmfxiHHb5iSlI9wMI8SdamE", + denomination: BigInt(12), + // + oAddress: "qX9KiT3p_KnV5RE7Dddghwc0uC5t-kvsVgjq2iLAi8s", oIcon: "p7iMD3X6iGYQ5Qw7dPU4ER7w678wEt2epwSA8t6-hu8", + // + deprecated: false, borrowingDisabled: false, borrowingDisabledReason: "", + // + get oTicker() { + return `o${this.cleanTicker.toUpperCase()}`; + }, + get ticker() { + return this.cleanTicker.toUpperCase(); + }, + get baseDenomination() { + return this.denomination; + }, + controllerAddress, }, VAR: { name: "Vento Arweave", - icon: "XQKXtuxDGDn13z0JBqYvbkNXPu3Y3aE1WaK2XftQ3cA", - ticker: "VAR", - address: "y-p7CPhs6JMUStAuE4KeTnMXN7qYBvEi2hiBFk8ZhjM", - oTicker: "oVAR", - oAddress: "TYaFOOJUwUjSCTi_CFNZXYAEt4SYTx-HNjrV-cCmwNQ", - controllerAddress, cleanTicker: "vAR", + collateralEnabled: true, + address: "y-p7CPhs6JMUStAuE4KeTnMXN7qYBvEi2hiBFk8ZhjM", + icon: "XQKXtuxDGDn13z0JBqYvbkNXPu3Y3aE1WaK2XftQ3cA", denomination: BigInt(12), - collateralEnabled: false, - baseDenomination: BigInt(12), - deprecated: false, + // + oAddress: "TYaFOOJUwUjSCTi_CFNZXYAEt4SYTx-HNjrV-cCmwNQ", oIcon: "kjybk2--iRY9vxo2eQtVu52vbT8iWJzwBslhGPtTMeM", + // + deprecated: false, borrowingDisabled: false, borrowingDisabledReason: "", + // + get oTicker() { + return `o${this.cleanTicker.toUpperCase()}`; + }, + get ticker() { + return this.cleanTicker.toUpperCase(); + }, + get baseDenomination() { + return this.denomination; + }, + controllerAddress, }, VUSDC: { name: "Vento USD Circle", - icon: "DbT_EMed2vx4MR7N03YJYLSNeNBvuSgIzjybw8TOqMg", - ticker: "VUSDC", + cleanTicker: "vUSDC", + collateralEnabled: true, address: "cxkFiGP89fEKOvbvl9SLs1lEaw0L-DWJiqQOuDPeDG8", - oTicker: "oVUSDC", + icon: "DbT_EMed2vx4MR7N03YJYLSNeNBvuSgIzjybw8TOqMg", + denomination: BigInt(6), + // oAddress: "aKt8ZDDT43-3vwgqSEKx6aWd_3GA1paePP9EAOf3zcc", + oIcon: "7EEISJIzxC-3RPhgvRc-lAZnP7st1b79_ER4Sc5P_MU", + // + deprecated: false, + borrowingDisabled: false, + borrowingDisabledReason: "", + // + get oTicker() { + return `o${this.cleanTicker.toUpperCase()}`; + }, + get ticker() { + return this.cleanTicker.toUpperCase(); + }, + get baseDenomination() { + return this.denomination; + }, controllerAddress, - cleanTicker: "vUSDC", - denomination: BigInt(6), - collateralEnabled: false, - baseDenomination: BigInt(6), + }, + VDAI: { + name: "Vento DAI", + cleanTicker: "vDAI", + collateralEnabled: true, + address: "Q5Qk5W_AOUou2nRu1RlEpfr8yzKmWJ98tQb8QEyYqx4", + icon: "0hn3-PiE45LzIr9fYxSEXrQu8qk9arXt-FsVoN98grw", + denomination: BigInt(18), + // + oAddress: "UNj2195zpcrRcHdxWXq0zfsUMybbpfyFpyFpyaaLm03dW0", + oIcon: "rCEwGR-OYAft5mAYqMOur7icDpxNCttyAuRqwJUjKSM", + // deprecated: false, - oIcon: "7EEISJIzxC-3RPhgvRc-lAZnP7st1b79_ER4Sc5P_MU", borrowingDisabled: false, borrowingDisabledReason: "", + // + get oTicker() { + return `o${this.cleanTicker.toUpperCase()}`; + }, + get ticker() { + return this.cleanTicker.toUpperCase(); + }, + get baseDenomination() { + return this.denomination; + }, + controllerAddress, + }, + VETH: { + name: "Vento Ethereum", + cleanTicker: "vETH", + collateralEnabled: true, + address: "SGUZMZ1toA4k5wlDNyDtHQThf1SEAOLNwiE8TzsnSgw", + icon: "zAQeInmLoCwtHfWzAebYWyrdb8Yh-s5H8_b4Ad2egSc", + denomination: BigInt(18), + // + oAddress: "Sipm0KlrxYR7Pr_sKgedjIt1yzEQ0R6Yfkkuhd7Q0Og", + oIcon: "z1nnBgzGpt-eXHrjD5A9KrQX6dK8E1ONDuBIqB94VTA", + // + deprecated: false, + borrowingDisabled: false, + borrowingDisabledReason: "", + // + get oTicker() { + return `o${this.cleanTicker.toUpperCase()}`; + }, + get ticker() { + return this.cleanTicker.toUpperCase(); + }, + get baseDenomination() { + return this.denomination; + }, + controllerAddress, }, }; diff --git a/src/functions/liquidations/getLiquidations.ts b/src/functions/liquidations/getLiquidations.ts index c4bcade..52497c1 100644 --- a/src/functions/liquidations/getLiquidations.ts +++ b/src/functions/liquidations/getLiquidations.ts @@ -61,12 +61,15 @@ export async function getLiquidations( const tokensList = Object.keys(tokens); // Make a request to RedStone oracle process for prices (same used onchain) - const redstonePriceFeedRes = await getData({ - Owner: controllerAddress, - Target: redstoneOracleAddress, - Action: "v2.Request-Latest-Data", - Tickers: JSON.stringify(collateralEnabledTickers.map(convertTicker)), - }, config); + const redstonePriceFeedRes = await getData( + { + Owner: controllerAddress, + Target: redstoneOracleAddress, + Action: "v2.Request-Latest-Data", + Tickers: JSON.stringify(collateralEnabledTickers.map(convertTicker)), + }, + config, + ); // add dry run await to not get rate limited await dryRunAwait(1); @@ -114,10 +117,13 @@ export async function getLiquidations( } // get discovered liquidations - const auctionsRes = await getData({ - Target: controllerAddress, - Action: "Get-Auctions", - }, config); + const auctionsRes = await getData( + { + Target: controllerAddress, + Action: "Get-Auctions", + }, + config, + ); // add dry run await to not get rate limited await dryRunAwait(1); diff --git a/src/functions/liquidations/getLiquidationsMap.ts b/src/functions/liquidations/getLiquidationsMap.ts index 5825772..5ee7392 100644 --- a/src/functions/liquidations/getLiquidationsMap.ts +++ b/src/functions/liquidations/getLiquidationsMap.ts @@ -35,18 +35,23 @@ export interface GetLiquidationsMapRes { remainingCapacity: number; } -export async function getLiquidationsMap(config?: Services): Promise { +export async function getLiquidationsMap( + config?: Services, +): Promise { try { // Get list of tokens to process const tokensList = Object.keys(tokens); // Make a request to RedStone oracle process for prices (same used onchain) - const redstonePriceFeedRes = await getData({ - Owner: controllerAddress, - Target: redstoneOracleAddress, - Action: "v2.Request-Latest-Data", - Tickers: JSON.stringify(collateralEnabledTickers.map(convertTicker)), - }, config); + const redstonePriceFeedRes = await getData( + { + Owner: controllerAddress, + Target: redstoneOracleAddress, + Action: "v2.Request-Latest-Data", + Tickers: JSON.stringify(collateralEnabledTickers.map(convertTicker)), + }, + config, + ); // add dry run await to not get rate limited await dryRunAwait(1); diff --git a/src/functions/oTokenData/getBalances.ts b/src/functions/oTokenData/getBalances.ts index 408798d..d5a3602 100644 --- a/src/functions/oTokenData/getBalances.ts +++ b/src/functions/oTokenData/getBalances.ts @@ -8,9 +8,10 @@ export interface GetBalances { export type GetBalancesRes = Record; -export async function getBalances({ - token, -}: GetBalances, config?: Services): Promise { +export async function getBalances( + { token }: GetBalances, + config?: Services, +): Promise { try { if (!token) { throw new Error("Please specify a token."); @@ -18,10 +19,13 @@ export async function getBalances({ const { oTokenAddress } = tokenInput(token); - const res = await getData({ - Target: oTokenAddress, - Action: "Balances", - }, config); + const res = await getData( + { + Target: oTokenAddress, + Action: "Balances", + }, + config, + ); if (!res.Messages || !res.Messages[0] || !res.Messages[0].Data) { throw new Error("Invalid response format from getData"); diff --git a/src/functions/oTokenData/getBorrowAPR.ts b/src/functions/oTokenData/getBorrowAPR.ts index a72c076..acd7302 100644 --- a/src/functions/oTokenData/getBorrowAPR.ts +++ b/src/functions/oTokenData/getBorrowAPR.ts @@ -8,9 +8,10 @@ export interface GetBorrowAPR { export type GetBorrowAPRRes = number; -export async function getBorrowAPR({ - token, -}: GetBorrowAPR, config?: Services): Promise { +export async function getBorrowAPR( + { token }: GetBorrowAPR, + config?: Services, +): Promise { try { if (!token) { throw new Error("Please specify a token."); @@ -18,10 +19,13 @@ export async function getBorrowAPR({ const { oTokenAddress } = tokenInput(token); - const checkDataRes = await getData({ - Target: oTokenAddress, - Action: "Get-APR", - }, config); + const checkDataRes = await getData( + { + Target: oTokenAddress, + Action: "Get-APR", + }, + config, + ); const tags = checkDataRes.Messages[0].Tags; const aprResponse: { diff --git a/src/functions/oTokenData/getCooldown.ts b/src/functions/oTokenData/getCooldown.ts index 4e24f18..b08f3ef 100644 --- a/src/functions/oTokenData/getCooldown.ts +++ b/src/functions/oTokenData/getCooldown.ts @@ -15,20 +15,23 @@ export type GetCooldownRes = remainingBlocks: number; }; -export async function getCooldown({ - recipient, - token, -}: GetCooldown, config?: Services): Promise { +export async function getCooldown( + { recipient, token }: GetCooldown, + config?: Services, +): Promise { if (!recipient) throw new Error("Please specify a recipient"); if (!token) throw new Error("Please specify a token address"); const { oTokenAddress } = tokenInput(token); - const cooldownRes = await getData({ - Target: oTokenAddress, - Owner: recipient, - Action: "Is-Cooldown", - }, config); + const cooldownRes = await getData( + { + Target: oTokenAddress, + Owner: recipient, + Action: "Is-Cooldown", + }, + config, + ); if (!cooldownRes?.Messages?.[0]?.Tags) { return { onCooldown: false }; diff --git a/src/functions/oTokenData/getExchangeRate.ts b/src/functions/oTokenData/getExchangeRate.ts index 50f74d0..b1b098c 100644 --- a/src/functions/oTokenData/getExchangeRate.ts +++ b/src/functions/oTokenData/getExchangeRate.ts @@ -9,10 +9,10 @@ export interface GetExchangeRate { export type GetExchangeRateRes = BigInt; -export async function getExchangeRate({ - token, - quantity, -}: GetExchangeRate, config?: Services): Promise { +export async function getExchangeRate( + { token, quantity }: GetExchangeRate, + config?: Services, +): Promise { try { if (!token || !quantity) { throw new Error("Please specify a token and quantity."); @@ -20,11 +20,14 @@ export async function getExchangeRate({ const { oTokenAddress } = tokenInput(token); - const message = await getData({ - Target: oTokenAddress, - Action: "Exchange-Rate-Current", - ...(quantity && { Quantity: quantity.toString() }), - }, config); + const message = await getData( + { + Target: oTokenAddress, + Action: "Exchange-Rate-Current", + ...(quantity && { Quantity: quantity.toString() }), + }, + config, + ); const valueTag = message.Messages[0].Tags.find( (tag: { name: string; value: string }) => tag.name === "Value", diff --git a/src/functions/oTokenData/getGlobalPosition.ts b/src/functions/oTokenData/getGlobalPosition.ts index 57cb682..99f9690 100644 --- a/src/functions/oTokenData/getGlobalPosition.ts +++ b/src/functions/oTokenData/getGlobalPosition.ts @@ -26,9 +26,10 @@ export interface GetGlobalPosition { walletAddress: string; } -export async function getGlobalPosition({ - walletAddress, -}: GetGlobalPosition, config?: Services): Promise { +export async function getGlobalPosition( + { walletAddress }: GetGlobalPosition, + config?: Services, +): Promise { try { if (!walletAddress) { throw new Error("Please specify a wallet address."); @@ -38,12 +39,15 @@ export async function getGlobalPosition({ const tokensList = Object.keys(tokens); // Make a request to RedStone oracle for prices - const redstonePriceFeedRes = await getData({ - Owner: controllerAddress, - Target: redstoneOracleAddress, - Action: "v2.Request-Latest-Data", - Tickers: JSON.stringify(collateralEnabledTickers.map(convertTicker)), - }, config); + const redstonePriceFeedRes = await getData( + { + Owner: controllerAddress, + Target: redstoneOracleAddress, + Action: "v2.Request-Latest-Data", + Tickers: JSON.stringify(collateralEnabledTickers.map(convertTicker)), + }, + config, + ); // add dry run await to not get rate limited await dryRunAwait(1); @@ -59,10 +63,13 @@ export async function getGlobalPosition({ for (let attempt = 1; attempt <= maxRetries; attempt++) { try { - const position = await getPosition({ - token, - recipient: walletAddress, - }, config); + const position = await getPosition( + { + token, + recipient: walletAddress, + }, + config, + ); // add dry run await to not get rate limited await dryRunAwait(1); diff --git a/src/functions/oTokenData/getInfo.ts b/src/functions/oTokenData/getInfo.ts index f5d84ef..3d41dc6 100644 --- a/src/functions/oTokenData/getInfo.ts +++ b/src/functions/oTokenData/getInfo.ts @@ -35,7 +35,10 @@ interface Tag { value: string; } -export async function getInfo({ token }: GetInfo, config?: Services): Promise { +export async function getInfo( + { token }: GetInfo, + config?: Services, +): Promise { try { if (!token) { throw new Error("Please specify a token."); @@ -43,10 +46,13 @@ export async function getInfo({ token }: GetInfo, config?: Services): Promise [ diff --git a/src/functions/oTokenData/getPosition.ts b/src/functions/oTokenData/getPosition.ts index 1130ed7..9a853b6 100644 --- a/src/functions/oTokenData/getPosition.ts +++ b/src/functions/oTokenData/getPosition.ts @@ -22,10 +22,10 @@ interface Tag { value: string; } -export async function getPosition({ - token, - recipient, -}: GetPosition, config?: Services): Promise { +export async function getPosition( + { token, recipient }: GetPosition, + config?: Services, +): Promise { try { if (!token || !recipient) { throw new Error("Please specify a token and recipient."); @@ -33,11 +33,14 @@ export async function getPosition({ const { oTokenAddress } = tokenInput(token); - const res = await getData({ - Target: oTokenAddress, - Action: "Position", - ...(recipient && { Recipient: recipient }), - }, config); + const res = await getData( + { + Target: oTokenAddress, + Action: "Position", + ...(recipient && { Recipient: recipient }), + }, + config, + ); const tagsObject = Object.fromEntries( res.Messages[0].Tags.map((tag: Tag) => [tag.name, tag.value]), diff --git a/src/functions/oTokenData/getSupplyAPR.ts b/src/functions/oTokenData/getSupplyAPR.ts index 92572a9..8cafbe9 100644 --- a/src/functions/oTokenData/getSupplyAPR.ts +++ b/src/functions/oTokenData/getSupplyAPR.ts @@ -13,11 +13,10 @@ export interface GetSupplyAPR { export type GetSupplyAPRRes = number; -export async function getSupplyAPR({ - token, - getInfoRes, - getBorrowAPRRes, -}: GetSupplyAPR, config?: Services): Promise { +export async function getSupplyAPR( + { token, getInfoRes, getBorrowAPRRes }: GetSupplyAPR, + config?: Services, +): Promise { try { if (!token) { throw new Error("Please specify a token."); diff --git a/src/functions/protocolData/getAllPositions.ts b/src/functions/protocolData/getAllPositions.ts index 77cfa90..e6bec24 100644 --- a/src/functions/protocolData/getAllPositions.ts +++ b/src/functions/protocolData/getAllPositions.ts @@ -15,9 +15,10 @@ export interface GetAllPositionsRes { }; } -export async function getAllPositions({ - token, -}: GetAllPositions, config?: Services): Promise { +export async function getAllPositions( + { token }: GetAllPositions, + config?: Services, +): Promise { try { if (!token) { throw new Error("Please specify a token."); @@ -25,10 +26,13 @@ export async function getAllPositions({ const { oTokenAddress } = tokenInput(token); - const res = await getData({ - Target: oTokenAddress, - Action: "Positions", - }, config); + const res = await getData( + { + Target: oTokenAddress, + Action: "Positions", + }, + config, + ); const allPositions = JSON.parse(res.Messages[0].Data); diff --git a/src/functions/protocolData/getHistoricalAPR.ts b/src/functions/protocolData/getHistoricalAPR.ts index b85f2bc..1435699 100644 --- a/src/functions/protocolData/getHistoricalAPR.ts +++ b/src/functions/protocolData/getHistoricalAPR.ts @@ -15,10 +15,10 @@ interface APR { timestamp: number; } -export async function getHistoricalAPR({ - token, - fillGaps = true, -}: GetHistoricalAPR, config?: Services): Promise { +export async function getHistoricalAPR( + { token, fillGaps = true }: GetHistoricalAPR, + config?: Services, +): Promise { try { if (!token) { throw new Error("Please specify a token."); @@ -26,12 +26,15 @@ export async function getHistoricalAPR({ const { oTokenAddress } = tokenInput(token); - const response = await getData({ - Target: APRAgentAddress, - Action: "Get-Data", - Token: oTokenAddress, - "Fill-Gaps": fillGaps.toString(), - }, config); + const response = await getData( + { + Target: APRAgentAddress, + Action: "Get-Data", + Token: oTokenAddress, + "Fill-Gaps": fillGaps.toString(), + }, + config, + ); if (!response.Messages?.[0]?.Data) { const errorTag = response.Messages[0].Tags.find( diff --git a/src/functions/utils/getPrice.ts b/src/functions/utils/getPrice.ts index 4748c7d..612d5ca 100644 --- a/src/functions/utils/getPrice.ts +++ b/src/functions/utils/getPrice.ts @@ -14,18 +14,24 @@ export interface GetPrice { export type GetPriceRes = number; -export async function getPrice({ token }: GetPrice, config?: Services): Promise { +export async function getPrice( + { token }: GetPrice, + config?: Services, +): Promise { if (!token) { throw new Error("Please specify a token."); } try { - const redstonePriceFeedRes = await getData({ - Owner: controllerAddress, - Target: redstoneOracleAddress, - Action: "v2.Request-Latest-Data", - Tickers: JSON.stringify([convertTicker(token)]), - }, config); + const redstonePriceFeedRes = await getData( + { + Owner: controllerAddress, + Target: redstoneOracleAddress, + Action: "v2.Request-Latest-Data", + Tickers: JSON.stringify([convertTicker(token)]), + }, + config, + ); const prices: RedstonePrices = JSON.parse( redstonePriceFeedRes.Messages[0].Data, diff --git a/tests.ts b/tests.ts index d254251..696dec7 100644 --- a/tests.ts +++ b/tests.ts @@ -140,7 +140,7 @@ const walletAddress = await ownerToAddress(JWK.n); //------------------------------- // const getInfo = await client.getInfo({ -// token: "QAR", +// token: "WUSDC", // }); // console.log(getInfo);