Skip to content

Conversation

@andreisilviudragnea
Copy link

@andreisilviudragnea andreisilviudragnea commented Nov 25, 2023

  • Decoupled Rpc trait from Solana RpcClient. Rpc trait has many artificial methods which are specific only to Solana RpcClient type. Those methods can be used directly from RpcClient.
  • Removed Context struct.
  • Refactored Rpc instance creation.
  • Replaced dyn Rpc with RpcEnum, using enum_dispatch crate to avoid boilerplate code.

@andreisilviudragnea andreisilviudragnea force-pushed the NDEV-2403 branch 2 times, most recently from 4716714 to 3fce700 Compare December 5, 2023 06:48
@anton-lisanin
Copy link
Collaborator

This appears to be unfinished.
Please get rid of .as_any().downcast_ref().

Solana's RpcClient is required for cancel_trx, collect_treasury, and init_environment.
They are not available through the neon-api and can only be used from the CLI.
You don't need to create dyn rpc::Rpc in the first place when executing one of these commands.

@andreisilviudragnea andreisilviudragnea force-pushed the NDEV-2403 branch 2 times, most recently from b26ac4f to 5c54d6a Compare December 5, 2023 14:25
@andreisilviudragnea andreisilviudragnea changed the title NDEV-2403: Decouple Rpc trait NDEV-2403: Decouple Rpc trait from Solana RpcClient Dec 5, 2023
@andreisilviudragnea
Copy link
Author

andreisilviudragnea commented Dec 5, 2023

@anton-lisanin I removed the Context struct and all usages of .as_any().downcast_ref().

@andreisilviudragnea andreisilviudragnea added the fullTestSuite Run OZ tests and part of dapps tests label Dec 5, 2023
Use RpcEnum

Remove as_any method

clippy

Clean up code

Remove Box and Arc

Clean up static dispatch

Make inner type of CloneRpcClient private
@neonlabstech
Copy link

Dapps report

Cost report for "Aave" dApp

Action Fee Cost in $ Accounts TRx Estimated Gas Used Gas Used % of EG
Token mint 0.00228896 0.0009984305266816 9 1 1164480 1144480 98.28
Token approve 0.00228896 0.0009984305266816 9 1 1164480 1144480 98.28
Deposit to lending pool 0.0077856 0.003396031694976 4 5 4761840 3892800 81.75
Borrow from lending pool 0.00508792 0.0022193199729632 4 30 3737360 2543960 68.07
Repay 0.00049 0.0002137350404 4 27 2586800 245000 9.47
Flashloan 0.00501792 0.0021887754566976003 4 28 7360480 2508960 34.09
Withdraw 7e-05 3.05334246e-05 4 5 1857760 35000 1.88
Liquidation 0.00335896 0.0014651507413488 4 57 4940000 1679480 34.0

Cost report for "Uniswap V3" dApp

Action Fee Cost in $ Accounts TRx Estimated Gas Used Gas Used % of EG
Token approve 0.00228896 0.0009984255367488002 9 1 1164480 1144480 98.28
NonfungiblePositionManager - Mint position 0.02730384 0.011909710570435201 4 28 30739120 13651920 44.41
NonfungiblePositionManager - Increase liquidity 0.00044 0.00019192438320000003 23 23 4364240 220000 5.04
NonfungiblePositionManager - Decrease Liquidity 0.00139808 0.0006098310037824 17 1 4274240 699040 16.35
NonfungiblePositionManager - Collect Fees 0.00455792 0.0019881272378976 20 1 3497360 2278960 65.16
NonfungiblePositionManager - Burn Liquidity Position 2e-05 8.723835600000001e-06 15 1 3954560 10000 0.25
Direct swap 2e-05 8.723835600000001e-06 17 1 1328400 10000 0.75
Burn transaction 0.00047936 0.00020911367191680003 11 1 739040 239680 32.43
Collect transaction 0.00228896 0.0009985247631648 12 1 1633840 1144480 70.05

Cost report for "Saddle Finance" dApp

Action Fee Cost in $ Accounts TRx Estimated Gas Used Gas Used % of EG
Add liquidity 0.00229896 0.0010033020307656 3 2 3181920 1149480 36.13
Swap DAI -> USDC 2e-05 8.7252448e-06 21 1 1797760 10000 0.56
Swap USDC -> DAI 2e-05 8.7252448e-06 21 1 1797760 10000 0.56
Remove liquidity 2e-05 8.7252448e-06 23 1 1937440 10000 0.52
Add liquidity in 3 Tokens 0.00278896 0.001215740015936 4 30 4220640 1394480 33.04
Swap DAI -> USDC 3 pool 2e-05 8.724702600000001e-06 21 1 1807760 10000 0.55
Swap USDC -> USDT 3 pool 2e-05 8.724702600000001e-06 21 1 1807760 10000 0.55
Swap USDC -> DAI 3 pool 2e-05 8.724702600000001e-06 21 1 1807760 10000 0.55
Remove liquidity 3 pool 3e-05 1.30943367e-05 3 2 2646480 15000 0.57
Add liquidity in metapool 0.00285896 0.0012476292450024 3 31 3271920 1429480 43.69
Swap SUSD -> LP metapool 2e-05 8.727853800000001e-06 22 1 1807760 10000 0.55
Swap USDC -> SUSD metapool 0.00103 0.0004494844707000001 4 53 3775520 515000 13.64
Swap DAI -> USDT metapool 0.00056 0.0002443799064 4 30 3086160 280000 9.07
Remove liquidity in Metapool 2e-05 8.727853800000001e-06 23 1 1937440 10000 0.52

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fullTestSuite Run OZ tests and part of dapps tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants