Skip to content

Commit

Permalink
Level-finance: update CalcAmountOut
Browse files Browse the repository at this point in the history
  • Loading branch information
guiltylotus committed Nov 23, 2023
1 parent 97ae036 commit 0db2c29
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
7 changes: 3 additions & 4 deletions pkg/source/level-finance/pool_simulator.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,9 @@ func NewPoolSimulator(entityPool entity.Pool) (*PoolSimulator, error) {
}, nil
}

func (p *PoolSimulator) CalcAmountOut(
tokenAmountIn pool.TokenAmount,
tokenOut string,
) (*pool.CalcAmountOutResult, error) {
func (p *PoolSimulator) CalcAmountOut(param pool.CalcAmountOutParams) (*pool.CalcAmountOutResult, error) {
tokenAmountIn := param.TokenAmountIn
tokenOut := param.TokenOut
tokenInIndex := p.GetTokenIndex(tokenAmountIn.Token)
tokenOutIndex := p.GetTokenIndex(tokenOut)
if tokenInIndex < 0 || tokenOutIndex < 0 {
Expand Down
10 changes: 6 additions & 4 deletions pkg/source/level-finance/pool_simulator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,13 @@ func TestCalcAmountOut(t *testing.T) {
assert.Nil(t, err)

result, err := levelFinancePool.CalcAmountOut(
pool.TokenAmount{
Token: "0x2170ed0880ac9a755fd29b2688956bd959f933f8",
Amount: bignumber.NewBig10("1000000000000000000"),
pool.CalcAmountOutParams{
TokenAmountIn: pool.TokenAmount{
Token: "0x2170ed0880ac9a755fd29b2688956bd959f933f8",
Amount: bignumber.NewBig10("1000000000000000000"),
},
TokenOut: "0x55d398326f99059ff775485246999027b3197955",
},
"0x55d398326f99059ff775485246999027b3197955",
)

assert.Nil(t, err)
Expand Down

0 comments on commit 0db2c29

Please sign in to comment.