3.0.39 • Published 1 year ago

@wildcatfi/wildcat-sdk v3.0.39

Weekly downloads
-
License
MIT
Repository
-
Last release
1 year ago

MarketController

Deploying markets

1. Get controller info for borrower

import { getController, MarketController, MarketParameters } from "@wildcatfi/wildcat-sdk";

const controller: MarketController = await getController(signer, borrower);

2. Get parameter constraints for new markets

controller.constraints: MarketParameterConstraints contains the min/max values of

  • annualInterestBips
  • delinquencyFeeBips
  • withdrawalBatchDuration
  • reserveRatioBips
  • delinquencyGracePeriod

If provided values are out of this range, market deployment will revert.

3. Deploying a mock token for new market

import { deployToken } from "@wildcatfi/wildcat-sdk";

await deployToken(signer, "name", "symbol");

4. Deploying new market

const marketParameters: MarketParameters = {...}

// 1. Ensure borrower is registered on the arch-controller.
// For the testnet deployment, anyone can register a borrower
if (!controller.isRegisteredBorrower) {
  await controller.registerBorrower()
}
// 2. Ensure the `asset, namePrefix, symbolPrefix` are unique.
if (controller.getExistingMarketForParameters(marketParameters)) {
  throw Error()
}
// 3. Deploy market
const market: Market = await controller.deployMarket(marketParameters);

Market

Get market instances

1. Get all Market instances on Wildcat

import { getAllMarkets } from "@wildcatfi/wildcat-sdk";

const markets = getAllMarkets(provider);

2. Get all Market instances for borrower

const controller: MarketController = await getController(signer, borrower);
// controller.markets has an array of all Market instances for the controller

MarketAccount

Get MarketAccount

1. Get MarketAccount for every market

import { getAllMarketAccountsForLender } from "@wildcatfi/wildcat-sdk";
const accounts = await getAllMarketAccountsForLender(signer, lenderAddress);

Deposit

1. Get underlying assets from mock token

if (market.underlyingToken.isMock) {
  await market.underlyingToken.faucet();
}

Development

Whenever anything in ./gql or ./contracts is changed, run yarn codegen to regenerate the graphql and typechain types.

The graphql scripts take a while to run, so the graphql script saves a file in .gql-cache with the checksums of the previous input/output files from gql codegen, so the script can skip graphql codegen if there's no reason to. Typechain only takes about a second so we don't do the same for it.

This runs:

  • yarn codegen:gql - Generates TS types for all the graphql queries, then runs a script to simplify the type literals (gql-type-cleanup.js)
  • yarn codegen:typechain - Generates types for the contracts with typechain, then runs a script (add-typechain-exports.js) to add exports for all the structs in the contracts to the src/typechain index file
3.0.35

1 year ago

3.0.38

1 year ago

3.0.39

1 year ago

3.0.36

1 year ago

3.0.37

1 year ago

3.0.34

1 year ago

3.0.32

1 year ago

3.0.33

1 year ago

3.0.31

1 year ago

3.0.27

1 year ago

3.0.28

1 year ago

3.0.26

1 year ago

3.0.30

1 year ago

3.0.29

1 year ago

3.0.25

1 year ago

3.0.23

1 year ago

3.0.24

1 year ago

3.0.22

1 year ago

3.0.21

1 year ago

3.0.16

1 year ago

3.0.17

1 year ago

3.0.14

1 year ago

3.0.15

1 year ago

3.0.20

1 year ago

3.0.18

1 year ago

3.0.19

1 year ago

3.0.12

1 year ago

3.0.13

1 year ago

3.0.10

1 year ago

3.0.11

1 year ago

3.0.8

1 year ago

3.0.9

1 year ago

3.0.7

1 year ago

3.0.6

1 year ago

3.0.4

1 year ago

3.0.3

1 year ago

3.0.5

1 year ago

3.0.2

1 year ago

3.0.1

1 year ago

2.0.79

2 years ago

2.0.78

2 years ago

2.0.82

2 years ago

2.0.83

2 years ago

2.0.80

2 years ago

2.0.81

2 years ago

2.0.77

2 years ago

2.0.76

2 years ago

2.0.75

2 years ago

2.0.73

2 years ago

2.0.74

2 years ago

2.0.71

2 years ago

2.0.72

2 years ago

2.0.70

2 years ago

2.0.69

2 years ago

2.0.68

2 years ago

2.0.66

2 years ago

2.0.67

2 years ago

2.0.64

2 years ago

2.0.65

2 years ago

2.0.63

2 years ago

2.0.59

2 years ago

2.0.58

2 years ago

2.0.62

2 years ago

2.0.60

2 years ago

2.0.61

2 years ago

2.0.57

2 years ago

2.0.56

2 years ago

2.0.55

2 years ago

2.0.54

2 years ago

2.0.53

2 years ago

2.0.52

2 years ago

2.0.51

2 years ago

2.0.49

2 years ago

2.0.50

2 years ago

2.0.48

2 years ago

2.0.47

2 years ago

2.0.46

2 years ago

2.0.37

2 years ago

2.0.38

2 years ago

2.0.39

2 years ago

2.0.44

2 years ago

2.0.45

2 years ago

2.0.42

2 years ago

2.0.43

2 years ago

2.0.40

2 years ago

2.0.41

2 years ago

2.0.36

2 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

2.0.28

2 years ago

1.0.4

3 years ago

2.0.29

2 years ago

1.0.3

3 years ago

2.0.3

2 years ago

2.0.2

2 years ago

2.0.35

2 years ago

2.0.5

2 years ago

2.0.4

2 years ago

2.0.33

2 years ago

2.0.7

2 years ago

2.0.34

2 years ago

2.0.6

2 years ago

2.0.9

2 years ago

2.0.32

2 years ago

2.0.30

2 years ago

2.0.1

2 years ago

2.0.0

3 years ago

2.0.15

2 years ago

2.0.16

2 years ago

2.0.13

2 years ago

2.0.14

2 years ago

2.0.11

2 years ago

2.0.12

2 years ago

2.0.10

2 years ago

2.0.19

2 years ago

2.0.17

2 years ago

2.0.18

2 years ago

2.0.26

2 years ago

2.0.27

2 years ago

2.0.24

2 years ago

2.0.25

2 years ago

2.0.22

2 years ago

2.0.23

2 years ago

2.0.20

2 years ago

2.0.21

2 years ago

1.0.11

3 years ago

1.0.10

3 years ago

1.0.15

3 years ago

1.0.14

3 years ago

1.0.13

3 years ago

1.0.12

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago