@aurigami/sdk 0.1.3 → 0.1.7
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/MoneyMarket.d.ts +7 -7
- package/dist/SDK.d.ts +6 -5
- package/dist/constants.d.ts +1 -1
- package/dist/dummy.d.ts +6 -5
- package/dist/helpers.d.ts +2 -0
- package/dist/sdk.cjs.development.js +68 -79
- 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 +65 -80
- package/dist/sdk.esm.js.map +1 -1
- package/dist/token.d.ts +6 -0
- package/dist/tokenAmount.d.ts +8 -0
- package/dist/types.d.ts +12 -12
- package/package.json +2 -2
- package/src/MoneyMarket.ts +10 -12
- package/src/SDK.ts +37 -35
- package/src/constants.ts +4 -7
- package/src/dummy.ts +30 -44
- package/src/helpers.ts +15 -0
- package/src/token.ts +11 -0
- package/src/tokenAmount.ts +29 -0
- package/src/types.ts +12 -12
package/dist/MoneyMarket.d.ts
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
import { BlockchainEntity, BlockchainEntityRead } from './BlockchainEntity';
|
|
2
2
|
import { ProviderOrSigner, MoneyMarketDetails } from './types';
|
|
3
|
-
import { Address, CurrencyAmount } from '@pendle/sdk-core';
|
|
4
3
|
import { Contract } from 'ethers';
|
|
5
4
|
import { TransactionResponse } from '@ethersproject/abstract-provider';
|
|
5
|
+
import { TokenAmount } from './tokenAmount';
|
|
6
6
|
export declare class MoneyMarketRead extends BlockchainEntityRead {
|
|
7
7
|
protected _auToken: Contract;
|
|
8
|
-
constructor(providerOrSigner: ProviderOrSigner, auToken:
|
|
8
|
+
constructor(providerOrSigner: ProviderOrSigner, auToken: string);
|
|
9
9
|
getDetails(): Promise<MoneyMarketDetails>;
|
|
10
10
|
}
|
|
11
11
|
export declare class MoneyMarketReadWrite extends MoneyMarketRead {
|
|
12
12
|
dummyTransaction: () => Promise<TransactionResponse>;
|
|
13
|
-
deposit(amount:
|
|
14
|
-
borrow(amount:
|
|
15
|
-
withdraw(amount:
|
|
16
|
-
repay(amount:
|
|
13
|
+
deposit(amount: TokenAmount): Promise<TransactionResponse>;
|
|
14
|
+
borrow(amount: TokenAmount): Promise<TransactionResponse>;
|
|
15
|
+
withdraw(amount: TokenAmount): Promise<TransactionResponse>;
|
|
16
|
+
repay(amount: TokenAmount): Promise<TransactionResponse>;
|
|
17
17
|
enableCollateral(): Promise<TransactionResponse>;
|
|
18
18
|
disableCollateral(): Promise<TransactionResponse>;
|
|
19
19
|
}
|
|
20
20
|
export declare class MoneyMarket extends BlockchainEntity {
|
|
21
|
-
protected address:
|
|
21
|
+
protected address: string;
|
|
22
22
|
constructor(address: string);
|
|
23
23
|
read(provider: ProviderOrSigner): MoneyMarketRead;
|
|
24
24
|
}
|
package/dist/SDK.d.ts
CHANGED
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
import { BlockchainEntity, BlockchainEntityRead } from './BlockchainEntity';
|
|
2
2
|
import { LockingDetails, PlyAuroraPoolDetails, ProviderOrSigner, UserDetails } from './types';
|
|
3
|
-
import { Token, CurrencyAmount } from '@pendle/sdk-core';
|
|
4
3
|
import { TransactionResponse } from '@ethersproject/abstract-provider';
|
|
4
|
+
import { TokenAmount } from './tokenAmount';
|
|
5
|
+
import { Token } from './token';
|
|
5
6
|
export declare class SdkRead extends BlockchainEntityRead {
|
|
6
7
|
constructor(providerOrSigner: ProviderOrSigner);
|
|
7
8
|
getLockingDetails(): Promise<LockingDetails>;
|
|
8
9
|
getUserDetails(userAddress: string): Promise<UserDetails>;
|
|
9
10
|
getPlyAuroraPoolDetails(): Promise<PlyAuroraPoolDetails>;
|
|
10
|
-
getTokenPrice(token: Token): Promise<
|
|
11
|
-
stakeBalanceOf(user: string): Promise<
|
|
11
|
+
getTokenPrice(token: Token): Promise<TokenAmount>;
|
|
12
|
+
stakeBalanceOf(user: string): Promise<TokenAmount>;
|
|
12
13
|
}
|
|
13
14
|
export declare class SdkReadWrite extends SdkRead {
|
|
14
15
|
dummyTransaction: () => Promise<TransactionResponse>;
|
|
15
16
|
claim(): Promise<TransactionResponse>;
|
|
16
|
-
stake(amount:
|
|
17
|
-
unstake(amount:
|
|
17
|
+
stake(amount: TokenAmount): Promise<TransactionResponse>;
|
|
18
|
+
unstake(amount: TokenAmount): Promise<TransactionResponse>;
|
|
18
19
|
}
|
|
19
20
|
export declare class SDK extends BlockchainEntity {
|
|
20
21
|
constructor();
|
package/dist/constants.d.ts
CHANGED
package/dist/dummy.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { Token
|
|
1
|
+
import { Token } from './token';
|
|
2
|
+
import { TokenAmount } from './tokenAmount';
|
|
2
3
|
import { UserMarketDetails } from './types';
|
|
3
4
|
export declare const dummyToken: Token;
|
|
4
5
|
export declare const dummyPly: Token;
|
|
5
6
|
export declare const dummyPlyAurora: Token;
|
|
6
|
-
export declare const dummyTokenAmount:
|
|
7
|
-
export declare const dummyZeroTokenAmount:
|
|
8
|
-
export declare const dummyTokenAmount2:
|
|
9
|
-
export declare const dummyTokenAmount3:
|
|
7
|
+
export declare const dummyTokenAmount: TokenAmount;
|
|
8
|
+
export declare const dummyZeroTokenAmount: TokenAmount;
|
|
9
|
+
export declare const dummyTokenAmount2: TokenAmount;
|
|
10
|
+
export declare const dummyTokenAmount3: TokenAmount;
|
|
10
11
|
export declare const dummyMarketAddress = "0xbeb5d47a3f720ec0a390d04b4d41ed7d9688bc7f";
|
|
11
12
|
export declare const dummyUserMarketDetails: UserMarketDetails;
|
package/dist/helpers.d.ts
CHANGED
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
|
|
6
|
+
|
|
7
|
+
var BigNumber = _interopDefault(require('bignumber.js'));
|
|
6
8
|
var ethers$2 = require('ethers');
|
|
7
9
|
|
|
8
10
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
@@ -845,43 +847,61 @@ var BlockchainEntity = /*#__PURE__*/function () {
|
|
|
845
847
|
return BlockchainEntity;
|
|
846
848
|
}();
|
|
847
849
|
|
|
848
|
-
var
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
}
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
}
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
isRaw
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
850
|
+
var Token = function Token(address, decimals, expiry) {
|
|
851
|
+
this.address = address.toLowerCase();
|
|
852
|
+
this.decimals = decimals;
|
|
853
|
+
this.expiry = expiry;
|
|
854
|
+
};
|
|
855
|
+
|
|
856
|
+
function formatObject(object) {
|
|
857
|
+
return JSON.stringify(object, null, ' ');
|
|
858
|
+
}
|
|
859
|
+
var decimalFactor = function decimalFactor(decimal) {
|
|
860
|
+
return ethers$2.BigNumber.from(10).pow(decimal).toString();
|
|
861
|
+
};
|
|
862
|
+
function validateAndParseAddress(address) {
|
|
863
|
+
try {
|
|
864
|
+
return ethers$2.utils.getAddress(address);
|
|
865
|
+
} catch (error) {
|
|
866
|
+
throw new Error("Invalid address " + address);
|
|
867
|
+
}
|
|
868
|
+
}
|
|
869
|
+
|
|
870
|
+
var TokenAmount = /*#__PURE__*/function () {
|
|
871
|
+
function TokenAmount(token, amount, isRaw) {
|
|
872
|
+
if (isRaw === void 0) {
|
|
873
|
+
isRaw = true;
|
|
874
|
+
}
|
|
875
|
+
|
|
876
|
+
if (isRaw) {
|
|
877
|
+
this.rawAmnt = amount;
|
|
878
|
+
} else {
|
|
879
|
+
this.rawAmnt = new BigNumber(amount).times(decimalFactor(token.decimals)).toFixed(0);
|
|
880
|
+
}
|
|
881
|
+
|
|
882
|
+
this.token = token;
|
|
883
|
+
}
|
|
884
|
+
|
|
885
|
+
var _proto = TokenAmount.prototype;
|
|
886
|
+
|
|
887
|
+
_proto.formattedAmount = function formattedAmount() {
|
|
888
|
+
return new BigNumber(this.rawAmnt).div(decimalFactor(this.token.decimals)).toString();
|
|
889
|
+
};
|
|
890
|
+
|
|
891
|
+
_proto.rawAmount = function rawAmount() {
|
|
892
|
+
return this.rawAmnt;
|
|
893
|
+
};
|
|
894
|
+
|
|
895
|
+
return TokenAmount;
|
|
896
|
+
}();
|
|
897
|
+
|
|
898
|
+
var dummyToken = /*#__PURE__*/new Token('0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e', 6);
|
|
899
|
+
var dummyPly = /*#__PURE__*/new Token('0x8729438eb15e2c8b576fcc6aecda6a148776c0f5', 18);
|
|
900
|
+
var dummyPlyAurora = /*#__PURE__*/new Token('0xE530dC2095Ef5653205CF5ea79F8979a7028065c', 18);
|
|
901
|
+
var dummyTokenAmount = /*#__PURE__*/new TokenAmount(dummyToken, '123.456', false);
|
|
902
|
+
var dummyZeroTokenAmount = /*#__PURE__*/new TokenAmount(dummyToken, '0');
|
|
903
|
+
var dummyTokenAmount2 = /*#__PURE__*/new TokenAmount(dummyToken, '456.123', false);
|
|
904
|
+
var dummyTokenAmount3 = /*#__PURE__*/new TokenAmount(dummyToken, '1000.123', false);
|
|
885
905
|
var dummyMarketAddress = '0xbeb5d47a3f720ec0a390d04b4d41ed7d9688bc7f';
|
|
886
906
|
var dummyUserMarketDetails = {
|
|
887
907
|
market: dummyMarketAddress,
|
|
@@ -893,12 +913,7 @@ var dummyUserMarketDetails = {
|
|
|
893
913
|
|
|
894
914
|
var ethers = /*#__PURE__*/require('ethers');
|
|
895
915
|
|
|
896
|
-
var DOLLAR = /*#__PURE__*/new
|
|
897
|
-
chainId: 43114,
|
|
898
|
-
decimal: 2,
|
|
899
|
-
symbol: 'USDC',
|
|
900
|
-
address: '0x0000000000000000000000000000000000000001'
|
|
901
|
-
});
|
|
916
|
+
var DOLLAR = /*#__PURE__*/new Token('0x0000000000000000000000000000000000000001', 2);
|
|
902
917
|
var AVAX_DEFAULT_PROVIDER_URL = 'https://api.avax.network/ext/bc/C/rpc';
|
|
903
918
|
var AVAX_DEFAULT_PROVIDER = /*#__PURE__*/new ethers.providers.JsonRpcProvider(AVAX_DEFAULT_PROVIDER_URL);
|
|
904
919
|
var dummyPrivateKey = '1111111111111111111111111111111111111111111111111111111111111111';
|
|
@@ -2243,16 +2258,8 @@ var SdkRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
2243
2258
|
return _context2.abrupt("return", {
|
|
2244
2259
|
markets: [dummyUserMarketDetails],
|
|
2245
2260
|
borrowLimit: dummyTokenAmount3,
|
|
2246
|
-
accruedPly: new
|
|
2247
|
-
|
|
2248
|
-
amount: '100.12',
|
|
2249
|
-
isRaw: false
|
|
2250
|
-
}),
|
|
2251
|
-
lockedPly: new sdkCore.CurrencyAmount({
|
|
2252
|
-
currency: dummyPly,
|
|
2253
|
-
amount: '200.12',
|
|
2254
|
-
isRaw: false
|
|
2255
|
-
}),
|
|
2261
|
+
accruedPly: new TokenAmount(dummyPly, '100.12', false),
|
|
2262
|
+
lockedPly: new TokenAmount(dummyPly, '200.12', false),
|
|
2256
2263
|
borrowableAmount: dummyTokenAmount2
|
|
2257
2264
|
});
|
|
2258
2265
|
|
|
@@ -2278,11 +2285,7 @@ var SdkRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
2278
2285
|
switch (_context3.prev = _context3.next) {
|
|
2279
2286
|
case 0:
|
|
2280
2287
|
return _context3.abrupt("return", {
|
|
2281
|
-
totalStakedLiquidity: new
|
|
2282
|
-
currency: dummyPlyAurora,
|
|
2283
|
-
amount: '12.1',
|
|
2284
|
-
isRaw: false
|
|
2285
|
-
}),
|
|
2288
|
+
totalStakedLiquidity: new TokenAmount(dummyPlyAurora, '12.1', false),
|
|
2286
2289
|
apy: 1.21
|
|
2287
2290
|
});
|
|
2288
2291
|
|
|
@@ -2312,18 +2315,10 @@ var SdkRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
2312
2315
|
break;
|
|
2313
2316
|
}
|
|
2314
2317
|
|
|
2315
|
-
return _context4.abrupt("return", new
|
|
2316
|
-
currency: DOLLAR,
|
|
2317
|
-
amount: '1',
|
|
2318
|
-
isRaw: false
|
|
2319
|
-
}));
|
|
2318
|
+
return _context4.abrupt("return", new TokenAmount(DOLLAR, '1', false));
|
|
2320
2319
|
|
|
2321
2320
|
case 2:
|
|
2322
|
-
return _context4.abrupt("return", new
|
|
2323
|
-
currency: DOLLAR,
|
|
2324
|
-
amount: '12.1',
|
|
2325
|
-
isRaw: false
|
|
2326
|
-
}));
|
|
2321
|
+
return _context4.abrupt("return", new TokenAmount(DOLLAR, '12.1', false));
|
|
2327
2322
|
|
|
2328
2323
|
case 3:
|
|
2329
2324
|
case "end":
|
|
@@ -2346,11 +2341,7 @@ var SdkRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
2346
2341
|
while (1) {
|
|
2347
2342
|
switch (_context5.prev = _context5.next) {
|
|
2348
2343
|
case 0:
|
|
2349
|
-
return _context5.abrupt("return", new
|
|
2350
|
-
currency: dummyPlyAurora,
|
|
2351
|
-
amount: '103.4',
|
|
2352
|
-
isRaw: false
|
|
2353
|
-
}));
|
|
2344
|
+
return _context5.abrupt("return", new TokenAmount(dummyPlyAurora, '103.4', false));
|
|
2354
2345
|
|
|
2355
2346
|
case 1:
|
|
2356
2347
|
case "end":
|
|
@@ -4283,7 +4274,7 @@ var MoneyMarket = /*#__PURE__*/function (_BlockchainEntity) {
|
|
|
4283
4274
|
var _this3;
|
|
4284
4275
|
|
|
4285
4276
|
_this3 = _BlockchainEntity.call(this) || this;
|
|
4286
|
-
_this3.address =
|
|
4277
|
+
_this3.address = validateAndParseAddress(address);
|
|
4287
4278
|
return _this3;
|
|
4288
4279
|
}
|
|
4289
4280
|
|
|
@@ -4296,10 +4287,6 @@ var MoneyMarket = /*#__PURE__*/function (_BlockchainEntity) {
|
|
|
4296
4287
|
return MoneyMarket;
|
|
4297
4288
|
}(BlockchainEntity);
|
|
4298
4289
|
|
|
4299
|
-
function formatObject(object) {
|
|
4300
|
-
return JSON.stringify(object, null, ' ');
|
|
4301
|
-
}
|
|
4302
|
-
|
|
4303
4290
|
function sum(a, b) {
|
|
4304
4291
|
return a + b;
|
|
4305
4292
|
}
|
|
@@ -4317,6 +4304,7 @@ exports.MoneyMarketReadWrite = MoneyMarketReadWrite;
|
|
|
4317
4304
|
exports.SDK = SDK;
|
|
4318
4305
|
exports.SdkRead = SdkRead;
|
|
4319
4306
|
exports.SdkReadWrite = SdkReadWrite;
|
|
4307
|
+
exports.decimalFactor = decimalFactor;
|
|
4320
4308
|
exports.dummyMarketAddress = dummyMarketAddress;
|
|
4321
4309
|
exports.dummyPly = dummyPly;
|
|
4322
4310
|
exports.dummyPlyAurora = dummyPlyAurora;
|
|
@@ -4328,4 +4316,5 @@ exports.dummyUserMarketDetails = dummyUserMarketDetails;
|
|
|
4328
4316
|
exports.dummyZeroTokenAmount = dummyZeroTokenAmount;
|
|
4329
4317
|
exports.formatObject = formatObject;
|
|
4330
4318
|
exports.sum = sum;
|
|
4319
|
+
exports.validateAndParseAddress = validateAndParseAddress;
|
|
4331
4320
|
//# sourceMappingURL=sdk.cjs.development.js.map
|