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-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-02-01 03:23:43 +00:00
|
|
|
depositCollateralBorrowAndWithdraw
|
2022-01-31 21:04:27 +00:00
|
|
|
};
|