y.prices.utils package
Submodules
y.prices.utils.buckets module
- ASyncFunctiony.prices.utils.buckets.check_bucket(token: str | hexbytes.main.HexBytes | AnyAddress | brownie.convert.datatypes.EthAddress | brownie.network.contract.Contract | int) str [source]
Since check_bucket is an
ASyncFunctionSyncDefault
, you can optionally pass sync=False or asynchronous=True to force it to return a coroutine. Without either kwarg, it will run synchronously.- Parameters:
token (str | HexBytes | AnyAddress | EthAddress | Contract | int)
- Return type:
y.prices.utils.sense_check module
This module contains utils for sense checking prices returned from the library.
A user will not need to use anything here.
Developers can skip the sense check for additional tokens by adding them to the
ACCEPTABLE_HIGH_PRICES
mapping.
- async y.prices.utils.sense_check.sense_check(token_address, block, price)[source]
Performs a sense check on the given token price and logs a warning if it is unexpectedly high.
This is just to help catch potential bugs before they cause issues.
- Parameters:
Example
>>> await sense_check("0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", 14_000_000, 123450000.00) unusually high price ($123450000.00) returned for USDC "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48" on Mainnet block 14000000. This does not necessarily mean that the price is wrong, but you may want to validate the price for yourself before proceeding.
Note
This function checks if the price is within acceptable ranges based on the token type and network. It will not log for various special cases such as ETH-like tokens, BTC-like tokens, LP tokens, and vault tokens where the underlying is exempt from the sense check.
- y.prices.utils.sense_check.ACCEPTABLE_HIGH_PRICES = ['0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE', '0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0', '0xA3D87FffcE63B53E0d54fAa1cc983B7eB0b74A9c', '0xaA17A236F2bAdc98DDc0Cf999AbB47D47Fc0A6Cf', '0x53a901d48795C58f485cBB38df08FA96a24669D5', '0xC4C319E2D4d66CcA4464C0c2B32c9Bd23ebe784e', '0x06325440D014e39736583c165C2963BA99fAf14E', '0x5e74C9036fb86BD7eCdcb084a0673EFc32eA31cb', '0xae78736Cd615f374D3085123A210448E74Fc6393', '0xE95A203B1a91a908F9B9CE46459d101078c2c3cb', '0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84', '0x9559Aaa82d9649C7A7b220E7c461d2E74c9a3593', '0x836A808d4828586A69364065A1e064609F5078c7', '0xc3D088842DcF02C13699F936BB83DFBBc6f721Ab', '0xC1330aCBbcE97cb9695B7ee161c0F95B875a8b0F', '0x5E8422345238F34275888049021821E8E08CAa1f', '0x856c4Efb76C1D1AE02e20CEB03A2A6a08b0b8dC3', '0xE72B141DF173b999AE7c1aDcbF60Cc9833Ce56a8', '0x3d1E5Cf16077F349e999d6b21A4f646e83Cd90c5', '0x0100546F2cD4C9D97f798fFC9755E47865FF7Ee6', '0xBe9895146f7AF43049ca1c1AE358B0541Ea49704', '0x7C07F7aBe10CE8e33DC6C5aD68FE033085256A84', '0xA35b1B31Ce002FBF2058D22F30f95D405200A15b', '0x64351fC9810aDAd17A690E4e1717Df5e7e085160', '0x821A278dFff762c76410264303F25bF42e195C0C', '0xa2E3356610840701BDf5611a53974510Ae27E2e1', '0x1BED97CBC3c24A4fb5C069C6E311a967386131f7', '0x3A65cbaebBFecbeA5D0CB523ab56fDbda7fF9aAA', '0x6951bDC4734b9f7F3E1B74afeBC670c736A0EDB6', '0xf1C9acDc66974dFB6dEcB12aA385b9cD01190E38', '0xEB4C2781e4ebA804CE9a9803C67d0893436bB27D', '0xfE18be6b3Bd88A2D2A7f928d00292E7a9963CfC6', '0x49849C98ae39Fff122806C06791Fa73784FB3675', '0x075b1bb99792c9E1041bA13afEf80C91a1e70fB3', '0xb19059ebb43466C323583928285a49f558E572Fd', '0x64eda51d3Ad40D56b9dFc5554E06F94e1Dd786Fd', '0xDE5331AC4B3630f94853Ff322B66407e0D6331E8', '0x410e3E86ef427e30B9235497143881f717d93c2A', '0x2fE94ea3d5d4a175184081439753DE15AeF9d614', '0x0327112423F3A68efdF1fcF402F6c5CB9f7C33fd', '0x3212b29E33587A00FB1C83346f5dBFA69A458923', '0x5228a22e72ccC52d415EcFd199F99D0665E7733b', '0xFbdCA68601f835b27790D98bbb8eC7f05FDEaA9B', '0x0316EB71485b0Ab14103307bf65a021042c6d380', '0x9BE89D2a4cd102D8Fecc6BF9dA793be995C22541', '0x8064d9Ae6cDf087b1bcd5BDf3531bD5d8C537a68', '0x8dAEBADE922dF735c38C80C7eBD708Af50815fAa', '0x8751D4196027d4e6DA63716fA7786B5174F04C15', '0x66eFF5221ca926636224650Fd3B9c497FF828F7D', '0x18084fbA666a33d37592fA2633fD49a74DD93a88', '0x45804880De22913dAFE09f4980848ECE6EcbAf78', '0x4922a015c4407F87432B179bb209e125432E4a2A', '0x0bc529c00C6401aEF6D220BE8C6Ea1667F6Ad93e', '0x41252E8691e964f7DE35156B68493bAb6797a275', '0x1cEB5cB57C4D4E2b2433641b95Dd330A33185A44', '0xD5525D397898e5502075Ea5E830d8914f6F0affe', '0x9f8F72aA9304c8B593d555F12eF6589cC3A579A2', '0x3A283D9c08E8b55966afb64C515f5143cf907611', '0x23B608675a2B2fB1890d3ABBd85c5775c51691d5', '0xcA3d75aC011BF5aD07a98d02f18225F9bD9A6BDF', '0xc4AD29ba4B3c580e6D59105FFf484999997675Ff', '0xd075e95423C5c4BA1E122CaE0f4CdFA19b82881b', '0xe9F84dE264E91529aF07Fa2C746e934397810334', '0xa1d0E215a23d7030842FC67cE582a6aFa3CCaB83', '0x0fe629d1E84E171f8fF0C1Ded2Cc2221Caa48a3f', '0x5F0E628B693018f639D10e4A4F59BD4d8B2B6B44', '0xdBdb4d16EdA451D0503b854CF79D55697F90c8DF', '0x3aaDA3e213aBf8529606924d8D1c55CbDc70Bf74', '0x892A6f9dF0147e5f079b0993F486F9acA3c87881', '0x0ab87046fBb341D058F17CBC4c1133F25a20a52f', '0x97983236bE88107Cc8998733Ef73D8d969c52E37', '0x68749665FF8D2d112Fa859AA293F07A622782F38', '0xf5f5B97624542D72A9E06f04804Bf81baA15e2B4', '0x7F86Bf177Dd4F3494b841a37e810A34dD56c829B', '0x2889302a794dA87fBF1D6Db415C1492194663D13', '0xBfAb6FA95E0091ed66058ad493189D2cB29385E6', '0x641927E970222B10b2E8CDBC96b1B4F427316f16', '0x9cea2eD9e47059260C97d697f82b8A14EfA61EA5', '0x269616D549D7e8Eaa82DFb17028d0B212D11232A', '0x69BbE2FA02b4D90A944fF328663667DC32786385', '0xD70240Dd62F4ea9a6A2416e0073D72139489d2AA', '0x114f1388fAB456c4bA31B1850b244Eedcd024136', '0xEA47B64e1BFCCb773A0420247C0aa0a3C1D2E5C5', '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2', '0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599']
List of tokens addresses for which high prices are acceptable. Nothing will be logged for tokens in this list.
y.prices.utils.ypriceapi module
- async y.prices.utils.ypriceapi.get_price(token, block)[source]
- Parameters:
token (str | HexBytes | AnyAddress | EthAddress)
block (int | BlockNumber | None)
- Return type:
UsdPrice | None
- y.prices.utils.ypriceapi.get_retry_header(x)
- async y.prices.utils.ypriceapi.read_response(response, token=None, block=None)[source]
- Parameters:
response (ClientResponse)
token (str | HexBytes | AnyAddress | EthAddress | None)
block (int | BlockNumber | None)
- Return type:
Any | None