# How to get the exchange rate between ust and aust on smart contract

**URL:** <https://forum.anchorprotocol.com/t/how-to-get-the-exchange-rate-between-ust-and-aust-on-smart-contract/2066>\
**Category:** Miscellaneous\
**Created:** [January 6, 2022, 5:17pm UTC](https://forum.anchorprotocol.com/t/how-to-get-the-exchange-rate-between-ust-and-aust-on-smart-contract/2066 "2022-01-06T17:17:08Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![jameszook](https://avatars.discourse-cdn.com/v4/letter/j/fbc32d/32.png) [@jameszook](https://forum.anchorprotocol.com/u/jameszook)\
**Post date:** [January 6, 2022, 5:17pm UTC](https://forum.anchorprotocol.com/t/how-to-get-the-exchange-rate-between-ust-and-aust-on-smart-contract/2066/1 "2022-01-06T17:17:08Z")

</div>

I am senior blockchain developer.  
I am developing the invest platform on terra chain.  
I want to deposit the all backed money to anchor protocol to earn.  
How to get the exchange rate between Ust and aUst on smart contract.  
or using terra.js.  
Thanks.  
James

---

<div class="post-metadata">

**Author:** ![saad.najafi](https://avatars.discourse-cdn.com/v4/letter/s/b3f665/32.png) [@saad.najafi](https://forum.anchorprotocol.com/u/saad.najafi)\
**Post date:** [January 10, 2022, 8:59pm UTC](https://forum.anchorprotocol.com/t/how-to-get-the-exchange-rate-between-ust-and-aust-on-smart-contract/2066/2 "2022-01-10T20:59:45Z")

</div>

To get the exchange rate of UST and aUst on a smart contract you should use a `smart` query from cosmwasm by sending this query to the market contract

> <https://github.com/Anchor-Protocol/money-market-contracts/blob/c85c0b8e4f7fd192504f15d7741e19da6a850f71/packages/moneymarket/src/market.rs#L108>

and the response is going to be this

> <https://github.com/Anchor-Protocol/money-market-contracts/blob/c85c0b8e4f7fd192504f15d7741e19da6a850f71/packages/moneymarket/src/market.rs#L152>

using terra.js you need to send `epoch_state` query using terra.js like following

`lcd.wasm.contractQuery($MARKET_ADDRESS, {epoch_state:{}})`

here is an API to call as well:  
[https://lcd.terra.dev/wasm/contracts/terra1sepfj7s0aeg5967uxnfk4thzlerrsktkpelm5s/store?query\_msg={"epoch\_state":{}](https://lcd.terra.dev/wasm/contracts/terra1sepfj7s0aeg5967uxnfk4thzlerrsktkpelm5s/store?query_msg=%7B%22epoch_state%22:%7B%7D)}

---

<div class="post-metadata">

**Author:** ![jameszook](https://avatars.discourse-cdn.com/v4/letter/j/fbc32d/32.png) [@jameszook](https://forum.anchorprotocol.com/u/jameszook)\
**Post date:** [February 8, 2022, 2:24am UTC](https://forum.anchorprotocol.com/t/how-to-get-the-exchange-rate-between-ust-and-aust-on-smart-contract/2066/3 "2022-02-08T02:24:10Z")

</div>

Thanks a lot.  
Regards

---

<div class="post-metadata">

**Author:** ![jameszook](https://avatars.discourse-cdn.com/v4/letter/j/fbc32d/32.png) [@jameszook](https://forum.anchorprotocol.com/u/jameszook)\
**Post date:** [February 8, 2022, 2:25am UTC](https://forum.anchorprotocol.com/t/how-to-get-the-exchange-rate-between-ust-and-aust-on-smart-contract/2066/4 "2022-02-08T02:25:08Z")

</div>

one more question.  
Can I do to yield from Anchor by depositing?

---

<div class="post-metadata">

**Author:** ![coin\_seeker](https://avatars.discourse-cdn.com/v4/letter/c/b19c9b/32.png) [@coin\_seeker](https://forum.anchorprotocol.com/u/coin_seeker)\
**Post date:** [February 8, 2022, 11:44am UTC](https://forum.anchorprotocol.com/t/how-to-get-the-exchange-rate-between-ust-and-aust-on-smart-contract/2066/5 "2022-02-08T11:44:38Z")

</div>

are you real dev? just check github manually. find the anchor SDK

---

<div class="post-metadata">

**Author:** ![jameszook](https://avatars.discourse-cdn.com/v4/letter/j/fbc32d/32.png) [@jameszook](https://forum.anchorprotocol.com/u/jameszook)\
**Post date:** [February 8, 2022, 12:13pm UTC](https://forum.anchorprotocol.com/t/how-to-get-the-exchange-rate-between-ust-and-aust-on-smart-contract/2066/6 "2022-02-08T12:13:13Z")

</div>

Thanks  
I already developed on smart contract to deposit to Anchor.  
And I got the aUST from Anchor.  
But someone told me that he received the some UST everyday from Anchor by depositing .  
Is it right?  
Please let me know.

---

<div class="post-metadata">

**Author:** ![jameszook](https://avatars.discourse-cdn.com/v4/letter/j/fbc32d/32.png) [@jameszook](https://forum.anchorprotocol.com/u/jameszook)\
**Post date:** [February 8, 2022, 12:14pm UTC](https://forum.anchorprotocol.com/t/how-to-get-the-exchange-rate-between-ust-and-aust-on-smart-contract/2066/7 "2022-02-08T12:14:49Z")

</div>

You can check my work with rust cosmwasm.

> **[GitHub - alenzer/WEFund](https://github.com/alenzer/WEFUND)**
>
> Contribute to alenzer/WEFund development by creating an account on GitHub.
