Skip to content

Add liquidity auction tier withdraw limit

Bitol Maya requested to merge MAYA-68 into develop

constants/constant_values.go:

  • Add constants for tiers.

constants/constants_v1.go:

  • Add constants values for tiers.

proto/thorchain/v1/x/thorchain/types/msg_add_liquidity.proto:

  • Add liquidity auction tier to add liquidity msg.

proto/thorchain/v1/x/thorchain/types/type_liquidity_auction_tier.proto:

  • Add liquidity auction tier proto for storing address and tier.

proto/thorchain/v1/x/thorchain/types/type_liquidity_provider.proto:

  • Add withdraw counter and last withdraw counter height to monitor current withdraw limit and last withdraw time.

x/thorchain/errors.go:

  • Add errors relative to reaching withdraw limit and invalid tier.

x/thorchain/handler.go:

  • Add tier variable to AddLiquidity msg.

x/thorchain/handler_add_liquidity.go:

  • Add msg member LiquidityAuctionTier to function called.
  • Called function SetLiquidityAuctionTier if were on LA. We should send an error if we couldn't update tier (for example setting an invalid tier) but the add liquidity should be done correctly.

x/thorchain/handler_add_liquidity_test.go:

  • Update test with new tier parameter.

x/thorchain/handler_test.go:

  • Update test with new tier parameter.

x/thorchain/handler_withdraw_test.go:

  • Update test with new tier parameter.

x/thorchain/helpers.go:

  • Add isWithDrawDaysLimit function to verify if address should be limited by tier. If tier is not valid (1, 2 or 3) it returns a false.
  • Add getWithdrawLimit function to return % limited by tier. If tier is not valid (1, 2 or 3) it returns an error.

x/thorchain/helpers_test.go:

  • Update test with new tier parameter.
  • Add isWithDrawDaysLimit and getWithdrawLimit unit tests.

x/thorchain/keeper/alias.go:

  • Add LiquidityAuctionTier alias.

x/thorchain/keeper/keeper.go:

  • Add GetLiquidityAuctionTier and SetLiquidityAuctionTier function prototype to keeper.

x/thorchain/keeper/keeper_dummy.go:

  • Add GetLiquidityAuctionTier, SetLiquidityProvider and SetLiquidityAuctionTier fucntions to keeper dummy.

x/thorchain/keeper/v1/alias.go:

  • Add LiquidityAuctionTier alias.

x/thorchain/keeper/v1/keeper.go:

  • Add LiquidityAuctionTier prefix.

x/thorchain/keeper/v1/keeper_liquidity_provider.go:

  • Add const LATier_Dont_Exist with "random" value.
  • Add setLiquidityAuctionTier function to save tier.
  • Add getLiquidityAuctionTier function to get tier value, if tier doesn't exist return an error.
  • Add SetLiquidityAuctionTier function to save tier, if previous saved tier value is higher it should return an error.
  • Add GetLiquidityAuctionTier function to get tier value, if tier was not set, return LATier_Dont_Exist.

x/thorchain/keeper/v1/keeper_liquidity_provider_test.go:

  • Add unit test for SetLiquidityAuctionTier and GetLiquidityAuctionTier.

x/thorchain/manager_network_current_test.go:

  • Update liquidity provider members for test.

x/thorchain/manager_network_v76_test.go:

  • Update liquidity provider members for test.

x/thorchain/manager_network_v87_test.go:

  • Update liquidity provider members for test.

x/thorchain/memo/memo_add.go:

  • Add memo parse tier logic. By default the tier is set to 3. Tier is an optional parameter, it could be sent as a single optional parameter or with AFFILIATE + FEE parameters.

x/thorchain/memo/memo_test.go:

  • Add unit test for add memo parse logic for tier.

x/thorchain/querier.go:

  • Add query logic to get tier by address.

x/thorchain/query/query.go:

  • Add query to get tier by address.

x/thorchain/thorchain_test.go:

  • Update test with tier parameter.

x/thorchain/types/msg_add_liquidity.go:

  • Add msg tier member.

x/thorchain/types/msg_add_liquidity.pb.go:

  • Autogenerated proto file.

x/thorchain/types/msg_add_liquidity_test.go:

  • Update test with tier parameter.

x/thorchain/types/type_liquidity_auction_tier.go:

  • Add liquidity auction tier type logic.

x/thorchain/types/type_liquidity_auction_tier.pb.go:

  • Autogenerated proto file.

x/thorchain/types/type_liquidity_provider.pb.go:

  • Autogenerated proto file.

x/thorchain/withdraw_current.go:

  • Add checkWithdrawLimit function call.
  • Add checkWithdrawLimit function to verify if the lp can withdraw depending on the % limit and tier.

x/thorchain/withdraw_current_test.go:

  • Add checkWithdrawLimit unit test.
  • Update old test with new tier parameter.

x/thorchain/withdraw_v76_test.go:

  • Update tests with new tier parameter.

x/thorchain/withdraw_v84_test.go:

  • Update tests with new tier parameter.

Merge request reports