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

Fix Review #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Fix Review #1

wants to merge 1 commit into from

Conversation

sherlock-admin4
Copy link
Contributor

Fix Review of

Repo: Velar-co/gl-sherlock
Commit Hash: cbc8105da41820b43a642e55303f0b5ba2281a90

@@ -4,6 +4,7 @@ import params as Params
import pools as Pools
import fees as Fees
import positions as Positions
import ERC20Plus as ERC20Plus

Choose a reason for hiding this comment

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

Change related to https://github.com/Velar-co/gl-sherlock/pull/1.

Fixes issues: #94

@@ -55,10 +56,10 @@ def CONTEXT(
quote_token: address,
desired : uint256,
slippage : uint256,
payload : Bytes[224]
payload : Bytes[512]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Change related to https://github.com/Velar-co/gl-sherlock/pull/1.

Fixes issues: #94

Comment on lines +61 to +62
base_decimals : uint256 = ERC20Plus(base_token).decimals()
quote_decimals: uint256 = ERC20Plus(quote_token).decimals()

Choose a reason for hiding this comment

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

Change related to https://github.com/Velar-co/gl-sherlock/pull/1.

Fixes issues: #94

@@ -72,6 +73,7 @@ def CONTEXT(

########################################################################
@external
@nonreentrant("lock")

Choose a reason for hiding this comment

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

Change related to https://github.com/Velar-co/gl-sherlock/pull/1.

Fixes issues: #94

@@ -80,7 +82,7 @@ def mint(
quote_amt : uint256,
desired : uint256,
slippage : uint256,
payload : Bytes[224]
payload : Bytes[512]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Change related to https://github.com/Velar-co/gl-sherlock/pull/1.

Fixes issues: #94

@@ -101,14 +103,15 @@ def mint(
return self.CORE.mint(1, base_token, quote_token, lp_token, base_amt, quote_amt, ctx)

@external
@nonreentrant("lock")

Choose a reason for hiding this comment

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

Change related to https://github.com/Velar-co/gl-sherlock/pull/1.

Fixes issues: #94

def burn(
base_token : address,
quote_token : address,
lp_token : address,
lp_amt : uint256,
desired : uint256,
slippage : uint256,
payload : Bytes[224]
payload : Bytes[512]

Choose a reason for hiding this comment

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

Change related to https://github.com/Velar-co/gl-sherlock/pull/1.

Fixes issues: #94

@@ -128,6 +131,7 @@ def burn(
return self.CORE.burn(1, base_token, quote_token, lp_token, lp_amt, ctx)

@external
@nonreentrant("lock")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Change related to https://github.com/Velar-co/gl-sherlock/pull/1.

Fixes issues: #94

@@ -136,7 +140,7 @@ def open(
leverage : uint256,
desired : uint256,
slippage : uint256,
payload : Bytes[224]
payload : Bytes[512]

Choose a reason for hiding this comment

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

Change related to https://github.com/Velar-co/gl-sherlock/pull/1.

Fixes issues: #94

@@ -158,13 +162,14 @@ def open(
return self.CORE.open(1, base_token, quote_token, long, collateral0, leverage, ctx)

@external
@nonreentrant("lock")

Choose a reason for hiding this comment

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

Change related to https://github.com/Velar-co/gl-sherlock/pull/1.

Fixes issues: #94

def close(
base_token : address,
quote_token : address,
position_id : uint256,
desired : uint256,
slippage : uint256,
payload : Bytes[224]
payload : Bytes[512]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Change related to https://github.com/Velar-co/gl-sherlock/pull/1.

Fixes issues: #94

@@ -183,13 +188,14 @@ def close(
return self.CORE.close(1, base_token, quote_token, position_id, ctx)

@external
@nonreentrant("lock")

Choose a reason for hiding this comment

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

Change related to https://github.com/Velar-co/gl-sherlock/pull/1.

Fixes issues: #94

def liquidate(
base_token : address,
quote_token: address,
position_id: uint256,
desired : uint256,
slippage : uint256,
payload : Bytes[224]
payload : Bytes[512]

Choose a reason for hiding this comment

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

Change related to https://github.com/Velar-co/gl-sherlock/pull/1.

Fixes issues: #94

@@ -160,7 +160,7 @@ def balanced(state: Value, burn_value: uint256, ctx: Ctx) -> Tokens:
# Magic number which depends on the smallest fee one wants to support
# and the blocktime (since fees are per block). See types.vy/Parameters
# for an example.
DENOM: constant(uint256) = 1_000_000_000
DENOM: constant(uint256) = 1_000_000_000_000
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Change related to https://github.com/Velar-co/gl-sherlock/pull/3.

Fixes issues: #66

@@ -60,12 +60,12 @@ def utilization(reserves: uint256, interest: uint256) -> uint256:
"""
Reserve utilization in percent (rounded down).
"""
return 0 if (reserves == 0 or interest == 0) else (interest / (reserves / 100))
return 0 if (reserves == 0 or interest == 0) else (interest / (reserves / 100_000))

Choose a reason for hiding this comment

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

Change related to https://github.com/Velar-co/gl-sherlock/pull/3.

Fixes issues: #66


@internal
@pure
def scale(fee: uint256, utilization: uint256) -> uint256:
return (fee * utilization) / 100
return (fee * utilization) / 100_000

Choose a reason for hiding this comment

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

Change related to https://github.com/Velar-co/gl-sherlock/pull/3.

Fixes issues: #66

Comment on lines +195 to +198
pool : PoolState = self.POOLS.lookup(pos.pool)
bc : uint256 = pool.base_collateral
qc : uint256 = pool.quote_collateral

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Change related to https://github.com/Velar-co/gl-sherlock/pull/2.

Fixes issues: #96

@@ -206,19 +210,19 @@ def value(id: uint256, ctx: Ctx) -> PositionValue:
quote_transfer : [],
# in the worst case describe above, reserves
# dont change
quote_reserves : [self.MATH.PLUS(pos.collateral), #does not need min()
quote_reserves : [self.MATH.PLUS(min(pos.collateral, qc)),

Choose a reason for hiding this comment

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

Change related to https://github.com/Velar-co/gl-sherlock/pull/2.

Fixes issues: #96

self.MATH.MINUS(fees.funding_paid)],
quote_collateral: [self.MATH.PLUS(fees.funding_paid),
self.MATH.MINUS(pos.collateral)],
self.MATH.MINUS(min(pos.collateral, qc))],

Choose a reason for hiding this comment

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

Change related to https://github.com/Velar-co/gl-sherlock/pull/2.

Fixes issues: #96

}) if pos.long else Deltas({
base_interest : [],
quote_interest : [self.MATH.MINUS(pos.interest)],

base_transfer : [],
base_reserves : [self.MATH.PLUS(pos.collateral),
base_reserves : [self.MATH.PLUS(min(pos.collateral, bc)),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Change related to https://github.com/Velar-co/gl-sherlock/pull/2.

Fixes issues: #96

self.MATH.MINUS(fees.funding_paid)],
base_collateral : [self.MATH.PLUS(fees.funding_paid), # <-
self.MATH.MINUS(pos.collateral)],
self.MATH.MINUS(min(pos.collateral, bc))],

Choose a reason for hiding this comment

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

Change related to https://github.com/Velar-co/gl-sherlock/pull/2.

Fixes issues: #96

Comment on lines +257 to +261
avail_pay : uint256 = pool.quote_collateral if pos.long else (
pool.base_collateral )
funding_paid : uint256 = min(c1.deducted, avail_pay)
# borrowing_paid is for informational purposes only, could also say
# min(c2.deducted, avail_pay - funding_paid).

Choose a reason for hiding this comment

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

Change related to https://github.com/Velar-co/gl-sherlock/pull/2.

Fixes issues: #96

borrowing_paid : uint256 = c2.deducted
# other users' bad positions do not affect liquidatability
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Change related to https://github.com/Velar-co/gl-sherlock/pull/2.

Fixes issues: #96

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.

4 participants