mirror of
https://github.com/pezkuwichain/pezkuwi-wallet-android.git
synced 2026-04-25 19:47:57 +00:00
Initial commit: Pezkuwi Wallet Android
Complete rebrand of Nova Wallet for Pezkuwichain ecosystem. ## Features - Full Pezkuwichain support (HEZ & PEZ tokens) - Polkadot ecosystem compatibility - Staking, Governance, DeFi, NFTs - XCM cross-chain transfers - Hardware wallet support (Ledger, Polkadot Vault) - WalletConnect v2 - Push notifications ## Languages - English, Turkish, Kurmanci (Kurdish), Spanish, French, German, Russian, Japanese, Chinese, Korean, Portuguese, Vietnamese Based on Nova Wallet by Novasama Technologies GmbH © Dijital Kurdistan Tech Institute 2026
This commit is contained in:
+279
@@ -0,0 +1,279 @@
|
||||
package io.novafoundation.nova.hydra_dx_math.stableswap
|
||||
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertNotEquals
|
||||
import org.junit.Ignore
|
||||
import org.junit.Test
|
||||
|
||||
class StableSwapTest {
|
||||
|
||||
@Test
|
||||
fun shouldCalculateOutGivenIn() {
|
||||
val data = """
|
||||
[{
|
||||
"asset_id": 1,
|
||||
"amount": "1000000000000",
|
||||
"decimals": 12
|
||||
},
|
||||
{
|
||||
"asset_id": 0,
|
||||
"amount": "1000000000000",
|
||||
"decimals": 12
|
||||
}
|
||||
]
|
||||
"""
|
||||
|
||||
val result = StableSwapMathBridge.calculate_out_given_in(
|
||||
data,
|
||||
0,
|
||||
1,
|
||||
"1000000000",
|
||||
"1",
|
||||
"0",
|
||||
""
|
||||
)
|
||||
|
||||
assertEquals("999500248", result)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun shouldCalculateInGiveOut() {
|
||||
val data = """
|
||||
[{
|
||||
"asset_id": 1,
|
||||
"amount": "1000000000000",
|
||||
"decimals": 12
|
||||
},
|
||||
{
|
||||
"asset_id": 0,
|
||||
"amount": "1000000000000",
|
||||
"decimals": 12
|
||||
}
|
||||
]
|
||||
"""
|
||||
|
||||
val result = StableSwapMathBridge.calculate_in_given_out(
|
||||
data,
|
||||
0,
|
||||
1,
|
||||
"1000000000",
|
||||
"1",
|
||||
"0",
|
||||
""
|
||||
)
|
||||
|
||||
assertNotEquals("-1", result)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun shouldCalculateAmplification() {
|
||||
val result = StableSwapMathBridge.calculate_amplification("10", "10", "0", "100", "50")
|
||||
|
||||
assertEquals("10", result)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun shouldCalculateShares() {
|
||||
val data = """
|
||||
[{
|
||||
"asset_id": 0,
|
||||
"amount":"90000000000",
|
||||
"decimals": 12
|
||||
},
|
||||
{
|
||||
"asset_id": 1,
|
||||
"amount": "5000000000000000000000",
|
||||
"decimals": 12
|
||||
}
|
||||
]
|
||||
"""
|
||||
|
||||
val assets = """
|
||||
[{"asset_id":1,"amount":"43000000000000000000"}]
|
||||
"""
|
||||
|
||||
val result = StableSwapMathBridge.calculate_shares(
|
||||
data,
|
||||
assets,
|
||||
"1000",
|
||||
"64839594451719860",
|
||||
"0",
|
||||
""
|
||||
)
|
||||
|
||||
assertEquals("371541351762585", result.toString())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun shouldCalculateSharesForAmount() {
|
||||
val data = """
|
||||
[
|
||||
{
|
||||
"asset_id": 0,
|
||||
"amount": "10000000000000000",
|
||||
"decimals": 12
|
||||
},
|
||||
{
|
||||
"asset_id": 1,
|
||||
"amount": "10000000000000000",
|
||||
"decimals": 12
|
||||
},
|
||||
{
|
||||
"asset_id": 2,
|
||||
"amount": "10000000000000000",
|
||||
"decimals": 12
|
||||
},
|
||||
{
|
||||
"asset_id": 3,
|
||||
"amount": "10000000000000000",
|
||||
"decimals": 12
|
||||
},
|
||||
{
|
||||
"asset_id": 4,
|
||||
"amount": "10000000000000000",
|
||||
"decimals": 12
|
||||
}
|
||||
]
|
||||
"""
|
||||
|
||||
val result = StableSwapMathBridge.calculate_shares_for_amount(
|
||||
data,
|
||||
0,
|
||||
"100000000000000",
|
||||
"100",
|
||||
"20000000000000000000000",
|
||||
"0",
|
||||
""
|
||||
)
|
||||
|
||||
assertEquals("40001593768209443008", result.toString())
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore("The test fails with last digit being 0 instead of 1. We need to check why it happens later")
|
||||
fun shouldCalculateAddOneAsset() {
|
||||
val data = """
|
||||
[
|
||||
{
|
||||
"asset_id": 0,
|
||||
"amount": "10000000000000000",
|
||||
"decimals": 12
|
||||
},
|
||||
{
|
||||
"asset_id": 1,
|
||||
"amount": "10000000000000000",
|
||||
"decimals": 12
|
||||
},
|
||||
{
|
||||
"asset_id": 2,
|
||||
"amount": "10000000000000000",
|
||||
"decimals": 12
|
||||
},
|
||||
{
|
||||
"asset_id": 3,
|
||||
"amount": "10000000000000000",
|
||||
"decimals": 12
|
||||
},
|
||||
{
|
||||
"asset_id": 4,
|
||||
"amount": "10000000000000000",
|
||||
"decimals": 12
|
||||
}
|
||||
]
|
||||
"""
|
||||
|
||||
val result = StableSwapMathBridge.calculate_add_one_asset(
|
||||
data,
|
||||
"399850144492663029649",
|
||||
2,
|
||||
"100",
|
||||
"20000000000000000000000",
|
||||
"0",
|
||||
""
|
||||
)
|
||||
|
||||
assertEquals("1000000000000001", result.toString())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun shouldcalculateLiquidityOutOneAsset() {
|
||||
val data = """
|
||||
[
|
||||
{
|
||||
"asset_id": 0,
|
||||
"amount": "10000000000000000",
|
||||
"decimals": 12
|
||||
},
|
||||
{
|
||||
"asset_id": 1,
|
||||
"amount": "10000000000000000",
|
||||
"decimals": 12
|
||||
},
|
||||
{
|
||||
"asset_id": 2,
|
||||
"amount": "10000000000000000",
|
||||
"decimals": 12
|
||||
},
|
||||
{
|
||||
"asset_id": 3,
|
||||
"amount": "10000000000000000",
|
||||
"decimals": 12
|
||||
},
|
||||
{
|
||||
"asset_id": 4,
|
||||
"amount": "10000000000000000",
|
||||
"decimals": 12
|
||||
}
|
||||
]
|
||||
"""
|
||||
|
||||
val result = StableSwapMathBridge.calculate_liquidity_out_one_asset(
|
||||
data,
|
||||
"40001593768209443008",
|
||||
0,
|
||||
"100",
|
||||
"20000000000000000000000",
|
||||
"0",
|
||||
""
|
||||
)
|
||||
|
||||
assertEquals("99999999999999", result.toString())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun failingCase() {
|
||||
val data = """
|
||||
[{"amount":"2246975221087","decimals":6,"asset_id":10},{"amount":"2256486088023","decimals":6,"asset_id":22}]
|
||||
"""
|
||||
|
||||
val result = StableSwapMathBridge.calculate_liquidity_out_one_asset(
|
||||
data,
|
||||
"1000000000",
|
||||
10,
|
||||
"100",
|
||||
"4502091550542833181457210",
|
||||
"0.00040",
|
||||
""
|
||||
)
|
||||
|
||||
assertEquals("99999999999999", result.toString())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun failingCase2() {
|
||||
val data = """
|
||||
[{"amount":"505342304916","decimals":6,"asset_id":10},{"amount":"368030436758902944990436","decimals":18,"asset_id":18},{"amount":"410374848833","decimals":6,"asset_id":21},{"amount":"0","decimals":6,"asset_id":23}] """
|
||||
|
||||
val result = StableSwapMathBridge.calculate_shares_for_amount(
|
||||
data,
|
||||
10,
|
||||
"10",
|
||||
"320",
|
||||
"1662219218861236418723363",
|
||||
"0.00040",
|
||||
""
|
||||
)
|
||||
|
||||
assertEquals("99999999999999", result.toString())
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
<manifest />
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
package io.novafoundation.nova.hydra_dx_math
|
||||
|
||||
import io.novafoundation.nova.common.utils.atLeastZero
|
||||
import java.math.BigInteger
|
||||
|
||||
object HydraDxMathConversions {
|
||||
|
||||
fun String.fromBridgeResultToBalance(): BigInteger? {
|
||||
return if (this == "-1") null else toBigInteger().atLeastZero()
|
||||
}
|
||||
}
|
||||
+75
@@ -0,0 +1,75 @@
|
||||
package io.novafoundation.nova.hydra_dx_math.stableswap;
|
||||
|
||||
public class StableSwapMathBridge {
|
||||
|
||||
static {
|
||||
System.loadLibrary("hydra_dx_math_java");
|
||||
}
|
||||
|
||||
public static native String calculate_out_given_in(
|
||||
String reserves,
|
||||
int asset_in,
|
||||
int asset_out,
|
||||
String amount_in,
|
||||
String amplification,
|
||||
String fee,
|
||||
String pegs
|
||||
);
|
||||
|
||||
public static native String calculate_in_given_out(
|
||||
String reserves,
|
||||
int asset_in,
|
||||
int asset_out,
|
||||
String amount_out,
|
||||
String amplification,
|
||||
String fee,
|
||||
String pegs
|
||||
);
|
||||
|
||||
public static native String calculate_amplification(
|
||||
String initial_amplification,
|
||||
String final_amplification,
|
||||
String initial_block,
|
||||
String final_block,
|
||||
String current_block
|
||||
);
|
||||
|
||||
public static native String calculate_shares(
|
||||
String reserves,
|
||||
String assets,
|
||||
String amplification,
|
||||
String share_issuance,
|
||||
String fee,
|
||||
String pegs
|
||||
);
|
||||
|
||||
public static native String calculate_shares_for_amount(
|
||||
String reserves,
|
||||
int asset_in,
|
||||
String amount,
|
||||
String amplification,
|
||||
String share_issuance,
|
||||
String fee,
|
||||
String pegs
|
||||
);
|
||||
|
||||
public static native String calculate_add_one_asset(
|
||||
String reserves,
|
||||
String shares,
|
||||
int asset_in,
|
||||
String amplification,
|
||||
String share_issuance,
|
||||
String fee,
|
||||
String pegs
|
||||
);
|
||||
|
||||
public static native String calculate_liquidity_out_one_asset(
|
||||
String reserves,
|
||||
String shares,
|
||||
int asset_out,
|
||||
String amplification,
|
||||
String share_issuance,
|
||||
String withdraw_fee,
|
||||
String pegs
|
||||
);
|
||||
}
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
package io.novafoundation.nova.hydra_dx_math.xyk;
|
||||
|
||||
public class HYKSwapMathBridge {
|
||||
|
||||
static {
|
||||
System.loadLibrary("hydra_dx_math_java");
|
||||
}
|
||||
|
||||
public static native String calculate_out_given_in(
|
||||
String balanceIn,
|
||||
String balanceOut,
|
||||
String amountIn
|
||||
);
|
||||
|
||||
public static native String calculate_in_given_out(
|
||||
String balanceIn,
|
||||
String balanceOut,
|
||||
String amountOut
|
||||
);
|
||||
|
||||
public static native String calculate_pool_trade_fee(
|
||||
String amount,
|
||||
String feeNumerator,
|
||||
String feeDenominator
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user