Skip to content

Commit

Permalink
Release 1.36 (#1120)
Browse files Browse the repository at this point in the history
Merge pull request #1120 from madfish-solutions/development
  • Loading branch information
alex-tsx authored Dec 23, 2024
2 parents 97a23fa + ab8138f commit a2972ca
Show file tree
Hide file tree
Showing 13 changed files with 43 additions and 36 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/apk-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
inputs:
version:
description: Version
default: "1.35"
default: "1.36"
required: true
build-number:
description: Build number
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/testapp-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
inputs:
version:
description: Version
default: "1.35"
default: "1.36"
required: true
build-number:
description: Build number
Expand Down
2 changes: 1 addition & 1 deletion android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ android {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1027
versionName "1.35"
versionName "1.36"

missingDimensionStrategy 'react-native-camera', 'general'
}
Expand Down
2 changes: 1 addition & 1 deletion ios/TempleWallet/Debug-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.35</string>
<string>1.36</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleURLTypes</key>
Expand Down
2 changes: 1 addition & 1 deletion ios/TempleWallet/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.35</string>
<string>1.36</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleURLTypes</key>
Expand Down
2 changes: 1 addition & 1 deletion ios/TempleWalletTests/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>1.35</string>
<string>1.36</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "temple-wallet",
"version": "1.35",
"version": "1.36",
"private": true,
"scripts": {
"postinstall": "rn-nodeify --install 'react-native-randombytes' --hack && bash postinstall.sh",
Expand Down
6 changes: 3 additions & 3 deletions src/apis/liquidity-baking/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { TezosToolkit } from '@taquito/taquito';
import { BigNumber } from 'bignumber.js';

import { SINGLE_SIRS_SWAP_MAX_DEXES } from 'src/config/swap';
import { MAIN_SIRS_SWAP_MAX_DEXES } from 'src/config/swap';
import { EarnOpportunityTokenStandardEnum } from 'src/enums/earn-opportunity-token-standard.enum';
import { EarnOpportunityTypeEnum } from 'src/enums/earn-opportunity-type.enum';
import { LiquidityBakingStorage } from 'src/op-params/liquidity-baking-storage.interface';
Expand Down Expand Up @@ -128,8 +128,8 @@ export const calculateUnstakeParams = async (
toTokenDecimals: threeRouteOutputToken.decimals,
amount: mutezToTz(swapInputMinusFeeAtomic, SIRS_TOKEN_METADATA.decimals).toFixed(),
// Such swap has either XTZ or tzBTC hops
xtzDexesLimit: SINGLE_SIRS_SWAP_MAX_DEXES,
tzbtcDexesLimit: SINGLE_SIRS_SWAP_MAX_DEXES,
xtzDexesLimit: MAIN_SIRS_SWAP_MAX_DEXES,
tzbtcDexesLimit: MAIN_SIRS_SWAP_MAX_DEXES,
rpcUrl
});

Expand Down
7 changes: 4 additions & 3 deletions src/config/swap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ export const ATOMIC_INPUT_THRESHOLD_FOR_FEE_FROM_INPUT = Math.ceil(
);

// These values have been set after some experimentation
export const SINGLE_SWAP_IN_BATCH_MAX_DEXES = 12;
const LB_OPERATION_DEXES_COST = 2;
export const SINGLE_SIRS_SWAP_MAX_DEXES = SINGLE_SWAP_IN_BATCH_MAX_DEXES - LB_OPERATION_DEXES_COST;
export const CASHBACK_SWAP_MAX_DEXES = 3;
// Actually, at most 2 dexes for each of underlying SIRS -> tzBTC -> X swap and SIRS -> XTZ -> X swap
export const MAIN_SIRS_SWAP_MAX_DEXES = 4;
export const MAIN_NON_SIRS_SWAP_MAX_DEXES = 3;

export const TEMPLE_TOKEN: Route3Token = {
id: 138,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { TezosToolkit } from '@taquito/taquito';
import { BigNumber } from 'bignumber.js';

import { ROUTING_FEE_ADDRESS, SINGLE_SIRS_SWAP_MAX_DEXES } from 'src/config/swap';
import { MAIN_SIRS_SWAP_MAX_DEXES, ROUTING_FEE_ADDRESS } from 'src/config/swap';
import {
THREE_ROUTE_SIRS_TOKEN,
THREE_ROUTE_TZBTC_TOKEN,
Expand Down Expand Up @@ -43,8 +43,8 @@ export const createLiquidityBakingStakeTransfersParams = async (
toTokenDecimals: THREE_ROUTE_SIRS_TOKEN.decimals,
amount: mutezToTz(swapInputMinusFeeAtomic, inputToken.decimals).toFixed(),
// Such swap has either XTZ or tzBTC hops
xtzDexesLimit: SINGLE_SIRS_SWAP_MAX_DEXES,
tzbtcDexesLimit: SINGLE_SIRS_SWAP_MAX_DEXES,
xtzDexesLimit: MAIN_SIRS_SWAP_MAX_DEXES,
tzbtcDexesLimit: MAIN_SIRS_SWAP_MAX_DEXES,
rpcUrl
});
const slippageRatio = calculateSlippageRatio(slippageTolerancePercentage);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { TezosToolkit } from '@taquito/taquito';
import { BigNumber } from 'bignumber.js';

import { ROUTING_FEE_ADDRESS, SINGLE_SWAP_IN_BATCH_MAX_DEXES } from 'src/config/swap';
import { MAIN_NON_SIRS_SWAP_MAX_DEXES, MAIN_SIRS_SWAP_MAX_DEXES, ROUTING_FEE_ADDRESS } from 'src/config/swap';
import { SavingsItem } from 'src/interfaces/earn-opportunity/savings-item.interface';
import { Route3Token } from 'src/interfaces/route3.interface';
import { ToastError } from 'src/toast/error-toast.utils';
import { TokenInterface } from 'src/token/interfaces/token.interface';
import { getTokenSlug, toTokenSlug } from 'src/token/utils/token.utils';
import { isDefined } from 'src/utils/is-defined';
import { fetchRoute3SwapParams } from 'src/utils/route3.util';
import { fetchRoute3SwapParams, isSirsSwap } from 'src/utils/route3.util';
import {
calculateSidePaymentsFromInput,
calculateSlippageRatio,
Expand Down Expand Up @@ -51,7 +51,7 @@ export const createStakeTransfersParams = async (
toSymbol: toRoute3Token.symbol,
toTokenDecimals: toRoute3Token.decimals,
amount: mutezToTz(swapInputMinusFeeAtomic, asset.decimals).toString(),
dexesLimit: SINGLE_SWAP_IN_BATCH_MAX_DEXES,
dexesLimit: isSirsSwap(fromRoute3Token, toRoute3Token) ? MAIN_SIRS_SWAP_MAX_DEXES : MAIN_NON_SIRS_SWAP_MAX_DEXES,
rpcUrl: tezos.rpc.getRpcUrl()
});

Expand Down
30 changes: 15 additions & 15 deletions src/screens/swap/swap-form/swap-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@ import { tokenEqualityFn } from 'src/components/token-dropdown/token-equality-fn
import {
ATOMIC_INPUT_THRESHOLD_FOR_FEE_FROM_INPUT,
CASHBACK_RATIO,
CASHBACK_SWAP_MAX_DEXES,
MAIN_NON_SIRS_SWAP_MAX_DEXES,
MAIN_SIRS_SWAP_MAX_DEXES,
ROUTING_FEE_ADDRESS,
ROUTING_FEE_RATIO,
ROUTING_FEE_SLIPPAGE_RATIO,
SINGLE_SIRS_SWAP_MAX_DEXES,
SINGLE_SWAP_IN_BATCH_MAX_DEXES,
SWAP_THRESHOLD_TO_GET_CASHBACK,
TEMPLE_TOKEN
} from 'src/config/swap';
Expand Down Expand Up @@ -49,7 +50,7 @@ import {
import { useCurrentAccountPkhSelector, useCurrentAccountTezosBalance } from 'src/store/wallet/wallet-selectors';
import { formatSize } from 'src/styles/format-size';
import { showErrorToast } from 'src/toast/toast.utils';
import { KNOWN_TOKENS_SLUGS, TEMPLE_TOKEN_SLUG } from 'src/token/data/token-slugs';
import { TEMPLE_TOKEN_SLUG } from 'src/token/data/token-slugs';
import { TEZ_TOKEN_SLUG } from 'src/token/data/tokens-metadata';
import { emptyTezosLikeToken, TokenInterface } from 'src/token/interfaces/token.interface';
import { getTokenSlug } from 'src/token/utils/token.utils';
Expand All @@ -58,7 +59,7 @@ import { useAnalytics } from 'src/utils/analytics/use-analytics.hook';
import { isDefined } from 'src/utils/is-defined';
import { BURN_ADDRESS } from 'src/utils/known-addresses';
import { ZERO } from 'src/utils/number.util';
import { fetchRoute3SwapParams, getRoute3TokenSymbol } from 'src/utils/route3.util';
import { fetchRoute3SwapParams, getRoute3TokenSymbol, isSirsSwap } from 'src/utils/route3.util';
import {
calculateSidePaymentsFromInput,
calculateOutputFeeAtomic,
Expand Down Expand Up @@ -115,19 +116,16 @@ export const SwapForm: FC<SwapFormProps> = ({ inputToken, outputToken }) => {

const isInputTokenTempleToken = inputAssetSlug === TEMPLE_TOKEN_SLUG;
const isOutputTokenTempleToken = outputAssetSlug === TEMPLE_TOKEN_SLUG;
const isSirsSwap = inputAssetSlug === KNOWN_TOKENS_SLUGS.SIRS || outputAssetSlug === KNOWN_TOKENS_SLUGS.SIRS;
const isSwapAmountMoreThreshold = inputAmountInUsd.isGreaterThanOrEqualTo(SWAP_THRESHOLD_TO_GET_CASHBACK);
const totalMaxDexes = isSirsSwap ? SINGLE_SIRS_SWAP_MAX_DEXES : SINGLE_SWAP_IN_BATCH_MAX_DEXES;
const cashbackSwapMaxDexes = Math.ceil(totalMaxDexes / (isSirsSwap ? 3 : 2));
const mainSwapMaxDexes =
totalMaxDexes - (isSwapAmountMoreThreshold && !isInputTokenTempleToken ? cashbackSwapMaxDexes : 0);
const mainSwapMaxDexes = isSirsSwap(inputAsset, newOutputValue.asset)
? MAIN_SIRS_SWAP_MAX_DEXES
: MAIN_NON_SIRS_SWAP_MAX_DEXES;

return {
isInputTokenTempleToken,
isOutputTokenTempleToken,
isSwapAmountMoreThreshold,
mainSwapMaxDexes,
cashbackSwapMaxDexes
mainSwapMaxDexes
};
},
[usdExchangeRates]
Expand Down Expand Up @@ -177,8 +175,10 @@ export const SwapForm: FC<SwapFormProps> = ({ inputToken, outputToken }) => {
swapParams.data
);

const { isInputTokenTempleToken, isOutputTokenTempleToken, isSwapAmountMoreThreshold, cashbackSwapMaxDexes } =
getSwapWithFeeParams(inputAssets, outputAssets);
const { isInputTokenTempleToken, isOutputTokenTempleToken, isSwapAmountMoreThreshold } = getSwapWithFeeParams(
inputAssets,
outputAssets
);

if (isInputTokenTempleToken && isSwapAmountMoreThreshold) {
const routingInputFeeOpParams = await getRoutingFeeTransferParams(
Expand All @@ -204,7 +204,7 @@ export const SwapForm: FC<SwapFormProps> = ({ inputToken, outputToken }) => {
toSymbol: TEMPLE_TOKEN.symbol,
toTokenDecimals: TEMPLE_TOKEN.decimals,
amount: mutezToTz(routingFeeFromInputAtomic, fromRoute3Token.decimals).toFixed(),
dexesLimit: cashbackSwapMaxDexes,
dexesLimit: CASHBACK_SWAP_MAX_DEXES,
rpcUrl: tezos.rpc.getRpcUrl()
});

Expand Down Expand Up @@ -244,7 +244,7 @@ export const SwapForm: FC<SwapFormProps> = ({ inputToken, outputToken }) => {
toSymbol: TEMPLE_TOKEN.symbol,
toTokenDecimals: TEMPLE_TOKEN.decimals,
amount: mutezToTz(routingFeeFromOutputAtomic, toRoute3Token.decimals).toFixed(),
dexesLimit: cashbackSwapMaxDexes,
dexesLimit: CASHBACK_SWAP_MAX_DEXES,
rpcUrl: tezos.rpc.getRpcUrl()
});

Expand Down
10 changes: 8 additions & 2 deletions src/utils/route3.util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,12 @@ export const fetchRoute3LiquidityBakingParams = (
}
});

export const isSirsSwap = (from: string | Pick<Route3Token, 'symbol'>, to: string | Pick<Route3Token, 'symbol'>) => {
return [from, to]
.map(symbolOrToken => (typeof symbolOrToken === 'string' ? symbolOrToken : symbolOrToken.symbol))
.includes(THREE_ROUTE_SIRS_TOKEN.symbol);
};

export const fetchRoute3SwapParams = ({
fromSymbol,
toSymbol,
Expand All @@ -153,7 +159,7 @@ export const fetchRoute3SwapParams = ({
const isLbUnderlyingTokenSwap =
intersection([fromSymbol, toSymbol], [THREE_ROUTE_TZBTC_TOKEN.symbol, THREE_ROUTE_XTZ_TOKEN.symbol]).length > 0;

return [fromSymbol, toSymbol].includes(THREE_ROUTE_SIRS_TOKEN.symbol)
return isSirsSwap(fromSymbol, toSymbol)
? fetchRoute3LiquidityBakingParams({
fromSymbol,
toSymbol,
Expand Down Expand Up @@ -187,7 +193,7 @@ export const mapToRoute3ExecuteHops = (hops: Route3Hop[]): MichelsonMap<string,

export const getRoute3TokenSymbol = (token: TokenInterface) => {
if (token.symbol === TEZ_TOKEN_METADATA.symbol) {
return 'xtz';
return 'XTZ';
}

return token.symbol;
Expand Down

0 comments on commit a2972ca

Please sign in to comment.