@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.
@@ -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: Address);
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: CurrencyAmount): Promise<TransactionResponse>;
14
- borrow(amount: CurrencyAmount): Promise<TransactionResponse>;
15
- withdraw(amount: CurrencyAmount): Promise<TransactionResponse>;
16
- repay(amount: CurrencyAmount): Promise<TransactionResponse>;
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: 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<CurrencyAmount>;
11
- stakeBalanceOf(user: string): Promise<CurrencyAmount>;
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: CurrencyAmount): Promise<TransactionResponse>;
17
- unstake(amount: CurrencyAmount): Promise<TransactionResponse>;
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();
@@ -1,4 +1,4 @@
1
- import { Token } from '@pendle/sdk-core';
1
+ import { Token } from './token';
2
2
  import { Signer } from 'ethers';
3
3
  export declare const DOLLAR: Token;
4
4
  export declare const AVAX_DEFAULT_PROVIDER_URL = "https://api.avax.network/ext/bc/C/rpc";
package/dist/dummy.d.ts CHANGED
@@ -1,11 +1,12 @@
1
- import { Token, CurrencyAmount } from '@pendle/sdk-core';
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: CurrencyAmount;
7
- export declare const dummyZeroTokenAmount: CurrencyAmount;
8
- export declare const dummyTokenAmount2: CurrencyAmount;
9
- export declare const dummyTokenAmount3: CurrencyAmount;
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
@@ -1 +1,3 @@
1
1
  export declare function formatObject(object: Object): string;
2
+ export declare const decimalFactor: (decimal: number) => string;
3
+ export declare function validateAndParseAddress(address: string): string;
@@ -2,7 +2,9 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var sdkCore = require('@pendle/sdk-core');
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 dummyToken = /*#__PURE__*/new sdkCore.Token({
849
- chainId: 43114,
850
- decimal: 6,
851
- symbol: 'USDC',
852
- address: '0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e'
853
- });
854
- var dummyPly = /*#__PURE__*/new sdkCore.Token({
855
- chainId: 43114,
856
- decimal: 18,
857
- symbol: 'QI',
858
- address: '0x8729438eb15e2c8b576fcc6aecda6a148776c0f5'
859
- });
860
- var dummyPlyAurora = /*#__PURE__*/new sdkCore.Token({
861
- chainId: 43114,
862
- decimal: 18,
863
- symbol: 'QIWAVAX',
864
- address: '0xE530dC2095Ef5653205CF5ea79F8979a7028065c'
865
- });
866
- var dummyTokenAmount = /*#__PURE__*/new sdkCore.CurrencyAmount({
867
- currency: dummyToken,
868
- amount: '123.456',
869
- isRaw: false
870
- });
871
- var dummyZeroTokenAmount = /*#__PURE__*/new sdkCore.CurrencyAmount({
872
- currency: dummyToken,
873
- amount: '0'
874
- });
875
- var dummyTokenAmount2 = /*#__PURE__*/new sdkCore.CurrencyAmount({
876
- currency: dummyToken,
877
- amount: '456.123',
878
- isRaw: false
879
- });
880
- var dummyTokenAmount3 = /*#__PURE__*/new sdkCore.CurrencyAmount({
881
- currency: dummyToken,
882
- amount: '1000.123',
883
- isRaw: false
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 sdkCore.Token({
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 sdkCore.CurrencyAmount({
2247
- currency: dummyPly,
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 sdkCore.CurrencyAmount({
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 sdkCore.CurrencyAmount({
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 sdkCore.CurrencyAmount({
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 sdkCore.CurrencyAmount({
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 = sdkCore.validateAndParseAddress(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