2022-02-02 18:22:30 +00:00
|
|
|
import { BigNumber } from "ethers";
|
|
|
|
import { encodeSpells } from "../../../scripts/tests/encodeSpells"
|
|
|
|
|
|
|
|
const depositCollteral = async (
|
|
|
|
dsa: any,
|
|
|
|
authority: any,
|
|
|
|
referrer: any,
|
|
|
|
currencyId: number,
|
|
|
|
amount: BigNumber,
|
|
|
|
underlying: boolean
|
|
|
|
) => {
|
2022-01-31 21:04:27 +00:00
|
|
|
const spells = [
|
|
|
|
{
|
|
|
|
connector: "NOTIONAL-TEST-A",
|
|
|
|
method: "depositCollateral",
|
|
|
|
args: [currencyId, underlying, amount, 0, 0]
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
|
|
|
const tx = await dsa.connect(authority).cast(...encodeSpells(spells), referrer.address);
|
|
|
|
await tx.wait()
|
|
|
|
};
|
|
|
|
|
2022-02-02 18:22:30 +00:00
|
|
|
const depositAndMintNToken = async (
|
|
|
|
dsa: any,
|
|
|
|
authority: any,
|
|
|
|
referrer: any,
|
|
|
|
currencyId: number,
|
|
|
|
amount: BigNumber,
|
|
|
|
underlying: boolean
|
|
|
|
) => {
|
2022-01-31 21:04:27 +00:00
|
|
|
const spells = [
|
|
|
|
{
|
|
|
|
connector: "NOTIONAL-TEST-A",
|
|
|
|
method: "depositAndMintNToken",
|
|
|
|
args: [currencyId, amount, underlying, 0, 0]
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
|
|
|
const tx = await dsa.connect(authority).cast(...encodeSpells(spells), referrer.address);
|
|
|
|
await tx.wait()
|
|
|
|
}
|
|
|
|
|
2022-02-02 18:22:30 +00:00
|
|
|
const depositAndLend = async (
|
|
|
|
dsa: any,
|
|
|
|
authority: any,
|
|
|
|
referrer: any,
|
|
|
|
currencyId: number,
|
|
|
|
underlying: boolean,
|
|
|
|
amount: BigNumber,
|
|
|
|
market: number,
|
|
|
|
fcash: BigNumber
|
|
|
|
) => {
|
2022-01-31 21:04:27 +00:00
|
|
|
const spells = [
|
|
|
|
{
|
|
|
|
connector: "NOTIONAL-TEST-A",
|
|
|
|
method: "depositAndLend",
|
2022-02-02 18:22:30 +00:00
|
|
|
args: [currencyId, amount, underlying, market, fcash, 0, 0]
|
2022-01-31 21:04:27 +00:00
|
|
|
}
|
|
|
|
];
|
|
|
|
|
|
|
|
const tx = await dsa.connect(authority).cast(...encodeSpells(spells), referrer.address);
|
2022-02-02 18:22:30 +00:00
|
|
|
await tx.wait()
|
2022-01-31 21:04:27 +00:00
|
|
|
};
|
|
|
|
|
2022-02-02 18:22:30 +00:00
|
|
|
const withdrawCollateral = async (
|
|
|
|
dsa: any,
|
|
|
|
authority: any,
|
|
|
|
referrer: any,
|
|
|
|
currencyId: number,
|
|
|
|
amount: BigNumber,
|
|
|
|
underlying: boolean
|
|
|
|
) => {
|
2022-01-31 21:04:27 +00:00
|
|
|
const spells = [
|
|
|
|
{
|
|
|
|
connector: "NOTIONAL-TEST-A",
|
|
|
|
method: "withdrawCollateral",
|
|
|
|
args: [currencyId, underlying, amount, 0, 0]
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
|
|
|
const tx = await dsa.connect(authority).cast(...encodeSpells(spells), referrer.address);
|
|
|
|
await tx.wait()
|
|
|
|
};
|
|
|
|
|
2022-02-02 18:22:30 +00:00
|
|
|
const redeemNTokenRaw = async (
|
|
|
|
dsa: any,
|
|
|
|
authority: any,
|
|
|
|
referrer: any,
|
|
|
|
currencyId: number,
|
|
|
|
sellTokenAssets: boolean,
|
|
|
|
tokensToRedeem: BigNumber
|
|
|
|
) => {
|
2022-01-31 21:04:27 +00:00
|
|
|
const spells = [
|
|
|
|
{
|
|
|
|
connector: "NOTIONAL-TEST-A",
|
|
|
|
method: "redeemNTokenRaw",
|
2022-03-31 15:27:31 +00:00
|
|
|
args: [currencyId, sellTokenAssets, tokensToRedeem, false, 0, 0]
|
2022-01-31 21:04:27 +00:00
|
|
|
}
|
|
|
|
];
|
|
|
|
|
|
|
|
const tx = await dsa.connect(authority).cast(...encodeSpells(spells), referrer.address);
|
|
|
|
await tx.wait()
|
|
|
|
};
|
|
|
|
|
2022-02-02 18:22:30 +00:00
|
|
|
const redeemNTokenAndWithdraw = async (
|
|
|
|
dsa: any,
|
|
|
|
authority: any,
|
|
|
|
referrer: any,
|
|
|
|
currencyId: number,
|
|
|
|
tokensToRedeem: BigNumber,
|
|
|
|
amountToWithdraw: BigNumber,
|
|
|
|
redeemToUnderlying: boolean
|
|
|
|
) => {
|
2022-01-31 21:04:27 +00:00
|
|
|
const spells = [
|
|
|
|
{
|
|
|
|
connector: "NOTIONAL-TEST-A",
|
|
|
|
method: "redeemNTokenAndWithdraw",
|
|
|
|
args: [currencyId, tokensToRedeem, amountToWithdraw, redeemToUnderlying, 0, 0]
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
|
|
|
const tx = await dsa.connect(authority).cast(...encodeSpells(spells), referrer.address);
|
|
|
|
await tx.wait()
|
|
|
|
};
|
|
|
|
|
2022-02-02 18:22:30 +00:00
|
|
|
const redeemNTokenAndDeleverage = async (
|
|
|
|
dsa: any,
|
|
|
|
authority: any,
|
|
|
|
referrer: any,
|
|
|
|
currencyId: number,
|
|
|
|
tokensToRedeem: BigNumber,
|
|
|
|
marketIndex: number,
|
|
|
|
fCashAmount: BigNumber
|
|
|
|
) => {
|
2022-01-31 21:04:27 +00:00
|
|
|
const spells = [
|
|
|
|
{
|
|
|
|
connector: "NOTIONAL-TEST-A",
|
|
|
|
method: "redeemNTokenAndDeleverage",
|
2022-02-02 18:22:30 +00:00
|
|
|
args: [currencyId, tokensToRedeem, marketIndex, fCashAmount, 0, 0]
|
2022-01-31 21:04:27 +00:00
|
|
|
}
|
|
|
|
];
|
|
|
|
|
|
|
|
const tx = await dsa.connect(authority).cast(...encodeSpells(spells), referrer.address);
|
|
|
|
await tx.wait()
|
|
|
|
};
|
|
|
|
|
|
|
|
const depositCollateralBorrowAndWithdraw = async (
|
2022-02-02 18:22:30 +00:00
|
|
|
dsa: any,
|
|
|
|
authority: any,
|
|
|
|
referrer: any,
|
|
|
|
depositCurrencyId: number,
|
|
|
|
depositType: number,
|
|
|
|
depositAmount: BigNumber,
|
|
|
|
borrowCurrencyId: number,
|
|
|
|
marketIndex: number,
|
|
|
|
fCashAmount: BigNumber,
|
|
|
|
redeedmUnderlying: boolean
|
2022-01-31 21:04:27 +00:00
|
|
|
) => {
|
|
|
|
const spells = [
|
|
|
|
{
|
|
|
|
connector: "NOTIONAL-TEST-A",
|
|
|
|
method: "depositCollateralBorrowAndWithdraw",
|
|
|
|
args: [
|
|
|
|
depositCurrencyId,
|
2022-02-02 18:22:30 +00:00
|
|
|
depositType,
|
2022-01-31 21:04:27 +00:00
|
|
|
depositAmount,
|
|
|
|
borrowCurrencyId,
|
|
|
|
marketIndex,
|
|
|
|
fCashAmount,
|
2022-02-02 18:22:30 +00:00
|
|
|
0,
|
2022-01-31 21:04:27 +00:00
|
|
|
redeedmUnderlying,
|
|
|
|
0,
|
|
|
|
0
|
|
|
|
]
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
|
|
|
const tx = await dsa.connect(authority).cast(...encodeSpells(spells), referrer.address);
|
|
|
|
await tx.wait()
|
|
|
|
};
|
|
|
|
|
2022-02-02 18:22:30 +00:00
|
|
|
const withdrawLend = async (
|
|
|
|
dsa: any,
|
|
|
|
authority: any,
|
|
|
|
referrer: any,
|
|
|
|
currencyId: number,
|
|
|
|
marketIndex: number,
|
|
|
|
fCashAmount: BigNumber
|
|
|
|
) => {
|
2022-01-31 21:04:27 +00:00
|
|
|
const spells = [
|
|
|
|
{
|
|
|
|
connector: "NOTIONAL-TEST-A",
|
|
|
|
method: "withdrawLend",
|
2022-02-02 18:22:30 +00:00
|
|
|
args: [currencyId, marketIndex, fCashAmount, 0, 0]
|
2022-01-31 21:04:27 +00:00
|
|
|
}
|
|
|
|
];
|
|
|
|
|
|
|
|
const tx = await dsa.connect(authority).cast(...encodeSpells(spells), referrer.address);
|
|
|
|
await tx.wait()
|
|
|
|
};
|
|
|
|
|
2022-04-11 18:37:10 +00:00
|
|
|
const mintSNoteFromETH = async (
|
|
|
|
dsa: any,
|
|
|
|
authority: any,
|
|
|
|
referrer: any,
|
|
|
|
noteAmount: BigNumber,
|
|
|
|
ethAmount: BigNumber,
|
|
|
|
minBPT: BigNumber
|
|
|
|
) => {
|
|
|
|
const spells = [
|
|
|
|
{
|
|
|
|
connector: "NOTIONAL-TEST-A",
|
|
|
|
method: "mintSNoteFromETH",
|
2022-04-14 04:01:59 +00:00
|
|
|
args: [noteAmount, ethAmount, minBPT, 0]
|
2022-04-11 18:37:10 +00:00
|
|
|
}
|
|
|
|
]
|
|
|
|
|
|
|
|
const tx = await dsa.connect(authority).cast(...encodeSpells(spells), referrer.address);
|
|
|
|
await tx.wait()
|
|
|
|
}
|
|
|
|
|
|
|
|
const mintSNoteFromWETH = async (
|
|
|
|
dsa: any,
|
|
|
|
authority: any,
|
|
|
|
referrer: any,
|
|
|
|
noteAmount: BigNumber,
|
|
|
|
wethAmount: BigNumber,
|
|
|
|
minBPT: BigNumber
|
|
|
|
) => {
|
|
|
|
const spells = [
|
|
|
|
{
|
|
|
|
connector: "NOTIONAL-TEST-A",
|
|
|
|
method: "mintSNoteFromWETH",
|
2022-04-14 04:01:59 +00:00
|
|
|
args: [noteAmount, wethAmount, minBPT, 0]
|
2022-04-11 18:37:10 +00:00
|
|
|
}
|
|
|
|
]
|
|
|
|
|
|
|
|
const tx = await dsa.connect(authority).cast(...encodeSpells(spells), referrer.address);
|
|
|
|
await tx.wait()
|
|
|
|
}
|
|
|
|
|
|
|
|
const mintSNoteFromBPT = async (
|
|
|
|
dsa: any,
|
|
|
|
authority: any,
|
|
|
|
referrer: any,
|
|
|
|
bptAmount: BigNumber
|
|
|
|
) => {
|
|
|
|
const spells = [
|
|
|
|
{
|
|
|
|
connector: "NOTIONAL-TEST-A",
|
|
|
|
method: "mintSNoteFromBPT",
|
|
|
|
args: [bptAmount]
|
|
|
|
}
|
|
|
|
]
|
|
|
|
|
|
|
|
const tx = await dsa.connect(authority).cast(...encodeSpells(spells), referrer.address);
|
|
|
|
await tx.wait()
|
|
|
|
}
|
|
|
|
|
|
|
|
const startCoolDown = async (
|
|
|
|
dsa: any,
|
|
|
|
authority: any,
|
|
|
|
referrer: any
|
|
|
|
) => {
|
|
|
|
const spells = [
|
|
|
|
{
|
|
|
|
connector: "NOTIONAL-TEST-A",
|
|
|
|
method: "startCoolDown",
|
|
|
|
args: []
|
|
|
|
}
|
|
|
|
]
|
|
|
|
|
|
|
|
const tx = await dsa.connect(authority).cast(...encodeSpells(spells), referrer.address);
|
|
|
|
await tx.wait()
|
|
|
|
}
|
|
|
|
|
|
|
|
const stopCoolDown = async (
|
|
|
|
dsa: any,
|
|
|
|
authority: any,
|
|
|
|
referrer: any
|
|
|
|
) => {
|
|
|
|
const spells = [
|
|
|
|
{
|
|
|
|
connector: "NOTIONAL-TEST-A",
|
|
|
|
method: "stopCoolDown",
|
|
|
|
args: []
|
|
|
|
}
|
|
|
|
]
|
|
|
|
|
|
|
|
const tx = await dsa.connect(authority).cast(...encodeSpells(spells), referrer.address);
|
|
|
|
await tx.wait()
|
|
|
|
}
|
|
|
|
|
|
|
|
const redeemSNote = async (
|
|
|
|
dsa: any,
|
|
|
|
authority: any,
|
|
|
|
referrer: any,
|
|
|
|
sNOTEAmount: BigNumber,
|
|
|
|
minWETH: BigNumber,
|
|
|
|
minNOTE: BigNumber,
|
|
|
|
redeemWETH: boolean
|
|
|
|
) => {
|
|
|
|
const spells = [
|
|
|
|
{
|
|
|
|
connector: "NOTIONAL-TEST-A",
|
|
|
|
method: "redeemSNote",
|
|
|
|
args: [sNOTEAmount, minWETH, minNOTE, redeemWETH]
|
|
|
|
}
|
|
|
|
]
|
|
|
|
|
|
|
|
const tx = await dsa.connect(authority).cast(...encodeSpells(spells), referrer.address);
|
|
|
|
await tx.wait()
|
|
|
|
}
|
|
|
|
|
2022-02-02 18:22:30 +00:00
|
|
|
export default {
|
2022-01-31 21:04:27 +00:00
|
|
|
depositCollteral,
|
|
|
|
depositAndMintNToken,
|
|
|
|
depositAndLend,
|
|
|
|
withdrawCollateral,
|
|
|
|
withdrawLend,
|
|
|
|
redeemNTokenRaw,
|
|
|
|
redeemNTokenAndWithdraw,
|
|
|
|
redeemNTokenAndDeleverage,
|
2022-04-11 18:37:10 +00:00
|
|
|
depositCollateralBorrowAndWithdraw,
|
|
|
|
mintSNoteFromETH,
|
|
|
|
mintSNoteFromWETH,
|
|
|
|
mintSNoteFromBPT,
|
|
|
|
startCoolDown,
|
|
|
|
stopCoolDown,
|
|
|
|
redeemSNote
|
2022-01-31 21:04:27 +00:00
|
|
|
};
|