Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate level-finance #202

Closed
wants to merge 9 commits into from
Closed

Integrate level-finance #202

wants to merge 9 commits into from

Conversation

guiltylotus
Copy link
Contributor

Why did we need it?

Related Issue

Release Note

How Has This Been Tested?

Screenshots (if appropriate):

@guiltylotus guiltylotus force-pushed the feat/AG-1137 branch 4 times, most recently from dbbaecc to e64dd55 Compare November 3, 2023 05:18
@guiltylotus guiltylotus changed the title WIP: Integrate level-finance Integrate level-finance Nov 3, 2023

func (d *PoolsListUpdater) init(ctx context.Context) ([]entity.Pool, error) {
var (
allAssets = make([]common.Address, 10)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why we hardcode 10 for all Assests, I see that ABI supports function method getAllAssets
[ getAllAssets method Response ] assets address[] : [[0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f] [0x82aF49447D8a07e3bd95BD0d56f35241523fBab1] [0x912CE59144191C1204E64559FE8253a0e49E6548] [0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9] [0xaf88d065e77c8cC2239327C5EDb3A432268e5831]] isStable bool[] : false,false,false,true,true

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your implementation is still ok, incase I didn't find getAllAssets method on BSC chain.

Copy link
Contributor Author

@guiltylotus guiltylotus Nov 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, there are some differences between bsc and arbitrum to get pool states. I updated in notion https://www.notion.so/kybernetwork/Integration-Notes-Level-Finance-Study-note-23dded16b3d444caacd84c253f8eaecf?pvs=4

calls.AddCall(&ethrpc.Call{
ABI: LiquidityPoolAbi,
Target: p.Address,
Method: liquidityPoolMethodFee,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see this method in level-finance arbitrum sc, please help me check again. Error:
app/main.go:442 failed to aggregate call {"poolAddress": "0x32b7bf19cb8b95c27e644183837813d4b595dcc6", "type": "level-finance", "err": "execution reverted: Multicall aggregate: call failed"}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated version for arbitrum

}

func calcSwapOutput(tokenIn, tokenOut *TokenInfo, amountIn *big.Int, state *PoolState) (*big.Int, *big.Int, error) {
priceIn := new(big.Int).Set(tokenIn.MinPrice)
Copy link
Member

@ChauNguyen-K ChauNguyen-K Nov 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @guiltylotus , please help me check this function, in levelOracle sc, we do not use the raw price value, instead, it does some calculations then return the calculated value as below:
https://arbiscan.io/address/0x82B585a8F15701BBD671850f0a9F1feE57a8DCB5#code#F1#L180

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In 1 block, the swap does not cause the price changes. So we can use directly getPrice result from the contract.


func calcSwapOutput(tokenIn, tokenOut *TokenInfo, amountIn *big.Int, state *PoolState) (*big.Int, *big.Int, error) {
priceIn := new(big.Int).Set(tokenIn.MinPrice)
priceOut := new(big.Int).Set(tokenOut.MaxPrice)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same with priceIn above.

@guiltylotus guiltylotus force-pushed the feat/AG-1137 branch 2 times, most recently from 146a246 to 0db2c29 Compare November 23, 2023 09:03
@0xh9n 0xh9n closed this Dec 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants