### Example: Get Start Epoch Time Source: https://github.com/curvedocs/curve-docs/blob/master/docs/curve_dao/crv-token.md This interactive example fetches the start timestamp of the current mining epoch directly on-chain. ```shell >>> CRV.start_epoch_time() ``` -------------------------------- ### Get Total Supply Example (Shell) Source: https://github.com/curvedocs/curve-docs/blob/master/docs/stableswap-exchange/stableswap-ng/pools/metapool.md Example of how to call the `totalSupply` function to get the total supply of LP tokens. ```shell >>> StableSwap.totalSupply() 6811356567627648910003460 ``` -------------------------------- ### Example: Get Initial A/gamma Source: https://github.com/curvedocs/curve-docs/blob/master/docs/cryptoswap-exchange/cryptoswap/pools/admin-controls.md This is an example of how to call the `initial_A_gamma` getter in CryptoSwap. ```shell >>> CryptoSwap.initial_A_gamma() ``` -------------------------------- ### Example Usage of initial_A() Source: https://github.com/curvedocs/curve-docs/blob/master/docs/stableswap-exchange/stableswap-ng/pools/plainpool.md Shows an example of calling the `initial_A` getter to obtain the pool's starting amplification coefficient. ```shell >>> StableSwap.initial_A() 50000 ``` -------------------------------- ### Get Price Oracle Examples Source: https://github.com/curvedocs/curve-docs/blob/master/docs/cryptoswap-exchange/tricrypto-ng/pools/oracles.md Examples demonstrating how to call the `price_oracle` function for different coin indices. ```shell >>> CurveTricryptoOptimizedWETH.price_oracle(0) 66466761042718407573921 >>> CurveTricryptoOptimizedWETH.price_oracle(1) 3243401255685792725933 ``` -------------------------------- ### Example: ve_supply Usage Source: https://github.com/curvedocs/curve-docs/blob/master/docs/fees/FeeDistributor.md Example of how to call the `ve_supply` function with a specific epoch start timestamp. ```shell >>> FeeDistributor.ve_supply(1718841600) 667140493408797243694521600 ``` -------------------------------- ### Example Usage of swap_into_synth Source: https://github.com/curvedocs/curve-docs/blob/master/docs/stableswap-exchange/stableswap/cross_asset_swaps/synthswap_exchange.md Demonstrates how to initiate a synth swap using the `swap_into_synth` function. It shows setting up accounts, contracts, calculating expected amounts, and executing the transaction, then retrieving the resulting token ID. ```shell >>> alice = accounts[0] >>> synth_swap = Contract('0x58A3c68e2D3aAf316239c003779F71aCb870Ee47') >>> dai = Contract('0x6b175474e89094c44da98b954eedeac495271d0f') >>> sbtc = Contract('0xfe18be6b3bd88a2d2a7f928d00292e7a9963cfc6') >>> expected = synth_swap.get_swap_into_synth_amount(dai, sbtc, dai.balanceOf(alice)) * 0.99 >>> tx = synth_swap.swap_into_synth(dai, sbtc, expected, {'from': alice}) Transaction sent: 0x83b311af19be08b8ec6241c3e834ccdf3b22586971de82a76a641e43bdf2b3ee Gas price: 20 gwei Gas limit: 1200000 Nonce: 5 >>> tx.events['TokenUpdate']['token_id'] 2423994707895209386239865227163451060473904619065 ``` -------------------------------- ### Get Number of Coins Example (Shell) Source: https://github.com/curvedocs/curve-docs/blob/master/docs/stableswap-exchange/stableswap-ng/pools/metapool.md Example of how to call the `N_COINS` function to get the number of coins in the pool. ```shell >>> StableSwap.N_COINS() 2 ``` -------------------------------- ### Example Usage Source: https://github.com/curvedocs/curve-docs/blob/master/docs/block-oracle/LZBlockRelay.md This is a placeholder for example usage, indicating that the 'soon' command is expected to be available. ```shell soon ``` -------------------------------- ### Example Usage of SynthSwap.swap_from_synth Source: https://github.com/curvedocs/curve-docs/blob/master/docs/stableswap-exchange/stableswap/cross_asset_swaps/synthswap_exchange.md This example demonstrates how to use the `swap_from_synth` function in a shell environment. It shows how to get the current underlying balance, calculate the expected amount, and initiate the swap transaction. ```shell >>> wbtc = Contract('0x2260fac5e5542a773aa44fbcfedf7c193bc2c599') >>> amount = synth_swap.token_info(token_id)['underlying_balance'] >>> expected = swynth_swap.get_swap_from_synth_amount(sbtc, wbtc, amount) * 0.99 >>> synth_swap.swap_from_synth(token_id, wbtc, amount, expected, {'from': alice}) Transaction sent: 0x83b311af19be08b8ec6241c3e834ccdf3b22586971de82a76a641e43bdf2b3ee Gas price: 20 gwei Gas limit: 800000 Nonce: 6 ``` -------------------------------- ### Example: Get Address Provider Source: https://github.com/curvedocs/curve-docs/blob/master/docs/registry/MetaRegistryAPI.md Example of calling the address_provider function to get the AddressProvider contract's address. ```shell >>> MetaRegistry.address_provider() '0x0000000022D53366457F9d5E68Ec105046FC4383' ``` -------------------------------- ### Example: Set Views Implementation Source: https://github.com/curvedocs/curve-docs/blob/master/docs/factory/tricrypto-ng/overview.md Example of how to call the set_views_implementation function. ```shell >>> Factory.set_views_implementation("todo") 'todo' ``` -------------------------------- ### Get Coin Address by Index - Example Source: https://github.com/curvedocs/curve-docs/blob/master/docs/stableswap-exchange/stableswap/pools/plain_pools.md Example of how to call the `coin` method to get the address of the first coin in the pool. ```shell >>> pool.coin(0) '0xdB25f211AB05b1c97D595516F45794528a807ad8' ``` -------------------------------- ### Example: Set Pool Implementation Source: https://github.com/curvedocs/curve-docs/blob/master/docs/factory/stableswap-ng/overview.md Example usage for setting a pool implementation. Replace 'todo' with actual parameters. ```shell >>> CurveStableSwapFactoryNG.set_pool_implementations('todo') ``` -------------------------------- ### Get Price Scale Examples Source: https://github.com/curvedocs/curve-docs/blob/master/docs/cryptoswap-exchange/tricrypto-ng/pools/oracles.md Examples showing how to use the `price_scale` function to get the price scale for coin indices 0 and 1. ```shell >>> CurveTricryptoOptimizedWETH.price_scale(0) 64955165867890305070839 >>> CurveTricryptoOptimizedWETH.price_scale(1) 3133935659389092150237 ``` -------------------------------- ### Example: Get Threshold Source: https://github.com/curvedocs/curve-docs/blob/master/docs/block-oracle/BlockOracle.md Example of retrieving the current threshold. ```shell >>> BlockOracle.threshold() 1 ``` -------------------------------- ### LeverageZap get_collateral Examples Source: https://github.com/curvedocs/curve-docs/blob/master/docs/crvUSD/leverage/LeverageZap.md Examples demonstrating how to use the get_collateral function with different routes to estimate output amounts. ```shell LeverageZap.get_collateral(100000000000000000000000, 0) # 100,000 crvUSD using route 0 154124094 # 1.54 wBTC ``` ```shell LeverageZap.get_collateral(100000000000000000000000, 1) # 100,000 crvUSD using route 1 155160443 # 1.55 wBTC ``` -------------------------------- ### Example: Query Plain Implementations Source: https://github.com/curvedocs/curve-docs/blob/master/docs/factory/stableswap/implementations.md An example showing how to retrieve a specific plain implementation contract address based on the number of coins in the pool and the implementation index. ```shell >>> Factory.plain_implementations(2, 0) '0x6523Ac15EC152Cb70a334230F6c5d62C5Bd963f1' ``` -------------------------------- ### Example: Get All Committers Source: https://github.com/curvedocs/curve-docs/blob/master/docs/block-oracle/BlockOracle.md Example of calling the get_all_committers function. ```shell >>> BlockOracle.get_all_committers() ['0xFacEFeeD696BFC0ebe7EaD3FFBb9a56290d31752'] ``` -------------------------------- ### Example: Set Metapool Implementation Source: https://github.com/curvedocs/curve-docs/blob/master/docs/factory/stableswap-ng/overview.md Example usage for setting a metapool implementation. Replace 'todo' with actual parameters. ```shell >>> CurveStableSwapFactoryNG.set_metapool_implementations('todo') ``` -------------------------------- ### Example: Get Aggregator Source: https://github.com/curvedocs/curve-docs/blob/master/docs/crvUSD/pegkeepers/PegKeeperRegulator.md Example of how to call the `aggregator` getter function. ```shell >>> PegKeeperRegulator.aggregator() '0x18672b1b0c623a30089A280Ed9256379fb0E4E62' ``` -------------------------------- ### Example Usage: Get SIGMA Source: https://github.com/curvedocs/curve-docs/blob/master/docs/crvUSD/priceaggregator_old.md Example of how to call the SIGMA getter function. ```shell >>> PriceAggregator.SIGMA() 1000000000000000 ``` -------------------------------- ### Example: Deploy Plain Pool via Factory Source: https://github.com/curvedocs/curve-docs/blob/master/docs/factory/stableswap/deployer-api.md This example demonstrates how to call the `deploy_plain_pool` function using the Factory contract. It shows the required parameters and the expected return value. ```shell >>> Factory.deploy_plain_pool( _name: "alUSD-crvUSD", _symbol: "alcrvUSD", _coins: ['0xbc6da0fe9ad5f3b0d58160288917aa56653660e9', '0xf939E0A03FB07F59A73314E73794Be0E57ac1b4E'], _A: 200, _fee: 4000000, _asset_type: 0, _implementation_idx: 0, ) 'returns address of deployed pool' ``` -------------------------------- ### Example: Get Fee Receiver Source: https://github.com/curvedocs/curve-docs/blob/master/docs/crvUSD/pegkeepers/PegKeeperRegulator.md Example of how to call the `fee_receiver` getter function. ```shell >>> PegKeeperRegulator.fee_receiver() '0xeCb456EA5365865EbAb8a2661B0c503410e9B347' ``` -------------------------------- ### Example: Query Metapool Implementations Source: https://github.com/curvedocs/curve-docs/blob/master/docs/factory/stableswap/implementations.md An example demonstrating how to query the metapool implementations for a given base pool address. ```shell >>> Factory.metapool_implementation('0xbebc44782c7db0a1a60cb6fe97d0b483032ff1c7') '[[0x213be373FDff327658139C7df330817DAD2d5bBE] [0x55Aa9BF126bCABF0bDC17Fa9E39Ec9239e1ce7A9] [0x0000000000000000000000000000000000000000] [0x0000000000000000000000000000000000000000] [0x0000000000000000000000000000000000000000] [0x0000000000000000000000000000000000000000] [0x0000000000000000000000000000000000000000] [0x0000000000000000000000000000000000000000] [0x0000000000000000000000000000000000000000] [0x0000000000000000000000000000000000000000]]' ``` -------------------------------- ### Example: Get Emergency Admin Source: https://github.com/curvedocs/curve-docs/blob/master/docs/crvUSD/pegkeepers/PegKeeperRegulator.md Example of how to call the `emergency_admin` getter function. ```shell >>> PegKeeperRegulator.emergency_admin() '0x467947EE34aF926cF1DCac093870f613C96B1E0c' ``` -------------------------------- ### Controller create_loan Example Usage Source: https://github.com/curvedocs/curve-docs/blob/master/docs/crvUSD/controller.md Example of how to call the create_loan function and query user state. Demonstrates the expected output for debt and user state after a loan is created. ```shell >>> Controller.create_loan(10**18, 10**21, 10) >>> Controller.debt(trader) 1000000000000000000000 >>> Controller.user_state(trader) [1000000000000000000, 0, 1000000000000000000000, 10] # [collateral, stablecoin, debt, bands] ``` -------------------------------- ### MonetaryPolicy.parameters() Examples Source: https://github.com/curvedocs/curve-docs/blob/master/docs/lending/contracts/secondary-mp.md Demonstrates the output of the parameters() getter function for different lending markets. Note the inclusion of a 'shift' value in the wstETH market example. ```shell >>> MonetaryPolicy.parameters() # mp for BTC lending market (follows wBTC mint market) 1046153846153846153, 120710059171597632, 384615384615384617, 0 >>> MonetaryPolicy.parameters() # mp for wstETH lending market (follows wETH mint market) 1046153846153846153, 120710059171597632, 384615384615384617, 1268391679 ``` -------------------------------- ### Example: Get Alpha Value Source: https://github.com/curvedocs/curve-docs/blob/master/docs/crvUSD/pegkeepers/PegKeeperRegulator.md Example of how to call the `alpha` getter function. ```shell >>> PegKeeperRegulator.alpha() 500000000000000000 ``` -------------------------------- ### LeverageZap Examples Source: https://github.com/curvedocs/curve-docs/blob/master/docs/crvUSD/leverage/LeverageZap.md Examples demonstrating the usage of `get_collateral` and `get_collateral_underlying` functions for wstETH market. ```shell # wstETH market: >>> LeverageZap.get_collateral(100000000000000000000000, 0) # 100,000 crvUSD using route 0 27065166978322615717 # 27.07 wstETH >>> LeverageZap.get_collateral_underlying(100000000000000000000000, 0) # 100,000 crvUSD using route 0 31551027792084938361 # 31.55 ETH ``` -------------------------------- ### Example: Get Price Deviation Source: https://github.com/curvedocs/curve-docs/blob/master/docs/crvUSD/pegkeepers/PegKeeperRegulator.md Example of how to call the `price_deviation` getter function. ```shell >>> PegKeeperRegulator.price_deviation() 500000000000000 ``` -------------------------------- ### Example: Get Future A/gamma Source: https://github.com/curvedocs/curve-docs/blob/master/docs/cryptoswap-exchange/cryptoswap/pools/admin-controls.md This is an example of how to call the `future_A_gamma` getter in CryptoSwap. ```shell >>> CryptoSwap.future_A_gamma() ``` -------------------------------- ### Example: Set Math Implementation Source: https://github.com/curvedocs/curve-docs/blob/master/docs/factory/tricrypto-ng/overview.md This is an example of how to call the `set_math_implementation` function. Replace 'todo' with the actual address of the new math contract. ```shell >>> Factory.set_math_implementation("todo") 'todo' ``` -------------------------------- ### Example Usage of Create Function Source: https://github.com/curvedocs/curve-docs/blob/master/docs/lending/contracts/oneway-factory.md This example demonstrates how to call the `create` function with specific token addresses, AMM parameters, discounts, oracle, name, and monetary policy rates. It shows the expected return value, which is the address of the newly created vault. ```shell >>> OneWayLendingVaultFactory.create( "0xf939e0a03fb07f59a73314e73794be0e57ac1b4e", # borrowed_token "0x8f22779662ad253844013d8e99eccb4d80e31417", # collateral_token 50, # A 6000000000000000, # fee 140000000000000000, # loan_discount 110000000000000000, # liquidation_discount external price oracle, # price_oracle "bobrCRV-long", # name 0, # min_borrow_rate 1) # max_borrow_rate '0xE16D806c4198955534d4EB10E4861Ea94557602E' # returns address of the created vault ``` -------------------------------- ### Example: Querying Pool Balances Source: https://github.com/curvedocs/curve-docs/blob/master/docs/registry/MetaRegistryAPI.md Shows how to use the `get_balances` function with different pool addresses and displays the resulting token balances. Note that these are raw token amounts. ```shell >>> MetaRegistry.get_balances("0xbEbc44782C7dB0a1A60Cb6fe97d0b483032FF1C7") 147006104035945155794243533, 141336760960804, 94869577680718, 0, 0, 0, 0, 0 >>> MetaRegistry.get_balances("0xEd279fDD11cA84bEef15AF5D39BB4d4bEE23F0cA") 6781730641038140101957300, 5934556341193690490470482, 0, 0, 0, 0, 0, 0 ``` -------------------------------- ### Example: Get Committer by Index Source: https://github.com/curvedocs/curve-docs/blob/master/docs/block-oracle/BlockOracle.md Example of retrieving the committer at index 0. ```shell >>> BlockOracle.committers(0) '0xFacEFeeD696BFC0ebe7EaD3FFBb9a56290d31752' ``` -------------------------------- ### Example: Get Controller Implementation Source: https://github.com/curvedocs/curve-docs/blob/master/docs/lending/contracts/oneway-factory.md Shows how to call the controller_impl() getter to retrieve the controller's address. ```shell In [1]: OneWayLendingVaultFactory.controller_impl() Out [1]: '0x5473B1BcBbC45d38d8fBb50a18a73aFb8B0637A7' ``` -------------------------------- ### Example: Get Sigma Value Source: https://github.com/curvedocs/curve-docs/blob/master/docs/crvUSD/monetarypolicy.md Example of calling the `sigma` getter function. ```shell >>> MonetaryPolicy.sigma() 20000000000000000 ``` -------------------------------- ### Example: Get Time Cursor Of Address Source: https://github.com/curvedocs/curve-docs/blob/master/docs/fees/FeeDistributor.md This example returns the `time_cursor_of` for a given address. ```shell >>> FeeDistributor.time_cursor_of('0x7a16fF8270133F063aAb6C9977183D9e72835428') 1719446400 ``` -------------------------------- ### Fetch Distribution Time - Example Source: https://github.com/curvedocs/curve-docs/blob/master/docs/scrvusd/RewardsHandler.md An interactive example to fetch the distribution time of rewards directly on-chain. This demonstrates how to call the `distribution_time` function. ```html
>>> RewardsHandler.distribution_time() 
``` -------------------------------- ### Example Usage: Get TVL MA Time Source: https://github.com/curvedocs/curve-docs/blob/master/docs/crvUSD/priceaggregator_old.md Example of how to call the TVL_MA_TIME getter function. ```shell >>> PriceAggregator.TVL_MA_TIME() 50000 ``` -------------------------------- ### Example Usage: Create Vault from Pool Source: https://github.com/curvedocs/curve-docs/blob/master/docs/lending/contracts/oneway-factory.md This example demonstrates how to call the `create_from_pool` function with specific token addresses, pool parameters, and vault configuration details. It shows the expected return value, which is the address of the newly created vault. ```shell >>> OneWayLendingVaultFactory.create_from_pool( "0xf939e0a03fb07f59a73314e73794be0e57ac1b4e", # borrowed_token "0x8f22779662ad253844013d8e99eccb4d80e31417", # collateral_token 50, # A 6000000000000000, # fee 140000000000000016, # loan_discount 110000000000000000, # liquidation_discount "0x9fee65d5a627e73212989c8bbedc5fa5cae3821f", # pool to use oracle from "bobrCRV-long", # name 0, # min_borrow_rate 1) # max_borrow_rate '0xE16D806c4198955534d4EB10E4861Ea94557602E' # returns address of the created vault ``` -------------------------------- ### Example Usage: Get Last Timestamp Source: https://github.com/curvedocs/curve-docs/blob/master/docs/crvUSD/priceaggregator_old.md Example of how to call the last_timestamp getter function. ```shell >>> PriceAggregator.last_timestamp() 1689448067 ``` -------------------------------- ### Example Usage: Get Stablecoin Address Source: https://github.com/curvedocs/curve-docs/blob/master/docs/crvUSD/priceaggregator_old.md Example of how to call the STABLECOIN getter function. ```shell >>> PriceAggregator.STABLECOIN() '0xf939E0A03FB07F59A73314E73794Be0E57ac1b4E' ``` -------------------------------- ### Example Usage: Controller.liquidation_discounts Source: https://github.com/curvedocs/curve-docs/blob/master/docs/crvUSD/controller.md Demonstrates how to call the `liquidation_discounts` getter method with a user address. ```shell >>> Controller.liquidation_discounts(trader) 0 ``` -------------------------------- ### Example Usage of Pool.price_oracle Source: https://github.com/curvedocs/curve-docs/blob/master/docs/cryptoswap-exchange/twocrypto-ng/pools/twocrypto.md Demonstrates how to call the `price_oracle` function and shows an example output for the CVG/ETH price. ```shell In [1]: Pool.price_oracle() Out [1]: 176068711374120 # CVG/ETH price ``` -------------------------------- ### Example: Get Worst Price Threshold Source: https://github.com/curvedocs/curve-docs/blob/master/docs/crvUSD/pegkeepers/PegKeeperRegulator.md Example of how to call the `worst_price_threshold` getter function. ```shell >>> PegKeeperRegulator.worst_price_threshold() 300000000000000 ``` -------------------------------- ### Example Usage of deploy_plain_pool Source: https://github.com/curvedocs/curve-docs/blob/master/docs/factory/stableswap-ng/deployer-api.md This example demonstrates how to call the `deploy_plain_pool` function with specific parameters for a crvUSD/USDT pool. ```shell >>> Factory.deploy_plain_pool( "crvUSD/USDT", # _name "crvusd-usdt", # _symbol [ # coins: "0xf939E0A03FB07F59A73314E73794Be0E57ac1b4E", # crvusd "0xdAC17F958D2ee523a2206206994597C13D831ec7" # usdt ], 1500 # _A 1000000, # _fee 20000000000, # _offpeg_fee_multiplier 865, # _ma_exp_time 0, # _implementation_idx [0, 0], # _asset_types ``` -------------------------------- ### Example: Get Initial A/gamma Time Source: https://github.com/curvedocs/curve-docs/blob/master/docs/cryptoswap-exchange/cryptoswap/pools/admin-controls.md This is an example of how to call the `initial_A_gamma_time` getter in CryptoSwap. ```shell >>> CryptoSwap.initial_A_gamma_time() ``` -------------------------------- ### Example Usage Source: https://github.com/curvedocs/curve-docs/blob/master/docs/block-oracle/HeaderVerifier.md An example demonstrating the usage of the Header Verifier functionality. This is a placeholder and requires further implementation. ```shell >>> soon ``` -------------------------------- ### Example: Get Admin Actions Deadline Source: https://github.com/curvedocs/curve-docs/blob/master/docs/cryptoswap-exchange/cryptoswap/pools/admin-controls.md This is an example of how to call the `admin_actions_deadline` getter in CryptoSwap. ```shell >>> CryptoSwap.admin_actions_deadline() ``` -------------------------------- ### Example: Set and Get Scaling Factor Source: https://github.com/curvedocs/curve-docs/blob/master/docs/scrvusd/RewardsHandler.md Demonstrates how to set the scaling factor from 10000 to 15000 and verify the change. ```shell >>> RewardsHandler.scaling_factor() 10000 >>> RewardsHandler.set_scaling_factor(15000) >>> RewardsHandler.scaling_factor() 15000 ``` -------------------------------- ### Example: Get Target Debt Fraction Source: https://github.com/curvedocs/curve-docs/blob/master/docs/crvUSD/monetarypolicy.md Example of calling the `target_debt_fraction` getter function. ```shell >>> MonetaryPolicy.target_debt_fraction() 100000000000000000 # 10% ``` -------------------------------- ### Example: Get Pool Name Source: https://github.com/curvedocs/curve-docs/blob/master/docs/registry/MetaRegistryAPI.md Example of how to call the `get_pool_name` function with a specific pool address. ```shell >>> MetaRegistry.get_pool_name("0xEd279fDD11cA84bEef15AF5D39BB4d4bEE23F0cA") 'lusd' ``` -------------------------------- ### Interactive Minimum Snapshot Time Example Source: https://github.com/curvedocs/curve-docs/blob/master/docs/scrvusd/RewardsHandler.md An interactive example to fetch the minimum time between snapshots in seconds directly on-chain. ```html
>>> RewardsHandler.min_snapshot_dt_seconds() 
```