Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,16 @@ Let's take the `test_coin` package as an example:

- `README.md` description of the package, explain the usage of the package.

## Learn More About the Project with LLM

We recommend using [DeepWiki](https://deepwiki.com/scallop-io/sui-lending-protocol) to gain a deeper understanding of the project's architecture, core concepts, and implementation details.

## Use Scallop SDK to interact with the contracts

It's recommended to use the Scallop SDK to interact with the contracts, see the official documentation: [How to use Scallop SDK](https://github.com/scallop-io/sui-scallop-sdk)

or even generate demo code and transaction examples directly through [DeepWiki](https://deepwiki.com/scallop-io/sui-scallop-sdk) integrated LLM interface.

## Integrate with Scallop Protocol in SUI Move

The protocol is designed to be simple, efficient, and secure.
Expand Down
11 changes: 6 additions & 5 deletions mainnet-data-setup/add-new-pool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,20 @@ import { buildMultiSigTx } from './multi-sig';
import { BorrowLimits } from './borrow-limits';
import { suiKit } from 'sui-elements';
import { xOracleTxBuilder } from 'contracts/sui_x_oracle';
import { riskModels } from './risk-models';

async function addNewPool_haedal() {
async function addNewPool_haWal() {
const tx = new SuiTxBlock();
const coin = 'haedal';
const dustCoinId = '0xd63a0ac2bf7bc0a79e5b2bada85a9eb9b7e3e88a1a8c6b8b692b86bd4d168ecb'; // This is used to keep a minimum amount of the coin in the pool
const coin = 'haWal';
const dustCoinId = '0xd4be5cdd137a8b26a03c46de227d188c1e385edddf3743e465fc453323e0763e'; // This is used to keep a minimum amount of the coin in the pool
const coinType = coinTypes[coin];
protocolTxBuilder.addInterestModel(tx, interestModels[coin], coinType);
protocolTxBuilder.addRiskModel(tx, riskModels[coin], coinType);
protocolTxBuilder.addLimiter(tx, outflowRateLimiters[coin], coinType);
protocolTxBuilder.setSupplyLimit(tx, SupplyLimits[coin], coinType);
protocolTxBuilder.setBorrowLimit(tx, BorrowLimits[coin], coinType);
protocolTxBuilder.updateBorrowFee(tx, borrowFees[coin], coinType);
protocolTxBuilder.setFlashloanFee(tx, FlashloanFees[coin], coinType);
protocolTxBuilder.updateIsolatedAssetStatus(tx, true, coinType);

pythRuleTxBuilder.registerPythFeed(tx, oracles[coin].pythPriceObjectId, pythRuleTxBuilder.calculatePriceConfidenceTolerance(2), coinType);
xOracleTxBuilder.addPrimaryPriceUpdateRuleV2(tx, coinType, pythRuleStructType);
Expand All @@ -50,4 +51,4 @@ async function addNewPool_haedal() {
return txBytes;
}

addNewPool_haedal().then(console.log);
addNewPool_haWal().then(console.log);
2 changes: 2 additions & 0 deletions mainnet-data-setup/asset-oracles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,6 @@ export const oracles: Record<SupportedBaseAssets | SupportedCollaterals, OracleD
usdy: { pythPriceObjectId: pythOracleData.priceFeeds.usdy_rr_usd.priceFeedObjectId },
wal: { pythPriceObjectId: pythOracleData.priceFeeds.wal_usd.priceFeedObjectId },
haedal: { pythPriceObjectId: pythOracleData.priceFeeds.haedal_usd.priceFeedObjectId },
wWal: { pythPriceObjectId: pythOracleData.priceFeeds.wal_usd.priceFeedObjectId },
haWal: { pythPriceObjectId: pythOracleData.priceFeeds.wal_usd.priceFeedObjectId },
};
2 changes: 2 additions & 0 deletions mainnet-data-setup/borrow-fee.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,6 @@ export const borrowFees: Record<SupportedBaseAssets, BorrowFee> = {
usdy: { numerator: 3, denominator: 1000 },
wal: { numerator: 10, denominator: 1000 },
haedal: { numerator: 10, denominator: 1000 },
wWal: { numerator: 10, denominator: 1000 },
haWal: { numerator: 10, denominator: 1000 },
}
6 changes: 4 additions & 2 deletions mainnet-data-setup/borrow-limits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@ export const BorrowLimits: Record<SupportedBaseAssets, number> = {
nativeUsdc: 5e7 * Math.pow(10, coinDecimals.nativeUsdc),
sbEth: 5e3 * Math.pow(10, coinDecimals.sbEth),
deep: 180_000_000 * Math.pow(10, coinDecimals.deep),
fud: 2_400_000_000_000 * Math.pow(10, coinDecimals.fud),
fud: 0 * Math.pow(10, coinDecimals.fud),
fdusd: 5e6 * Math.pow(10, coinDecimals.fdusd), // 5M
sbUsdt: 1e7 * Math.pow(10, coinDecimals.sbUsdt),
blub: 24e12 * Math.pow(10, coinDecimals.blub), // 24T
blub: 0 * Math.pow(10, coinDecimals.blub),
mUsd: 2e6 * Math.pow(10, coinDecimals.mUsd), // 2M
ns: 5e6 * Math.pow(10, coinDecimals.ns), // 5M
usdy: 5e6 * Math.pow(10, coinDecimals.usdy), // 5M
wal: 18_000_000 * Math.pow(10, coinDecimals.wal), // 18M
haedal: 5_000_000 * Math.pow(10, coinDecimals.haedal), // 5M
wWal: 8_000_000 * Math.pow(10, coinDecimals.wWal), // 8M
haWal: 8_000_000 * Math.pow(10, coinDecimals.haWal), // 8M
}
11 changes: 11 additions & 0 deletions mainnet-data-setup/chain-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ export type SupportedCollaterals =
| 'usdy'
| 'wal'
| 'deep'
| 'haedal'
| 'wWal'
| 'haWal'
;

export type SupportedBaseAssets =
Expand Down Expand Up @@ -47,6 +50,8 @@ export type SupportedBaseAssets =
| 'usdy'
| 'wal'
| 'haedal'
| 'wWal'
| 'haWal'
;

export const coinTypes = {
Expand Down Expand Up @@ -75,6 +80,8 @@ export const coinTypes = {
usdy: '0x960b531667636f39e85867775f52f6b1f220a058c4de786905bdf761e06a56bb::usdy::USDY',
wal: '0x356a26eb9e012a68958082340d4c4116e7f55615cf27affcff209cf0ae544f59::wal::WAL',
haedal: '0x3a304c7feba2d819ea57c3542d68439ca2c386ba02159c740f7b406e592c62ea::haedal::HAEDAL',
wWal: '0xb1b0650a8862e30e3f604fd6c5838bc25464b8d3d827fbd58af7cb9685b832bf::wwal::WWAL',
haWal: '0x8b4d553839b219c3fd47608a0cc3d5fcc572cb25d41b7df3833208586a8d2470::hawal::HAWAL',
};

export const coinMetadataIds = {
Expand Down Expand Up @@ -103,6 +110,8 @@ export const coinMetadataIds = {
usdy: '0xd8dd6cf839e2367de6e6107da4b4361f44798dd6cf26d094058d94e4cee25e36',
wal: '0xcf8a31804ae40cb3e7183fe57320f87467a7750d4fa701bca1ffbb1edd37781e',
haedal: '0xcc89fcc22f0d13de3688b94fa16d64a22079186a941914280c67101ff754263c',
wWal: '0xb99b3755f138d5a56b3bbc1b9cc19ed7da9be82c79844b39ff84d5c438ee5c40',
haWal: '0x285c96e598e2861a898eff9331a5ffeb9e2199cdb02f6ba52f311b0fab5c47cf',
};

export const coinDecimals = {
Expand Down Expand Up @@ -131,4 +140,6 @@ export const coinDecimals = {
usdy: 6,
wal: 9,
haedal: 9,
wWal: 9,
haWal: 9,
}
2 changes: 2 additions & 0 deletions mainnet-data-setup/flashloan-fees.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,6 @@ export const FlashloanFees: Record<SupportedBaseAssets, number> = {
usdy: 10,
wal: 10,
haedal: 10,
wWal: 10,
haWal: 10,
}
68 changes: 52 additions & 16 deletions mainnet-data-setup/interest-models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export const wormholeUsdtInterestModel: InterestModel = {
midKink, // 80%
highKink, // 90%

revenueFactor: 30 * (scale / 100), // 30%
revenueFactor: 20 * (scale / 100), // 20%
borrowWeight, // 1
scale,
minBorrowAmount: 10 ** (coinDecimals.wormholeUsdt - 2), // 0.01 USDT
Expand Down Expand Up @@ -228,10 +228,10 @@ export const nativeUsdcInterestModel: InterestModel = {
borrowRateOnHighKink: getRatePerSec(25), // 25%
maxBorrowRate: getRatePerSec(150), // 150%

midKink, // 80%
highKink, // 90%
midKink: 85 * (scale / 100), // 85%
highKink: 95 * (scale / 100), // 95%

revenueFactor: 30 * (scale / 100), // 30%
revenueFactor: 20 * (scale / 100), // 20%
borrowWeight, // 1
scale,
minBorrowAmount: 10 ** (coinDecimals.nativeUsdc - 2), // 0.01 USDC
Expand Down Expand Up @@ -265,7 +265,7 @@ export const deepInterestModel: InterestModel = {
midKink, // 80%
highKink, // 90%

revenueFactor: 40 * (scale / 100), // 40%
revenueFactor: 30 * (scale / 100), // 30%
borrowWeight, // 1
scale,
minBorrowAmount: 10 ** (coinDecimals.deep + 1), // 10 DEEP
Expand Down Expand Up @@ -296,10 +296,10 @@ export const fdusdInterestModel: InterestModel = {
borrowRateOnHighKink: getRatePerSec(25), // 25%
maxBorrowRate: getRatePerSec(150), // 150%

midKink, // 80%
highKink, // 90%
midKink: 85 * (scale / 100), // 85%
highKink: 95 * (scale / 100), // 95%

revenueFactor: 30 * (scale / 100), // 30%
revenueFactor: 20 * (scale / 100), // 20%
borrowWeight, // 1
scale,
minBorrowAmount: 10 ** (coinDecimals.fdusd - 2), // 0.01 FDUSD
Expand All @@ -313,10 +313,10 @@ export const sbUsdtInterestModel: InterestModel = {
borrowRateOnHighKink: getRatePerSec(25), // 25%
maxBorrowRate: getRatePerSec(150), // 150%

midKink, // 80%
highKink, // 90%
midKink: 85 * (scale / 100), // 85%
highKink: 95 * (scale / 100), // 95%

revenueFactor: 30 * (scale / 100), // 30%
revenueFactor: 20 * (scale / 100), // 20%
borrowWeight, // 1
scale,
minBorrowAmount: 10 ** (coinDecimals.sbUsdt - 2), // 0.01 USDT
Expand Down Expand Up @@ -347,10 +347,10 @@ export const usdyInterestModel: InterestModel = {
borrowRateOnHighKink: getRatePerSec(25), // 25%
maxBorrowRate: getRatePerSec(150), // 150%

midKink, // 80%
highKink, // 90%
midKink: 85 * (scale / 100), // 85%
highKink: 95 * (scale / 100), // 95%

revenueFactor: 30 * (scale / 100), // 30%
revenueFactor: 20 * (scale / 100), // 20%
borrowWeight, // 1
scale,
minBorrowAmount: 10 ** (coinDecimals.usdy - 2), // 0.01 USDY
Expand Down Expand Up @@ -402,7 +402,7 @@ export const haedalInterestModel: InterestModel = {
highKink, // 90%

revenueFactor: 40 * (scale / 100), // 40%
borrowWeight: (scale * 1.25), // 125%
borrowWeight, // 100%
scale,
minBorrowAmount: 10 ** (coinDecimals.haedal - 1), // 0.1 NS
};
Expand All @@ -418,12 +418,46 @@ export const walInterestModel: InterestModel = {
midKink, // 80%
highKink, // 90%

revenueFactor: 40 * (scale / 100), // 40%
revenueFactor: 30 * (scale / 100), // 30%
borrowWeight, // 1
scale,
minBorrowAmount: 10 ** (coinDecimals.wal - 2), // 0.01 WAL
};

export const wWalInterestModel: InterestModel = {
baseBorrowRatePerSec: getRatePerSec(20),
interestRateScale,

borrowRateOnMidKink: getRatePerSec(30), // 30%
borrowRateOnHighKink: getRatePerSec(50), // 50%
maxBorrowRate: getRatePerSec(600), // 600%

midKink, // 80%
highKink, // 90%

revenueFactor: 30 * (scale / 100), // 30%
borrowWeight, // 1
scale,
minBorrowAmount: 10 ** (coinDecimals.wWal - 2), // 0.01 wWAL
};

export const haWalInterestModel: InterestModel = {
baseBorrowRatePerSec: getRatePerSec(20),
interestRateScale,

borrowRateOnMidKink: getRatePerSec(30), // 30%
borrowRateOnHighKink: getRatePerSec(50), // 50%
maxBorrowRate: getRatePerSec(600), // 600%

midKink, // 80%
highKink, // 90%

revenueFactor: 30 * (scale / 100), // 30%
borrowWeight, // 1
scale,
minBorrowAmount: 10 ** (coinDecimals.haWal - 2), // 0.01 haWAL
};

export const interestModels: Record<SupportedBaseAssets, InterestModel> = {
sui: suiInterestModel,
sca: scaInterestModel,
Expand All @@ -449,4 +483,6 @@ export const interestModels: Record<SupportedBaseAssets, InterestModel> = {
usdy: usdyInterestModel,
wal: walInterestModel,
haedal: haedalInterestModel,
wWal: wWalInterestModel,
haWal: haWalInterestModel,
}
35 changes: 23 additions & 12 deletions mainnet-data-setup/outflow-rate-limiters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@ const outflowSegmentDuration = 60 * 30 // 30 minutes

export const outflowRateLimiters: Record<SupportedBaseAssets, OutflowLimiterModel> = {
sui: {
outflowLimit: 3 * 10 ** (6 + coinDecimals.sui), // 3 million SUI per day
outflowLimit: 1 * 10 ** (6 + coinDecimals.sui), // 1 million SUI per day
outflowCycleDuration,
outflowSegmentDuration,
},
afSui: {
outflowLimit: 10 ** (5 + coinDecimals.afSui), // 100k afSUI per day
outflowLimit: 5_000 * 10 ** (coinDecimals.afSui), // 5k afSUI per day
outflowCycleDuration,
outflowSegmentDuration,
},
haSui: {
outflowLimit: 10 ** (5 + coinDecimals.haSui), // 100K haSUI per day
outflowLimit: 5_000 * 10 ** (coinDecimals.haSui), // 5k haSUI per day
outflowCycleDuration,
outflowSegmentDuration,
},
Expand All @@ -34,7 +34,7 @@ export const outflowRateLimiters: Record<SupportedBaseAssets, OutflowLimiterMode
outflowSegmentDuration,
},
cetus: {
outflowLimit: 10 ** (6 + coinDecimals.cetus), // 1 million CETUS per day
outflowLimit: 5 * 10 ** (5 + coinDecimals.cetus), // 500k CETUS per day
outflowCycleDuration,
outflowSegmentDuration,
},
Expand All @@ -59,12 +59,12 @@ export const outflowRateLimiters: Record<SupportedBaseAssets, OutflowLimiterMode
outflowSegmentDuration,
},
sbwBTC: {
outflowLimit: 2 * 10 ** (0 + coinDecimals.sbwBTC), // 2 BTC per day
outflowLimit: 1 * 10 ** (0 + coinDecimals.sbwBTC), // 1 BTC per day
outflowCycleDuration,
outflowSegmentDuration,
},
wormholeSol: {
outflowLimit: 1 * 10 ** (3 + coinDecimals.wormholeSol), // 1000 SOL per day
outflowLimit: 1 * 10 ** (2 + coinDecimals.wormholeSol), // 100 SOL per day
outflowCycleDuration,
outflowSegmentDuration,
},
Expand All @@ -74,12 +74,12 @@ export const outflowRateLimiters: Record<SupportedBaseAssets, OutflowLimiterMode
outflowSegmentDuration,
},
sbEth: {
outflowLimit: 25 * 10 ** (1 + coinDecimals.sbEth), // 250 ETH per day
outflowLimit: 50 * 10 ** (coinDecimals.sbEth), // 50 ETH per day
outflowCycleDuration,
outflowSegmentDuration,
},
deep: {
outflowLimit: 20 * 10 ** (6 + coinDecimals.deep), // 20M DEEP per day
outflowLimit: 5 * 10 ** (6 + coinDecimals.deep), // 5M DEEP per day
outflowCycleDuration,
outflowSegmentDuration,
},
Expand All @@ -94,7 +94,7 @@ export const outflowRateLimiters: Record<SupportedBaseAssets, OutflowLimiterMode
outflowSegmentDuration,
},
mUsd: {
outflowLimit: 5 * 10 ** (5 + coinDecimals.mUsd), // 500k MUSD per day
outflowLimit: 5 * 10 ** (4 + coinDecimals.mUsd), // 50k MUSD per day
outflowCycleDuration,
outflowSegmentDuration,
},
Expand All @@ -114,7 +114,7 @@ export const outflowRateLimiters: Record<SupportedBaseAssets, OutflowLimiterMode
outflowSegmentDuration,
},
ns: {
outflowLimit: 5 * 10 ** (5 + coinDecimals.ns), // 500k NS per day
outflowLimit: 1 * 10 ** (5 + coinDecimals.ns), // 100k NS per day
outflowCycleDuration,
outflowSegmentDuration,
},
Expand All @@ -124,8 +124,19 @@ export const outflowRateLimiters: Record<SupportedBaseAssets, OutflowLimiterMode
outflowSegmentDuration,
},
haedal: {
outflowLimit: 5 * 10 ** (6 + coinDecimals.haedal), // 5M HAEDAL per day
outflowLimit: 5 * 10 ** (5 + coinDecimals.haedal), // 500k HAEDAL per day
outflowCycleDuration,
outflowSegmentDuration,
},
},
wWal: {
outflowLimit: 10_000 * 10 ** (coinDecimals.wWal), // 10k wWAL per day
outflowCycleDuration,
outflowSegmentDuration,
},
haWal: {
outflowLimit: 10_000 * 10 ** (coinDecimals.haWal), // 10k haWAL per day
outflowCycleDuration,
outflowSegmentDuration,
},

}
Loading