@aurigami/sdk 0.3.0 → 0.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/constants.d.ts +1 -1
- package/dist/sdk.cjs.development.js +69 -82
- package/dist/sdk.cjs.development.js.map +1 -1
- package/dist/sdk.cjs.production.min.js +1 -1
- package/dist/sdk.cjs.production.min.js.map +1 -1
- package/dist/sdk.esm.js +69 -82
- package/dist/sdk.esm.js.map +1 -1
- package/dist/types.d.ts +1 -0
- package/package.json +2 -2
- package/src/MoneyMarket.ts +1 -7
- package/src/SDK.ts +6 -9
- package/src/constants.ts +24 -24
- package/src/decimals.ts +17 -16
- package/src/types.ts +1 -0
package/dist/constants.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import BigNumber from 'bignumber.js';
|
|
|
2
2
|
import { Signer } from 'ethers';
|
|
3
3
|
export declare const AVAX_DEFAULT_PROVIDER_URL = "https://api.avax.network/ext/bc/C/rpc";
|
|
4
4
|
export declare const AVAX_DEFAULT_PROVIDER: any;
|
|
5
|
-
export declare const AURORA_DEFAULT_PROVIDER_URL = "https://
|
|
5
|
+
export declare const AURORA_DEFAULT_PROVIDER_URL = "https://mainnet.aurora.dev";
|
|
6
6
|
export declare const AURORA_DEFAULT_PROVIDER: any;
|
|
7
7
|
export declare const dummyAddress: string;
|
|
8
8
|
export declare const ETHAddress: string;
|
|
@@ -900,7 +900,7 @@ var ethers = /*#__PURE__*/require('ethers');
|
|
|
900
900
|
|
|
901
901
|
var AVAX_DEFAULT_PROVIDER_URL = 'https://api.avax.network/ext/bc/C/rpc';
|
|
902
902
|
var AVAX_DEFAULT_PROVIDER = /*#__PURE__*/new ethers.providers.JsonRpcProvider(AVAX_DEFAULT_PROVIDER_URL);
|
|
903
|
-
var AURORA_DEFAULT_PROVIDER_URL = "https://
|
|
903
|
+
var AURORA_DEFAULT_PROVIDER_URL = "https://mainnet.aurora.dev";
|
|
904
904
|
var AURORA_DEFAULT_PROVIDER = /*#__PURE__*/new ethers.providers.JsonRpcProvider(AURORA_DEFAULT_PROVIDER_URL);
|
|
905
905
|
var dummyAddress = "0xDEADbeEfEEeEEEeEEEeEEeeeeeEeEEeeeeEEEEeE";
|
|
906
906
|
var ETHAddress = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE";
|
|
@@ -910,41 +910,41 @@ var AURORA_CHAINID = 1313161554;
|
|
|
910
910
|
var DECIMAL_PRECISION = 6;
|
|
911
911
|
var networkAddresses = {
|
|
912
912
|
auTokens: [{
|
|
913
|
-
address: /*#__PURE__*/'
|
|
914
|
-
underlying: /*#__PURE__*/'
|
|
913
|
+
address: /*#__PURE__*/'0x2dEf6eb801757655AD227110d65C80DB595bBc60'.toLowerCase(),
|
|
914
|
+
underlying: /*#__PURE__*/'0xb12bfca5a55806aaf64e99521918a4bf0fc40802'.toLowerCase()
|
|
915
915
|
}, {
|
|
916
|
-
address: /*#__PURE__*/'
|
|
916
|
+
address: /*#__PURE__*/'0x7b47690b04494A628151Dbb86B4cC95CF2629B14'.toLowerCase(),
|
|
917
917
|
underlying: /*#__PURE__*/ETHAddress.toLowerCase()
|
|
918
918
|
}, {
|
|
919
|
-
address: /*#__PURE__*/'
|
|
920
|
-
underlying: /*#__PURE__*/'
|
|
919
|
+
address: /*#__PURE__*/'0xFB0e4680B8b1c7B69fb6a3988029c74fea871DD9'.toLowerCase(),
|
|
920
|
+
underlying: /*#__PURE__*/'0xf4eb217ba2454613b15dbdea6e5f22276410e89e'.toLowerCase()
|
|
921
921
|
}, {
|
|
922
|
-
address: /*#__PURE__*/'
|
|
923
|
-
underlying: /*#__PURE__*/'
|
|
922
|
+
address: /*#__PURE__*/'0x6bB82009b316A9098C23E3962b4371E879c8D23D'.toLowerCase(),
|
|
923
|
+
underlying: /*#__PURE__*/'0x4988a896b1227218e4a686fde5eabdcabd91571f'.toLowerCase()
|
|
924
924
|
}, {
|
|
925
|
-
address: /*#__PURE__*/'
|
|
926
|
-
underlying: /*#__PURE__*/'
|
|
925
|
+
address: /*#__PURE__*/'0xBf43057c634868251e65e39b4f27662f644454b4'.toLowerCase(),
|
|
926
|
+
underlying: /*#__PURE__*/'0xe3520349f477a5f6eb06107066048508498a291b'.toLowerCase()
|
|
927
927
|
}, {
|
|
928
|
-
address: /*#__PURE__*/'
|
|
929
|
-
underlying: /*#__PURE__*/'
|
|
928
|
+
address: /*#__PURE__*/'0x83Ae17f197C1F1260543d4D5A710772761535066'.toLowerCase(),
|
|
929
|
+
underlying: /*#__PURE__*/'0x8bec47865ade3b172a928df8f990bc7f2a3b9f79'.toLowerCase()
|
|
930
930
|
}, {
|
|
931
|
-
address: /*#__PURE__*/'
|
|
932
|
-
underlying: /*#__PURE__*/'
|
|
931
|
+
address: /*#__PURE__*/'0xcC5CA0156317C1FF2A96E0f45659625081352071'.toLowerCase(),
|
|
932
|
+
underlying: /*#__PURE__*/'0xC42C30aC6Cc15faC9bD938618BcaA1a1FaE8501d'.toLowerCase()
|
|
933
933
|
}, {
|
|
934
|
-
address: /*#__PURE__*/'
|
|
935
|
-
underlying: /*#__PURE__*/'
|
|
934
|
+
address: /*#__PURE__*/'0x173Bf18675D52B4887C5d40E935C3ab1192aFb4C'.toLowerCase(),
|
|
935
|
+
underlying: /*#__PURE__*/'0xb9b8d9e5557381BF025f1A59B602ad3F19A4e4Be'.toLowerCase()
|
|
936
936
|
}],
|
|
937
937
|
misc: {
|
|
938
|
-
COMPTROLLER: /*#__PURE__*/"
|
|
939
|
-
oracle: /*#__PURE__*/"
|
|
940
|
-
AURIFAIRLAUNCH: /*#__PURE__*/"
|
|
941
|
-
AURILENS: /*#__PURE__*/'
|
|
942
|
-
TOKENLOCK: /*#__PURE__*/'
|
|
938
|
+
COMPTROLLER: /*#__PURE__*/"0x3b416D37A85F7aD941e36258d4Da660A1898E181".toLowerCase(),
|
|
939
|
+
oracle: /*#__PURE__*/"0x08A74ca75BAE803e92752f8d7A5cD718b1cA6509".toLowerCase(),
|
|
940
|
+
AURIFAIRLAUNCH: /*#__PURE__*/"0xeed0433Cbc81F25061bb739Ff8f1D5736b16d038".toLowerCase(),
|
|
941
|
+
AURILENS: /*#__PURE__*/'0xb11820C3d8ae1f6C31047644C59190280651C9da'.toLowerCase(),
|
|
942
|
+
TOKENLOCK: /*#__PURE__*/'0x537754515509A83Ce2D076c0982292AC5289b408'.toLowerCase()
|
|
943
943
|
},
|
|
944
944
|
tokens: {
|
|
945
|
-
AURORA: /*#__PURE__*/"
|
|
946
|
-
PLY: /*#__PURE__*/"
|
|
947
|
-
AURPLY: /*#__PURE__*/
|
|
945
|
+
AURORA: /*#__PURE__*/"0x8bec47865ade3b172a928df8f990bc7f2a3b9f79".toLowerCase(),
|
|
946
|
+
PLY: /*#__PURE__*/"0xb9b8d9e5557381BF025f1A59B602ad3F19A4e4Be".toLowerCase(),
|
|
947
|
+
AURPLY: /*#__PURE__*/"0x822E871518C22E8570cFbEa43FddbBFF963d4bdE".toLowerCase()
|
|
948
948
|
}
|
|
949
949
|
};
|
|
950
950
|
var BORROW_LIMIT_BUFFER = /*#__PURE__*/new BigNumber(0.95);
|
|
@@ -955,21 +955,22 @@ var AurPlyPid = 0;
|
|
|
955
955
|
|
|
956
956
|
var decimalRecords = {
|
|
957
957
|
'0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee': 18,
|
|
958
|
-
'
|
|
959
|
-
'
|
|
960
|
-
'
|
|
961
|
-
'
|
|
962
|
-
'
|
|
963
|
-
'
|
|
964
|
-
'
|
|
965
|
-
'
|
|
966
|
-
'
|
|
967
|
-
'
|
|
968
|
-
'
|
|
969
|
-
'
|
|
970
|
-
'
|
|
971
|
-
'
|
|
972
|
-
'
|
|
958
|
+
'0xb9b8d9e5557381bf025f1a59b602ad3f19a4e4be': 18,
|
|
959
|
+
'0x83ae17f197c1f1260543d4d5a710772761535066': 8,
|
|
960
|
+
'0xf4eb217ba2454613b15dbdea6e5f22276410e89e': 8,
|
|
961
|
+
'0x4988a896b1227218e4a686fde5eabdcabd91571f': 6,
|
|
962
|
+
'0xfb0e4680b8b1c7b69fb6a3988029c74fea871dd9': 8,
|
|
963
|
+
'0xb12bfca5a55806aaf64e99521918a4bf0fc40802': 6,
|
|
964
|
+
'0xbf43057c634868251e65e39b4f27662f644454b4': 8,
|
|
965
|
+
'0xc42c30ac6cc15fac9bd938618bcaa1a1fae8501d': 24,
|
|
966
|
+
'0x7b47690b04494a628151dbb86b4cc95cf2629b14': 8,
|
|
967
|
+
'0x822e871518c22e8570cfbea43fddbbff963d4bde': 18,
|
|
968
|
+
'0x2def6eb801757655ad227110d65c80db595bbc60': 8,
|
|
969
|
+
'0x6bb82009b316a9098c23e3962b4371e879c8d23d': 8,
|
|
970
|
+
'0x8bec47865ade3b172a928df8f990bc7f2a3b9f79': 18,
|
|
971
|
+
'0xcc5ca0156317c1ff2a96e0f45659625081352071': 8,
|
|
972
|
+
'0xe3520349f477a5f6eb06107066048508498a291b': 18,
|
|
973
|
+
'0x173bf18675d52b4887c5d40e935c3ab1192afb4c': 8
|
|
973
974
|
};
|
|
974
975
|
|
|
975
976
|
function formatObject(object) {
|
|
@@ -2343,32 +2344,19 @@ var MoneyMarketRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
2343
2344
|
|
|
2344
2345
|
_proto.getRewardSpeeds = /*#__PURE__*/function () {
|
|
2345
2346
|
var _getRewardSpeeds = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
|
|
2346
|
-
var
|
|
2347
|
+
var speeds;
|
|
2347
2348
|
return runtime_1.wrap(function _callee$(_context) {
|
|
2348
2349
|
while (1) {
|
|
2349
2350
|
switch (_context.prev = _context.next) {
|
|
2350
2351
|
case 0:
|
|
2351
|
-
|
|
2352
|
-
|
|
2353
|
-
promises.push(this._comptroller.rewardSpeeds(exports.ComptrollerRewardType.PLY, this.auToken.address, true).then(function (res) {
|
|
2354
|
-
speeds.plyRewardSupplySpeed = res;
|
|
2355
|
-
}));
|
|
2356
|
-
promises.push(this._comptroller.rewardSpeeds(exports.ComptrollerRewardType.PLY, this.auToken.address, false).then(function (res) {
|
|
2357
|
-
speeds.plyRewardBorrowSpeed = res;
|
|
2358
|
-
}));
|
|
2359
|
-
promises.push(this._comptroller.rewardSpeeds(exports.ComptrollerRewardType.AURORA, this.auToken.address, true).then(function (res) {
|
|
2360
|
-
speeds.auroraRewardSupplySpeed = res;
|
|
2361
|
-
}));
|
|
2362
|
-
promises.push(this._comptroller.rewardSpeeds(exports.ComptrollerRewardType.AURORA, this.auToken.address, false).then(function (res) {
|
|
2363
|
-
speeds.auroraRewardBorrowSpeed = res;
|
|
2364
|
-
}));
|
|
2365
|
-
_context.next = 8;
|
|
2366
|
-
return Promise.all(promises);
|
|
2352
|
+
_context.next = 2;
|
|
2353
|
+
return this._auriLens.getRewardSpeeds(this._comptroller.address, this.auToken.address);
|
|
2367
2354
|
|
|
2368
|
-
case
|
|
2355
|
+
case 2:
|
|
2356
|
+
speeds = _context.sent;
|
|
2369
2357
|
return _context.abrupt("return", speeds);
|
|
2370
2358
|
|
|
2371
|
-
case
|
|
2359
|
+
case 4:
|
|
2372
2360
|
case "end":
|
|
2373
2361
|
return _context.stop();
|
|
2374
2362
|
}
|
|
@@ -2968,11 +2956,10 @@ var SdkRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
2968
2956
|
while (1) {
|
|
2969
2957
|
switch (_context.prev = _context.next) {
|
|
2970
2958
|
case 0:
|
|
2971
|
-
|
|
2972
|
-
_context.next = 3;
|
|
2959
|
+
_context.next = 2;
|
|
2973
2960
|
return getCurrentTimestamp(this._networkConnection.provider);
|
|
2974
2961
|
|
|
2975
|
-
case
|
|
2962
|
+
case 2:
|
|
2976
2963
|
currentTime = _context.sent;
|
|
2977
2964
|
currentWeek = ethers$1.BigNumber.from(currentTime - REWARDCLAIMSTART).div(7 * ONE_DAY).toNumber();
|
|
2978
2965
|
denominator = 10000;
|
|
@@ -2981,14 +2968,14 @@ var SdkRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
2981
2968
|
promises.push(this._tokenLock.percentageLock(currentWeek + 1)["catch"](function (err) {
|
|
2982
2969
|
return denominator;
|
|
2983
2970
|
}));
|
|
2984
|
-
_context.next =
|
|
2971
|
+
_context.next = 10;
|
|
2985
2972
|
return Promise.all(promises).then(function (res) {
|
|
2986
2973
|
return res.map(function (v) {
|
|
2987
2974
|
return v.toString();
|
|
2988
2975
|
});
|
|
2989
2976
|
});
|
|
2990
2977
|
|
|
2991
|
-
case
|
|
2978
|
+
case 10:
|
|
2992
2979
|
values = _context.sent;
|
|
2993
2980
|
return _context.abrupt("return", {
|
|
2994
2981
|
vestingStart: REWARDCLAIMSTART,
|
|
@@ -2996,7 +2983,7 @@ var SdkRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
2996
2983
|
nextUnlockPortion: new BigNumber(denominator).minus(values[1]).div(denominator).toNumber()
|
|
2997
2984
|
});
|
|
2998
2985
|
|
|
2999
|
-
case
|
|
2986
|
+
case 12:
|
|
3000
2987
|
case "end":
|
|
3001
2988
|
return _context.stop();
|
|
3002
2989
|
}
|
|
@@ -3015,7 +3002,7 @@ var SdkRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
3015
3002
|
var _getUserDetails = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(userAddress) {
|
|
3016
3003
|
var _this2 = this;
|
|
3017
3004
|
|
|
3018
|
-
var marketCount, userMarketDetails, assetsIn,
|
|
3005
|
+
var marketCount, userMarketDetails, assetsIn, promises, totalBorrowLimit, pricePromises, _loop2, _iterator, _step, underlyingPrices, depositValuationPromises, _loop, i, depositValues, accountLiquidity, rewardBalancesMetadata, lockedAmount, values, borrowedvaluation, bufferedBorrowLimit, borrowableAmount, auToken, moneyMarket;
|
|
3019
3006
|
|
|
3020
3007
|
return runtime_1.wrap(function _callee2$(_context2) {
|
|
3021
3008
|
while (1) {
|
|
@@ -3023,7 +3010,6 @@ var SdkRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
3023
3010
|
case 0:
|
|
3024
3011
|
marketCount = networkAddresses.auTokens.length;
|
|
3025
3012
|
userMarketDetails = [];
|
|
3026
|
-
collateralRatio = new Array(marketCount);
|
|
3027
3013
|
promises = [];
|
|
3028
3014
|
totalBorrowLimit = new BigNumber(0);
|
|
3029
3015
|
pricePromises = [];
|
|
@@ -3041,7 +3027,7 @@ var SdkRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
3041
3027
|
userMarketDetail.borrowBalance = res;
|
|
3042
3028
|
}));
|
|
3043
3029
|
promises.push(moneyMarket.getCollateralRatio().then(function (res) {
|
|
3044
|
-
collateralRatio
|
|
3030
|
+
userMarketDetail.collateralRatio = res.toNumber();
|
|
3045
3031
|
}));
|
|
3046
3032
|
pricePromises.push(fetchPrice(moneyMarket.underlying.address, _this2._networkConnection.provider));
|
|
3047
3033
|
};
|
|
@@ -3053,24 +3039,26 @@ var SdkRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
3053
3039
|
promises.push(this._comptroller.getAssetsIn(userAddress).then(function (res) {
|
|
3054
3040
|
assetsIn = res;
|
|
3055
3041
|
}));
|
|
3056
|
-
_context2.next =
|
|
3042
|
+
_context2.next = 10;
|
|
3057
3043
|
return Promise.all(promises);
|
|
3058
3044
|
|
|
3059
|
-
case
|
|
3060
|
-
_context2.next =
|
|
3045
|
+
case 10:
|
|
3046
|
+
_context2.next = 12;
|
|
3061
3047
|
return Promise.all(pricePromises);
|
|
3062
3048
|
|
|
3063
|
-
case
|
|
3049
|
+
case 12:
|
|
3064
3050
|
underlyingPrices = _context2.sent;
|
|
3065
3051
|
depositValuationPromises = [];
|
|
3066
3052
|
|
|
3067
3053
|
_loop = function _loop() {
|
|
3068
3054
|
var auToken = networkAddresses.auTokens[i];
|
|
3069
3055
|
|
|
3070
|
-
if (assetsIn.
|
|
3071
|
-
isSameAddress(auToken.address, auAddress);
|
|
3072
|
-
})
|
|
3056
|
+
if (assetsIn.find(function (auAddress) {
|
|
3057
|
+
return isSameAddress(auToken.address, auAddress);
|
|
3058
|
+
}) !== undefined) {
|
|
3073
3059
|
userMarketDetails[i].isCollateral = true;
|
|
3060
|
+
} else {
|
|
3061
|
+
userMarketDetails[i].isCollateral = false;
|
|
3074
3062
|
}
|
|
3075
3063
|
|
|
3076
3064
|
depositValuationPromises.push(fetchValuation(userMarketDetails[i].depositBalance, _this2._networkConnection.provider, underlyingPrices[i]));
|
|
@@ -3080,23 +3068,23 @@ var SdkRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
3080
3068
|
_loop();
|
|
3081
3069
|
}
|
|
3082
3070
|
|
|
3083
|
-
_context2.next =
|
|
3071
|
+
_context2.next = 18;
|
|
3084
3072
|
return Promise.all(depositValuationPromises);
|
|
3085
3073
|
|
|
3086
|
-
case
|
|
3074
|
+
case 18:
|
|
3087
3075
|
depositValues = _context2.sent;
|
|
3088
3076
|
totalBorrowLimit = depositValues.reduce(function (p, v, index) {
|
|
3089
|
-
if (userMarketDetails[index].isCollateral) return p.plus(v.multipliedBy(
|
|
3077
|
+
if (userMarketDetails[index].isCollateral) return p.plus(v.multipliedBy(userMarketDetails[index].collateralRatio));
|
|
3090
3078
|
return p;
|
|
3091
|
-
});
|
|
3079
|
+
}, new BigNumber(0));
|
|
3092
3080
|
promises = [];
|
|
3093
3081
|
promises.push(this._comptroller.getAccountLiquidity(userAddress));
|
|
3094
3082
|
promises.push(this._auriLens.callStatic.getRewardBalancesMetadata(this._comptroller.address, this._auriFairLaunch.address, userAddress, [AurPlyPid]));
|
|
3095
3083
|
promises.push(this._tokenLock.lockedAmounts(userAddress));
|
|
3096
|
-
_context2.next =
|
|
3084
|
+
_context2.next = 26;
|
|
3097
3085
|
return Promise.all(promises);
|
|
3098
3086
|
|
|
3099
|
-
case
|
|
3087
|
+
case 26:
|
|
3100
3088
|
values = _context2.sent;
|
|
3101
3089
|
accountLiquidity = values[0];
|
|
3102
3090
|
rewardBalancesMetadata = values[1];
|
|
@@ -3130,7 +3118,7 @@ var SdkRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
3130
3118
|
}
|
|
3131
3119
|
});
|
|
3132
3120
|
|
|
3133
|
-
case
|
|
3121
|
+
case 35:
|
|
3134
3122
|
case "end":
|
|
3135
3123
|
return _context2.stop();
|
|
3136
3124
|
}
|
|
@@ -3154,7 +3142,6 @@ var SdkRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
3154
3142
|
case 0:
|
|
3155
3143
|
promises = [];
|
|
3156
3144
|
promises.push(this._auriFairLaunch.getPoolInfo(AurPlyPid).then(function (res) {
|
|
3157
|
-
console.log(res);
|
|
3158
3145
|
stakedLiquidity = res.totalStake;
|
|
3159
3146
|
rewardPerSecond = res.rewardPerSecond;
|
|
3160
3147
|
}));
|