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

Add vault legal text #263

Merged
merged 3 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions scripts/update_client_api.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ if [ $? -ne 0 ]; then
exit 1
fi

source ~/.zprofile

# Running npm commands
nvm install
nvm use
npm install
npm run build
npm run webpack
Expand Down
2 changes: 1 addition & 1 deletion v4/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ ext {
compileSdkVersion = 34

// App dependencies
abacusVersion = '1.13.14'
abacusVersion = '1.13.17'
carteraVersion = '0.1.15'
kollectionsVersion = '2.0.16'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,5 @@ object VaultRoutes {
const val withdraw = "vault/withdraw"
const val confirmation = "vault/confirmation"
const val history = "vault/history"
const val tos = "vault/tos"
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.ColorFilter
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.hilt.navigation.compose.hiltViewModel
Expand Down Expand Up @@ -162,7 +163,7 @@ object DydxOrderDetailsView : DydxComponent {
.padding(vertical = 16.dp)
.padding(horizontal = ThemeShapes.HorizontalPadding),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.SpaceBetween,
horizontalArrangement = Arrangement.spacedBy(ThemeShapes.HorizontalPadding),
) {
Text(
text = item.title ?: "",
Expand All @@ -171,6 +172,8 @@ object DydxOrderDetailsView : DydxComponent {
.themeFont(fontSize = ThemeFont.FontSize.small),
)

Spacer(modifier = Modifier.weight(1f))

when (val value = item.value) {
is Item.ItemValue.Number -> {
Text(
Expand All @@ -185,6 +188,7 @@ object DydxOrderDetailsView : DydxComponent {
text = value.value ?: "-",
style = TextStyle.dydxDefault
.themeColor(ThemeColor.SemanticColor.text_primary),
textAlign = TextAlign.End,
)
}
is Item.ItemValue.Checkmark -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,16 +248,39 @@ class DydxOrderDetailsViewModel @Inject constructor(
),
),
DydxOrderDetailsView.Item(
title = localizer.localize("APP.TRADE.TIME_IN_FORCE"),
title = localizer.localize("APP.TRADE.GOOD_TIL"),
value = DydxOrderDetailsView.Item.ItemValue.StringValue(
order.resources.timeInForceString ?: order.resources.timeInForceStringKey?.let {
localizer.localize(
it,
)
order.goodTilBlock?.toLong()?.let {
"$it"
},
),
),
),
DydxOrderDetailsView.Item(
title = localizer.localize("APP.TRADE.TIME_IN_FORCE"),
value = DydxOrderDetailsView.Item.ItemValue.StringValue(
order.resources.timeInForceString
?: order.resources.timeInForceStringKey?.let {
localizer.localize(
it,
)
},
),
),
if (order.cancelReason != null) {
DydxOrderDetailsView.Item(
title = localizer.localize("APP.TRADE.CANCEL_REASON"),
value = DydxOrderDetailsView.Item.ItemValue.StringValue(
order.cancelReason?.let {
localizer.localize(
"APP.TRADE.$it",
)
},
),
)
} else {
null
},
).filterNotNull(),
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,21 +111,21 @@ class DydxAdjustMarginInputViewModel @Inject constructor(
when (input.type) {
Add -> {
if (summary.crossFreeCollateral != null && amount.toDouble() >= summary.crossFreeCollateral!!) {
return localizer.localize("APP.ERRORS.TRANSFER_MODAL.TRANSFER_MORE_THAN_FREE")
return localizer.localize("ERRORS.TRANSFER_MODAL.TRANSFER_MORE_THAN_FREE")
}
if (summary.crossMarginUsage != null && summary.crossMarginUsage!! > 1.0) {
return localizer.localize("APP.ERRORS.TRADE_BOX.INVALID_NEW_ACCOUNT_MARGIN_USAGE")
return localizer.localize("ERRORS.TRADE_BOX.INVALID_NEW_ACCOUNT_MARGIN_USAGE")
}
}
Remove -> {
if (summary.positionLeverageUpdated != null && summary.positionLeverageUpdated!! > marketMaxLeverage) {
return localizer.localize("APP.ERRORS.TRADE_BOX.POSITION_LEVERAGE_OVER_MAX")
return localizer.localize("ERRORS.TRADE_BOX.POSITION_LEVERAGE_OVER_MAX")
}
if (marginUsage != null && marginUsage > 1) {
return localizer.localize("APP.ERRORS.TRADE_BOX.INVALID_NEW_ACCOUNT_MARGIN_USAGE")
return localizer.localize("ERRORS.TRADE_BOX.INVALID_NEW_ACCOUNT_MARGIN_USAGE")
}
if (freeCollateral != null && amount.toDouble() > freeCollateral) {
return localizer.localize("APP.ERRORS.TRANSFER_MODAL.TRANSFER_MORE_THAN_FREE")
return localizer.localize("ERRORS.TRANSFER_MODAL.TRANSFER_MORE_THAN_FREE")
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class TradeStream @Inject constructor(
.distinctUntilChanged()

override fun submitTrade() {
if (abacusStateManager.state.tradeInput != null) {
if (abacusStateManager.state.tradeInput.value != null) {
_submissionStatus.update { null }

abacusStateManager.placeOrder { submissionStatus ->
Expand All @@ -68,7 +68,7 @@ class TradeStream @Inject constructor(
}

override fun closePosition() {
if (abacusStateManager.state.closePositionInput != null) {
if (abacusStateManager.state.closePositionInput.value != null) {
_submissionStatus.update { null }

abacusStateManager.closePosition { submissionStatus ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@ class DydxTransferOutUSDCStep(
val recipient = transferInput.address ?: return invalidInputEvent

if (usdcBalanceInWallet > gasFee) {
val payload: Map<String, Any> = mapOf(
val payload: Map<String, Any?> = mapOf(
"subaccountNumber" to subaccountNumber,
"amount" to amount,
"memo" to transferInput.memo,
"recipient" to recipient,
)
val paramsInJson = payload.toJson()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import exchange.dydx.trading.feature.vault.DydxVaultView
import exchange.dydx.trading.feature.vault.depositwithdraw.DydxVaultDepositWithdrawView
import exchange.dydx.trading.feature.vault.depositwithdraw.confirmation.DydxVaultConfirmationView
import exchange.dydx.trading.feature.vault.history.DydxVaultHistoryView
import exchange.dydx.trading.feature.vault.tos.DydxVaultTosView
import exchange.dydx.utilities.utils.Logging

fun NavGraphBuilder.vaultGraph(
Expand Down Expand Up @@ -58,4 +59,12 @@ fun NavGraphBuilder.vaultGraph(
) { navBackStackEntry ->
DydxVaultHistoryView.Content(Modifier)
}

dydxComposable(
router = appRouter,
route = VaultRoutes.tos,
deepLinks = appRouter.deeplinks(VaultRoutes.tos),
) { navBackStackEntry ->
DydxVaultTosView.Content(Modifier)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import exchange.dydx.abacus.protocols.LocalizerProtocol
import exchange.dydx.dydxstatemanager.AbacusStateManagerProtocol
import exchange.dydx.trading.common.DydxViewModel
import exchange.dydx.trading.common.navigation.DydxRouter
import exchange.dydx.trading.common.navigation.VaultRoutes
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flowOf
import javax.inject.Inject
Expand All @@ -24,10 +25,10 @@ class DydxVaultHeaderViewModel @Inject constructor(
localizer = localizer,
dydxChainLogoUrl = abacusStateManager.environment?.chainLogo,
learnMoreAction = {
val url = abacusStateManager.environment?.links?.vaultLearnMore
if (url != null) {
router.navigateTo(url)
}
router.navigateTo(
route = VaultRoutes.tos,
presentation = DydxRouter.Presentation.Modal,
)
},
)
}
Expand Down
Loading
Loading