Skip to content

Commit cd55c3b

Browse files
authored
Merge pull request #18 from AcalaNetwork/develop
Release 0.4.6
2 parents 2a31a11 + 2dc20d9 commit cd55c3b

46 files changed

Lines changed: 4781 additions & 1217 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## [0.4.6] - 20220526
2+
- bump polkawallet_sdk v0.4.6.
3+
- new module browser.
4+
- new module vault-multiply.
5+
16
## [0.4.5] - 20220505
27
- bump polkawallet_sdk v0.4.5.
38
- XCM transfer rebuild.

assets/images/adjust_multiple.png

373 Bytes
Loading

assets/images/icon_multiply.png

1.56 KB
Loading

assets/images/multiply_update.png

370 Bytes
Loading

lib/api/assets/acalaServiceAssets.dart

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import 'dart:async';
22
import 'dart:convert';
33

4+
import 'package:polkawallet_plugin_karura/common/constants/index.dart';
45
import 'package:polkawallet_plugin_karura/polkawallet_plugin_karura.dart';
56
import 'package:polkawallet_plugin_karura/utils/assets.dart';
67
import 'package:polkawallet_sdk/plugin/store/balances.dart';
@@ -43,11 +44,8 @@ class AcalaServiceAssets {
4344
tokens.forEach((e) {
4445
final channel = '$tokenBalanceChannel${e.symbol}';
4546
plugin.sdk.api.subscribeMessage(
46-
'api.query.tokens.accounts',
47-
[
48-
address,
49-
e.currencyId ?? {'Token': e.symbol}
50-
],
47+
'acala.getTokenBalance',
48+
['api', address, e.tokenNameId],
5149
channel,
5250
(Map data) {
5351
callback({
@@ -74,8 +72,8 @@ class AcalaServiceAssets {
7472
final channel =
7573
'$tokenBalanceChannel${lpToken.map((e) => e.symbol).join('')}';
7674
plugin.sdk.api.subscribeMessage(
77-
'api.query.tokens.accounts',
78-
[address, currencyId],
75+
'acala.getTokenBalance',
76+
['api', address, e.tokenNameId],
7977
channel,
8078
(Map data) {
8179
callback({
@@ -103,6 +101,10 @@ class AcalaServiceAssets {
103101
AssetsUtils.tokenDataFromCurrencyId(plugin, e[0]).tokenNameId!;
104102
prices[tokenNameId] = Fmt.balanceInt(e[1]['value'].toString());
105103
});
104+
if (prices[relay_chain_token_symbol] != null &&
105+
prices[relay_chain_token_symbol]! > BigInt.zero) {
106+
prices['sa://0'] = prices[relay_chain_token_symbol]!;
107+
}
106108
callback(prices);
107109
}
108110

lib/api/types/homaNewEnvData.g.dart

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/api/types/loanType.dart

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@ class LoanType extends _LoanType {
1919
BigInt.parse((json['requiredCollateralRatio'] ?? 0).toString());
2020
data.interestRatePerSec =
2121
BigInt.parse((json['interestRatePerSec'] ?? 0).toString());
22-
data.globalInterestRatePerSec = json['globalInterestRatePerSec'] == null
23-
? null
24-
: BigInt.parse(json['globalInterestRatePerSec'].toString());
22+
data.stableFeeYear = data.calcStableFee(SECONDS_OF_YEAR);
2523
data.maximumTotalDebitValue =
2624
BigInt.parse(json['maximumTotalDebitValue'].toString());
2725
data.minimumDebitValue = BigInt.parse(json['minimumDebitValue'].toString());
@@ -87,6 +85,12 @@ class LoanType extends _LoanType {
8785
requiredCollateralRatio
8886
: BigInt.zero;
8987
}
88+
89+
double calcStableFee(int seconds) {
90+
final base =
91+
interestRatePerSec / BigInt.from(pow(10, acala_price_decimals));
92+
return pow((1 + base), seconds) - 1;
93+
}
9094
}
9195

9296
abstract class _LoanType {
@@ -96,9 +100,9 @@ abstract class _LoanType {
96100
BigInt liquidationRatio = BigInt.zero;
97101
BigInt requiredCollateralRatio = BigInt.zero;
98102
BigInt interestRatePerSec = BigInt.zero;
99-
BigInt? globalInterestRatePerSec = BigInt.zero;
100103
BigInt maximumTotalDebitValue = BigInt.zero;
101104
BigInt minimumDebitValue = BigInt.zero;
105+
double stableFeeYear = 0;
102106
int expectedBlockTime = 0;
103107
}
104108

@@ -131,7 +135,6 @@ class LoanData extends _LoanData {
131135
data.maxToBorrow = type.calcMaxToBorrow(data.collaterals, tokenPrice,
132136
stableCoinDecimals: stableCoinDecimals,
133137
collateralDecimals: collateralDecimals);
134-
data.stableFeeYear = data.calcStableFee(SECONDS_OF_YEAR);
135138
data.liquidationPrice = type.calcLiquidationPrice(
136139
data.debitInUSD, data.collaterals,
137140
stableCoinDecimals: stableCoinDecimals,
@@ -155,7 +158,6 @@ class LoanData extends _LoanData {
155158
data.maxToBorrow = this.maxToBorrow;
156159
data.stableCoinPrice = this.stableCoinPrice;
157160
data.liquidationPrice = this.liquidationPrice;
158-
data.stableFeeYear = this.stableFeeYear;
159161
return data;
160162
}
161163
}
@@ -175,14 +177,7 @@ abstract class _LoanData {
175177
double collateralRatio = 0;
176178
BigInt requiredCollateral = BigInt.zero;
177179
BigInt maxToBorrow = BigInt.zero;
178-
double stableFeeYear = 0;
179180
BigInt liquidationPrice = BigInt.zero;
180-
181-
double calcStableFee(int seconds) {
182-
final base = (type.globalInterestRatePerSec! + type.interestRatePerSec) /
183-
BigInt.from(pow(10, acala_price_decimals));
184-
return pow((1 + base), seconds) - 1;
185-
}
186181
}
187182

188183
class CollateralIncentiveData extends _CollateralIncentiveData {

lib/js_service_karura/dist/main.js

Lines changed: 144 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/js_service_karura/dist/main.js.LICENSE.txt

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,6 @@
55
* @license MIT
66
*/
77

8-
/*! *****************************************************************************
9-
Copyright (c) Microsoft Corporation.
10-
11-
Permission to use, copy, modify, and/or distribute this software for any
12-
purpose with or without fee is hereby granted.
13-
14-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
15-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
16-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
17-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
18-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
19-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
20-
PERFORMANCE OF THIS SOFTWARE.
21-
***************************************************************************** */
22-
238
/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
249

2510
/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
@@ -38,3 +23,12 @@ PERFORMANCE OF THIS SOFTWARE.
3823
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
3924
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
4025
*/
26+
27+
/**
28+
* [js-sha3]{@link https://github.com/emn178/js-sha3}
29+
*
30+
* @version 0.8.0
31+
* @author Chen, Yi-Cyuan [emn178@gmail.com]
32+
* @copyright Chen, Yi-Cyuan 2015-2018
33+
* @license MIT
34+
*/

lib/js_service_karura/package.json

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@
2121
"@polkadot/api": "^7.2.1"
2222
},
2323
"dependencies": {
24-
"@acala-network/api": "^4.0.4-1",
25-
"@acala-network/sdk": "^4.0.4-1",
26-
"@acala-network/sdk-core": "^4.0.4-1",
27-
"@acala-network/sdk-swap": "^4.0.4-1",
28-
"@acala-network/sdk-wallet": "^4.0.4-1",
24+
"@acala-network/api": "^4.1.2-28",
25+
"@acala-network/sdk": "^4.1.2-28",
26+
"@acala-network/sdk-core": "^4.1.2-28",
27+
"@acala-network/sdk-swap": "^4.1.2-28",
28+
"@acala-network/sdk-wallet": "^4.1.2-28",
2929
"@babel/polyfill": "^7.8.3",
3030
"@polkadot/api": "^7.2.1",
3131
"@polkadot/ui-shared": "^0.85.3",
@@ -51,5 +51,21 @@
5151
"stream-browserify": "^3.0.0",
5252
"webpack": "^5.58.2",
5353
"webpack-cli": "^4.9.0"
54+
},
55+
"browserslist": {
56+
"production": [
57+
"chrome >= 67",
58+
"edge >= 79",
59+
"firefox >= 68",
60+
"opera >= 54",
61+
"safari >= 13",
62+
"android >= 56",
63+
"ios_saf >= 13"
64+
],
65+
"development": [
66+
"last 1 chrome version",
67+
"last 1 firefox version",
68+
"last 1 safari version"
69+
]
5470
}
5571
}

0 commit comments

Comments
 (0)