Skip to content

Commit

Permalink
chore: remove skip ff [OTE-365]
Browse files Browse the repository at this point in the history
  • Loading branch information
yogurtandjam committed Sep 12, 2024
1 parent 4875794 commit e60e9d2
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 198 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import exchange.dydx.abacus.output.input.OrderType
import exchange.dydx.abacus.output.input.ReceiptLine
import exchange.dydx.abacus.output.input.TransferType
import exchange.dydx.abacus.state.internalstate.InternalInputState
import exchange.dydx.abacus.state.manager.StatsigConfig

internal class ReceiptCalculator {
fun calculate(
Expand Down Expand Up @@ -52,30 +51,17 @@ internal class ReceiptCalculator {
InputType.TRANSFER -> {
when (input.transfer.type) {
TransferType.deposit, TransferType.withdrawal -> {
if (StatsigConfig.useSkip) {
listOf(
ReceiptLine.Equity,
ReceiptLine.BuyingPower,
ReceiptLine.BridgeFee,
// add these back when supported by Skip
listOf(
ReceiptLine.Equity,
ReceiptLine.BuyingPower,
ReceiptLine.BridgeFee,
// add these back when supported by Skip
// ReceiptLine.ExchangeRate,
// ReceiptLine.ExchangeReceived,
// ReceiptLine.Fee,
ReceiptLine.Slippage,
ReceiptLine.TransferRouteEstimatedDuration,
)
} else {
listOf(
ReceiptLine.Equity,
ReceiptLine.BuyingPower,
ReceiptLine.ExchangeRate,
ReceiptLine.ExchangeReceived,
ReceiptLine.Fee,
// ReceiptLine.BridgeFee,
ReceiptLine.Slippage,
ReceiptLine.TransferRouteEstimatedDuration,
)
}
ReceiptLine.Slippage,
ReceiptLine.TransferRouteEstimatedDuration,
)
}

TransferType.transferOut -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,6 @@ class V4Environment(
@JsExport
@Suppress("PropertyName")
data object StatsigConfig {
var useSkip: Boolean = false
var ff_enable_evm_swaps: Boolean = false
var dc_max_safe_bridge_fees: Float = Float.POSITIVE_INFINITY
var ff_enable_limit_close: Boolean = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,7 @@ import exchange.dydx.abacus.processor.input.ClosePositionInputProcessor
import exchange.dydx.abacus.processor.input.TradeInputProcessor
import exchange.dydx.abacus.processor.launchIncentive.LaunchIncentiveProcessor
import exchange.dydx.abacus.processor.markets.MarketsSummaryProcessor
import exchange.dydx.abacus.processor.router.IRouterProcessor
import exchange.dydx.abacus.processor.router.skip.SkipProcessor
import exchange.dydx.abacus.processor.router.squid.SquidProcessor
import exchange.dydx.abacus.processor.wallet.WalletProcessor
import exchange.dydx.abacus.protocols.LocalizerProtocol
import exchange.dydx.abacus.protocols.ParserProtocol
Expand All @@ -65,7 +63,6 @@ import exchange.dydx.abacus.state.internalstate.InternalAccountState
import exchange.dydx.abacus.state.internalstate.InternalState
import exchange.dydx.abacus.state.manager.BlockAndTime
import exchange.dydx.abacus.state.manager.EnvironmentFeatureFlags
import exchange.dydx.abacus.state.manager.StatsigConfig
import exchange.dydx.abacus.state.manager.TokenInfo
import exchange.dydx.abacus.state.manager.V4Environment
import exchange.dydx.abacus.utils.IList
Expand Down Expand Up @@ -125,21 +122,11 @@ open class TradingStateMachine(
}
internal val walletProcessor = WalletProcessor(parser, localizer)
internal val configsProcessor = ConfigsProcessor(parser, localizer)
private val skipProcessor = SkipProcessor(
internal val routerProcessor = SkipProcessor(
parser = parser,
internalState = internalState.input.transfer,
staticTyping = staticTyping,
)
private val squidProcessor = SquidProcessor(
parser = parser,
internalState = internalState.input.transfer,
staticTyping = staticTyping,
)
internal val routerProcessor: IRouterProcessor
get() {
if (StatsigConfig.useSkip) return skipProcessor
return squidProcessor
}
internal val rewardsProcessor = RewardsParamsProcessor(parser)
internal val launchIncentiveProcessor = LaunchIncentiveProcessor(parser)
internal val tradeInputProcessor = TradeInputProcessor(parser)
Expand Down Expand Up @@ -1182,30 +1169,17 @@ open class TradingStateMachine(
val type = parser.asString(transfer["type"]) ?: return null
return when (type) {
"DEPOSIT", "WITHDRAWAL" -> {
if (StatsigConfig.useSkip) {
listOf(
ReceiptLine.Equity.rawValue,
ReceiptLine.BuyingPower.rawValue,
ReceiptLine.BridgeFee.rawValue,
// add these back when supported by Skip
listOf(
ReceiptLine.Equity.rawValue,
ReceiptLine.BuyingPower.rawValue,
ReceiptLine.BridgeFee.rawValue,
// add these back when supported by Skip
// ReceiptLine.ExchangeRate.rawValue,
// ReceiptLine.ExchangeReceived.rawValue,
// ReceiptLine.Fee.rawValue,
ReceiptLine.Slippage.rawValue,
ReceiptLine.TransferRouteEstimatedDuration.rawValue,
)
} else {
listOf(
ReceiptLine.Equity.rawValue,
ReceiptLine.BuyingPower.rawValue,
ReceiptLine.ExchangeRate.rawValue,
ReceiptLine.ExchangeReceived.rawValue,
ReceiptLine.Fee.rawValue,
// ReceiptLine.BridgeFee.rawValue,
ReceiptLine.Slippage.rawValue,
ReceiptLine.TransferRouteEstimatedDuration.rawValue,
)
}
ReceiptLine.Slippage.rawValue,
ReceiptLine.TransferRouteEstimatedDuration.rawValue,
)
}

"TRANSFER_OUT" -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import exchange.dydx.abacus.state.manager.HumanReadablePlaceOrderPayload
import exchange.dydx.abacus.state.manager.HumanReadableSubaccountTransferPayload
import exchange.dydx.abacus.state.manager.HumanReadableTriggerOrdersPayload
import exchange.dydx.abacus.state.manager.HumanReadableWithdrawPayload
import exchange.dydx.abacus.state.manager.StatsigConfig
import exchange.dydx.abacus.state.manager.pendingCctpWithdraw
import exchange.dydx.abacus.state.manager.processingCctpWithdraw
import exchange.dydx.abacus.state.manager.utils.Address
Expand Down Expand Up @@ -600,11 +599,7 @@ internal open class AccountSupervisor(
}

private fun sweepNobleBalanceToDydx(amount: BigDecimal) {
if (StatsigConfig.useSkip) {
sweepNobleBalanceToDydxSkip(amount = amount)
} else {
sweepNobleBalanceToDydxSquid(amount = amount)
}
sweepNobleBalanceToDydxSkip(amount = amount)
}

private fun sweepNobleBalanceToDydxSquid(amount: BigDecimal) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,16 +113,12 @@ internal class OnboardingSupervisor(
}

private fun retrieveAssetsFromRouter() {
if (StatsigConfig.useSkip) {
CoroutineScope(Dispatchers.Unconfined).launch {
retrieveSkipTransferChains()
}
retrieveSkipTransferTokens()
if (StatsigConfig.ff_enable_evm_swaps) {
retrieveSkipEvmSwapVenues()
}
} else {
retrieveTransferAssets()
CoroutineScope(Dispatchers.Unconfined).launch {
retrieveSkipTransferChains()
}
retrieveSkipTransferTokens()
if (StatsigConfig.ff_enable_evm_swaps) {
retrieveSkipEvmSwapVenues()
}
retrieveCctpChainIds()
}
Expand Down Expand Up @@ -236,49 +232,22 @@ internal class OnboardingSupervisor(
subaccountNumber: Int?,
) {
val isCctp = state?.input?.transfer?.isCctp ?: false
if (StatsigConfig.useSkip) {
if (isCctp) {
retrieveSkipDepositRouteCCTP(
state = state,
accountAddress = accountAddress,
sourceAddress = sourceAddress,
subaccountNumber = subaccountNumber,
)
} else {
retrieveSkipDepositRouteNonCCTP(
state,
accountAddress,
sourceAddress,
subaccountNumber,
)
}
return
}
when (configs.squidVersion) {
OnboardingConfigs.SquidVersion.V2WithdrawalOnly -> retrieveDepositRouteV1(
if (isCctp) {
retrieveSkipDepositRouteCCTP(
state = state,
accountAddress = accountAddress,
sourceAddress = sourceAddress,
subaccountNumber = subaccountNumber,
)
} else {
retrieveSkipDepositRouteNonCCTP(
state,
accountAddress,
sourceAddress,
subaccountNumber,
)

OnboardingConfigs.SquidVersion.V2, OnboardingConfigs.SquidVersion.V2DepositOnly ->
if (isCctp) {
retrieveDepositRouteV2(
state,
accountAddress,
sourceAddress,
subaccountNumber,
)
} else {
retrieveDepositRouteV1(
state,
accountAddress,
sourceAddress,
subaccountNumber,
)
}
}
return
}

private fun retrieveSkipDepositRouteNonCCTP(
Expand Down Expand Up @@ -689,11 +658,7 @@ internal class OnboardingSupervisor(
isCctp: Boolean,
requestId: String?,
) {
if (StatsigConfig.useSkip) {
fetchTransferStatusSkip(hash, fromChainId)
} else {
fetchTransferStatus(hash, fromChainId, toChainId, isCctp)
}
fetchTransferStatusSkip(hash, fromChainId)
}

private fun simulateWithdrawal(
Expand Down Expand Up @@ -769,76 +734,33 @@ internal class OnboardingSupervisor(
val isCctp =
CctpConfig.cctpChainIds?.any { it.isCctpEnabled(state?.input?.transfer) } ?: false
val isExchange = state?.input?.transfer?.exchange != null
if (StatsigConfig.useSkip) {
if (isCctp) {
retrieveSkipWithdrawalRouteCCTP(
state,
decimals,
gas,
accountAddress,
sourceAddress,
subaccountNumber,
)
} else if (isExchange) {
retrieveSkipWithdrawalRouteExchange(
state,
decimals,
gas,
accountAddress,
sourceAddress,
subaccountNumber,
)
} else {
retrieveSkipWithdrawalRouteNonCCTP(
state,
decimals,
gas,
accountAddress,
sourceAddress,
subaccountNumber,
)
}
return
}
when (configs.squidVersion) {
OnboardingConfigs.SquidVersion.V2DepositOnly -> retrieveWithdrawalRouteV1(
if (isCctp) {
retrieveSkipWithdrawalRouteCCTP(
state,
decimals,
gas,
accountAddress,
sourceAddress,
subaccountNumber,
)
} else if (isExchange) {
retrieveSkipWithdrawalRouteExchange(
state,
decimals,
gas,
accountAddress,
sourceAddress,
subaccountNumber,
)
} else {
retrieveSkipWithdrawalRouteNonCCTP(
state,
decimals,
gas,
accountAddress,
sourceAddress,
subaccountNumber,
)

OnboardingConfigs.SquidVersion.V2, OnboardingConfigs.SquidVersion.V2WithdrawalOnly ->
if (isCctp) {
retrieveWithdrawalRouteV2(
state,
decimals,
gas,
accountAddress,
sourceAddress,
subaccountNumber,
)
} else if (isExchange) {
retrieveWithdrawalRouteNoble(
state,
decimals,
gas,
accountAddress,
sourceAddress,
subaccountNumber,
)
} else {
retrieveWithdrawalRouteV1(
state,
decimals,
gas,
accountAddress,
sourceAddress,
subaccountNumber,
)
}
}
}

Expand Down Expand Up @@ -1532,25 +1454,14 @@ internal class OnboardingSupervisor(
subaccountNumber: Int?,
callback: TransactionCallback
) {
if (StatsigConfig.useSkip) {
cctpToNobleSkip(
state,
decimals,
gas,
accountAddress,
subaccountNumber,
callback,
)
} else {
cctpToNobleSquid(
state,
decimals,
gas,
accountAddress,
subaccountNumber,
callback,
)
}
cctpToNobleSkip(
state,
decimals,
gas,
accountAddress,
subaccountNumber,
callback,
)
}

private fun cctpToNobleSquid(
Expand Down

0 comments on commit e60e9d2

Please sign in to comment.